diff --git a/editors/editoria/src/config/config.js b/editors/editoria/src/config/config.js index dabe19bde78b8fbb85ff316301e8222815ab12d0..72381316256b8bf69bc55671fdc477d94ab95008 100644 --- a/editors/editoria/src/config/config.js +++ b/editors/editoria/src/config/config.js @@ -30,6 +30,8 @@ import { TrackingAndEditingToolGroupService, } from 'wax-prosemirror-services'; +import { DefaultSchema } from 'wax-prosemirror-utilities'; + import { WaxSelectionPlugin } from 'wax-prosemirror-plugins'; import invisibles, { @@ -62,7 +64,7 @@ export default { }, ], - SchemaService: {}, + SchemaService: DefaultSchema, RulesService: [emDash, ellipsis], ShortCutsService: {}, diff --git a/wax-prosemirror-services/src/SchemaService/Schema.js b/wax-prosemirror-services/src/SchemaService/Schema.js index 34672efc627b113c516afb315e74dd7dede087b2..304b5a94caf83359c19e27e67ccf7dc48b26ae96 100644 --- a/wax-prosemirror-services/src/SchemaService/Schema.js +++ b/wax-prosemirror-services/src/SchemaService/Schema.js @@ -1,8 +1,5 @@ import { Schema as PmPschema } from 'prosemirror-model'; import { injectable } from 'inversify'; -import { pickBy, identity } from 'lodash'; -import DefaultSchema from './DefaultSchema'; - import Node from './Node'; import Mark from './Mark'; @@ -83,7 +80,7 @@ class Schema { } getSchema() { - const nodes = DefaultSchema.nodes; + const nodes = {}; const marks = {}; // console.log(this._nodes); @@ -96,15 +93,20 @@ class Schema { } this.schema = new PmPschema({ - nodes: pickBy( - Object.assign(nodes, this.prosemirrorSchema.nodes), - identity, - ), - marks: pickBy( - Object.assign(marks, this.prosemirrorSchema.marks), - identity, - ), + nodes: Object.assign(this.prosemirrorSchema.nodes, nodes), + marks: Object.assign(this.prosemirrorSchema.marks, marks), }); + + // this.schema = new PmPschema({ + // nodes: pickBy( + // Object.assign(nodes, this.prosemirrorSchema.nodes), + // identity, + // ), + // marks: pickBy( + // Object.assign(marks, this.prosemirrorSchema.marks), + // identity, + // ), + // }); return this.schema; } } diff --git a/wax-prosemirror-services/src/ShortCutsService/ShortCuts.js b/wax-prosemirror-services/src/ShortCutsService/ShortCuts.js index 87660df9becf605ccfc296c75e60cda40c369451..34a4af4490db338a3d0068447d4028af52ba0734 100644 --- a/wax-prosemirror-services/src/ShortCutsService/ShortCuts.js +++ b/wax-prosemirror-services/src/ShortCutsService/ShortCuts.js @@ -58,6 +58,16 @@ const backSpaceShortCut = (state, dispatch, view) => { ); }; +const pressEnter = (state, dispatch) => { + // LISTS + if (splitListItem(state.schema.nodes.list_item)(state)) { + splitListItem(state.schema.nodes.list_item)(state, dispatch); + return true; + } + + return false; +}; + const undoShortCut = (state, dispatch, view) => undo(state, tr => dispatch(tr.setMeta('inputType', 'Undo')), view); @@ -68,7 +78,6 @@ const redoShortCut = (state, dispatch, view) => class ShortCuts { constructor(plugins, schema) { this.insertBreak = this.insertBreak.bind(this); - this.pressEnter = this.pressEnter.bind(this); this.insertRule = this.insertRule.bind(this); this.PmPlugins = plugins; this.schema = schema; @@ -81,16 +90,6 @@ class ShortCuts { return true; } - pressEnter(state, dispatch) { - // LISTS - if (splitListItem(this.schema.nodes.list_item)(state)) { - splitListItem(this.schema.nodes.list_item)(state, dispatch); - return true; - } - - return false; - } - insertRule(state, dispatch) { const hr = this.schema.nodes.horizontal_rule.create(); dispatch(state.tr.replaceSelectionWith(hr).scrollIntoView()); @@ -131,7 +130,7 @@ class ShortCuts { 'Mod-_': this.insertRule, 'Mod-[': liftListItem(this.schema.nodes.list_item), 'Mod-]': sinkListItem(this.schema.nodes.list_item), - Enter: this.pressEnter, + Enter: pressEnter, 'Shift-Ctrl-8': wrapInList(this.schema.nodes.bulletlist), 'Shift-Ctrl-9': wrapInList(this.schema.nodes.orderedlist), }; diff --git a/wax-prosemirror-utilities/index.js b/wax-prosemirror-utilities/index.js index 6996a4213ca6d4fc2401d8956792d362b931083f..5abfc388661e794874a54c51e5c5800cb0b9e71f 100644 --- a/wax-prosemirror-utilities/index.js +++ b/wax-prosemirror-utilities/index.js @@ -1,3 +1,4 @@ -export { default as SchemaHelpers } from "./src/schema/SchemaHelpers"; -export { default as DocumentHelpers } from "./src/document/DocumentHelpers"; -export { default as Commands } from "./src/commands/Commands"; +export { default as SchemaHelpers } from './src/schema/SchemaHelpers'; +export { default as DocumentHelpers } from './src/document/DocumentHelpers'; +export { default as Commands } from './src/commands/Commands'; +export { default as DefaultSchema } from './src/schema/DefaultSchema'; diff --git a/wax-prosemirror-services/src/SchemaService/DefaultSchema.js b/wax-prosemirror-utilities/src/schema/DefaultSchema.js similarity index 100% rename from wax-prosemirror-services/src/SchemaService/DefaultSchema.js rename to wax-prosemirror-utilities/src/schema/DefaultSchema.js