mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-18 22:36:14 +08:00
refactoring
This commit is contained in:
parent
c9ae5fcbcb
commit
8f866d6043
@ -834,26 +834,27 @@ class ExtensionTest<Options, Extends extends ExtensionExtends> {
|
||||
}
|
||||
|
||||
public create() {
|
||||
|
||||
const self = this
|
||||
|
||||
// type ParentOptions = NoInfer<Options>
|
||||
type ParentOptions = Options
|
||||
|
||||
return function<Options = ParentOptions>(options?: Partial<NoInfer<Options>>): ExtensionTest<Options, Extends> {
|
||||
return cloneDeep(self as unknown as ExtensionTest<Options, Extends>, true)
|
||||
.options(options as Options)
|
||||
return <Options = ParentOptions>(options?: Partial<NoInfer<Options>>) => {
|
||||
return cloneDeep(this, true).options(options as Options)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface NodeExtends extends ExtensionExtends {
|
||||
topNode: boolean
|
||||
schema: (params: ExtensionCallback) => NodeSpec
|
||||
}
|
||||
|
||||
class NodeTest<Options> extends ExtensionTest<Options, NodeExtends> {
|
||||
type = 'node'
|
||||
|
||||
public topNode(value: NodeExtends['topNode'] = true) {
|
||||
this.storeConfig('topNode', value, 'overwrite')
|
||||
return this
|
||||
}
|
||||
|
||||
public schema(value: NodeExtends['schema']) {
|
||||
this.storeConfig('schema', value, 'overwrite')
|
||||
return this
|
||||
@ -883,7 +884,11 @@ const Suggestion = new NodeTest<TestOptions>()
|
||||
}))
|
||||
.create()
|
||||
|
||||
console.log(Suggestion().options({ trigger: 'jo' }))
|
||||
// const Blub = new ExtensionTest<TestOptions, ExtensionExtends>()
|
||||
// .name('blub')
|
||||
// .create()
|
||||
|
||||
console.log(Suggestion(), Suggestion().topNode().options({ trigger: 'jo' }))
|
||||
|
||||
// interface MentionOptions {
|
||||
// trigger: string
|
||||
|
Loading…
Reference in New Issue
Block a user