From a2446cd93030cdcdd36d12a92d2498219547c913 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Thu, 19 Dec 2019 21:40:39 +0200 Subject: [PATCH] SmallCaps Service --- .../SmallCapsService/SmallCaps.js | 23 +++++++++++++++++++ .../SmallCapsService/SmallCapsService.js | 18 +++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 wax-prosemirror-plugins/src/InlineAnnotations/SmallCapsService/SmallCaps.js create mode 100644 wax-prosemirror-plugins/src/InlineAnnotations/SmallCapsService/SmallCapsService.js diff --git a/wax-prosemirror-plugins/src/InlineAnnotations/SmallCapsService/SmallCaps.js b/wax-prosemirror-plugins/src/InlineAnnotations/SmallCapsService/SmallCaps.js new file mode 100644 index 000000000..34162290c --- /dev/null +++ b/wax-prosemirror-plugins/src/InlineAnnotations/SmallCapsService/SmallCaps.js @@ -0,0 +1,23 @@ +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 SmallCaps extends Tools { + title = "Toggle Small Caps"; + content = icons.small_caps; + + get run() { + return (state, dispatch) => { + toggleMark(state.config.schema.marks.smallcaps)(state, dispatch); + }; + } + + get active() { + return state => { + return markActive(state.config.schema.marks.smallcaps)(state); + }; + } +} diff --git a/wax-prosemirror-plugins/src/InlineAnnotations/SmallCapsService/SmallCapsService.js b/wax-prosemirror-plugins/src/InlineAnnotations/SmallCapsService/SmallCapsService.js new file mode 100644 index 000000000..5e7959d59 --- /dev/null +++ b/wax-prosemirror-plugins/src/InlineAnnotations/SmallCapsService/SmallCapsService.js @@ -0,0 +1,18 @@ +import Service from "wax-prosemirror-core/src/services/Service"; +import { smallcapsMark } from "wax-prosemirror-schema"; +import SmallCaps from "./SmallCaps"; + +class SmallCapsService extends Service { + register() { + this.container.bind("SmallCaps").to(SmallCaps); + + this.container + .bind("schema") + .toConstantValue({ + smallcaps: smallcapsMark + }) + .whenTargetNamed("mark"); + } +} + +export default SmallCapsService; -- GitLab