fix: drop duplicate Link extension and scroll headings to viewport top

This commit is contained in:
Gagancreates 2026-05-22 02:18:54 +05:30
parent d35f1dc2bd
commit b1394b2ebb
3 changed files with 11 additions and 4 deletions

View file

@ -499,7 +499,7 @@ function ComposeBox({
const editor = useEditor({
extensions: [
StarterKit,
StarterKit.configure({ link: false }),
Link.configure({ openOnClick: false, autolink: true }),
Placeholder.configure({
placeholder: mode === 'reply' ? 'Write your reply…' : 'Write a message…',

View file

@ -564,11 +564,16 @@ const scrollToHeading = (view: EditorView, rawTarget: string) => {
const selectionPos = Math.min(foundPos + 1, view.state.doc.content.size)
view.dispatch(
view.state.tr
.setSelection(TextSelection.near(view.state.doc.resolve(selectionPos)))
.scrollIntoView()
view.state.tr.setSelection(TextSelection.near(view.state.doc.resolve(selectionPos)))
)
view.focus()
const domAtPos = view.domAtPos(foundPos + 1)
const node = domAtPos.node
const headingEl = node.nodeType === Node.ELEMENT_NODE
? (node as HTMLElement)
: node.parentElement
headingEl?.scrollIntoView({ block: 'start', behavior: 'smooth' })
return true
}
@ -727,6 +732,7 @@ export const MarkdownEditor = forwardRef<MarkdownEditorHandle, MarkdownEditorPro
heading: {
levels: [1, 2, 3],
},
link: false,
}),
Link.configure({
openOnClick: false,

View file

@ -42,6 +42,7 @@ export function RichMarkdownViewer({ content }: { content: string }) {
heading: {
levels: [1, 2, 3],
},
link: false,
}),
Link.configure({
openOnClick: true,