mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-25 21:35:53 +08:00
allow for returning an array of multiple commands
This commit is contained in:
parent
e51141eb5e
commit
92515e2ee4
@ -1,5 +1,5 @@
|
|||||||
import { Node } from 'tiptap'
|
import { Node } from 'tiptap'
|
||||||
import { wrappingInputRule, wrapInList, toggleList } from 'tiptap-commands'
|
import { wrappingInputRule, toggleList } from 'tiptap-commands'
|
||||||
|
|
||||||
export default class BulletNode extends Node {
|
export default class BulletNode extends Node {
|
||||||
|
|
||||||
@ -22,9 +22,9 @@ export default class BulletNode extends Node {
|
|||||||
return toggleList(type, schema.nodes.list_item)
|
return toggleList(type, schema.nodes.list_item)
|
||||||
}
|
}
|
||||||
|
|
||||||
keys({ type }) {
|
keys({ type, schema }) {
|
||||||
return {
|
return {
|
||||||
'Shift-Ctrl-8': wrapInList(type),
|
'Shift-Ctrl-8': toggleList(type, schema.nodes.list_item),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Node } from 'tiptap'
|
import { Node } from 'tiptap'
|
||||||
import { wrappingInputRule, wrapInList, toggleList } from 'tiptap-commands'
|
import { wrappingInputRule, toggleList } from 'tiptap-commands'
|
||||||
|
|
||||||
export default class OrderedListNode extends Node {
|
export default class OrderedListNode extends Node {
|
||||||
|
|
||||||
@ -32,9 +32,9 @@ export default class OrderedListNode extends Node {
|
|||||||
return toggleList(type, schema.nodes.list_item)
|
return toggleList(type, schema.nodes.list_item)
|
||||||
}
|
}
|
||||||
|
|
||||||
keys({ type }) {
|
keys({ type, schema }) {
|
||||||
return {
|
return {
|
||||||
'Shift-Ctrl-9': wrapInList(type),
|
'Shift-Ctrl-9': toggleList(type, schema.nodes.list_item),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,11 +94,15 @@ export default class ExtensionManager {
|
|||||||
...commands,
|
...commands,
|
||||||
[name]: attrs => {
|
[name]: attrs => {
|
||||||
view.focus()
|
view.focus()
|
||||||
command({
|
|
||||||
|
const provider = command({
|
||||||
type: schema[`${type}s`][name],
|
type: schema[`${type}s`][name],
|
||||||
attrs,
|
attrs,
|
||||||
schema,
|
schema,
|
||||||
})(view.state, view.dispatch, view)
|
})
|
||||||
|
const callbacks = Array.isArray(provider) ? provider : [provider]
|
||||||
|
|
||||||
|
callbacks.forEach(callback => callback(view.state, view.dispatch, view))
|
||||||
},
|
},
|
||||||
}), {})
|
}), {})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user