Skip to content
Snippets Groups Projects
Commit 5d96bd04 authored by chris's avatar chris
Browse files

Merge branch 'wax-plugins' of gitlab.coko.foundation:wax/wax-prosemirror into wax-plugins

parents 64c28550 14940486
No related branches found
No related tags found
1 merge request!45Develop
import { emDash, ellipsis } from "prosemirror-inputrules"; import { emDash, ellipsis } from "prosemirror-inputrules";
import { columnResizing, tableEditing } from "prosemirror-tables"; import { columnResizing, tableEditing } from "prosemirror-tables";
import {
ImageService,
PlaceholderService,
TextStyleService,
InlineAnnotationsService,
LinkService,
ListsService,
ListToolGroupService,
TablesService,
TableToolGroupService,
BaseService,
BaseToolGroupService,
DisplayBlockLevelService,
DisplayToolGroupService,
ImageToolGroupService
} from "wax-prosemirror-services";
import invisibles, { import invisibles, {
space, space,
hardBreak, hardBreak,
...@@ -27,5 +44,25 @@ export default { ...@@ -27,5 +44,25 @@ export default {
tableEditing(), tableEditing(),
// TrackChangePlugin({ options: {} }), // TrackChangePlugin({ options: {} }),
invisibles([hardBreak()]) invisibles([hardBreak()])
],
services: [
new ListToolGroupService(),
new TextStyleService(),
new PlaceholderService(),
new ImageService(),
new InlineAnnotationsService(),
// new OverlayService()
new LinkService(),
new ListsService(),
new TableToolGroupService(),
new TablesService(),
new BaseService(),
new BaseToolGroupService(),
//new ImageToolGroupService(),
new DisplayBlockLevelService(),
new DisplayToolGroupService(),
// new TextBlockLevelService(),
// new TextToolGroupService()
new ImageToolGroupService()
] ]
}; };
...@@ -27,7 +27,8 @@ ...@@ -27,7 +27,8 @@
"inversify": "^5.0.1", "inversify": "^5.0.1",
"inversify-inject-decorators": "^3.1.0", "inversify-inject-decorators": "^3.1.0",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"wax-prosemirror-services": "^0.0.3" "wax-prosemirror-services": "^0.0.3",
"deepmerge": "^4.2.2"
}, },
"devDependencies": { "devDependencies": {
"mocha": "^3.4.2", "mocha": "^3.4.2",
......
import { Container } from "inversify"; import { Container } from "inversify";
import "reflect-metadata"; import "reflect-metadata";
import deepmerge from "deepmerge";
import Config from "./config/Config"; import Config from "./config/Config";
import defaultConfig from "./config/defaultConfig"; import defaultConfig from "./config/defaultConfig";
import PmPlugins from "./PmPlugins"; import PmPlugins from "./PmPlugins";
...@@ -77,6 +78,11 @@ export default class Application { ...@@ -77,6 +78,11 @@ export default class Application {
.inSingletonScope(); .inSingletonScope();
container.bind("Wax").toFactory(() => new Application(container)); container.bind("Wax").toFactory(() => new Application(container));
defaultConfig.services = defaultConfig.services.concat(
config.config.services
);
container.bind("config").toConstantValue(defaultConfig); container.bind("config").toConstantValue(defaultConfig);
container container
.bind("Config") .bind("Config")
......
...@@ -44,7 +44,6 @@ class Wax extends Component { ...@@ -44,7 +44,6 @@ class Wax extends Component {
this.application = Application.create(props); this.application = Application.create(props);
const schema = this.application.getSchema(); const schema = this.application.getSchema();
this.application.bootServices(); this.application.bootServices();
const { value, onChange } = this.props; const { value, onChange } = this.props;
const WaxOnchange = onChange ? onChange : value => true; const WaxOnchange = onChange ? onChange : value => true;
......
...@@ -4,25 +4,7 @@ import { ...@@ -4,25 +4,7 @@ import {
MenuService, MenuService,
RulesService, RulesService,
ShortCutsService, ShortCutsService,
AnnotationToolGroupService, AnnotationToolGroupService
/*TODO MOVE FROM DEFAULT CONFIG*/
ImageService,
PlaceholderService,
TextStyleService,
InlineAnnotationsService,
LinkService,
OverlayService,
ListsService,
ListToolGroupService,
TablesService,
TableToolGroupService,
BaseService,
BaseToolGroupService,
ImageToolGroupService,
TextBlockLevelService,
TextToolGroupService,
DisplayBlockLevelService,
DisplayToolGroupService
} from "wax-prosemirror-services"; } from "wax-prosemirror-services";
export default { export default {
...@@ -32,23 +14,6 @@ export default { ...@@ -32,23 +14,6 @@ export default {
new ShortCutsService(), new ShortCutsService(),
new LayoutService(), new LayoutService(),
new MenuService(), new MenuService(),
new AnnotationToolGroupService(), new AnnotationToolGroupService()
new ListToolGroupService(),
new DisplayBlockLevelService(),
new DisplayToolGroupService(),
// new TextStyleService(),
new PlaceholderService(),
new ImageService(),
new InlineAnnotationsService(),
// new OverlayService()
new LinkService(),
new ListsService(),
new TableToolGroupService(),
new TablesService(),
new BaseService(),
new BaseToolGroupService(),
new ImageToolGroupService()
// new TextBlockLevelService(),
// new TextToolGroupService()
] ]
}; };
...@@ -17,13 +17,13 @@ export default class LinkService extends Service { ...@@ -17,13 +17,13 @@ export default class LinkService extends Service {
register() { register() {
this.container.bind("Link").to(LinkTool); this.container.bind("Link").to(LinkTool);
const createMark = this.container.get("CreateMark");
this.container createMark(
.bind("schema") {
.toConstantValue({
link: linkMark link: linkMark
}) },
.whenTargetNamed("mark"); { toWaxSchema: true }
);
} }
dependencies = [new OverlayService()]; dependencies = [new OverlayService()];
......
...@@ -16,7 +16,7 @@ export default class LinkTool extends Tools { ...@@ -16,7 +16,7 @@ export default class LinkTool extends Tools {
return true; return true;
} }
toggleMark(state.config.schema.marks.link, { href: "#" })( toggleMark(state.config.schema.marks.link, { href: "ld#" })(
state, state,
dispatch dispatch
); );
......
...@@ -12,54 +12,38 @@ export default class Schema { ...@@ -12,54 +12,38 @@ export default class Schema {
prosemirrorSchema = { nodes: {}, marks: {} }; prosemirrorSchema = { nodes: {}, marks: {} };
schema = null; schema = null;
constructor( addNode(schemaConfig) {
@multiInject("schema") const name = Object.keys(schemaConfig)[0];
@named("mark") const config = schemaConfig[name];
marks,
@multiInject("schema")
@named("node")
nodes
) {
this.setNodes(nodes);
this.setMarks(marks);
}
setNodes(nodes) {
return nodes.map(schemaConfig => {
const name = Object.keys(schemaConfig)[0];
const config = schemaConfig[name];
const node = new Node(name); const node = new Node(name);
let nd = {}; let nd = {};
if ((nd = this.has(node))) { if ((nd = this.has(node))) {
nd.fromJSON(config); nd.fromJSON(config);
return nd; return nd;
} else { } else {
node.fromJSON(config); node.fromJSON(config);
this.addSchema(node); this.addSchema(node);
return { [name]: node }; return { [name]: node };
} }
});
} }
setMarks(marks) { addMark(schemaConfig) {
return marks.map(schemaConfig => { const name = Object.keys(schemaConfig)[0];
const name = Object.keys(schemaConfig)[0]; const config = schemaConfig[name];
const config = schemaConfig[name];
const mark = new Mark(name);
const mark = new Mark(name); let mr = {};
let mr = {}; if ((mr = this.has(mark))) {
if ((mr = this.has(mark))) { mr.fromJSON(config);
mr.fromJSON(config); return mr;
return mr; } else {
} else { mark.fromJSON(config);
mark.fromJSON(config); this.addSchema(mark);
this.addSchema(mark); return { [name]: mark };
return { [name]: mark }; }
}
});
} }
has(instance) { has(instance) {
......
...@@ -14,14 +14,10 @@ export default class SchemaService extends Service { ...@@ -14,14 +14,10 @@ export default class SchemaService extends Service {
this.container.bind("CreateNode").toFactory(context => { this.container.bind("CreateNode").toFactory(context => {
return (schema, options = { toWaxSchema: false }) => { return (schema, options = { toWaxSchema: false }) => {
const schemaInstance = context.container.get("Schema");
if (options.toWaxSchema) { if (options.toWaxSchema) {
context.container schemaInstance.addNode(schema);
.bind("schema")
.toConstantValue(schema)
.whenTargetNamed("node");
} else { } else {
const schemaInstance = context.container.get("Schema");
schemaInstance.addProsemirrorSchema(schema, "nodes"); schemaInstance.addProsemirrorSchema(schema, "nodes");
} }
}; };
...@@ -29,13 +25,10 @@ export default class SchemaService extends Service { ...@@ -29,13 +25,10 @@ export default class SchemaService extends Service {
this.container.bind("CreateMark").toFactory(context => { this.container.bind("CreateMark").toFactory(context => {
return (schema, options = { toWaxSchema: false }) => { return (schema, options = { toWaxSchema: false }) => {
const schemaInstance = context.container.get("Schema");
if (options.toWaxSchema) { if (options.toWaxSchema) {
context.container schemaInstance.addMark(schema);
.bind("schema")
.toConstantValue(schema)
.whenTargetNamed("mark");
} else { } else {
const schemaInstance = context.container.get("Schema");
schemaInstance.addProsemirrorSchema(schema, "marks"); schemaInstance.addProsemirrorSchema(schema, "marks");
} }
}; };
......
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