Skip to content
Snippets Groups Projects
Commit 48b997af authored by chris's avatar chris
Browse files

new schema creation

parent 43f32894
No related branches found
No related tags found
1 merge request!202new schema creation
......@@ -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: {},
......
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;
}
}
......@@ -58,6 +58,18 @@ const backSpaceShortCut = (state, dispatch, view) => {
);
};
const pressEnter = (state, dispatch) => {
// LISTS
console.log(state);
console.log('lisr', splitListItem(state.schema.nodes.list_item)(state));
splitListItem(state.schema.nodes.list_item)(state, dispatch);
if (splitListItem(state.schema.nodes.list_item)(state)) {
return true;
}
return false;
};
const undoShortCut = (state, dispatch, view) =>
undo(state, tr => dispatch(tr.setMeta('inputType', 'Undo')), view);
......@@ -68,7 +80,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 +92,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 +132,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),
};
......
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';
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment