diff --git a/wax-prosemirror-services/src/InlineAnnotations/CodeService/CodeService.js b/wax-prosemirror-services/src/InlineAnnotations/CodeService/CodeService.js index 543d5f6a407317361ff7c051be439ee79dfe3e8c..aa9e80f1ee9571e648e2a1701379a184111ce4df 100644 --- a/wax-prosemirror-services/src/InlineAnnotations/CodeService/CodeService.js +++ b/wax-prosemirror-services/src/InlineAnnotations/CodeService/CodeService.js @@ -1,9 +1,13 @@ +import { toggleMark } from "prosemirror-commands"; import Service from "wax-prosemirror-core/src/services/Service"; import { codeMark } from "wax-prosemirror-schema"; import Code from "./Code"; class CodeService extends Service { - boot() {} + boot() { + const shortCuts = this.container.get("ShortCuts"); + shortCuts.addShortCut({ "Mod-`": toggleMark(this.schema.marks.code) }); + } register() { this.container diff --git a/wax-prosemirror-services/src/InlineAnnotations/EmphasisService/EmphasisService.js b/wax-prosemirror-services/src/InlineAnnotations/EmphasisService/EmphasisService.js index 190a397ab28ec2c4aafd6a9f87584b17729edf80..7114a88a152b45672eaa43f4cc2676d5f82d8995 100644 --- a/wax-prosemirror-services/src/InlineAnnotations/EmphasisService/EmphasisService.js +++ b/wax-prosemirror-services/src/InlineAnnotations/EmphasisService/EmphasisService.js @@ -1,8 +1,14 @@ +import { toggleMark } from "prosemirror-commands"; import Service from "wax-prosemirror-core/src/services/Service"; import { emphasisMark } from "wax-prosemirror-schema"; import Emphasis from "./Emphasis"; class EmphasisService extends Service { + boot() { + const shortCuts = this.container.get("ShortCuts"); + shortCuts.addShortCut({ "Mod-i": toggleMark(this.schema.marks.em) }); + } + register() { this.container.bind("Emphasis").to(Emphasis); diff --git a/wax-prosemirror-services/src/InlineAnnotations/StrongService/StrongService.js b/wax-prosemirror-services/src/InlineAnnotations/StrongService/StrongService.js index cd954b8fb27581d7202cfd14cf314dffb2aae133..79832f9fcccf9e93651f3b0ee4e47ecc7d0b918d 100644 --- a/wax-prosemirror-services/src/InlineAnnotations/StrongService/StrongService.js +++ b/wax-prosemirror-services/src/InlineAnnotations/StrongService/StrongService.js @@ -1,8 +1,14 @@ +import { toggleMark } from "prosemirror-commands"; import Service from "wax-prosemirror-core/src/services/Service"; import { strongMark } from "wax-prosemirror-schema"; import Strong from "./Strong"; class StrongService extends Service { + boot() { + const shortCuts = this.container.get("ShortCuts"); + shortCuts.addShortCut({ "Mod-b": toggleMark(this.schema.marks.strong) }); + } + register() { this.container.bind("Strong").to(Strong); diff --git a/wax-prosemirror-services/src/InlineAnnotations/UnderlineService/UnderlineService.js b/wax-prosemirror-services/src/InlineAnnotations/UnderlineService/UnderlineService.js index 5e9fd797f3a47d8e57b5af61a3c801db0b30f47f..c72013b98ea41c9ed51d10fb4fd58a0dae724cc9 100644 --- a/wax-prosemirror-services/src/InlineAnnotations/UnderlineService/UnderlineService.js +++ b/wax-prosemirror-services/src/InlineAnnotations/UnderlineService/UnderlineService.js @@ -1,8 +1,14 @@ +import { toggleMark } from "prosemirror-commands"; import Service from "wax-prosemirror-core/src/services/Service"; import { underlineMark } from "wax-prosemirror-schema"; import Underline from "./Underline"; class UnderlineService extends Service { + boot() { + const shortCuts = this.container.get("ShortCuts"); + shortCuts.addShortCut({ "Mod-u": toggleMark(this.schema.marks.underline) }); + } + register() { this.container.bind("Underline").to(Underline); diff --git a/wax-prosemirror-services/src/SchemaService/Schema.js b/wax-prosemirror-services/src/SchemaService/Schema.js index 8360e36e6cb973713856c93eb35dcf18c120591c..0cb402b484fc8e28b85dc810413ad701ceafb1d2 100644 --- a/wax-prosemirror-services/src/SchemaService/Schema.js +++ b/wax-prosemirror-services/src/SchemaService/Schema.js @@ -98,7 +98,6 @@ export default class Schema { nodes[index] = this._nodes[index].toJSON(); } - console.log(this._marks); for (let index in this._marks) { marks[index] = this._marks[index].toJSON(); } diff --git a/wax-prosemirror-services/src/ShortCutsService/ShortCuts.js b/wax-prosemirror-services/src/ShortCutsService/ShortCuts.js index fd511d861b1eb15c9694a8b61b31ebe69152af10..0e4628ac0e795eded156fff198d9d0b32a6190f1 100644 --- a/wax-prosemirror-services/src/ShortCutsService/ShortCuts.js +++ b/wax-prosemirror-services/src/ShortCutsService/ShortCuts.js @@ -13,10 +13,11 @@ import { @injectable() class ShortCuts { + keys = {}; constructor(plugins, schema) { this.PmPlugins = plugins; this.schema = schema; - + this.keys = this.getKeys(); this.insertBreak = this.insertBreak.bind(this); this.insertRule = this.insertRule.bind(this); } @@ -38,12 +39,13 @@ class ShortCuts { this.PmPlugins.add("shortcuts", shortCuts); } - addShortCut() { - /* TODO add shortcut from each package*/ + addShortCut(shortcut) { + this.keys = Object.assign(this.keys, shortcut); + this.createShortCuts(); } createKeyBindings() { - const keys = Object.assign(this.getKeys(), this.shortCuts); + const keys = this.keys; Object.keys(baseKeymap).forEach(key => { if (keys[key]) { keys[key] = chainCommands(keys[key], baseKeymap[key]);