Skip to content
Snippets Groups Projects
Commit 491a053c authored by chris's avatar chris
Browse files

feat(shortcuts): add certain shortcuts

parent f6bf25c0
No related branches found
No related tags found
1 merge request!45Develop
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
......
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);
......
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);
......
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);
......
......@@ -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();
}
......
......@@ -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]);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment