Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
editor.on('click keyup SetContent ObjectResized ResizeEditor', (e) => {
// Fixing issue with chrome focus on img.
resetTimer(
Delay.setEditorTimeout(editor, launchContextToolbar, 0)
);
});
setClipboardData(evt, getData(editor), fallback(editor), () => {
if (Env.browser.isChrome()) {
const rng = editor.selection.getRng();
// Chrome fails to execCommand from another execCommand with this message:
// "We don't execute document.execCommand() this time, because it is called recursively.""
Delay.setEditorTimeout(editor, () => { // detach
// Restore the range before deleting, as Chrome on Android will
// collapse the selection after a cut event has fired.
editor.selection.setRng(rng);
editor.execCommand('Delete');
}, 0);
} else {
editor.execCommand('Delete');
}
});
}
const cancelHandler = (e) => {
const cleanup = () => {
resolve([]);
fileInput.parentNode.removeChild(fileInput);
};
// Android will fire focusin before the input change event
// so we need to do a slight delay to get outside the event loop
if (Env.os.isAndroid() && e.type !== 'remove') {
Delay.setEditorTimeout(editor, cleanup, 0);
} else {
cleanup();
}
editor.off('focusin remove', cancelHandler);
};
editor.getDoc().execCommand('Paste', false, null);
clipboardContent['text/html'] = pasteBin.getHtml();
}
// If clipboard API has HTML then use that directly
if (hasContentType(clipboardContent, 'text/html')) {
e.preventDefault();
// if clipboard lacks internal mime type, inspect html for internal markings
if (!internal) {
internal = InternalHtml.isMarked(clipboardContent['text/html']);
}
insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal);
} else {
Delay.setEditorTimeout(editor, function () {
insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal);
}, 0);
}
});
};
const wait = (editor: Editor, oldSize: Cell, times: number, interval: number, callback?: Function) => {
Delay.setEditorTimeout(editor, () => {
resize(editor, oldSize);
if (times--) {
wait(editor, oldSize, times, interval, callback);
} else if (callback) {
callback();
}
}, interval);
};
editor.on('focusout', (e) => {
Delay.setEditorTimeout(editor, () => {
if (Focus.search(sink.element()).isNone() && Focus.search(contextbar.element()).isNone()) {
lastAnchor.set(Option.none());
InlineView.hide(contextbar);
}
}, 0);
});
const startTimedUpload = function (editor: Editor, imageUploadTimerState) {
const imageUploadTimer = Delay.setEditorTimeout(editor, function () {
editor.editorUpload.uploadImagesAuto();
}, Settings.getUploadTimeout(editor));
imageUploadTimerState.set(imageUploadTimer);
};
const delayedConfirm = function (editor: Editor, message: string, callback: (state: boolean) => void) {
const rng = editor.selection.getRng();
Delay.setEditorTimeout(editor, function () {
editor.windowManager.confirm(message, function (state) {
editor.selection.setRng(rng);
callback(state);
});
});
};
const selectionReset = () => {
Delay.setEditorTimeout(editor, () => {
editor.selection.setRng(originalSelection);
}, 10);
unbindEventListeners();
};
editor.once('touchend', selectionReset);