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

shortCutsService initial setup

parent d7716a4d
No related branches found
No related tags found
1 merge request!45Develop
...@@ -25,7 +25,7 @@ import invisibles, { ...@@ -25,7 +25,7 @@ import invisibles, {
} from "@guardian/prosemirror-invisibles"; } from "@guardian/prosemirror-invisibles";
import { LayoutService } from "./customServices/LayoutService/LayoutService"; import { LayoutService } from "./customServices/LayoutService/LayoutService";
import { CreateSchema, CreateShortCuts } from "wax-prosemirror-core"; import { CreateSchema } from "wax-prosemirror-core";
import { import {
LinkToolTipPlugin, LinkToolTipPlugin,
FindAndReplacePlugin, FindAndReplacePlugin,
...@@ -49,35 +49,6 @@ const extraNodes = { ...@@ -49,35 +49,6 @@ const extraNodes = {
EditoriaSchema.nodes = { ...EditoriaSchema.nodes, ...extraNodes }; EditoriaSchema.nodes = { ...EditoriaSchema.nodes, ...extraNodes };
const schema = new CreateSchema(EditoriaSchema); const schema = new CreateSchema(EditoriaSchema);
const shortCuts = {
"Mod-b": toggleMark(schema.marks.strong),
"Mod-i": toggleMark(schema.marks.em),
"Mod-u": toggleMark(schema.marks.underline),
"Mod-`": toggleMark(schema.marks.code),
"Ctrl->": wrapIn(schema.nodes.blockquote),
Enter: splitListItem(schema.nodes.list_item),
"Mod-[": liftListItem(schema.nodes.list_item),
"Mod-]": sinkListItem(schema.nodes.list_item),
"Alt-ArrowUp": joinUp,
"Alt-ArrowDown": joinDown,
"Mod-BracketLeft": lift,
Tab: goToNextCell(1),
"Shift-Tab": goToNextCell(-1),
"Shift-Ctrl-0": setBlockType(schema.nodes.paragraph),
"Shift-Ctrl-\\": setBlockType(schema.nodes.code_block),
"Shift-Ctrl-8": wrapInList(schema.nodes.bullet_list),
"Shift-Ctrl-9": wrapInList(schema.nodes.ordered_list),
"Shift-Ctrl-1": setBlockType(schema.nodes.heading, { level: 1 }),
"Shift-Ctrl-2": setBlockType(schema.nodes.heading, { level: 2 }),
"Shift-Ctrl-3": setBlockType(schema.nodes.heading, { level: 3 }),
"Shift-Ctrl-4": setBlockType(schema.nodes.heading, { level: 4 }),
"Shift-Ctrl-5": setBlockType(schema.nodes.heading, { level: 5 }),
"Shift-Ctrl-6": setBlockType(schema.nodes.heading, { level: 6 })
};
// Create shortCuts
const keys = new CreateShortCuts({ schema, shortCuts });
// Add Plugins // Add Plugins
const plugins = [ const plugins = [
columnResizing(), columnResizing(),
...@@ -101,4 +72,4 @@ const services = [new LinkService()]; ...@@ -101,4 +72,4 @@ const services = [new LinkService()];
// Add Rules // Add Rules
export { schema, keys, plugins, services }; export { schema, plugins, services };
...@@ -15,5 +15,10 @@ export default { ...@@ -15,5 +15,10 @@ export default {
{ {
rules: [emDash, ellipsis] rules: [emDash, ellipsis]
} }
],
RulesService: [
{
shortCuts: {}
}
] ]
}; };
export { default as Wax } from "./src/Wax"; export { default as Wax } from "./src/Wax";
export { default as CreateSchema } from "./src/config/classes/CreateSchema"; export { default as CreateSchema } from "./src/config/classes/CreateSchema";
export {
default as CreateShortCuts
} from "./src/config/classes/CreateShortCuts";
export { default as Service } from "./src/services/Service"; export { default as Service } from "./src/services/Service";
import LayoutService from "../services/LayoutService/LayoutService"; import LayoutService from "../services/LayoutService/LayoutService";
import { import {
MenuService,
AnnotationService, AnnotationService,
ImageService,
MenuService,
RedoUndoService, RedoUndoService,
TextStyleService,
PlaceholderService, PlaceholderService,
ImageService, RulesService,
RulesService ShortCutsService,
TextStyleService
} from "wax-prosemirror-plugins"; } from "wax-prosemirror-plugins";
export default { export default {
services: [ services: [
new RulesService(), new RulesService(),
new ShortCutsService(),
new LayoutService(), new LayoutService(),
new MenuService(), new MenuService(),
new RedoUndoService(), new RedoUndoService(),
......
...@@ -11,8 +11,6 @@ import WaxView from "./WaxView"; ...@@ -11,8 +11,6 @@ import WaxView from "./WaxView";
import defaultPlugins from "./config/defaultPlugins"; import defaultPlugins from "./config/defaultPlugins";
import placeholder from "./config/plugins/placeholder"; import placeholder from "./config/plugins/placeholder";
import CreateShortCuts from "./config/classes/CreateShortCuts";
const parser = schema => { const parser = schema => {
const parser = DOMParser.fromSchema(schema); const parser = DOMParser.fromSchema(schema);
......
...@@ -19,5 +19,7 @@ export { ...@@ -19,5 +19,7 @@ export {
} from "./src/PlaceholderService/PlaceholderService"; } from "./src/PlaceholderService/PlaceholderService";
export { default as ImageService } from "./src/ImageService/ImageService"; export { default as ImageService } from "./src/ImageService/ImageService";
export { default as RulesService } from "./src/RulesService/RulesService"; export { default as RulesService } from "./src/RulesService/RulesService";
export {
default as ShortCutsService
} from "./src/ShortCutsService/ShortCutsService";
export { default as Tool } from "./src/lib/Tools"; export { default as Tool } from "./src/lib/Tools";
import { injectable, inject } from "inversify"; import { injectable } from "inversify";
import { import {
inputRules, inputRules,
wrappingInputRule, wrappingInputRule,
......
import { injectable } from "inversify";
import { keymap } from "prosemirror-keymap"; import { keymap } from "prosemirror-keymap";
import { undoInputRule } from "prosemirror-inputrules"; import { undoInputRule } from "prosemirror-inputrules";
import { undo, redo } from "prosemirror-history"; import { undo, redo } from "prosemirror-history";
...@@ -10,7 +11,8 @@ import { ...@@ -10,7 +11,8 @@ import {
selectParentNode selectParentNode
} from "prosemirror-commands"; } from "prosemirror-commands";
class CreateShortCuts { @injectable()
class ShortCuts {
constructor(config) { constructor(config) {
this.schema = config.schema; this.schema = config.schema;
this.shortCuts = config.shortCuts; this.shortCuts = config.shortCuts;
...@@ -63,4 +65,4 @@ class CreateShortCuts { ...@@ -63,4 +65,4 @@ class CreateShortCuts {
} }
} }
export default CreateShortCuts; export default ShortCuts;
import Service from "wax-prosemirror-core/src/services/Service";
import ShortCuts from "./ShortCuts";
export default class ShortCutsService extends Service {
name = "ShortCutsService";
boot() {}
register() {}
}
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