From 92515e2ee42e5c8809afd5bb7e9e64911a1382f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Sun, 23 Sep 2018 08:04:02 +0200 Subject: [PATCH] allow for returning an array of multiple commands --- packages/tiptap-extensions/src/nodes/BulletList.js | 6 +++--- packages/tiptap-extensions/src/nodes/OrderedList.js | 6 +++--- packages/tiptap/src/utils/ExtensionManager.js | 8 ++++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/tiptap-extensions/src/nodes/BulletList.js b/packages/tiptap-extensions/src/nodes/BulletList.js index ab6888f4..d4a0b41b 100644 --- a/packages/tiptap-extensions/src/nodes/BulletList.js +++ b/packages/tiptap-extensions/src/nodes/BulletList.js @@ -1,5 +1,5 @@ import { Node } from 'tiptap' -import { wrappingInputRule, wrapInList, toggleList } from 'tiptap-commands' +import { wrappingInputRule, toggleList } from 'tiptap-commands' export default class BulletNode extends Node { @@ -22,9 +22,9 @@ export default class BulletNode extends Node { return toggleList(type, schema.nodes.list_item) } - keys({ type }) { + keys({ type, schema }) { return { - 'Shift-Ctrl-8': wrapInList(type), + 'Shift-Ctrl-8': toggleList(type, schema.nodes.list_item), } } diff --git a/packages/tiptap-extensions/src/nodes/OrderedList.js b/packages/tiptap-extensions/src/nodes/OrderedList.js index 61184c09..4d56d288 100644 --- a/packages/tiptap-extensions/src/nodes/OrderedList.js +++ b/packages/tiptap-extensions/src/nodes/OrderedList.js @@ -1,5 +1,5 @@ import { Node } from 'tiptap' -import { wrappingInputRule, wrapInList, toggleList } from 'tiptap-commands' +import { wrappingInputRule, toggleList } from 'tiptap-commands' export default class OrderedListNode extends Node { @@ -32,9 +32,9 @@ export default class OrderedListNode extends Node { return toggleList(type, schema.nodes.list_item) } - keys({ type }) { + keys({ type, schema }) { return { - 'Shift-Ctrl-9': wrapInList(type), + 'Shift-Ctrl-9': toggleList(type, schema.nodes.list_item), } } diff --git a/packages/tiptap/src/utils/ExtensionManager.js b/packages/tiptap/src/utils/ExtensionManager.js index b1733a54..eac4cb91 100644 --- a/packages/tiptap/src/utils/ExtensionManager.js +++ b/packages/tiptap/src/utils/ExtensionManager.js @@ -94,11 +94,15 @@ export default class ExtensionManager { ...commands, [name]: attrs => { view.focus() - command({ + + const provider = command({ type: schema[`${type}s`][name], attrs, schema, - })(view.state, view.dispatch, view) + }) + const callbacks = Array.isArray(provider) ? provider : [provider] + + callbacks.forEach(callback => callback(view.state, view.dispatch, view)) }, }), {}) }