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; + } } }