From 78a5f19255ba41d6637269237987bf8ec398cc5d Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Fri, 8 Mar 2024 01:05:26 +0400 Subject: [PATCH] Prevent errors with layerable textnodes. Fixes #5720 --- src/navigator/index.ts | 2 +- src/navigator/view/ItemView.ts | 7 +++---- src/utils/dom.ts | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/navigator/index.ts b/src/navigator/index.ts index 7fe68460af..6c45e6649f 100644 --- a/src/navigator/index.ts +++ b/src/navigator/index.ts @@ -367,7 +367,7 @@ export default class LayerManager extends Module { __isLayerable(cmp: Component): boolean { const tag = cmp.get('tagName'); const hideText = this.config.hideTextnode; - const isValid = !hideText || (!cmp.is('textnode') && tag !== 'br'); + const isValid = !hideText || (!cmp.isInstanceOf('textnode') && tag !== 'br'); return isValid && cmp.get('layerable')!; } diff --git a/src/navigator/view/ItemView.ts b/src/navigator/view/ItemView.ts index 32e05c7811..c1b1cd7faf 100644 --- a/src/navigator/view/ItemView.ts +++ b/src/navigator/view/ItemView.ts @@ -4,7 +4,6 @@ import Component from '../../dom_components/model/Component'; import ComponentView from '../../dom_components/view/ComponentView'; import EditorModel from '../../editor/model/Editor'; import { isEnterKey, isEscKey } from '../../utils/dom'; -import { getModel } from '../../utils/mixins'; import LayerManager from '../index'; import ItemsView from './ItemsView'; import { getOnComponentDrag, getOnComponentDragEnd, getOnComponentDragStart } from '../../commands'; @@ -96,8 +95,8 @@ export default class ItemView extends View { return this.config.stylePrefix; } - opt: any; - module: any; + opt: ItemViewProps; + module: LayerManager; config: any; sorter: any; /** @ts-ignore */ @@ -357,7 +356,7 @@ export default class ItemView extends View { const countEl = itemEl.find('[data-count]'); title[count ? 'removeClass' : 'addClass'](clsNoChild); - countEl.html(count || ''); + countEl.html(`${count || ''}`); !count && module.setOpen(model, false); } diff --git a/src/utils/dom.ts b/src/utils/dom.ts index 909ed03448..ca4d1c7cb8 100644 --- a/src/utils/dom.ts +++ b/src/utils/dom.ts @@ -37,7 +37,7 @@ export const attrUp = (el?: HTMLElement, attrs: ObjectAny = {}) => el && el.setAttribute && each(attrs, (value, key) => el.setAttribute(key, value)); export const isVisible = (el?: HTMLElement) => { - return el && !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length); + return el && !!(el.offsetWidth || el.offsetHeight || el.getClientRects?.().length); }; export const empty = (node: HTMLElement) => {