Better handle newlines in content pasted into composer

This commit is contained in:
Scott Nonnenberg 2023-05-11 12:48:34 -07:00 committed by GitHub
parent 21f5ac30f2
commit 995b207b48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -25,6 +25,10 @@ export const matchEmojiBlot = (node: HTMLElement, delta: Delta): Delta => {
};
export const matchEmojiText = (node: Text): Delta => {
if (node.data.replace(/(\n|\r\n)/g, '') === '') {
return new Delta();
}
const nodeAsInsert = { insert: node.data };
return new Delta(insertEmojiOps([nodeAsInsert]));

View file

@ -26,8 +26,11 @@ export class SignalClipboard {
this.quill.root.addEventListener('paste', e => this.onCapturePaste(e));
const clipboard = this.quill.getModule('clipboard');
// We don't want any of the default matchers!
clipboard.matchers = clipboard.matchers.slice(11);
// We keep just the first few matchers (for spacing) then drop the rest!
clipboard.matchers = clipboard.matchers
.slice(0, 4)
.concat(clipboard.matchers.slice(11));
}
onCapturePaste(event: ClipboardEvent): void {