quill
quill copied to clipboard
quill.clipboard.addMatcher does not detect pasted URLs
Steps for Reproduction
- Visit https://stackblitz.com/edit/stackblitz-starters-zqlwfk?file=src%2FLinkPreview.ts
- Copy link from browser's address bar
- Paste the link into Quill editor
Expected behavior:
Should show alert "it works"
Actual behavior:
Nothing happens (however, when you cut the link from editor and paste it back, then it works)
Platforms:
OS: Windows 7, Windows 10, Ubuntu 22.04 Browsers: Chrome, Firefox, Opera, Vivaldi
Version:
Quill 2.0.2
When you copy URL from browser's address bar, it's recognized as text and clipboard matchers are not executed.
onCapturePaste(e: ClipboardEvent) {
/* ... */
const html = e.clipboardData?.getData('text/html'); // undefined
let text = e.clipboardData?.getData('text/plain'); // URL as string
/* ... */
this.onPaste(range, { html, text });
}
convert(
{ html, text }: { html?: string; text?: string },
formats: Record<string, unknown> = {},
) {
if (formats[CodeBlock.blotName]) { // formats is empty
return new Delta().insert(text || '', {
[CodeBlock.blotName]: formats[CodeBlock.blotName],
});
}
if (!html) {
return new Delta().insert(text || '', formats); // it's executed - insert text and finish
}
const delta = this.convertHTML(html); // it's not executed (this method calls clipboard matchers)
/* ... */
return delta;
}
So is this a feature request to add clipboard matchers for plain text?