diff --git a/wax-prosemirror-plugins/src/AnnotationService/tools/Code.js b/wax-prosemirror-plugins/src/AnnotationService/tools/Code.js deleted file mode 100644 index 61887249a4c332293482402b79f9609392391ce7..0000000000000000000000000000000000000000 --- a/wax-prosemirror-plugins/src/AnnotationService/tools/Code.js +++ /dev/null @@ -1,23 +0,0 @@ -import { toggleMark } from "prosemirror-commands"; -import { markActive } from "../../lib/Utils"; -import Tools from "../../lib/Tools"; -import { injectable } from "inversify"; -import { icons } from "wax-prosemirror-components"; - -@injectable() -export default class Code extends Tools { - title = "Toggle code"; - content = icons.code; - - get run() { - return (state, dispatch) => { - toggleMark(state.config.schema.marks.code)(state, dispatch); - }; - } - - get active() { - return state => { - return markActive(state.config.schema.marks.code)(state); - }; - } -} diff --git a/wax-prosemirror-plugins/src/AnnotationService/tools/Strong.js b/wax-prosemirror-plugins/src/AnnotationService/tools/Strong.js deleted file mode 100644 index c2f94db1e94422520cecb062e55457988ea12d6b..0000000000000000000000000000000000000000 --- a/wax-prosemirror-plugins/src/AnnotationService/tools/Strong.js +++ /dev/null @@ -1,23 +0,0 @@ -import { toggleMark } from "prosemirror-commands"; -import { markActive } from "../../lib/Utils"; -import Tools from "../../lib/Tools"; -import { injectable } from "inversify"; -import { icons } from "wax-prosemirror-components"; - -@injectable() -export default class Strong extends Tools { - title = "Toggle strong"; - content = icons.strong; - - get run() { - return (state, dispatch) => { - toggleMark(state.config.schema.marks.strong)(state, dispatch); - }; - } - - get active() { - return state => { - return markActive(state.config.schema.marks.strong)(state); - }; - } -} diff --git a/wax-prosemirror-plugins/src/AnnotationService/tools/index.js b/wax-prosemirror-plugins/src/AnnotationService/tools/index.js index be85cabc3b9b1dcac46f24c485589b2dc0e7d92f..da37b4865aa1735b4e96771cf340437e6bdcc51b 100644 --- a/wax-prosemirror-plugins/src/AnnotationService/tools/index.js +++ b/wax-prosemirror-plugins/src/AnnotationService/tools/index.js @@ -1,7 +1,7 @@ export { default as Blockquote } from "./Blockquote"; export { default as Em } from "./Em"; // export { default as Code } from "./Code"; -export { default as Link } from "./Link"; +// export { default as Link } from "./Link"; export { default as SmallCaps } from "./SmallCaps"; export { default as StrikeThrough } from "./StrikeThrough"; // export { default as Strong } from "./Strong"; diff --git a/wax-prosemirror-plugins/src/AnnotationService/tools/Link.js b/wax-prosemirror-plugins/src/InlineAnnotations/LinkService/Link.js similarity index 100% rename from wax-prosemirror-plugins/src/AnnotationService/tools/Link.js rename to wax-prosemirror-plugins/src/InlineAnnotations/LinkService/Link.js diff --git a/wax-prosemirror-plugins/src/InlineAnnotations/LinkService/LinkService.js b/wax-prosemirror-plugins/src/InlineAnnotations/LinkService/LinkService.js new file mode 100644 index 0000000000000000000000000000000000000000..10720c6719efa08ecc56544fbf044b9ce418dad7 --- /dev/null +++ b/wax-prosemirror-plugins/src/InlineAnnotations/LinkService/LinkService.js @@ -0,0 +1,17 @@ +import Service from "wax-prosemirror-core/src/services/Service"; +import { linkMark } from "wax-prosemirror-schema"; +import Link from "./Link"; + +class LinkService extends Service { + boot() { + const createMark = this.container.get("CreateMark"); + + createMark({ link: linkMark }); + } + + register() { + this.container.bind("Link").to(Link); + } +} + +export default LinkService; diff --git a/wax-prosemirror-plugins/src/InlineAnnotations/index.js b/wax-prosemirror-plugins/src/InlineAnnotations/index.js index 51cb6f0de07e9700beb6e7af01fa67baee820849..efdd9a4db36d24dbee332e06bc16a52e1b433731 100644 --- a/wax-prosemirror-plugins/src/InlineAnnotations/index.js +++ b/wax-prosemirror-plugins/src/InlineAnnotations/index.js @@ -1,3 +1,4 @@ import CodeService from "./CodeService/CodeService"; import StrongService from "./StrongService/StrongService"; -export default [new CodeService(), new StrongService()]; +import LinkService from "./LinkService/LinkService"; +export default [new CodeService(), new StrongService(), new LinkService()]; diff --git a/wax-prosemirror-schema/index.js b/wax-prosemirror-schema/index.js index 64d1d1e226b2d5ea993c9a0152a5b376cc58c1cf..f05b0c9857fdbf2401753035ba764690cf8b071b 100644 --- a/wax-prosemirror-schema/index.js +++ b/wax-prosemirror-schema/index.js @@ -3,3 +3,4 @@ export { default as EditoriaSchema } from "./src/editoria/EditoriaSchema"; export { default as XpubSchema } from "./src/XpubSchema"; export { default as codeMark } from "./src/marks/codeMark"; export { default as strongMark } from "./src/marks/strongMark"; +export { default as linkMark } from "./src/marks/linkMark"; diff --git a/wax-prosemirror-schema/src/editoria/marks.js b/wax-prosemirror-schema/src/editoria/marks.js index 7c74eee18a12a965313ec888f471ad88b518d36f..a483ed195fa8f668e2016f81fca144c45458778a 100644 --- a/wax-prosemirror-schema/src/editoria/marks.js +++ b/wax-prosemirror-schema/src/editoria/marks.js @@ -3,32 +3,32 @@ const emDOM = ["em", 0], codeDOM = ["code", 0]; const marks = { - link: { - attrs: { - href: { default: null }, - rel: { default: "" }, - target: { default: "blank" }, - title: { default: null } - }, - inclusive: false, - parseDOM: [ - { - tag: "a[href]", - getAttrs: dom => { - const href = dom.getAttribute("href"); - const target = href && href.indexOf("#") === 0 ? "" : "blank"; - return { - href: dom.getAttribute("href"), - title: dom.getAttribute("title"), - target - }; - } - } - ], - toDOM(node) { - return ["a", node.attrs, 0]; - } - }, + // link: { + // attrs: { + // href: { default: null }, + // rel: { default: "" }, + // target: { default: "blank" }, + // title: { default: null } + // }, + // inclusive: false, + // parseDOM: [ + // { + // tag: "a[href]", + // getAttrs: dom => { + // const href = dom.getAttribute("href"); + // const target = href && href.indexOf("#") === 0 ? "" : "blank"; + // return { + // href: dom.getAttribute("href"), + // title: dom.getAttribute("title"), + // target + // }; + // } + // } + // ], + // toDOM(node) { + // return ["a", node.attrs, 0]; + // } + // }, em: { parseDOM: [{ tag: "i" }, { tag: "em" }, { style: "font-style=italic" }], toDOM() { diff --git a/wax-prosemirror-schema/src/marks/linkMark.js b/wax-prosemirror-schema/src/marks/linkMark.js new file mode 100644 index 0000000000000000000000000000000000000000..1549d1537c93867c3e21af718a08f746ad806268 --- /dev/null +++ b/wax-prosemirror-schema/src/marks/linkMark.js @@ -0,0 +1,29 @@ +const link = { + attrs: { + href: { default: null }, + rel: { default: "" }, + target: { default: "blank" }, + title: { default: null } + }, + inclusive: false, + parseDOM: [ + { + tag: "a[href]", + getAttrs: dom => { + const href = dom.getAttribute("href"); + const target = href && href.indexOf("#") === 0 ? "" : "blank"; + return { + href: dom.getAttribute("href"), + title: dom.getAttribute("title"), + target + }; + } + } + ], + toDOM(hook, next, node) { + hook.value = ["a", node.attrs, 0]; + next(); + } +}; + +export default link; diff --git a/wax-prosemirror-schema/src/marks/strongMark.js b/wax-prosemirror-schema/src/marks/strongMark.js index 1979c537d9a2a6dcfcdb7e4af3637bfbefd22b15..32b9482a176d9ee2af6e4fcfe5b10b43c2ad06ad 100644 --- a/wax-prosemirror-schema/src/marks/strongMark.js +++ b/wax-prosemirror-schema/src/marks/strongMark.js @@ -15,3 +15,5 @@ const strong = { next(); } }; + +export default strong;