From 2856900c6a99968d3809369e68c3761fb3f3fcef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Tue, 22 Sep 2020 20:23:54 +0200 Subject: [PATCH] fix splitlistitem --- packages/core/src/Editor.ts | 48 --------------------------- packages/core/src/ExtensionManager.ts | 13 +------- packages/extension-list-item/index.ts | 2 +- 3 files changed, 2 insertions(+), 61 deletions(-) diff --git a/packages/core/src/Editor.ts b/packages/core/src/Editor.ts index f98ae33a..3fb95e2d 100644 --- a/packages/core/src/Editor.ts +++ b/packages/core/src/Editor.ts @@ -79,8 +79,6 @@ export class Editor extends EventEmitter { private extensionManager!: ExtensionManager private commands: { [key: string]: any } = {} private css!: HTMLStyleElement - private lastCommand = Promise.resolve() - public lastCommandValue: any = undefined public schema!: Schema public view!: EditorView public selection = { from: 0, to: 0 } @@ -295,33 +293,8 @@ export class Editor extends EventEmitter { throw new Error(`tiptap: '${name}' is a protected name.`) } - // this.commands[name] = this.chainCommand((...args: any) => { - // // console.log('command', this.lastCommandValue) - // const commandValue = callback(() => {}, this.proxy)(...args) - - // // if (commandValue !== undefined) { - // this.lastCommandValue = commandValue - // // } - - // return this.proxy - // }) - - - // this.commands[name] = (...args: any) => { - // const tr = this.state.tr - // callback(...args)({ editor: this.proxy, tr }) - // this.view.dispatch(tr) - // } - this.commands[name] = callback - // // if (commandValue !== undefined) { - // this.lastCommandValue = commandValue - // // } - - // return this.proxy - // }) - return this.proxy } @@ -335,27 +308,6 @@ export class Editor extends EventEmitter { return this.commands[name](...options) } - /** - * Wraps a command to make it chainable. - * - * @param method - */ - private chainCommand = (method: Function) => (...args: any) => { - // console.log('chain', this.lastCommandValue) - // this.lastCommand = this.lastCommand - // .then(() => { - - // const jo = method.apply(this, args) - - // console.log({jo}) - // }) - // // .then(method.apply(this, args)) - // .catch(console.error) - method.apply(this, args) - - return this.proxy - } - /** * Register a ProseMirror plugin. * diff --git a/packages/core/src/ExtensionManager.ts b/packages/core/src/ExtensionManager.ts index 4f4f4e54..df056a02 100644 --- a/packages/core/src/ExtensionManager.ts +++ b/packages/core/src/ExtensionManager.ts @@ -94,18 +94,7 @@ export default class ExtensionManager { return collect(this.extensions) .map(extension => extension.config.keys) .filter(keys => keys) - .map(keys => { - const values = Object.entries(keys).map(([key, action]) => { - return [key, () => { - this.editor.lastCommandValue = undefined - // @ts-ignore - const bla = action().lastCommandValue - // console.log({bla}) - return bla - }] - }) - return keymap(Object.fromEntries(values)) - }) + .map(keys => keymap(keys)) .toArray() } diff --git a/packages/extension-list-item/index.ts b/packages/extension-list-item/index.ts index 4b55442b..e1ae0b52 100644 --- a/packages/extension-list-item/index.ts +++ b/packages/extension-list-item/index.ts @@ -12,7 +12,7 @@ export default new Node() toDOM: () => ['li', 0], })) .keys(({ editor, name }) => ({ - // Enter: () => editor.chain().focus().splitListItem(name).run() + Enter: () => editor.splitListItem(name), // Tab: () => editor.sinkListItem(name), // 'Shift-Tab': () => editor.liftListItem(name), }))