diff --git a/wax-prosemirror-core/src/Application.js b/wax-prosemirror-core/src/Application.js index 15e88d829e57f928cc308ab93b09d18bbb495053..cee436005fbc2fbdfeb7d910c41451282fd8d64b 100644 --- a/wax-prosemirror-core/src/Application.js +++ b/wax-prosemirror-core/src/Application.js @@ -8,6 +8,7 @@ export default class Application { container = {}; config = {}; PmPlugins = {}; + constructor(container) { this.container = container; this.PmPlugins = container.get("PmPlugins"); diff --git a/wax-prosemirror-plugins/src/InlineAnnotations/CodeService/CodeService.js b/wax-prosemirror-plugins/src/InlineAnnotations/CodeService/CodeService.js index 9939652f38169f9c681031e4dbd97208bace1310..2baafb75211b7f09334e5eb9b24e237bf9fd7f70 100644 --- a/wax-prosemirror-plugins/src/InlineAnnotations/CodeService/CodeService.js +++ b/wax-prosemirror-plugins/src/InlineAnnotations/CodeService/CodeService.js @@ -5,9 +5,10 @@ console.log(codeMark); class CodeService extends Service { boot() { const createMark = this.container.get("CreateMark"); + createMark({ code: { - parseDOM: [{ tag: "code" }], + parseDOM: { tag: "code" }, toDOM(hook, next) { hook.value = ["code", 0]; next(); diff --git a/wax-prosemirror-plugins/src/RulesService/RulesService.js b/wax-prosemirror-plugins/src/RulesService/RulesService.js index f7e5bc57473a71b173d5b520729a9bcccbc03c4e..a1a578ef0fe496fd8650a3c371ae1fd88d2a6bbf 100644 --- a/wax-prosemirror-plugins/src/RulesService/RulesService.js +++ b/wax-prosemirror-plugins/src/RulesService/RulesService.js @@ -11,10 +11,13 @@ export default class RulesService extends Service { register() { const PmPlugins = this.app.PmPlugins; const configRules = this.config; - const { schema } = this; + this.container .bind("Rules") - .toDynamicValue(() => new Rules(schema, PmPlugins)) + .toDynamicValue(() => { + const { schema } = this; + return new Rules(schema, PmPlugins); + }) .inSingletonScope(); const rules = this.container.get("Rules"); rules.addRule(configRules); diff --git a/wax-prosemirror-plugins/src/SchemaService/ParseRule.js b/wax-prosemirror-plugins/src/SchemaService/ParseRule.js index 3245551c6e0e393e0d77e8996da76b377eaebbeb..5f757b0fe354bc4b171e4299b795ff10f683bc7f 100644 --- a/wax-prosemirror-plugins/src/SchemaService/ParseRule.js +++ b/wax-prosemirror-plugins/src/SchemaService/ParseRule.js @@ -3,30 +3,36 @@ import Middleware from "../lib/Middleware"; export default class ParseRule { tag = ""; - exporter = {}; + exporter = null; constructor({ getAttrs, tag }) { this.tag = tag; - this.exporter = new Middleware(); + if (getAttrs) { + this.exporter = new Middleware(); + } this.addStack(getAttrs); } addStack(getAttrs) { - this.exporter.use(getAttrs); + if (getAttrs) { + this.exporter.use(getAttrs); + } } parseSchema(exporter) { - return { - tag: this.tag, - getAttrs(dom) { + const rule = { tag: this.tag }; + if (this.exporter) { + rule.getAttrs = dom => { let hooks = {}; exporter.go({ dom }, hook => { hooks = hook; }); return omit(hooks, ["dom"]); - } - }; + }; + } + console.log(rule, "rule"); + return rule; } combineRules() { diff --git a/wax-prosemirror-plugins/src/SchemaService/Schema.js b/wax-prosemirror-plugins/src/SchemaService/Schema.js index 197d67fb0dd39a54909710ae4fb03f8d5f55a0fa..dfa6a68a38211b1baf653e20b105f12d3b81a74d 100644 --- a/wax-prosemirror-plugins/src/SchemaService/Schema.js +++ b/wax-prosemirror-plugins/src/SchemaService/Schema.js @@ -10,6 +10,7 @@ export default class Schema { _nodes = {}; _marks = {}; schema = null; + has(instance) { if (instance instanceof Node) { return this._nodes[instance.name] ? this._nodes[instance.name] : false; @@ -50,6 +51,7 @@ export default class Schema { for (let index in this._marks) { marks[index] = this._marks[index].toJSON(); } + return new PmPschema({ nodes, marks }); } } diff --git a/wax-prosemirror-schema/src/editoria/marks.js b/wax-prosemirror-schema/src/editoria/marks.js index d5792ded525b9989fdb56bba3ae003ca835e1e99..f4c577419bc8bae0bf1d40303e185e2095ab2206 100644 --- a/wax-prosemirror-schema/src/editoria/marks.js +++ b/wax-prosemirror-schema/src/editoria/marks.js @@ -51,12 +51,12 @@ const marks = { return strongDOM; } }, - code: { - parseDOM: [{ tag: "code" }], - toDOM() { - return codeDOM; - } - }, + // code: { + // parseDOM: [{ tag: "code" }], + // toDOM() { + // return codeDOM; + // } + // }, subscript: { excludes: "superscript", parseDOM: [{ tag: "sub" }, { style: "vertical-align=sub" }],