@tiptap/core 2.11.7 → 3.0.0-beta.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 +5047 -5070
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3326 -0
- package/dist/index.d.ts +3326 -25
- package/dist/index.js +4931 -4976
- 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-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 +28 -9
- package/src/CommandManager.ts +4 -11
- package/src/Editor.ts +219 -103
- package/src/EventEmitter.ts +7 -10
- package/src/Extendable.ts +484 -0
- package/src/Extension.ts +17 -492
- package/src/ExtensionManager.ts +88 -140
- package/src/InputRule.ts +40 -51
- package/src/Mark.ts +146 -623
- package/src/MarkView.ts +66 -0
- package/src/Node.ts +332 -825
- package/src/NodePos.ts +3 -5
- package/src/NodeView.ts +13 -23
- package/src/PasteRule.ts +46 -56
- 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 +50 -53
- package/src/commands/forEach.ts +3 -3
- package/src/commands/insertContent.ts +14 -16
- package/src/commands/insertContentAt.ts +111 -95
- 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 +11 -9
- 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 +39 -38
- package/src/commands/setMark.ts +58 -60
- package/src/commands/setMeta.ts +8 -6
- package/src/commands/setNode.ts +34 -32
- 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 +70 -78
- package/src/commands/splitListItem.ts +95 -107
- package/src/commands/toggleList.ts +76 -74
- package/src/commands/toggleMark.ts +13 -11
- package/src/commands/toggleNode.ts +20 -18
- 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 +94 -102
- 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/focusEvents.ts +2 -6
- package/src/extensions/index.ts +1 -0
- package/src/extensions/keymap.ts +54 -50
- package/src/extensions/paste.ts +0 -1
- 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 +2 -4
- package/src/helpers/createNodeFromContent.ts +7 -12
- 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 +7 -17
- package/src/helpers/getMarkType.ts +2 -4
- package/src/helpers/getMarksBetween.ts +2 -2
- 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 -5
- package/src/helpers/getSchema.ts +5 -5
- package/src/helpers/getSchemaByResolvedExtensions.ts +47 -78
- 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 +3 -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 +3 -3
- 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 +25 -24
- 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 +5 -8
- package/src/inputRules/nodeInputRule.ts +6 -12
- package/src/inputRules/textInputRule.ts +3 -5
- package/src/inputRules/textblockTypeInputRule.ts +6 -11
- package/src/inputRules/wrappingInputRule.ts +18 -23
- package/src/jsx-runtime.ts +64 -0
- package/src/pasteRules/markPasteRule.ts +5 -6
- package/src/pasteRules/nodePasteRule.ts +6 -11
- package/src/pasteRules/textPasteRule.ts +3 -5
- package/src/style.ts +0 -4
- package/src/types.ts +534 -179
- package/src/utilities/callOrReturn.ts +1 -1
- 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 +4 -1
- package/src/utilities/index.ts +1 -0
- package/src/utilities/isMacOS.ts +1 -3
- package/src/utilities/isiOS.ts +5 -10
- package/src/utilities/mergeAttributes.ts +16 -6
- package/src/utilities/removeDuplicates.ts +1 -3
- package/dist/CommandManager.d.ts +0 -21
- package/dist/CommandManager.d.ts.map +0 -1
- package/dist/Editor.d.ts +0 -166
- package/dist/Editor.d.ts.map +0 -1
- package/dist/EventEmitter.d.ts +0 -13
- package/dist/EventEmitter.d.ts.map +0 -1
- package/dist/Extension.d.ts +0 -345
- package/dist/Extension.d.ts.map +0 -1
- package/dist/ExtensionManager.d.ts +0 -57
- package/dist/ExtensionManager.d.ts.map +0 -1
- package/dist/InputRule.d.ts +0 -43
- package/dist/InputRule.d.ts.map +0 -1
- package/dist/Mark.d.ts +0 -453
- package/dist/Mark.d.ts.map +0 -1
- package/dist/Node.d.ts +0 -629
- package/dist/Node.d.ts.map +0 -1
- package/dist/NodePos.d.ts +0 -45
- package/dist/NodePos.d.ts.map +0 -1
- package/dist/NodeView.d.ts +0 -41
- package/dist/NodeView.d.ts.map +0 -1
- package/dist/PasteRule.d.ts +0 -51
- package/dist/PasteRule.d.ts.map +0 -1
- package/dist/Tracker.d.ts +0 -12
- package/dist/Tracker.d.ts.map +0 -1
- package/dist/commands/blur.d.ts +0 -14
- package/dist/commands/blur.d.ts.map +0 -1
- package/dist/commands/clearContent.d.ts +0 -15
- package/dist/commands/clearContent.d.ts.map +0 -1
- package/dist/commands/clearNodes.d.ts +0 -14
- package/dist/commands/clearNodes.d.ts.map +0 -1
- package/dist/commands/command.d.ts +0 -19
- package/dist/commands/command.d.ts.map +0 -1
- package/dist/commands/createParagraphNear.d.ts +0 -14
- package/dist/commands/createParagraphNear.d.ts.map +0 -1
- package/dist/commands/cut.d.ts +0 -21
- package/dist/commands/cut.d.ts.map +0 -1
- package/dist/commands/deleteCurrentNode.d.ts +0 -14
- package/dist/commands/deleteCurrentNode.d.ts.map +0 -1
- package/dist/commands/deleteNode.d.ts +0 -16
- package/dist/commands/deleteNode.d.ts.map +0 -1
- package/dist/commands/deleteRange.d.ts +0 -15
- package/dist/commands/deleteRange.d.ts.map +0 -1
- package/dist/commands/deleteSelection.d.ts +0 -14
- package/dist/commands/deleteSelection.d.ts.map +0 -1
- package/dist/commands/enter.d.ts +0 -14
- package/dist/commands/enter.d.ts.map +0 -1
- package/dist/commands/exitCode.d.ts +0 -14
- package/dist/commands/exitCode.d.ts.map +0 -1
- package/dist/commands/extendMarkRange.d.ts +0 -26
- package/dist/commands/extendMarkRange.d.ts.map +0 -1
- package/dist/commands/first.d.ts +0 -15
- package/dist/commands/first.d.ts.map +0 -1
- package/dist/commands/focus.d.ts +0 -28
- package/dist/commands/focus.d.ts.map +0 -1
- package/dist/commands/forEach.d.ts +0 -15
- package/dist/commands/forEach.d.ts.map +0 -1
- package/dist/commands/index.d.ts +0 -56
- package/dist/commands/index.d.ts.map +0 -1
- package/dist/commands/insertContent.d.ts +0 -35
- package/dist/commands/insertContent.d.ts.map +0 -1
- package/dist/commands/insertContentAt.d.ts +0 -48
- package/dist/commands/insertContentAt.d.ts.map +0 -1
- package/dist/commands/join.d.ts +0 -42
- package/dist/commands/join.d.ts.map +0 -1
- package/dist/commands/joinItemBackward.d.ts +0 -14
- package/dist/commands/joinItemBackward.d.ts.map +0 -1
- package/dist/commands/joinItemForward.d.ts +0 -14
- package/dist/commands/joinItemForward.d.ts.map +0 -1
- package/dist/commands/joinTextblockBackward.d.ts +0 -13
- package/dist/commands/joinTextblockBackward.d.ts.map +0 -1
- package/dist/commands/joinTextblockForward.d.ts +0 -13
- package/dist/commands/joinTextblockForward.d.ts.map +0 -1
- package/dist/commands/keyboardShortcut.d.ts +0 -15
- package/dist/commands/keyboardShortcut.d.ts.map +0 -1
- package/dist/commands/lift.d.ts +0 -18
- package/dist/commands/lift.d.ts.map +0 -1
- package/dist/commands/liftEmptyBlock.d.ts +0 -14
- package/dist/commands/liftEmptyBlock.d.ts.map +0 -1
- package/dist/commands/liftListItem.d.ts +0 -16
- package/dist/commands/liftListItem.d.ts.map +0 -1
- package/dist/commands/newlineInCode.d.ts +0 -14
- package/dist/commands/newlineInCode.d.ts.map +0 -1
- package/dist/commands/resetAttributes.d.ts +0 -17
- package/dist/commands/resetAttributes.d.ts.map +0 -1
- package/dist/commands/scrollIntoView.d.ts +0 -14
- package/dist/commands/scrollIntoView.d.ts.map +0 -1
- package/dist/commands/selectAll.d.ts +0 -14
- package/dist/commands/selectAll.d.ts.map +0 -1
- package/dist/commands/selectNodeBackward.d.ts +0 -14
- package/dist/commands/selectNodeBackward.d.ts.map +0 -1
- package/dist/commands/selectNodeForward.d.ts +0 -14
- package/dist/commands/selectNodeForward.d.ts.map +0 -1
- package/dist/commands/selectParentNode.d.ts +0 -14
- package/dist/commands/selectParentNode.d.ts.map +0 -1
- package/dist/commands/selectTextblockEnd.d.ts +0 -14
- package/dist/commands/selectTextblockEnd.d.ts.map +0 -1
- package/dist/commands/selectTextblockStart.d.ts +0 -14
- package/dist/commands/selectTextblockStart.d.ts.map +0 -1
- package/dist/commands/setContent.d.ts +0 -41
- package/dist/commands/setContent.d.ts.map +0 -1
- package/dist/commands/setMark.d.ts +0 -16
- package/dist/commands/setMark.d.ts.map +0 -1
- package/dist/commands/setMeta.d.ts +0 -17
- package/dist/commands/setMeta.d.ts.map +0 -1
- package/dist/commands/setNode.d.ts +0 -17
- package/dist/commands/setNode.d.ts.map +0 -1
- package/dist/commands/setNodeSelection.d.ts +0 -15
- package/dist/commands/setNodeSelection.d.ts.map +0 -1
- package/dist/commands/setTextSelection.d.ts +0 -15
- package/dist/commands/setTextSelection.d.ts.map +0 -1
- package/dist/commands/sinkListItem.d.ts +0 -16
- package/dist/commands/sinkListItem.d.ts.map +0 -1
- package/dist/commands/splitBlock.d.ts +0 -18
- package/dist/commands/splitBlock.d.ts.map +0 -1
- package/dist/commands/splitListItem.d.ts +0 -17
- package/dist/commands/splitListItem.d.ts.map +0 -1
- package/dist/commands/toggleList.d.ts +0 -19
- package/dist/commands/toggleList.d.ts.map +0 -1
- package/dist/commands/toggleMark.d.ts +0 -31
- package/dist/commands/toggleMark.d.ts.map +0 -1
- package/dist/commands/toggleNode.d.ts +0 -18
- package/dist/commands/toggleNode.d.ts.map +0 -1
- package/dist/commands/toggleWrap.d.ts +0 -17
- package/dist/commands/toggleWrap.d.ts.map +0 -1
- package/dist/commands/undoInputRule.d.ts +0 -14
- package/dist/commands/undoInputRule.d.ts.map +0 -1
- package/dist/commands/unsetAllMarks.d.ts +0 -14
- package/dist/commands/unsetAllMarks.d.ts.map +0 -1
- package/dist/commands/unsetMark.d.ts +0 -26
- package/dist/commands/unsetMark.d.ts.map +0 -1
- package/dist/commands/updateAttributes.d.ts +0 -25
- package/dist/commands/updateAttributes.d.ts.map +0 -1
- package/dist/commands/wrapIn.d.ts +0 -17
- package/dist/commands/wrapIn.d.ts.map +0 -1
- package/dist/commands/wrapInList.d.ts +0 -17
- package/dist/commands/wrapInList.d.ts.map +0 -1
- package/dist/extensions/clipboardTextSerializer.d.ts +0 -6
- package/dist/extensions/clipboardTextSerializer.d.ts.map +0 -1
- package/dist/extensions/commands.d.ts +0 -4
- package/dist/extensions/commands.d.ts.map +0 -1
- package/dist/extensions/drop.d.ts +0 -3
- package/dist/extensions/drop.d.ts.map +0 -1
- package/dist/extensions/editable.d.ts +0 -3
- package/dist/extensions/editable.d.ts.map +0 -1
- package/dist/extensions/focusEvents.d.ts +0 -5
- package/dist/extensions/focusEvents.d.ts.map +0 -1
- package/dist/extensions/index.d.ts +0 -9
- package/dist/extensions/index.d.ts.map +0 -1
- package/dist/extensions/keymap.d.ts +0 -3
- package/dist/extensions/keymap.d.ts.map +0 -1
- package/dist/extensions/paste.d.ts +0 -3
- package/dist/extensions/paste.d.ts.map +0 -1
- package/dist/extensions/tabindex.d.ts +0 -3
- package/dist/extensions/tabindex.d.ts.map +0 -1
- package/dist/helpers/combineTransactionSteps.d.ts +0 -11
- package/dist/helpers/combineTransactionSteps.d.ts.map +0 -1
- package/dist/helpers/createChainableState.d.ts +0 -11
- package/dist/helpers/createChainableState.d.ts.map +0 -1
- package/dist/helpers/createDocument.d.ts +0 -13
- package/dist/helpers/createDocument.d.ts.map +0 -1
- package/dist/helpers/createNodeFromContent.d.ts +0 -16
- package/dist/helpers/createNodeFromContent.d.ts.map +0 -1
- package/dist/helpers/defaultBlockAt.d.ts +0 -8
- package/dist/helpers/defaultBlockAt.d.ts.map +0 -1
- package/dist/helpers/findChildren.d.ts +0 -10
- package/dist/helpers/findChildren.d.ts.map +0 -1
- package/dist/helpers/findChildrenInRange.d.ts +0 -11
- package/dist/helpers/findChildrenInRange.d.ts.map +0 -1
- package/dist/helpers/findParentNode.d.ts +0 -17
- package/dist/helpers/findParentNode.d.ts.map +0 -1
- package/dist/helpers/findParentNodeClosestToPos.d.ts +0 -18
- package/dist/helpers/findParentNodeClosestToPos.d.ts.map +0 -1
- package/dist/helpers/generateHTML.d.ts +0 -9
- package/dist/helpers/generateHTML.d.ts.map +0 -1
- package/dist/helpers/generateJSON.d.ts +0 -9
- package/dist/helpers/generateJSON.d.ts.map +0 -1
- package/dist/helpers/generateText.d.ts +0 -13
- package/dist/helpers/generateText.d.ts.map +0 -1
- package/dist/helpers/getAttributes.d.ts +0 -10
- package/dist/helpers/getAttributes.d.ts.map +0 -1
- package/dist/helpers/getAttributesFromExtensions.d.ts +0 -7
- package/dist/helpers/getAttributesFromExtensions.d.ts.map +0 -1
- package/dist/helpers/getChangedRanges.d.ts +0 -12
- package/dist/helpers/getChangedRanges.d.ts.map +0 -1
- package/dist/helpers/getDebugJSON.d.ts +0 -9
- package/dist/helpers/getDebugJSON.d.ts.map +0 -1
- package/dist/helpers/getExtensionField.d.ts +0 -10
- package/dist/helpers/getExtensionField.d.ts.map +0 -1
- package/dist/helpers/getHTMLFromFragment.d.ts +0 -3
- package/dist/helpers/getHTMLFromFragment.d.ts.map +0 -1
- package/dist/helpers/getMarkAttributes.d.ts +0 -4
- package/dist/helpers/getMarkAttributes.d.ts.map +0 -1
- package/dist/helpers/getMarkRange.d.ts +0 -20
- package/dist/helpers/getMarkRange.d.ts.map +0 -1
- package/dist/helpers/getMarkType.d.ts +0 -3
- package/dist/helpers/getMarkType.d.ts.map +0 -1
- package/dist/helpers/getMarksBetween.d.ts +0 -4
- package/dist/helpers/getMarksBetween.d.ts.map +0 -1
- package/dist/helpers/getNodeAtPosition.d.ts +0 -12
- package/dist/helpers/getNodeAtPosition.d.ts.map +0 -1
- package/dist/helpers/getNodeAttributes.d.ts +0 -4
- package/dist/helpers/getNodeAttributes.d.ts.map +0 -1
- package/dist/helpers/getNodeType.d.ts +0 -3
- package/dist/helpers/getNodeType.d.ts.map +0 -1
- package/dist/helpers/getRenderedAttributes.d.ts +0 -4
- package/dist/helpers/getRenderedAttributes.d.ts.map +0 -1
- package/dist/helpers/getSchema.d.ts +0 -5
- package/dist/helpers/getSchema.d.ts.map +0 -1
- package/dist/helpers/getSchemaByResolvedExtensions.d.ts +0 -11
- package/dist/helpers/getSchemaByResolvedExtensions.d.ts.map +0 -1
- package/dist/helpers/getSchemaTypeByName.d.ts +0 -9
- package/dist/helpers/getSchemaTypeByName.d.ts.map +0 -1
- package/dist/helpers/getSchemaTypeNameByName.d.ts +0 -9
- package/dist/helpers/getSchemaTypeNameByName.d.ts.map +0 -1
- package/dist/helpers/getSplittedAttributes.d.ts +0 -10
- package/dist/helpers/getSplittedAttributes.d.ts.map +0 -1
- package/dist/helpers/getText.d.ts +0 -16
- package/dist/helpers/getText.d.ts.map +0 -1
- package/dist/helpers/getTextBetween.d.ts +0 -15
- package/dist/helpers/getTextBetween.d.ts.map +0 -1
- package/dist/helpers/getTextContentFromNodes.d.ts +0 -9
- package/dist/helpers/getTextContentFromNodes.d.ts.map +0 -1
- package/dist/helpers/getTextSerializersFromSchema.d.ts +0 -9
- package/dist/helpers/getTextSerializersFromSchema.d.ts.map +0 -1
- package/dist/helpers/index.d.ts +0 -52
- package/dist/helpers/index.d.ts.map +0 -1
- package/dist/helpers/injectExtensionAttributesToParseRule.d.ts +0 -10
- package/dist/helpers/injectExtensionAttributesToParseRule.d.ts.map +0 -1
- package/dist/helpers/isActive.d.ts +0 -3
- package/dist/helpers/isActive.d.ts.map +0 -1
- package/dist/helpers/isAtEndOfNode.d.ts +0 -3
- package/dist/helpers/isAtEndOfNode.d.ts.map +0 -1
- package/dist/helpers/isAtStartOfNode.d.ts +0 -3
- package/dist/helpers/isAtStartOfNode.d.ts.map +0 -1
- package/dist/helpers/isExtensionRulesEnabled.d.ts +0 -3
- package/dist/helpers/isExtensionRulesEnabled.d.ts.map +0 -1
- package/dist/helpers/isList.d.ts +0 -3
- package/dist/helpers/isList.d.ts.map +0 -1
- package/dist/helpers/isMarkActive.d.ts +0 -4
- package/dist/helpers/isMarkActive.d.ts.map +0 -1
- package/dist/helpers/isNodeActive.d.ts +0 -4
- package/dist/helpers/isNodeActive.d.ts.map +0 -1
- package/dist/helpers/isNodeEmpty.d.ts +0 -15
- package/dist/helpers/isNodeEmpty.d.ts.map +0 -1
- package/dist/helpers/isNodeSelection.d.ts +0 -3
- package/dist/helpers/isNodeSelection.d.ts.map +0 -1
- package/dist/helpers/isTextSelection.d.ts +0 -3
- package/dist/helpers/isTextSelection.d.ts.map +0 -1
- package/dist/helpers/posToDOMRect.d.ts +0 -3
- package/dist/helpers/posToDOMRect.d.ts.map +0 -1
- package/dist/helpers/resolveFocusPosition.d.ts +0 -5
- package/dist/helpers/resolveFocusPosition.d.ts.map +0 -1
- package/dist/helpers/rewriteUnknownContent.d.ts +0 -46
- package/dist/helpers/rewriteUnknownContent.d.ts.map +0 -1
- package/dist/helpers/selectionToInsertionEnd.d.ts +0 -3
- package/dist/helpers/selectionToInsertionEnd.d.ts.map +0 -1
- package/dist/helpers/splitExtensions.d.ts +0 -10
- package/dist/helpers/splitExtensions.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.umd.js +0 -5525
- package/dist/index.umd.js.map +0 -1
- package/dist/inputRules/index.d.ts +0 -6
- package/dist/inputRules/index.d.ts.map +0 -1
- package/dist/inputRules/markInputRule.d.ts +0 -14
- package/dist/inputRules/markInputRule.d.ts.map +0 -1
- package/dist/inputRules/nodeInputRule.d.ts +0 -24
- package/dist/inputRules/nodeInputRule.d.ts.map +0 -1
- package/dist/inputRules/textInputRule.d.ts +0 -11
- package/dist/inputRules/textInputRule.d.ts.map +0 -1
- package/dist/inputRules/textblockTypeInputRule.d.ts +0 -16
- package/dist/inputRules/textblockTypeInputRule.d.ts.map +0 -1
- package/dist/inputRules/wrappingInputRule.d.ts +0 -29
- package/dist/inputRules/wrappingInputRule.d.ts.map +0 -1
- package/dist/pasteRules/index.d.ts +0 -4
- package/dist/pasteRules/index.d.ts.map +0 -1
- package/dist/pasteRules/markPasteRule.d.ts +0 -14
- package/dist/pasteRules/markPasteRule.d.ts.map +0 -1
- package/dist/pasteRules/nodePasteRule.d.ts +0 -15
- package/dist/pasteRules/nodePasteRule.d.ts.map +0 -1
- package/dist/pasteRules/textPasteRule.d.ts +0 -11
- package/dist/pasteRules/textPasteRule.d.ts.map +0 -1
- package/dist/style.d.ts +0 -2
- package/dist/style.d.ts.map +0 -1
- package/dist/types.d.ts +0 -323
- package/dist/types.d.ts.map +0 -1
- package/dist/utilities/callOrReturn.d.ts +0 -10
- package/dist/utilities/callOrReturn.d.ts.map +0 -1
- package/dist/utilities/createStyleTag.d.ts +0 -2
- package/dist/utilities/createStyleTag.d.ts.map +0 -1
- package/dist/utilities/deleteProps.d.ts +0 -7
- package/dist/utilities/deleteProps.d.ts.map +0 -1
- package/dist/utilities/elementFromString.d.ts +0 -2
- package/dist/utilities/elementFromString.d.ts.map +0 -1
- package/dist/utilities/escapeForRegEx.d.ts +0 -2
- package/dist/utilities/escapeForRegEx.d.ts.map +0 -1
- package/dist/utilities/findDuplicates.d.ts +0 -2
- package/dist/utilities/findDuplicates.d.ts.map +0 -1
- package/dist/utilities/fromString.d.ts +0 -2
- package/dist/utilities/fromString.d.ts.map +0 -1
- package/dist/utilities/index.d.ts +0 -21
- package/dist/utilities/index.d.ts.map +0 -1
- package/dist/utilities/isAndroid.d.ts +0 -2
- package/dist/utilities/isAndroid.d.ts.map +0 -1
- package/dist/utilities/isEmptyObject.d.ts +0 -2
- package/dist/utilities/isEmptyObject.d.ts.map +0 -1
- package/dist/utilities/isFunction.d.ts +0 -2
- package/dist/utilities/isFunction.d.ts.map +0 -1
- package/dist/utilities/isMacOS.d.ts +0 -2
- package/dist/utilities/isMacOS.d.ts.map +0 -1
- package/dist/utilities/isNumber.d.ts +0 -2
- package/dist/utilities/isNumber.d.ts.map +0 -1
- package/dist/utilities/isPlainObject.d.ts +0 -2
- package/dist/utilities/isPlainObject.d.ts.map +0 -1
- package/dist/utilities/isRegExp.d.ts +0 -2
- package/dist/utilities/isRegExp.d.ts.map +0 -1
- package/dist/utilities/isString.d.ts +0 -2
- package/dist/utilities/isString.d.ts.map +0 -1
- package/dist/utilities/isiOS.d.ts +0 -2
- package/dist/utilities/isiOS.d.ts.map +0 -1
- package/dist/utilities/mergeAttributes.d.ts +0 -2
- package/dist/utilities/mergeAttributes.d.ts.map +0 -1
- package/dist/utilities/mergeDeep.d.ts +0 -2
- package/dist/utilities/mergeDeep.d.ts.map +0 -1
- package/dist/utilities/minMax.d.ts +0 -2
- package/dist/utilities/minMax.d.ts.map +0 -1
- package/dist/utilities/objectIncludes.d.ts +0 -9
- package/dist/utilities/objectIncludes.d.ts.map +0 -1
- package/dist/utilities/removeDuplicates.d.ts +0 -9
- package/dist/utilities/removeDuplicates.d.ts.map +0 -1
|
@@ -10,7 +10,7 @@ export const Tabindex = Extension.create({
|
|
|
10
10
|
new Plugin({
|
|
11
11
|
key: new PluginKey('tabindex'),
|
|
12
12
|
props: {
|
|
13
|
-
attributes: (): { [name: string]: string
|
|
13
|
+
attributes: (): { [name: string]: string } => (this.editor.isEditable ? { tabindex: '0' } : {}),
|
|
14
14
|
},
|
|
15
15
|
}),
|
|
16
16
|
]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Node as ProseMirrorNode } from '@tiptap/pm/model'
|
|
2
|
-
import { Transaction } from '@tiptap/pm/state'
|
|
1
|
+
import type { Node as ProseMirrorNode } from '@tiptap/pm/model'
|
|
2
|
+
import type { Transaction } from '@tiptap/pm/state'
|
|
3
3
|
import { Transform } from '@tiptap/pm/transform'
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -8,10 +8,7 @@ import { Transform } from '@tiptap/pm/transform'
|
|
|
8
8
|
* @param transactions The transactions to combine
|
|
9
9
|
* @returns A new `Transform` with all steps of the passed transactions
|
|
10
10
|
*/
|
|
11
|
-
export function combineTransactionSteps(
|
|
12
|
-
oldDoc: ProseMirrorNode,
|
|
13
|
-
transactions: Transaction[],
|
|
14
|
-
): Transform {
|
|
11
|
+
export function combineTransactionSteps(oldDoc: ProseMirrorNode, transactions: Transaction[]): Transform {
|
|
15
12
|
const transform = new Transform(oldDoc)
|
|
16
13
|
|
|
17
14
|
transactions.forEach(transaction => {
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { EditorState, Transaction } from '@tiptap/pm/state'
|
|
1
|
+
import type { EditorState, Transaction } from '@tiptap/pm/state'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Takes a Transaction & Editor State and turns it into a chainable state object
|
|
5
5
|
* @param config The transaction and state to create the chainable state from
|
|
6
6
|
* @returns A chainable Editor state object
|
|
7
7
|
*/
|
|
8
|
-
export function createChainableState(config: {
|
|
9
|
-
transaction: Transaction
|
|
10
|
-
state: EditorState
|
|
11
|
-
}): EditorState {
|
|
8
|
+
export function createChainableState(config: { transaction: Transaction; state: EditorState }): EditorState {
|
|
12
9
|
const { state, transaction } = config
|
|
13
10
|
let { selection } = transaction
|
|
14
11
|
let { doc } = transaction
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Fragment, Node as ProseMirrorNode, ParseOptions, Schema,
|
|
3
|
-
} from '@tiptap/pm/model'
|
|
1
|
+
import type { Fragment, Node as ProseMirrorNode, ParseOptions, Schema } from '@tiptap/pm/model'
|
|
4
2
|
|
|
5
|
-
import { Content } from '../types.js'
|
|
3
|
+
import type { Content } from '../types.js'
|
|
6
4
|
import { createNodeFromContent } from './createNodeFromContent.js'
|
|
7
5
|
|
|
8
6
|
/**
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
ParseOptions,
|
|
6
|
-
Schema,
|
|
7
|
-
} from '@tiptap/pm/model'
|
|
8
|
-
|
|
9
|
-
import { Content } from '../types.js'
|
|
1
|
+
import type { ParseOptions } from '@tiptap/pm/model'
|
|
2
|
+
import { DOMParser, Fragment, Node as ProseMirrorNode, Schema } from '@tiptap/pm/model'
|
|
3
|
+
|
|
4
|
+
import type { Content } from '../types.js'
|
|
10
5
|
import { elementFromString } from '../utilities/elementFromString.js'
|
|
11
6
|
|
|
12
7
|
export type CreateNodeFromContentOptions = {
|
|
@@ -67,7 +62,6 @@ export function createNodeFromContent(
|
|
|
67
62
|
}
|
|
68
63
|
|
|
69
64
|
if (isTextContent) {
|
|
70
|
-
|
|
71
65
|
// Check for invalid content
|
|
72
66
|
if (options.errorOnInvalidContent) {
|
|
73
67
|
let hasInvalidContent = false
|
|
@@ -106,7 +100,9 @@ export function createNodeFromContent(
|
|
|
106
100
|
}
|
|
107
101
|
|
|
108
102
|
if (options.errorOnInvalidContent && hasInvalidContent) {
|
|
109
|
-
throw new Error('[tiptap error]: Invalid HTML content', {
|
|
103
|
+
throw new Error('[tiptap error]: Invalid HTML content', {
|
|
104
|
+
cause: new Error(`Invalid element found: ${invalidContent}`),
|
|
105
|
+
})
|
|
110
106
|
}
|
|
111
107
|
}
|
|
112
108
|
|
|
@@ -117,7 +113,6 @@ export function createNodeFromContent(
|
|
|
117
113
|
}
|
|
118
114
|
|
|
119
115
|
return parser.parse(elementFromString(content), options.parseOptions)
|
|
120
|
-
|
|
121
116
|
}
|
|
122
117
|
|
|
123
118
|
return createNodeFromContent('', schema, options)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Node as ProseMirrorNode } from '@tiptap/pm/model'
|
|
1
|
+
import type { Node as ProseMirrorNode } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { NodeWithPos, Predicate } from '../types.js'
|
|
3
|
+
import type { NodeWithPos, Predicate } from '../types.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Find children inside a Prosemirror node that match a predicate.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Node as ProseMirrorNode } from '@tiptap/pm/model'
|
|
1
|
+
import type { Node as ProseMirrorNode } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { NodeWithPos, Predicate, Range } from '../types.js'
|
|
3
|
+
import type { NodeWithPos, Predicate, Range } from '../types.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Same as `findChildren` but searches only within a `range`.
|
|
@@ -9,11 +9,7 @@ import { NodeWithPos, Predicate, Range } from '../types.js'
|
|
|
9
9
|
* @param predicate The predicate to match
|
|
10
10
|
* @returns An array of nodes with their positions
|
|
11
11
|
*/
|
|
12
|
-
export function findChildrenInRange(
|
|
13
|
-
node: ProseMirrorNode,
|
|
14
|
-
range: Range,
|
|
15
|
-
predicate: Predicate,
|
|
16
|
-
): NodeWithPos[] {
|
|
12
|
+
export function findChildrenInRange(node: ProseMirrorNode, range: Range, predicate: Predicate): NodeWithPos[] {
|
|
17
13
|
const nodesWithPos: NodeWithPos[] = []
|
|
18
14
|
|
|
19
15
|
// if (range.from === range.to) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Selection } from '@tiptap/pm/state'
|
|
1
|
+
import type { Selection } from '@tiptap/pm/state'
|
|
2
2
|
|
|
3
|
-
import { Predicate } from '../types.js'
|
|
3
|
+
import type { Predicate } from '../types.js'
|
|
4
4
|
import { findParentNodeClosestToPos } from './findParentNodeClosestToPos.js'
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -11,6 +11,8 @@ import { findParentNodeClosestToPos } from './findParentNodeClosestToPos.js'
|
|
|
11
11
|
* findParentNode(node => node.type.name === 'paragraph')
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
export function findParentNode(
|
|
14
|
+
export function findParentNode(
|
|
15
|
+
predicate: Predicate,
|
|
16
|
+
): (selection: Selection) => ReturnType<typeof findParentNodeClosestToPos> {
|
|
15
17
|
return (selection: Selection) => findParentNodeClosestToPos(selection.$from, predicate)
|
|
16
18
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Node as ProseMirrorNode, ResolvedPos } from '@tiptap/pm/model'
|
|
1
|
+
import type { Node as ProseMirrorNode, ResolvedPos } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { Predicate } from '../types.js'
|
|
3
|
+
import type { Predicate } from '../types.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Finds the closest parent node to a resolved position that matches a predicate.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AnyConfig, Extensions } from '../types.js'
|
|
2
|
+
import { getExtensionField } from './getExtensionField.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Create a flattened array of extensions by traversing the `addExtensions` field.
|
|
6
|
+
* @param extensions An array of Tiptap extensions
|
|
7
|
+
* @returns A flattened array of Tiptap extensions
|
|
8
|
+
*/
|
|
9
|
+
export function flattenExtensions(extensions: Extensions): Extensions {
|
|
10
|
+
return (
|
|
11
|
+
extensions
|
|
12
|
+
.map(extension => {
|
|
13
|
+
const context = {
|
|
14
|
+
name: extension.name,
|
|
15
|
+
options: extension.options,
|
|
16
|
+
storage: extension.storage,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const addExtensions = getExtensionField<AnyConfig['addExtensions']>(extension, 'addExtensions', context)
|
|
20
|
+
|
|
21
|
+
if (addExtensions) {
|
|
22
|
+
return [extension, ...flattenExtensions(addExtensions())]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return extension
|
|
26
|
+
})
|
|
27
|
+
// `Infinity` will break TypeScript so we set a number that is probably high enough
|
|
28
|
+
.flat(10)
|
|
29
|
+
)
|
|
30
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Node } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { Extensions, JSONContent } from '../types.js'
|
|
3
|
+
import type { Extensions, JSONContent } from '../types.js'
|
|
4
4
|
import { getHTMLFromFragment } from './getHTMLFromFragment.js'
|
|
5
5
|
import { getSchema } from './getSchema.js'
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Node } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { Extensions, JSONContent, TextSerializer } from '../types.js'
|
|
3
|
+
import type { Extensions, JSONContent, TextSerializer } from '../types.js'
|
|
4
4
|
import { getSchema } from './getSchema.js'
|
|
5
5
|
import { getText } from './getText.js'
|
|
6
6
|
import { getTextSerializersFromSchema } from './getTextSerializersFromSchema.js'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MarkType, NodeType } from '@tiptap/pm/model'
|
|
2
|
-
import { EditorState } from '@tiptap/pm/state'
|
|
1
|
+
import type { MarkType, NodeType } from '@tiptap/pm/model'
|
|
2
|
+
import type { EditorState } from '@tiptap/pm/state'
|
|
3
3
|
|
|
4
4
|
import { getMarkAttributes } from './getMarkAttributes.js'
|
|
5
5
|
import { getNodeAttributes } from './getNodeAttributes.js'
|
|
@@ -11,10 +11,7 @@ import { getSchemaTypeNameByName } from './getSchemaTypeNameByName.js'
|
|
|
11
11
|
* @param typeOrName The node or mark type or name
|
|
12
12
|
* @returns The attributes of the node or mark or an empty object
|
|
13
13
|
*/
|
|
14
|
-
export function getAttributes(
|
|
15
|
-
state: EditorState,
|
|
16
|
-
typeOrName: string | NodeType | MarkType,
|
|
17
|
-
): Record<string, any> {
|
|
14
|
+
export function getAttributes(state: EditorState, typeOrName: string | NodeType | MarkType): Record<string, any> {
|
|
18
15
|
const schemaType = getSchemaTypeNameByName(
|
|
19
16
|
typeof typeOrName === 'string' ? typeOrName : typeOrName.name,
|
|
20
17
|
state.schema,
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import { MarkConfig, NodeConfig } from '../index.js'
|
|
2
|
-
import {
|
|
3
|
-
AnyConfig,
|
|
4
|
-
Attribute,
|
|
5
|
-
Attributes,
|
|
6
|
-
ExtensionAttribute,
|
|
7
|
-
Extensions,
|
|
8
|
-
} from '../types.js'
|
|
1
|
+
import type { MarkConfig, NodeConfig } from '../index.js'
|
|
2
|
+
import type { AnyConfig, Attribute, Attributes, ExtensionAttribute, Extensions } from '../types.js'
|
|
9
3
|
import { getExtensionField } from './getExtensionField.js'
|
|
10
4
|
import { splitExtensions } from './splitExtensions.js'
|
|
11
5
|
|
|
@@ -17,8 +11,9 @@ export function getAttributesFromExtensions(extensions: Extensions): ExtensionAt
|
|
|
17
11
|
const extensionAttributes: ExtensionAttribute[] = []
|
|
18
12
|
const { nodeExtensions, markExtensions } = splitExtensions(extensions)
|
|
19
13
|
const nodeAndMarkExtensions = [...nodeExtensions, ...markExtensions]
|
|
20
|
-
const defaultAttribute: Required<Attribute> = {
|
|
14
|
+
const defaultAttribute: Required<Omit<Attribute, 'validate'>> & Pick<Attribute, 'validate'> = {
|
|
21
15
|
default: null,
|
|
16
|
+
validate: undefined,
|
|
22
17
|
rendered: true,
|
|
23
18
|
renderHTML: null,
|
|
24
19
|
parseHTML: null,
|
|
@@ -48,18 +43,16 @@ export function getAttributesFromExtensions(extensions: Extensions): ExtensionAt
|
|
|
48
43
|
|
|
49
44
|
globalAttributes.forEach(globalAttribute => {
|
|
50
45
|
globalAttribute.types.forEach(type => {
|
|
51
|
-
Object
|
|
52
|
-
.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
attribute
|
|
58
|
-
|
|
59
|
-
...attribute,
|
|
60
|
-
},
|
|
61
|
-
})
|
|
46
|
+
Object.entries(globalAttribute.attributes).forEach(([name, attribute]) => {
|
|
47
|
+
extensionAttributes.push({
|
|
48
|
+
type,
|
|
49
|
+
name,
|
|
50
|
+
attribute: {
|
|
51
|
+
...defaultAttribute,
|
|
52
|
+
...attribute,
|
|
53
|
+
},
|
|
62
54
|
})
|
|
55
|
+
})
|
|
63
56
|
})
|
|
64
57
|
})
|
|
65
58
|
})
|
|
@@ -84,28 +77,26 @@ export function getAttributesFromExtensions(extensions: Extensions): ExtensionAt
|
|
|
84
77
|
// TODO: remove `as Attributes`
|
|
85
78
|
const attributes = addAttributes() as Attributes
|
|
86
79
|
|
|
87
|
-
Object
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
...attribute,
|
|
93
|
-
}
|
|
80
|
+
Object.entries(attributes).forEach(([name, attribute]) => {
|
|
81
|
+
const mergedAttr = {
|
|
82
|
+
...defaultAttribute,
|
|
83
|
+
...attribute,
|
|
84
|
+
}
|
|
94
85
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
86
|
+
if (typeof mergedAttr?.default === 'function') {
|
|
87
|
+
mergedAttr.default = mergedAttr.default()
|
|
88
|
+
}
|
|
98
89
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
90
|
+
if (mergedAttr?.isRequired && mergedAttr?.default === undefined) {
|
|
91
|
+
delete mergedAttr.default
|
|
92
|
+
}
|
|
102
93
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
})
|
|
94
|
+
extensionAttributes.push({
|
|
95
|
+
type: extension.name,
|
|
96
|
+
name,
|
|
97
|
+
attribute: mergedAttr,
|
|
108
98
|
})
|
|
99
|
+
})
|
|
109
100
|
})
|
|
110
101
|
|
|
111
102
|
return extensionAttributes
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Step, Transform } from '@tiptap/pm/transform'
|
|
1
|
+
import type { Step, Transform } from '@tiptap/pm/transform'
|
|
2
2
|
|
|
3
|
-
import { Range } from '../types.js'
|
|
3
|
+
import type { Range } from '../types.js'
|
|
4
4
|
import { removeDuplicates } from '../utilities/removeDuplicates.js'
|
|
5
5
|
|
|
6
6
|
export type ChangedRange = {
|
|
7
|
-
oldRange: Range
|
|
8
|
-
newRange: Range
|
|
7
|
+
oldRange: Range
|
|
8
|
+
newRange: Range
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -18,15 +18,17 @@ function simplifyChangedRanges(changes: ChangedRange[]): ChangedRange[] {
|
|
|
18
18
|
return uniqueChanges.length === 1
|
|
19
19
|
? uniqueChanges
|
|
20
20
|
: uniqueChanges.filter((change, index) => {
|
|
21
|
-
|
|
21
|
+
const rest = uniqueChanges.filter((_, i) => i !== index)
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
return !rest.some(otherChange => {
|
|
24
|
+
return (
|
|
25
|
+
change.oldRange.from >= otherChange.oldRange.from &&
|
|
26
|
+
change.oldRange.to <= otherChange.oldRange.to &&
|
|
27
|
+
change.newRange.from >= otherChange.newRange.from &&
|
|
28
|
+
change.newRange.to <= otherChange.newRange.to
|
|
29
|
+
)
|
|
30
|
+
})
|
|
28
31
|
})
|
|
29
|
-
})
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
/**
|
|
@@ -45,8 +47,8 @@ export function getChangedRanges(transform: Transform): ChangedRange[] {
|
|
|
45
47
|
// @ts-ignore
|
|
46
48
|
if (!stepMap.ranges.length) {
|
|
47
49
|
const { from, to } = steps[index] as Step & {
|
|
48
|
-
from?: number
|
|
49
|
-
to?: number
|
|
50
|
+
from?: number
|
|
51
|
+
to?: number
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
if (from === undefined || to === undefined) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Node as ProseMirrorNode } from '@tiptap/pm/model'
|
|
1
|
+
import type { Node as ProseMirrorNode } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { JSONContent } from '../types.js'
|
|
3
|
+
import type { JSONContent } from '../types.js'
|
|
4
4
|
|
|
5
5
|
interface DebugJSONContent extends JSONContent {
|
|
6
6
|
from: number
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ExtensionConfig } from '../Extension.js'
|
|
2
|
+
import type { MarkConfig } from '../Mark.js'
|
|
3
|
+
import type { NodeConfig } from '../Node.js'
|
|
4
|
+
import type { AnyExtension, MaybeThisParameterType, RemoveThis } from '../types.js'
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* Returns a field from an extension
|
|
@@ -7,26 +10,23 @@ import { AnyExtension, MaybeThisParameterType, RemoveThis } from '../types.js'
|
|
|
7
10
|
* @param context The context object that should be passed as `this` into the function
|
|
8
11
|
* @returns The field value
|
|
9
12
|
*/
|
|
10
|
-
export function getExtensionField<T = any>(
|
|
11
|
-
extension:
|
|
12
|
-
field:
|
|
13
|
+
export function getExtensionField<T = any, E extends AnyExtension = any>(
|
|
14
|
+
extension: E,
|
|
15
|
+
field: keyof ExtensionConfig | keyof MarkConfig | keyof NodeConfig,
|
|
13
16
|
context?: Omit<MaybeThisParameterType<T>, 'parent'>,
|
|
14
17
|
): RemoveThis<T> {
|
|
15
|
-
|
|
16
|
-
if (extension.config[field] === undefined && extension.parent) {
|
|
18
|
+
if (extension.config[field as keyof typeof extension.config] === undefined && extension.parent) {
|
|
17
19
|
return getExtensionField(extension.parent, field, context)
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
if (typeof extension.config[field] === 'function') {
|
|
21
|
-
const value = extension.config[field].bind({
|
|
22
|
+
if (typeof extension.config[field as keyof typeof extension.config] === 'function') {
|
|
23
|
+
const value = (extension.config[field as keyof typeof extension.config] as any).bind({
|
|
22
24
|
...context,
|
|
23
|
-
parent: extension.parent
|
|
24
|
-
? getExtensionField(extension.parent, field, context)
|
|
25
|
-
: null,
|
|
25
|
+
parent: extension.parent ? getExtensionField(extension.parent, field, context) : null,
|
|
26
26
|
})
|
|
27
27
|
|
|
28
28
|
return value
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
return extension.config[field]
|
|
31
|
+
return extension.config[field as keyof typeof extension.config] as RemoveThis<T>
|
|
32
32
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Fragment, Schema } from '@tiptap/pm/model'
|
|
2
|
+
import { DOMSerializer } from '@tiptap/pm/model'
|
|
2
3
|
|
|
3
4
|
export function getHTMLFromFragment(fragment: Fragment, schema: Schema): string {
|
|
4
5
|
const documentFragment = DOMSerializer.fromSchema(schema).serializeFragment(fragment)
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { Mark, MarkType } from '@tiptap/pm/model'
|
|
2
|
-
import { EditorState } from '@tiptap/pm/state'
|
|
1
|
+
import type { Mark, MarkType } from '@tiptap/pm/model'
|
|
2
|
+
import type { EditorState } from '@tiptap/pm/state'
|
|
3
3
|
|
|
4
4
|
import { getMarkType } from './getMarkType.js'
|
|
5
5
|
|
|
6
|
-
export function getMarkAttributes(
|
|
7
|
-
state: EditorState,
|
|
8
|
-
typeOrName: string | MarkType,
|
|
9
|
-
): Record<string, any> {
|
|
6
|
+
export function getMarkAttributes(state: EditorState, typeOrName: string | MarkType): Record<string, any> {
|
|
10
7
|
const type = getMarkType(typeOrName, state.schema)
|
|
11
8
|
const { from, to, empty } = state.selection
|
|
12
9
|
const marks: Mark[] = []
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Mark as ProseMirrorMark, MarkType, ResolvedPos } from '@tiptap/pm/model'
|
|
1
|
+
import type { Mark as ProseMirrorMark, MarkType, ResolvedPos } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { Range } from '../types.js'
|
|
3
|
+
import type { Range } from '../types.js'
|
|
4
4
|
import { objectIncludes } from '../utilities/objectIncludes.js'
|
|
5
5
|
|
|
6
6
|
function findMarkInSet(
|
|
@@ -10,8 +10,8 @@ function findMarkInSet(
|
|
|
10
10
|
): ProseMirrorMark | undefined {
|
|
11
11
|
return marks.find(item => {
|
|
12
12
|
return (
|
|
13
|
-
item.type === type
|
|
14
|
-
|
|
13
|
+
item.type === type &&
|
|
14
|
+
objectIncludes(
|
|
15
15
|
// Only check equality for the attributes that are provided
|
|
16
16
|
Object.fromEntries(Object.keys(attributes).map(k => [k, item.attrs[k]])),
|
|
17
17
|
attributes,
|
|
@@ -20,11 +20,7 @@ function findMarkInSet(
|
|
|
20
20
|
})
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
function isMarkInSet(
|
|
24
|
-
marks: ProseMirrorMark[],
|
|
25
|
-
type: MarkType,
|
|
26
|
-
attributes: Record<string, any> = {},
|
|
27
|
-
): boolean {
|
|
23
|
+
function isMarkInSet(marks: ProseMirrorMark[], type: MarkType, attributes: Record<string, any> = {}): boolean {
|
|
28
24
|
return !!findMarkInSet(marks, type, attributes)
|
|
29
25
|
}
|
|
30
26
|
|
|
@@ -77,18 +73,12 @@ export function getMarkRange(
|
|
|
77
73
|
let endIndex = startIndex + 1
|
|
78
74
|
let endPos = startPos + start.node.nodeSize
|
|
79
75
|
|
|
80
|
-
while (
|
|
81
|
-
startIndex > 0
|
|
82
|
-
&& isMarkInSet([...$pos.parent.child(startIndex - 1).marks], type, attributes)
|
|
83
|
-
) {
|
|
76
|
+
while (startIndex > 0 && isMarkInSet([...$pos.parent.child(startIndex - 1).marks], type, attributes)) {
|
|
84
77
|
startIndex -= 1
|
|
85
78
|
startPos -= $pos.parent.child(startIndex).nodeSize
|
|
86
79
|
}
|
|
87
80
|
|
|
88
|
-
while (
|
|
89
|
-
endIndex < $pos.parent.childCount
|
|
90
|
-
&& isMarkInSet([...$pos.parent.child(endIndex).marks], type, attributes)
|
|
91
|
-
) {
|
|
81
|
+
while (endIndex < $pos.parent.childCount && isMarkInSet([...$pos.parent.child(endIndex).marks], type, attributes)) {
|
|
92
82
|
endPos += $pos.parent.child(endIndex).nodeSize
|
|
93
83
|
endIndex += 1
|
|
94
84
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { MarkType, Schema } from '@tiptap/pm/model'
|
|
1
|
+
import type { MarkType, Schema } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
3
|
export function getMarkType(nameOrType: string | MarkType, schema: Schema): MarkType {
|
|
4
4
|
if (typeof nameOrType === 'string') {
|
|
5
5
|
if (!schema.marks[nameOrType]) {
|
|
6
|
-
throw Error(
|
|
7
|
-
`There is no mark type named '${nameOrType}'. Maybe you forgot to add the extension?`,
|
|
8
|
-
)
|
|
6
|
+
throw Error(`There is no mark type named '${nameOrType}'. Maybe you forgot to add the extension?`)
|
|
9
7
|
}
|
|
10
8
|
|
|
11
9
|
return schema.marks[nameOrType]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Node as ProseMirrorNode } from '@tiptap/pm/model'
|
|
1
|
+
import type { Node as ProseMirrorNode } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { MarkRange } from '../types.js'
|
|
3
|
+
import type { MarkRange } from '../types.js'
|
|
4
4
|
import { getMarkRange } from './getMarkRange.js'
|
|
5
5
|
|
|
6
6
|
export function getMarksBetween(from: number, to: number, doc: ProseMirrorNode): MarkRange[] {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Node, NodeType } from '@tiptap/pm/model'
|
|
2
|
-
import { EditorState } from '@tiptap/pm/state'
|
|
1
|
+
import type { Node, NodeType } from '@tiptap/pm/model'
|
|
2
|
+
import type { EditorState } from '@tiptap/pm/state'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Finds the first node of a given type or name in the current selection.
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { Node, NodeType } from '@tiptap/pm/model'
|
|
2
|
-
import { EditorState } from '@tiptap/pm/state'
|
|
1
|
+
import type { Node, NodeType } from '@tiptap/pm/model'
|
|
2
|
+
import type { EditorState } from '@tiptap/pm/state'
|
|
3
3
|
|
|
4
4
|
import { getNodeType } from './getNodeType.js'
|
|
5
5
|
|
|
6
|
-
export function getNodeAttributes(
|
|
7
|
-
state: EditorState,
|
|
8
|
-
typeOrName: string | NodeType,
|
|
9
|
-
): Record<string, any> {
|
|
6
|
+
export function getNodeAttributes(state: EditorState, typeOrName: string | NodeType): Record<string, any> {
|
|
10
7
|
const type = getNodeType(typeOrName, state.schema)
|
|
11
8
|
const { from, to } = state.selection
|
|
12
9
|
const nodes: Node[] = []
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { NodeType, Schema } from '@tiptap/pm/model'
|
|
1
|
+
import type { NodeType, Schema } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
3
|
export function getNodeType(nameOrType: string | NodeType, schema: Schema): NodeType {
|
|
4
4
|
if (typeof nameOrType === 'string') {
|
|
5
5
|
if (!schema.nodes[nameOrType]) {
|
|
6
|
-
throw Error(
|
|
7
|
-
`There is no node type named '${nameOrType}'. Maybe you forgot to add the extension?`,
|
|
8
|
-
)
|
|
6
|
+
throw Error(`There is no node type named '${nameOrType}'. Maybe you forgot to add the extension?`)
|
|
9
7
|
}
|
|
10
8
|
|
|
11
9
|
return schema.nodes[nameOrType]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Mark, Node } from '@tiptap/pm/model'
|
|
1
|
+
import type { Mark, Node } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { ExtensionAttribute } from '../types.js'
|
|
3
|
+
import type { ExtensionAttribute } from '../types.js'
|
|
4
4
|
import { mergeAttributes } from '../utilities/mergeAttributes.js'
|
|
5
5
|
|
|
6
6
|
export function getRenderedAttributes(
|
|
@@ -8,9 +8,7 @@ export function getRenderedAttributes(
|
|
|
8
8
|
extensionAttributes: ExtensionAttribute[],
|
|
9
9
|
): Record<string, any> {
|
|
10
10
|
return extensionAttributes
|
|
11
|
-
.filter(
|
|
12
|
-
attribute => attribute.type === nodeOrMark.type.name,
|
|
13
|
-
)
|
|
11
|
+
.filter(attribute => attribute.type === nodeOrMark.type.name)
|
|
14
12
|
.filter(item => item.attribute.rendered)
|
|
15
13
|
.map(item => {
|
|
16
14
|
if (!item.attribute.renderHTML) {
|
package/src/helpers/getSchema.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Schema } from '@tiptap/pm/model'
|
|
1
|
+
import type { Schema } from '@tiptap/pm/model'
|
|
2
2
|
|
|
3
|
-
import { Editor } from '../Editor.js'
|
|
4
|
-
import {
|
|
5
|
-
import { Extensions } from '../types.js'
|
|
3
|
+
import type { Editor } from '../Editor.js'
|
|
4
|
+
import type { Extensions } from '../types.js'
|
|
6
5
|
import { getSchemaByResolvedExtensions } from './getSchemaByResolvedExtensions.js'
|
|
6
|
+
import { resolveExtensions } from './resolveExtensions.js'
|
|
7
7
|
|
|
8
8
|
export function getSchema(extensions: Extensions, editor?: Editor): Schema {
|
|
9
|
-
const resolvedExtensions =
|
|
9
|
+
const resolvedExtensions = resolveExtensions(extensions)
|
|
10
10
|
|
|
11
11
|
return getSchemaByResolvedExtensions(resolvedExtensions, editor)
|
|
12
12
|
}
|