From 2965bf0811a580a49523d26340786fd9687bf306 Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Fri, 10 May 2019 18:41:35 +0300
Subject: [PATCH] pass dynamic keys

---
 editors/editoria/src/Editoria.js              | 33 ++++++++++++++++---
 wax-prosemirror-core/index.js                 |  1 +
 .../src/config/classes/WaxKeys.js             | 11 -------
 3 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/editors/editoria/src/Editoria.js b/editors/editoria/src/Editoria.js
index f6b0dd95e..d41233032 100644
--- a/editors/editoria/src/Editoria.js
+++ b/editors/editoria/src/Editoria.js
@@ -1,6 +1,15 @@
 import React, { Component } from "react";
 import styled, { createGlobalStyle } from "styled-components";
-import { orderedList, bulletList, listItem } from "prosemirror-schema-list";
+import {
+  orderedList,
+  bulletList,
+  listItem,
+  wrapInList,
+  splitListItem,
+  liftListItem,
+  sinkListItem
+} from "prosemirror-schema-list";
+
 import {
   tableNodes,
   columnResizing,
@@ -8,7 +17,7 @@ import {
   goToNextCell
 } from "prosemirror-tables";
 
-import { Wax, CreateSchema } from "wax-prosemirror-core";
+import { Wax, CreateSchema, WaxKeys } from "wax-prosemirror-core";
 import { EditoriaSchema } from "wax-prosemirror-schema";
 import { MainMenuBar, SideMenuBar } from "wax-prosemirror-components";
 import "wax-prosemirror-layouts/layouts/editoria-layout.css";
@@ -37,12 +46,26 @@ const extraNodes = {
 };
 
 EditoriaSchema.nodes = { ...EditoriaSchema.nodes, ...extraNodes };
+const schema = new CreateSchema(EditoriaSchema);
+
 const plugins = [columnResizing(), tableEditing()];
-const keys = {};
+
+const shortCuts = {
+  Tab: goToNextCell(1),
+  "Shift-Tab": goToNextCell(-1),
+  Enter: splitListItem(schema.nodes.list_item),
+  "Mod-[": liftListItem(schema.nodes.list_item),
+  "Mod-]": sinkListItem(schema.nodes.list_item),
+  "Shift-Ctrl-8": wrapInList(schema.nodes.bullet_list),
+  "Shift-Ctrl-9": wrapInList(schema.nodes.ordered_list)
+};
+
+const keys = new WaxKeys({ schema: schema, shortCuts: shortCuts });
 
 const options = {
-  schema: new CreateSchema(EditoriaSchema),
-  plugins
+  schema,
+  plugins,
+  keys
 };
 
 const GlobalStyle = createGlobalStyle`
diff --git a/wax-prosemirror-core/index.js b/wax-prosemirror-core/index.js
index c1651b304..0cfad56a8 100644
--- a/wax-prosemirror-core/index.js
+++ b/wax-prosemirror-core/index.js
@@ -1,2 +1,3 @@
 export { default as Wax } from "./src/Wax";
 export { default as CreateSchema } from "./src/config/classes/CreateSchema";
+export { default as WaxKeys } from "./src/config/classes/WaxKeys";
diff --git a/wax-prosemirror-core/src/config/classes/WaxKeys.js b/wax-prosemirror-core/src/config/classes/WaxKeys.js
index d4880d4fd..7f5f0803d 100644
--- a/wax-prosemirror-core/src/config/classes/WaxKeys.js
+++ b/wax-prosemirror-core/src/config/classes/WaxKeys.js
@@ -1,12 +1,6 @@
 import { keymap } from "prosemirror-keymap";
 import { undoInputRule } from "prosemirror-inputrules";
 import { undo, redo } from "prosemirror-history";
-import {
-  wrapInList,
-  splitListItem,
-  liftListItem,
-  sinkListItem
-} from "prosemirror-schema-list";
 
 import {
   baseKeymap,
@@ -69,15 +63,10 @@ class WaxKeys {
       "Mod-i": toggleMark(this.schema.marks.em),
       "Mod-u": toggleMark(this.schema.marks.underline),
       "Mod-`": toggleMark(this.schema.marks.code),
-      "Shift-Ctrl-8": wrapInList(this.schema.nodes.bullet_list),
-      "Shift-Ctrl-9": wrapInList(this.schema.nodes.ordered_list),
       "Ctrl->": wrapIn(this.schema.nodes.blockquote),
       "Mod-Enter": chainCommands(exitCode, this.insertBreak),
       "Shift-Enter": chainCommands(exitCode, this.insertBreak),
       "Ctrl-Enter": chainCommands(exitCode, this.insertBreak), // mac-only?
-      Enter: splitListItem(this.schema.nodes.list_item),
-      "Mod-[": liftListItem(this.schema.nodes.list_item),
-      "Mod-]": sinkListItem(this.schema.nodes.list_item),
       "Shift-Ctrl-0": setBlockType(this.schema.nodes.paragraph),
       "Shift-Ctrl-\\": setBlockType(this.schema.nodes.code_block),
       "Shift-Ctrl-1": setBlockType(this.schema.nodes.heading, { level: 1 }),
-- 
GitLab