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