mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-06-09 19:45:17 +02:00
fix: drop duplicate Link extension and scroll headings to viewport top
This commit is contained in:
parent
d35f1dc2bd
commit
b1394b2ebb
3 changed files with 11 additions and 4 deletions
|
|
@ -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…',
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ export function RichMarkdownViewer({ content }: { content: string }) {
|
|||
heading: {
|
||||
levels: [1, 2, 3],
|
||||
},
|
||||
link: false,
|
||||
}),
|
||||
Link.configure({
|
||||
openOnClick: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue