mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-25 12:39:03 +08:00
add plugins
This commit is contained in:
parent
3e7bd37d63
commit
4d8e654b51
@ -3,6 +3,7 @@ import deepmerge from 'deepmerge'
|
||||
import collect from 'collect.js'
|
||||
import { Editor, CommandSpec } from '@tiptap/core'
|
||||
import cloneDeep from 'clone-deep'
|
||||
import { Plugin } from "prosemirror-state";
|
||||
|
||||
// type RecursivePartial<T> = {
|
||||
// [P in keyof T]?:
|
||||
@ -788,6 +789,7 @@ interface ExtensionExtends<Callback = ExtensionCallback> {
|
||||
name: string
|
||||
options: AnyObject
|
||||
commands: (params: Callback) => CommandSpec
|
||||
plugins: (params: Callback) => Plugin[]
|
||||
}
|
||||
|
||||
class ExtensionTest<Options, Extends extends ExtensionExtends = ExtensionExtends> {
|
||||
@ -828,6 +830,11 @@ class ExtensionTest<Options, Extends extends ExtensionExtends = ExtensionExtends
|
||||
return this
|
||||
}
|
||||
|
||||
public plugins(value: Extends['plugins']) {
|
||||
this.storeConfig('plugins', value, 'overwrite')
|
||||
return this
|
||||
}
|
||||
|
||||
public extend<T extends Extract<keyof Extends, string>>(key: T, value: Extends[T]) {
|
||||
this.storeConfig(key, value, 'extend')
|
||||
return this
|
||||
@ -884,6 +891,9 @@ const Suggestion = new NodeTest<TestOptions>()
|
||||
next()
|
||||
},
|
||||
}))
|
||||
.plugins(() => [
|
||||
new Plugin({}),
|
||||
])
|
||||
.extend('schema', () => ({
|
||||
toDOM: () => ['span', 0],
|
||||
}))
|
||||
|
Loading…
Reference in New Issue
Block a user