Better handle newlines in content pasted into composer
This commit is contained in:
parent
21f5ac30f2
commit
995b207b48
2 changed files with 9 additions and 2 deletions
|
@ -25,6 +25,10 @@ export const matchEmojiBlot = (node: HTMLElement, delta: Delta): Delta => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const matchEmojiText = (node: Text): Delta => {
|
export const matchEmojiText = (node: Text): Delta => {
|
||||||
|
if (node.data.replace(/(\n|\r\n)/g, '') === '') {
|
||||||
|
return new Delta();
|
||||||
|
}
|
||||||
|
|
||||||
const nodeAsInsert = { insert: node.data };
|
const nodeAsInsert = { insert: node.data };
|
||||||
|
|
||||||
return new Delta(insertEmojiOps([nodeAsInsert]));
|
return new Delta(insertEmojiOps([nodeAsInsert]));
|
||||||
|
|
|
@ -26,8 +26,11 @@ export class SignalClipboard {
|
||||||
this.quill.root.addEventListener('paste', e => this.onCapturePaste(e));
|
this.quill.root.addEventListener('paste', e => this.onCapturePaste(e));
|
||||||
|
|
||||||
const clipboard = this.quill.getModule('clipboard');
|
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 {
|
onCapturePaste(event: ClipboardEvent): void {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue