fix options type
This commit is contained in:
@@ -60,15 +60,15 @@ type AnyObject = {
|
|||||||
|
|
||||||
type NoInfer<T> = [T][T extends any ? 0 : never]
|
type NoInfer<T> = [T][T extends any ? 0 : never]
|
||||||
|
|
||||||
export interface ExtensionCallback {
|
export interface ExtensionCallback<Options> {
|
||||||
name: string
|
name: string
|
||||||
editor: Editor
|
editor: Editor
|
||||||
options: any
|
options: Options
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ExtensionExtends<Callback> {
|
export interface ExtensionExtends<Callback, Options> {
|
||||||
name: string
|
name: string
|
||||||
options: AnyObject
|
options: Options
|
||||||
commands: (params: Callback) => CommandSpec
|
commands: (params: Callback) => CommandSpec
|
||||||
inputRules: (params: Callback) => any[]
|
inputRules: (params: Callback) => any[]
|
||||||
pasteRules: (params: Callback) => any[]
|
pasteRules: (params: Callback) => any[]
|
||||||
@@ -78,7 +78,11 @@ export interface ExtensionExtends<Callback> {
|
|||||||
plugins: (params: Callback) => Plugin[]
|
plugins: (params: Callback) => Plugin[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Extension<Options = {}, Callback = ExtensionCallback, Extends extends ExtensionExtends<Callback> = ExtensionExtends<Callback>> {
|
export default class Extension<
|
||||||
|
Options = {},
|
||||||
|
Callback = ExtensionCallback<Options>,
|
||||||
|
Extends extends ExtensionExtends<Callback, Options> = ExtensionExtends<Callback, Options>
|
||||||
|
> {
|
||||||
type = 'extension'
|
type = 'extension'
|
||||||
config: any = {}
|
config: any = {}
|
||||||
configs: {
|
configs: {
|
||||||
|
|||||||
@@ -2,22 +2,26 @@ import { MarkSpec, MarkType } from 'prosemirror-model'
|
|||||||
import Extension, { ExtensionCallback, ExtensionExtends } from './Extension'
|
import Extension, { ExtensionCallback, ExtensionExtends } from './Extension'
|
||||||
import { Editor } from './Editor'
|
import { Editor } from './Editor'
|
||||||
|
|
||||||
interface Callback {
|
interface MarkCallback<Options> {
|
||||||
name: string
|
name: string
|
||||||
editor: Editor
|
editor: Editor
|
||||||
options: any
|
options: Options
|
||||||
type: MarkType
|
type: MarkType
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MarkExtends extends ExtensionExtends<Callback> {
|
export interface MarkExtends<Callback, Options> extends ExtensionExtends<Callback, Options> {
|
||||||
topMark: boolean
|
topMark: boolean
|
||||||
schema: (params: Callback) => MarkSpec
|
schema: (params: Callback) => MarkSpec
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Mark<Options = {}> extends Extension<Options, Callback, MarkExtends> {
|
export default class Mark<
|
||||||
|
Options = {},
|
||||||
|
Callback = MarkCallback<Options>,
|
||||||
|
Extends extends MarkExtends<Callback, Options> = MarkExtends<Callback, Options>
|
||||||
|
> extends Extension<Options, Callback, Extends> {
|
||||||
type = 'mark'
|
type = 'mark'
|
||||||
|
|
||||||
public schema(value: MarkExtends['schema']) {
|
public schema(value: Extends['schema']) {
|
||||||
this.storeConfig('schema', value, 'overwrite')
|
this.storeConfig('schema', value, 'overwrite')
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,27 +2,31 @@ import { NodeSpec, NodeType } from 'prosemirror-model'
|
|||||||
import Extension, { ExtensionCallback, ExtensionExtends } from './Extension'
|
import Extension, { ExtensionCallback, ExtensionExtends } from './Extension'
|
||||||
import { Editor } from './Editor'
|
import { Editor } from './Editor'
|
||||||
|
|
||||||
interface Callback {
|
interface NodeCallback<Options> {
|
||||||
name: string
|
name: string
|
||||||
editor: Editor
|
editor: Editor
|
||||||
options: any
|
options: Options
|
||||||
type: NodeType
|
type: NodeType
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NodeExtends extends ExtensionExtends<Callback> {
|
export interface NodeExtends<Callback, Options> extends ExtensionExtends<Callback, Options> {
|
||||||
topNode: boolean
|
topNode: boolean
|
||||||
schema: (params: Callback) => NodeSpec
|
schema: (params: Callback) => NodeSpec
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Node<Options = {}> extends Extension<Options, Callback, NodeExtends> {
|
export default class Node<
|
||||||
|
Options = {},
|
||||||
|
Callback = NodeCallback<Options>,
|
||||||
|
Extends extends NodeExtends<Callback, Options> = NodeExtends<Callback, Options>
|
||||||
|
> extends Extension<Options, Callback, Extends> {
|
||||||
type = 'node'
|
type = 'node'
|
||||||
|
|
||||||
public topNode(value: NodeExtends['topNode'] = true) {
|
public topNode(value: Extends['topNode'] = true) {
|
||||||
this.storeConfig('topNode', value, 'overwrite')
|
this.storeConfig('topNode', value, 'overwrite')
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
public schema(value: NodeExtends['schema']) {
|
public schema(value: Extends['schema']) {
|
||||||
this.storeConfig('schema', value, 'overwrite')
|
this.storeConfig('schema', value, 'overwrite')
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user