1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-21 06:09:41 +02:00
codex.docs/src/frontend/js/classes/editor.js

44 lines
801 B
JavaScript
Raw Normal View History

import CodeXEditor from 'codex.editor';
import Header from 'codex.editor.header';
/**
* Class for working with Editor.js
*/
export default class Editor {
/**
* Creates Editor instance
* @property {object} initialData - data to start with
*/
constructor({initialData}) {
this.editor = new CodeXEditor({
tools: {
header: {
class: Header,
config: {
placeholder: 'Enter a title'
}
}
},
data: initialData || {
blocks: [
{
type: 'header',
data: {
text: '',
level: 2
}
}
]
}
});
}
/**
* Return Editor data
* @return {Promise.<{}>}
*/
save() {
return this.editor.saver.save();
}
}