add missing methods

This commit is contained in:
Philipp Kühn
2020-09-08 11:00:31 +02:00
parent 56093e3fd0
commit 678b6444d2

View File

@@ -789,6 +789,11 @@ interface ExtensionExtends<Callback = ExtensionCallback> {
name: string
options: AnyObject
commands: (params: Callback) => CommandSpec
inputRules: (params: Callback) => any[]
pasteRules: (params: Callback) => any[]
keys: (params: Callback) => {
[key: string]: Function
}
plugins: (params: Callback) => Plugin[]
}
@@ -830,6 +835,21 @@ class ExtensionTest<Options, Extends extends ExtensionExtends = ExtensionExtends
return this
}
public keys(value: Extends['keys']) {
this.storeConfig('keys', value, 'overwrite')
return this
}
public inputRules(value: Extends['inputRules']) {
this.storeConfig('inputRules', value, 'overwrite')
return this
}
public pasteRules(value: Extends['pasteRules']) {
this.storeConfig('pasteRules', value, 'overwrite')
return this
}
public plugins(value: Extends['plugins']) {
this.storeConfig('plugins', value, 'overwrite')
return this
@@ -885,6 +905,9 @@ const Suggestion = new NodeTest<TestOptions>()
.schema(() => ({
toDOM: () => ['div', 0]
}))
.keys(({ editor }) => ({
'Mod-i': () => editor.italic(),
}))
.commands(({ editor, name }) => ({
[name]: next => () => {
editor.toggleMark(name)