mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-06-21 20:18:11 +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({
|
const editor = useEditor({
|
||||||
extensions: [
|
extensions: [
|
||||||
StarterKit,
|
StarterKit.configure({ link: false }),
|
||||||
Link.configure({ openOnClick: false, autolink: true }),
|
Link.configure({ openOnClick: false, autolink: true }),
|
||||||
Placeholder.configure({
|
Placeholder.configure({
|
||||||
placeholder: mode === 'reply' ? 'Write your reply…' : 'Write a message…',
|
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)
|
const selectionPos = Math.min(foundPos + 1, view.state.doc.content.size)
|
||||||
view.dispatch(
|
view.dispatch(
|
||||||
view.state.tr
|
view.state.tr.setSelection(TextSelection.near(view.state.doc.resolve(selectionPos)))
|
||||||
.setSelection(TextSelection.near(view.state.doc.resolve(selectionPos)))
|
|
||||||
.scrollIntoView()
|
|
||||||
)
|
)
|
||||||
view.focus()
|
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
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -727,6 +732,7 @@ export const MarkdownEditor = forwardRef<MarkdownEditorHandle, MarkdownEditorPro
|
||||||
heading: {
|
heading: {
|
||||||
levels: [1, 2, 3],
|
levels: [1, 2, 3],
|
||||||
},
|
},
|
||||||
|
link: false,
|
||||||
}),
|
}),
|
||||||
Link.configure({
|
Link.configure({
|
||||||
openOnClick: false,
|
openOnClick: false,
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ export function RichMarkdownViewer({ content }: { content: string }) {
|
||||||
heading: {
|
heading: {
|
||||||
levels: [1, 2, 3],
|
levels: [1, 2, 3],
|
||||||
},
|
},
|
||||||
|
link: false,
|
||||||
}),
|
}),
|
||||||
Link.configure({
|
Link.configure({
|
||||||
openOnClick: true,
|
openOnClick: true,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue