Compare commits

...

2 Commits

Author SHA1 Message Date
Cyril
1115fe3546 fixup! 🐛(frontend) sanitize pasted toolbar links 2026-04-15 10:11:26 +02:00
Cyril
598a6adc02 🐛(frontend) sanitize pasted toolbar links
Strip < and > from pasted BlockNote links to keep valid external URLs.
2026-04-15 10:00:09 +02:00
2 changed files with 31 additions and 3 deletions

View File

@@ -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

View File

@@ -88,6 +88,32 @@ interface BlockNoteEditorProps {
provider: HocuspocusProvider;
}
/**
* Strips angle brackets wrapping URLs (e.g. `<https://example.com>` → `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<HTMLDivElement>) => {
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 (
<Box
ref={refEditorContainer}
onPasteCapture={handlePasteUrlBrackets}
$css={css`
${cssEditor};
${cssComments(showComments, currentUserAvatarUrl)}