Skip to content

Commit

Permalink
Cleanup EditorView
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Apr 15, 2024
1 parent 83ca230 commit 717e429
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/editor/view/EditorView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,45 @@ import EditorModel from '../model/Editor';
export default class EditorView extends View<EditorModel> {
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();
});
});
}

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;
}
Expand Down

0 comments on commit 717e429

Please sign in to comment.