add generic to commands type

This commit is contained in:
Philipp Kühn
2021-06-04 21:56:29 +02:00
parent af91b811bf
commit 78e2a6e775
75 changed files with 258 additions and 272 deletions

View File

@@ -4,7 +4,7 @@ import {
SingleCommands, SingleCommands,
ChainedCommands, ChainedCommands,
CanCommands, CanCommands,
RawCommands, AnyCommands,
CommandProps, CommandProps,
} from './types' } from './types'
@@ -12,9 +12,9 @@ export default class CommandManager {
editor: Editor editor: Editor
commands: RawCommands commands: AnyCommands
constructor(editor: Editor, commands: RawCommands) { constructor(editor: Editor, commands: AnyCommands) {
this.editor = editor this.editor = editor
this.commands = commands this.commands = commands
} }
@@ -28,7 +28,7 @@ export default class CommandManager {
return Object.fromEntries(Object return Object.fromEntries(Object
.entries(commands) .entries(commands)
.map(([name, command]) => { .map(([name, command]) => {
const method = (...args: never[]) => { const method = (...args: any[]) => {
const callback = command(...args)(props) const callback = command(...args)(props)
if (!tr.getMeta('preventDispatch')) { if (!tr.getMeta('preventDispatch')) {
@@ -39,7 +39,7 @@ export default class CommandManager {
} }
return [name, method] return [name, method]
})) as SingleCommands })) as unknown as SingleCommands
} }
public createChain(startTr?: Transaction, shouldDispatch = true): ChainedCommands { public createChain(startTr?: Transaction, shouldDispatch = true): ChainedCommands {
@@ -86,7 +86,7 @@ export default class CommandManager {
.entries(commands) .entries(commands)
.map(([name, command]) => { .map(([name, command]) => {
return [name, (...args: never[]) => command(...args)({ ...props, dispatch })] return [name, (...args: never[]) => command(...args)({ ...props, dispatch })]
})) as SingleCommands })) as unknown as SingleCommands
return { return {
...formattedCommands, ...formattedCommands,
@@ -117,7 +117,7 @@ export default class CommandManager {
.entries(commands) .entries(commands)
.map(([name, command]) => { .map(([name, command]) => {
return [name, (...args: never[]) => command(...args)(props)] return [name, (...args: never[]) => command(...args)(props)]
})) as SingleCommands })) as unknown as SingleCommands
}, },
} }

View File

@@ -1,12 +1,12 @@
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
blur: { blur: {
/** /**
* Removes focus from the editor. * Removes focus from the editor.
*/ */
blur: () => Command, blur: () => ReturnType,
} }
} }
} }

View File

@@ -1,12 +1,12 @@
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
clearContent: { clearContent: {
/** /**
* Clear the whole document. * Clear the whole document.
*/ */
clearContent: (emitUpdate?: boolean) => Command, clearContent: (emitUpdate?: boolean) => ReturnType,
} }
} }
} }

View File

@@ -1,13 +1,13 @@
import { liftTarget } from 'prosemirror-transform' import { liftTarget } from 'prosemirror-transform'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
clearNodes: { clearNodes: {
/** /**
* Normalize nodes to a simple paragraph. * Normalize nodes to a simple paragraph.
*/ */
clearNodes: () => Command, clearNodes: () => ReturnType,
} }
} }
} }

View File

@@ -1,12 +1,12 @@
import { Command, RawCommands } from '../types' import { Command, RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
command: { command: {
/** /**
* Define a command inline. * Define a command inline.
*/ */
command: (fn: (props: Parameters<Command>[0]) => boolean) => Command, command: (fn: (props: Parameters<Command>[0]) => boolean) => ReturnType,
} }
} }
} }

View File

@@ -1,13 +1,13 @@
import { createParagraphNear as originalCreateParagraphNear } from 'prosemirror-commands' import { createParagraphNear as originalCreateParagraphNear } from 'prosemirror-commands'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
createParagraphNear: { createParagraphNear: {
/** /**
* Create a paragraph nearby. * Create a paragraph nearby.
*/ */
createParagraphNear: () => Command, createParagraphNear: () => ReturnType,
} }
} }
} }

View File

@@ -1,12 +1,12 @@
import { Command, RawCommands, Range } from '../types' import { RawCommands, Range } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
deleteRange: { deleteRange: {
/** /**
* Delete a given range. * Delete a given range.
*/ */
deleteRange: (range: Range) => Command, deleteRange: (range: Range) => ReturnType,
} }
} }
} }

View File

@@ -1,13 +1,13 @@
import { deleteSelection as originalDeleteSelection } from 'prosemirror-commands' import { deleteSelection as originalDeleteSelection } from 'prosemirror-commands'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
deleteSelection: { deleteSelection: {
/** /**
* Delete the selection, if there is one. * Delete the selection, if there is one.
*/ */
deleteSelection: () => Command, deleteSelection: () => ReturnType,
} }
} }
} }

View File

@@ -1,12 +1,12 @@
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
enter: { enter: {
/** /**
* Trigger enter. * Trigger enter.
*/ */
enter: () => Command, enter: () => ReturnType,
} }
} }
} }

View File

@@ -1,13 +1,13 @@
import { exitCode as originalExitCode } from 'prosemirror-commands' import { exitCode as originalExitCode } from 'prosemirror-commands'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
exitCode: { exitCode: {
/** /**
* Exit from a code block. * Exit from a code block.
*/ */
exitCode: () => Command, exitCode: () => ReturnType,
} }
} }
} }

View File

@@ -1,16 +1,16 @@
import { TextSelection } from 'prosemirror-state' import { TextSelection } from 'prosemirror-state'
import { MarkType } from 'prosemirror-model' import { MarkType } from 'prosemirror-model'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
import getMarkType from '../helpers/getMarkType' import getMarkType from '../helpers/getMarkType'
import getMarkRange from '../helpers/getMarkRange' import getMarkRange from '../helpers/getMarkRange'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
extendMarkRange: { extendMarkRange: {
/** /**
* Extends the text selection to the current mark. * Extends the text selection to the current mark.
*/ */
extendMarkRange: (typeOrName: string | MarkType, attributes?: Record<string, any>) => Command, extendMarkRange: (typeOrName: string | MarkType, attributes?: Record<string, any>) => ReturnType,
} }
} }
} }

View File

@@ -1,12 +1,12 @@
import { Command, RawCommands } from '../types' import { Command, RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
first: { first: {
/** /**
* Runs one command after the other and stops at the first which returns true. * Runs one command after the other and stops at the first which returns true.
*/ */
first: (commands: Command[] | ((props: Parameters<Command>[0]) => Command[])) => Command, first: (commands: Command[] | ((props: Parameters<Command>[0]) => Command[])) => ReturnType,
} }
} }
} }

View File

@@ -1,5 +1,5 @@
import { EditorState, TextSelection } from 'prosemirror-state' import { EditorState, TextSelection } from 'prosemirror-state'
import { Command, RawCommands, FocusPosition } from '../types' import { RawCommands, FocusPosition } from '../types'
import minMax from '../utilities/minMax' import minMax from '../utilities/minMax'
import isTextSelection from '../helpers/isTextSelection' import isTextSelection from '../helpers/isTextSelection'
@@ -31,12 +31,12 @@ function resolveSelection(state: EditorState, position: FocusPosition = null) {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
focus: { focus: {
/** /**
* Focus the editor at the given position. * Focus the editor at the given position.
*/ */
focus: (position?: FocusPosition) => Command, focus: (position?: FocusPosition) => ReturnType,
} }
} }
} }

View File

@@ -1,12 +1,12 @@
import { Command, RawCommands, Content } from '../types' import { RawCommands, Content } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
insertContent: { insertContent: {
/** /**
* Insert a node or string of HTML at the current position. * Insert a node or string of HTML at the current position.
*/ */
insertContent: (value: Content) => Command, insertContent: (value: Content) => ReturnType,
} }
} }
} }

View File

@@ -1,19 +1,18 @@
import createNodeFromContent from '../helpers/createNodeFromContent' import createNodeFromContent from '../helpers/createNodeFromContent'
import selectionToInsertionEnd from '../helpers/selectionToInsertionEnd' import selectionToInsertionEnd from '../helpers/selectionToInsertionEnd'
import { import {
Command,
RawCommands, RawCommands,
Content, Content,
Range, Range,
} from '../types' } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
insertContentAt: { insertContentAt: {
/** /**
* Insert a node or string of HTML at a specific position. * Insert a node or string of HTML at a specific position.
*/ */
insertContentAt: (position: number | Range, value: Content) => Command, insertContentAt: (position: number | Range, value: Content) => ReturnType,
} }
} }
} }

View File

@@ -1,13 +1,13 @@
import { joinBackward as originalJoinBackward } from 'prosemirror-commands' import { joinBackward as originalJoinBackward } from 'prosemirror-commands'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
joinBackward: { joinBackward: {
/** /**
* Join two nodes backward. * Join two nodes backward.
*/ */
joinBackward: () => Command, joinBackward: () => ReturnType,
} }
} }
} }

View File

@@ -1,13 +1,13 @@
import { joinForward as originalJoinForward } from 'prosemirror-commands' import { joinForward as originalJoinForward } from 'prosemirror-commands'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
joinForward: { joinForward: {
/** /**
* Join two nodes forward. * Join two nodes forward.
*/ */
joinForward: () => Command, joinForward: () => ReturnType,
} }
} }
} }

View File

@@ -1,4 +1,4 @@
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
const mac = typeof navigator !== 'undefined' ? /Mac/.test(navigator.platform) : false const mac = typeof navigator !== 'undefined' ? /Mac/.test(navigator.platform) : false
@@ -57,12 +57,12 @@ function normalizeKeyName(name: string) {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
keyboardShortcut: { keyboardShortcut: {
/** /**
* Trigger a keyboard shortcut. * Trigger a keyboard shortcut.
*/ */
keyboardShortcut: (name: string) => Command, keyboardShortcut: (name: string) => ReturnType,
} }
} }
} }

View File

@@ -1,16 +1,16 @@
import { lift as originalLift } from 'prosemirror-commands' import { lift as originalLift } from 'prosemirror-commands'
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
import isNodeActive from '../helpers/isNodeActive' import isNodeActive from '../helpers/isNodeActive'
import getNodeType from '../helpers/getNodeType' import getNodeType from '../helpers/getNodeType'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
lift: { lift: {
/** /**
* Removes an existing wrap. * Removes an existing wrap.
*/ */
lift: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command, lift: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType,
} }
} }
} }

View File

@@ -1,13 +1,13 @@
import { liftEmptyBlock as originalLiftEmptyBlock } from 'prosemirror-commands' import { liftEmptyBlock as originalLiftEmptyBlock } from 'prosemirror-commands'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
liftEmptyBlock: { liftEmptyBlock: {
/** /**
* Lift block if empty. * Lift block if empty.
*/ */
liftEmptyBlock: () => Command, liftEmptyBlock: () => ReturnType,
} }
} }
} }

View File

@@ -1,15 +1,15 @@
import { liftListItem as originalLiftListItem } from 'prosemirror-schema-list' import { liftListItem as originalLiftListItem } from 'prosemirror-schema-list'
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
import getNodeType from '../helpers/getNodeType' import getNodeType from '../helpers/getNodeType'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
liftListItem: { liftListItem: {
/** /**
* Lift the list item into a wrapping list. * Lift the list item into a wrapping list.
*/ */
liftListItem: (typeOrName: string | NodeType) => Command, liftListItem: (typeOrName: string | NodeType) => ReturnType,
} }
} }
} }

View File

@@ -1,13 +1,13 @@
import { newlineInCode as originalNewlineInCode } from 'prosemirror-commands' import { newlineInCode as originalNewlineInCode } from 'prosemirror-commands'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
newlineInCode: { newlineInCode: {
/** /**
* Add a newline character in code. * Add a newline character in code.
*/ */
newlineInCode: () => Command, newlineInCode: () => ReturnType,
} }
} }
} }

View File

@@ -1,13 +1,13 @@
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
replace: { replace: {
/** /**
* Replaces text with a node. * Replaces text with a node.
*/ */
replace: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command, replace: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType,
} }
} }
} }

View File

@@ -1,14 +1,14 @@
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import getNodeType from '../helpers/getNodeType' import getNodeType from '../helpers/getNodeType'
import { Command, RawCommands, Range } from '../types' import { RawCommands, Range } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
replaceRange: { replaceRange: {
/** /**
* Replaces text with a node within a range. * Replaces text with a node within a range.
*/ */
replaceRange: (range: Range, typeOrName: string | NodeType, attributes?: Record<string, any>) => Command, replaceRange: (range: Range, typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType,
} }
} }
} }

View File

@@ -3,15 +3,15 @@ import getNodeType from '../helpers/getNodeType'
import getMarkType from '../helpers/getMarkType' import getMarkType from '../helpers/getMarkType'
import getSchemaTypeNameByName from '../helpers/getSchemaTypeNameByName' import getSchemaTypeNameByName from '../helpers/getSchemaTypeNameByName'
import deleteProps from '../utilities/deleteProps' import deleteProps from '../utilities/deleteProps'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
resetAttributes: { resetAttributes: {
/** /**
* Resets some node attributes to the default value. * Resets some node attributes to the default value.
*/ */
resetAttributes: (typeOrName: string | NodeType | MarkType, attributes: string | string[]) => Command, resetAttributes: (typeOrName: string | NodeType | MarkType, attributes: string | string[]) => ReturnType,
} }
} }
} }

View File

@@ -1,12 +1,12 @@
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
scrollIntoView: { scrollIntoView: {
/** /**
* Scroll the selection into view. * Scroll the selection into view.
*/ */
scrollIntoView: () => Command, scrollIntoView: () => ReturnType,
} }
} }
} }

View File

@@ -1,13 +1,13 @@
import { selectAll as originalSelectAll } from 'prosemirror-commands' import { selectAll as originalSelectAll } from 'prosemirror-commands'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
selectAll: { selectAll: {
/** /**
* Select the whole document. * Select the whole document.
*/ */
selectAll: () => Command, selectAll: () => ReturnType,
} }
} }
} }

View File

@@ -1,13 +1,13 @@
import { selectNodeBackward as originalSelectNodeBackward } from 'prosemirror-commands' import { selectNodeBackward as originalSelectNodeBackward } from 'prosemirror-commands'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
selectNodeBackward: { selectNodeBackward: {
/** /**
* Select a node backward. * Select a node backward.
*/ */
selectNodeBackward: () => Command, selectNodeBackward: () => ReturnType,
} }
} }
} }

View File

@@ -1,13 +1,13 @@
import { selectNodeForward as originalSelectNodeForward } from 'prosemirror-commands' import { selectNodeForward as originalSelectNodeForward } from 'prosemirror-commands'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
selectNodeForward: { selectNodeForward: {
/** /**
* Select a node forward. * Select a node forward.
*/ */
selectNodeForward: () => Command, selectNodeForward: () => ReturnType,
} }
} }
} }

View File

@@ -1,13 +1,13 @@
import { selectParentNode as originalSelectParentNode } from 'prosemirror-commands' import { selectParentNode as originalSelectParentNode } from 'prosemirror-commands'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
selectParentNode: { selectParentNode: {
/** /**
* Select the parent node. * Select the parent node.
*/ */
selectParentNode: () => Command, selectParentNode: () => ReturnType,
} }
} }
} }

View File

@@ -1,10 +1,10 @@
import { TextSelection } from 'prosemirror-state' import { TextSelection } from 'prosemirror-state'
import { ParseOptions } from 'prosemirror-model' import { ParseOptions } from 'prosemirror-model'
import createDocument from '../helpers/createDocument' import createDocument from '../helpers/createDocument'
import { Command, RawCommands, Content } from '../types' import { RawCommands, Content } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
setContent: { setContent: {
/** /**
* Replace the whole document with new content. * Replace the whole document with new content.
@@ -13,7 +13,7 @@ declare module '@tiptap/core' {
content: Content, content: Content,
emitUpdate?: boolean, emitUpdate?: boolean,
parseOptions?: ParseOptions, parseOptions?: ParseOptions,
) => Command, ) => ReturnType,
} }
} }
} }

View File

@@ -1,15 +1,15 @@
import { MarkType } from 'prosemirror-model' import { MarkType } from 'prosemirror-model'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
import getMarkType from '../helpers/getMarkType' import getMarkType from '../helpers/getMarkType'
import getMarkAttributes from '../helpers/getMarkAttributes' import getMarkAttributes from '../helpers/getMarkAttributes'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
setMark: { setMark: {
/** /**
* Add a mark with new attributes. * Add a mark with new attributes.
*/ */
setMark: (typeOrName: string | MarkType, attributes?: Record<string, any>) => Command, setMark: (typeOrName: string | MarkType, attributes?: Record<string, any>) => ReturnType,
} }
} }
} }

View File

@@ -1,12 +1,12 @@
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
setMeta: { setMeta: {
/** /**
* Store a metadata property in the current transaction. * Store a metadata property in the current transaction.
*/ */
setMeta: (key: string, value: any) => Command, setMeta: (key: string, value: any) => ReturnType,
} }
} }
} }

View File

@@ -1,15 +1,15 @@
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { setBlockType } from 'prosemirror-commands' import { setBlockType } from 'prosemirror-commands'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
import getNodeType from '../helpers/getNodeType' import getNodeType from '../helpers/getNodeType'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
setNode: { setNode: {
/** /**
* Replace a given range with a node. * Replace a given range with a node.
*/ */
setNode: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command, setNode: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType,
} }
} }
} }

View File

@@ -1,14 +1,14 @@
import { NodeSelection } from 'prosemirror-state' import { NodeSelection } from 'prosemirror-state'
import minMax from '../utilities/minMax' import minMax from '../utilities/minMax'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
setNodeSelection: { setNodeSelection: {
/** /**
* Creates a NodeSelection. * Creates a NodeSelection.
*/ */
setNodeSelection: (position: number) => Command, setNodeSelection: (position: number) => ReturnType,
} }
} }
} }

View File

@@ -1,14 +1,14 @@
import { TextSelection } from 'prosemirror-state' import { TextSelection } from 'prosemirror-state'
import minMax from '../utilities/minMax' import minMax from '../utilities/minMax'
import { Command, RawCommands, Range } from '../types' import { RawCommands, Range } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
setTextSelection: { setTextSelection: {
/** /**
* Creates a TextSelection. * Creates a TextSelection.
*/ */
setTextSelection: (position: number | Range) => Command, setTextSelection: (position: number | Range) => ReturnType,
} }
} }
} }

View File

@@ -1,15 +1,15 @@
import { sinkListItem as originalSinkListItem } from 'prosemirror-schema-list' import { sinkListItem as originalSinkListItem } from 'prosemirror-schema-list'
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
import getNodeType from '../helpers/getNodeType' import getNodeType from '../helpers/getNodeType'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
sinkListItem: { sinkListItem: {
/** /**
* Sink the list item down into an inner list. * Sink the list item down into an inner list.
*/ */
sinkListItem: (typeOrName: string | NodeType) => Command, sinkListItem: (typeOrName: string | NodeType) => ReturnType,
} }
} }
} }

View File

@@ -1,7 +1,7 @@
import { canSplit } from 'prosemirror-transform' import { canSplit } from 'prosemirror-transform'
import { ContentMatch } from 'prosemirror-model' import { ContentMatch } from 'prosemirror-model'
import { EditorState, NodeSelection, TextSelection } from 'prosemirror-state' import { EditorState, NodeSelection, TextSelection } from 'prosemirror-state'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
import getSplittedAttributes from '../helpers/getSplittedAttributes' import getSplittedAttributes from '../helpers/getSplittedAttributes'
function defaultBlockAt(match: ContentMatch) { function defaultBlockAt(match: ContentMatch) {
@@ -27,12 +27,12 @@ function ensureMarks(state: EditorState, splittableMarks?: string[]) {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
splitBlock: { splitBlock: {
/** /**
* Forks a new node from an existing node. * Forks a new node from an existing node.
*/ */
splitBlock: (options?: { keepMarks?: boolean }) => Command, splitBlock: (options?: { keepMarks?: boolean }) => ReturnType,
} }
} }
} }

View File

@@ -6,17 +6,17 @@ import {
} from 'prosemirror-model' } from 'prosemirror-model'
import { canSplit } from 'prosemirror-transform' import { canSplit } from 'prosemirror-transform'
import { TextSelection } from 'prosemirror-state' import { TextSelection } from 'prosemirror-state'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
import getNodeType from '../helpers/getNodeType' import getNodeType from '../helpers/getNodeType'
import getSplittedAttributes from '../helpers/getSplittedAttributes' import getSplittedAttributes from '../helpers/getSplittedAttributes'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
splitListItem: { splitListItem: {
/** /**
* Splits one list item into two list items. * Splits one list item into two list items.
*/ */
splitListItem: (typeOrName: string | NodeType) => Command, splitListItem: (typeOrName: string | NodeType) => ReturnType,
} }
} }
} }

View File

@@ -1,16 +1,16 @@
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
import getNodeType from '../helpers/getNodeType' import getNodeType from '../helpers/getNodeType'
import findParentNode from '../helpers/findParentNode' import findParentNode from '../helpers/findParentNode'
import isList from '../helpers/isList' import isList from '../helpers/isList'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
toggleList: { toggleList: {
/** /**
* Toggle between different list types. * Toggle between different list types.
*/ */
toggleList: (listTypeOrName: string | NodeType, itemTypeOrName: string | NodeType) => Command, toggleList: (listTypeOrName: string | NodeType, itemTypeOrName: string | NodeType) => ReturnType,
} }
} }
} }

View File

@@ -1,15 +1,15 @@
import { MarkType } from 'prosemirror-model' import { MarkType } from 'prosemirror-model'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
import getMarkType from '../helpers/getMarkType' import getMarkType from '../helpers/getMarkType'
import isMarkActive from '../helpers/isMarkActive' import isMarkActive from '../helpers/isMarkActive'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
toggleMark: { toggleMark: {
/** /**
* Toggle a mark on and off. * Toggle a mark on and off.
*/ */
toggleMark: (typeOrName: string | MarkType, attributes?: Record<string, any>) => Command, toggleMark: (typeOrName: string | MarkType, attributes?: Record<string, any>) => ReturnType,
} }
} }
} }

View File

@@ -1,15 +1,15 @@
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
import isNodeActive from '../helpers/isNodeActive' import isNodeActive from '../helpers/isNodeActive'
import getNodeType from '../helpers/getNodeType' import getNodeType from '../helpers/getNodeType'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
toggleNode: { toggleNode: {
/** /**
* Toggle a node with another node. * Toggle a node with another node.
*/ */
toggleNode: (typeOrName: string | NodeType, toggleTypeOrName: string | NodeType, attributes?: Record<string, any>) => Command, toggleNode: (typeOrName: string | NodeType, toggleTypeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType,
} }
} }
} }

View File

@@ -1,16 +1,16 @@
import { wrapIn, lift } from 'prosemirror-commands' import { wrapIn, lift } from 'prosemirror-commands'
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
import isNodeActive from '../helpers/isNodeActive' import isNodeActive from '../helpers/isNodeActive'
import getNodeType from '../helpers/getNodeType' import getNodeType from '../helpers/getNodeType'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
toggleWrap: { toggleWrap: {
/** /**
* Wraps nodes in another node, or removes an existing wrap. * Wraps nodes in another node, or removes an existing wrap.
*/ */
toggleWrap: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command, toggleWrap: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType,
} }
} }
} }

View File

@@ -1,13 +1,13 @@
import { undoInputRule as originalUndoInputRule } from 'prosemirror-inputrules' import { undoInputRule as originalUndoInputRule } from 'prosemirror-inputrules'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
undoInputRule: { undoInputRule: {
/** /**
* Undo an input rule. * Undo an input rule.
*/ */
undoInputRule: () => Command, undoInputRule: () => ReturnType,
} }
} }
} }

View File

@@ -1,12 +1,12 @@
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
unsetAllMarks: { unsetAllMarks: {
/** /**
* Remove all marks in the current selection. * Remove all marks in the current selection.
*/ */
unsetAllMarks: () => Command, unsetAllMarks: () => ReturnType,
} }
} }
} }

View File

@@ -1,15 +1,15 @@
import { MarkType } from 'prosemirror-model' import { MarkType } from 'prosemirror-model'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
import getMarkType from '../helpers/getMarkType' import getMarkType from '../helpers/getMarkType'
import getMarkRange from '../helpers/getMarkRange' import getMarkRange from '../helpers/getMarkRange'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
unsetMark: { unsetMark: {
/** /**
* Remove all marks in the current selection. * Remove all marks in the current selection.
*/ */
unsetMark: (typeOrName: string | MarkType) => Command, unsetMark: (typeOrName: string | MarkType) => ReturnType,
} }
} }
} }

View File

@@ -2,15 +2,15 @@ import { NodeType, MarkType } from 'prosemirror-model'
import getNodeType from '../helpers/getNodeType' import getNodeType from '../helpers/getNodeType'
import getMarkType from '../helpers/getMarkType' import getMarkType from '../helpers/getMarkType'
import getSchemaTypeNameByName from '../helpers/getSchemaTypeNameByName' import getSchemaTypeNameByName from '../helpers/getSchemaTypeNameByName'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
updateAttributes: { updateAttributes: {
/** /**
* Update attributes of a node or mark. * Update attributes of a node or mark.
*/ */
updateAttributes: (typeOrName: string | NodeType | MarkType, attributes: Record<string, any>) => Command, updateAttributes: (typeOrName: string | NodeType | MarkType, attributes: Record<string, any>) => ReturnType,
} }
} }
} }

View File

@@ -1,16 +1,16 @@
import { wrapIn as originalWrapIn } from 'prosemirror-commands' import { wrapIn as originalWrapIn } from 'prosemirror-commands'
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
import isNodeActive from '../helpers/isNodeActive' import isNodeActive from '../helpers/isNodeActive'
import getNodeType from '../helpers/getNodeType' import getNodeType from '../helpers/getNodeType'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
wrapIn: { wrapIn: {
/** /**
* Wraps nodes in another node. * Wraps nodes in another node.
*/ */
wrapIn: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command, wrapIn: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType,
} }
} }
} }

View File

@@ -1,15 +1,15 @@
import { wrapInList as originalWrapInList } from 'prosemirror-schema-list' import { wrapInList as originalWrapInList } from 'prosemirror-schema-list'
import { NodeType } from 'prosemirror-model' import { NodeType } from 'prosemirror-model'
import { Command, RawCommands } from '../types' import { RawCommands } from '../types'
import getNodeType from '../helpers/getNodeType' import getNodeType from '../helpers/getNodeType'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
wrapInList: { wrapInList: {
/** /**
* Wrap a node in a list. * Wrap a node in a list.
*/ */
wrapInList: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command, wrapInList: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType,
} }
} }
} }

View File

@@ -38,7 +38,8 @@ export { default as isNodeSelection } from './helpers/isNodeSelection'
export { default as isTextSelection } from './helpers/isTextSelection' export { default as isTextSelection } from './helpers/isTextSelection'
export { default as posToDOMRect } from './helpers/posToDOMRect' export { default as posToDOMRect } from './helpers/posToDOMRect'
export interface Commands {} // eslint-disable-next-line
export interface Commands<ReturnType = any> {}
// eslint-disable-next-line // eslint-disable-next-line
export interface ExtensionConfig<Options = any> {} export interface ExtensionConfig<Options = any> {}

View File

@@ -156,24 +156,20 @@ export type NodeViewRendererProps = {
export type NodeViewRenderer = (props: NodeViewRendererProps) => (NodeView | {}) export type NodeViewRenderer = (props: NodeViewRendererProps) => (NodeView | {})
export type UnionCommands = UnionToIntersection<ValuesOf<Pick<Commands, KeysWithTypeOf<Commands, {}>>>> export type AnyCommands = Record<string, (...args: any[]) => Command>
export type UnionCommands<T = Command> = UnionToIntersection<ValuesOf<Pick<Commands<T>, KeysWithTypeOf<Commands<T>, {}>>>>
export type RawCommands = { export type RawCommands = {
[Item in keyof UnionCommands]: UnionCommands[Item] extends (...args: any[]) => any [Item in keyof UnionCommands]: UnionCommands<Command>[Item]
? (...args: Parameters<UnionCommands[Item]>) => Command
: never
} }
export type SingleCommands = { export type SingleCommands = {
[Item in keyof RawCommands]: RawCommands[Item] extends (...args: any[]) => any [Item in keyof UnionCommands]: UnionCommands<boolean>[Item]
? (...args: Parameters<RawCommands[Item]>) => boolean
: never
} }
export type ChainedCommands = { export type ChainedCommands = {
[Item in keyof RawCommands]: RawCommands[Item] extends (...args: any[]) => any [Item in keyof UnionCommands]: UnionCommands<ChainedCommands>[Item]
? (...args: Parameters<RawCommands[Item]>) => ChainedCommands
: never
} & { } & {
run: () => boolean run: () => boolean
} }

View File

@@ -1,4 +1,4 @@
import { Command, Node, mergeAttributes } from '@tiptap/core' import { Node, mergeAttributes } from '@tiptap/core'
import { wrappingInputRule } from 'prosemirror-inputrules' import { wrappingInputRule } from 'prosemirror-inputrules'
export interface BlockquoteOptions { export interface BlockquoteOptions {
@@ -6,20 +6,20 @@ export interface BlockquoteOptions {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
blockQuote: { blockQuote: {
/** /**
* Set a blockquote node * Set a blockquote node
*/ */
setBlockquote: () => Command, setBlockquote: () => ReturnType,
/** /**
* Toggle a blockquote node * Toggle a blockquote node
*/ */
toggleBlockquote: () => Command, toggleBlockquote: () => ReturnType,
/** /**
* Unset a blockquote node * Unset a blockquote node
*/ */
unsetBlockquote: () => Command, unsetBlockquote: () => ReturnType,
} }
} }
} }

View File

@@ -1,5 +1,4 @@
import { import {
Command,
Mark, Mark,
markInputRule, markInputRule,
markPasteRule, markPasteRule,
@@ -11,20 +10,20 @@ export interface BoldOptions {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
bold: { bold: {
/** /**
* Set a bold mark * Set a bold mark
*/ */
setBold: () => Command, setBold: () => ReturnType,
/** /**
* Toggle a bold mark * Toggle a bold mark
*/ */
toggleBold: () => Command, toggleBold: () => ReturnType,
/** /**
* Unset a bold mark * Unset a bold mark
*/ */
unsetBold: () => Command, unsetBold: () => ReturnType,
} }
} }
} }

View File

@@ -1,4 +1,4 @@
import { Command, Node, mergeAttributes } from '@tiptap/core' import { Node, mergeAttributes } from '@tiptap/core'
import { wrappingInputRule } from 'prosemirror-inputrules' import { wrappingInputRule } from 'prosemirror-inputrules'
export interface BulletListOptions { export interface BulletListOptions {
@@ -6,12 +6,12 @@ export interface BulletListOptions {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
bulletList: { bulletList: {
/** /**
* Toggle a bullet list * Toggle a bullet list
*/ */
toggleBulletList: () => Command, toggleBulletList: () => ReturnType,
} }
} }
} }

View File

@@ -1,4 +1,4 @@
import { Command, Node } from '@tiptap/core' import { Node } from '@tiptap/core'
import { textblockTypeInputRule } from 'prosemirror-inputrules' import { textblockTypeInputRule } from 'prosemirror-inputrules'
export interface CodeBlockOptions { export interface CodeBlockOptions {
@@ -7,16 +7,16 @@ export interface CodeBlockOptions {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
codeBlock: { codeBlock: {
/** /**
* Set a code block * Set a code block
*/ */
setCodeBlock: (attributes?: { language: string }) => Command, setCodeBlock: (attributes?: { language: string }) => ReturnType,
/** /**
* Toggle a code block * Toggle a code block
*/ */
toggleCodeBlock: (attributes?: { language: string }) => Command, toggleCodeBlock: (attributes?: { language: string }) => ReturnType,
} }
} }
} }

View File

@@ -1,5 +1,4 @@
import { import {
Command,
Mark, Mark,
markInputRule, markInputRule,
markPasteRule, markPasteRule,
@@ -11,20 +10,20 @@ export interface CodeOptions {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
code: { code: {
/** /**
* Set a code mark * Set a code mark
*/ */
setCode: () => Command, setCode: () => ReturnType,
/** /**
* Toggle inline code * Toggle inline code
*/ */
toggleCode: () => Command, toggleCode: () => ReturnType,
/** /**
* Unset a code mark * Unset a code mark
*/ */
unsetCode: () => Command, unsetCode: () => ReturnType,
} }
} }
} }

View File

@@ -1,4 +1,4 @@
import { Extension, Command } from '@tiptap/core' import { Extension } from '@tiptap/core'
import { yCursorPlugin } from 'y-prosemirror' import { yCursorPlugin } from 'y-prosemirror'
export interface CollaborationCursorOptions { export interface CollaborationCursorOptions {
@@ -9,12 +9,12 @@ export interface CollaborationCursorOptions {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
collaborationCursor: { collaborationCursor: {
/** /**
* Update details of the current user * Update details of the current user
*/ */
user: (attributes: Record<string, any>) => Command, user: (attributes: Record<string, any>) => ReturnType,
} }
} }
} }

View File

@@ -1,4 +1,4 @@
import { Extension, Command } from '@tiptap/core' import { Extension } from '@tiptap/core'
import { UndoManager } from 'yjs' import { UndoManager } from 'yjs'
import { import {
redo, redo,
@@ -9,16 +9,16 @@ import {
} from 'y-prosemirror' } from 'y-prosemirror'
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
collaboration: { collaboration: {
/** /**
* Undo recent changes * Undo recent changes
*/ */
undo: () => Command, undo: () => ReturnType,
/** /**
* Reapply reverted changes * Reapply reverted changes
*/ */
redo: () => Command, redo: () => ReturnType,
} }
} }
} }

View File

@@ -1,4 +1,4 @@
import { Command, Extension } from '@tiptap/core' import { Extension } from '@tiptap/core'
import '@tiptap/extension-text-style' import '@tiptap/extension-text-style'
type FontFamilyOptions = { type FontFamilyOptions = {
@@ -6,16 +6,16 @@ type FontFamilyOptions = {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
fontFamily: { fontFamily: {
/** /**
* Set the font family * Set the font family
*/ */
setFontFamily: (fontFamily: string) => Command, setFontFamily: (fontFamily: string) => ReturnType,
/** /**
* Unset the font family * Unset the font family
*/ */
unsetFontFamily: () => Command, unsetFontFamily: () => ReturnType,
} }
} }
} }

View File

@@ -1,16 +1,16 @@
import { Command, Node, mergeAttributes } from '@tiptap/core' import { Node, mergeAttributes } from '@tiptap/core'
export interface HardBreakOptions { export interface HardBreakOptions {
HTMLAttributes: Record<string, any>, HTMLAttributes: Record<string, any>,
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
hardBreak: { hardBreak: {
/** /**
* Add a hard break * Add a hard break
*/ */
setHardBreak: () => Command, setHardBreak: () => ReturnType,
} }
} }
} }

View File

@@ -1,4 +1,4 @@
import { Command, Node, mergeAttributes } from '@tiptap/core' import { Node, mergeAttributes } from '@tiptap/core'
import { textblockTypeInputRule } from 'prosemirror-inputrules' import { textblockTypeInputRule } from 'prosemirror-inputrules'
type Level = 1 | 2 | 3 | 4 | 5 | 6 type Level = 1 | 2 | 3 | 4 | 5 | 6
@@ -9,16 +9,16 @@ export interface HeadingOptions {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
heading: { heading: {
/** /**
* Set a heading node * Set a heading node
*/ */
setHeading: (attributes: { level: Level }) => Command, setHeading: (attributes: { level: Level }) => ReturnType,
/** /**
* Toggle a heading node * Toggle a heading node
*/ */
toggleHeading: (attributes: { level: Level }) => Command, toggleHeading: (attributes: { level: Level }) => ReturnType,
} }
} }
} }

View File

@@ -1,5 +1,4 @@
import { import {
Command,
Mark, Mark,
markInputRule, markInputRule,
markPasteRule, markPasteRule,
@@ -12,20 +11,20 @@ export interface HighlightOptions {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
highlight: { highlight: {
/** /**
* Set a highlight mark * Set a highlight mark
*/ */
setHighlight: (attributes?: { color: string }) => Command, setHighlight: (attributes?: { color: string }) => ReturnType,
/** /**
* Toggle a highlight mark * Toggle a highlight mark
*/ */
toggleHighlight: (attributes?: { color: string }) => Command, toggleHighlight: (attributes?: { color: string }) => ReturnType,
/** /**
* Unset a highlight mark * Unset a highlight mark
*/ */
unsetHighlight: () => Command, unsetHighlight: () => ReturnType,
} }
} }
} }

View File

@@ -1,4 +1,4 @@
import { Command, Extension } from '@tiptap/core' import { Extension } from '@tiptap/core'
import { history, undo, redo } from 'prosemirror-history' import { history, undo, redo } from 'prosemirror-history'
export interface HistoryOptions { export interface HistoryOptions {
@@ -7,16 +7,16 @@ export interface HistoryOptions {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
history: { history: {
/** /**
* Undo recent changes * Undo recent changes
*/ */
undo: () => Command, undo: () => ReturnType,
/** /**
* Reapply reverted changes * Reapply reverted changes
*/ */
redo: () => Command, redo: () => ReturnType,
} }
} }
} }

View File

@@ -1,5 +1,4 @@
import { import {
Command,
Node, Node,
nodeInputRule, nodeInputRule,
mergeAttributes, mergeAttributes,
@@ -11,12 +10,12 @@ export interface HorizontalRuleOptions {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
horizontalRule: { horizontalRule: {
/** /**
* Add a horizontal rule * Add a horizontal rule
*/ */
setHorizontalRule: () => Command, setHorizontalRule: () => ReturnType,
} }
} }
} }

View File

@@ -1,5 +1,4 @@
import { import {
Command,
Node, Node,
nodeInputRule, nodeInputRule,
mergeAttributes, mergeAttributes,
@@ -11,12 +10,12 @@ export interface ImageOptions {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
image: { image: {
/** /**
* Add an image * Add an image
*/ */
setImage: (options: { src: string, alt?: string, title?: string }) => Command, setImage: (options: { src: string, alt?: string, title?: string }) => ReturnType,
} }
} }
} }

View File

@@ -1,5 +1,4 @@
import { import {
Command,
Mark, Mark,
markInputRule, markInputRule,
markPasteRule, markPasteRule,
@@ -11,20 +10,20 @@ export interface ItalicOptions {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
italic: { italic: {
/** /**
* Set an italic mark * Set an italic mark
*/ */
setItalic: () => Command, setItalic: () => ReturnType,
/** /**
* Toggle an italic mark * Toggle an italic mark
*/ */
toggleItalic: () => Command, toggleItalic: () => ReturnType,
/** /**
* Unset an italic mark * Unset an italic mark
*/ */
unsetItalic: () => Command, unsetItalic: () => ReturnType,
} }
} }
} }

View File

@@ -1,5 +1,4 @@
import { import {
Command,
Mark, Mark,
markPasteRule, markPasteRule,
mergeAttributes, mergeAttributes,
@@ -22,20 +21,20 @@ export interface LinkOptions {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
link: { link: {
/** /**
* Set a link mark * Set a link mark
*/ */
setLink: (attributes: { href: string, target?: string }) => Command, setLink: (attributes: { href: string, target?: string }) => ReturnType,
/** /**
* Toggle a link mark * Toggle a link mark
*/ */
toggleLink: (attributes: { href: string, target?: string }) => Command, toggleLink: (attributes: { href: string, target?: string }) => ReturnType,
/** /**
* Unset a link mark * Unset a link mark
*/ */
unsetLink: () => Command, unsetLink: () => ReturnType,
} }
} }
} }

View File

@@ -1,4 +1,4 @@
import { Command, Node, mergeAttributes } from '@tiptap/core' import { Node, mergeAttributes } from '@tiptap/core'
import { wrappingInputRule } from 'prosemirror-inputrules' import { wrappingInputRule } from 'prosemirror-inputrules'
export interface OrderedListOptions { export interface OrderedListOptions {
@@ -6,12 +6,12 @@ export interface OrderedListOptions {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
orderedList: { orderedList: {
/** /**
* Toggle an ordered list * Toggle an ordered list
*/ */
toggleOrderedList: () => Command, toggleOrderedList: () => ReturnType,
} }
} }
} }

View File

@@ -1,16 +1,16 @@
import { Command, Node, mergeAttributes } from '@tiptap/core' import { Node, mergeAttributes } from '@tiptap/core'
export interface ParagraphOptions { export interface ParagraphOptions {
HTMLAttributes: Record<string, any>, HTMLAttributes: Record<string, any>,
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
paragraph: { paragraph: {
/** /**
* Toggle a paragraph * Toggle a paragraph
*/ */
setParagraph: () => Command, setParagraph: () => ReturnType,
} }
} }
} }

View File

@@ -1,5 +1,4 @@
import { import {
Command,
Mark, Mark,
markInputRule, markInputRule,
markPasteRule, markPasteRule,
@@ -11,20 +10,20 @@ export interface StrikeOptions {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
strike: { strike: {
/** /**
* Set a strike mark * Set a strike mark
*/ */
setStrike: () => Command, setStrike: () => ReturnType,
/** /**
* Toggle a strike mark * Toggle a strike mark
*/ */
toggleStrike: () => Command, toggleStrike: () => ReturnType,
/** /**
* Unset a strike mark * Unset a strike mark
*/ */
unsetStrike: () => Command, unsetStrike: () => ReturnType,
} }
} }
} }

View File

@@ -1,6 +1,5 @@
import { import {
Node, Node,
Command,
ParentConfig, ParentConfig,
mergeAttributes, mergeAttributes,
getExtensionField, getExtensionField,
@@ -43,27 +42,27 @@ export interface TableOptions {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
table: { table: {
insertTable: (options?: { rows?: number, cols?: number, withHeaderRow?: boolean }) => Command, insertTable: (options?: { rows?: number, cols?: number, withHeaderRow?: boolean }) => ReturnType,
addColumnBefore: () => Command, addColumnBefore: () => ReturnType,
addColumnAfter: () => Command, addColumnAfter: () => ReturnType,
deleteColumn: () => Command, deleteColumn: () => ReturnType,
addRowBefore: () => Command, addRowBefore: () => ReturnType,
addRowAfter: () => Command, addRowAfter: () => ReturnType,
deleteRow: () => Command, deleteRow: () => ReturnType,
deleteTable: () => Command, deleteTable: () => ReturnType,
mergeCells: () => Command, mergeCells: () => ReturnType,
splitCell: () => Command, splitCell: () => ReturnType,
toggleHeaderColumn: () => Command, toggleHeaderColumn: () => ReturnType,
toggleHeaderRow: () => Command, toggleHeaderRow: () => ReturnType,
toggleHeaderCell: () => Command, toggleHeaderCell: () => ReturnType,
mergeOrSplit: () => Command, mergeOrSplit: () => ReturnType,
setCellAttribute: (name: string, value: any) => Command, setCellAttribute: (name: string, value: any) => ReturnType,
goToNextCell: () => Command, goToNextCell: () => ReturnType,
goToPreviousCell: () => Command, goToPreviousCell: () => ReturnType,
fixTables: () => Command, fixTables: () => ReturnType,
setCellSelection: (position: { anchorCell: number, headCell?: number }) => Command, setCellSelection: (position: { anchorCell: number, headCell?: number }) => ReturnType,
} }
} }

View File

@@ -1,16 +1,16 @@
import { Command, Node, mergeAttributes } from '@tiptap/core' import { Node, mergeAttributes } from '@tiptap/core'
export interface TaskListOptions { export interface TaskListOptions {
HTMLAttributes: Record<string, any>, HTMLAttributes: Record<string, any>,
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
taskList: { taskList: {
/** /**
* Toggle a task list * Toggle a task list
*/ */
toggleTaskList: () => Command, toggleTaskList: () => ReturnType,
} }
} }
} }

View File

@@ -1,4 +1,4 @@
import { Command, Extension } from '@tiptap/core' import { Extension } from '@tiptap/core'
type TextAlignOptions = { type TextAlignOptions = {
types: string[], types: string[],
@@ -7,16 +7,16 @@ type TextAlignOptions = {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
textAlign: { textAlign: {
/** /**
* Set the text align attribute * Set the text align attribute
*/ */
setTextAlign: (alignment: string) => Command, setTextAlign: (alignment: string) => ReturnType,
/** /**
* Unset the text align attribute * Unset the text align attribute
*/ */
unsetTextAlign: () => Command, unsetTextAlign: () => ReturnType,
} }
} }
} }

View File

@@ -1,5 +1,4 @@
import { import {
Command,
Mark, Mark,
getMarkAttributes, getMarkAttributes,
mergeAttributes, mergeAttributes,
@@ -10,12 +9,12 @@ export interface TextStyleOptions {
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
textStyle: { textStyle: {
/** /**
* Remove spans without inline style attributes. * Remove spans without inline style attributes.
*/ */
removeEmptyTextStyle: () => Command, removeEmptyTextStyle: () => ReturnType,
} }
} }
} }

View File

@@ -1,24 +1,24 @@
import { Command, Mark, mergeAttributes } from '@tiptap/core' import { Mark, mergeAttributes } from '@tiptap/core'
export interface UnderlineOptions { export interface UnderlineOptions {
HTMLAttributes: Record<string, any>, HTMLAttributes: Record<string, any>,
} }
declare module '@tiptap/core' { declare module '@tiptap/core' {
interface Commands { interface Commands<ReturnType> {
underline: { underline: {
/** /**
* Set an underline mark * Set an underline mark
*/ */
setUnderline: () => Command, setUnderline: () => ReturnType,
/** /**
* Toggle an underline mark * Toggle an underline mark
*/ */
toggleUnderline: () => Command, toggleUnderline: () => ReturnType,
/** /**
* Unset an underline mark * Unset an underline mark
*/ */
unsetUnderline: () => Command, unsetUnderline: () => ReturnType,
} }
} }
} }