|
|
@ -65,7 +65,7 @@ export function initCompImagePaste($target) { |
|
|
|
for (const textarea of this.querySelectorAll('textarea')) { |
|
|
|
for (const textarea of this.querySelectorAll('textarea')) { |
|
|
|
textarea.addEventListener('paste', async (e) => { |
|
|
|
textarea.addEventListener('paste', async (e) => { |
|
|
|
for (const img of clipboardPastedImages(e)) { |
|
|
|
for (const img of clipboardPastedImages(e)) { |
|
|
|
const name = img.name.substr(0, img.name.lastIndexOf('.')); |
|
|
|
const name = img.name.slice(0, img.name.lastIndexOf('.')); |
|
|
|
insertAtCursor(textarea, `![${name}]()`); |
|
|
|
insertAtCursor(textarea, `![${name}]()`); |
|
|
|
const data = await uploadFile(img, uploadUrl); |
|
|
|
const data = await uploadFile(img, uploadUrl); |
|
|
|
replaceAndKeepCursor(textarea, `![${name}]()`, `![${name}](/attachments/${data.uuid})`); |
|
|
|
replaceAndKeepCursor(textarea, `![${name}]()`, `![${name}](/attachments/${data.uuid})`); |
|
|
@ -81,7 +81,7 @@ export function initEasyMDEImagePaste(easyMDE, dropzone, files) { |
|
|
|
const uploadUrl = dropzone.getAttribute('data-upload-url'); |
|
|
|
const uploadUrl = dropzone.getAttribute('data-upload-url'); |
|
|
|
easyMDE.codemirror.on('paste', async (_, e) => { |
|
|
|
easyMDE.codemirror.on('paste', async (_, e) => { |
|
|
|
for (const img of clipboardPastedImages(e)) { |
|
|
|
for (const img of clipboardPastedImages(e)) { |
|
|
|
const name = img.name.substr(0, img.name.lastIndexOf('.')); |
|
|
|
const name = img.name.slice(0, img.name.lastIndexOf('.')); |
|
|
|
const data = await uploadFile(img, uploadUrl); |
|
|
|
const data = await uploadFile(img, uploadUrl); |
|
|
|
const pos = easyMDE.codemirror.getCursor(); |
|
|
|
const pos = easyMDE.codemirror.getCursor(); |
|
|
|
easyMDE.codemirror.replaceRange(`![${name}](/attachments/${data.uuid})`, pos); |
|
|
|
easyMDE.codemirror.replaceRange(`![${name}](/attachments/${data.uuid})`, pos); |
|
|
|