diff --git a/CHANGELOG.md b/CHANGELOG.md index 102c6b6025..7e6b377a42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,17 +11,18 @@ and this project adheres to - 🚸(frontend) redirect on current url tab after 401 #2197 - 🐛(frontend) abort check media status unmount #2194 - ✨(backend) order pinned documents by last updated at #2028 +- 🐛(frontend) sanitize pasted toolbar links #2214 ### Changed - - ♿️(frontend) structure correctly 5xx error alerts #2128 +- ♿️(frontend) structure correctly 5xx error alerts #2128 ## [v4.8.6] - 2026-04-08 ### Added -- 🚸(frontend) allow opening "@page" links with -ctrl/command/middle-mouse click #2170 +- 🚸(frontend) allow opening "@page" links with + ctrl/command/middle-mouse click #2170 - ✅ E2E - Any instance friendly #2142 ### Changed diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx index f4b19a99d6..dcd3e69fc4 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/BlockNoteEditor.tsx @@ -88,6 +88,32 @@ interface BlockNoteEditorProps { provider: HocuspocusProvider; } +/** + * Strips angle brackets wrapping URLs (e.g. `` → `https://example.com`). + * BlockNote copies links in Markdown autolink format; pasting into the link + * toolbar input keeps the brackets, producing broken hrefs. + */ + +const handlePasteUrlBrackets = (e: React.ClipboardEvent) => { + const target = e.target; + if ( + !(target instanceof HTMLInputElement) && + !(target instanceof HTMLTextAreaElement) + ) { + return; + } + const text = e.clipboardData?.getData('text/plain') ?? ''; + const cleaned = text.replace(/^\s*<([^<>]+)>\s*$/, '$1'); + if (cleaned === text) { + return; + } + e.preventDefault(); + const start = target.selectionStart ?? target.value.length; + const end = target.selectionEnd ?? target.value.length; + target.setRangeText(cleaned, start, end, 'end'); + target.dispatchEvent(new Event('input', { bubbles: true })); +}; + export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => { const { user } = useAuth(); const { setEditor } = useEditorStore(); @@ -267,6 +293,7 @@ export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => { return (