diff --git a/src/components/input/editor/EditorToolbar.vue b/src/components/input/editor/EditorToolbar.vue index aac57a429..8a676c09b 100644 --- a/src/components/input/editor/EditorToolbar.vue +++ b/src/components/input/editor/EditorToolbar.vue @@ -151,7 +151,7 @@
- + @@ -369,7 +369,6 @@
- @@ -388,40 +387,14 @@ const { uploadCallback?: UploadCallback, }>() -const emit = defineEmits(['imageAdded']) - const tableMode = ref(false) -const uploadInputRef = ref(null) function toggleTableMode() { tableMode.value = !tableMode.value } -function addImage() { - - if (typeof uploadCallback !== 'undefined') { - const files = uploadInputRef.value?.files - - if (!files || files.length === 0) { - return - } - - uploadCallback(files).then(urls => { - urls.forEach(url => { - editor?.chain().focus().setImage({src: url}).run() - }) - emit('imageAdded') - }) - - return - } - - const url = window.prompt('URL') - - if (url) { - editor?.chain().focus().setImage({src: url}).run() - emit('imageAdded') - } +function openImagePicker() { + document.getElementById('tiptap__image-upload').click() } function setLink() { diff --git a/src/components/input/editor/TipTap.vue b/src/components/input/editor/TipTap.vue index d6abeae76..00136cd80 100644 --- a/src/components/input/editor/TipTap.vue +++ b/src/components/input/editor/TipTap.vue @@ -4,12 +4,18 @@ v-if="editor" :editor="editor" :upload-callback="uploadCallback" - @image-added="onImageAdded" /> + @@ -205,7 +211,7 @@ const editor = useEditor({ // return VueNodeViewRenderer(CodeBlock) // }, // }).configure({ lowlight }), - + Commands.configure({ suggestion: suggestionSetup(t), }), @@ -235,6 +241,39 @@ watch(inputHTML, (value) => { }) onBeforeUnmount(() => editor.value?.destroy()) + +const uploadInputRef = ref(null) + +function addImage() { + + if (typeof uploadCallback !== 'undefined') { + const files = uploadInputRef.value?.files + + if (!files || files.length === 0) { + return + } + + uploadCallback(files).then(urls => { + urls.forEach(url => { + editor.value + .chain() + .focus() + .setImage({src: url}) + .run() + }) + onImageAdded() + }) + + return + } + + const url = window.prompt('URL') + + if (url) { + editor.value.chain().focus().setImage({src: url}).run() + onImageAdded() + } +}