fix splitlistitem

This commit is contained in:
Philipp Kühn
2020-09-22 20:23:54 +02:00
parent 7f9bb9f1d1
commit 2856900c6a
3 changed files with 2 additions and 61 deletions

View File

@@ -79,8 +79,6 @@ export class Editor extends EventEmitter {
private extensionManager!: ExtensionManager private extensionManager!: ExtensionManager
private commands: { [key: string]: any } = {} private commands: { [key: string]: any } = {}
private css!: HTMLStyleElement private css!: HTMLStyleElement
private lastCommand = Promise.resolve()
public lastCommandValue: any = undefined
public schema!: Schema public schema!: Schema
public view!: EditorView public view!: EditorView
public selection = { from: 0, to: 0 } public selection = { from: 0, to: 0 }
@@ -295,33 +293,8 @@ export class Editor extends EventEmitter {
throw new Error(`tiptap: '${name}' is a protected name.`) 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 this.commands[name] = callback
// // if (commandValue !== undefined) {
// this.lastCommandValue = commandValue
// // }
// return this.proxy
// })
return this.proxy return this.proxy
} }
@@ -335,27 +308,6 @@ export class Editor extends EventEmitter {
return this.commands[name](...options) 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. * Register a ProseMirror plugin.
* *

View File

@@ -94,18 +94,7 @@ export default class ExtensionManager {
return collect(this.extensions) return collect(this.extensions)
.map(extension => extension.config.keys) .map(extension => extension.config.keys)
.filter(keys => keys) .filter(keys => keys)
.map(keys => { .map(keys => keymap(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))
})
.toArray() .toArray()
} }

View File

@@ -12,7 +12,7 @@ export default new Node()
toDOM: () => ['li', 0], toDOM: () => ['li', 0],
})) }))
.keys(({ editor, name }) => ({ .keys(({ editor, name }) => ({
// Enter: () => editor.chain().focus().splitListItem(name).run() Enter: () => editor.splitListItem(name),
// Tab: () => editor.sinkListItem(name), // Tab: () => editor.sinkListItem(name),
// 'Shift-Tab': () => editor.liftListItem(name), // 'Shift-Tab': () => editor.liftListItem(name),
})) }))