From 717e4297ce3010866af0b14976755bae3e929540 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Tue, 16 Apr 2024 00:13:09 +0400 Subject: [PATCH] Cleanup EditorView --- src/editor/view/EditorView.ts | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/editor/view/EditorView.ts b/src/editor/view/EditorView.ts index 3d02371d1..18cdc6cf2 100644 --- a/src/editor/view/EditorView.ts +++ b/src/editor/view/EditorView.ts @@ -5,15 +5,14 @@ import EditorModel from '../model/Editor'; export default class EditorView extends View { constructor(model: EditorModel) { super({ model }); - //const { model } = this; - const { Panels, UndoManager } = model.attributes; + const { Panels, UndoManager } = model; model.view = this; model.once('change:ready', () => { Panels.active(); Panels.disableButtons(); UndoManager.clear(); setTimeout(() => { - model.trigger('load', model.get('Editor')); + model.trigger('load', model.Editor); model.clearDirtyCount(); }); }); @@ -21,35 +20,30 @@ export default class EditorView extends View { render() { const { $el, model } = this; - const { Panels, Canvas } = model.attributes; - const { config, modules } = model; + const { Panels, Canvas, config, modules } = model; const pfx = config.stylePrefix; const classNames = [`${pfx}editor`]; !config.customUI && classNames.push(`${pfx}one-bg ${pfx}two-color`); - // @ts-ignore const contEl = $(config.el || `body ${config.container}`); config.cssIcons && appendStyles(config.cssIcons, { unique: true, prepand: true }); $el.empty(); - // @ts-ignore - if (config.width) contEl.css('width', config.width); - // @ts-ignore - if (config.height) contEl.css('height', config.height); + config.width && contEl.css('width', config.width); + config.height && contEl.css('height', config.height); $el.append(Canvas.render()); $el.append(Panels.render()); // Load shallow editor - const shallow = model.get('shallow'); - const shallowCanvasEl = shallow.get('Canvas').render(); + const { shallow } = model; + const shallowCanvasEl = shallow.Canvas.render(); shallowCanvasEl.style.display = 'none'; $el.append(shallowCanvasEl); $el.attr('class', classNames.join(' ')); - // @ts-ignore contEl.addClass(`${pfx}editor-cont`).empty().append($el); - modules.forEach(md => md.postRender && md.postRender(this)); + modules.forEach(md => md.postRender?.(this)); return this; }