From f147b37cd27689313e6d012f91ce570c9792ae27 Mon Sep 17 00:00:00 2001 From: wpj-wpj-wpj Date: Wed, 20 Mar 2024 17:45:41 +0800 Subject: [PATCH] fix: when compositionend after InlineEmbed element, selection do not update --- packages/quill/src/blots/embed.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/quill/src/blots/embed.ts b/packages/quill/src/blots/embed.ts index 2e019f7613..9679b18d5b 100644 --- a/packages/quill/src/blots/embed.ts +++ b/packages/quill/src/blots/embed.ts @@ -78,16 +78,18 @@ class Embed extends EmbedBlot { } update(mutations: MutationRecord[], context: Record) { - mutations.forEach((mutation) => { - if ( + const mutation = mutations.find((mutation) => { + return ( mutation.type === 'characterData' && (mutation.target === this.leftGuard || mutation.target === this.rightGuard) - ) { - const range = this.restore(mutation.target as Text); - if (range) context.range = range; - } + ); }); + + if (mutation) { + const range = this.restore(mutation.target as Text); + if (range) context.range = range; + } } }