Skip to content
Snippets Groups Projects
Commit 828cca73 authored by chris's avatar chris
Browse files

fix fake cursor on backspace

parent bc4b124b
No related branches found
No related tags found
1 merge request!526new wrapper component
......@@ -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,
};
......
......@@ -235,7 +235,7 @@ img.ProseMirror-separator {
}
span#fake-cursor::before {
display: inline;
display: inline-flex;
content: '';
border-right: 1px solid black;
height: 23px;
......
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