|
|
|
@ -5,15 +5,14 @@ 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(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
@ -21,35 +20,30 @@ export default class EditorView extends View<EditorModel> { |
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
|