diff --git a/wax-prosemirror-core/src/config/plugins/FakeCursorPlugin.js b/wax-prosemirror-core/src/config/plugins/FakeCursorPlugin.js index c53bd01f9b55a17a5466f46a0c381f82f7e0a8f1..b4cb4734a38afa1c6c6411d16fac369ea8a30316 100644 --- a/wax-prosemirror-core/src/config/plugins/FakeCursorPlugin.js +++ b/wax-prosemirror-core/src/config/plugins/FakeCursorPlugin.js @@ -11,27 +11,34 @@ export default props => { init: (_, state) => {}, apply(tr, prev, _, newState) { let createDecoration; - const widget = document.createElement('span'); - widget.setAttribute('id', 'fake-cursor'); - if (newState.selection.from === newState.selection.to) { - createDecoration = DecorationSet.create(newState.doc, [ - Decoration.widget(newState.selection.from, widget, { - key: 'fakecursor', - }), - ]); - } - setTimeout(() => { - widget.setAttribute('contenteditable', true); - if ( - navigator.userAgent.includes('Firefox') && - newState.selection.$from.nodeBefore === null - ) { - widget.setAttribute('style', 'visibility:hidden'); - } else { - widget.setAttribute('style', 'display:none'); + if ( + tr.steps.length === 0 || + (tr.steps[0] && tr.steps[0].from === tr.steps[0].to) + ) { + const widget = document.createElement('span'); + widget.setAttribute('id', 'fake-cursor'); + + if (newState.selection.from === newState.selection.to) { + createDecoration = DecorationSet.create(newState.doc, [ + Decoration.widget(newState.selection.from, widget, { + key: 'fakecursor', + }), + ]); } - }); + setTimeout(() => { + widget.setAttribute('contenteditable', true); + if ( + navigator.userAgent.includes('Firefox') && + newState.selection.$from.nodeBefore === null + ) { + widget.setAttribute('style', 'visibility:hidden'); + } else { + widget.setAttribute('style', 'display:none'); + } + }); + } + return { createDecoration, }; diff --git a/wax-prosemirror-core/src/styles/styles.css b/wax-prosemirror-core/src/styles/styles.css index 802fced80c1a51aabdad7269415c4118d3472573..c8a9e456b75af535c5c32727e1d0302c50952817 100644 --- a/wax-prosemirror-core/src/styles/styles.css +++ b/wax-prosemirror-core/src/styles/styles.css @@ -235,7 +235,7 @@ img.ProseMirror-separator { } span#fake-cursor::before { - display: inline; + display: inline-flex; content: ''; border-right: 1px solid black; height: 23px;