add plugins

This commit is contained in:
Philipp Kühn 2020-09-08 08:51:32 +02:00
parent 3e7bd37d63
commit 4d8e654b51

View File

@ -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],
}))