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

fix focus on surface

parent b8cc7276
No related branches found
No related tags found
1 merge request!501Translations
...@@ -11,7 +11,9 @@ export default props => { ...@@ -11,7 +11,9 @@ export default props => {
init: (_, state) => {}, init: (_, state) => {},
apply(tr, prev, _, newState) { apply(tr, prev, _, newState) {
let createDecoration; let createDecoration;
const widget = document.createElement('fakecursor'); const widget = document.createElement('span');
widget.setAttribute('id', 'fake-cursor');
if (newState.selection.from === newState.selection.to) { if (newState.selection.from === newState.selection.to) {
createDecoration = DecorationSet.create(newState.doc, [ createDecoration = DecorationSet.create(newState.doc, [
Decoration.widget(newState.selection.from, widget, { Decoration.widget(newState.selection.from, widget, {
...@@ -21,6 +23,11 @@ export default props => { ...@@ -21,6 +23,11 @@ export default props => {
} }
setTimeout(() => { setTimeout(() => {
widget.setAttribute('contenteditable', true); widget.setAttribute('contenteditable', true);
if (navigator.userAgent.includes('Firefox')) {
widget.setAttribute('style', 'visibility:hidden');
} else {
widget.setAttribute('style', 'display:none');
}
}); });
return { return {
createDecoration, createDecoration,
...@@ -36,14 +43,12 @@ export default props => { ...@@ -36,14 +43,12 @@ export default props => {
handleDOMEvents: { handleDOMEvents: {
focus: (view, event) => { focus: (view, event) => {
event.preventDefault(); event.preventDefault();
const fakeCursor = document.getElementsByTagName('fakecursor'); const fakeCursor = document.getElementById('fake-cursor');
if (fakeCursor && fakeCursor[0]) { if (fakeCursor) {
for (let i = 0; i < fakeCursor.length; i++) { if (navigator.userAgent.includes('Firefox')) {
if (navigator.userAgent.includes('Firefox')) { fakeCursor.style.visibility = 'hidden';
fakeCursor[i].style.visibility = 'hidden'; } else {
} else { fakeCursor.style.display = 'none';
fakeCursor[i].style.display = 'none';
}
} }
} }
}, },
...@@ -52,14 +57,12 @@ export default props => { ...@@ -52,14 +57,12 @@ export default props => {
if (view && event.relatedTarget === null) { if (view && event.relatedTarget === null) {
view.focus(); view.focus();
} else { } else {
const fakeCursor = document.getElementsByTagName('fakecursor'); const fakeCursor = document.getElementById('fake-cursor');
if (fakeCursor && fakeCursor[0]) { if (fakeCursor) {
for (let i = 0; i < fakeCursor.length; i++) { if (navigator.userAgent.includes('Firefox')) {
if (navigator.userAgent.includes('Firefox')) { fakeCursor.style.visibility = 'visible';
fakeCursor[i].style.visibility = 'visible'; } else {
} else { fakeCursor.style.display = 'inline';
fakeCursor[i].style.display = 'inline';
}
} }
} }
} }
......
...@@ -227,22 +227,7 @@ img.ProseMirror-separator { ...@@ -227,22 +227,7 @@ img.ProseMirror-separator {
color: #000; color: #000;
} }
span#fake-cursor::before {
/** Mozilla Firefox */
fakecursor {
display: none;
}
@-moz-document url-prefix() {
fakecursor {
visibility: hidden;
display: inline !important;
}
}
fakecursor::before {
display: inline; display: inline;
content: ''; content: '';
border-right: 1px solid black; border-right: 1px solid black;
......
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