From 34178f918de42d19aba3a64160033c07e4594d2f Mon Sep 17 00:00:00 2001 From: Alex Ritter Date: Sun, 17 Apr 2022 12:26:50 +0200 Subject: [PATCH] Convert EditorView to ts --- src/editor/index.ts | 6 +---- .../view/{EditorView.js => EditorView.ts} | 22 ++++++++++--------- 2 files changed, 13 insertions(+), 15 deletions(-) rename src/editor/view/{EditorView.js => EditorView.ts} (65%) diff --git a/src/editor/index.ts b/src/editor/index.ts index 4350fcc28..f82a71dc3 100644 --- a/src/editor/index.ts +++ b/src/editor/index.ts @@ -761,11 +761,7 @@ export default class EditorModule implements IBaseModule { */ render() { this.editorView?.remove(); - this.editorView = new EditorView({ - model: this.em, - //@ts-ignore - config: this.config, - }); + this.editorView = new EditorView(this.em); return this.editorView.render().el; } diff --git a/src/editor/view/EditorView.js b/src/editor/view/EditorView.ts similarity index 65% rename from src/editor/view/EditorView.js rename to src/editor/view/EditorView.ts index 409e5147d..ff617f076 100644 --- a/src/editor/view/EditorView.js +++ b/src/editor/view/EditorView.ts @@ -1,12 +1,14 @@ import Backbone from 'backbone'; import { View } from '../../common'; import { appendStyles } from '../../utils/mixins'; +import EditorModel from '../model/Editor'; const $ = Backbone.$; -export default class EditorView extends View { - initialize() { - const { model } = this; +export default class EditorView extends View { + constructor(model: EditorModel) { + super({model}) + //const { model } = this; const { Panels, UndoManager } = model.attributes; model.view = this; model.once('change:ready', () => { @@ -22,15 +24,15 @@ export default class EditorView extends View { render() { const { $el, model } = this; - const { Panels, Canvas, modules } = model.attributes; - const conf = model.getConfig(); - const pfx = conf.stylePrefix; - const contEl = $(conf.el || `body ${conf.container}`); - appendStyles(conf.cssIcons, { unique: 1, prepand: 1 }); + const { Panels, Canvas } = model.attributes; + const { config, modules } = model; + const pfx = config.stylePrefix; + const contEl = $(config.el || `body ${config.container}`); + appendStyles(config.cssIcons, { unique: 1, prepand: 1 }); $el.empty(); - if (conf.width) contEl.css('width', conf.width); - if (conf.height) contEl.css('height', conf.height); + if (config.width) contEl.css('width', config.width); + if (config.height) contEl.css('height', config.height); $el.append(Canvas.render()); $el.append(Panels.render());