Skip to content
Snippets Groups Projects
Commit 4b9e60ca authored by chris's avatar chris
Browse files

fake cursor plugin fixes

parent 68fb3f37
No related branches found
No related tags found
1 merge request!458Hhmi accessibility
......@@ -88,8 +88,19 @@ const WaxView = forwardRef((props, ref) => {
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';
},
},
},
);
......
......@@ -11,13 +11,14 @@ export default props => {
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',
}),
]);
if (newState.selection.from === newState.selection.to) {
const widget = document.createElement('fakecursor');
createDecoration = DecorationSet.create(newState.doc, [
Decoration.widget(newState.selection.from, widget, {
key: 'fakecursor',
}),
]);
}
return {
createDecoration,
};
......@@ -30,15 +31,8 @@ export default props => {
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';
},
focus: (view, _event) => {},
blur: (view, _event) => {},
},
},
});
......
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