1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-25 16:19:44 +02:00

Integrate CodeXEditor: dynamic import added (#5)

* Main elements created

* Add Editor to the writing page
This commit is contained in:
Peter Savchenko 2018-09-19 01:47:32 +03:00 committed by GitHub
parent 4326cb22ab
commit e7e64cea3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 15676 additions and 820 deletions

View file

@ -2,11 +2,42 @@
// eslint-disable-next-line no-unused-vars
import css from '../styles/main.pcss';
module.exports = class Docs {
/**
* Module Dispatcher
* @see {@link https://github.com/codex-team/moduleDispatcher}
* @author CodeX
*/
import ModuleDispatcher from 'module-dispatcher';
/**
* Import modules
*/
import Writing from './modules/writing';
/**
* Main app class
*/
class Docs {
/**
* @constructor
*/
constructor() {
console.log('CodeX Docs initialized');
this.writing = new Writing();
document.addEventListener('DOMContentLoaded', (event) => {
this.docReady();
});
}
};
/**
* Document is ready
*/
docReady() {
this.moduleDispatcher = new ModuleDispatcher({
Library: window.Docs
});
}
}
module.exports = new Docs();

View file

@ -0,0 +1,28 @@
/**
* Module for pages create/edit
*/
module.exports = class Writing {
constructor(){
}
/**
* Called by ModuleDispatcher to initialize module from DOM
*/
init(config, moduleEl) {
this.editorWrapper = document.createElement('div');
this.editorWrapper.id = 'codex-editor';
moduleEl.appendChild(this.editorWrapper);
this.loadEditor().then(() => {
console.log('Editor loaded');
})
};
loadEditor(){
return import(/* webpackChunkName: "codex-editor" */ 'codex.editor').then(({ default: CodexEditor }) => {
console.log('codex-editor', new CodexEditor());
}).catch(error => 'An error occurred while loading CodeX Editor');
}
};