Browse Source

Prevent errors with layerable textnodes. Fixes #5720

pull/5735/head
Artur Arseniev 2 years ago
parent
commit
78a5f19255
  1. 2
      src/navigator/index.ts
  2. 7
      src/navigator/view/ItemView.ts
  3. 2
      src/utils/dom.ts

2
src/navigator/index.ts

@ -367,7 +367,7 @@ export default class LayerManager extends Module<LayerManagerConfig> {
__isLayerable(cmp: Component): boolean { __isLayerable(cmp: Component): boolean {
const tag = cmp.get('tagName'); const tag = cmp.get('tagName');
const hideText = this.config.hideTextnode; 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')!; return isValid && cmp.get('layerable')!;
} }

7
src/navigator/view/ItemView.ts

@ -4,7 +4,6 @@ import Component from '../../dom_components/model/Component';
import ComponentView from '../../dom_components/view/ComponentView'; import ComponentView from '../../dom_components/view/ComponentView';
import EditorModel from '../../editor/model/Editor'; import EditorModel from '../../editor/model/Editor';
import { isEnterKey, isEscKey } from '../../utils/dom'; import { isEnterKey, isEscKey } from '../../utils/dom';
import { getModel } from '../../utils/mixins';
import LayerManager from '../index'; import LayerManager from '../index';
import ItemsView from './ItemsView'; import ItemsView from './ItemsView';
import { getOnComponentDrag, getOnComponentDragEnd, getOnComponentDragStart } from '../../commands'; import { getOnComponentDrag, getOnComponentDragEnd, getOnComponentDragStart } from '../../commands';
@ -96,8 +95,8 @@ export default class ItemView extends View {
return this.config.stylePrefix; return this.config.stylePrefix;
} }
opt: any; opt: ItemViewProps;
module: any; module: LayerManager;
config: any; config: any;
sorter: any; sorter: any;
/** @ts-ignore */ /** @ts-ignore */
@ -357,7 +356,7 @@ export default class ItemView extends View {
const countEl = itemEl.find('[data-count]'); const countEl = itemEl.find('[data-count]');
title[count ? 'removeClass' : 'addClass'](clsNoChild); title[count ? 'removeClass' : 'addClass'](clsNoChild);
countEl.html(count || ''); countEl.html(`${count || ''}`);
!count && module.setOpen(model, false); !count && module.setOpen(model, false);
} }

2
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)); el && el.setAttribute && each(attrs, (value, key) => el.setAttribute(key, value));
export const isVisible = (el?: HTMLElement) => { 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) => { export const empty = (node: HTMLElement) => {

Loading…
Cancel
Save