diff --git a/wax-prosemirror-plugins/src/AnnotationService/tools/index.js b/wax-prosemirror-plugins/src/AnnotationService/tools/index.js index af913b5443ae23a4ac0af534fc3ec6e1f29149b6..64e4415430cbd09b32e778b129ea01249a6a1c9c 100644 --- a/wax-prosemirror-plugins/src/AnnotationService/tools/index.js +++ b/wax-prosemirror-plugins/src/AnnotationService/tools/index.js @@ -1,8 +1,5 @@ export { default as Blockquote } from "./Blockquote"; export { default as SmallCaps } from "./SmallCaps"; -export { default as StrikeThrough } from "./StrikeThrough"; -// export { default as Subscript } from "./Subscript"; -export { default as Superscript } from "./Superscript"; export { default as Underline } from "./Underline"; export { default as Table } from "./Table"; export { default as TableDropDownOptions } from "./TableDropDownOptions"; diff --git a/wax-prosemirror-plugins/src/AnnotationService/tools/StrikeThrough.js b/wax-prosemirror-plugins/src/InlineAnnotations/StrikeThroughService/StrikeThrough.js similarity index 83% rename from wax-prosemirror-plugins/src/AnnotationService/tools/StrikeThrough.js rename to wax-prosemirror-plugins/src/InlineAnnotations/StrikeThroughService/StrikeThrough.js index ef38b0a08335971695994a353245547f8a198b29..c89a7d66fed422ce6521601decd8c45b20c84e10 100644 --- a/wax-prosemirror-plugins/src/AnnotationService/tools/StrikeThrough.js +++ b/wax-prosemirror-plugins/src/InlineAnnotations/StrikeThroughService/StrikeThrough.js @@ -17,7 +17,8 @@ export default class StrikeThrough extends Tools { get active() { return state => { - return markActive(state.config.schema.marks.strikethrough)(state); + console.log(state.config); + // return markActive(state.config.schema.marks.strikethrough)(state); }; } } diff --git a/wax-prosemirror-plugins/src/InlineAnnotations/StrikeThroughService/StrikeThroughService.js b/wax-prosemirror-plugins/src/InlineAnnotations/StrikeThroughService/StrikeThroughService.js new file mode 100644 index 0000000000000000000000000000000000000000..e4d8d931b4d769bee1b7366118141c360a7d85ea --- /dev/null +++ b/wax-prosemirror-plugins/src/InlineAnnotations/StrikeThroughService/StrikeThroughService.js @@ -0,0 +1,18 @@ +import Service from "wax-prosemirror-core/src/services/Service"; +import { strikethroughMark } from "wax-prosemirror-schema"; +import StrikeThrough from "./StrikeThrough"; +console.log(strikethroughMark); +class StrikeThroughService extends Service { + register() { + this.container.bind("StrikeThrough").to(StrikeThrough); + + this.container + .bind("schema") + .toConstantValue({ + em: strikethroughMark + }) + .whenTargetNamed("mark"); + } +} + +export default StrikeThroughService; diff --git a/wax-prosemirror-plugins/src/AnnotationService/tools/Superscript.js b/wax-prosemirror-plugins/src/InlineAnnotations/SuperscriptService/Superscript.js similarity index 100% rename from wax-prosemirror-plugins/src/AnnotationService/tools/Superscript.js rename to wax-prosemirror-plugins/src/InlineAnnotations/SuperscriptService/Superscript.js diff --git a/wax-prosemirror-plugins/src/InlineAnnotations/SuperscriptService/SuperscriptService.js b/wax-prosemirror-plugins/src/InlineAnnotations/SuperscriptService/SuperscriptService.js new file mode 100644 index 0000000000000000000000000000000000000000..26ebd501ef320f210676f831d7a49ba21f6d52a1 --- /dev/null +++ b/wax-prosemirror-plugins/src/InlineAnnotations/SuperscriptService/SuperscriptService.js @@ -0,0 +1,18 @@ +import Service from "wax-prosemirror-core/src/services/Service"; +import { superscriptMark } from "wax-prosemirror-schema"; +import Superscript from "./Superscript"; + +class SuperscriptService extends Service { + boot() {} + + register() { + this.container + .bind("schema") + .toConstantValue({ superscript: superscriptMark }) + .whenTargetNamed("mark"); + + this.container.bind("Superscript").to(Superscript); + } +} + +export default SuperscriptService; diff --git a/wax-prosemirror-plugins/src/InlineAnnotations/index.js b/wax-prosemirror-plugins/src/InlineAnnotations/index.js index 1d9705ef190299bf09fcfe0c93c45dc92ccf9e8b..25dec0ebd594e808204c289797cca7cc340ca08d 100644 --- a/wax-prosemirror-plugins/src/InlineAnnotations/index.js +++ b/wax-prosemirror-plugins/src/InlineAnnotations/index.js @@ -2,9 +2,13 @@ import CodeService from "./CodeService/CodeService"; import StrongService from "./StrongService/StrongService"; import EmphasisService from "./EmphasisService/EmphasisService"; import SubscriptService from "./SubscriptService/SubscriptService"; +import SuperscriptService from "./SuperscriptService/SuperscriptService"; +import StrikeThroughService from "./StrikeThroughService/StrikeThroughService"; export default [ new CodeService(), new StrongService(), new EmphasisService(), - new SubscriptService() + new SubscriptService(), + new SuperscriptService(), + new StrikeThroughService() ]; diff --git a/wax-prosemirror-schema/index.js b/wax-prosemirror-schema/index.js index e0c547e00c4a8b6631a314484e2c2e4f30fb90a2..dea985b30a3b68ee2171999c4d1fd78602eb5963 100644 --- a/wax-prosemirror-schema/index.js +++ b/wax-prosemirror-schema/index.js @@ -1,8 +1,18 @@ export { default as DefaultSchema } from "./src/DefaultSchema"; export { default as EditoriaSchema } from "./src/editoria/EditoriaSchema"; export { default as XpubSchema } from "./src/XpubSchema"; + +/* +LIST OF SUPPORTED MARKS +*/ export { default as codeMark } from "./src/marks/codeMark"; export { default as strongMark } from "./src/marks/strongMark"; export { default as linkMark } from "./src/marks/linkMark"; export { default as emphasisMark } from "./src/marks/emphasisMark"; export { default as subscriptMark } from "./src/marks/subscriptMark"; +export { default as superscriptMark } from "./src/marks/superscriptMark"; +export { default as strikethroughMark } from "./src/marks/strikethroughMark"; +export { default as smallcapsMark } from "./src/marks/smallcapsMark"; +/* +LIST OF SUPPORTED NODES +*/ diff --git a/wax-prosemirror-schema/src/editoria/marks.js b/wax-prosemirror-schema/src/editoria/marks.js index dc5a8df6795489fe7ef47f93b711025f4ace5ab2..2191cf6aa864b5c1deffd2990137f9ddaaa7b1f0 100644 --- a/wax-prosemirror-schema/src/editoria/marks.js +++ b/wax-prosemirror-schema/src/editoria/marks.js @@ -3,24 +3,6 @@ const emDOM = ["em", 0], codeDOM = ["code", 0]; const marks = { - superscript: { - excludes: "subscript", - parseDOM: [{ tag: "sup" }, { style: "vertical-align=super" }], - toDOM: () => ["sup"] - }, - strikethrough: { - parseDOM: [ - { tag: "strike" }, - { style: "text-decoration:line-through" }, - { style: "text-decoration-line:line-through" } - ], - toDOM: () => [ - "span", - { - style: "text-decoration-line:line-through" - } - ] - }, underline: { parseDOM: [{ tag: "u" }, { style: "text-decoration:underline" }], toDOM: () => [ diff --git a/wax-prosemirror-schema/src/marks/smallcapsMark.js b/wax-prosemirror-schema/src/marks/smallcapsMark.js new file mode 100644 index 0000000000000000000000000000000000000000..72ba1b55b94bc968ff910216905b6106581930fb --- /dev/null +++ b/wax-prosemirror-schema/src/marks/smallcapsMark.js @@ -0,0 +1,19 @@ +const smallcaps = { + attrs: { + class: { default: "small-caps" } + }, + // inclusive: false, + parseDOM: [ + { + tag: "span.small-caps", + getAttrs(dom) { + return { class: dom.getAttribute("class") }; + } + } + ], + toDOM(node) { + return ["span", node.attrs, 0]; + } +}; + +export default smallcaps; diff --git a/wax-prosemirror-schema/src/marks/strikethroughMark.js b/wax-prosemirror-schema/src/marks/strikethroughMark.js new file mode 100644 index 0000000000000000000000000000000000000000..e7d2c692eecbd89773a181070f63e6af903c2a75 --- /dev/null +++ b/wax-prosemirror-schema/src/marks/strikethroughMark.js @@ -0,0 +1,18 @@ +const strikethrough = { + parseDOM: [ + { tag: "strike" }, + { style: "text-decoration:line-through" }, + { style: "text-decoration-line:line-through" } + ], + toDOM: (hook, next) => { + hook.value = [ + "span", + { + style: "text-decoration-line:line-through" + } + ]; + next(); + } +}; + +export default strikethrough; diff --git a/wax-prosemirror-schema/src/marks/superscriptMark.js b/wax-prosemirror-schema/src/marks/superscriptMark.js new file mode 100644 index 0000000000000000000000000000000000000000..4e4bc5328a2d9ad11544b826c9254cff866cb24d --- /dev/null +++ b/wax-prosemirror-schema/src/marks/superscriptMark.js @@ -0,0 +1,10 @@ +const superscript = { + excludes: "subscript", + parseDOM: [{ tag: "sup" }, { style: "vertical-align=super" }], + toDOM: (hook, next) => { + hook.value = ["sup"]; + next(); + } +}; + +export default superscript; diff --git a/wax-prosemirror-schema/src/marks/underlineMark.js b/wax-prosemirror-schema/src/marks/underlineMark.js new file mode 100644 index 0000000000000000000000000000000000000000..fe7ac335ac85b85691fe59a5b55bb5104af0612e --- /dev/null +++ b/wax-prosemirror-schema/src/marks/underlineMark.js @@ -0,0 +1,14 @@ +const underline = { + parseDOM: [{ tag: "u" }, { style: "text-decoration:underline" }], + toDOM: (hook, next) => { + hook.value = [ + "span", + { + style: "text-decoration:underline" + } + ]; + next(); + } +}; + +export default underline;