-import Clipboard from "../services/clipboard";
+import Clipboard from '../services/clipboard';
let wrap;
let draggedContentEditable;
const images = clipboard.getImages();
for (const imageFile of images) {
-
- const id = "image-" + Math.random().toString(16).slice(2);
+ const id = `image-${Math.random().toString(16).slice(2)}`;
const loadingImage = window.baseUrl('/loading.gif');
event.preventDefault();
*/
async function uploadImageFile(file, pageId) {
if (file === null || file.type.indexOf('image') !== 0) {
- throw new Error(`Not an image file`);
+ throw new Error('Not an image file');
}
const remoteFilename = file.name || `image-${Date.now()}.png`;
* @param {WysiwygConfigOptions} options
*/
function dragStart(editor, options) {
- let node = editor.selection.getNode();
+ const node = editor.selection.getNode();
if (node.nodeName === 'IMG') {
wrap = editor.dom.getParent(node, '.mceTemp');
* @param {DragEvent} event
*/
function drop(editor, options, event) {
- let dom = editor.dom,
- rng = tinymce.dom.RangeUtils.getCaretRangeFromPoint(event.clientX, event.clientY, editor.getDoc());
+ const {dom} = editor;
+ const rng = tinymce.dom.RangeUtils.getCaretRangeFromPoint(event.clientX, event.clientY, editor.getDoc());
// Template insertion
const templateId = event.dataTransfer && event.dataTransfer.getData('bookstack/template');
event.preventDefault();
window.$http.get(`/templates/${templateId}`).then(resp => {
editor.selection.setRng(rng);
- editor.undoManager.transact(function () {
+ editor.undoManager.transact(() => {
editor.execCommand('mceInsertContent', false, resp.data.html);
});
});
} else if (wrap) {
event.preventDefault();
- editor.undoManager.transact(function () {
+ editor.undoManager.transact(() => {
editor.selection.setRng(rng);
editor.selection.setNode(wrap);
dom.remove(wrap);
// Handle contenteditable section drop
if (!event.isDefaultPrevented() && draggedContentEditable) {
event.preventDefault();
- editor.undoManager.transact(function () {
+ editor.undoManager.transact(() => {
const selectedNode = editor.selection.getNode();
const range = editor.selection.getRng();
const selectedNodeRoot = selectedNode.closest('body > *');
*/
export function listenForDragAndPaste(editor, options) {
editor.on('dragstart', () => dragStart(editor, options));
- editor.on('drop', event => drop(editor, options, event));
+ editor.on('drop', event => drop(editor, options, event));
editor.on('paste', event => paste(editor, options, event));
-}
\ No newline at end of file
+}