From 8db655cc37b964f5058da4081d02eb1e4fe43f74 Mon Sep 17 00:00:00 2001 From: codytseng Date: Fri, 11 Jul 2025 11:59:59 +0800 Subject: [PATCH] fix: append new line after file upload placeholder in editor --- src/components/PostEditor/PostContent.tsx | 2 +- .../PostEditor/PostTextarea/ClipboardAndDropHandler.ts | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/PostEditor/PostContent.tsx b/src/components/PostEditor/PostContent.tsx index 7760710..ae871d1 100644 --- a/src/components/PostEditor/PostContent.tsx +++ b/src/components/PostEditor/PostContent.tsx @@ -104,7 +104,7 @@ export default function PostContent({
{ - textareaRef.current?.appendText(url) + textareaRef.current?.appendText(url + '\n') }} onUploadingChange={(uploading) => setUploadingFiles((prev) => (uploading ? prev + 1 : prev - 1)) diff --git a/src/components/PostEditor/PostTextarea/ClipboardAndDropHandler.ts b/src/components/PostEditor/PostTextarea/ClipboardAndDropHandler.ts index a40f387..3f2c290 100644 --- a/src/components/PostEditor/PostTextarea/ClipboardAndDropHandler.ts +++ b/src/components/PostEditor/PostTextarea/ClipboardAndDropHandler.ts @@ -99,10 +99,8 @@ async function uploadFile(view: EditorView, file: File, options: ClipboardAndDro options.onUploadStart?.(file) const placeholder = `[Uploading "${name}"...]` - const uploadingNode = view.state.schema.text(placeholder) - const paragraph = view.state.schema.nodes.paragraph.create() - let tr = view.state.tr.replaceSelectionWith(uploadingNode) - tr = tr.insert(tr.selection.to, paragraph) + const uploadingNode = view.state.schema.text(placeholder + '\n') + const tr = view.state.tr.replaceSelectionWith(uploadingNode) view.dispatch(tr) mediaUpload