diff --git a/wax-prosemirror-core/src/WaxView.js b/wax-prosemirror-core/src/WaxView.js index f5998e3ec4e4c7dc7d89bd2d4cd9c3bca7b0ccf3..48d9862593a1681089a2f4b22d00cd2ec940f689 100644 --- a/wax-prosemirror-core/src/WaxView.js +++ b/wax-prosemirror-core/src/WaxView.js @@ -84,24 +84,6 @@ const WaxView = forwardRef((props, ref) => { attributes: { spellcheck: browserSpellCheck ? 'true' : 'false', }, - handleDOMEvents: { - blur: (editorView, event) => { - if (view && event.relatedTarget === null) { - view.focus(); - } else { - const fakeCursor = document.getElementsByTagName( - 'fakecursor', - ); - if (fakeCursor && fakeCursor[0]) - fakeCursor[0].style.display = 'inline'; - } - }, - focus: (editorView, event) => { - const fakeCursor = document.getElementsByTagName('fakecursor'); - if (fakeCursor && fakeCursor[0]) - fakeCursor[0].style.display = 'none'; - }, - }, }, ); diff --git a/wax-prosemirror-services/src/TablesService/plugins/FakeCursorPlugin.js b/wax-prosemirror-core/src/plugins/FakeCursorPlugin.js similarity index 66% rename from wax-prosemirror-services/src/TablesService/plugins/FakeCursorPlugin.js rename to wax-prosemirror-core/src/plugins/FakeCursorPlugin.js index e6770b617fc14383fa66967547198cccf65e6b4d..607ab2c58448cdd58da52e9d9b1f841b23f41ecf 100644 --- a/wax-prosemirror-services/src/TablesService/plugins/FakeCursorPlugin.js +++ b/wax-prosemirror-core/src/plugins/FakeCursorPlugin.js @@ -31,8 +31,19 @@ export default props => { return fakeCursorPluginState.createDecoration; }, handleDOMEvents: { - focus: (view, _event) => {}, - blur: (view, _event) => {}, + focus: (view, event) => { + const fakeCursor = document.getElementsByTagName('fakecursor'); + if (fakeCursor && fakeCursor[0]) fakeCursor[0].style.display = 'none'; + }, + blur: (view, event) => { + if (view && event.relatedTarget === null) { + view.focus(); + } else { + const fakeCursor = document.getElementsByTagName('fakecursor'); + if (fakeCursor && fakeCursor[0]) + fakeCursor[0].style.display = 'inline'; + } + }, }, }, }); diff --git a/wax-prosemirror-core/src/plugins/defaultPlugins.js b/wax-prosemirror-core/src/plugins/defaultPlugins.js index 88158c86b7cace5cf58ed3c872a94fc0fecc2f18..eb62279208e5fb8de8a9a2f915ad7457d3b941c7 100644 --- a/wax-prosemirror-core/src/plugins/defaultPlugins.js +++ b/wax-prosemirror-core/src/plugins/defaultPlugins.js @@ -1,5 +1,6 @@ import { history } from 'prosemirror-history'; import { dropCursor } from 'prosemirror-dropcursor'; import { gapCursor } from 'prosemirror-gapcursor'; +import FakeCursorPlugin from './FakeCursorPlugin'; -export default [dropCursor(), gapCursor(), history()]; +export default [dropCursor(), gapCursor(), history(), FakeCursorPlugin()]; diff --git a/wax-prosemirror-core/src/styles/styles.css b/wax-prosemirror-core/src/styles/styles.css index 670f3b37ceafa83e815c951badd8010fa933cf10..a36bcdc70a8adbc6a7c13bc79574db0c61d3fe51 100644 --- a/wax-prosemirror-core/src/styles/styles.css +++ b/wax-prosemirror-core/src/styles/styles.css @@ -225,4 +225,9 @@ img.ProseMirror-separator { .ProseMirror *::selection{ background-color: #C5D7FE; color: #000; -} \ No newline at end of file +} + +fakecursor { + border-right: 1px solid black; + display: none; + } \ No newline at end of file diff --git a/wax-prosemirror-services/src/TablesService/TablesService.js b/wax-prosemirror-services/src/TablesService/TablesService.js index 0d26560544d126e697737e2195ed52fedc47c9ab..84f3d020762dc909ebd02d9ef0226fcada4173bd 100644 --- a/wax-prosemirror-services/src/TablesService/TablesService.js +++ b/wax-prosemirror-services/src/TablesService/TablesService.js @@ -1,15 +1,8 @@ import { Service } from 'wax-prosemirror-core'; import TablesServices from './index'; -import FakeCursorPlugin from './plugins/FakeCursorPlugin'; import './table.css'; class TablesService extends Service { - boot() { - this.app.PmPlugins.add( - 'fakeCursorPlugin', - FakeCursorPlugin('fakeCursorPlugin'), - ); - } dependencies = TablesServices; } diff --git a/wax-prosemirror-services/src/TablesService/table.css b/wax-prosemirror-services/src/TablesService/table.css index e5a5cef6defb1e3042f8d1482fde5b9a01e9d69a..1737e4ac5e6407dddce1c2eaa0be6147117d96e6 100644 --- a/wax-prosemirror-services/src/TablesService/table.css +++ b/wax-prosemirror-services/src/TablesService/table.css @@ -52,9 +52,4 @@ right: 0; top: 0; z-index: 2; - } - - fakecursor { - border-right: 1px solid black; - display: none; } \ No newline at end of file