FF workaround for broken execCommand and getSelection

closes #407
This commit is contained in:
tophf 2018-06-29 13:00:25 +03:00
parent 31ed15a8f6
commit 3c13f13ae2

View File

@ -96,6 +96,8 @@ onDOMready().then(() => {
this._input.focus(); this._input.focus();
document.execCommand('selectAll', false, null); document.execCommand('selectAll', false, null);
document.execCommand('delete', false, null); document.execCommand('delete', false, null);
// some versions of Firefox ignore the above
this._input.value = '';
}, },
case() { case() {
state.icase = !state.icase; state.icase = !state.icase;
@ -535,7 +537,7 @@ onDOMready().then(() => {
setActiveEditor(cm); setActiveEditor(cm);
const dialogFocused = state.dialog && state.dialog.contains(document.activeElement); const dialogFocused = state.dialog && state.dialog.contains(document.activeElement);
let sel = dialogFocused ? '' : getSelection().toString(); let sel = dialogFocused ? '' : getSelection().toString() || cm && cm.getSelection();
sel = !sel.includes('\n') && !sel.includes('\r') && sel; sel = !sel.includes('\n') && !sel.includes('\r') && sel;
if (sel) state.find = sel; if (sel) state.find = sel;
@ -546,6 +548,8 @@ onDOMready().then(() => {
state.input.focus(); state.input.focus();
state.input.select(); state.input.select();
document.execCommand('insertText', false, sel); document.execCommand('insertText', false, sel);
// some versions of Firefox ignore the above
state.input.value = sel;
} }
state.input.focus(); state.input.focus();