@tiptap/core 3.0.0 → 3.0.1
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/LICENSE.md +21 -0
- package/README.md +5 -1
- package/dist/index.cjs +5169 -4654
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3356 -0
- package/dist/index.d.ts +3356 -0
- package/dist/index.js +5051 -4561
- package/dist/index.js.map +1 -1
- package/dist/jsx-runtime/jsx-runtime.cjs +56 -0
- package/dist/jsx-runtime/jsx-runtime.cjs.map +1 -0
- package/dist/jsx-runtime/jsx-runtime.d.cts +22 -0
- package/dist/jsx-runtime/jsx-runtime.d.ts +22 -0
- package/dist/jsx-runtime/jsx-runtime.js +26 -0
- package/dist/jsx-runtime/jsx-runtime.js.map +1 -0
- package/jsx-dev-runtime/index.cjs +1 -0
- package/jsx-dev-runtime/index.d.cts +1 -0
- package/jsx-dev-runtime/index.d.ts +1 -0
- package/jsx-dev-runtime/index.js +1 -0
- package/jsx-runtime/index.cjs +1 -0
- package/jsx-runtime/index.d.cts +1 -0
- package/jsx-runtime/index.d.ts +1 -0
- package/jsx-runtime/index.js +1 -0
- package/package.json +30 -10
- package/src/CommandManager.ts +4 -11
- package/src/Editor.ts +273 -100
- package/src/EventEmitter.ts +16 -10
- package/src/Extendable.ts +484 -0
- package/src/Extension.ts +29 -493
- package/src/ExtensionManager.ts +100 -143
- package/src/InputRule.ts +28 -24
- package/src/Mark.ts +157 -624
- package/src/MarkView.ts +122 -0
- package/src/Node.ts +343 -807
- package/src/NodePos.ts +18 -9
- package/src/NodeView.ts +58 -35
- package/src/PasteRule.ts +68 -24
- package/src/Tracker.ts +8 -10
- package/src/commands/blur.ts +15 -13
- package/src/commands/clearContent.ts +13 -6
- package/src/commands/clearNodes.ts +33 -31
- package/src/commands/command.ts +2 -2
- package/src/commands/createParagraphNear.ts +6 -4
- package/src/commands/cut.ts +13 -11
- package/src/commands/deleteCurrentNode.ts +24 -22
- package/src/commands/deleteNode.ts +20 -18
- package/src/commands/deleteRange.ts +11 -9
- package/src/commands/deleteSelection.ts +6 -4
- package/src/commands/enter.ts +7 -5
- package/src/commands/exitCode.ts +6 -4
- package/src/commands/extendMarkRange.ts +16 -14
- package/src/commands/first.ts +3 -5
- package/src/commands/focus.ts +51 -53
- package/src/commands/forEach.ts +3 -3
- package/src/commands/insertContent.ts +8 -10
- package/src/commands/insertContentAt.ts +131 -76
- package/src/commands/join.ts +21 -13
- package/src/commands/joinItemBackward.ts +17 -19
- package/src/commands/joinItemForward.ts +17 -19
- package/src/commands/joinTextblockBackward.ts +6 -4
- package/src/commands/joinTextblockForward.ts +6 -4
- package/src/commands/keyboardShortcut.ts +30 -35
- package/src/commands/lift.ts +12 -10
- package/src/commands/liftEmptyBlock.ts +7 -5
- package/src/commands/liftListItem.ts +8 -6
- package/src/commands/newlineInCode.ts +6 -4
- package/src/commands/resetAttributes.ts +38 -43
- package/src/commands/scrollIntoView.ts +10 -8
- package/src/commands/selectAll.ts +15 -8
- package/src/commands/selectNodeBackward.ts +6 -4
- package/src/commands/selectNodeForward.ts +6 -4
- package/src/commands/selectParentNode.ts +6 -4
- package/src/commands/selectTextblockEnd.ts +6 -4
- package/src/commands/selectTextblockStart.ts +6 -4
- package/src/commands/setContent.ts +37 -40
- package/src/commands/setMark.ts +58 -60
- package/src/commands/setMeta.ts +10 -6
- package/src/commands/setNode.ts +36 -27
- package/src/commands/setNodeSelection.ts +12 -10
- package/src/commands/setTextSelection.ts +16 -14
- package/src/commands/sinkListItem.ts +8 -6
- package/src/commands/splitBlock.ts +60 -68
- package/src/commands/splitListItem.ts +99 -101
- package/src/commands/toggleList.ts +76 -74
- package/src/commands/toggleMark.ts +13 -11
- package/src/commands/toggleNode.ts +22 -11
- package/src/commands/toggleWrap.ts +12 -10
- package/src/commands/undoInputRule.ts +32 -30
- package/src/commands/unsetAllMarks.ts +17 -15
- package/src/commands/unsetMark.ts +29 -27
- package/src/commands/updateAttributes.ts +97 -45
- package/src/commands/wrapIn.ts +8 -6
- package/src/commands/wrapInList.ts +8 -6
- package/src/extensions/clipboardTextSerializer.ts +2 -4
- package/src/extensions/delete.ts +89 -0
- package/src/extensions/drop.ts +26 -0
- package/src/extensions/focusEvents.ts +5 -7
- package/src/extensions/index.ts +4 -1
- package/src/extensions/keymap.ts +63 -52
- package/src/extensions/paste.ts +25 -0
- package/src/extensions/tabindex.ts +1 -1
- package/src/helpers/combineTransactionSteps.ts +3 -6
- package/src/helpers/createChainableState.ts +2 -5
- package/src/helpers/createDocument.ts +3 -3
- package/src/helpers/createNodeFromContent.ts +37 -25
- package/src/helpers/defaultBlockAt.ts +1 -1
- package/src/helpers/findChildren.ts +2 -2
- package/src/helpers/findChildrenInRange.ts +3 -7
- package/src/helpers/findParentNode.ts +5 -3
- package/src/helpers/findParentNodeClosestToPos.ts +2 -2
- package/src/helpers/flattenExtensions.ts +30 -0
- package/src/helpers/generateHTML.ts +1 -1
- package/src/helpers/generateJSON.ts +1 -1
- package/src/helpers/generateText.ts +1 -1
- package/src/helpers/getAttributes.ts +3 -6
- package/src/helpers/getAttributesFromExtensions.ts +29 -38
- package/src/helpers/getChangedRanges.ts +15 -13
- package/src/helpers/getDebugJSON.ts +2 -2
- package/src/helpers/getExtensionField.ts +12 -12
- package/src/helpers/getHTMLFromFragment.ts +2 -1
- package/src/helpers/getMarkAttributes.ts +3 -6
- package/src/helpers/getMarkRange.ts +36 -19
- package/src/helpers/getMarkType.ts +2 -4
- package/src/helpers/getMarksBetween.ts +3 -3
- package/src/helpers/getNodeAtPosition.ts +2 -2
- package/src/helpers/getNodeAttributes.ts +3 -6
- package/src/helpers/getNodeType.ts +2 -4
- package/src/helpers/getRenderedAttributes.ts +3 -2
- package/src/helpers/getSchema.ts +5 -5
- package/src/helpers/getSchemaByResolvedExtensions.ts +49 -79
- package/src/helpers/getSchemaTypeByName.ts +1 -1
- package/src/helpers/getSchemaTypeNameByName.ts +1 -1
- package/src/helpers/getSplittedAttributes.ts +5 -5
- package/src/helpers/getText.ts +2 -2
- package/src/helpers/getTextBetween.ts +2 -2
- package/src/helpers/getTextContentFromNodes.ts +9 -12
- package/src/helpers/getTextSerializersFromSchema.ts +2 -2
- package/src/helpers/index.ts +4 -0
- package/src/helpers/injectExtensionAttributesToParseRule.ts +3 -3
- package/src/helpers/isActive.ts +2 -6
- package/src/helpers/isAtEndOfNode.ts +1 -1
- package/src/helpers/isAtStartOfNode.ts +1 -1
- package/src/helpers/isExtensionRulesEnabled.ts +2 -4
- package/src/helpers/isList.ts +2 -2
- package/src/helpers/isMarkActive.ts +3 -3
- package/src/helpers/isNodeActive.ts +3 -3
- package/src/helpers/isNodeEmpty.ts +56 -5
- package/src/helpers/posToDOMRect.ts +1 -1
- package/src/helpers/resolveExtensions.ts +25 -0
- package/src/helpers/resolveFocusPosition.ts +5 -16
- package/src/helpers/rewriteUnknownContent.ts +149 -0
- package/src/helpers/selectionToInsertionEnd.ts +2 -1
- package/src/helpers/sortExtensions.ts +26 -0
- package/src/helpers/splitExtensions.ts +4 -4
- package/src/index.ts +3 -7
- package/src/inputRules/markInputRule.ts +6 -9
- package/src/inputRules/nodeInputRule.ts +7 -13
- package/src/inputRules/textInputRule.ts +4 -6
- package/src/inputRules/textblockTypeInputRule.ts +7 -12
- package/src/inputRules/wrappingInputRule.ts +19 -24
- package/src/jsx-runtime.ts +64 -0
- package/src/pasteRules/markPasteRule.ts +6 -7
- package/src/pasteRules/nodePasteRule.ts +15 -11
- package/src/pasteRules/textPasteRule.ts +4 -6
- package/src/style.ts +2 -6
- package/src/types.ts +513 -58
- package/src/utilities/callOrReturn.ts +1 -1
- package/src/utilities/canInsertNode.ts +30 -0
- package/src/utilities/createStyleTag.ts +3 -1
- package/src/utilities/deleteProps.ts +7 -11
- package/src/utilities/elementFromString.ts +3 -0
- package/src/utilities/findDuplicates.ts +5 -2
- package/src/utilities/index.ts +2 -0
- package/src/utilities/isFunction.ts +1 -0
- package/src/utilities/isMacOS.ts +1 -3
- package/src/utilities/isiOS.ts +5 -10
- package/src/utilities/mergeAttributes.ts +32 -5
- package/src/utilities/removeDuplicates.ts +1 -3
- package/dist/index.umd.js +0 -5098
- package/dist/index.umd.js.map +0 -1
- package/dist/packages/core/src/CommandManager.d.ts +0 -20
- package/dist/packages/core/src/Editor.d.ts +0 -161
- package/dist/packages/core/src/EventEmitter.d.ts +0 -11
- package/dist/packages/core/src/Extension.d.ts +0 -343
- package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
- package/dist/packages/core/src/InputRule.d.ts +0 -42
- package/dist/packages/core/src/Mark.d.ts +0 -451
- package/dist/packages/core/src/Node.d.ts +0 -611
- package/dist/packages/core/src/NodePos.d.ts +0 -44
- package/dist/packages/core/src/NodeView.d.ts +0 -31
- package/dist/packages/core/src/PasteRule.d.ts +0 -50
- package/dist/packages/core/src/Tracker.d.ts +0 -11
- package/dist/packages/core/src/commands/blur.d.ts +0 -13
- package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
- package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
- package/dist/packages/core/src/commands/command.d.ts +0 -18
- package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
- package/dist/packages/core/src/commands/cut.d.ts +0 -20
- package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
- package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
- package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
- package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
- package/dist/packages/core/src/commands/enter.d.ts +0 -13
- package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
- package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
- package/dist/packages/core/src/commands/first.d.ts +0 -14
- package/dist/packages/core/src/commands/focus.d.ts +0 -27
- package/dist/packages/core/src/commands/forEach.d.ts +0 -14
- package/dist/packages/core/src/commands/index.d.ts +0 -55
- package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
- package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
- package/dist/packages/core/src/commands/join.d.ts +0 -41
- package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
- package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
- package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
- package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
- package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
- package/dist/packages/core/src/commands/lift.d.ts +0 -17
- package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
- package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
- package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
- package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
- package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
- package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
- package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
- package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
- package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
- package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
- package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
- package/dist/packages/core/src/commands/setContent.d.ts +0 -40
- package/dist/packages/core/src/commands/setMark.d.ts +0 -15
- package/dist/packages/core/src/commands/setMeta.d.ts +0 -15
- package/dist/packages/core/src/commands/setNode.d.ts +0 -16
- package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
- package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
- package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
- package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
- package/dist/packages/core/src/commands/splitListItem.d.ts +0 -15
- package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
- package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
- package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
- package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
- package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
- package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
- package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
- package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
- package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
- package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
- package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
- package/dist/packages/core/src/extensions/commands.d.ts +0 -3
- package/dist/packages/core/src/extensions/editable.d.ts +0 -2
- package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
- package/dist/packages/core/src/extensions/index.d.ts +0 -6
- package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
- package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
- package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
- package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
- package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
- package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
- package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
- package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
- package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
- package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
- package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
- package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
- package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
- package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
- package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
- package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
- package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
- package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
- package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
- package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
- package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
- package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
- package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
- package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
- package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
- package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
- package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
- package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
- package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
- package/dist/packages/core/src/helpers/getText.d.ts +0 -15
- package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
- package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
- package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
- package/dist/packages/core/src/helpers/index.d.ts +0 -50
- package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
- package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
- package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
- package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
- package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
- package/dist/packages/core/src/helpers/isList.d.ts +0 -2
- package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
- package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
- package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -2
- package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
- package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
- package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
- package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
- package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
- package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
- package/dist/packages/core/src/index.d.ts +0 -24
- package/dist/packages/core/src/inputRules/index.d.ts +0 -5
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
- package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
- package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
- package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
- package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
- package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -13
- package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
- package/dist/packages/core/src/style.d.ts +0 -1
- package/dist/packages/core/src/types.d.ts +0 -255
- package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
- package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
- package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
- package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
- package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
- package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
- package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
- package/dist/packages/core/src/utilities/index.d.ts +0 -20
- package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
- package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
- package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
- package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
- package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
- package/dist/packages/core/src/utilities/isString.d.ts +0 -1
- package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
- package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
- package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
- package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
- package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
- package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Node as ProseMirrorNode, ParseOptions } from '@tiptap/pm/model'
|
|
2
|
+
import { Fragment } from '@tiptap/pm/model'
|
|
2
3
|
|
|
3
4
|
import { createNodeFromContent } from '../helpers/createNodeFromContent.js'
|
|
4
5
|
import { selectionToInsertionEnd } from '../helpers/selectionToInsertionEnd.js'
|
|
5
|
-
import { Content, Range, RawCommands } from '../types.js'
|
|
6
|
+
import type { Content, Range, RawCommands } from '../types.js'
|
|
6
7
|
|
|
7
8
|
declare module '@tiptap/core' {
|
|
8
9
|
interface Commands<ReturnType> {
|
|
@@ -20,7 +21,7 @@ declare module '@tiptap/core' {
|
|
|
20
21
|
/**
|
|
21
22
|
* The ProseMirror content to insert.
|
|
22
23
|
*/
|
|
23
|
-
value: Content,
|
|
24
|
+
value: Content | ProseMirrorNode | Fragment,
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* Optional options
|
|
@@ -60,95 +61,149 @@ const isFragment = (nodeOrFragment: ProseMirrorNode | Fragment): nodeOrFragment
|
|
|
60
61
|
return !('type' in nodeOrFragment)
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
export const insertContentAt: RawCommands['insertContentAt'] =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
export const insertContentAt: RawCommands['insertContentAt'] =
|
|
65
|
+
(position, value, options) =>
|
|
66
|
+
({ tr, dispatch, editor }) => {
|
|
67
|
+
if (dispatch) {
|
|
68
|
+
options = {
|
|
69
|
+
parseOptions: editor.options.parseOptions,
|
|
70
|
+
updateSelection: true,
|
|
71
|
+
applyInputRules: false,
|
|
72
|
+
applyPasteRules: false,
|
|
73
|
+
...options,
|
|
74
|
+
}
|
|
72
75
|
|
|
73
|
-
|
|
76
|
+
let content: Fragment | ProseMirrorNode
|
|
77
|
+
const { selection } = editor.state
|
|
78
|
+
|
|
79
|
+
const emitContentError = (error: Error) => {
|
|
80
|
+
editor.emit('contentError', {
|
|
81
|
+
editor,
|
|
82
|
+
error,
|
|
83
|
+
disableCollaboration: () => {
|
|
84
|
+
if (
|
|
85
|
+
'collaboration' in editor.storage &&
|
|
86
|
+
typeof editor.storage.collaboration === 'object' &&
|
|
87
|
+
editor.storage.collaboration
|
|
88
|
+
) {
|
|
89
|
+
;(editor.storage.collaboration as any).isDisabled = true
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
})
|
|
93
|
+
}
|
|
74
94
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
parseOptions
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
95
|
+
const parseOptions: ParseOptions = {
|
|
96
|
+
preserveWhitespace: 'full',
|
|
97
|
+
...options.parseOptions,
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// If `emitContentError` is enabled, we want to check the content for errors
|
|
101
|
+
// but ignore them (do not remove the invalid content from the document)
|
|
102
|
+
if (!options.errorOnInvalidContent && !editor.options.enableContentCheck && editor.options.emitContentError) {
|
|
103
|
+
try {
|
|
104
|
+
createNodeFromContent(value, editor.schema, {
|
|
105
|
+
parseOptions,
|
|
106
|
+
errorOnInvalidContent: true,
|
|
107
|
+
})
|
|
108
|
+
} catch (e) {
|
|
109
|
+
emitContentError(e as Error)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
86
112
|
|
|
87
|
-
|
|
113
|
+
try {
|
|
114
|
+
content = createNodeFromContent(value, editor.schema, {
|
|
115
|
+
parseOptions,
|
|
116
|
+
errorOnInvalidContent: options.errorOnInvalidContent ?? editor.options.enableContentCheck,
|
|
117
|
+
})
|
|
118
|
+
} catch (e) {
|
|
119
|
+
emitContentError(e as Error)
|
|
120
|
+
return false
|
|
121
|
+
}
|
|
88
122
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const nodes = isFragment(content) ? content : [content]
|
|
123
|
+
let { from, to } =
|
|
124
|
+
typeof position === 'number' ? { from: position, to: position } : { from: position.from, to: position.to }
|
|
92
125
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
126
|
+
let isOnlyTextContent = true
|
|
127
|
+
let isOnlyBlockContent = true
|
|
128
|
+
const nodes = isFragment(content) ? content : [content]
|
|
96
129
|
|
|
97
|
-
|
|
130
|
+
nodes.forEach(node => {
|
|
131
|
+
// check if added node is valid
|
|
132
|
+
node.check()
|
|
98
133
|
|
|
99
|
-
|
|
100
|
-
})
|
|
134
|
+
isOnlyTextContent = isOnlyTextContent ? node.isText && node.marks.length === 0 : false
|
|
101
135
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
// example:
|
|
105
|
-
// replace an empty paragraph by an inserted image
|
|
106
|
-
// instead of inserting the image below the paragraph
|
|
107
|
-
if (from === to && isOnlyBlockContent) {
|
|
108
|
-
const { parent } = tr.doc.resolve(from)
|
|
109
|
-
const isEmptyTextBlock = parent.isTextblock && !parent.type.spec.code && !parent.childCount
|
|
136
|
+
isOnlyBlockContent = isOnlyBlockContent ? node.isBlock : false
|
|
137
|
+
})
|
|
110
138
|
|
|
111
|
-
if
|
|
112
|
-
|
|
113
|
-
|
|
139
|
+
// check if we can replace the wrapping node by
|
|
140
|
+
// the newly inserted content
|
|
141
|
+
// example:
|
|
142
|
+
// replace an empty paragraph by an inserted image
|
|
143
|
+
// instead of inserting the image below the paragraph
|
|
144
|
+
if (from === to && isOnlyBlockContent) {
|
|
145
|
+
const { parent } = tr.doc.resolve(from)
|
|
146
|
+
const isEmptyTextBlock = parent.isTextblock && !parent.type.spec.code && !parent.childCount
|
|
147
|
+
|
|
148
|
+
if (isEmptyTextBlock) {
|
|
149
|
+
from -= 1
|
|
150
|
+
to += 1
|
|
151
|
+
}
|
|
114
152
|
}
|
|
115
|
-
}
|
|
116
153
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
154
|
+
let newContent
|
|
155
|
+
|
|
156
|
+
// if there is only plain text we have to use `insertText`
|
|
157
|
+
// because this will keep the current marks
|
|
158
|
+
if (isOnlyTextContent) {
|
|
159
|
+
// if value is string, we can use it directly
|
|
160
|
+
// otherwise if it is an array, we have to join it
|
|
161
|
+
if (Array.isArray(value)) {
|
|
162
|
+
newContent = value.map(v => v.text || '').join('')
|
|
163
|
+
} else if (value instanceof Fragment) {
|
|
164
|
+
let text = ''
|
|
165
|
+
|
|
166
|
+
value.forEach(node => {
|
|
167
|
+
if (node.text) {
|
|
168
|
+
text += node.text
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
newContent = text
|
|
173
|
+
} else if (typeof value === 'object' && !!value && !!value.text) {
|
|
174
|
+
newContent = value.text
|
|
175
|
+
} else {
|
|
176
|
+
newContent = value as string
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
tr.insertText(newContent, from, to)
|
|
128
180
|
} else {
|
|
129
|
-
newContent =
|
|
130
|
-
}
|
|
181
|
+
newContent = content
|
|
131
182
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
183
|
+
const fromSelectionAtStart = selection.$from.parentOffset === 0
|
|
184
|
+
const isTextSelection = selection.$from.node().isText || selection.$from.node().isTextblock
|
|
185
|
+
const hasContent = selection.$from.node().content.size > 0
|
|
135
186
|
|
|
136
|
-
|
|
137
|
-
|
|
187
|
+
if (fromSelectionAtStart && isTextSelection && hasContent) {
|
|
188
|
+
from = Math.max(0, from - 1)
|
|
189
|
+
}
|
|
138
190
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
selectionToInsertionEnd(tr, tr.steps.length - 1, -1)
|
|
142
|
-
}
|
|
191
|
+
tr.replaceWith(from, to, newContent)
|
|
192
|
+
}
|
|
143
193
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
194
|
+
// set cursor at end of inserted content
|
|
195
|
+
if (options.updateSelection) {
|
|
196
|
+
selectionToInsertionEnd(tr, tr.steps.length - 1, -1)
|
|
197
|
+
}
|
|
147
198
|
|
|
148
|
-
|
|
149
|
-
|
|
199
|
+
if (options.applyInputRules) {
|
|
200
|
+
tr.setMeta('applyInputRules', { from, text: newContent })
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (options.applyPasteRules) {
|
|
204
|
+
tr.setMeta('applyPasteRules', { from, text: newContent })
|
|
205
|
+
}
|
|
150
206
|
}
|
|
151
|
-
}
|
|
152
207
|
|
|
153
|
-
|
|
154
|
-
}
|
|
208
|
+
return true
|
|
209
|
+
}
|
package/src/commands/join.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
joinUp as originalJoinUp,
|
|
6
6
|
} from '@tiptap/pm/commands'
|
|
7
7
|
|
|
8
|
-
import { RawCommands } from '../types.js'
|
|
8
|
+
import type { RawCommands } from '../types.js'
|
|
9
9
|
|
|
10
10
|
declare module '@tiptap/core' {
|
|
11
11
|
interface Commands<ReturnType> {
|
|
@@ -44,18 +44,26 @@ declare module '@tiptap/core' {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
export const joinUp: RawCommands['joinUp'] =
|
|
48
|
-
|
|
49
|
-
}
|
|
47
|
+
export const joinUp: RawCommands['joinUp'] =
|
|
48
|
+
() =>
|
|
49
|
+
({ state, dispatch }) => {
|
|
50
|
+
return originalJoinUp(state, dispatch)
|
|
51
|
+
}
|
|
50
52
|
|
|
51
|
-
export const joinDown: RawCommands['joinDown'] =
|
|
52
|
-
|
|
53
|
-
}
|
|
53
|
+
export const joinDown: RawCommands['joinDown'] =
|
|
54
|
+
() =>
|
|
55
|
+
({ state, dispatch }) => {
|
|
56
|
+
return originalJoinDown(state, dispatch)
|
|
57
|
+
}
|
|
54
58
|
|
|
55
|
-
export const joinBackward: RawCommands['joinBackward'] =
|
|
56
|
-
|
|
57
|
-
}
|
|
59
|
+
export const joinBackward: RawCommands['joinBackward'] =
|
|
60
|
+
() =>
|
|
61
|
+
({ state, dispatch }) => {
|
|
62
|
+
return originalJoinBackward(state, dispatch)
|
|
63
|
+
}
|
|
58
64
|
|
|
59
|
-
export const joinForward: RawCommands['joinForward'] =
|
|
60
|
-
|
|
61
|
-
}
|
|
65
|
+
export const joinForward: RawCommands['joinForward'] =
|
|
66
|
+
() =>
|
|
67
|
+
({ state, dispatch }) => {
|
|
68
|
+
return originalJoinForward(state, dispatch)
|
|
69
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { joinPoint } from '@tiptap/pm/transform'
|
|
2
2
|
|
|
3
|
-
import { RawCommands } from '../types.js'
|
|
3
|
+
import type { RawCommands } from '../types.js'
|
|
4
4
|
|
|
5
5
|
declare module '@tiptap/core' {
|
|
6
6
|
interface Commands<ReturnType> {
|
|
@@ -14,26 +14,24 @@ declare module '@tiptap/core' {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export const joinItemBackward: RawCommands['joinItemBackward'] =
|
|
18
|
-
|
|
19
|
-
dispatch,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
const point = joinPoint(state.doc, state.selection.$from.pos, -1)
|
|
17
|
+
export const joinItemBackward: RawCommands['joinItemBackward'] =
|
|
18
|
+
() =>
|
|
19
|
+
({ state, dispatch, tr }) => {
|
|
20
|
+
try {
|
|
21
|
+
const point = joinPoint(state.doc, state.selection.$from.pos, -1)
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
if (point === null || point === undefined) {
|
|
24
|
+
return false
|
|
25
|
+
}
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
tr.join(point, 2)
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
if (dispatch) {
|
|
30
|
+
dispatch(tr)
|
|
31
|
+
}
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
return true
|
|
34
|
+
} catch {
|
|
35
|
+
return false
|
|
36
|
+
}
|
|
38
37
|
}
|
|
39
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { joinPoint } from '@tiptap/pm/transform'
|
|
2
2
|
|
|
3
|
-
import { RawCommands } from '../types.js'
|
|
3
|
+
import type { RawCommands } from '../types.js'
|
|
4
4
|
|
|
5
5
|
declare module '@tiptap/core' {
|
|
6
6
|
interface Commands<ReturnType> {
|
|
@@ -14,26 +14,24 @@ declare module '@tiptap/core' {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export const joinItemForward: RawCommands['joinItemForward'] =
|
|
18
|
-
|
|
19
|
-
dispatch,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
const point = joinPoint(state.doc, state.selection.$from.pos, +1)
|
|
17
|
+
export const joinItemForward: RawCommands['joinItemForward'] =
|
|
18
|
+
() =>
|
|
19
|
+
({ state, dispatch, tr }) => {
|
|
20
|
+
try {
|
|
21
|
+
const point = joinPoint(state.doc, state.selection.$from.pos, +1)
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
if (point === null || point === undefined) {
|
|
24
|
+
return false
|
|
25
|
+
}
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
tr.join(point, 2)
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
if (dispatch) {
|
|
30
|
+
dispatch(tr)
|
|
31
|
+
}
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
return true
|
|
34
|
+
} catch {
|
|
35
|
+
return false
|
|
36
|
+
}
|
|
38
37
|
}
|
|
39
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { joinTextblockBackward as originalCommand } from '@tiptap/pm/commands'
|
|
2
2
|
|
|
3
|
-
import { RawCommands } from '../types.js'
|
|
3
|
+
import type { RawCommands } from '../types.js'
|
|
4
4
|
|
|
5
5
|
declare module '@tiptap/core' {
|
|
6
6
|
interface Commands<ReturnType> {
|
|
@@ -13,6 +13,8 @@ declare module '@tiptap/core' {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const joinTextblockBackward: RawCommands['joinTextblockBackward'] =
|
|
17
|
-
|
|
18
|
-
}
|
|
16
|
+
export const joinTextblockBackward: RawCommands['joinTextblockBackward'] =
|
|
17
|
+
() =>
|
|
18
|
+
({ state, dispatch }) => {
|
|
19
|
+
return originalCommand(state, dispatch)
|
|
20
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { joinTextblockForward as originalCommand } from '@tiptap/pm/commands'
|
|
2
2
|
|
|
3
|
-
import { RawCommands } from '../types.js'
|
|
3
|
+
import type { RawCommands } from '../types.js'
|
|
4
4
|
|
|
5
5
|
declare module '@tiptap/core' {
|
|
6
6
|
interface Commands<ReturnType> {
|
|
@@ -13,6 +13,8 @@ declare module '@tiptap/core' {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const joinTextblockForward: RawCommands['joinTextblockForward'] =
|
|
17
|
-
|
|
18
|
-
}
|
|
16
|
+
export const joinTextblockForward: RawCommands['joinTextblockForward'] =
|
|
17
|
+
() =>
|
|
18
|
+
({ state, dispatch }) => {
|
|
19
|
+
return originalCommand(state, dispatch)
|
|
20
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RawCommands } from '../types.js'
|
|
1
|
+
import type { RawCommands } from '../types.js'
|
|
2
2
|
import { isiOS } from '../utilities/isiOS.js'
|
|
3
3
|
import { isMacOS } from '../utilities/isMacOS.js'
|
|
4
4
|
|
|
@@ -64,42 +64,37 @@ declare module '@tiptap/core' {
|
|
|
64
64
|
* @param name The name of the keyboard shortcut.
|
|
65
65
|
* @example editor.commands.keyboardShortcut('Mod-b')
|
|
66
66
|
*/
|
|
67
|
-
keyboardShortcut: (name: string) => ReturnType
|
|
67
|
+
keyboardShortcut: (name: string) => ReturnType
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
export const keyboardShortcut: RawCommands['keyboardShortcut'] =
|
|
73
|
-
|
|
74
|
-
view,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (newStep && dispatch) {
|
|
100
|
-
tr.maybeStep(newStep)
|
|
101
|
-
}
|
|
102
|
-
})
|
|
72
|
+
export const keyboardShortcut: RawCommands['keyboardShortcut'] =
|
|
73
|
+
name =>
|
|
74
|
+
({ editor, view, tr, dispatch }) => {
|
|
75
|
+
const keys = normalizeKeyName(name).split(/-(?!$)/)
|
|
76
|
+
const key = keys.find(item => !['Alt', 'Ctrl', 'Meta', 'Shift'].includes(item))
|
|
77
|
+
const event = new KeyboardEvent('keydown', {
|
|
78
|
+
key: key === 'Space' ? ' ' : key,
|
|
79
|
+
altKey: keys.includes('Alt'),
|
|
80
|
+
ctrlKey: keys.includes('Ctrl'),
|
|
81
|
+
metaKey: keys.includes('Meta'),
|
|
82
|
+
shiftKey: keys.includes('Shift'),
|
|
83
|
+
bubbles: true,
|
|
84
|
+
cancelable: true,
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
const capturedTransaction = editor.captureTransaction(() => {
|
|
88
|
+
view.someProp('handleKeyDown', f => f(view, event))
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
capturedTransaction?.steps.forEach(step => {
|
|
92
|
+
const newStep = step.map(tr.mapping)
|
|
93
|
+
|
|
94
|
+
if (newStep && dispatch) {
|
|
95
|
+
tr.maybeStep(newStep)
|
|
96
|
+
}
|
|
97
|
+
})
|
|
103
98
|
|
|
104
|
-
|
|
105
|
-
}
|
|
99
|
+
return true
|
|
100
|
+
}
|
package/src/commands/lift.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { lift as originalLift } from '@tiptap/pm/commands'
|
|
2
|
-
import { NodeType } from '@tiptap/pm/model'
|
|
2
|
+
import type { NodeType } from '@tiptap/pm/model'
|
|
3
3
|
|
|
4
4
|
import { getNodeType } from '../helpers/getNodeType.js'
|
|
5
5
|
import { isNodeActive } from '../helpers/isNodeActive.js'
|
|
6
|
-
import { RawCommands } from '../types.js'
|
|
6
|
+
import type { RawCommands } from '../types.js'
|
|
7
7
|
|
|
8
8
|
declare module '@tiptap/core' {
|
|
9
9
|
interface Commands<ReturnType> {
|
|
@@ -20,13 +20,15 @@ declare module '@tiptap/core' {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export const lift: RawCommands['lift'] =
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
export const lift: RawCommands['lift'] =
|
|
24
|
+
(typeOrName, attributes = {}) =>
|
|
25
|
+
({ state, dispatch }) => {
|
|
26
|
+
const type = getNodeType(typeOrName, state.schema)
|
|
27
|
+
const isActive = isNodeActive(state, type, attributes)
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
if (!isActive) {
|
|
30
|
+
return false
|
|
31
|
+
}
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
+
return originalLift(state, dispatch)
|
|
34
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { liftEmptyBlock as originalLiftEmptyBlock } from '@tiptap/pm/commands'
|
|
2
2
|
|
|
3
|
-
import { RawCommands } from '../types.js'
|
|
3
|
+
import type { RawCommands } from '../types.js'
|
|
4
4
|
|
|
5
5
|
declare module '@tiptap/core' {
|
|
6
6
|
interface Commands<ReturnType> {
|
|
@@ -9,11 +9,13 @@ declare module '@tiptap/core' {
|
|
|
9
9
|
* If the cursor is in an empty textblock that can be lifted, lift the block.
|
|
10
10
|
* @example editor.commands.liftEmptyBlock()
|
|
11
11
|
*/
|
|
12
|
-
liftEmptyBlock: () => ReturnType
|
|
12
|
+
liftEmptyBlock: () => ReturnType
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export const liftEmptyBlock: RawCommands['liftEmptyBlock'] =
|
|
18
|
-
|
|
19
|
-
}
|
|
17
|
+
export const liftEmptyBlock: RawCommands['liftEmptyBlock'] =
|
|
18
|
+
() =>
|
|
19
|
+
({ state, dispatch }) => {
|
|
20
|
+
return originalLiftEmptyBlock(state, dispatch)
|
|
21
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { NodeType } from '@tiptap/pm/model'
|
|
1
|
+
import type { NodeType } from '@tiptap/pm/model'
|
|
2
2
|
import { liftListItem as originalLiftListItem } from '@tiptap/pm/schema-list'
|
|
3
3
|
|
|
4
4
|
import { getNodeType } from '../helpers/getNodeType.js'
|
|
5
|
-
import { RawCommands } from '../types.js'
|
|
5
|
+
import type { RawCommands } from '../types.js'
|
|
6
6
|
|
|
7
7
|
declare module '@tiptap/core' {
|
|
8
8
|
interface Commands<ReturnType> {
|
|
@@ -17,8 +17,10 @@ declare module '@tiptap/core' {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export const liftListItem: RawCommands['liftListItem'] =
|
|
21
|
-
|
|
20
|
+
export const liftListItem: RawCommands['liftListItem'] =
|
|
21
|
+
typeOrName =>
|
|
22
|
+
({ state, dispatch }) => {
|
|
23
|
+
const type = getNodeType(typeOrName, state.schema)
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
+
return originalLiftListItem(type)(state, dispatch)
|
|
26
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { newlineInCode as originalNewlineInCode } from '@tiptap/pm/commands'
|
|
2
2
|
|
|
3
|
-
import { RawCommands } from '../types.js'
|
|
3
|
+
import type { RawCommands } from '../types.js'
|
|
4
4
|
|
|
5
5
|
declare module '@tiptap/core' {
|
|
6
6
|
interface Commands<ReturnType> {
|
|
@@ -14,6 +14,8 @@ declare module '@tiptap/core' {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export const newlineInCode: RawCommands['newlineInCode'] =
|
|
18
|
-
|
|
19
|
-
}
|
|
17
|
+
export const newlineInCode: RawCommands['newlineInCode'] =
|
|
18
|
+
() =>
|
|
19
|
+
({ state, dispatch }) => {
|
|
20
|
+
return originalNewlineInCode(state, dispatch)
|
|
21
|
+
}
|