Browse Source

fix: append new line after file upload placeholder in editor

imwald
codytseng 8 months ago
parent
commit
8db655cc37
  1. 2
      src/components/PostEditor/PostContent.tsx
  2. 6
      src/components/PostEditor/PostTextarea/ClipboardAndDropHandler.ts

2
src/components/PostEditor/PostContent.tsx

@ -104,7 +104,7 @@ export default function PostContent({ @@ -104,7 +104,7 @@ export default function PostContent({
<div className="flex gap-2 items-center">
<Uploader
onUploadSuccess={({ url }) => {
textareaRef.current?.appendText(url)
textareaRef.current?.appendText(url + '\n')
}}
onUploadingChange={(uploading) =>
setUploadingFiles((prev) => (uploading ? prev + 1 : prev - 1))

6
src/components/PostEditor/PostTextarea/ClipboardAndDropHandler.ts

@ -99,10 +99,8 @@ async function uploadFile(view: EditorView, file: File, options: ClipboardAndDro @@ -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

Loading…
Cancel
Save