fix options type

This commit is contained in:
Philipp Kühn
2020-09-09 17:10:29 +02:00
parent f9bd8158cf
commit 0973845608
3 changed files with 28 additions and 16 deletions

View File

@@ -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
}