fix splitlistitem
This commit is contained in:
@@ -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.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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),
|
||||||
}))
|
}))
|
||||||
|
|||||||
Reference in New Issue
Block a user