add type to this context in extensions

This commit is contained in:
Philipp Kühn
2020-10-22 23:21:52 +02:00
parent 6746163dda
commit d8d33c7429
8 changed files with 258 additions and 64 deletions

View File

@@ -1,3 +1,4 @@
import { MarkType, NodeType } from 'prosemirror-model'
import { Plugin } from 'prosemirror-state'
import { Editor } from './Editor'
import { GlobalAttributes } from './types'
@@ -16,11 +17,9 @@ export interface ExtensionSpec<Options = {}, Commands = {}> {
/**
* Global attributes
*/
addGlobalAttributes?: (
this: {
options: Options,
},
) => GlobalAttributes,
addGlobalAttributes?: (this: {
options: Options,
}) => GlobalAttributes,
/**
* Commands
@@ -28,6 +27,7 @@ export interface ExtensionSpec<Options = {}, Commands = {}> {
addCommands?: (this: {
options: Options,
editor: Editor,
type: NodeType | MarkType,
}) => Commands,
/**
@@ -36,6 +36,7 @@ export interface ExtensionSpec<Options = {}, Commands = {}> {
addKeyboardShortcuts?: (this: {
options: Options,
editor: Editor,
type: NodeType | MarkType,
}) => {
[key: string]: any
},
@@ -46,6 +47,7 @@ export interface ExtensionSpec<Options = {}, Commands = {}> {
addInputRules?: (this: {
options: Options,
editor: Editor,
// type: NodeType | MarkType,
}) => any[],
/**
@@ -54,6 +56,7 @@ export interface ExtensionSpec<Options = {}, Commands = {}> {
addPasteRules?: (this: {
options: Options,
editor: Editor,
type: NodeType | MarkType,
}) => any[],
/**
@@ -62,6 +65,7 @@ export interface ExtensionSpec<Options = {}, Commands = {}> {
addProseMirrorPlugins?: (this: {
options: Options,
editor: Editor,
type: NodeType | MarkType,
}) => Plugin[],
}