Browse Source

Use abstract base class

pull/4264/head
Alex Ritter 5 years ago
parent
commit
b209e2995e
  1. 1
      src/editor/config/config.js
  2. 26
      src/editor/index.ts

1
src/editor/config/config.js

@ -1,4 +1,5 @@
export default { export default {
name: 'Editor',
// Style prefix // Style prefix
stylePrefix: 'gjs-', stylePrefix: 'gjs-',

26
src/editor/index.ts

@ -55,27 +55,23 @@
* @module Editor * @module Editor
*/ */
import { EventHandler } from 'backbone'; import { EventHandler } from 'backbone';
import Module from '../abstract/Module';
import cash from '../utils/cash-dom'; import cash from '../utils/cash-dom';
import html from '../utils/html'; import html from '../utils/html';
import defaults from './config/config'; import defaults from './config/config';
import EditorModel from './model/Editor'; import EditorModel from './model/Editor';
import EditorView from './view/EditorView'; import EditorView from './view/EditorView';
export default class EditorModule { export default class EditorModule extends Module<typeof defaults> {
constructor(config = {}, opts: any = {}) { constructor(config = {}, opts: any = {}) {
var c = { ...defaults, ...config, pStylePrefix: defaults.stylePrefix };
super(new EditorModel(c), c)
this.$ = opts.$; this.$ = opts.$;
this.c = { ...defaults, ...config };
this.c.pStylePrefix = this.c.stylePrefix;
this.em = new EditorModel(this.c);
this.em.init(this); this.em.init(this);
this.editor = this.em; this.editor = this.em;
} }
editorView?: EditorView; editorView?: EditorView;
em: EditorModel;
editor: EditorModel; editor: EditorModel;
c: any;
$: cash; $: cash;
/** /**
@ -218,16 +214,6 @@ export default class EditorModule {
return this.em.get("DeviceManager"); return this.em.get("DeviceManager");
} }
/**
* Returns configuration object
* @param {string} [prop] Property name
* @returns {any} Returns the configuration object or
* the value of the specified property
*/
getConfig(prop: string) {
return this.em.getConfig(prop);
}
/** /**
* Returns HTML built inside canvas * Returns HTML built inside canvas
* @param {Object} [opts={}] Options * @param {Object} [opts={}] Options
@ -560,7 +546,7 @@ export default class EditorModule {
* @return {HTMLElement} * @return {HTMLElement}
*/ */
getContainer() { getContainer() {
return this.c.el; return this.config.el;
} }
/** /**
@ -777,7 +763,7 @@ export default class EditorModule {
this.editorView = new EditorView({ this.editorView = new EditorView({
model: this.em, model: this.em,
//@ts-ignore //@ts-ignore
config: this.c, config: this.config,
}); });
return this.editorView.render().el; return this.editorView.render().el;
} }

Loading…
Cancel
Save