Skip to content
Snippets Groups Projects
Commit 7175e509 authored by chris's avatar chris
Browse files

fake cursor

parent 74678e8f
No related branches found
No related tags found
1 merge request!458Hhmi accessibility
......@@ -86,9 +86,9 @@ const WaxView = forwardRef((props, ref) => {
},
handleDOMEvents: {
blur: (editorView, event) => {
if (view && event.relatedTarget === null) {
view.focus();
}
// if (view && event.relatedTarget === null) {
// view.focus();
// }
},
},
},
......
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;
}
......
/* eslint-disable */
import { Plugin, PluginKey } from 'prosemirror-state';
import { Decoration, DecorationSet } from 'prosemirror-view';
const fakeCursorPlugin = new PluginKey('fakeCursorPlugin');
export default props => {
return new Plugin({
key: fakeCursorPlugin,
state: {
init: (_, state) => {},
apply(tr, prev, _, newState) {
let createDecoration;
const widget = document.createElement('fakecursor');
createDecoration = DecorationSet.create(newState.doc, [
Decoration.widget(newState.selection.from, widget, {
key: 'fakecursor',
}),
]);
return {
createDecoration,
};
},
},
props: {
decorations: state => {
const fakeCursorPluginState = state && fakeCursorPlugin.getState(state);
if (fakeCursorPluginState)
return fakeCursorPluginState.createDecoration;
},
handleDOMEvents: {
focus: (view, _event) => {
const fakeCursor = document.getElementsByTagName('fakecursor');
if (fakeCursor && fakeCursor[0]) fakeCursor[0].style.display = 'none';
},
blur: (view, _event) => {
const fakeCursor = document.getElementsByTagName('fakecursor');
if (fakeCursor && fakeCursor[0])
fakeCursor[0].style.display = 'inline';
},
},
},
});
};
......@@ -52,4 +52,9 @@
right: 0;
top: 0;
z-index: 2;
}
fakecursor {
border-right: 1px solid black;
display: none;
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment