NOW MANAGED ON CODEBERG
Lexical: Added image insert via image link paste
Dan Browna43a1832f5bd
diff --git a/resources/js/wysiwyg/services/drop-paste-handling.ts b/resources/js/wysiwyg/services/drop-paste-handling.tsindex 2ee831d74..57f9a80ae 100644--- a/resources/js/wysiwyg/services/drop-paste-handling.ts+++ b/resources/js/wysiwyg/services/drop-paste-handling.ts@@ -95,6 +95,21 @@ function handleMediaInsert(data: DataTransfer, context: EditorUiContext): booleareturn handled;}+function handleImageLinkInsert(data: DataTransfer, context: EditorUiContext): boolean {+ const regex = /https?:\/\/([^?#]*?)\.(png|jpeg|jpg|gif|webp|bmp|avif)/i+ const text = data.getData('text/plain');+ if (text && regex.test(text)) {+ context.editor.update(() => {+ const image = $createImageNode(text);+ $insertNodes([image]);+ image.select();+ });+ return true;+ }++ return false;+}+function createDropListener(context: EditorUiContext): (event: DragEvent) => boolean {const editor = context.editor;return (event: DragEvent): boolean => {@@ -138,7 +153,10 @@ function createPasteListener(context: EditorUiContext): (event: ClipboardEvent)return false;}- const handled = handleMediaInsert(event.clipboardData, context);+ const handled =+ handleImageLinkInsert(event.clipboardData, context) ||+ handleMediaInsert(event.clipboardData, context);+if (handled) {event.preventDefault();}