1- import $ from 'jquery' ;
21import { htmlEscape } from 'escape-goat' ;
32import { POST } from '../../modules/fetch.js' ;
43import { imageInfo } from '../../utils/image.js' ;
@@ -93,11 +92,10 @@ class CodeMirrorEditor {
9392}
9493
9594const uploadClipboardImage = async ( editor , dropzone , e ) => {
96- const $dropzone = $ ( dropzone ) ;
97- const uploadUrl = $dropzone . attr ( 'data-upload-url' ) ;
98- const $files = $dropzone . find ( '.files' ) ;
95+ const uploadUrl = dropzone . getAttribute ( 'data-upload-url' ) ;
96+ const filesContainer = dropzone . querySelector ( '.files' ) ;
9997
100- if ( ! uploadUrl || ! $files . length ) return ;
98+ if ( ! uploadUrl || ! filesContainer ) return ;
10199
102100 const pastedImages = clipboardPastedImages ( e ) ;
103101 if ( ! pastedImages || pastedImages . length === 0 ) {
@@ -126,8 +124,12 @@ const uploadClipboardImage = async (editor, dropzone, e) => {
126124 }
127125 editor . replacePlaceholder ( placeholder , text ) ;
128126
129- const $input = $ ( `<input name="files" type="hidden">` ) . attr ( 'id' , uuid ) . val ( uuid ) ;
130- $files . append ( $input ) ;
127+ const input = document . createElement ( 'input' ) ;
128+ input . setAttribute ( 'name' , 'files' ) ;
129+ input . setAttribute ( 'type' , 'hidden' ) ;
130+ input . setAttribute ( 'id' , uuid ) ;
131+ input . value = uuid ;
132+ filesContainer . append ( input ) ;
131133 }
132134} ;
133135
@@ -140,7 +142,7 @@ export function initEasyMDEImagePaste(easyMDE, dropzone) {
140142
141143export function initTextareaImagePaste ( textarea , dropzone ) {
142144 if ( ! dropzone ) return ;
143- $ ( textarea ) . on ( 'paste' , async ( e ) => {
144- return uploadClipboardImage ( new TextareaEditor ( textarea ) , dropzone , e . originalEvent ) ;
145+ textarea . addEventListener ( 'paste' , async ( e ) => {
146+ return uploadClipboardImage ( new TextareaEditor ( textarea ) , dropzone , e ) ;
145147 } ) ;
146148}
0 commit comments