mirror of
https://github.com/heyman/heynote.git
synced 2025-06-20 09:37:50 +02:00
Fix issue where auto detected language would not get emitted to the status bar immediately on language change, if the cursor wasn't changed at the same time
This commit is contained in:
parent
7a74798a11
commit
6a53168b05
@ -220,7 +220,6 @@ const blockLayer = layer({
|
|||||||
|
|
||||||
|
|
||||||
const preventFirstBlockFromBeingDeleted = EditorState.changeFilter.of((tr) => {
|
const preventFirstBlockFromBeingDeleted = EditorState.changeFilter.of((tr) => {
|
||||||
//console.log("annotations:", tr.annotation(heynoteEvent), tr.annotations.some(a => tr.annotation(heynoteEvent)))
|
|
||||||
if (!tr.annotations.some(a => a.type === heynoteEvent) && firstBlockDelimiterSize) {
|
if (!tr.annotations.some(a => a.type === heynoteEvent) && firstBlockDelimiterSize) {
|
||||||
return [0, firstBlockDelimiterSize]
|
return [0, firstBlockDelimiterSize]
|
||||||
}
|
}
|
||||||
@ -276,7 +275,10 @@ const blockLineNumbers = lineNumbers({
|
|||||||
const emitCursorChange = (element) => ViewPlugin.fromClass(
|
const emitCursorChange = (element) => ViewPlugin.fromClass(
|
||||||
class {
|
class {
|
||||||
update(update) {
|
update(update) {
|
||||||
if (update.selectionSet) {
|
// if the selection changed or the language changed (can happen without selection change),
|
||||||
|
// emit a selection change event
|
||||||
|
const langChange = update.transactions.some(tr => tr.annotations.some(a => a.value == LANGUAGE_CHANGE))
|
||||||
|
if (update.selectionSet || langChange) {
|
||||||
const cursorLine = getBlockLineFromPos(update.state, update.state.selection.main.head)
|
const cursorLine = getBlockLineFromPos(update.state, update.state.selection.main.head)
|
||||||
const block = getActiveNoteBlock(update.state)
|
const block = getActiveNoteBlock(update.state)
|
||||||
element.dispatchEvent(new SelectionChangeEvent({
|
element.dispatchEvent(new SelectionChangeEvent({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user