mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-18 14:13:21 +08:00
fix options type
This commit is contained in:
parent
f9bd8158cf
commit
0973845608
@ -60,15 +60,15 @@ type AnyObject = {
|
||||
|
||||
type NoInfer<T> = [T][T extends any ? 0 : never]
|
||||
|
||||
export interface ExtensionCallback {
|
||||
export interface ExtensionCallback<Options> {
|
||||
name: string
|
||||
editor: Editor
|
||||
options: any
|
||||
options: Options
|
||||
}
|
||||
|
||||
export interface ExtensionExtends<Callback> {
|
||||
export interface ExtensionExtends<Callback, Options> {
|
||||
name: string
|
||||
options: AnyObject
|
||||
options: Options
|
||||
commands: (params: Callback) => CommandSpec
|
||||
inputRules: (params: Callback) => any[]
|
||||
pasteRules: (params: Callback) => any[]
|
||||
@ -78,7 +78,11 @@ export interface ExtensionExtends<Callback> {
|
||||
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'
|
||||
config: any = {}
|
||||
configs: {
|
||||
|
@ -2,22 +2,26 @@ import { MarkSpec, MarkType } from 'prosemirror-model'
|
||||
import Extension, { ExtensionCallback, ExtensionExtends } from './Extension'
|
||||
import { Editor } from './Editor'
|
||||
|
||||
interface Callback {
|
||||
interface MarkCallback<Options> {
|
||||
name: string
|
||||
editor: Editor
|
||||
options: any
|
||||
options: Options
|
||||
type: MarkType
|
||||
}
|
||||
|
||||
export interface MarkExtends extends ExtensionExtends<Callback> {
|
||||
export interface MarkExtends<Callback, Options> extends ExtensionExtends<Callback, Options> {
|
||||
topMark: boolean
|
||||
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'
|
||||
|
||||
public schema(value: MarkExtends['schema']) {
|
||||
public schema(value: Extends['schema']) {
|
||||
this.storeConfig('schema', value, 'overwrite')
|
||||
return this
|
||||
}
|
||||
|
@ -2,27 +2,31 @@ import { NodeSpec, NodeType } from 'prosemirror-model'
|
||||
import Extension, { ExtensionCallback, ExtensionExtends } from './Extension'
|
||||
import { Editor } from './Editor'
|
||||
|
||||
interface Callback {
|
||||
interface NodeCallback<Options> {
|
||||
name: string
|
||||
editor: Editor
|
||||
options: any
|
||||
options: Options
|
||||
type: NodeType
|
||||
}
|
||||
|
||||
export interface NodeExtends extends ExtensionExtends<Callback> {
|
||||
export interface NodeExtends<Callback, Options> extends ExtensionExtends<Callback, Options> {
|
||||
topNode: boolean
|
||||
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'
|
||||
|
||||
public topNode(value: NodeExtends['topNode'] = true) {
|
||||
public topNode(value: Extends['topNode'] = true) {
|
||||
this.storeConfig('topNode', value, 'overwrite')
|
||||
return this
|
||||
}
|
||||
|
||||
public schema(value: NodeExtends['schema']) {
|
||||
public schema(value: Extends['schema']) {
|
||||
this.storeConfig('schema', value, 'overwrite')
|
||||
return this
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user