diff --git a/src/muya/lib/eventHandler/clickEvent.js b/src/muya/lib/eventHandler/clickEvent.js index bc582128..c2e76879 100644 --- a/src/muya/lib/eventHandler/clickEvent.js +++ b/src/muya/lib/eventHandler/clickEvent.js @@ -18,21 +18,19 @@ class ClickEvent { // Hide format box eventCenter.dispatch('muya-format-picker', { reference: null }) - // Commit native cursor position because right-clicking doesn't update the cursor postion. const { start, end } = selection.getCursorRange() + + // Cursor out of editor if (!start || !end) { - // right click on paragraph icons return } - // if you want to show `insert row or column`, you need to put cursor on cell text... + + // Commit native cursor position because right-clicking doesn't update the cursor postion. contentState.cursor = { start, end } - // TODO: Should we render to update the cursor or is this not necessary because we'll render - // when leaving or clicking on the context menu? - const sectionChanges = contentState.selectionChange(contentState.cursor) eventCenter.dispatch('contextmenu', event, sectionChanges) } @@ -68,7 +66,7 @@ class ClickEvent { formatType: 'image', data: event.target.getAttribute('src') }) - selectionText(markedImageText) + selectionText(markedImageText) } else if (mathText) { selectionText(mathText) } else if (rubyText) { diff --git a/src/muya/lib/eventHandler/keyboard.js b/src/muya/lib/eventHandler/keyboard.js index 4356189f..dfd37377 100644 --- a/src/muya/lib/eventHandler/keyboard.js +++ b/src/muya/lib/eventHandler/keyboard.js @@ -62,10 +62,14 @@ class Keyboard { return } - // prevent dispatch `selectionChange` and `selectionFormats` by click the toolbar of table/html block and front icons + // Cursor outside editor area or over not editable elements. if (event.target.closest('[contenteditable=false]')) { return } + const { start, end } = selection.getCursorRange() + if (!start || !end) { + return + } if (timer) clearTimeout(timer) timer = setTimeout(() => { @@ -199,7 +203,7 @@ class Keyboard { if (!start || !end) { return } - + if ( !this.isComposed ) {