-import $ from 'jquery';
import {htmlEscape} from 'escape-goat';
import {POST} from '../../modules/fetch.js';
import {imageInfo} from '../../utils/image.js';
}
const uploadClipboardImage = async (editor, dropzone, e) => {
- const $dropzone = $(dropzone);
- const uploadUrl = $dropzone.attr('data-upload-url');
- const $files = $dropzone.find('.files');
+ const uploadUrl = dropzone.getAttribute('data-upload-url');
+ const filesContainer = dropzone.querySelector('.files');
- if (!uploadUrl || !$files.length) return;
+ if (!uploadUrl || !filesContainer) return;
const pastedImages = clipboardPastedImages(e);
if (!pastedImages || pastedImages.length === 0) {
}
editor.replacePlaceholder(placeholder, text);
- const $input = $(`<input name="files" type="hidden">`).attr('id', uuid).val(uuid);
- $files.append($input);
+ const input = document.createElement('input');
+ input.setAttribute('name', 'files');
+ input.setAttribute('type', 'hidden');
+ input.setAttribute('id', uuid);
+ input.value = uuid;
+ filesContainer.append(input);
}
};
export function initTextareaImagePaste(textarea, dropzone) {
if (!dropzone) return;
- $(textarea).on('paste', async (e) => {
- return uploadClipboardImage(new TextareaEditor(textarea), dropzone, e.originalEvent);
+ textarea.addEventListener('paste', async (e) => {
+ return uploadClipboardImage(new TextareaEditor(textarea), dropzone, e);
});
}