@tiptap/core 2.3.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +290 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +290 -79
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +290 -79
- package/dist/index.umd.js.map +1 -1
- package/dist/packages/core/src/Extension.d.ts +129 -14
- package/dist/packages/core/src/ExtensionManager.d.ts +37 -0
- package/dist/packages/core/src/Mark.d.ts +129 -14
- package/dist/packages/core/src/Node.d.ts +226 -30
- package/dist/packages/core/src/NodeView.d.ts +4 -0
- package/dist/packages/core/src/PasteRule.d.ts +4 -0
- package/dist/packages/core/src/commands/blur.d.ts +1 -0
- package/dist/packages/core/src/commands/clearContent.d.ts +2 -0
- package/dist/packages/core/src/commands/clearNodes.d.ts +1 -0
- package/dist/packages/core/src/commands/command.d.ts +6 -0
- package/dist/packages/core/src/commands/createParagraphNear.d.ts +1 -0
- package/dist/packages/core/src/commands/cut.d.ts +5 -0
- package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +1 -0
- package/dist/packages/core/src/commands/deleteNode.d.ts +3 -1
- package/dist/packages/core/src/commands/deleteRange.d.ts +2 -0
- package/dist/packages/core/src/commands/deleteSelection.d.ts +1 -0
- package/dist/packages/core/src/commands/enter.d.ts +1 -0
- package/dist/packages/core/src/commands/exitCode.d.ts +1 -0
- package/dist/packages/core/src/commands/extendMarkRange.d.ts +14 -2
- package/dist/packages/core/src/commands/first.d.ts +2 -0
- package/dist/packages/core/src/commands/focus.d.ts +14 -1
- package/dist/packages/core/src/commands/insertContent.d.ts +17 -1
- package/dist/packages/core/src/commands/insertContentAt.d.ts +20 -1
- package/dist/packages/core/src/commands/join.d.ts +12 -4
- package/dist/packages/core/src/commands/joinItemBackward.d.ts +2 -1
- package/dist/packages/core/src/commands/joinItemForward.d.ts +2 -1
- package/dist/packages/core/src/commands/keyboardShortcut.d.ts +2 -0
- package/dist/packages/core/src/commands/lift.d.ts +5 -1
- package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +2 -1
- package/dist/packages/core/src/commands/liftListItem.d.ts +3 -1
- package/dist/packages/core/src/commands/newlineInCode.d.ts +1 -0
- package/dist/packages/core/src/commands/resetAttributes.d.ts +3 -0
- package/dist/packages/core/src/commands/scrollIntoView.d.ts +1 -0
- package/dist/packages/core/src/commands/selectAll.d.ts +1 -0
- package/dist/packages/core/src/commands/selectNodeBackward.d.ts +1 -0
- package/dist/packages/core/src/commands/selectNodeForward.d.ts +1 -0
- package/dist/packages/core/src/commands/selectParentNode.d.ts +1 -0
- package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +1 -0
- package/dist/packages/core/src/commands/selectTextblockStart.d.ts +1 -0
- package/dist/packages/core/src/commands/setContent.d.ts +19 -1
- package/dist/packages/core/src/commands/setMark.d.ts +2 -0
- package/dist/packages/core/src/commands/setMeta.d.ts +3 -0
- package/dist/packages/core/src/commands/setNode.d.ts +3 -0
- package/dist/packages/core/src/commands/setNodeSelection.d.ts +2 -0
- package/dist/packages/core/src/commands/setTextSelection.d.ts +2 -0
- package/dist/packages/core/src/commands/sinkListItem.d.ts +2 -0
- package/dist/packages/core/src/commands/splitBlock.d.ts +3 -0
- package/dist/packages/core/src/commands/splitListItem.d.ts +2 -0
- package/dist/packages/core/src/commands/toggleList.d.ts +5 -0
- package/dist/packages/core/src/commands/toggleMark.d.ts +13 -1
- package/dist/packages/core/src/commands/toggleNode.d.ts +4 -0
- package/dist/packages/core/src/commands/toggleWrap.d.ts +3 -0
- package/dist/packages/core/src/commands/undoInputRule.d.ts +1 -0
- package/dist/packages/core/src/commands/unsetAllMarks.d.ts +1 -0
- package/dist/packages/core/src/commands/unsetMark.d.ts +8 -1
- package/dist/packages/core/src/commands/updateAttributes.d.ts +12 -1
- package/dist/packages/core/src/commands/wrapIn.d.ts +3 -0
- package/dist/packages/core/src/commands/wrapInList.d.ts +3 -0
- package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +3 -0
- package/dist/packages/core/src/helpers/createChainableState.d.ts +5 -0
- package/dist/packages/core/src/helpers/createDocument.d.ts +7 -0
- package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +7 -0
- package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +5 -0
- package/dist/packages/core/src/helpers/findChildren.d.ts +6 -0
- package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +4 -0
- package/dist/packages/core/src/helpers/findParentNode.d.ts +8 -0
- package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +9 -0
- package/dist/packages/core/src/helpers/generateHTML.d.ts +6 -0
- package/dist/packages/core/src/helpers/generateJSON.d.ts +6 -0
- package/dist/packages/core/src/helpers/generateText.d.ts +7 -0
- package/dist/packages/core/src/helpers/getAttributes.d.ts +6 -0
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +7 -0
- package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +6 -0
- package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +6 -0
- package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +6 -0
- package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +7 -0
- package/dist/packages/core/src/helpers/getText.d.ts +9 -0
- package/dist/packages/core/src/helpers/getTextBetween.d.ts +8 -0
- package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +6 -0
- package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +5 -0
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +1 -0
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +1 -0
- package/dist/packages/core/src/inputRules/textInputRule.d.ts +1 -0
- package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +1 -0
- package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +1 -0
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +1 -0
- package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +1 -0
- package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +1 -0
- package/package.json +2 -2
- package/src/Extension.ts +130 -14
- package/src/ExtensionManager.ts +117 -85
- package/src/Mark.ts +129 -14
- package/src/Node.ts +226 -30
- package/src/NodePos.ts +19 -18
- package/src/NodeView.ts +4 -0
- package/src/PasteRule.ts +4 -0
- package/src/commands/blur.ts +1 -0
- package/src/commands/clearContent.ts +2 -0
- package/src/commands/clearNodes.ts +1 -0
- package/src/commands/command.ts +6 -0
- package/src/commands/createParagraphNear.ts +1 -0
- package/src/commands/cut.ts +5 -0
- package/src/commands/deleteCurrentNode.ts +1 -0
- package/src/commands/deleteNode.ts +3 -1
- package/src/commands/deleteRange.ts +2 -0
- package/src/commands/deleteSelection.ts +1 -0
- package/src/commands/enter.ts +1 -0
- package/src/commands/exitCode.ts +1 -0
- package/src/commands/extendMarkRange.ts +12 -1
- package/src/commands/first.ts +2 -0
- package/src/commands/focus.ts +12 -0
- package/src/commands/insertContent.ts +16 -0
- package/src/commands/insertContentAt.ts +19 -0
- package/src/commands/join.ts +12 -4
- package/src/commands/joinItemBackward.ts +2 -1
- package/src/commands/joinItemForward.ts +2 -1
- package/src/commands/keyboardShortcut.ts +2 -0
- package/src/commands/lift.ts +5 -1
- package/src/commands/liftEmptyBlock.ts +2 -1
- package/src/commands/liftListItem.ts +3 -1
- package/src/commands/newlineInCode.ts +1 -0
- package/src/commands/resetAttributes.ts +3 -0
- package/src/commands/scrollIntoView.ts +1 -0
- package/src/commands/selectAll.ts +1 -0
- package/src/commands/selectNodeBackward.ts +1 -0
- package/src/commands/selectNodeForward.ts +1 -0
- package/src/commands/selectParentNode.ts +1 -0
- package/src/commands/selectTextblockEnd.ts +1 -0
- package/src/commands/selectTextblockStart.ts +1 -0
- package/src/commands/setContent.ts +17 -0
- package/src/commands/setMark.ts +2 -0
- package/src/commands/setMeta.ts +3 -0
- package/src/commands/setNode.ts +3 -0
- package/src/commands/setNodeSelection.ts +2 -0
- package/src/commands/setTextSelection.ts +2 -0
- package/src/commands/sinkListItem.ts +2 -0
- package/src/commands/splitBlock.ts +3 -0
- package/src/commands/splitListItem.ts +2 -0
- package/src/commands/toggleList.ts +5 -0
- package/src/commands/toggleMark.ts +12 -0
- package/src/commands/toggleNode.ts +4 -0
- package/src/commands/toggleWrap.ts +3 -0
- package/src/commands/undoInputRule.ts +1 -0
- package/src/commands/unsetAllMarks.ts +1 -0
- package/src/commands/unsetMark.ts +7 -0
- package/src/commands/updateAttributes.ts +10 -0
- package/src/commands/wrapIn.ts +3 -0
- package/src/commands/wrapInList.ts +3 -0
- package/src/extensions/keymap.ts +7 -1
- package/src/helpers/combineTransactionSteps.ts +3 -0
- package/src/helpers/createChainableState.ts +5 -0
- package/src/helpers/createDocument.ts +7 -0
- package/src/helpers/createNodeFromContent.ts +16 -3
- package/src/helpers/defaultBlockAt.ts +5 -0
- package/src/helpers/findChildren.ts +6 -0
- package/src/helpers/findChildrenInRange.ts +4 -0
- package/src/helpers/findParentNode.ts +8 -0
- package/src/helpers/findParentNodeClosestToPos.ts +9 -0
- package/src/helpers/generateHTML.ts +6 -0
- package/src/helpers/generateJSON.ts +6 -0
- package/src/helpers/generateText.ts +7 -0
- package/src/helpers/getAttributes.ts +6 -0
- package/src/helpers/getExtensionField.ts +7 -0
- package/src/helpers/getSchemaByResolvedExtensions.ts +6 -0
- package/src/helpers/getSchemaTypeByName.ts +6 -0
- package/src/helpers/getSchemaTypeNameByName.ts +6 -0
- package/src/helpers/getSplittedAttributes.ts +7 -0
- package/src/helpers/getText.ts +9 -0
- package/src/helpers/getTextBetween.ts +12 -10
- package/src/helpers/getTextContentFromNodes.ts +6 -0
- package/src/helpers/getTextSerializersFromSchema.ts +5 -0
- package/src/inputRules/markInputRule.ts +1 -0
- package/src/inputRules/nodeInputRule.ts +1 -0
- package/src/inputRules/textInputRule.ts +1 -0
- package/src/inputRules/textblockTypeInputRule.ts +1 -0
- package/src/inputRules/wrappingInputRule.ts +1 -0
- package/src/pasteRules/markPasteRule.ts +1 -0
- package/src/pasteRules/nodePasteRule.ts +1 -0
- package/src/pasteRules/textPasteRule.ts +1 -0
|
@@ -5,9 +5,25 @@ declare module '@tiptap/core' {
|
|
|
5
5
|
insertContent: {
|
|
6
6
|
/**
|
|
7
7
|
* Insert a node or string of HTML at the current position.
|
|
8
|
+
* @example editor.commands.insertContent('<h1>Example</h1>')
|
|
9
|
+
* @example editor.commands.insertContent('<h1>Example</h1>', { updateSelection: false })
|
|
8
10
|
*/
|
|
9
|
-
insertContent: (
|
|
11
|
+
insertContent: (
|
|
12
|
+
/**
|
|
13
|
+
* The ProseMirror content to insert.
|
|
14
|
+
*/
|
|
15
|
+
value: Content,
|
|
16
|
+
/**
|
|
17
|
+
* Optional options
|
|
18
|
+
*/
|
|
19
|
+
options?: {
|
|
20
|
+
/**
|
|
21
|
+
* Options for parsing the content.
|
|
22
|
+
*/
|
|
10
23
|
parseOptions?: ParseOptions;
|
|
24
|
+
/**
|
|
25
|
+
* Whether to update the selection after inserting the content.
|
|
26
|
+
*/
|
|
11
27
|
updateSelection?: boolean;
|
|
12
28
|
applyInputRules?: boolean;
|
|
13
29
|
applyPasteRules?: boolean;
|
|
@@ -5,9 +5,28 @@ declare module '@tiptap/core' {
|
|
|
5
5
|
insertContentAt: {
|
|
6
6
|
/**
|
|
7
7
|
* Insert a node or string of HTML at a specific position.
|
|
8
|
+
* @example editor.commands.insertContentAt(0, '<h1>Example</h1>')
|
|
8
9
|
*/
|
|
9
|
-
insertContentAt: (
|
|
10
|
+
insertContentAt: (
|
|
11
|
+
/**
|
|
12
|
+
* The position to insert the content at.
|
|
13
|
+
*/
|
|
14
|
+
position: number | Range,
|
|
15
|
+
/**
|
|
16
|
+
* The ProseMirror content to insert.
|
|
17
|
+
*/
|
|
18
|
+
value: Content,
|
|
19
|
+
/**
|
|
20
|
+
* Optional options
|
|
21
|
+
*/
|
|
22
|
+
options?: {
|
|
23
|
+
/**
|
|
24
|
+
* Options for parsing the content.
|
|
25
|
+
*/
|
|
10
26
|
parseOptions?: ParseOptions;
|
|
27
|
+
/**
|
|
28
|
+
* Whether to update the selection after inserting the content.
|
|
29
|
+
*/
|
|
11
30
|
updateSelection?: boolean;
|
|
12
31
|
applyInputRules?: boolean;
|
|
13
32
|
applyPasteRules?: boolean;
|
|
@@ -3,25 +3,33 @@ declare module '@tiptap/core' {
|
|
|
3
3
|
interface Commands<ReturnType> {
|
|
4
4
|
joinUp: {
|
|
5
5
|
/**
|
|
6
|
-
* Join
|
|
6
|
+
* Join the selected block or, if there is a text selection, the closest ancestor block of the selection that can be joined, with the sibling above it.
|
|
7
|
+
* @example editor.commands.joinUp()
|
|
7
8
|
*/
|
|
8
9
|
joinUp: () => ReturnType;
|
|
9
10
|
};
|
|
10
11
|
joinDown: {
|
|
11
12
|
/**
|
|
12
|
-
* Join
|
|
13
|
+
* Join the selected block, or the closest ancestor of the selection that can be joined, with the sibling after it.
|
|
14
|
+
* @example editor.commands.joinDown()
|
|
13
15
|
*/
|
|
14
16
|
joinDown: () => ReturnType;
|
|
15
17
|
};
|
|
16
18
|
joinBackward: {
|
|
17
19
|
/**
|
|
18
|
-
*
|
|
20
|
+
* If the selection is empty and at the start of a textblock, try to reduce the distance between that block and the one before it—if there's a block directly before it that can be joined, join them.
|
|
21
|
+
* If not, try to move the selected block closer to the next one in the document structure by lifting it out of its
|
|
22
|
+
* parent or moving it into a parent of the previous block. Will use the view for accurate (bidi-aware) start-of-textblock detection if given.
|
|
23
|
+
* @example editor.commands.joinBackward()
|
|
19
24
|
*/
|
|
20
25
|
joinBackward: () => ReturnType;
|
|
21
26
|
};
|
|
22
27
|
joinForward: {
|
|
23
28
|
/**
|
|
24
|
-
*
|
|
29
|
+
* If the selection is empty and the cursor is at the end of a textblock, try to reduce or remove the boundary between that block and the one after it,
|
|
30
|
+
* either by joining them or by moving the other block closer to this one in the tree structure.
|
|
31
|
+
* Will use the view for accurate start-of-textblock detection if given.
|
|
32
|
+
* @example editor.commands.joinForward()
|
|
25
33
|
*/
|
|
26
34
|
joinForward: () => ReturnType;
|
|
27
35
|
};
|
|
@@ -4,7 +4,11 @@ declare module '@tiptap/core' {
|
|
|
4
4
|
interface Commands<ReturnType> {
|
|
5
5
|
lift: {
|
|
6
6
|
/**
|
|
7
|
-
* Removes an existing wrap
|
|
7
|
+
* Removes an existing wrap if possible lifting the node out of it
|
|
8
|
+
* @param typeOrName The type or name of the node.
|
|
9
|
+
* @param attributes The attributes of the node.
|
|
10
|
+
* @example editor.commands.lift('paragraph')
|
|
11
|
+
* @example editor.commands.lift('heading', { level: 1 })
|
|
8
12
|
*/
|
|
9
13
|
lift: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType;
|
|
10
14
|
};
|
|
@@ -3,7 +3,8 @@ declare module '@tiptap/core' {
|
|
|
3
3
|
interface Commands<ReturnType> {
|
|
4
4
|
liftEmptyBlock: {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* If the cursor is in an empty textblock that can be lifted, lift the block.
|
|
7
|
+
* @example editor.commands.liftEmptyBlock()
|
|
7
8
|
*/
|
|
8
9
|
liftEmptyBlock: () => ReturnType;
|
|
9
10
|
};
|
|
@@ -4,7 +4,9 @@ declare module '@tiptap/core' {
|
|
|
4
4
|
interface Commands<ReturnType> {
|
|
5
5
|
liftListItem: {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Create a command to lift the list item around the selection up into a wrapping list.
|
|
8
|
+
* @param typeOrName The type or name of the node.
|
|
9
|
+
* @example editor.commands.liftListItem('listItem')
|
|
8
10
|
*/
|
|
9
11
|
liftListItem: (typeOrName: string | NodeType) => ReturnType;
|
|
10
12
|
};
|
|
@@ -5,6 +5,9 @@ declare module '@tiptap/core' {
|
|
|
5
5
|
resetAttributes: {
|
|
6
6
|
/**
|
|
7
7
|
* Resets some node attributes to the default value.
|
|
8
|
+
* @param typeOrName The type or name of the node.
|
|
9
|
+
* @param attributes The attributes of the node to reset.
|
|
10
|
+
* @example editor.commands.resetAttributes('heading', 'level')
|
|
8
11
|
*/
|
|
9
12
|
resetAttributes: (typeOrName: string | NodeType | MarkType, attributes: string | string[]) => ReturnType;
|
|
10
13
|
};
|
|
@@ -5,8 +5,26 @@ declare module '@tiptap/core' {
|
|
|
5
5
|
setContent: {
|
|
6
6
|
/**
|
|
7
7
|
* Replace the whole document with new content.
|
|
8
|
+
* @param content The new content.
|
|
9
|
+
* @param emitUpdate Whether to emit an update event.
|
|
10
|
+
* @param parseOptions Options for parsing the content.
|
|
11
|
+
* @example editor.commands.setContent('<p>Example text</p>')
|
|
8
12
|
*/
|
|
9
|
-
setContent: (
|
|
13
|
+
setContent: (
|
|
14
|
+
/**
|
|
15
|
+
* The new content.
|
|
16
|
+
*/
|
|
17
|
+
content: Content,
|
|
18
|
+
/**
|
|
19
|
+
* Whether to emit an update event.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
emitUpdate?: boolean,
|
|
23
|
+
/**
|
|
24
|
+
* Options for parsing the content.
|
|
25
|
+
* @default {}
|
|
26
|
+
*/
|
|
27
|
+
parseOptions?: ParseOptions) => ReturnType;
|
|
10
28
|
};
|
|
11
29
|
}
|
|
12
30
|
}
|
|
@@ -5,6 +5,8 @@ declare module '@tiptap/core' {
|
|
|
5
5
|
setMark: {
|
|
6
6
|
/**
|
|
7
7
|
* Add a mark with new attributes.
|
|
8
|
+
* @param typeOrName The mark type or name.
|
|
9
|
+
* @example editor.commands.setMark('bold', { level: 1 })
|
|
8
10
|
*/
|
|
9
11
|
setMark: (typeOrName: string | MarkType, attributes?: Record<string, any>) => ReturnType;
|
|
10
12
|
};
|
|
@@ -4,6 +4,9 @@ declare module '@tiptap/core' {
|
|
|
4
4
|
setMeta: {
|
|
5
5
|
/**
|
|
6
6
|
* Store a metadata property in the current transaction.
|
|
7
|
+
* @param key The key of the metadata property.
|
|
8
|
+
* @param value The value to store.
|
|
9
|
+
* @example editor.commands.setMeta('foo', 'bar')
|
|
7
10
|
*/
|
|
8
11
|
setMeta: (key: string, value: any) => ReturnType;
|
|
9
12
|
};
|
|
@@ -5,6 +5,9 @@ declare module '@tiptap/core' {
|
|
|
5
5
|
setNode: {
|
|
6
6
|
/**
|
|
7
7
|
* Replace a given range with a node.
|
|
8
|
+
* @param typeOrName The type or name of the node
|
|
9
|
+
* @param attributes The attributes of the node
|
|
10
|
+
* @example editor.commands.setNode('paragraph')
|
|
8
11
|
*/
|
|
9
12
|
setNode: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType;
|
|
10
13
|
};
|
|
@@ -5,6 +5,8 @@ declare module '@tiptap/core' {
|
|
|
5
5
|
sinkListItem: {
|
|
6
6
|
/**
|
|
7
7
|
* Sink the list item down into an inner list.
|
|
8
|
+
* @param typeOrName The type or name of the node.
|
|
9
|
+
* @example editor.commands.sinkListItem('listItem')
|
|
8
10
|
*/
|
|
9
11
|
sinkListItem: (typeOrName: string | NodeType) => ReturnType;
|
|
10
12
|
};
|
|
@@ -4,6 +4,9 @@ declare module '@tiptap/core' {
|
|
|
4
4
|
splitBlock: {
|
|
5
5
|
/**
|
|
6
6
|
* Forks a new node from an existing node.
|
|
7
|
+
* @param options.keepMarks Keep marks from the previous node.
|
|
8
|
+
* @example editor.commands.splitBlock()
|
|
9
|
+
* @example editor.commands.splitBlock({ keepMarks: true })
|
|
7
10
|
*/
|
|
8
11
|
splitBlock: (options?: {
|
|
9
12
|
keepMarks?: boolean;
|
|
@@ -5,6 +5,8 @@ declare module '@tiptap/core' {
|
|
|
5
5
|
splitListItem: {
|
|
6
6
|
/**
|
|
7
7
|
* Splits one list item into two list items.
|
|
8
|
+
* @param typeOrName The type or name of the node.
|
|
9
|
+
* @example editor.commands.splitListItem('listItem')
|
|
8
10
|
*/
|
|
9
11
|
splitListItem: (typeOrName: string | NodeType) => ReturnType;
|
|
10
12
|
};
|
|
@@ -5,6 +5,11 @@ declare module '@tiptap/core' {
|
|
|
5
5
|
toggleList: {
|
|
6
6
|
/**
|
|
7
7
|
* Toggle between different list types.
|
|
8
|
+
* @param listTypeOrName The type or name of the list.
|
|
9
|
+
* @param itemTypeOrName The type or name of the list item.
|
|
10
|
+
* @param keepMarks Keep marks when toggling.
|
|
11
|
+
* @param attributes Attributes for the new list.
|
|
12
|
+
* @example editor.commands.toggleList('bulletList', 'listItem')
|
|
8
13
|
*/
|
|
9
14
|
toggleList: (listTypeOrName: string | NodeType, itemTypeOrName: string | NodeType, keepMarks?: boolean, attributes?: Record<string, any>) => ReturnType;
|
|
10
15
|
};
|
|
@@ -5,8 +5,20 @@ declare module '@tiptap/core' {
|
|
|
5
5
|
toggleMark: {
|
|
6
6
|
/**
|
|
7
7
|
* Toggle a mark on and off.
|
|
8
|
+
* @param typeOrName The mark type or name.
|
|
9
|
+
* @param attributes The attributes of the mark.
|
|
10
|
+
* @param options.extendEmptyMarkRange Removes the mark even across the current selection. Defaults to `false`.
|
|
11
|
+
* @example editor.commands.toggleMark('bold')
|
|
8
12
|
*/
|
|
9
|
-
toggleMark: (
|
|
13
|
+
toggleMark: (
|
|
14
|
+
/**
|
|
15
|
+
* The mark type or name.
|
|
16
|
+
*/
|
|
17
|
+
typeOrName: string | MarkType,
|
|
18
|
+
/**
|
|
19
|
+
* The attributes of the mark.
|
|
20
|
+
*/
|
|
21
|
+
attributes?: Record<string, any>, options?: {
|
|
10
22
|
/**
|
|
11
23
|
* Removes the mark even across the current selection. Defaults to `false`.
|
|
12
24
|
*/
|
|
@@ -5,6 +5,10 @@ declare module '@tiptap/core' {
|
|
|
5
5
|
toggleNode: {
|
|
6
6
|
/**
|
|
7
7
|
* Toggle a node with another node.
|
|
8
|
+
* @param typeOrName The type or name of the node.
|
|
9
|
+
* @param toggleTypeOrName The type or name of the node to toggle.
|
|
10
|
+
* @param attributes The attributes of the node.
|
|
11
|
+
* @example editor.commands.toggleNode('heading', 'paragraph')
|
|
8
12
|
*/
|
|
9
13
|
toggleNode: (typeOrName: string | NodeType, toggleTypeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType;
|
|
10
14
|
};
|
|
@@ -5,6 +5,9 @@ declare module '@tiptap/core' {
|
|
|
5
5
|
toggleWrap: {
|
|
6
6
|
/**
|
|
7
7
|
* Wraps nodes in another node, or removes an existing wrap.
|
|
8
|
+
* @param typeOrName The type or name of the node.
|
|
9
|
+
* @param attributes The attributes of the node.
|
|
10
|
+
* @example editor.commands.toggleWrap('blockquote')
|
|
8
11
|
*/
|
|
9
12
|
toggleWrap: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType;
|
|
10
13
|
};
|
|
@@ -5,8 +5,15 @@ declare module '@tiptap/core' {
|
|
|
5
5
|
unsetMark: {
|
|
6
6
|
/**
|
|
7
7
|
* Remove all marks in the current selection.
|
|
8
|
+
* @param typeOrName The mark type or name.
|
|
9
|
+
* @param options.extendEmptyMarkRange Removes the mark even across the current selection. Defaults to `false`.
|
|
10
|
+
* @example editor.commands.unsetMark('bold')
|
|
8
11
|
*/
|
|
9
|
-
unsetMark: (
|
|
12
|
+
unsetMark: (
|
|
13
|
+
/**
|
|
14
|
+
* The mark type or name.
|
|
15
|
+
*/
|
|
16
|
+
typeOrName: string | MarkType, options?: {
|
|
10
17
|
/**
|
|
11
18
|
* Removes the mark even across the current selection. Defaults to `false`.
|
|
12
19
|
*/
|
|
@@ -5,8 +5,19 @@ declare module '@tiptap/core' {
|
|
|
5
5
|
updateAttributes: {
|
|
6
6
|
/**
|
|
7
7
|
* Update attributes of a node or mark.
|
|
8
|
+
* @param typeOrName The type or name of the node or mark.
|
|
9
|
+
* @param attributes The attributes of the node or mark.
|
|
10
|
+
* @example editor.commands.updateAttributes('mention', { userId: "2" })
|
|
8
11
|
*/
|
|
9
|
-
updateAttributes: (
|
|
12
|
+
updateAttributes: (
|
|
13
|
+
/**
|
|
14
|
+
* The type or name of the node or mark.
|
|
15
|
+
*/
|
|
16
|
+
typeOrName: string | NodeType | MarkType,
|
|
17
|
+
/**
|
|
18
|
+
* The attributes of the node or mark.
|
|
19
|
+
*/
|
|
20
|
+
attributes: Record<string, any>) => ReturnType;
|
|
10
21
|
};
|
|
11
22
|
}
|
|
12
23
|
}
|
|
@@ -5,6 +5,9 @@ declare module '@tiptap/core' {
|
|
|
5
5
|
wrapIn: {
|
|
6
6
|
/**
|
|
7
7
|
* Wraps nodes in another node.
|
|
8
|
+
* @param typeOrName The type or name of the node.
|
|
9
|
+
* @param attributes The attributes of the node.
|
|
10
|
+
* @example editor.commands.wrapIn('blockquote')
|
|
8
11
|
*/
|
|
9
12
|
wrapIn: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType;
|
|
10
13
|
};
|
|
@@ -5,6 +5,9 @@ declare module '@tiptap/core' {
|
|
|
5
5
|
wrapInList: {
|
|
6
6
|
/**
|
|
7
7
|
* Wrap a node in a list.
|
|
8
|
+
* @param typeOrName The type or name of the node.
|
|
9
|
+
* @param attributes The attributes of the node.
|
|
10
|
+
* @example editor.commands.wrapInList('bulletList')
|
|
8
11
|
*/
|
|
9
12
|
wrapInList: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType;
|
|
10
13
|
};
|
|
@@ -3,5 +3,8 @@ import { Transaction } from '@tiptap/pm/state';
|
|
|
3
3
|
import { Transform } from '@tiptap/pm/transform';
|
|
4
4
|
/**
|
|
5
5
|
* Returns a new `Transform` based on all steps of the passed transactions.
|
|
6
|
+
* @param oldDoc The Prosemirror node to start from
|
|
7
|
+
* @param transactions The transactions to combine
|
|
8
|
+
* @returns A new `Transform` with all steps of the passed transactions
|
|
6
9
|
*/
|
|
7
10
|
export declare function combineTransactionSteps(oldDoc: ProseMirrorNode, transactions: Transaction[]): Transform;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { EditorState, Transaction } from '@tiptap/pm/state';
|
|
2
|
+
/**
|
|
3
|
+
* Takes a Transaction & Editor State and turns it into a chainable state object
|
|
4
|
+
* @param config The transaction and state to create the chainable state from
|
|
5
|
+
* @returns A chainable Editor state object
|
|
6
|
+
*/
|
|
2
7
|
export declare function createChainableState(config: {
|
|
3
8
|
transaction: Transaction;
|
|
4
9
|
state: EditorState;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import { Node as ProseMirrorNode, ParseOptions, Schema } from '@tiptap/pm/model';
|
|
2
2
|
import { Content } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create a new Prosemirror document node from content.
|
|
5
|
+
* @param content The JSON or HTML content to create the document from
|
|
6
|
+
* @param schema The Prosemirror schema to use for the document
|
|
7
|
+
* @param parseOptions Options for the parser
|
|
8
|
+
* @returns The created Prosemirror document node
|
|
9
|
+
*/
|
|
3
10
|
export declare function createDocument(content: Content, schema: Schema, parseOptions?: ParseOptions): ProseMirrorNode;
|
|
@@ -4,4 +4,11 @@ export declare type CreateNodeFromContentOptions = {
|
|
|
4
4
|
slice?: boolean;
|
|
5
5
|
parseOptions?: ParseOptions;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Takes a JSON or HTML content and creates a Prosemirror node or fragment from it.
|
|
9
|
+
* @param content The JSON or HTML content to create the node from
|
|
10
|
+
* @param schema The Prosemirror schema to use for the node
|
|
11
|
+
* @param options Options for the parser
|
|
12
|
+
* @returns The created Prosemirror node or fragment
|
|
13
|
+
*/
|
|
7
14
|
export declare function createNodeFromContent(content: Content, schema: Schema, options?: CreateNodeFromContentOptions): ProseMirrorNode | Fragment;
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import { ContentMatch, NodeType } from '@tiptap/pm/model';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the default block type at a given match
|
|
4
|
+
* @param match The content match to get the default block type from
|
|
5
|
+
* @returns The default block type or null
|
|
6
|
+
*/
|
|
2
7
|
export declare function defaultBlockAt(match: ContentMatch): NodeType | null;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { Node as ProseMirrorNode } from '@tiptap/pm/model';
|
|
2
2
|
import { NodeWithPos, Predicate } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Find children inside a Prosemirror node that match a predicate.
|
|
5
|
+
* @param node The Prosemirror node to search in
|
|
6
|
+
* @param predicate The predicate to match
|
|
7
|
+
* @returns An array of nodes with their positions
|
|
8
|
+
*/
|
|
3
9
|
export declare function findChildren(node: ProseMirrorNode, predicate: Predicate): NodeWithPos[];
|
|
@@ -2,5 +2,9 @@ import { Node as ProseMirrorNode } from '@tiptap/pm/model';
|
|
|
2
2
|
import { NodeWithPos, Predicate, Range } from '../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Same as `findChildren` but searches only within a `range`.
|
|
5
|
+
* @param node The Prosemirror node to search in
|
|
6
|
+
* @param range The range to search in
|
|
7
|
+
* @param predicate The predicate to match
|
|
8
|
+
* @returns An array of nodes with their positions
|
|
5
9
|
*/
|
|
6
10
|
export declare function findChildrenInRange(node: ProseMirrorNode, range: Range, predicate: Predicate): NodeWithPos[];
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { Selection } from '@tiptap/pm/state';
|
|
2
2
|
import { Predicate } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Finds the closest parent node to the current selection that matches a predicate.
|
|
5
|
+
* @param predicate The predicate to match
|
|
6
|
+
* @returns A command that finds the closest parent node to the current selection that matches the predicate
|
|
7
|
+
* @example ```js
|
|
8
|
+
* findParentNode(node => node.type.name === 'paragraph')
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
3
11
|
export declare function findParentNode(predicate: Predicate): (selection: Selection) => {
|
|
4
12
|
pos: number;
|
|
5
13
|
start: number;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { Node as ProseMirrorNode, ResolvedPos } from '@tiptap/pm/model';
|
|
2
2
|
import { Predicate } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Finds the closest parent node to a resolved position that matches a predicate.
|
|
5
|
+
* @param $pos The resolved position to search from
|
|
6
|
+
* @param predicate The predicate to match
|
|
7
|
+
* @returns The closest parent node to the resolved position that matches the predicate
|
|
8
|
+
* @example ```js
|
|
9
|
+
* findParentNodeClosestToPos($from, node => node.type.name === 'paragraph')
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
3
12
|
export declare function findParentNodeClosestToPos($pos: ResolvedPos, predicate: Predicate): {
|
|
4
13
|
pos: number;
|
|
5
14
|
start: number;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { Extensions, JSONContent } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generate HTML from a JSONContent
|
|
4
|
+
* @param doc The JSONContent to generate HTML from
|
|
5
|
+
* @param extensions The extensions to use for the schema
|
|
6
|
+
* @returns The generated HTML
|
|
7
|
+
*/
|
|
2
8
|
export declare function generateHTML(doc: JSONContent, extensions: Extensions): string;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { Extensions } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generate JSONContent from HTML
|
|
4
|
+
* @param html The HTML to generate JSONContent from
|
|
5
|
+
* @param extensions The extensions to use for the schema
|
|
6
|
+
* @returns The generated JSONContent
|
|
7
|
+
*/
|
|
2
8
|
export declare function generateJSON(html: string, extensions: Extensions): Record<string, any>;
|