From c3baadd373d83d54bc28535c82b82de7be7540e4 Mon Sep 17 00:00:00 2001 From: iskaktoltay Date: Tue, 17 Dec 2024 18:58:38 +0500 Subject: [PATCH] fixed uploading image after inserting it with link dropdown --- .../core/extensions/LinkMenu/defaultLinkMenuItems.tsx | 9 +++++---- frontend/apps/desktop/src/editor/image.tsx | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/apps/desktop/src/editor/blocknote/core/extensions/LinkMenu/defaultLinkMenuItems.tsx b/frontend/apps/desktop/src/editor/blocknote/core/extensions/LinkMenu/defaultLinkMenuItems.tsx index 0cbc80a4c..7a0b49852 100644 --- a/frontend/apps/desktop/src/editor/blocknote/core/extensions/LinkMenu/defaultLinkMenuItems.tsx +++ b/frontend/apps/desktop/src/editor/blocknote/core/extensions/LinkMenu/defaultLinkMenuItems.tsx @@ -1,12 +1,12 @@ import {HMBlockSchema} from '@/editor/schema' import {youtubeParser} from '@/editor/utils' import { - StateStream, - UnpackedHypermediaId, createHMUrl, isHypermediaScheme, isPublicGatewayLink, normalizeHmId, + StateStream, + UnpackedHypermediaId, } from '@shm/shared' import { File as FileIcon, @@ -243,7 +243,7 @@ export function getLinkMenuItems({ const {state, schema} = editor._tiptapEditor const {selection} = state if (!selection.empty) return - let embedUrl = link ? link : sourceUrl ? sourceUrl : '' + let embedUrl = '' if (media === 'video') { let videoUrl = link ? link : sourceUrl ? sourceUrl : '' if (videoUrl.includes('youtu.be') || videoUrl.includes('youtube')) { @@ -261,11 +261,12 @@ export function getLinkMenuItems({ } embedUrl = videoUrl } + const node = media !== 'twitter' ? schema.nodes[media].create({ url: embedUrl ? embedUrl : '', - src: embedUrl ? '' : link, + src: embedUrl ? '' : link ? link : sourceUrl ? sourceUrl : '', name: fileName ? fileName : '', }) : schema.nodes['web-embed'].create({ diff --git a/frontend/apps/desktop/src/editor/image.tsx b/frontend/apps/desktop/src/editor/image.tsx index 73ec8be64..67f82169c 100644 --- a/frontend/apps/desktop/src/editor/image.tsx +++ b/frontend/apps/desktop/src/editor/image.tsx @@ -20,6 +20,9 @@ export const ImageBlock = createReactBlockSpec({ url: { default: '', }, + src: { + default: '', + }, alt: { default: '', },