mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-06 00:42:59 +08:00
add generic to commands type
This commit is contained in:
parent
af91b811bf
commit
78e2a6e775
@ -4,7 +4,7 @@ import {
|
||||
SingleCommands,
|
||||
ChainedCommands,
|
||||
CanCommands,
|
||||
RawCommands,
|
||||
AnyCommands,
|
||||
CommandProps,
|
||||
} from './types'
|
||||
|
||||
@ -12,9 +12,9 @@ export default class CommandManager {
|
||||
|
||||
editor: Editor
|
||||
|
||||
commands: RawCommands
|
||||
commands: AnyCommands
|
||||
|
||||
constructor(editor: Editor, commands: RawCommands) {
|
||||
constructor(editor: Editor, commands: AnyCommands) {
|
||||
this.editor = editor
|
||||
this.commands = commands
|
||||
}
|
||||
@ -28,7 +28,7 @@ export default class CommandManager {
|
||||
return Object.fromEntries(Object
|
||||
.entries(commands)
|
||||
.map(([name, command]) => {
|
||||
const method = (...args: never[]) => {
|
||||
const method = (...args: any[]) => {
|
||||
const callback = command(...args)(props)
|
||||
|
||||
if (!tr.getMeta('preventDispatch')) {
|
||||
@ -39,7 +39,7 @@ export default class CommandManager {
|
||||
}
|
||||
|
||||
return [name, method]
|
||||
})) as SingleCommands
|
||||
})) as unknown as SingleCommands
|
||||
}
|
||||
|
||||
public createChain(startTr?: Transaction, shouldDispatch = true): ChainedCommands {
|
||||
@ -86,7 +86,7 @@ export default class CommandManager {
|
||||
.entries(commands)
|
||||
.map(([name, command]) => {
|
||||
return [name, (...args: never[]) => command(...args)({ ...props, dispatch })]
|
||||
})) as SingleCommands
|
||||
})) as unknown as SingleCommands
|
||||
|
||||
return {
|
||||
...formattedCommands,
|
||||
@ -117,7 +117,7 @@ export default class CommandManager {
|
||||
.entries(commands)
|
||||
.map(([name, command]) => {
|
||||
return [name, (...args: never[]) => command(...args)(props)]
|
||||
})) as SingleCommands
|
||||
})) as unknown as SingleCommands
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
blur: {
|
||||
/**
|
||||
* Removes focus from the editor.
|
||||
*/
|
||||
blur: () => Command,
|
||||
blur: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
clearContent: {
|
||||
/**
|
||||
* Clear the whole document.
|
||||
*/
|
||||
clearContent: (emitUpdate?: boolean) => Command,
|
||||
clearContent: (emitUpdate?: boolean) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { liftTarget } from 'prosemirror-transform'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
clearNodes: {
|
||||
/**
|
||||
* Normalize nodes to a simple paragraph.
|
||||
*/
|
||||
clearNodes: () => Command,
|
||||
clearNodes: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { Command, RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
command: {
|
||||
/**
|
||||
* Define a command inline.
|
||||
*/
|
||||
command: (fn: (props: Parameters<Command>[0]) => boolean) => Command,
|
||||
command: (fn: (props: Parameters<Command>[0]) => boolean) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { createParagraphNear as originalCreateParagraphNear } from 'prosemirror-commands'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
createParagraphNear: {
|
||||
/**
|
||||
* Create a paragraph nearby.
|
||||
*/
|
||||
createParagraphNear: () => Command,
|
||||
createParagraphNear: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { Command, RawCommands, Range } from '../types'
|
||||
import { RawCommands, Range } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
deleteRange: {
|
||||
/**
|
||||
* Delete a given range.
|
||||
*/
|
||||
deleteRange: (range: Range) => Command,
|
||||
deleteRange: (range: Range) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { deleteSelection as originalDeleteSelection } from 'prosemirror-commands'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
deleteSelection: {
|
||||
/**
|
||||
* Delete the selection, if there is one.
|
||||
*/
|
||||
deleteSelection: () => Command,
|
||||
deleteSelection: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
enter: {
|
||||
/**
|
||||
* Trigger enter.
|
||||
*/
|
||||
enter: () => Command,
|
||||
enter: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { exitCode as originalExitCode } from 'prosemirror-commands'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
exitCode: {
|
||||
/**
|
||||
* Exit from a code block.
|
||||
*/
|
||||
exitCode: () => Command,
|
||||
exitCode: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { TextSelection } from 'prosemirror-state'
|
||||
import { MarkType } from 'prosemirror-model'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
import getMarkType from '../helpers/getMarkType'
|
||||
import getMarkRange from '../helpers/getMarkRange'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
extendMarkRange: {
|
||||
/**
|
||||
* 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { Command, RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
first: {
|
||||
/**
|
||||
* 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { EditorState, TextSelection } from 'prosemirror-state'
|
||||
import { Command, RawCommands, FocusPosition } from '../types'
|
||||
import { RawCommands, FocusPosition } from '../types'
|
||||
import minMax from '../utilities/minMax'
|
||||
import isTextSelection from '../helpers/isTextSelection'
|
||||
|
||||
@ -31,12 +31,12 @@ function resolveSelection(state: EditorState, position: FocusPosition = null) {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
focus: {
|
||||
/**
|
||||
* Focus the editor at the given position.
|
||||
*/
|
||||
focus: (position?: FocusPosition) => Command,
|
||||
focus: (position?: FocusPosition) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { Command, RawCommands, Content } from '../types'
|
||||
import { RawCommands, Content } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
insertContent: {
|
||||
/**
|
||||
* Insert a node or string of HTML at the current position.
|
||||
*/
|
||||
insertContent: (value: Content) => Command,
|
||||
insertContent: (value: Content) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,18 @@
|
||||
import createNodeFromContent from '../helpers/createNodeFromContent'
|
||||
import selectionToInsertionEnd from '../helpers/selectionToInsertionEnd'
|
||||
import {
|
||||
Command,
|
||||
RawCommands,
|
||||
Content,
|
||||
Range,
|
||||
} from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
insertContentAt: {
|
||||
/**
|
||||
* 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { joinBackward as originalJoinBackward } from 'prosemirror-commands'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
joinBackward: {
|
||||
/**
|
||||
* Join two nodes backward.
|
||||
*/
|
||||
joinBackward: () => Command,
|
||||
joinBackward: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { joinForward as originalJoinForward } from 'prosemirror-commands'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
joinForward: {
|
||||
/**
|
||||
* Join two nodes forward.
|
||||
*/
|
||||
joinForward: () => Command,
|
||||
joinForward: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
const mac = typeof navigator !== 'undefined' ? /Mac/.test(navigator.platform) : false
|
||||
|
||||
@ -57,12 +57,12 @@ function normalizeKeyName(name: string) {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
keyboardShortcut: {
|
||||
/**
|
||||
* Trigger a keyboard shortcut.
|
||||
*/
|
||||
keyboardShortcut: (name: string) => Command,
|
||||
keyboardShortcut: (name: string) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { lift as originalLift } from 'prosemirror-commands'
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
import isNodeActive from '../helpers/isNodeActive'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
lift: {
|
||||
/**
|
||||
* Removes an existing wrap.
|
||||
*/
|
||||
lift: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command,
|
||||
lift: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { liftEmptyBlock as originalLiftEmptyBlock } from 'prosemirror-commands'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
liftEmptyBlock: {
|
||||
/**
|
||||
* Lift block if empty.
|
||||
*/
|
||||
liftEmptyBlock: () => Command,
|
||||
liftEmptyBlock: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { liftListItem as originalLiftListItem } from 'prosemirror-schema-list'
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
liftListItem: {
|
||||
/**
|
||||
* Lift the list item into a wrapping list.
|
||||
*/
|
||||
liftListItem: (typeOrName: string | NodeType) => Command,
|
||||
liftListItem: (typeOrName: string | NodeType) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { newlineInCode as originalNewlineInCode } from 'prosemirror-commands'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
newlineInCode: {
|
||||
/**
|
||||
* Add a newline character in code.
|
||||
*/
|
||||
newlineInCode: () => Command,
|
||||
newlineInCode: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
replace: {
|
||||
/**
|
||||
* Replaces text with a node.
|
||||
*/
|
||||
replace: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command,
|
||||
replace: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
import { Command, RawCommands, Range } from '../types'
|
||||
import { RawCommands, Range } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
replaceRange: {
|
||||
/**
|
||||
* 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,15 +3,15 @@ import getNodeType from '../helpers/getNodeType'
|
||||
import getMarkType from '../helpers/getMarkType'
|
||||
import getSchemaTypeNameByName from '../helpers/getSchemaTypeNameByName'
|
||||
import deleteProps from '../utilities/deleteProps'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
resetAttributes: {
|
||||
/**
|
||||
* 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
scrollIntoView: {
|
||||
/**
|
||||
* Scroll the selection into view.
|
||||
*/
|
||||
scrollIntoView: () => Command,
|
||||
scrollIntoView: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { selectAll as originalSelectAll } from 'prosemirror-commands'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
selectAll: {
|
||||
/**
|
||||
* Select the whole document.
|
||||
*/
|
||||
selectAll: () => Command,
|
||||
selectAll: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { selectNodeBackward as originalSelectNodeBackward } from 'prosemirror-commands'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
selectNodeBackward: {
|
||||
/**
|
||||
* Select a node backward.
|
||||
*/
|
||||
selectNodeBackward: () => Command,
|
||||
selectNodeBackward: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { selectNodeForward as originalSelectNodeForward } from 'prosemirror-commands'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
selectNodeForward: {
|
||||
/**
|
||||
* Select a node forward.
|
||||
*/
|
||||
selectNodeForward: () => Command,
|
||||
selectNodeForward: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { selectParentNode as originalSelectParentNode } from 'prosemirror-commands'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
selectParentNode: {
|
||||
/**
|
||||
* Select the parent node.
|
||||
*/
|
||||
selectParentNode: () => Command,
|
||||
selectParentNode: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { TextSelection } from 'prosemirror-state'
|
||||
import { ParseOptions } from 'prosemirror-model'
|
||||
import createDocument from '../helpers/createDocument'
|
||||
import { Command, RawCommands, Content } from '../types'
|
||||
import { RawCommands, Content } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
setContent: {
|
||||
/**
|
||||
* Replace the whole document with new content.
|
||||
@ -13,7 +13,7 @@ declare module '@tiptap/core' {
|
||||
content: Content,
|
||||
emitUpdate?: boolean,
|
||||
parseOptions?: ParseOptions,
|
||||
) => Command,
|
||||
) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { MarkType } from 'prosemirror-model'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
import getMarkType from '../helpers/getMarkType'
|
||||
import getMarkAttributes from '../helpers/getMarkAttributes'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
setMark: {
|
||||
/**
|
||||
* Add a mark with new attributes.
|
||||
*/
|
||||
setMark: (typeOrName: string | MarkType, attributes?: Record<string, any>) => Command,
|
||||
setMark: (typeOrName: string | MarkType, attributes?: Record<string, any>) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
setMeta: {
|
||||
/**
|
||||
* Store a metadata property in the current transaction.
|
||||
*/
|
||||
setMeta: (key: string, value: any) => Command,
|
||||
setMeta: (key: string, value: any) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { setBlockType } from 'prosemirror-commands'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
setNode: {
|
||||
/**
|
||||
* 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
import { NodeSelection } from 'prosemirror-state'
|
||||
import minMax from '../utilities/minMax'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
setNodeSelection: {
|
||||
/**
|
||||
* Creates a NodeSelection.
|
||||
*/
|
||||
setNodeSelection: (position: number) => Command,
|
||||
setNodeSelection: (position: number) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
import { TextSelection } from 'prosemirror-state'
|
||||
import minMax from '../utilities/minMax'
|
||||
import { Command, RawCommands, Range } from '../types'
|
||||
import { RawCommands, Range } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
setTextSelection: {
|
||||
/**
|
||||
* Creates a TextSelection.
|
||||
*/
|
||||
setTextSelection: (position: number | Range) => Command,
|
||||
setTextSelection: (position: number | Range) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { sinkListItem as originalSinkListItem } from 'prosemirror-schema-list'
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
sinkListItem: {
|
||||
/**
|
||||
* Sink the list item down into an inner list.
|
||||
*/
|
||||
sinkListItem: (typeOrName: string | NodeType) => Command,
|
||||
sinkListItem: (typeOrName: string | NodeType) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { canSplit } from 'prosemirror-transform'
|
||||
import { ContentMatch } from 'prosemirror-model'
|
||||
import { EditorState, NodeSelection, TextSelection } from 'prosemirror-state'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
import getSplittedAttributes from '../helpers/getSplittedAttributes'
|
||||
|
||||
function defaultBlockAt(match: ContentMatch) {
|
||||
@ -27,12 +27,12 @@ function ensureMarks(state: EditorState, splittableMarks?: string[]) {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
splitBlock: {
|
||||
/**
|
||||
* Forks a new node from an existing node.
|
||||
*/
|
||||
splitBlock: (options?: { keepMarks?: boolean }) => Command,
|
||||
splitBlock: (options?: { keepMarks?: boolean }) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,17 +6,17 @@ import {
|
||||
} from 'prosemirror-model'
|
||||
import { canSplit } from 'prosemirror-transform'
|
||||
import { TextSelection } from 'prosemirror-state'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
import getSplittedAttributes from '../helpers/getSplittedAttributes'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
splitListItem: {
|
||||
/**
|
||||
* Splits one list item into two list items.
|
||||
*/
|
||||
splitListItem: (typeOrName: string | NodeType) => Command,
|
||||
splitListItem: (typeOrName: string | NodeType) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
import findParentNode from '../helpers/findParentNode'
|
||||
import isList from '../helpers/isList'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
toggleList: {
|
||||
/**
|
||||
* Toggle between different list types.
|
||||
*/
|
||||
toggleList: (listTypeOrName: string | NodeType, itemTypeOrName: string | NodeType) => Command,
|
||||
toggleList: (listTypeOrName: string | NodeType, itemTypeOrName: string | NodeType) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { MarkType } from 'prosemirror-model'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
import getMarkType from '../helpers/getMarkType'
|
||||
import isMarkActive from '../helpers/isMarkActive'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
toggleMark: {
|
||||
/**
|
||||
* Toggle a mark on and off.
|
||||
*/
|
||||
toggleMark: (typeOrName: string | MarkType, attributes?: Record<string, any>) => Command,
|
||||
toggleMark: (typeOrName: string | MarkType, attributes?: Record<string, any>) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
import isNodeActive from '../helpers/isNodeActive'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
toggleNode: {
|
||||
/**
|
||||
* 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { wrapIn, lift } from 'prosemirror-commands'
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
import isNodeActive from '../helpers/isNodeActive'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
toggleWrap: {
|
||||
/**
|
||||
* 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { undoInputRule as originalUndoInputRule } from 'prosemirror-inputrules'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
undoInputRule: {
|
||||
/**
|
||||
* Undo an input rule.
|
||||
*/
|
||||
undoInputRule: () => Command,
|
||||
undoInputRule: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
unsetAllMarks: {
|
||||
/**
|
||||
* Remove all marks in the current selection.
|
||||
*/
|
||||
unsetAllMarks: () => Command,
|
||||
unsetAllMarks: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { MarkType } from 'prosemirror-model'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
import getMarkType from '../helpers/getMarkType'
|
||||
import getMarkRange from '../helpers/getMarkRange'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
unsetMark: {
|
||||
/**
|
||||
* Remove all marks in the current selection.
|
||||
*/
|
||||
unsetMark: (typeOrName: string | MarkType) => Command,
|
||||
unsetMark: (typeOrName: string | MarkType) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,15 +2,15 @@ import { NodeType, MarkType } from 'prosemirror-model'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
import getMarkType from '../helpers/getMarkType'
|
||||
import getSchemaTypeNameByName from '../helpers/getSchemaTypeNameByName'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
updateAttributes: {
|
||||
/**
|
||||
* 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { wrapIn as originalWrapIn } from 'prosemirror-commands'
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
import isNodeActive from '../helpers/isNodeActive'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
wrapIn: {
|
||||
/**
|
||||
* Wraps nodes in another node.
|
||||
*/
|
||||
wrapIn: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command,
|
||||
wrapIn: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { wrapInList as originalWrapInList } from 'prosemirror-schema-list'
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import { Command, RawCommands } from '../types'
|
||||
import { RawCommands } from '../types'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
wrapInList: {
|
||||
/**
|
||||
* Wrap a node in a list.
|
||||
*/
|
||||
wrapInList: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command,
|
||||
wrapInList: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,8 @@ export { default as isNodeSelection } from './helpers/isNodeSelection'
|
||||
export { default as isTextSelection } from './helpers/isTextSelection'
|
||||
export { default as posToDOMRect } from './helpers/posToDOMRect'
|
||||
|
||||
export interface Commands {}
|
||||
// eslint-disable-next-line
|
||||
export interface Commands<ReturnType = any> {}
|
||||
|
||||
// eslint-disable-next-line
|
||||
export interface ExtensionConfig<Options = any> {}
|
||||
|
@ -156,24 +156,20 @@ export type NodeViewRendererProps = {
|
||||
|
||||
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 = {
|
||||
[Item in keyof UnionCommands]: UnionCommands[Item] extends (...args: any[]) => any
|
||||
? (...args: Parameters<UnionCommands[Item]>) => Command
|
||||
: never
|
||||
[Item in keyof UnionCommands]: UnionCommands<Command>[Item]
|
||||
}
|
||||
|
||||
export type SingleCommands = {
|
||||
[Item in keyof RawCommands]: RawCommands[Item] extends (...args: any[]) => any
|
||||
? (...args: Parameters<RawCommands[Item]>) => boolean
|
||||
: never
|
||||
[Item in keyof UnionCommands]: UnionCommands<boolean>[Item]
|
||||
}
|
||||
|
||||
export type ChainedCommands = {
|
||||
[Item in keyof RawCommands]: RawCommands[Item] extends (...args: any[]) => any
|
||||
? (...args: Parameters<RawCommands[Item]>) => ChainedCommands
|
||||
: never
|
||||
[Item in keyof UnionCommands]: UnionCommands<ChainedCommands>[Item]
|
||||
} & {
|
||||
run: () => boolean
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Command, Node, mergeAttributes } from '@tiptap/core'
|
||||
import { Node, mergeAttributes } from '@tiptap/core'
|
||||
import { wrappingInputRule } from 'prosemirror-inputrules'
|
||||
|
||||
export interface BlockquoteOptions {
|
||||
@ -6,20 +6,20 @@ export interface BlockquoteOptions {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
blockQuote: {
|
||||
/**
|
||||
* Set a blockquote node
|
||||
*/
|
||||
setBlockquote: () => Command,
|
||||
setBlockquote: () => ReturnType,
|
||||
/**
|
||||
* Toggle a blockquote node
|
||||
*/
|
||||
toggleBlockquote: () => Command,
|
||||
toggleBlockquote: () => ReturnType,
|
||||
/**
|
||||
* Unset a blockquote node
|
||||
*/
|
||||
unsetBlockquote: () => Command,
|
||||
unsetBlockquote: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {
|
||||
Command,
|
||||
Mark,
|
||||
markInputRule,
|
||||
markPasteRule,
|
||||
@ -11,20 +10,20 @@ export interface BoldOptions {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
bold: {
|
||||
/**
|
||||
* Set a bold mark
|
||||
*/
|
||||
setBold: () => Command,
|
||||
setBold: () => ReturnType,
|
||||
/**
|
||||
* Toggle a bold mark
|
||||
*/
|
||||
toggleBold: () => Command,
|
||||
toggleBold: () => ReturnType,
|
||||
/**
|
||||
* Unset a bold mark
|
||||
*/
|
||||
unsetBold: () => Command,
|
||||
unsetBold: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Command, Node, mergeAttributes } from '@tiptap/core'
|
||||
import { Node, mergeAttributes } from '@tiptap/core'
|
||||
import { wrappingInputRule } from 'prosemirror-inputrules'
|
||||
|
||||
export interface BulletListOptions {
|
||||
@ -6,12 +6,12 @@ export interface BulletListOptions {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
bulletList: {
|
||||
/**
|
||||
* Toggle a bullet list
|
||||
*/
|
||||
toggleBulletList: () => Command,
|
||||
toggleBulletList: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Command, Node } from '@tiptap/core'
|
||||
import { Node } from '@tiptap/core'
|
||||
import { textblockTypeInputRule } from 'prosemirror-inputrules'
|
||||
|
||||
export interface CodeBlockOptions {
|
||||
@ -7,16 +7,16 @@ export interface CodeBlockOptions {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
codeBlock: {
|
||||
/**
|
||||
* Set a code block
|
||||
*/
|
||||
setCodeBlock: (attributes?: { language: string }) => Command,
|
||||
setCodeBlock: (attributes?: { language: string }) => ReturnType,
|
||||
/**
|
||||
* Toggle a code block
|
||||
*/
|
||||
toggleCodeBlock: (attributes?: { language: string }) => Command,
|
||||
toggleCodeBlock: (attributes?: { language: string }) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {
|
||||
Command,
|
||||
Mark,
|
||||
markInputRule,
|
||||
markPasteRule,
|
||||
@ -11,20 +10,20 @@ export interface CodeOptions {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
code: {
|
||||
/**
|
||||
* Set a code mark
|
||||
*/
|
||||
setCode: () => Command,
|
||||
setCode: () => ReturnType,
|
||||
/**
|
||||
* Toggle inline code
|
||||
*/
|
||||
toggleCode: () => Command,
|
||||
toggleCode: () => ReturnType,
|
||||
/**
|
||||
* Unset a code mark
|
||||
*/
|
||||
unsetCode: () => Command,
|
||||
unsetCode: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Extension, Command } from '@tiptap/core'
|
||||
import { Extension } from '@tiptap/core'
|
||||
import { yCursorPlugin } from 'y-prosemirror'
|
||||
|
||||
export interface CollaborationCursorOptions {
|
||||
@ -9,12 +9,12 @@ export interface CollaborationCursorOptions {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
collaborationCursor: {
|
||||
/**
|
||||
* Update details of the current user
|
||||
*/
|
||||
user: (attributes: Record<string, any>) => Command,
|
||||
user: (attributes: Record<string, any>) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Extension, Command } from '@tiptap/core'
|
||||
import { Extension } from '@tiptap/core'
|
||||
import { UndoManager } from 'yjs'
|
||||
import {
|
||||
redo,
|
||||
@ -9,16 +9,16 @@ import {
|
||||
} from 'y-prosemirror'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
collaboration: {
|
||||
/**
|
||||
* Undo recent changes
|
||||
*/
|
||||
undo: () => Command,
|
||||
undo: () => ReturnType,
|
||||
/**
|
||||
* Reapply reverted changes
|
||||
*/
|
||||
redo: () => Command,
|
||||
redo: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Command, Extension } from '@tiptap/core'
|
||||
import { Extension } from '@tiptap/core'
|
||||
import '@tiptap/extension-text-style'
|
||||
|
||||
type FontFamilyOptions = {
|
||||
@ -6,16 +6,16 @@ type FontFamilyOptions = {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
fontFamily: {
|
||||
/**
|
||||
* Set the font family
|
||||
*/
|
||||
setFontFamily: (fontFamily: string) => Command,
|
||||
setFontFamily: (fontFamily: string) => ReturnType,
|
||||
/**
|
||||
* Unset the font family
|
||||
*/
|
||||
unsetFontFamily: () => Command,
|
||||
unsetFontFamily: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { Command, Node, mergeAttributes } from '@tiptap/core'
|
||||
import { Node, mergeAttributes } from '@tiptap/core'
|
||||
|
||||
export interface HardBreakOptions {
|
||||
HTMLAttributes: Record<string, any>,
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
hardBreak: {
|
||||
/**
|
||||
* Add a hard break
|
||||
*/
|
||||
setHardBreak: () => Command,
|
||||
setHardBreak: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Command, Node, mergeAttributes } from '@tiptap/core'
|
||||
import { Node, mergeAttributes } from '@tiptap/core'
|
||||
import { textblockTypeInputRule } from 'prosemirror-inputrules'
|
||||
|
||||
type Level = 1 | 2 | 3 | 4 | 5 | 6
|
||||
@ -9,16 +9,16 @@ export interface HeadingOptions {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
heading: {
|
||||
/**
|
||||
* Set a heading node
|
||||
*/
|
||||
setHeading: (attributes: { level: Level }) => Command,
|
||||
setHeading: (attributes: { level: Level }) => ReturnType,
|
||||
/**
|
||||
* Toggle a heading node
|
||||
*/
|
||||
toggleHeading: (attributes: { level: Level }) => Command,
|
||||
toggleHeading: (attributes: { level: Level }) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {
|
||||
Command,
|
||||
Mark,
|
||||
markInputRule,
|
||||
markPasteRule,
|
||||
@ -12,20 +11,20 @@ export interface HighlightOptions {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
highlight: {
|
||||
/**
|
||||
* Set a highlight mark
|
||||
*/
|
||||
setHighlight: (attributes?: { color: string }) => Command,
|
||||
setHighlight: (attributes?: { color: string }) => ReturnType,
|
||||
/**
|
||||
* Toggle a highlight mark
|
||||
*/
|
||||
toggleHighlight: (attributes?: { color: string }) => Command,
|
||||
toggleHighlight: (attributes?: { color: string }) => ReturnType,
|
||||
/**
|
||||
* Unset a highlight mark
|
||||
*/
|
||||
unsetHighlight: () => Command,
|
||||
unsetHighlight: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Command, Extension } from '@tiptap/core'
|
||||
import { Extension } from '@tiptap/core'
|
||||
import { history, undo, redo } from 'prosemirror-history'
|
||||
|
||||
export interface HistoryOptions {
|
||||
@ -7,16 +7,16 @@ export interface HistoryOptions {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
history: {
|
||||
/**
|
||||
* Undo recent changes
|
||||
*/
|
||||
undo: () => Command,
|
||||
undo: () => ReturnType,
|
||||
/**
|
||||
* Reapply reverted changes
|
||||
*/
|
||||
redo: () => Command,
|
||||
redo: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {
|
||||
Command,
|
||||
Node,
|
||||
nodeInputRule,
|
||||
mergeAttributes,
|
||||
@ -11,12 +10,12 @@ export interface HorizontalRuleOptions {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
horizontalRule: {
|
||||
/**
|
||||
* Add a horizontal rule
|
||||
*/
|
||||
setHorizontalRule: () => Command,
|
||||
setHorizontalRule: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {
|
||||
Command,
|
||||
Node,
|
||||
nodeInputRule,
|
||||
mergeAttributes,
|
||||
@ -11,12 +10,12 @@ export interface ImageOptions {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
image: {
|
||||
/**
|
||||
* Add an image
|
||||
*/
|
||||
setImage: (options: { src: string, alt?: string, title?: string }) => Command,
|
||||
setImage: (options: { src: string, alt?: string, title?: string }) => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {
|
||||
Command,
|
||||
Mark,
|
||||
markInputRule,
|
||||
markPasteRule,
|
||||
@ -11,20 +10,20 @@ export interface ItalicOptions {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
italic: {
|
||||
/**
|
||||
* Set an italic mark
|
||||
*/
|
||||
setItalic: () => Command,
|
||||
setItalic: () => ReturnType,
|
||||
/**
|
||||
* Toggle an italic mark
|
||||
*/
|
||||
toggleItalic: () => Command,
|
||||
toggleItalic: () => ReturnType,
|
||||
/**
|
||||
* Unset an italic mark
|
||||
*/
|
||||
unsetItalic: () => Command,
|
||||
unsetItalic: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {
|
||||
Command,
|
||||
Mark,
|
||||
markPasteRule,
|
||||
mergeAttributes,
|
||||
@ -22,20 +21,20 @@ export interface LinkOptions {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
link: {
|
||||
/**
|
||||
* Set a link mark
|
||||
*/
|
||||
setLink: (attributes: { href: string, target?: string }) => Command,
|
||||
setLink: (attributes: { href: string, target?: string }) => ReturnType,
|
||||
/**
|
||||
* Toggle a link mark
|
||||
*/
|
||||
toggleLink: (attributes: { href: string, target?: string }) => Command,
|
||||
toggleLink: (attributes: { href: string, target?: string }) => ReturnType,
|
||||
/**
|
||||
* Unset a link mark
|
||||
*/
|
||||
unsetLink: () => Command,
|
||||
unsetLink: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Command, Node, mergeAttributes } from '@tiptap/core'
|
||||
import { Node, mergeAttributes } from '@tiptap/core'
|
||||
import { wrappingInputRule } from 'prosemirror-inputrules'
|
||||
|
||||
export interface OrderedListOptions {
|
||||
@ -6,12 +6,12 @@ export interface OrderedListOptions {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
orderedList: {
|
||||
/**
|
||||
* Toggle an ordered list
|
||||
*/
|
||||
toggleOrderedList: () => Command,
|
||||
toggleOrderedList: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { Command, Node, mergeAttributes } from '@tiptap/core'
|
||||
import { Node, mergeAttributes } from '@tiptap/core'
|
||||
|
||||
export interface ParagraphOptions {
|
||||
HTMLAttributes: Record<string, any>,
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
paragraph: {
|
||||
/**
|
||||
* Toggle a paragraph
|
||||
*/
|
||||
setParagraph: () => Command,
|
||||
setParagraph: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {
|
||||
Command,
|
||||
Mark,
|
||||
markInputRule,
|
||||
markPasteRule,
|
||||
@ -11,20 +10,20 @@ export interface StrikeOptions {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
strike: {
|
||||
/**
|
||||
* Set a strike mark
|
||||
*/
|
||||
setStrike: () => Command,
|
||||
setStrike: () => ReturnType,
|
||||
/**
|
||||
* Toggle a strike mark
|
||||
*/
|
||||
toggleStrike: () => Command,
|
||||
toggleStrike: () => ReturnType,
|
||||
/**
|
||||
* Unset a strike mark
|
||||
*/
|
||||
unsetStrike: () => Command,
|
||||
unsetStrike: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import {
|
||||
Node,
|
||||
Command,
|
||||
ParentConfig,
|
||||
mergeAttributes,
|
||||
getExtensionField,
|
||||
@ -43,27 +42,27 @@ export interface TableOptions {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
table: {
|
||||
insertTable: (options?: { rows?: number, cols?: number, withHeaderRow?: boolean }) => Command,
|
||||
addColumnBefore: () => Command,
|
||||
addColumnAfter: () => Command,
|
||||
deleteColumn: () => Command,
|
||||
addRowBefore: () => Command,
|
||||
addRowAfter: () => Command,
|
||||
deleteRow: () => Command,
|
||||
deleteTable: () => Command,
|
||||
mergeCells: () => Command,
|
||||
splitCell: () => Command,
|
||||
toggleHeaderColumn: () => Command,
|
||||
toggleHeaderRow: () => Command,
|
||||
toggleHeaderCell: () => Command,
|
||||
mergeOrSplit: () => Command,
|
||||
setCellAttribute: (name: string, value: any) => Command,
|
||||
goToNextCell: () => Command,
|
||||
goToPreviousCell: () => Command,
|
||||
fixTables: () => Command,
|
||||
setCellSelection: (position: { anchorCell: number, headCell?: number }) => Command,
|
||||
insertTable: (options?: { rows?: number, cols?: number, withHeaderRow?: boolean }) => ReturnType,
|
||||
addColumnBefore: () => ReturnType,
|
||||
addColumnAfter: () => ReturnType,
|
||||
deleteColumn: () => ReturnType,
|
||||
addRowBefore: () => ReturnType,
|
||||
addRowAfter: () => ReturnType,
|
||||
deleteRow: () => ReturnType,
|
||||
deleteTable: () => ReturnType,
|
||||
mergeCells: () => ReturnType,
|
||||
splitCell: () => ReturnType,
|
||||
toggleHeaderColumn: () => ReturnType,
|
||||
toggleHeaderRow: () => ReturnType,
|
||||
toggleHeaderCell: () => ReturnType,
|
||||
mergeOrSplit: () => ReturnType,
|
||||
setCellAttribute: (name: string, value: any) => ReturnType,
|
||||
goToNextCell: () => ReturnType,
|
||||
goToPreviousCell: () => ReturnType,
|
||||
fixTables: () => ReturnType,
|
||||
setCellSelection: (position: { anchorCell: number, headCell?: number }) => ReturnType,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { Command, Node, mergeAttributes } from '@tiptap/core'
|
||||
import { Node, mergeAttributes } from '@tiptap/core'
|
||||
|
||||
export interface TaskListOptions {
|
||||
HTMLAttributes: Record<string, any>,
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
taskList: {
|
||||
/**
|
||||
* Toggle a task list
|
||||
*/
|
||||
toggleTaskList: () => Command,
|
||||
toggleTaskList: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Command, Extension } from '@tiptap/core'
|
||||
import { Extension } from '@tiptap/core'
|
||||
|
||||
type TextAlignOptions = {
|
||||
types: string[],
|
||||
@ -7,16 +7,16 @@ type TextAlignOptions = {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
textAlign: {
|
||||
/**
|
||||
* Set the text align attribute
|
||||
*/
|
||||
setTextAlign: (alignment: string) => Command,
|
||||
setTextAlign: (alignment: string) => ReturnType,
|
||||
/**
|
||||
* Unset the text align attribute
|
||||
*/
|
||||
unsetTextAlign: () => Command,
|
||||
unsetTextAlign: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {
|
||||
Command,
|
||||
Mark,
|
||||
getMarkAttributes,
|
||||
mergeAttributes,
|
||||
@ -10,12 +9,12 @@ export interface TextStyleOptions {
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
textStyle: {
|
||||
/**
|
||||
* Remove spans without inline style attributes.
|
||||
*/
|
||||
removeEmptyTextStyle: () => Command,
|
||||
removeEmptyTextStyle: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,24 @@
|
||||
import { Command, Mark, mergeAttributes } from '@tiptap/core'
|
||||
import { Mark, mergeAttributes } from '@tiptap/core'
|
||||
|
||||
export interface UnderlineOptions {
|
||||
HTMLAttributes: Record<string, any>,
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
interface Commands<ReturnType> {
|
||||
underline: {
|
||||
/**
|
||||
* Set an underline mark
|
||||
*/
|
||||
setUnderline: () => Command,
|
||||
setUnderline: () => ReturnType,
|
||||
/**
|
||||
* Toggle an underline mark
|
||||
*/
|
||||
toggleUnderline: () => Command,
|
||||
toggleUnderline: () => ReturnType,
|
||||
/**
|
||||
* Unset an underline mark
|
||||
*/
|
||||
unsetUnderline: () => Command,
|
||||
unsetUnderline: () => ReturnType,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user