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