From 3bb4429f1519219404404b28014d550b01cf7d22 Mon Sep 17 00:00:00 2001 From: attoae <55045456+attoae@users.noreply.github.com> Date: Mon, 23 Sep 2024 19:01:32 +0800 Subject: [PATCH] fix: The returned value queried is not necessarily BlockBlot --- packages/quill/src/blots/scroll.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/quill/src/blots/scroll.ts b/packages/quill/src/blots/scroll.ts index 9975e12831..146c8f4e0a 100644 --- a/packages/quill/src/blots/scroll.ts +++ b/packages/quill/src/blots/scroll.ts @@ -1,4 +1,10 @@ -import { ContainerBlot, LeafBlot, Scope, ScrollBlot } from 'parchment'; +import { + BlockBlot, + ContainerBlot, + LeafBlot, + Scope, + ScrollBlot +} from 'parchment'; import type { Blot, Parent, EmbedBlot, ParentBlot, Registry } from 'parchment'; import Delta, { AttributeMap, Op } from 'quill-delta'; import Emitter from '../core/emitter.js'; @@ -381,7 +387,8 @@ class Scroll extends ScrollBlot { const formats: AttributeMap = {}; Object.entries(attributes).forEach(([key, value]) => { - const isBlockBlot = this.query(key, Scope.BLOCK & Scope.BLOT) != null; + const match = this.query(key, Scope.BLOCK & Scope.BLOT); + const isBlockBlot = match != null && match.prototype instanceof BlockBlot; if (isBlockBlot) { blotName = key; } else {