don't load godo blocksMenu when use basic schema (#59583)
This commit is contained in:
parent
cc7b2bb9aa
commit
209915808f
|
@ -23,10 +23,12 @@ export default class Godo {
|
||||||
|
|
||||||
constructor (textarea, options) {
|
constructor (textarea, options) {
|
||||||
this.textarea = textarea;
|
this.textarea = textarea;
|
||||||
|
let displayBlocksMenu = true;
|
||||||
|
|
||||||
this.schema = (() => {
|
this.schema = (() => {
|
||||||
switch(options.schema) {
|
switch(options.schema) {
|
||||||
case 'basic':
|
case 'basic':
|
||||||
|
displayBlocksMenu = false;
|
||||||
return basic_schema;
|
return basic_schema;
|
||||||
break;
|
break;
|
||||||
case 'headers':
|
case 'headers':
|
||||||
|
@ -43,18 +45,21 @@ export default class Godo {
|
||||||
textarea.insertAdjacentElement('afterend', this.editor_wrapper);
|
textarea.insertAdjacentElement('afterend', this.editor_wrapper);
|
||||||
|
|
||||||
this.marksMenu = menuPlugin(marks(this.schema));
|
this.marksMenu = menuPlugin(marks(this.schema));
|
||||||
this.blockMenu = menuPlugin(blocks(this.schema));
|
this.blocksMenu = menuPlugin(blocks(this.schema));
|
||||||
|
|
||||||
|
let plugins_list = [
|
||||||
|
history(),
|
||||||
|
keymap(baseKeymap),
|
||||||
|
keymap(buildKeymap(this.schema)),
|
||||||
|
this.marksMenu
|
||||||
|
];
|
||||||
|
|
||||||
|
if (displayBlocksMenu) plugins_list.push(this.blocksMenu);
|
||||||
|
|
||||||
this.state = EditorState.create({
|
this.state = EditorState.create({
|
||||||
schema: this.schema,
|
schema: this.schema,
|
||||||
doc: DOMParser.fromSchema(this.schema).parse(this.get_textarea_content()),
|
doc: DOMParser.fromSchema(this.schema).parse(this.get_textarea_content()),
|
||||||
plugins: [
|
plugins: plugins_list
|
||||||
history(),
|
|
||||||
keymap(baseKeymap),
|
|
||||||
keymap(buildKeymap(this.schema)),
|
|
||||||
this.marksMenu,
|
|
||||||
this.blockMenu
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.view = new EditorView(this.editor_wrapper, {
|
this.view = new EditorView(this.editor_wrapper, {
|
||||||
|
|
Loading…
Reference in New Issue