@tiptap/core 3.0.0 → 3.0.2
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
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,3356 @@
|
|
|
1
|
+
import { Transaction, EditorState, Plugin, Selection, NodeSelection, TextSelection, PluginKey } from '@tiptap/pm/state';
|
|
2
|
+
import { Node as Node$1, MarkType as MarkType$1, MarkSpec, Mark as Mark$1, DOMOutputSpec, NodeType as NodeType$1, NodeSpec, Slice, ParseOptions, Fragment as Fragment$1, Schema, ContentMatch, ResolvedPos, ParseRule } from '@tiptap/pm/model';
|
|
3
|
+
import { EditorProps, EditorView, Decoration, DecorationAttrs, ViewMutationRecord, NodeViewConstructor, NodeView as NodeView$1, MarkViewConstructor, MarkView as MarkView$1 } from '@tiptap/pm/view';
|
|
4
|
+
import { Transform, Mappable } from '@tiptap/pm/transform';
|
|
5
|
+
|
|
6
|
+
type StringKeyOf<T> = Extract<keyof T, string>;
|
|
7
|
+
type CallbackType<T extends Record<string, any>, EventName extends StringKeyOf<T>> = T[EventName] extends any[] ? T[EventName] : [T[EventName]];
|
|
8
|
+
type CallbackFunction<T extends Record<string, any>, EventName extends StringKeyOf<T>> = (...props: CallbackType<T, EventName>) => any;
|
|
9
|
+
declare class EventEmitter<T extends Record<string, any>> {
|
|
10
|
+
private callbacks;
|
|
11
|
+
on<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this;
|
|
12
|
+
emit<EventName extends StringKeyOf<T>>(event: EventName, ...args: CallbackType<T, EventName>): this;
|
|
13
|
+
off<EventName extends StringKeyOf<T>>(event: EventName, fn?: CallbackFunction<T, EventName>): this;
|
|
14
|
+
once<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this;
|
|
15
|
+
removeAllListeners(): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Returns a new `Transform` based on all steps of the passed transactions.
|
|
20
|
+
* @param oldDoc The Prosemirror node to start from
|
|
21
|
+
* @param transactions The transactions to combine
|
|
22
|
+
* @returns A new `Transform` with all steps of the passed transactions
|
|
23
|
+
*/
|
|
24
|
+
declare function combineTransactionSteps(oldDoc: Node$1, transactions: Transaction[]): Transform;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Takes a Transaction & Editor State and turns it into a chainable state object
|
|
28
|
+
* @param config The transaction and state to create the chainable state from
|
|
29
|
+
* @returns A chainable Editor state object
|
|
30
|
+
*/
|
|
31
|
+
declare function createChainableState(config: {
|
|
32
|
+
transaction: Transaction;
|
|
33
|
+
state: EditorState;
|
|
34
|
+
}): EditorState;
|
|
35
|
+
|
|
36
|
+
type InputRuleMatch = {
|
|
37
|
+
index: number;
|
|
38
|
+
text: string;
|
|
39
|
+
replaceWith?: string;
|
|
40
|
+
match?: RegExpMatchArray;
|
|
41
|
+
data?: Record<string, any>;
|
|
42
|
+
};
|
|
43
|
+
type InputRuleFinder = RegExp | ((text: string) => InputRuleMatch | null);
|
|
44
|
+
declare class InputRule {
|
|
45
|
+
find: InputRuleFinder;
|
|
46
|
+
handler: (props: {
|
|
47
|
+
state: EditorState;
|
|
48
|
+
range: Range;
|
|
49
|
+
match: ExtendedRegExpMatchArray;
|
|
50
|
+
commands: SingleCommands;
|
|
51
|
+
chain: () => ChainedCommands;
|
|
52
|
+
can: () => CanCommands;
|
|
53
|
+
}) => void | null;
|
|
54
|
+
constructor(config: {
|
|
55
|
+
find: InputRuleFinder;
|
|
56
|
+
handler: (props: {
|
|
57
|
+
state: EditorState;
|
|
58
|
+
range: Range;
|
|
59
|
+
match: ExtendedRegExpMatchArray;
|
|
60
|
+
commands: SingleCommands;
|
|
61
|
+
chain: () => ChainedCommands;
|
|
62
|
+
can: () => CanCommands;
|
|
63
|
+
}) => void | null;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Create an input rules plugin. When enabled, it will cause text
|
|
68
|
+
* input that matches any of the given rules to trigger the rule’s
|
|
69
|
+
* action.
|
|
70
|
+
*/
|
|
71
|
+
declare function inputRulesPlugin(props: {
|
|
72
|
+
editor: Editor;
|
|
73
|
+
rules: InputRule[];
|
|
74
|
+
}): Plugin;
|
|
75
|
+
|
|
76
|
+
interface MarkConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, MarkConfig<Options, Storage>, MarkType$1> {
|
|
77
|
+
/**
|
|
78
|
+
* Mark View
|
|
79
|
+
*/
|
|
80
|
+
addMarkView?: ((this: {
|
|
81
|
+
name: string;
|
|
82
|
+
options: Options;
|
|
83
|
+
storage: Storage;
|
|
84
|
+
editor: Editor;
|
|
85
|
+
type: MarkType$1;
|
|
86
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['addMarkView'];
|
|
87
|
+
}) => MarkViewRenderer) | null;
|
|
88
|
+
/**
|
|
89
|
+
* Keep mark after split node
|
|
90
|
+
*/
|
|
91
|
+
keepOnSplit?: boolean | (() => boolean);
|
|
92
|
+
/**
|
|
93
|
+
* Inclusive
|
|
94
|
+
*/
|
|
95
|
+
inclusive?: MarkSpec['inclusive'] | ((this: {
|
|
96
|
+
name: string;
|
|
97
|
+
options: Options;
|
|
98
|
+
storage: Storage;
|
|
99
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['inclusive'];
|
|
100
|
+
editor?: Editor;
|
|
101
|
+
}) => MarkSpec['inclusive']);
|
|
102
|
+
/**
|
|
103
|
+
* Excludes
|
|
104
|
+
*/
|
|
105
|
+
excludes?: MarkSpec['excludes'] | ((this: {
|
|
106
|
+
name: string;
|
|
107
|
+
options: Options;
|
|
108
|
+
storage: Storage;
|
|
109
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['excludes'];
|
|
110
|
+
editor?: Editor;
|
|
111
|
+
}) => MarkSpec['excludes']);
|
|
112
|
+
/**
|
|
113
|
+
* Marks this Mark as exitable
|
|
114
|
+
*/
|
|
115
|
+
exitable?: boolean | (() => boolean);
|
|
116
|
+
/**
|
|
117
|
+
* Group
|
|
118
|
+
*/
|
|
119
|
+
group?: MarkSpec['group'] | ((this: {
|
|
120
|
+
name: string;
|
|
121
|
+
options: Options;
|
|
122
|
+
storage: Storage;
|
|
123
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['group'];
|
|
124
|
+
editor?: Editor;
|
|
125
|
+
}) => MarkSpec['group']);
|
|
126
|
+
/**
|
|
127
|
+
* Spanning
|
|
128
|
+
*/
|
|
129
|
+
spanning?: MarkSpec['spanning'] | ((this: {
|
|
130
|
+
name: string;
|
|
131
|
+
options: Options;
|
|
132
|
+
storage: Storage;
|
|
133
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['spanning'];
|
|
134
|
+
editor?: Editor;
|
|
135
|
+
}) => MarkSpec['spanning']);
|
|
136
|
+
/**
|
|
137
|
+
* Code
|
|
138
|
+
*/
|
|
139
|
+
code?: boolean | ((this: {
|
|
140
|
+
name: string;
|
|
141
|
+
options: Options;
|
|
142
|
+
storage: Storage;
|
|
143
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['code'];
|
|
144
|
+
editor?: Editor;
|
|
145
|
+
}) => boolean);
|
|
146
|
+
/**
|
|
147
|
+
* Parse HTML
|
|
148
|
+
*/
|
|
149
|
+
parseHTML?: (this: {
|
|
150
|
+
name: string;
|
|
151
|
+
options: Options;
|
|
152
|
+
storage: Storage;
|
|
153
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['parseHTML'];
|
|
154
|
+
editor?: Editor;
|
|
155
|
+
}) => MarkSpec['parseDOM'];
|
|
156
|
+
/**
|
|
157
|
+
* Render HTML
|
|
158
|
+
*/
|
|
159
|
+
renderHTML?: ((this: {
|
|
160
|
+
name: string;
|
|
161
|
+
options: Options;
|
|
162
|
+
storage: Storage;
|
|
163
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['renderHTML'];
|
|
164
|
+
editor?: Editor;
|
|
165
|
+
}, props: {
|
|
166
|
+
mark: Mark$1;
|
|
167
|
+
HTMLAttributes: Record<string, any>;
|
|
168
|
+
}) => DOMOutputSpec) | null;
|
|
169
|
+
/**
|
|
170
|
+
* Attributes
|
|
171
|
+
*/
|
|
172
|
+
addAttributes?: (this: {
|
|
173
|
+
name: string;
|
|
174
|
+
options: Options;
|
|
175
|
+
storage: Storage;
|
|
176
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['addAttributes'];
|
|
177
|
+
editor?: Editor;
|
|
178
|
+
}) => Attributes$1 | {};
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The Mark class is used to create custom mark extensions.
|
|
182
|
+
* @see https://tiptap.dev/api/extensions#create-a-new-extension
|
|
183
|
+
*/
|
|
184
|
+
declare class Mark<Options = any, Storage = any> extends Extendable<Options, Storage, MarkConfig<Options, Storage>> {
|
|
185
|
+
type: string;
|
|
186
|
+
/**
|
|
187
|
+
* Create a new Mark instance
|
|
188
|
+
* @param config - Mark configuration object or a function that returns a configuration object
|
|
189
|
+
*/
|
|
190
|
+
static create<O = any, S = any>(config?: Partial<MarkConfig<O, S>> | (() => Partial<MarkConfig<O, S>>)): Mark<O, S>;
|
|
191
|
+
static handleExit({ editor, mark }: {
|
|
192
|
+
editor: Editor;
|
|
193
|
+
mark: Mark;
|
|
194
|
+
}): boolean;
|
|
195
|
+
configure(options?: Partial<Options>): Mark<Options, Storage>;
|
|
196
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = MarkConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)): Mark<ExtendedOptions, ExtendedStorage>;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
interface NodeConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, NodeConfig<Options, Storage>, NodeType$1> {
|
|
200
|
+
/**
|
|
201
|
+
* Node View
|
|
202
|
+
*/
|
|
203
|
+
addNodeView?: ((this: {
|
|
204
|
+
name: string;
|
|
205
|
+
options: Options;
|
|
206
|
+
storage: Storage;
|
|
207
|
+
editor: Editor;
|
|
208
|
+
type: NodeType$1;
|
|
209
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addNodeView'];
|
|
210
|
+
}) => NodeViewRenderer) | null;
|
|
211
|
+
/**
|
|
212
|
+
* Defines if this node should be a top level node (doc)
|
|
213
|
+
* @default false
|
|
214
|
+
* @example true
|
|
215
|
+
*/
|
|
216
|
+
topNode?: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* The content expression for this node, as described in the [schema
|
|
219
|
+
* guide](/docs/guide/#schema.content_expressions). When not given,
|
|
220
|
+
* the node does not allow any content.
|
|
221
|
+
*
|
|
222
|
+
* You can read more about it on the Prosemirror documentation here
|
|
223
|
+
* @see https://prosemirror.net/docs/guide/#schema.content_expressions
|
|
224
|
+
* @default undefined
|
|
225
|
+
* @example content: 'block+'
|
|
226
|
+
* @example content: 'headline paragraph block*'
|
|
227
|
+
*/
|
|
228
|
+
content?: NodeSpec['content'] | ((this: {
|
|
229
|
+
name: string;
|
|
230
|
+
options: Options;
|
|
231
|
+
storage: Storage;
|
|
232
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['content'];
|
|
233
|
+
editor?: Editor;
|
|
234
|
+
}) => NodeSpec['content']);
|
|
235
|
+
/**
|
|
236
|
+
* The marks that are allowed inside of this node. May be a
|
|
237
|
+
* space-separated string referring to mark names or groups, `"_"`
|
|
238
|
+
* to explicitly allow all marks, or `""` to disallow marks. When
|
|
239
|
+
* not given, nodes with inline content default to allowing all
|
|
240
|
+
* marks, other nodes default to not allowing marks.
|
|
241
|
+
*
|
|
242
|
+
* @example marks: 'strong em'
|
|
243
|
+
*/
|
|
244
|
+
marks?: NodeSpec['marks'] | ((this: {
|
|
245
|
+
name: string;
|
|
246
|
+
options: Options;
|
|
247
|
+
storage: Storage;
|
|
248
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['marks'];
|
|
249
|
+
editor?: Editor;
|
|
250
|
+
}) => NodeSpec['marks']);
|
|
251
|
+
/**
|
|
252
|
+
* The group or space-separated groups to which this node belongs,
|
|
253
|
+
* which can be referred to in the content expressions for the
|
|
254
|
+
* schema.
|
|
255
|
+
*
|
|
256
|
+
* By default Tiptap uses the groups 'block' and 'inline' for nodes. You
|
|
257
|
+
* can also use custom groups if you want to group specific nodes together
|
|
258
|
+
* and handle them in your schema.
|
|
259
|
+
* @example group: 'block'
|
|
260
|
+
* @example group: 'inline'
|
|
261
|
+
* @example group: 'customBlock' // this uses a custom group
|
|
262
|
+
*/
|
|
263
|
+
group?: NodeSpec['group'] | ((this: {
|
|
264
|
+
name: string;
|
|
265
|
+
options: Options;
|
|
266
|
+
storage: Storage;
|
|
267
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['group'];
|
|
268
|
+
editor?: Editor;
|
|
269
|
+
}) => NodeSpec['group']);
|
|
270
|
+
/**
|
|
271
|
+
* Should be set to true for inline nodes. (Implied for text nodes.)
|
|
272
|
+
*/
|
|
273
|
+
inline?: NodeSpec['inline'] | ((this: {
|
|
274
|
+
name: string;
|
|
275
|
+
options: Options;
|
|
276
|
+
storage: Storage;
|
|
277
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['inline'];
|
|
278
|
+
editor?: Editor;
|
|
279
|
+
}) => NodeSpec['inline']);
|
|
280
|
+
/**
|
|
281
|
+
* Can be set to true to indicate that, though this isn't a [leaf
|
|
282
|
+
* node](https://prosemirror.net/docs/ref/#model.NodeType.isLeaf), it doesn't have directly editable
|
|
283
|
+
* content and should be treated as a single unit in the view.
|
|
284
|
+
*
|
|
285
|
+
* @example atom: true
|
|
286
|
+
*/
|
|
287
|
+
atom?: NodeSpec['atom'] | ((this: {
|
|
288
|
+
name: string;
|
|
289
|
+
options: Options;
|
|
290
|
+
storage: Storage;
|
|
291
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['atom'];
|
|
292
|
+
editor?: Editor;
|
|
293
|
+
}) => NodeSpec['atom']);
|
|
294
|
+
/**
|
|
295
|
+
* Controls whether nodes of this type can be selected as a [node
|
|
296
|
+
* selection](https://prosemirror.net/docs/ref/#state.NodeSelection). Defaults to true for non-text
|
|
297
|
+
* nodes.
|
|
298
|
+
*
|
|
299
|
+
* @default true
|
|
300
|
+
* @example selectable: false
|
|
301
|
+
*/
|
|
302
|
+
selectable?: NodeSpec['selectable'] | ((this: {
|
|
303
|
+
name: string;
|
|
304
|
+
options: Options;
|
|
305
|
+
storage: Storage;
|
|
306
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['selectable'];
|
|
307
|
+
editor?: Editor;
|
|
308
|
+
}) => NodeSpec['selectable']);
|
|
309
|
+
/**
|
|
310
|
+
* Determines whether nodes of this type can be dragged without
|
|
311
|
+
* being selected. Defaults to false.
|
|
312
|
+
*
|
|
313
|
+
* @default: false
|
|
314
|
+
* @example: draggable: true
|
|
315
|
+
*/
|
|
316
|
+
draggable?: NodeSpec['draggable'] | ((this: {
|
|
317
|
+
name: string;
|
|
318
|
+
options: Options;
|
|
319
|
+
storage: Storage;
|
|
320
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['draggable'];
|
|
321
|
+
editor?: Editor;
|
|
322
|
+
}) => NodeSpec['draggable']);
|
|
323
|
+
/**
|
|
324
|
+
* Can be used to indicate that this node contains code, which
|
|
325
|
+
* causes some commands to behave differently.
|
|
326
|
+
*/
|
|
327
|
+
code?: NodeSpec['code'] | ((this: {
|
|
328
|
+
name: string;
|
|
329
|
+
options: Options;
|
|
330
|
+
storage: Storage;
|
|
331
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['code'];
|
|
332
|
+
editor?: Editor;
|
|
333
|
+
}) => NodeSpec['code']);
|
|
334
|
+
/**
|
|
335
|
+
* Controls way whitespace in this a node is parsed. The default is
|
|
336
|
+
* `"normal"`, which causes the [DOM parser](https://prosemirror.net/docs/ref/#model.DOMParser) to
|
|
337
|
+
* collapse whitespace in normal mode, and normalize it (replacing
|
|
338
|
+
* newlines and such with spaces) otherwise. `"pre"` causes the
|
|
339
|
+
* parser to preserve spaces inside the node. When this option isn't
|
|
340
|
+
* given, but [`code`](https://prosemirror.net/docs/ref/#model.NodeSpec.code) is true, `whitespace`
|
|
341
|
+
* will default to `"pre"`. Note that this option doesn't influence
|
|
342
|
+
* the way the node is rendered—that should be handled by `toDOM`
|
|
343
|
+
* and/or styling.
|
|
344
|
+
*/
|
|
345
|
+
whitespace?: NodeSpec['whitespace'] | ((this: {
|
|
346
|
+
name: string;
|
|
347
|
+
options: Options;
|
|
348
|
+
storage: Storage;
|
|
349
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['whitespace'];
|
|
350
|
+
editor?: Editor;
|
|
351
|
+
}) => NodeSpec['whitespace']);
|
|
352
|
+
/**
|
|
353
|
+
* Allows a **single** node to be set as linebreak equivalent (e.g. hardBreak).
|
|
354
|
+
* When converting between block types that have whitespace set to "pre"
|
|
355
|
+
* and don't support the linebreak node (e.g. codeBlock) and other block types
|
|
356
|
+
* that do support the linebreak node (e.g. paragraphs) - this node will be used
|
|
357
|
+
* as the linebreak instead of stripping the newline.
|
|
358
|
+
*
|
|
359
|
+
* See [linebreakReplacement](https://prosemirror.net/docs/ref/#model.NodeSpec.linebreakReplacement).
|
|
360
|
+
*/
|
|
361
|
+
linebreakReplacement?: NodeSpec['linebreakReplacement'] | ((this: {
|
|
362
|
+
name: string;
|
|
363
|
+
options: Options;
|
|
364
|
+
storage: Storage;
|
|
365
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['linebreakReplacement'];
|
|
366
|
+
editor?: Editor;
|
|
367
|
+
}) => NodeSpec['linebreakReplacement']);
|
|
368
|
+
/**
|
|
369
|
+
* When enabled, enables both
|
|
370
|
+
* [`definingAsContext`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingAsContext) and
|
|
371
|
+
* [`definingForContent`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingForContent).
|
|
372
|
+
*
|
|
373
|
+
* @default false
|
|
374
|
+
* @example isolating: true
|
|
375
|
+
*/
|
|
376
|
+
defining?: NodeSpec['defining'] | ((this: {
|
|
377
|
+
name: string;
|
|
378
|
+
options: Options;
|
|
379
|
+
storage: Storage;
|
|
380
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['defining'];
|
|
381
|
+
editor?: Editor;
|
|
382
|
+
}) => NodeSpec['defining']);
|
|
383
|
+
/**
|
|
384
|
+
* When enabled (default is false), the sides of nodes of this type
|
|
385
|
+
* count as boundaries that regular editing operations, like
|
|
386
|
+
* backspacing or lifting, won't cross. An example of a node that
|
|
387
|
+
* should probably have this enabled is a table cell.
|
|
388
|
+
*/
|
|
389
|
+
isolating?: NodeSpec['isolating'] | ((this: {
|
|
390
|
+
name: string;
|
|
391
|
+
options: Options;
|
|
392
|
+
storage: Storage;
|
|
393
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['isolating'];
|
|
394
|
+
editor?: Editor;
|
|
395
|
+
}) => NodeSpec['isolating']);
|
|
396
|
+
/**
|
|
397
|
+
* Associates DOM parser information with this node, which can be
|
|
398
|
+
* used by [`DOMParser.fromSchema`](https://prosemirror.net/docs/ref/#model.DOMParser^fromSchema) to
|
|
399
|
+
* automatically derive a parser. The `node` field in the rules is
|
|
400
|
+
* implied (the name of this node will be filled in automatically).
|
|
401
|
+
* If you supply your own parser, you do not need to also specify
|
|
402
|
+
* parsing rules in your schema.
|
|
403
|
+
*
|
|
404
|
+
* @example parseHTML: [{ tag: 'div', attrs: { 'data-id': 'my-block' } }]
|
|
405
|
+
*/
|
|
406
|
+
parseHTML?: (this: {
|
|
407
|
+
name: string;
|
|
408
|
+
options: Options;
|
|
409
|
+
storage: Storage;
|
|
410
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['parseHTML'];
|
|
411
|
+
editor?: Editor;
|
|
412
|
+
}) => NodeSpec['parseDOM'];
|
|
413
|
+
/**
|
|
414
|
+
* A description of a DOM structure. Can be either a string, which is
|
|
415
|
+
* interpreted as a text node, a DOM node, which is interpreted as
|
|
416
|
+
* itself, a `{dom, contentDOM}` object, or an array.
|
|
417
|
+
*
|
|
418
|
+
* An array describes a DOM element. The first value in the array
|
|
419
|
+
* should be a string—the name of the DOM element, optionally prefixed
|
|
420
|
+
* by a namespace URL and a space. If the second element is plain
|
|
421
|
+
* object, it is interpreted as a set of attributes for the element.
|
|
422
|
+
* Any elements after that (including the 2nd if it's not an attribute
|
|
423
|
+
* object) are interpreted as children of the DOM elements, and must
|
|
424
|
+
* either be valid `DOMOutputSpec` values, or the number zero.
|
|
425
|
+
*
|
|
426
|
+
* The number zero (pronounced “hole”) is used to indicate the place
|
|
427
|
+
* where a node's child nodes should be inserted. If it occurs in an
|
|
428
|
+
* output spec, it should be the only child element in its parent
|
|
429
|
+
* node.
|
|
430
|
+
*
|
|
431
|
+
* @example toDOM: ['div[data-id="my-block"]', { class: 'my-block' }, 0]
|
|
432
|
+
*/
|
|
433
|
+
renderHTML?: ((this: {
|
|
434
|
+
name: string;
|
|
435
|
+
options: Options;
|
|
436
|
+
storage: Storage;
|
|
437
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['renderHTML'];
|
|
438
|
+
editor?: Editor;
|
|
439
|
+
}, props: {
|
|
440
|
+
node: Node$1;
|
|
441
|
+
HTMLAttributes: Record<string, any>;
|
|
442
|
+
}) => DOMOutputSpec) | null;
|
|
443
|
+
/**
|
|
444
|
+
* renders the node as text
|
|
445
|
+
* @example renderText: () => 'foo
|
|
446
|
+
*/
|
|
447
|
+
renderText?: ((this: {
|
|
448
|
+
name: string;
|
|
449
|
+
options: Options;
|
|
450
|
+
storage: Storage;
|
|
451
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['renderText'];
|
|
452
|
+
editor?: Editor;
|
|
453
|
+
}, props: {
|
|
454
|
+
node: Node$1;
|
|
455
|
+
pos: number;
|
|
456
|
+
parent: Node$1;
|
|
457
|
+
index: number;
|
|
458
|
+
}) => string) | null;
|
|
459
|
+
/**
|
|
460
|
+
* Add attributes to the node
|
|
461
|
+
* @example addAttributes: () => ({ class: 'foo' })
|
|
462
|
+
*/
|
|
463
|
+
addAttributes?: (this: {
|
|
464
|
+
name: string;
|
|
465
|
+
options: Options;
|
|
466
|
+
storage: Storage;
|
|
467
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addAttributes'];
|
|
468
|
+
editor?: Editor;
|
|
469
|
+
}) => Attributes$1 | {};
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* The Node class is used to create custom node extensions.
|
|
473
|
+
* @see https://tiptap.dev/api/extensions#create-a-new-extension
|
|
474
|
+
*/
|
|
475
|
+
declare class Node<Options = any, Storage = any> extends Extendable<Options, Storage, NodeConfig<Options, Storage>> {
|
|
476
|
+
type: string;
|
|
477
|
+
/**
|
|
478
|
+
* Create a new Node instance
|
|
479
|
+
* @param config - Node configuration object or a function that returns a configuration object
|
|
480
|
+
*/
|
|
481
|
+
static create<O = any, S = any>(config?: Partial<NodeConfig<O, S>> | (() => Partial<NodeConfig<O, S>>)): Node<O, S>;
|
|
482
|
+
configure(options?: Partial<Options>): Node<Options, Storage>;
|
|
483
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = NodeConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)): Node<ExtendedOptions, ExtendedStorage>;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
type PasteRuleMatch = {
|
|
487
|
+
index: number;
|
|
488
|
+
text: string;
|
|
489
|
+
replaceWith?: string;
|
|
490
|
+
match?: RegExpMatchArray;
|
|
491
|
+
data?: Record<string, any>;
|
|
492
|
+
};
|
|
493
|
+
type PasteRuleFinder = RegExp | ((text: string, event?: ClipboardEvent | null) => PasteRuleMatch[] | null | undefined);
|
|
494
|
+
/**
|
|
495
|
+
* Paste rules are used to react to pasted content.
|
|
496
|
+
* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#paste-rules
|
|
497
|
+
*/
|
|
498
|
+
declare class PasteRule {
|
|
499
|
+
find: PasteRuleFinder;
|
|
500
|
+
handler: (props: {
|
|
501
|
+
state: EditorState;
|
|
502
|
+
range: Range;
|
|
503
|
+
match: ExtendedRegExpMatchArray;
|
|
504
|
+
commands: SingleCommands;
|
|
505
|
+
chain: () => ChainedCommands;
|
|
506
|
+
can: () => CanCommands;
|
|
507
|
+
pasteEvent: ClipboardEvent | null;
|
|
508
|
+
dropEvent: DragEvent | null;
|
|
509
|
+
}) => void | null;
|
|
510
|
+
constructor(config: {
|
|
511
|
+
find: PasteRuleFinder;
|
|
512
|
+
handler: (props: {
|
|
513
|
+
can: () => CanCommands;
|
|
514
|
+
chain: () => ChainedCommands;
|
|
515
|
+
commands: SingleCommands;
|
|
516
|
+
dropEvent: DragEvent | null;
|
|
517
|
+
match: ExtendedRegExpMatchArray;
|
|
518
|
+
pasteEvent: ClipboardEvent | null;
|
|
519
|
+
range: Range;
|
|
520
|
+
state: EditorState;
|
|
521
|
+
}) => void | null;
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Create an paste rules plugin. When enabled, it will cause pasted
|
|
526
|
+
* text that matches any of the given rules to trigger the rule’s
|
|
527
|
+
* action.
|
|
528
|
+
*/
|
|
529
|
+
declare function pasteRulesPlugin(props: {
|
|
530
|
+
editor: Editor;
|
|
531
|
+
rules: PasteRule[];
|
|
532
|
+
}): Plugin[];
|
|
533
|
+
|
|
534
|
+
interface ExtendableConfig<Options = any, Storage = any, Config extends ExtensionConfig<Options, Storage> | NodeConfig<Options, Storage> | MarkConfig<Options, Storage> | ExtendableConfig<Options, Storage> = ExtendableConfig<Options, Storage, any, any>, PMType = any> {
|
|
535
|
+
/**
|
|
536
|
+
* The extension name - this must be unique.
|
|
537
|
+
* It will be used to identify the extension.
|
|
538
|
+
*
|
|
539
|
+
* @example 'myExtension'
|
|
540
|
+
*/
|
|
541
|
+
name: string;
|
|
542
|
+
/**
|
|
543
|
+
* The priority of your extension. The higher, the earlier it will be called
|
|
544
|
+
* and will take precedence over other extensions with a lower priority.
|
|
545
|
+
* @default 100
|
|
546
|
+
* @example 101
|
|
547
|
+
*/
|
|
548
|
+
priority?: number;
|
|
549
|
+
/**
|
|
550
|
+
* This method will add options to this extension
|
|
551
|
+
* @see https://tiptap.dev/docs/editor/guide/custom-extensions#settings
|
|
552
|
+
* @example
|
|
553
|
+
* addOptions() {
|
|
554
|
+
* return {
|
|
555
|
+
* myOption: 'foo',
|
|
556
|
+
* myOtherOption: 10,
|
|
557
|
+
* }
|
|
558
|
+
*/
|
|
559
|
+
addOptions?: (this: {
|
|
560
|
+
name: string;
|
|
561
|
+
parent: ParentConfig<Config>['addOptions'];
|
|
562
|
+
}) => Options;
|
|
563
|
+
/**
|
|
564
|
+
* The default storage this extension can save data to.
|
|
565
|
+
* @see https://tiptap.dev/docs/editor/guide/custom-extensions#storage
|
|
566
|
+
* @example
|
|
567
|
+
* defaultStorage: {
|
|
568
|
+
* prefetchedUsers: [],
|
|
569
|
+
* loading: false,
|
|
570
|
+
* }
|
|
571
|
+
*/
|
|
572
|
+
addStorage?: (this: {
|
|
573
|
+
name: string;
|
|
574
|
+
options: Options;
|
|
575
|
+
parent: ParentConfig<Config>['addStorage'];
|
|
576
|
+
}) => Storage;
|
|
577
|
+
/**
|
|
578
|
+
* This function adds globalAttributes to specific nodes.
|
|
579
|
+
* @see https://tiptap.dev/docs/editor/guide/custom-extensions#global-attributes
|
|
580
|
+
* @example
|
|
581
|
+
* addGlobalAttributes() {
|
|
582
|
+
* return [
|
|
583
|
+
* {
|
|
584
|
+
// Extend the following extensions
|
|
585
|
+
* types: [
|
|
586
|
+
* 'heading',
|
|
587
|
+
* 'paragraph',
|
|
588
|
+
* ],
|
|
589
|
+
* // … with those attributes
|
|
590
|
+
* attributes: {
|
|
591
|
+
* textAlign: {
|
|
592
|
+
* default: 'left',
|
|
593
|
+
* renderHTML: attributes => ({
|
|
594
|
+
* style: `text-align: ${attributes.textAlign}`,
|
|
595
|
+
* }),
|
|
596
|
+
* parseHTML: element => element.style.textAlign || 'left',
|
|
597
|
+
* },
|
|
598
|
+
* },
|
|
599
|
+
* },
|
|
600
|
+
* ]
|
|
601
|
+
* }
|
|
602
|
+
*/
|
|
603
|
+
addGlobalAttributes?: (this: {
|
|
604
|
+
name: string;
|
|
605
|
+
options: Options;
|
|
606
|
+
storage: Storage;
|
|
607
|
+
extensions: (Node | Mark)[];
|
|
608
|
+
parent: ParentConfig<Config>['addGlobalAttributes'];
|
|
609
|
+
}) => GlobalAttributes;
|
|
610
|
+
/**
|
|
611
|
+
* This function adds commands to the editor
|
|
612
|
+
* @see https://tiptap.dev/docs/editor/guide/custom-extensions#commands
|
|
613
|
+
* @example
|
|
614
|
+
* addCommands() {
|
|
615
|
+
* return {
|
|
616
|
+
* myCommand: () => ({ chain }) => chain().setMark('type', 'foo').run(),
|
|
617
|
+
* }
|
|
618
|
+
* }
|
|
619
|
+
*/
|
|
620
|
+
addCommands?: (this: {
|
|
621
|
+
name: string;
|
|
622
|
+
options: Options;
|
|
623
|
+
storage: Storage;
|
|
624
|
+
editor: Editor;
|
|
625
|
+
type: PMType;
|
|
626
|
+
parent: ParentConfig<Config>['addCommands'];
|
|
627
|
+
}) => Partial<RawCommands>;
|
|
628
|
+
/**
|
|
629
|
+
* This function registers keyboard shortcuts.
|
|
630
|
+
* @see https://tiptap.dev/docs/editor/guide/custom-extensions#keyboard-shortcuts
|
|
631
|
+
* @example
|
|
632
|
+
* addKeyboardShortcuts() {
|
|
633
|
+
* return {
|
|
634
|
+
* 'Mod-l': () => this.editor.commands.toggleBulletList(),
|
|
635
|
+
* }
|
|
636
|
+
* },
|
|
637
|
+
*/
|
|
638
|
+
addKeyboardShortcuts?: (this: {
|
|
639
|
+
name: string;
|
|
640
|
+
options: Options;
|
|
641
|
+
storage: Storage;
|
|
642
|
+
editor: Editor;
|
|
643
|
+
type: PMType;
|
|
644
|
+
parent: ParentConfig<Config>['addKeyboardShortcuts'];
|
|
645
|
+
}) => {
|
|
646
|
+
[key: string]: KeyboardShortcutCommand;
|
|
647
|
+
};
|
|
648
|
+
/**
|
|
649
|
+
* This function adds input rules to the editor.
|
|
650
|
+
* @see https://tiptap.dev/docs/editor/guide/custom-extensions#input-rules
|
|
651
|
+
* @example
|
|
652
|
+
* addInputRules() {
|
|
653
|
+
* return [
|
|
654
|
+
* markInputRule({
|
|
655
|
+
* find: inputRegex,
|
|
656
|
+
* type: this.type,
|
|
657
|
+
* }),
|
|
658
|
+
* ]
|
|
659
|
+
* },
|
|
660
|
+
*/
|
|
661
|
+
addInputRules?: (this: {
|
|
662
|
+
name: string;
|
|
663
|
+
options: Options;
|
|
664
|
+
storage: Storage;
|
|
665
|
+
editor: Editor;
|
|
666
|
+
type: PMType;
|
|
667
|
+
parent: ParentConfig<Config>['addInputRules'];
|
|
668
|
+
}) => InputRule[];
|
|
669
|
+
/**
|
|
670
|
+
* This function adds paste rules to the editor.
|
|
671
|
+
* @see https://tiptap.dev/docs/editor/guide/custom-extensions#paste-rules
|
|
672
|
+
* @example
|
|
673
|
+
* addPasteRules() {
|
|
674
|
+
* return [
|
|
675
|
+
* markPasteRule({
|
|
676
|
+
* find: pasteRegex,
|
|
677
|
+
* type: this.type,
|
|
678
|
+
* }),
|
|
679
|
+
* ]
|
|
680
|
+
* },
|
|
681
|
+
*/
|
|
682
|
+
addPasteRules?: (this: {
|
|
683
|
+
name: string;
|
|
684
|
+
options: Options;
|
|
685
|
+
storage: Storage;
|
|
686
|
+
editor: Editor;
|
|
687
|
+
type: PMType;
|
|
688
|
+
parent: ParentConfig<Config>['addPasteRules'];
|
|
689
|
+
}) => PasteRule[];
|
|
690
|
+
/**
|
|
691
|
+
* This function adds Prosemirror plugins to the editor
|
|
692
|
+
* @see https://tiptap.dev/docs/editor/guide/custom-extensions#prosemirror-plugins
|
|
693
|
+
* @example
|
|
694
|
+
* addProseMirrorPlugins() {
|
|
695
|
+
* return [
|
|
696
|
+
* customPlugin(),
|
|
697
|
+
* ]
|
|
698
|
+
* }
|
|
699
|
+
*/
|
|
700
|
+
addProseMirrorPlugins?: (this: {
|
|
701
|
+
name: string;
|
|
702
|
+
options: Options;
|
|
703
|
+
storage: Storage;
|
|
704
|
+
editor: Editor;
|
|
705
|
+
type: PMType;
|
|
706
|
+
parent: ParentConfig<Config>['addProseMirrorPlugins'];
|
|
707
|
+
}) => Plugin[];
|
|
708
|
+
/**
|
|
709
|
+
* This function adds additional extensions to the editor. This is useful for
|
|
710
|
+
* building extension kits.
|
|
711
|
+
* @example
|
|
712
|
+
* addExtensions() {
|
|
713
|
+
* return [
|
|
714
|
+
* BulletList,
|
|
715
|
+
* OrderedList,
|
|
716
|
+
* ListItem
|
|
717
|
+
* ]
|
|
718
|
+
* }
|
|
719
|
+
*/
|
|
720
|
+
addExtensions?: (this: {
|
|
721
|
+
name: string;
|
|
722
|
+
options: Options;
|
|
723
|
+
storage: Storage;
|
|
724
|
+
parent: ParentConfig<Config>['addExtensions'];
|
|
725
|
+
}) => Extensions;
|
|
726
|
+
/**
|
|
727
|
+
* This function extends the schema of the node.
|
|
728
|
+
* @example
|
|
729
|
+
* extendNodeSchema() {
|
|
730
|
+
* return {
|
|
731
|
+
* group: 'inline',
|
|
732
|
+
* selectable: false,
|
|
733
|
+
* }
|
|
734
|
+
* }
|
|
735
|
+
*/
|
|
736
|
+
extendNodeSchema?: ((this: {
|
|
737
|
+
name: string;
|
|
738
|
+
options: Options;
|
|
739
|
+
storage: Storage;
|
|
740
|
+
parent: ParentConfig<Config>['extendNodeSchema'];
|
|
741
|
+
}, extension: Node) => Record<string, any>) | null;
|
|
742
|
+
/**
|
|
743
|
+
* This function extends the schema of the mark.
|
|
744
|
+
* @example
|
|
745
|
+
* extendMarkSchema() {
|
|
746
|
+
* return {
|
|
747
|
+
* group: 'inline',
|
|
748
|
+
* selectable: false,
|
|
749
|
+
* }
|
|
750
|
+
* }
|
|
751
|
+
*/
|
|
752
|
+
extendMarkSchema?: ((this: {
|
|
753
|
+
name: string;
|
|
754
|
+
options: Options;
|
|
755
|
+
storage: Storage;
|
|
756
|
+
parent: ParentConfig<Config>['extendMarkSchema'];
|
|
757
|
+
}, extension: Mark) => Record<string, any>) | null;
|
|
758
|
+
/**
|
|
759
|
+
* The editor is not ready yet.
|
|
760
|
+
*/
|
|
761
|
+
onBeforeCreate?: ((this: {
|
|
762
|
+
name: string;
|
|
763
|
+
options: Options;
|
|
764
|
+
storage: Storage;
|
|
765
|
+
editor: Editor;
|
|
766
|
+
type: PMType;
|
|
767
|
+
parent: ParentConfig<Config>['onBeforeCreate'];
|
|
768
|
+
}, event: EditorEvents['beforeCreate']) => void) | null;
|
|
769
|
+
/**
|
|
770
|
+
* The editor is ready.
|
|
771
|
+
*/
|
|
772
|
+
onCreate?: ((this: {
|
|
773
|
+
name: string;
|
|
774
|
+
options: Options;
|
|
775
|
+
storage: Storage;
|
|
776
|
+
editor: Editor;
|
|
777
|
+
type: PMType;
|
|
778
|
+
parent: ParentConfig<Config>['onCreate'];
|
|
779
|
+
}, event: EditorEvents['create']) => void) | null;
|
|
780
|
+
/**
|
|
781
|
+
* The content has changed.
|
|
782
|
+
*/
|
|
783
|
+
onUpdate?: ((this: {
|
|
784
|
+
name: string;
|
|
785
|
+
options: Options;
|
|
786
|
+
storage: Storage;
|
|
787
|
+
editor: Editor;
|
|
788
|
+
type: PMType;
|
|
789
|
+
parent: ParentConfig<Config>['onUpdate'];
|
|
790
|
+
}, event: EditorEvents['update']) => void) | null;
|
|
791
|
+
/**
|
|
792
|
+
* The selection has changed.
|
|
793
|
+
*/
|
|
794
|
+
onSelectionUpdate?: ((this: {
|
|
795
|
+
name: string;
|
|
796
|
+
options: Options;
|
|
797
|
+
storage: Storage;
|
|
798
|
+
editor: Editor;
|
|
799
|
+
type: PMType;
|
|
800
|
+
parent: ParentConfig<Config>['onSelectionUpdate'];
|
|
801
|
+
}, event: EditorEvents['selectionUpdate']) => void) | null;
|
|
802
|
+
/**
|
|
803
|
+
* The editor state has changed.
|
|
804
|
+
*/
|
|
805
|
+
onTransaction?: ((this: {
|
|
806
|
+
name: string;
|
|
807
|
+
options: Options;
|
|
808
|
+
storage: Storage;
|
|
809
|
+
editor: Editor;
|
|
810
|
+
type: PMType;
|
|
811
|
+
parent: ParentConfig<Config>['onTransaction'];
|
|
812
|
+
}, event: EditorEvents['transaction']) => void) | null;
|
|
813
|
+
/**
|
|
814
|
+
* The editor is focused.
|
|
815
|
+
*/
|
|
816
|
+
onFocus?: ((this: {
|
|
817
|
+
name: string;
|
|
818
|
+
options: Options;
|
|
819
|
+
storage: Storage;
|
|
820
|
+
editor: Editor;
|
|
821
|
+
type: PMType;
|
|
822
|
+
parent: ParentConfig<Config>['onFocus'];
|
|
823
|
+
}, event: EditorEvents['focus']) => void) | null;
|
|
824
|
+
/**
|
|
825
|
+
* The editor isn’t focused anymore.
|
|
826
|
+
*/
|
|
827
|
+
onBlur?: ((this: {
|
|
828
|
+
name: string;
|
|
829
|
+
options: Options;
|
|
830
|
+
storage: Storage;
|
|
831
|
+
editor: Editor;
|
|
832
|
+
type: PMType;
|
|
833
|
+
parent: ParentConfig<Config>['onBlur'];
|
|
834
|
+
}, event: EditorEvents['blur']) => void) | null;
|
|
835
|
+
/**
|
|
836
|
+
* The editor is destroyed.
|
|
837
|
+
*/
|
|
838
|
+
onDestroy?: ((this: {
|
|
839
|
+
name: string;
|
|
840
|
+
options: Options;
|
|
841
|
+
storage: Storage;
|
|
842
|
+
editor: Editor;
|
|
843
|
+
type: PMType;
|
|
844
|
+
parent: ParentConfig<Config>['onDestroy'];
|
|
845
|
+
}, event: EditorEvents['destroy']) => void) | null;
|
|
846
|
+
}
|
|
847
|
+
declare class Extendable<Options = any, Storage = any, Config = ExtensionConfig<Options, Storage> | NodeConfig<Options, Storage> | MarkConfig<Options, Storage>> {
|
|
848
|
+
type: string;
|
|
849
|
+
parent: Extendable | null;
|
|
850
|
+
child: Extendable | null;
|
|
851
|
+
name: string;
|
|
852
|
+
config: Config;
|
|
853
|
+
constructor(config?: Partial<Config>);
|
|
854
|
+
get options(): Options;
|
|
855
|
+
get storage(): Readonly<Storage>;
|
|
856
|
+
configure(options?: Partial<Options>): Extendable<Options, Storage, ExtensionConfig<Options, Storage> | NodeConfig<Options, Storage> | MarkConfig<Options, Storage>>;
|
|
857
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage> | NodeConfig<ExtendedOptions, ExtendedStorage> | MarkConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Extendable<ExtendedOptions, ExtendedStorage>;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
type AnyConfig = ExtensionConfig | NodeConfig | MarkConfig;
|
|
861
|
+
type AnyExtension = Extendable;
|
|
862
|
+
type Extensions = AnyExtension[];
|
|
863
|
+
type ParentConfig<T> = Partial<{
|
|
864
|
+
[P in keyof T]: Required<T>[P] extends (...args: any) => any ? (...args: Parameters<Required<T>[P]>) => ReturnType<Required<T>[P]> : T[P];
|
|
865
|
+
}>;
|
|
866
|
+
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
867
|
+
type RemoveThis<T> = T extends (...args: any) => any ? (...args: Parameters<T>) => ReturnType<T> : T;
|
|
868
|
+
type MaybeReturnType<T> = T extends (...args: any) => any ? ReturnType<T> : T;
|
|
869
|
+
type MaybeThisParameterType<T> = Exclude<T, Primitive> extends (...args: any) => any ? ThisParameterType<Exclude<T, Primitive>> : any;
|
|
870
|
+
interface EditorEvents {
|
|
871
|
+
beforeCreate: {
|
|
872
|
+
/**
|
|
873
|
+
* The editor instance
|
|
874
|
+
*/
|
|
875
|
+
editor: Editor;
|
|
876
|
+
};
|
|
877
|
+
create: {
|
|
878
|
+
/**
|
|
879
|
+
* The editor instance
|
|
880
|
+
*/
|
|
881
|
+
editor: Editor;
|
|
882
|
+
};
|
|
883
|
+
contentError: {
|
|
884
|
+
/**
|
|
885
|
+
* The editor instance
|
|
886
|
+
*/
|
|
887
|
+
editor: Editor;
|
|
888
|
+
/**
|
|
889
|
+
* The error that occurred while parsing the content
|
|
890
|
+
*/
|
|
891
|
+
error: Error;
|
|
892
|
+
/**
|
|
893
|
+
* If called, will re-initialize the editor with the collaboration extension removed.
|
|
894
|
+
* This will prevent syncing back deletions of content not present in the current schema.
|
|
895
|
+
*/
|
|
896
|
+
disableCollaboration: () => void;
|
|
897
|
+
};
|
|
898
|
+
update: {
|
|
899
|
+
/**
|
|
900
|
+
* The editor instance
|
|
901
|
+
*/
|
|
902
|
+
editor: Editor;
|
|
903
|
+
/**
|
|
904
|
+
* The transaction that caused the update
|
|
905
|
+
*/
|
|
906
|
+
transaction: Transaction;
|
|
907
|
+
/**
|
|
908
|
+
* Appended transactions that were added to the initial transaction by plugins
|
|
909
|
+
*/
|
|
910
|
+
appendedTransactions: Transaction[];
|
|
911
|
+
};
|
|
912
|
+
selectionUpdate: {
|
|
913
|
+
/**
|
|
914
|
+
* The editor instance
|
|
915
|
+
*/
|
|
916
|
+
editor: Editor;
|
|
917
|
+
/**
|
|
918
|
+
* The transaction that caused the selection update
|
|
919
|
+
*/
|
|
920
|
+
transaction: Transaction;
|
|
921
|
+
};
|
|
922
|
+
beforeTransaction: {
|
|
923
|
+
/**
|
|
924
|
+
* The editor instance
|
|
925
|
+
*/
|
|
926
|
+
editor: Editor;
|
|
927
|
+
/**
|
|
928
|
+
* The transaction that will be applied
|
|
929
|
+
*/
|
|
930
|
+
transaction: Transaction;
|
|
931
|
+
/**
|
|
932
|
+
* The next state of the editor after the transaction is applied
|
|
933
|
+
*/
|
|
934
|
+
nextState: EditorState;
|
|
935
|
+
};
|
|
936
|
+
transaction: {
|
|
937
|
+
/**
|
|
938
|
+
* The editor instance
|
|
939
|
+
*/
|
|
940
|
+
editor: Editor;
|
|
941
|
+
/**
|
|
942
|
+
* The initial transaction
|
|
943
|
+
*/
|
|
944
|
+
transaction: Transaction;
|
|
945
|
+
/**
|
|
946
|
+
* Appended transactions that were added to the initial transaction by plugins
|
|
947
|
+
*/
|
|
948
|
+
appendedTransactions: Transaction[];
|
|
949
|
+
};
|
|
950
|
+
focus: {
|
|
951
|
+
/**
|
|
952
|
+
* The editor instance
|
|
953
|
+
*/
|
|
954
|
+
editor: Editor;
|
|
955
|
+
/**
|
|
956
|
+
* The focus event
|
|
957
|
+
*/
|
|
958
|
+
event: FocusEvent;
|
|
959
|
+
/**
|
|
960
|
+
* The transaction that caused the focus
|
|
961
|
+
*/
|
|
962
|
+
transaction: Transaction;
|
|
963
|
+
};
|
|
964
|
+
blur: {
|
|
965
|
+
/**
|
|
966
|
+
* The editor instance
|
|
967
|
+
*/
|
|
968
|
+
editor: Editor;
|
|
969
|
+
/**
|
|
970
|
+
* The focus event
|
|
971
|
+
*/
|
|
972
|
+
event: FocusEvent;
|
|
973
|
+
/**
|
|
974
|
+
* The transaction that caused the blur
|
|
975
|
+
*/
|
|
976
|
+
transaction: Transaction;
|
|
977
|
+
};
|
|
978
|
+
destroy: void;
|
|
979
|
+
paste: {
|
|
980
|
+
/**
|
|
981
|
+
* The editor instance
|
|
982
|
+
*/
|
|
983
|
+
editor: Editor;
|
|
984
|
+
/**
|
|
985
|
+
* The clipboard event
|
|
986
|
+
*/
|
|
987
|
+
event: ClipboardEvent;
|
|
988
|
+
/**
|
|
989
|
+
* The slice that was pasted
|
|
990
|
+
*/
|
|
991
|
+
slice: Slice;
|
|
992
|
+
};
|
|
993
|
+
drop: {
|
|
994
|
+
/**
|
|
995
|
+
* The editor instance
|
|
996
|
+
*/
|
|
997
|
+
editor: Editor;
|
|
998
|
+
/**
|
|
999
|
+
* The drag event
|
|
1000
|
+
*/
|
|
1001
|
+
event: DragEvent;
|
|
1002
|
+
/**
|
|
1003
|
+
* The slice that was dropped
|
|
1004
|
+
*/
|
|
1005
|
+
slice: Slice;
|
|
1006
|
+
/**
|
|
1007
|
+
* Whether the content was moved (true) or copied (false)
|
|
1008
|
+
*/
|
|
1009
|
+
moved: boolean;
|
|
1010
|
+
};
|
|
1011
|
+
delete: {
|
|
1012
|
+
/**
|
|
1013
|
+
* The editor instance
|
|
1014
|
+
*/
|
|
1015
|
+
editor: Editor;
|
|
1016
|
+
/**
|
|
1017
|
+
* The range of the deleted content (before the deletion)
|
|
1018
|
+
*/
|
|
1019
|
+
deletedRange: Range;
|
|
1020
|
+
/**
|
|
1021
|
+
* The new range of positions of where the deleted content was in the new document (after the deletion)
|
|
1022
|
+
*/
|
|
1023
|
+
newRange: Range;
|
|
1024
|
+
/**
|
|
1025
|
+
* The transaction that caused the deletion
|
|
1026
|
+
*/
|
|
1027
|
+
transaction: Transaction;
|
|
1028
|
+
/**
|
|
1029
|
+
* The combined transform (including all appended transactions) that caused the deletion
|
|
1030
|
+
*/
|
|
1031
|
+
combinedTransform: Transform;
|
|
1032
|
+
/**
|
|
1033
|
+
* Whether the deletion was partial (only a part of this content was deleted)
|
|
1034
|
+
*/
|
|
1035
|
+
partial: boolean;
|
|
1036
|
+
/**
|
|
1037
|
+
* This is the start position of the mark in the document (before the deletion)
|
|
1038
|
+
*/
|
|
1039
|
+
from: number;
|
|
1040
|
+
/**
|
|
1041
|
+
* This is the end position of the mark in the document (before the deletion)
|
|
1042
|
+
*/
|
|
1043
|
+
to: number;
|
|
1044
|
+
} & ({
|
|
1045
|
+
/**
|
|
1046
|
+
* The content that was deleted
|
|
1047
|
+
*/
|
|
1048
|
+
type: 'node';
|
|
1049
|
+
/**
|
|
1050
|
+
* The node which the deletion occurred in
|
|
1051
|
+
* @note This can be a parent node of the deleted content
|
|
1052
|
+
*/
|
|
1053
|
+
node: Node$1;
|
|
1054
|
+
/**
|
|
1055
|
+
* The new start position of the node in the document (after the deletion)
|
|
1056
|
+
*/
|
|
1057
|
+
newFrom: number;
|
|
1058
|
+
/**
|
|
1059
|
+
* The new end position of the node in the document (after the deletion)
|
|
1060
|
+
*/
|
|
1061
|
+
newTo: number;
|
|
1062
|
+
} | {
|
|
1063
|
+
/**
|
|
1064
|
+
* The content that was deleted
|
|
1065
|
+
*/
|
|
1066
|
+
type: 'mark';
|
|
1067
|
+
/**
|
|
1068
|
+
* The mark that was deleted
|
|
1069
|
+
*/
|
|
1070
|
+
mark: Mark$1;
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
type EnableRules = (AnyExtension | string)[] | boolean;
|
|
1074
|
+
interface EditorOptions {
|
|
1075
|
+
/**
|
|
1076
|
+
* The element or selector to bind the editor to
|
|
1077
|
+
* If `null` is passed, the editor will not be mounted automatically
|
|
1078
|
+
* If a function is passed, it will be called with the editor's root element
|
|
1079
|
+
*/
|
|
1080
|
+
element: Element | null;
|
|
1081
|
+
/**
|
|
1082
|
+
* The content of the editor (HTML, JSON, or a JSON array)
|
|
1083
|
+
*/
|
|
1084
|
+
content: Content;
|
|
1085
|
+
/**
|
|
1086
|
+
* The extensions to use
|
|
1087
|
+
*/
|
|
1088
|
+
extensions: Extensions;
|
|
1089
|
+
/**
|
|
1090
|
+
* Whether to inject base CSS styles
|
|
1091
|
+
*/
|
|
1092
|
+
injectCSS: boolean;
|
|
1093
|
+
/**
|
|
1094
|
+
* A nonce to use for CSP while injecting styles
|
|
1095
|
+
*/
|
|
1096
|
+
injectNonce: string | undefined;
|
|
1097
|
+
/**
|
|
1098
|
+
* The editor's initial focus position
|
|
1099
|
+
*/
|
|
1100
|
+
autofocus: FocusPosition;
|
|
1101
|
+
/**
|
|
1102
|
+
* Whether the editor is editable
|
|
1103
|
+
*/
|
|
1104
|
+
editable: boolean;
|
|
1105
|
+
/**
|
|
1106
|
+
* The editor's props
|
|
1107
|
+
*/
|
|
1108
|
+
editorProps: EditorProps;
|
|
1109
|
+
/**
|
|
1110
|
+
* The editor's content parser options
|
|
1111
|
+
*/
|
|
1112
|
+
parseOptions: ParseOptions;
|
|
1113
|
+
/**
|
|
1114
|
+
* The editor's core extension options
|
|
1115
|
+
*/
|
|
1116
|
+
coreExtensionOptions?: {
|
|
1117
|
+
clipboardTextSerializer?: {
|
|
1118
|
+
blockSeparator?: string;
|
|
1119
|
+
};
|
|
1120
|
+
delete?: {
|
|
1121
|
+
/**
|
|
1122
|
+
* Whether the `delete` extension should be called asynchronously to avoid blocking the editor while processing deletions
|
|
1123
|
+
* @default true deletion events are called asynchronously
|
|
1124
|
+
*/
|
|
1125
|
+
async?: boolean;
|
|
1126
|
+
/**
|
|
1127
|
+
* Allows filtering the transactions that are processed by the `delete` extension.
|
|
1128
|
+
* If the function returns `true`, the transaction will be ignored.
|
|
1129
|
+
*/
|
|
1130
|
+
filterTransaction?: (transaction: Transaction) => boolean;
|
|
1131
|
+
};
|
|
1132
|
+
};
|
|
1133
|
+
/**
|
|
1134
|
+
* Whether to enable input rules behavior
|
|
1135
|
+
*/
|
|
1136
|
+
enableInputRules: EnableRules;
|
|
1137
|
+
/**
|
|
1138
|
+
* Whether to enable paste rules behavior
|
|
1139
|
+
*/
|
|
1140
|
+
enablePasteRules: EnableRules;
|
|
1141
|
+
/**
|
|
1142
|
+
* Determines whether core extensions are enabled.
|
|
1143
|
+
*
|
|
1144
|
+
* If set to `false`, all core extensions will be disabled.
|
|
1145
|
+
* To disable specific core extensions, provide an object where the keys are the extension names and the values are `false`.
|
|
1146
|
+
* Extensions not listed in the object will remain enabled.
|
|
1147
|
+
*
|
|
1148
|
+
* @example
|
|
1149
|
+
* // Disable all core extensions
|
|
1150
|
+
* enabledCoreExtensions: false
|
|
1151
|
+
*
|
|
1152
|
+
* @example
|
|
1153
|
+
* // Disable only the keymap core extension
|
|
1154
|
+
* enabledCoreExtensions: { keymap: false }
|
|
1155
|
+
*
|
|
1156
|
+
* @default true
|
|
1157
|
+
*/
|
|
1158
|
+
enableCoreExtensions?: boolean | Partial<Record<'editable' | 'clipboardTextSerializer' | 'commands' | 'focusEvents' | 'keymap' | 'tabindex' | 'drop' | 'paste' | 'delete', false>>;
|
|
1159
|
+
/**
|
|
1160
|
+
* If `true`, the editor will check the content for errors on initialization.
|
|
1161
|
+
* Emitting the `contentError` event if the content is invalid.
|
|
1162
|
+
* Which can be used to show a warning or error message to the user.
|
|
1163
|
+
* @default false
|
|
1164
|
+
*/
|
|
1165
|
+
enableContentCheck: boolean;
|
|
1166
|
+
/**
|
|
1167
|
+
* If `true`, the editor will emit the `contentError` event if invalid content is
|
|
1168
|
+
* encountered but `enableContentCheck` is `false`. This lets you preserve the
|
|
1169
|
+
* invalid editor content while still showing a warning or error message to
|
|
1170
|
+
* the user.
|
|
1171
|
+
*
|
|
1172
|
+
* @default false
|
|
1173
|
+
*/
|
|
1174
|
+
emitContentError: boolean;
|
|
1175
|
+
/**
|
|
1176
|
+
* Called before the editor is constructed.
|
|
1177
|
+
*/
|
|
1178
|
+
onBeforeCreate: (props: EditorEvents['beforeCreate']) => void;
|
|
1179
|
+
/**
|
|
1180
|
+
* Called after the editor is constructed.
|
|
1181
|
+
*/
|
|
1182
|
+
onCreate: (props: EditorEvents['create']) => void;
|
|
1183
|
+
/**
|
|
1184
|
+
* Called when the editor encounters an error while parsing the content.
|
|
1185
|
+
* Only enabled if `enableContentCheck` is `true`.
|
|
1186
|
+
*/
|
|
1187
|
+
onContentError: (props: EditorEvents['contentError']) => void;
|
|
1188
|
+
/**
|
|
1189
|
+
* Called when the editor's content is updated.
|
|
1190
|
+
*/
|
|
1191
|
+
onUpdate: (props: EditorEvents['update']) => void;
|
|
1192
|
+
/**
|
|
1193
|
+
* Called when the editor's selection is updated.
|
|
1194
|
+
*/
|
|
1195
|
+
onSelectionUpdate: (props: EditorEvents['selectionUpdate']) => void;
|
|
1196
|
+
/**
|
|
1197
|
+
* Called after a transaction is applied to the editor.
|
|
1198
|
+
*/
|
|
1199
|
+
onTransaction: (props: EditorEvents['transaction']) => void;
|
|
1200
|
+
/**
|
|
1201
|
+
* Called on focus events.
|
|
1202
|
+
*/
|
|
1203
|
+
onFocus: (props: EditorEvents['focus']) => void;
|
|
1204
|
+
/**
|
|
1205
|
+
* Called on blur events.
|
|
1206
|
+
*/
|
|
1207
|
+
onBlur: (props: EditorEvents['blur']) => void;
|
|
1208
|
+
/**
|
|
1209
|
+
* Called when the editor is destroyed.
|
|
1210
|
+
*/
|
|
1211
|
+
onDestroy: (props: EditorEvents['destroy']) => void;
|
|
1212
|
+
/**
|
|
1213
|
+
* Called when content is pasted into the editor.
|
|
1214
|
+
*/
|
|
1215
|
+
onPaste: (e: ClipboardEvent, slice: Slice) => void;
|
|
1216
|
+
/**
|
|
1217
|
+
* Called when content is dropped into the editor.
|
|
1218
|
+
*/
|
|
1219
|
+
onDrop: (e: DragEvent, slice: Slice, moved: boolean) => void;
|
|
1220
|
+
/**
|
|
1221
|
+
* Called when content is deleted from the editor.
|
|
1222
|
+
*/
|
|
1223
|
+
onDelete: (props: EditorEvents['delete']) => void;
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* The editor's content as HTML
|
|
1227
|
+
*/
|
|
1228
|
+
type HTMLContent = string;
|
|
1229
|
+
/**
|
|
1230
|
+
* Loosely describes a JSON representation of a Prosemirror document or node
|
|
1231
|
+
*/
|
|
1232
|
+
type JSONContent = {
|
|
1233
|
+
type?: string;
|
|
1234
|
+
attrs?: Record<string, any>;
|
|
1235
|
+
content?: JSONContent[];
|
|
1236
|
+
marks?: {
|
|
1237
|
+
type: string;
|
|
1238
|
+
attrs?: Record<string, any>;
|
|
1239
|
+
[key: string]: any;
|
|
1240
|
+
}[];
|
|
1241
|
+
text?: string;
|
|
1242
|
+
[key: string]: any;
|
|
1243
|
+
};
|
|
1244
|
+
/**
|
|
1245
|
+
* A mark type is either a JSON representation of a mark or a Prosemirror mark instance
|
|
1246
|
+
*/
|
|
1247
|
+
type MarkType<Type extends string | {
|
|
1248
|
+
name: string;
|
|
1249
|
+
} = any, TAttributes extends undefined | Record<string, any> = any> = {
|
|
1250
|
+
type: Type;
|
|
1251
|
+
attrs: TAttributes;
|
|
1252
|
+
};
|
|
1253
|
+
/**
|
|
1254
|
+
* A node type is either a JSON representation of a node or a Prosemirror node instance
|
|
1255
|
+
*/
|
|
1256
|
+
type NodeType<Type extends string | {
|
|
1257
|
+
name: string;
|
|
1258
|
+
} = any, TAttributes extends undefined | Record<string, any> = any, NodeMarkType extends MarkType = any, TContent extends (NodeType | TextType)[] = any> = {
|
|
1259
|
+
type: Type;
|
|
1260
|
+
attrs: TAttributes;
|
|
1261
|
+
content?: TContent;
|
|
1262
|
+
marks?: NodeMarkType[];
|
|
1263
|
+
};
|
|
1264
|
+
/**
|
|
1265
|
+
* A node type is either a JSON representation of a doc node or a Prosemirror doc node instance
|
|
1266
|
+
*/
|
|
1267
|
+
type DocumentType<TDocAttributes extends Record<string, any> | undefined = Record<string, any>, TContentType extends NodeType[] = NodeType[]> = Omit<NodeType<'doc', TDocAttributes, never, TContentType>, 'marks' | 'content'> & {
|
|
1268
|
+
content: TContentType;
|
|
1269
|
+
};
|
|
1270
|
+
/**
|
|
1271
|
+
* A node type is either a JSON representation of a text node or a Prosemirror text node instance
|
|
1272
|
+
*/
|
|
1273
|
+
type TextType<TMarkType extends MarkType = MarkType> = {
|
|
1274
|
+
type: 'text';
|
|
1275
|
+
text: string;
|
|
1276
|
+
marks: TMarkType[];
|
|
1277
|
+
};
|
|
1278
|
+
/**
|
|
1279
|
+
* Describes the output of a `renderHTML` function in prosemirror
|
|
1280
|
+
* @see https://prosemirror.net/docs/ref/#model.DOMOutputSpec
|
|
1281
|
+
*/
|
|
1282
|
+
type DOMOutputSpecArray$1 = [string] | [string, Record<string, any>] | [string, 0] | [string, Record<string, any>, 0] | [string, Record<string, any>, DOMOutputSpecArray$1 | 0] | [string, DOMOutputSpecArray$1];
|
|
1283
|
+
type Content = HTMLContent | JSONContent | JSONContent[] | null;
|
|
1284
|
+
type CommandProps = {
|
|
1285
|
+
editor: Editor;
|
|
1286
|
+
tr: Transaction;
|
|
1287
|
+
commands: SingleCommands;
|
|
1288
|
+
can: () => CanCommands;
|
|
1289
|
+
chain: () => ChainedCommands;
|
|
1290
|
+
state: EditorState;
|
|
1291
|
+
view: EditorView;
|
|
1292
|
+
dispatch: ((args?: any) => any) | undefined;
|
|
1293
|
+
};
|
|
1294
|
+
type Command = (props: CommandProps) => boolean;
|
|
1295
|
+
type CommandSpec = (...args: any[]) => Command;
|
|
1296
|
+
type KeyboardShortcutCommand = (props: {
|
|
1297
|
+
editor: Editor;
|
|
1298
|
+
}) => boolean;
|
|
1299
|
+
type Attribute = {
|
|
1300
|
+
default?: any;
|
|
1301
|
+
validate?: string | ((value: any) => void);
|
|
1302
|
+
rendered?: boolean;
|
|
1303
|
+
renderHTML?: ((attributes: Record<string, any>) => Record<string, any> | null) | null;
|
|
1304
|
+
parseHTML?: ((element: HTMLElement) => any | null) | null;
|
|
1305
|
+
keepOnSplit?: boolean;
|
|
1306
|
+
isRequired?: boolean;
|
|
1307
|
+
};
|
|
1308
|
+
type Attributes$1 = {
|
|
1309
|
+
[key: string]: Attribute;
|
|
1310
|
+
};
|
|
1311
|
+
type ExtensionAttribute = {
|
|
1312
|
+
type: string;
|
|
1313
|
+
name: string;
|
|
1314
|
+
attribute: Required<Omit<Attribute, 'validate'>> & Pick<Attribute, 'validate'>;
|
|
1315
|
+
};
|
|
1316
|
+
type GlobalAttributes = {
|
|
1317
|
+
/**
|
|
1318
|
+
* The node & mark types this attribute should be applied to.
|
|
1319
|
+
*/
|
|
1320
|
+
types: string[];
|
|
1321
|
+
/**
|
|
1322
|
+
* The attributes to add to the node or mark types.
|
|
1323
|
+
*/
|
|
1324
|
+
attributes: Record<string, Attribute | undefined>;
|
|
1325
|
+
}[];
|
|
1326
|
+
type PickValue<T, K extends keyof T> = T[K];
|
|
1327
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
1328
|
+
type Diff<T extends keyof any, U extends keyof any> = ({
|
|
1329
|
+
[P in T]: P;
|
|
1330
|
+
} & {
|
|
1331
|
+
[P in U]: never;
|
|
1332
|
+
} & {
|
|
1333
|
+
[x: string]: never;
|
|
1334
|
+
})[T];
|
|
1335
|
+
type Overwrite<T, U> = Pick<T, Diff<keyof T, keyof U>> & U;
|
|
1336
|
+
type ValuesOf<T> = T[keyof T];
|
|
1337
|
+
type KeysWithTypeOf<T, Type> = {
|
|
1338
|
+
[P in keyof T]: T[P] extends Type ? P : never;
|
|
1339
|
+
}[keyof T];
|
|
1340
|
+
type DOMNode = InstanceType<typeof window.Node>;
|
|
1341
|
+
/**
|
|
1342
|
+
* prosemirror-view does not export the `type` property of `Decoration`.
|
|
1343
|
+
* So, this defines the `DecorationType` interface to include the `type` property.
|
|
1344
|
+
*/
|
|
1345
|
+
interface DecorationType {
|
|
1346
|
+
spec: any;
|
|
1347
|
+
map(mapping: Mappable, span: Decoration, offset: number, oldOffset: number): Decoration | null;
|
|
1348
|
+
valid(node: Node, span: Decoration): boolean;
|
|
1349
|
+
eq(other: DecorationType): boolean;
|
|
1350
|
+
destroy(dom: DOMNode): void;
|
|
1351
|
+
readonly attrs: DecorationAttrs;
|
|
1352
|
+
}
|
|
1353
|
+
/**
|
|
1354
|
+
* prosemirror-view does not export the `type` property of `Decoration`.
|
|
1355
|
+
* This adds the `type` property to the `Decoration` type.
|
|
1356
|
+
*/
|
|
1357
|
+
type DecorationWithType = Decoration & {
|
|
1358
|
+
type: DecorationType;
|
|
1359
|
+
};
|
|
1360
|
+
interface NodeViewProps extends NodeViewRendererProps {
|
|
1361
|
+
decorations: readonly DecorationWithType[];
|
|
1362
|
+
selected: boolean;
|
|
1363
|
+
updateAttributes: (attributes: Record<string, any>) => void;
|
|
1364
|
+
deleteNode: () => void;
|
|
1365
|
+
}
|
|
1366
|
+
interface NodeViewRendererOptions {
|
|
1367
|
+
stopEvent: ((props: {
|
|
1368
|
+
event: Event;
|
|
1369
|
+
}) => boolean) | null;
|
|
1370
|
+
ignoreMutation: ((props: {
|
|
1371
|
+
mutation: ViewMutationRecord;
|
|
1372
|
+
}) => boolean) | null;
|
|
1373
|
+
contentDOMElementTag: string;
|
|
1374
|
+
}
|
|
1375
|
+
interface NodeViewRendererProps {
|
|
1376
|
+
/**
|
|
1377
|
+
* The node that is being rendered.
|
|
1378
|
+
*/
|
|
1379
|
+
node: Parameters<NodeViewConstructor>[0];
|
|
1380
|
+
/**
|
|
1381
|
+
* The editor's view.
|
|
1382
|
+
*/
|
|
1383
|
+
view: Parameters<NodeViewConstructor>[1];
|
|
1384
|
+
/**
|
|
1385
|
+
* A function that can be called to get the node's current position in the document.
|
|
1386
|
+
*/
|
|
1387
|
+
getPos: Parameters<NodeViewConstructor>[2];
|
|
1388
|
+
/**
|
|
1389
|
+
* is an array of node or inline decorations that are active around the node.
|
|
1390
|
+
* They are automatically drawn in the normal way, and you will usually just want to ignore this, but they can also be used as a way to provide context information to the node view without adding it to the document itself.
|
|
1391
|
+
*/
|
|
1392
|
+
decorations: Parameters<NodeViewConstructor>[3];
|
|
1393
|
+
/**
|
|
1394
|
+
* holds the decorations for the node's content. You can safely ignore this if your view has no content or a contentDOM property, since the editor will draw the decorations on the content.
|
|
1395
|
+
* But if you, for example, want to create a nested editor with the content, it may make sense to provide it with the inner decorations.
|
|
1396
|
+
*/
|
|
1397
|
+
innerDecorations: Parameters<NodeViewConstructor>[4];
|
|
1398
|
+
/**
|
|
1399
|
+
* The editor instance.
|
|
1400
|
+
*/
|
|
1401
|
+
editor: Editor;
|
|
1402
|
+
/**
|
|
1403
|
+
* The extension that is responsible for the node.
|
|
1404
|
+
*/
|
|
1405
|
+
extension: Node;
|
|
1406
|
+
/**
|
|
1407
|
+
* The HTML attributes that should be added to the node's DOM element.
|
|
1408
|
+
*/
|
|
1409
|
+
HTMLAttributes: Record<string, any>;
|
|
1410
|
+
}
|
|
1411
|
+
type NodeViewRenderer = (props: NodeViewRendererProps) => NodeView$1;
|
|
1412
|
+
interface MarkViewProps extends MarkViewRendererProps {
|
|
1413
|
+
}
|
|
1414
|
+
interface MarkViewRendererProps {
|
|
1415
|
+
/**
|
|
1416
|
+
* The node that is being rendered.
|
|
1417
|
+
*/
|
|
1418
|
+
mark: Parameters<MarkViewConstructor>[0];
|
|
1419
|
+
/**
|
|
1420
|
+
* The editor's view.
|
|
1421
|
+
*/
|
|
1422
|
+
view: Parameters<MarkViewConstructor>[1];
|
|
1423
|
+
/**
|
|
1424
|
+
* indicates whether the mark's content is inline
|
|
1425
|
+
*/
|
|
1426
|
+
inline: Parameters<MarkViewConstructor>[2];
|
|
1427
|
+
/**
|
|
1428
|
+
* The editor instance.
|
|
1429
|
+
*/
|
|
1430
|
+
editor: Editor;
|
|
1431
|
+
/**
|
|
1432
|
+
* The extension that is responsible for the mark.
|
|
1433
|
+
*/
|
|
1434
|
+
extension: Mark;
|
|
1435
|
+
/**
|
|
1436
|
+
* The HTML attributes that should be added to the mark's DOM element.
|
|
1437
|
+
*/
|
|
1438
|
+
HTMLAttributes: Record<string, any>;
|
|
1439
|
+
updateAttributes: (attrs: Record<string, any>) => void;
|
|
1440
|
+
}
|
|
1441
|
+
type MarkViewRenderer<Props = MarkViewRendererProps> = (props: Props) => MarkView$1;
|
|
1442
|
+
interface MarkViewRendererOptions {
|
|
1443
|
+
ignoreMutation: ((props: {
|
|
1444
|
+
mutation: ViewMutationRecord;
|
|
1445
|
+
}) => boolean) | null;
|
|
1446
|
+
}
|
|
1447
|
+
type AnyCommands = Record<string, (...args: any[]) => Command>;
|
|
1448
|
+
type UnionCommands<T = Command> = UnionToIntersection<ValuesOf<Pick<Commands<T>, KeysWithTypeOf<Commands<T>, object>>>>;
|
|
1449
|
+
type RawCommands = {
|
|
1450
|
+
[Item in keyof UnionCommands]: UnionCommands<Command>[Item];
|
|
1451
|
+
};
|
|
1452
|
+
type SingleCommands = {
|
|
1453
|
+
[Item in keyof UnionCommands]: UnionCommands<boolean>[Item];
|
|
1454
|
+
};
|
|
1455
|
+
type ChainedCommands = {
|
|
1456
|
+
[Item in keyof UnionCommands]: UnionCommands<ChainedCommands>[Item];
|
|
1457
|
+
} & {
|
|
1458
|
+
run: () => boolean;
|
|
1459
|
+
};
|
|
1460
|
+
type CanCommands = SingleCommands & {
|
|
1461
|
+
chain: () => ChainedCommands;
|
|
1462
|
+
};
|
|
1463
|
+
type FocusPosition = 'start' | 'end' | 'all' | number | boolean | null;
|
|
1464
|
+
type Range = {
|
|
1465
|
+
from: number;
|
|
1466
|
+
to: number;
|
|
1467
|
+
};
|
|
1468
|
+
type NodeRange = {
|
|
1469
|
+
node: Node$1;
|
|
1470
|
+
from: number;
|
|
1471
|
+
to: number;
|
|
1472
|
+
};
|
|
1473
|
+
type MarkRange = {
|
|
1474
|
+
mark: Mark$1;
|
|
1475
|
+
from: number;
|
|
1476
|
+
to: number;
|
|
1477
|
+
};
|
|
1478
|
+
type Predicate = (node: Node$1) => boolean;
|
|
1479
|
+
type NodeWithPos = {
|
|
1480
|
+
node: Node$1;
|
|
1481
|
+
pos: number;
|
|
1482
|
+
};
|
|
1483
|
+
type TextSerializer = (props: {
|
|
1484
|
+
node: Node$1;
|
|
1485
|
+
pos: number;
|
|
1486
|
+
parent: Node$1;
|
|
1487
|
+
index: number;
|
|
1488
|
+
range: Range;
|
|
1489
|
+
}) => string;
|
|
1490
|
+
type ExtendedRegExpMatchArray = RegExpMatchArray & {
|
|
1491
|
+
data?: Record<string, any>;
|
|
1492
|
+
};
|
|
1493
|
+
type Dispatch = ((args?: any) => any) | undefined;
|
|
1494
|
+
|
|
1495
|
+
/**
|
|
1496
|
+
* Create a new Prosemirror document node from content.
|
|
1497
|
+
* @param content The JSON or HTML content to create the document from
|
|
1498
|
+
* @param schema The Prosemirror schema to use for the document
|
|
1499
|
+
* @param parseOptions Options for the parser
|
|
1500
|
+
* @returns The created Prosemirror document node
|
|
1501
|
+
*/
|
|
1502
|
+
declare function createDocument(content: Content | Node$1 | Fragment$1, schema: Schema, parseOptions?: ParseOptions, options?: {
|
|
1503
|
+
errorOnInvalidContent?: boolean;
|
|
1504
|
+
}): Node$1;
|
|
1505
|
+
|
|
1506
|
+
type CreateNodeFromContentOptions = {
|
|
1507
|
+
slice?: boolean;
|
|
1508
|
+
parseOptions?: ParseOptions;
|
|
1509
|
+
errorOnInvalidContent?: boolean;
|
|
1510
|
+
};
|
|
1511
|
+
/**
|
|
1512
|
+
* Takes a JSON or HTML content and creates a Prosemirror node or fragment from it.
|
|
1513
|
+
* @param content The JSON or HTML content to create the node from
|
|
1514
|
+
* @param schema The Prosemirror schema to use for the node
|
|
1515
|
+
* @param options Options for the parser
|
|
1516
|
+
* @returns The created Prosemirror node or fragment
|
|
1517
|
+
*/
|
|
1518
|
+
declare function createNodeFromContent(content: Content | Node$1 | Fragment$1, schema: Schema, options?: CreateNodeFromContentOptions): Node$1 | Fragment$1;
|
|
1519
|
+
|
|
1520
|
+
/**
|
|
1521
|
+
* Gets the default block type at a given match
|
|
1522
|
+
* @param match The content match to get the default block type from
|
|
1523
|
+
* @returns The default block type or null
|
|
1524
|
+
*/
|
|
1525
|
+
declare function defaultBlockAt(match: ContentMatch): NodeType$1 | null;
|
|
1526
|
+
|
|
1527
|
+
/**
|
|
1528
|
+
* Find children inside a Prosemirror node that match a predicate.
|
|
1529
|
+
* @param node The Prosemirror node to search in
|
|
1530
|
+
* @param predicate The predicate to match
|
|
1531
|
+
* @returns An array of nodes with their positions
|
|
1532
|
+
*/
|
|
1533
|
+
declare function findChildren(node: Node$1, predicate: Predicate): NodeWithPos[];
|
|
1534
|
+
|
|
1535
|
+
/**
|
|
1536
|
+
* Same as `findChildren` but searches only within a `range`.
|
|
1537
|
+
* @param node The Prosemirror node to search in
|
|
1538
|
+
* @param range The range to search in
|
|
1539
|
+
* @param predicate The predicate to match
|
|
1540
|
+
* @returns An array of nodes with their positions
|
|
1541
|
+
*/
|
|
1542
|
+
declare function findChildrenInRange(node: Node$1, range: Range, predicate: Predicate): NodeWithPos[];
|
|
1543
|
+
|
|
1544
|
+
/**
|
|
1545
|
+
* Finds the closest parent node to a resolved position that matches a predicate.
|
|
1546
|
+
* @param $pos The resolved position to search from
|
|
1547
|
+
* @param predicate The predicate to match
|
|
1548
|
+
* @returns The closest parent node to the resolved position that matches the predicate
|
|
1549
|
+
* @example ```js
|
|
1550
|
+
* findParentNodeClosestToPos($from, node => node.type.name === 'paragraph')
|
|
1551
|
+
* ```
|
|
1552
|
+
*/
|
|
1553
|
+
declare function findParentNodeClosestToPos($pos: ResolvedPos, predicate: Predicate): {
|
|
1554
|
+
pos: number;
|
|
1555
|
+
start: number;
|
|
1556
|
+
depth: number;
|
|
1557
|
+
node: Node$1;
|
|
1558
|
+
} | undefined;
|
|
1559
|
+
|
|
1560
|
+
/**
|
|
1561
|
+
* Finds the closest parent node to the current selection that matches a predicate.
|
|
1562
|
+
* @param predicate The predicate to match
|
|
1563
|
+
* @returns A command that finds the closest parent node to the current selection that matches the predicate
|
|
1564
|
+
* @example ```js
|
|
1565
|
+
* findParentNode(node => node.type.name === 'paragraph')
|
|
1566
|
+
* ```
|
|
1567
|
+
*/
|
|
1568
|
+
declare function findParentNode(predicate: Predicate): (selection: Selection) => ReturnType<typeof findParentNodeClosestToPos>;
|
|
1569
|
+
|
|
1570
|
+
/**
|
|
1571
|
+
* Create a flattened array of extensions by traversing the `addExtensions` field.
|
|
1572
|
+
* @param extensions An array of Tiptap extensions
|
|
1573
|
+
* @returns A flattened array of Tiptap extensions
|
|
1574
|
+
*/
|
|
1575
|
+
declare function flattenExtensions(extensions: Extensions): Extensions;
|
|
1576
|
+
|
|
1577
|
+
/**
|
|
1578
|
+
* Generate HTML from a JSONContent
|
|
1579
|
+
* @param doc The JSONContent to generate HTML from
|
|
1580
|
+
* @param extensions The extensions to use for the schema
|
|
1581
|
+
* @returns The generated HTML
|
|
1582
|
+
*/
|
|
1583
|
+
declare function generateHTML(doc: JSONContent, extensions: Extensions): string;
|
|
1584
|
+
|
|
1585
|
+
/**
|
|
1586
|
+
* Generate JSONContent from HTML
|
|
1587
|
+
* @param html The HTML to generate JSONContent from
|
|
1588
|
+
* @param extensions The extensions to use for the schema
|
|
1589
|
+
* @returns The generated JSONContent
|
|
1590
|
+
*/
|
|
1591
|
+
declare function generateJSON(html: string, extensions: Extensions): Record<string, any>;
|
|
1592
|
+
|
|
1593
|
+
/**
|
|
1594
|
+
* Generate raw text from a JSONContent
|
|
1595
|
+
* @param doc The JSONContent to generate text from
|
|
1596
|
+
* @param extensions The extensions to use for the schema
|
|
1597
|
+
* @param options Options for the text generation f.e. blockSeparator or textSerializers
|
|
1598
|
+
* @returns The generated text
|
|
1599
|
+
*/
|
|
1600
|
+
declare function generateText(doc: JSONContent, extensions: Extensions, options?: {
|
|
1601
|
+
blockSeparator?: string;
|
|
1602
|
+
textSerializers?: Record<string, TextSerializer>;
|
|
1603
|
+
}): string;
|
|
1604
|
+
|
|
1605
|
+
/**
|
|
1606
|
+
* Get node or mark attributes by type or name on the current editor state
|
|
1607
|
+
* @param state The current editor state
|
|
1608
|
+
* @param typeOrName The node or mark type or name
|
|
1609
|
+
* @returns The attributes of the node or mark or an empty object
|
|
1610
|
+
*/
|
|
1611
|
+
declare function getAttributes(state: EditorState, typeOrName: string | NodeType$1 | MarkType$1): Record<string, any>;
|
|
1612
|
+
|
|
1613
|
+
/**
|
|
1614
|
+
* Get a list of all extension attributes defined in `addAttribute` and `addGlobalAttribute`.
|
|
1615
|
+
* @param extensions List of extensions
|
|
1616
|
+
*/
|
|
1617
|
+
declare function getAttributesFromExtensions(extensions: Extensions): ExtensionAttribute[];
|
|
1618
|
+
|
|
1619
|
+
type ChangedRange = {
|
|
1620
|
+
oldRange: Range;
|
|
1621
|
+
newRange: Range;
|
|
1622
|
+
};
|
|
1623
|
+
/**
|
|
1624
|
+
* Returns a list of changed ranges
|
|
1625
|
+
* based on the first and last state of all steps.
|
|
1626
|
+
*/
|
|
1627
|
+
declare function getChangedRanges(transform: Transform): ChangedRange[];
|
|
1628
|
+
|
|
1629
|
+
interface DebugJSONContent extends JSONContent {
|
|
1630
|
+
from: number;
|
|
1631
|
+
to: number;
|
|
1632
|
+
}
|
|
1633
|
+
declare function getDebugJSON(node: Node$1, startOffset?: number): DebugJSONContent;
|
|
1634
|
+
|
|
1635
|
+
interface ExtensionConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, ExtensionConfig<Options, Storage>, null> {
|
|
1636
|
+
}
|
|
1637
|
+
/**
|
|
1638
|
+
* The Extension class is the base class for all extensions.
|
|
1639
|
+
* @see https://tiptap.dev/api/extensions#create-a-new-extension
|
|
1640
|
+
*/
|
|
1641
|
+
declare class Extension<Options = any, Storage = any> extends Extendable<Options, Storage, ExtensionConfig<Options, Storage>> {
|
|
1642
|
+
type: string;
|
|
1643
|
+
/**
|
|
1644
|
+
* Create a new Extension instance
|
|
1645
|
+
* @param config - Extension configuration object or a function that returns a configuration object
|
|
1646
|
+
*/
|
|
1647
|
+
static create<O = any, S = any>(config?: Partial<ExtensionConfig<O, S>> | (() => Partial<ExtensionConfig<O, S>>)): Extension<O, S>;
|
|
1648
|
+
configure(options?: Partial<Options>): Extension<Options, Storage>;
|
|
1649
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)): Extension<ExtendedOptions, ExtendedStorage>;
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
/**
|
|
1653
|
+
* Returns a field from an extension
|
|
1654
|
+
* @param extension The Tiptap extension
|
|
1655
|
+
* @param field The field, for example `renderHTML` or `priority`
|
|
1656
|
+
* @param context The context object that should be passed as `this` into the function
|
|
1657
|
+
* @returns The field value
|
|
1658
|
+
*/
|
|
1659
|
+
declare function getExtensionField<T = any, E extends AnyExtension = any>(extension: E, field: keyof ExtensionConfig | keyof MarkConfig | keyof NodeConfig, context?: Omit<MaybeThisParameterType<T>, 'parent'>): RemoveThis<T>;
|
|
1660
|
+
|
|
1661
|
+
declare function getHTMLFromFragment(fragment: Fragment$1, schema: Schema): string;
|
|
1662
|
+
|
|
1663
|
+
declare function getMarkAttributes(state: EditorState, typeOrName: string | MarkType$1): Record<string, any>;
|
|
1664
|
+
|
|
1665
|
+
/**
|
|
1666
|
+
* Get the range of a mark at a resolved position.
|
|
1667
|
+
*/
|
|
1668
|
+
declare function getMarkRange(
|
|
1669
|
+
/**
|
|
1670
|
+
* The position to get the mark range for.
|
|
1671
|
+
*/
|
|
1672
|
+
$pos: ResolvedPos,
|
|
1673
|
+
/**
|
|
1674
|
+
* The mark type to get the range for.
|
|
1675
|
+
*/
|
|
1676
|
+
type: MarkType$1,
|
|
1677
|
+
/**
|
|
1678
|
+
* The attributes to match against.
|
|
1679
|
+
* If not provided, only the first mark at the position will be matched.
|
|
1680
|
+
*/
|
|
1681
|
+
attributes?: Record<string, any>): Range | void;
|
|
1682
|
+
|
|
1683
|
+
declare function getMarksBetween(from: number, to: number, doc: Node$1): MarkRange[];
|
|
1684
|
+
|
|
1685
|
+
declare function getMarkType(nameOrType: string | MarkType$1, schema: Schema): MarkType$1;
|
|
1686
|
+
|
|
1687
|
+
/**
|
|
1688
|
+
* Finds the first node of a given type or name in the current selection.
|
|
1689
|
+
* @param state The editor state.
|
|
1690
|
+
* @param typeOrName The node type or name.
|
|
1691
|
+
* @param pos The position to start searching from.
|
|
1692
|
+
* @param maxDepth The maximum depth to search.
|
|
1693
|
+
* @returns The node and the depth as an array.
|
|
1694
|
+
*/
|
|
1695
|
+
declare const getNodeAtPosition: (state: EditorState, typeOrName: string | NodeType$1, pos: number, maxDepth?: number) => [Node$1 | null, number];
|
|
1696
|
+
|
|
1697
|
+
declare function getNodeAttributes(state: EditorState, typeOrName: string | NodeType$1): Record<string, any>;
|
|
1698
|
+
|
|
1699
|
+
declare function getNodeType(nameOrType: string | NodeType$1, schema: Schema): NodeType$1;
|
|
1700
|
+
|
|
1701
|
+
declare function getRenderedAttributes(nodeOrMark: Node$1 | Mark$1, extensionAttributes: ExtensionAttribute[]): Record<string, any>;
|
|
1702
|
+
|
|
1703
|
+
declare function getSchema(extensions: Extensions, editor?: Editor): Schema;
|
|
1704
|
+
|
|
1705
|
+
/**
|
|
1706
|
+
* Creates a new Prosemirror schema based on the given extensions.
|
|
1707
|
+
* @param extensions An array of Tiptap extensions
|
|
1708
|
+
* @param editor The editor instance
|
|
1709
|
+
* @returns A Prosemirror schema
|
|
1710
|
+
*/
|
|
1711
|
+
declare function getSchemaByResolvedExtensions(extensions: Extensions, editor?: Editor): Schema;
|
|
1712
|
+
|
|
1713
|
+
/**
|
|
1714
|
+
* Tries to get a node or mark type by its name.
|
|
1715
|
+
* @param name The name of the node or mark type
|
|
1716
|
+
* @param schema The Prosemiror schema to search in
|
|
1717
|
+
* @returns The node or mark type, or null if it doesn't exist
|
|
1718
|
+
*/
|
|
1719
|
+
declare function getSchemaTypeByName(name: string, schema: Schema): NodeType$1 | MarkType$1 | null;
|
|
1720
|
+
|
|
1721
|
+
/**
|
|
1722
|
+
* Get the type of a schema item by its name.
|
|
1723
|
+
* @param name The name of the schema item
|
|
1724
|
+
* @param schema The Prosemiror schema to search in
|
|
1725
|
+
* @returns The type of the schema item (`node` or `mark`), or null if it doesn't exist
|
|
1726
|
+
*/
|
|
1727
|
+
declare function getSchemaTypeNameByName(name: string, schema: Schema): 'node' | 'mark' | null;
|
|
1728
|
+
|
|
1729
|
+
/**
|
|
1730
|
+
* Return attributes of an extension that should be splitted by keepOnSplit flag
|
|
1731
|
+
* @param extensionAttributes Array of extension attributes
|
|
1732
|
+
* @param typeName The type of the extension
|
|
1733
|
+
* @param attributes The attributes of the extension
|
|
1734
|
+
* @returns The splitted attributes
|
|
1735
|
+
*/
|
|
1736
|
+
declare function getSplittedAttributes(extensionAttributes: ExtensionAttribute[], typeName: string, attributes: Record<string, any>): Record<string, any>;
|
|
1737
|
+
|
|
1738
|
+
/**
|
|
1739
|
+
* Gets the text of a Prosemirror node
|
|
1740
|
+
* @param node The Prosemirror node
|
|
1741
|
+
* @param options Options for the text serializer & block separator
|
|
1742
|
+
* @returns The text of the node
|
|
1743
|
+
* @example ```js
|
|
1744
|
+
* const text = getText(node, { blockSeparator: '\n' })
|
|
1745
|
+
* ```
|
|
1746
|
+
*/
|
|
1747
|
+
declare function getText(node: Node$1, options?: {
|
|
1748
|
+
blockSeparator?: string;
|
|
1749
|
+
textSerializers?: Record<string, TextSerializer>;
|
|
1750
|
+
}): string;
|
|
1751
|
+
|
|
1752
|
+
/**
|
|
1753
|
+
* Gets the text between two positions in a Prosemirror node
|
|
1754
|
+
* and serializes it using the given text serializers and block separator (see getText)
|
|
1755
|
+
* @param startNode The Prosemirror node to start from
|
|
1756
|
+
* @param range The range of the text to get
|
|
1757
|
+
* @param options Options for the text serializer & block separator
|
|
1758
|
+
* @returns The text between the two positions
|
|
1759
|
+
*/
|
|
1760
|
+
declare function getTextBetween(startNode: Node$1, range: Range, options?: {
|
|
1761
|
+
blockSeparator?: string;
|
|
1762
|
+
textSerializers?: Record<string, TextSerializer>;
|
|
1763
|
+
}): string;
|
|
1764
|
+
|
|
1765
|
+
/**
|
|
1766
|
+
* Returns the text content of a resolved prosemirror position
|
|
1767
|
+
* @param $from The resolved position to get the text content from
|
|
1768
|
+
* @param maxMatch The maximum number of characters to match
|
|
1769
|
+
* @returns The text content
|
|
1770
|
+
*/
|
|
1771
|
+
declare const getTextContentFromNodes: ($from: ResolvedPos, maxMatch?: number) => string;
|
|
1772
|
+
|
|
1773
|
+
/**
|
|
1774
|
+
* Find text serializers `toText` in a Prosemirror schema
|
|
1775
|
+
* @param schema The Prosemirror schema to search in
|
|
1776
|
+
* @returns A record of text serializers by node name
|
|
1777
|
+
*/
|
|
1778
|
+
declare function getTextSerializersFromSchema(schema: Schema): Record<string, TextSerializer>;
|
|
1779
|
+
|
|
1780
|
+
/**
|
|
1781
|
+
* This function merges extension attributes into parserule attributes (`attrs` or `getAttrs`).
|
|
1782
|
+
* Cancels when `getAttrs` returned `false`.
|
|
1783
|
+
* @param parseRule ProseMirror ParseRule
|
|
1784
|
+
* @param extensionAttributes List of attributes to inject
|
|
1785
|
+
*/
|
|
1786
|
+
declare function injectExtensionAttributesToParseRule(parseRule: ParseRule, extensionAttributes: ExtensionAttribute[]): ParseRule;
|
|
1787
|
+
|
|
1788
|
+
declare function isActive(state: EditorState, name: string | null, attributes?: Record<string, any>): boolean;
|
|
1789
|
+
|
|
1790
|
+
declare const isAtEndOfNode: (state: EditorState, nodeType?: string) => boolean;
|
|
1791
|
+
|
|
1792
|
+
declare const isAtStartOfNode: (state: EditorState) => boolean;
|
|
1793
|
+
|
|
1794
|
+
declare function isExtensionRulesEnabled(extension: AnyExtension, enabled: EnableRules): boolean;
|
|
1795
|
+
|
|
1796
|
+
declare function isList(name: string, extensions: Extensions): boolean;
|
|
1797
|
+
|
|
1798
|
+
declare function isMarkActive(state: EditorState, typeOrName: MarkType$1 | string | null, attributes?: Record<string, any>): boolean;
|
|
1799
|
+
|
|
1800
|
+
declare function isNodeActive(state: EditorState, typeOrName: NodeType$1 | string | null, attributes?: Record<string, any>): boolean;
|
|
1801
|
+
|
|
1802
|
+
/**
|
|
1803
|
+
* Returns true if the given prosemirror node is empty.
|
|
1804
|
+
*/
|
|
1805
|
+
declare function isNodeEmpty(node: Node$1, { checkChildren, ignoreWhitespace, }?: {
|
|
1806
|
+
/**
|
|
1807
|
+
* When true (default), it will also check if all children are empty.
|
|
1808
|
+
*/
|
|
1809
|
+
checkChildren?: boolean;
|
|
1810
|
+
/**
|
|
1811
|
+
* When true, it will ignore whitespace when checking for emptiness.
|
|
1812
|
+
*/
|
|
1813
|
+
ignoreWhitespace?: boolean;
|
|
1814
|
+
}): boolean;
|
|
1815
|
+
|
|
1816
|
+
declare function isNodeSelection(value: unknown): value is NodeSelection;
|
|
1817
|
+
|
|
1818
|
+
declare function isTextSelection(value: unknown): value is TextSelection;
|
|
1819
|
+
|
|
1820
|
+
declare function posToDOMRect(view: EditorView, from: number, to: number): DOMRect;
|
|
1821
|
+
|
|
1822
|
+
/**
|
|
1823
|
+
* Returns a flattened and sorted extension list while
|
|
1824
|
+
* also checking for duplicated extensions and warns the user.
|
|
1825
|
+
* @param extensions An array of Tiptap extensions
|
|
1826
|
+
* @returns An flattened and sorted array of Tiptap extensions
|
|
1827
|
+
*/
|
|
1828
|
+
declare function resolveExtensions(extensions: Extensions): Extensions;
|
|
1829
|
+
|
|
1830
|
+
declare function resolveFocusPosition(doc: Node$1, position?: FocusPosition): Selection | null;
|
|
1831
|
+
|
|
1832
|
+
type RewriteUnknownContentOptions = {
|
|
1833
|
+
/**
|
|
1834
|
+
* If true, unknown nodes will be treated as paragraphs
|
|
1835
|
+
* @default true
|
|
1836
|
+
*/
|
|
1837
|
+
fallbackToParagraph?: boolean;
|
|
1838
|
+
};
|
|
1839
|
+
/**
|
|
1840
|
+
* Rewrite unknown nodes and marks within JSON content
|
|
1841
|
+
* Allowing for user within the editor
|
|
1842
|
+
*/
|
|
1843
|
+
declare function rewriteUnknownContent(
|
|
1844
|
+
/**
|
|
1845
|
+
* The JSON content to clean of unknown nodes and marks
|
|
1846
|
+
*/
|
|
1847
|
+
json: JSONContent,
|
|
1848
|
+
/**
|
|
1849
|
+
* The schema to use for validation
|
|
1850
|
+
*/
|
|
1851
|
+
schema: Schema,
|
|
1852
|
+
/**
|
|
1853
|
+
* Options for the cleaning process
|
|
1854
|
+
*/
|
|
1855
|
+
options?: RewriteUnknownContentOptions): {
|
|
1856
|
+
/**
|
|
1857
|
+
* The cleaned JSON content
|
|
1858
|
+
*/
|
|
1859
|
+
json: JSONContent | null;
|
|
1860
|
+
/**
|
|
1861
|
+
* The array of nodes and marks that were rewritten
|
|
1862
|
+
*/
|
|
1863
|
+
rewrittenContent: {
|
|
1864
|
+
/**
|
|
1865
|
+
* The original JSON content that was rewritten
|
|
1866
|
+
*/
|
|
1867
|
+
original: JSONContent;
|
|
1868
|
+
/**
|
|
1869
|
+
* The name of the node or mark that was unsupported
|
|
1870
|
+
*/
|
|
1871
|
+
unsupported: string;
|
|
1872
|
+
}[];
|
|
1873
|
+
};
|
|
1874
|
+
|
|
1875
|
+
declare function selectionToInsertionEnd(tr: Transaction, startLen: number, bias: number): void;
|
|
1876
|
+
|
|
1877
|
+
/**
|
|
1878
|
+
* Sort extensions by priority.
|
|
1879
|
+
* @param extensions An array of Tiptap extensions
|
|
1880
|
+
* @returns A sorted array of Tiptap extensions by priority
|
|
1881
|
+
*/
|
|
1882
|
+
declare function sortExtensions(extensions: Extensions): Extensions;
|
|
1883
|
+
|
|
1884
|
+
declare function splitExtensions(extensions: Extensions): {
|
|
1885
|
+
baseExtensions: Extension<any, any>[];
|
|
1886
|
+
nodeExtensions: Node<any, any>[];
|
|
1887
|
+
markExtensions: Mark<any, any>[];
|
|
1888
|
+
};
|
|
1889
|
+
|
|
1890
|
+
declare class ExtensionManager {
|
|
1891
|
+
editor: Editor;
|
|
1892
|
+
schema: Schema;
|
|
1893
|
+
extensions: Extensions;
|
|
1894
|
+
splittableMarks: string[];
|
|
1895
|
+
constructor(extensions: Extensions, editor: Editor);
|
|
1896
|
+
static resolve: typeof resolveExtensions;
|
|
1897
|
+
static sort: typeof sortExtensions;
|
|
1898
|
+
static flatten: typeof flattenExtensions;
|
|
1899
|
+
/**
|
|
1900
|
+
* Get all commands from the extensions.
|
|
1901
|
+
* @returns An object with all commands where the key is the command name and the value is the command function
|
|
1902
|
+
*/
|
|
1903
|
+
get commands(): RawCommands;
|
|
1904
|
+
/**
|
|
1905
|
+
* Get all registered Prosemirror plugins from the extensions.
|
|
1906
|
+
* @returns An array of Prosemirror plugins
|
|
1907
|
+
*/
|
|
1908
|
+
get plugins(): Plugin[];
|
|
1909
|
+
/**
|
|
1910
|
+
* Get all attributes from the extensions.
|
|
1911
|
+
* @returns An array of attributes
|
|
1912
|
+
*/
|
|
1913
|
+
get attributes(): ExtensionAttribute[];
|
|
1914
|
+
/**
|
|
1915
|
+
* Get all node views from the extensions.
|
|
1916
|
+
* @returns An object with all node views where the key is the node name and the value is the node view function
|
|
1917
|
+
*/
|
|
1918
|
+
get nodeViews(): Record<string, NodeViewConstructor>;
|
|
1919
|
+
get markViews(): Record<string, MarkViewConstructor>;
|
|
1920
|
+
/**
|
|
1921
|
+
* Go through all extensions, create extension storages & setup marks
|
|
1922
|
+
* & bind editor event listener.
|
|
1923
|
+
*/
|
|
1924
|
+
private setupExtensions;
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
declare class NodePos {
|
|
1928
|
+
private resolvedPos;
|
|
1929
|
+
private isBlock;
|
|
1930
|
+
private editor;
|
|
1931
|
+
private get name();
|
|
1932
|
+
constructor(pos: ResolvedPos, editor: Editor, isBlock?: boolean, node?: Node$1 | null);
|
|
1933
|
+
private currentNode;
|
|
1934
|
+
get node(): Node$1;
|
|
1935
|
+
get element(): HTMLElement;
|
|
1936
|
+
actualDepth: number | null;
|
|
1937
|
+
get depth(): number;
|
|
1938
|
+
get pos(): number;
|
|
1939
|
+
get content(): Fragment$1;
|
|
1940
|
+
set content(content: Content);
|
|
1941
|
+
get attributes(): {
|
|
1942
|
+
[key: string]: any;
|
|
1943
|
+
};
|
|
1944
|
+
get textContent(): string;
|
|
1945
|
+
get size(): number;
|
|
1946
|
+
get from(): number;
|
|
1947
|
+
get range(): Range;
|
|
1948
|
+
get to(): number;
|
|
1949
|
+
get parent(): NodePos | null;
|
|
1950
|
+
get before(): NodePos | null;
|
|
1951
|
+
get after(): NodePos | null;
|
|
1952
|
+
get children(): NodePos[];
|
|
1953
|
+
get firstChild(): NodePos | null;
|
|
1954
|
+
get lastChild(): NodePos | null;
|
|
1955
|
+
closest(selector: string, attributes?: {
|
|
1956
|
+
[key: string]: any;
|
|
1957
|
+
}): NodePos | null;
|
|
1958
|
+
querySelector(selector: string, attributes?: {
|
|
1959
|
+
[key: string]: any;
|
|
1960
|
+
}): NodePos | null;
|
|
1961
|
+
querySelectorAll(selector: string, attributes?: {
|
|
1962
|
+
[key: string]: any;
|
|
1963
|
+
}, firstItemOnly?: boolean): NodePos[];
|
|
1964
|
+
setAttribute(attributes: {
|
|
1965
|
+
[key: string]: any;
|
|
1966
|
+
}): void;
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
type ClipboardTextSerializerOptions = {
|
|
1970
|
+
blockSeparator?: string;
|
|
1971
|
+
};
|
|
1972
|
+
declare const ClipboardTextSerializer: Extension<ClipboardTextSerializerOptions, any>;
|
|
1973
|
+
|
|
1974
|
+
declare module '@tiptap/core' {
|
|
1975
|
+
interface Commands<ReturnType> {
|
|
1976
|
+
blur: {
|
|
1977
|
+
/**
|
|
1978
|
+
* Removes focus from the editor.
|
|
1979
|
+
* @example editor.commands.blur()
|
|
1980
|
+
*/
|
|
1981
|
+
blur: () => ReturnType;
|
|
1982
|
+
};
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
declare module '@tiptap/core' {
|
|
1987
|
+
interface Commands<ReturnType> {
|
|
1988
|
+
clearContent: {
|
|
1989
|
+
/**
|
|
1990
|
+
* Clear the whole document.
|
|
1991
|
+
* @example editor.commands.clearContent()
|
|
1992
|
+
*/
|
|
1993
|
+
clearContent: (
|
|
1994
|
+
/**
|
|
1995
|
+
* Whether to emit an update event.
|
|
1996
|
+
* @default true
|
|
1997
|
+
*/
|
|
1998
|
+
emitUpdate?: boolean) => ReturnType;
|
|
1999
|
+
};
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
declare module '@tiptap/core' {
|
|
2004
|
+
interface Commands<ReturnType> {
|
|
2005
|
+
clearNodes: {
|
|
2006
|
+
/**
|
|
2007
|
+
* Normalize nodes to a simple paragraph.
|
|
2008
|
+
* @example editor.commands.clearNodes()
|
|
2009
|
+
*/
|
|
2010
|
+
clearNodes: () => ReturnType;
|
|
2011
|
+
};
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
|
|
2015
|
+
declare module '@tiptap/core' {
|
|
2016
|
+
interface Commands<ReturnType> {
|
|
2017
|
+
command: {
|
|
2018
|
+
/**
|
|
2019
|
+
* Define a command inline.
|
|
2020
|
+
* @param fn The command function.
|
|
2021
|
+
* @example
|
|
2022
|
+
* editor.commands.command(({ tr, state }) => {
|
|
2023
|
+
* ...
|
|
2024
|
+
* return true
|
|
2025
|
+
* })
|
|
2026
|
+
*/
|
|
2027
|
+
command: (fn: (props: Parameters<Command>[0]) => boolean) => ReturnType;
|
|
2028
|
+
};
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
declare module '@tiptap/core' {
|
|
2033
|
+
interface Commands<ReturnType> {
|
|
2034
|
+
createParagraphNear: {
|
|
2035
|
+
/**
|
|
2036
|
+
* Create a paragraph nearby.
|
|
2037
|
+
* @example editor.commands.createParagraphNear()
|
|
2038
|
+
*/
|
|
2039
|
+
createParagraphNear: () => ReturnType;
|
|
2040
|
+
};
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
declare module '@tiptap/core' {
|
|
2045
|
+
interface Commands<ReturnType> {
|
|
2046
|
+
cut: {
|
|
2047
|
+
/**
|
|
2048
|
+
* Cuts content from a range and inserts it at a given position.
|
|
2049
|
+
* @param range The range to cut.
|
|
2050
|
+
* @param range.from The start position of the range.
|
|
2051
|
+
* @param range.to The end position of the range.
|
|
2052
|
+
* @param targetPos The position to insert the content at.
|
|
2053
|
+
* @example editor.commands.cut({ from: 1, to: 3 }, 5)
|
|
2054
|
+
*/
|
|
2055
|
+
cut: ({ from, to }: {
|
|
2056
|
+
from: number;
|
|
2057
|
+
to: number;
|
|
2058
|
+
}, targetPos: number) => ReturnType;
|
|
2059
|
+
};
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
declare module '@tiptap/core' {
|
|
2064
|
+
interface Commands<ReturnType> {
|
|
2065
|
+
deleteCurrentNode: {
|
|
2066
|
+
/**
|
|
2067
|
+
* Delete the node that currently has the selection anchor.
|
|
2068
|
+
* @example editor.commands.deleteCurrentNode()
|
|
2069
|
+
*/
|
|
2070
|
+
deleteCurrentNode: () => ReturnType;
|
|
2071
|
+
};
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
|
|
2075
|
+
declare module '@tiptap/core' {
|
|
2076
|
+
interface Commands<ReturnType> {
|
|
2077
|
+
deleteNode: {
|
|
2078
|
+
/**
|
|
2079
|
+
* Delete a node with a given type or name.
|
|
2080
|
+
* @param typeOrName The type or name of the node.
|
|
2081
|
+
* @example editor.commands.deleteNode('paragraph')
|
|
2082
|
+
*/
|
|
2083
|
+
deleteNode: (typeOrName: string | NodeType$1) => ReturnType;
|
|
2084
|
+
};
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
|
|
2088
|
+
declare module '@tiptap/core' {
|
|
2089
|
+
interface Commands<ReturnType> {
|
|
2090
|
+
deleteRange: {
|
|
2091
|
+
/**
|
|
2092
|
+
* Delete a given range.
|
|
2093
|
+
* @param range The range to delete.
|
|
2094
|
+
* @example editor.commands.deleteRange({ from: 1, to: 3 })
|
|
2095
|
+
*/
|
|
2096
|
+
deleteRange: (range: Range) => ReturnType;
|
|
2097
|
+
};
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
declare module '@tiptap/core' {
|
|
2102
|
+
interface Commands<ReturnType> {
|
|
2103
|
+
deleteSelection: {
|
|
2104
|
+
/**
|
|
2105
|
+
* Delete the selection, if there is one.
|
|
2106
|
+
* @example editor.commands.deleteSelection()
|
|
2107
|
+
*/
|
|
2108
|
+
deleteSelection: () => ReturnType;
|
|
2109
|
+
};
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
declare module '@tiptap/core' {
|
|
2114
|
+
interface Commands<ReturnType> {
|
|
2115
|
+
enter: {
|
|
2116
|
+
/**
|
|
2117
|
+
* Trigger enter.
|
|
2118
|
+
* @example editor.commands.enter()
|
|
2119
|
+
*/
|
|
2120
|
+
enter: () => ReturnType;
|
|
2121
|
+
};
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
declare module '@tiptap/core' {
|
|
2126
|
+
interface Commands<ReturnType> {
|
|
2127
|
+
exitCode: {
|
|
2128
|
+
/**
|
|
2129
|
+
* Exit from a code block.
|
|
2130
|
+
* @example editor.commands.exitCode()
|
|
2131
|
+
*/
|
|
2132
|
+
exitCode: () => ReturnType;
|
|
2133
|
+
};
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
declare module '@tiptap/core' {
|
|
2138
|
+
interface Commands<ReturnType> {
|
|
2139
|
+
extendMarkRange: {
|
|
2140
|
+
/**
|
|
2141
|
+
* Extends the text selection to the current mark by type or name.
|
|
2142
|
+
* @param typeOrName The type or name of the mark.
|
|
2143
|
+
* @param attributes The attributes of the mark.
|
|
2144
|
+
* @example editor.commands.extendMarkRange('bold')
|
|
2145
|
+
* @example editor.commands.extendMarkRange('mention', { userId: "1" })
|
|
2146
|
+
*/
|
|
2147
|
+
extendMarkRange: (
|
|
2148
|
+
/**
|
|
2149
|
+
* The type or name of the mark.
|
|
2150
|
+
*/
|
|
2151
|
+
typeOrName: string | MarkType$1,
|
|
2152
|
+
/**
|
|
2153
|
+
* The attributes of the mark.
|
|
2154
|
+
*/
|
|
2155
|
+
attributes?: Record<string, any>) => ReturnType;
|
|
2156
|
+
};
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
declare module '@tiptap/core' {
|
|
2161
|
+
interface Commands<ReturnType> {
|
|
2162
|
+
first: {
|
|
2163
|
+
/**
|
|
2164
|
+
* Runs one command after the other and stops at the first which returns true.
|
|
2165
|
+
* @param commands The commands to run.
|
|
2166
|
+
* @example editor.commands.first([command1, command2])
|
|
2167
|
+
*/
|
|
2168
|
+
first: (commands: Command[] | ((props: CommandProps) => Command[])) => ReturnType;
|
|
2169
|
+
};
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
declare module '@tiptap/core' {
|
|
2174
|
+
interface Commands<ReturnType> {
|
|
2175
|
+
focus: {
|
|
2176
|
+
/**
|
|
2177
|
+
* Focus the editor at the given position.
|
|
2178
|
+
* @param position The position to focus at.
|
|
2179
|
+
* @param options.scrollIntoView Scroll the focused position into view after focusing
|
|
2180
|
+
* @example editor.commands.focus()
|
|
2181
|
+
* @example editor.commands.focus(32, { scrollIntoView: false })
|
|
2182
|
+
*/
|
|
2183
|
+
focus: (
|
|
2184
|
+
/**
|
|
2185
|
+
* The position to focus at.
|
|
2186
|
+
*/
|
|
2187
|
+
position?: FocusPosition,
|
|
2188
|
+
/**
|
|
2189
|
+
* Optional options
|
|
2190
|
+
* @default { scrollIntoView: true }
|
|
2191
|
+
*/
|
|
2192
|
+
options?: {
|
|
2193
|
+
scrollIntoView?: boolean;
|
|
2194
|
+
}) => ReturnType;
|
|
2195
|
+
};
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2199
|
+
declare module '@tiptap/core' {
|
|
2200
|
+
interface Commands<ReturnType> {
|
|
2201
|
+
forEach: {
|
|
2202
|
+
/**
|
|
2203
|
+
* Loop through an array of items.
|
|
2204
|
+
*/
|
|
2205
|
+
forEach: <T>(items: T[], fn: (item: T, props: CommandProps & {
|
|
2206
|
+
index: number;
|
|
2207
|
+
}) => boolean) => ReturnType;
|
|
2208
|
+
};
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
|
|
2212
|
+
declare module '@tiptap/core' {
|
|
2213
|
+
interface Commands<ReturnType> {
|
|
2214
|
+
insertContent: {
|
|
2215
|
+
/**
|
|
2216
|
+
* Insert a node or string of HTML at the current position.
|
|
2217
|
+
* @example editor.commands.insertContent('<h1>Example</h1>')
|
|
2218
|
+
* @example editor.commands.insertContent('<h1>Example</h1>', { updateSelection: false })
|
|
2219
|
+
*/
|
|
2220
|
+
insertContent: (
|
|
2221
|
+
/**
|
|
2222
|
+
* The ProseMirror content to insert.
|
|
2223
|
+
*/
|
|
2224
|
+
value: Content | Node$1 | Fragment$1,
|
|
2225
|
+
/**
|
|
2226
|
+
* Optional options
|
|
2227
|
+
*/
|
|
2228
|
+
options?: {
|
|
2229
|
+
/**
|
|
2230
|
+
* Options for parsing the content.
|
|
2231
|
+
*/
|
|
2232
|
+
parseOptions?: ParseOptions;
|
|
2233
|
+
/**
|
|
2234
|
+
* Whether to update the selection after inserting the content.
|
|
2235
|
+
*/
|
|
2236
|
+
updateSelection?: boolean;
|
|
2237
|
+
applyInputRules?: boolean;
|
|
2238
|
+
applyPasteRules?: boolean;
|
|
2239
|
+
}) => ReturnType;
|
|
2240
|
+
};
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
declare module '@tiptap/core' {
|
|
2245
|
+
interface Commands<ReturnType> {
|
|
2246
|
+
insertContentAt: {
|
|
2247
|
+
/**
|
|
2248
|
+
* Insert a node or string of HTML at a specific position.
|
|
2249
|
+
* @example editor.commands.insertContentAt(0, '<h1>Example</h1>')
|
|
2250
|
+
*/
|
|
2251
|
+
insertContentAt: (
|
|
2252
|
+
/**
|
|
2253
|
+
* The position to insert the content at.
|
|
2254
|
+
*/
|
|
2255
|
+
position: number | Range,
|
|
2256
|
+
/**
|
|
2257
|
+
* The ProseMirror content to insert.
|
|
2258
|
+
*/
|
|
2259
|
+
value: Content | Node$1 | Fragment$1,
|
|
2260
|
+
/**
|
|
2261
|
+
* Optional options
|
|
2262
|
+
*/
|
|
2263
|
+
options?: {
|
|
2264
|
+
/**
|
|
2265
|
+
* Options for parsing the content.
|
|
2266
|
+
*/
|
|
2267
|
+
parseOptions?: ParseOptions;
|
|
2268
|
+
/**
|
|
2269
|
+
* Whether to update the selection after inserting the content.
|
|
2270
|
+
*/
|
|
2271
|
+
updateSelection?: boolean;
|
|
2272
|
+
/**
|
|
2273
|
+
* Whether to apply input rules after inserting the content.
|
|
2274
|
+
*/
|
|
2275
|
+
applyInputRules?: boolean;
|
|
2276
|
+
/**
|
|
2277
|
+
* Whether to apply paste rules after inserting the content.
|
|
2278
|
+
*/
|
|
2279
|
+
applyPasteRules?: boolean;
|
|
2280
|
+
/**
|
|
2281
|
+
* Whether to throw an error if the content is invalid.
|
|
2282
|
+
*/
|
|
2283
|
+
errorOnInvalidContent?: boolean;
|
|
2284
|
+
}) => ReturnType;
|
|
2285
|
+
};
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
declare module '@tiptap/core' {
|
|
2290
|
+
interface Commands<ReturnType> {
|
|
2291
|
+
joinUp: {
|
|
2292
|
+
/**
|
|
2293
|
+
* 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.
|
|
2294
|
+
* @example editor.commands.joinUp()
|
|
2295
|
+
*/
|
|
2296
|
+
joinUp: () => ReturnType;
|
|
2297
|
+
};
|
|
2298
|
+
joinDown: {
|
|
2299
|
+
/**
|
|
2300
|
+
* Join the selected block, or the closest ancestor of the selection that can be joined, with the sibling after it.
|
|
2301
|
+
* @example editor.commands.joinDown()
|
|
2302
|
+
*/
|
|
2303
|
+
joinDown: () => ReturnType;
|
|
2304
|
+
};
|
|
2305
|
+
joinBackward: {
|
|
2306
|
+
/**
|
|
2307
|
+
* 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.
|
|
2308
|
+
* If not, try to move the selected block closer to the next one in the document structure by lifting it out of its
|
|
2309
|
+
* 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.
|
|
2310
|
+
* @example editor.commands.joinBackward()
|
|
2311
|
+
*/
|
|
2312
|
+
joinBackward: () => ReturnType;
|
|
2313
|
+
};
|
|
2314
|
+
joinForward: {
|
|
2315
|
+
/**
|
|
2316
|
+
* 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,
|
|
2317
|
+
* either by joining them or by moving the other block closer to this one in the tree structure.
|
|
2318
|
+
* Will use the view for accurate start-of-textblock detection if given.
|
|
2319
|
+
* @example editor.commands.joinForward()
|
|
2320
|
+
*/
|
|
2321
|
+
joinForward: () => ReturnType;
|
|
2322
|
+
};
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
declare module '@tiptap/core' {
|
|
2327
|
+
interface Commands<ReturnType> {
|
|
2328
|
+
joinItemBackward: {
|
|
2329
|
+
/**
|
|
2330
|
+
* Join two items backward.
|
|
2331
|
+
* @example editor.commands.joinItemBackward()
|
|
2332
|
+
*/
|
|
2333
|
+
joinItemBackward: () => ReturnType;
|
|
2334
|
+
};
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
declare module '@tiptap/core' {
|
|
2339
|
+
interface Commands<ReturnType> {
|
|
2340
|
+
joinItemForward: {
|
|
2341
|
+
/**
|
|
2342
|
+
* Join two items Forwards.
|
|
2343
|
+
* @example editor.commands.joinItemForward()
|
|
2344
|
+
*/
|
|
2345
|
+
joinItemForward: () => ReturnType;
|
|
2346
|
+
};
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
declare module '@tiptap/core' {
|
|
2351
|
+
interface Commands<ReturnType> {
|
|
2352
|
+
joinTextblockBackward: {
|
|
2353
|
+
/**
|
|
2354
|
+
* A more limited form of joinBackward that only tries to join the current textblock to the one before it, if the cursor is at the start of a textblock.
|
|
2355
|
+
*/
|
|
2356
|
+
joinTextblockBackward: () => ReturnType;
|
|
2357
|
+
};
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2361
|
+
declare module '@tiptap/core' {
|
|
2362
|
+
interface Commands<ReturnType> {
|
|
2363
|
+
joinTextblockForward: {
|
|
2364
|
+
/**
|
|
2365
|
+
* A more limited form of joinForward that only tries to join the current textblock to the one after it, if the cursor is at the end of a textblock.
|
|
2366
|
+
*/
|
|
2367
|
+
joinTextblockForward: () => ReturnType;
|
|
2368
|
+
};
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
declare module '@tiptap/core' {
|
|
2373
|
+
interface Commands<ReturnType> {
|
|
2374
|
+
keyboardShortcut: {
|
|
2375
|
+
/**
|
|
2376
|
+
* Trigger a keyboard shortcut.
|
|
2377
|
+
* @param name The name of the keyboard shortcut.
|
|
2378
|
+
* @example editor.commands.keyboardShortcut('Mod-b')
|
|
2379
|
+
*/
|
|
2380
|
+
keyboardShortcut: (name: string) => ReturnType;
|
|
2381
|
+
};
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
|
|
2385
|
+
declare module '@tiptap/core' {
|
|
2386
|
+
interface Commands<ReturnType> {
|
|
2387
|
+
lift: {
|
|
2388
|
+
/**
|
|
2389
|
+
* Removes an existing wrap if possible lifting the node out of it
|
|
2390
|
+
* @param typeOrName The type or name of the node.
|
|
2391
|
+
* @param attributes The attributes of the node.
|
|
2392
|
+
* @example editor.commands.lift('paragraph')
|
|
2393
|
+
* @example editor.commands.lift('heading', { level: 1 })
|
|
2394
|
+
*/
|
|
2395
|
+
lift: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
|
|
2396
|
+
};
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
declare module '@tiptap/core' {
|
|
2401
|
+
interface Commands<ReturnType> {
|
|
2402
|
+
liftEmptyBlock: {
|
|
2403
|
+
/**
|
|
2404
|
+
* If the cursor is in an empty textblock that can be lifted, lift the block.
|
|
2405
|
+
* @example editor.commands.liftEmptyBlock()
|
|
2406
|
+
*/
|
|
2407
|
+
liftEmptyBlock: () => ReturnType;
|
|
2408
|
+
};
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
declare module '@tiptap/core' {
|
|
2413
|
+
interface Commands<ReturnType> {
|
|
2414
|
+
liftListItem: {
|
|
2415
|
+
/**
|
|
2416
|
+
* Create a command to lift the list item around the selection up into a wrapping list.
|
|
2417
|
+
* @param typeOrName The type or name of the node.
|
|
2418
|
+
* @example editor.commands.liftListItem('listItem')
|
|
2419
|
+
*/
|
|
2420
|
+
liftListItem: (typeOrName: string | NodeType$1) => ReturnType;
|
|
2421
|
+
};
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
declare module '@tiptap/core' {
|
|
2426
|
+
interface Commands<ReturnType> {
|
|
2427
|
+
newlineInCode: {
|
|
2428
|
+
/**
|
|
2429
|
+
* Add a newline character in code.
|
|
2430
|
+
* @example editor.commands.newlineInCode()
|
|
2431
|
+
*/
|
|
2432
|
+
newlineInCode: () => ReturnType;
|
|
2433
|
+
};
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2437
|
+
declare module '@tiptap/core' {
|
|
2438
|
+
interface Commands<ReturnType> {
|
|
2439
|
+
resetAttributes: {
|
|
2440
|
+
/**
|
|
2441
|
+
* Resets some node attributes to the default value.
|
|
2442
|
+
* @param typeOrName The type or name of the node.
|
|
2443
|
+
* @param attributes The attributes of the node to reset.
|
|
2444
|
+
* @example editor.commands.resetAttributes('heading', 'level')
|
|
2445
|
+
*/
|
|
2446
|
+
resetAttributes: (typeOrName: string | NodeType$1 | MarkType$1, attributes: string | string[]) => ReturnType;
|
|
2447
|
+
};
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
declare module '@tiptap/core' {
|
|
2452
|
+
interface Commands<ReturnType> {
|
|
2453
|
+
scrollIntoView: {
|
|
2454
|
+
/**
|
|
2455
|
+
* Scroll the selection into view.
|
|
2456
|
+
* @example editor.commands.scrollIntoView()
|
|
2457
|
+
*/
|
|
2458
|
+
scrollIntoView: () => ReturnType;
|
|
2459
|
+
};
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2463
|
+
declare module '@tiptap/core' {
|
|
2464
|
+
interface Commands<ReturnType> {
|
|
2465
|
+
selectAll: {
|
|
2466
|
+
/**
|
|
2467
|
+
* Select the whole document.
|
|
2468
|
+
* @example editor.commands.selectAll()
|
|
2469
|
+
*/
|
|
2470
|
+
selectAll: () => ReturnType;
|
|
2471
|
+
};
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
declare module '@tiptap/core' {
|
|
2476
|
+
interface Commands<ReturnType> {
|
|
2477
|
+
selectNodeBackward: {
|
|
2478
|
+
/**
|
|
2479
|
+
* Select a node backward.
|
|
2480
|
+
* @example editor.commands.selectNodeBackward()
|
|
2481
|
+
*/
|
|
2482
|
+
selectNodeBackward: () => ReturnType;
|
|
2483
|
+
};
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
|
|
2487
|
+
declare module '@tiptap/core' {
|
|
2488
|
+
interface Commands<ReturnType> {
|
|
2489
|
+
selectNodeForward: {
|
|
2490
|
+
/**
|
|
2491
|
+
* Select a node forward.
|
|
2492
|
+
* @example editor.commands.selectNodeForward()
|
|
2493
|
+
*/
|
|
2494
|
+
selectNodeForward: () => ReturnType;
|
|
2495
|
+
};
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2499
|
+
declare module '@tiptap/core' {
|
|
2500
|
+
interface Commands<ReturnType> {
|
|
2501
|
+
selectParentNode: {
|
|
2502
|
+
/**
|
|
2503
|
+
* Select the parent node.
|
|
2504
|
+
* @example editor.commands.selectParentNode()
|
|
2505
|
+
*/
|
|
2506
|
+
selectParentNode: () => ReturnType;
|
|
2507
|
+
};
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
|
|
2511
|
+
declare module '@tiptap/core' {
|
|
2512
|
+
interface Commands<ReturnType> {
|
|
2513
|
+
selectTextblockEnd: {
|
|
2514
|
+
/**
|
|
2515
|
+
* Moves the cursor to the end of current text block.
|
|
2516
|
+
* @example editor.commands.selectTextblockEnd()
|
|
2517
|
+
*/
|
|
2518
|
+
selectTextblockEnd: () => ReturnType;
|
|
2519
|
+
};
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2523
|
+
declare module '@tiptap/core' {
|
|
2524
|
+
interface Commands<ReturnType> {
|
|
2525
|
+
selectTextblockStart: {
|
|
2526
|
+
/**
|
|
2527
|
+
* Moves the cursor to the start of current text block.
|
|
2528
|
+
* @example editor.commands.selectTextblockStart()
|
|
2529
|
+
*/
|
|
2530
|
+
selectTextblockStart: () => ReturnType;
|
|
2531
|
+
};
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
|
|
2535
|
+
declare module '@tiptap/core' {
|
|
2536
|
+
interface Commands<ReturnType> {
|
|
2537
|
+
setContent: {
|
|
2538
|
+
/**
|
|
2539
|
+
* Replace the whole document with new content.
|
|
2540
|
+
* @param content The new content.
|
|
2541
|
+
* @param emitUpdate Whether to emit an update event.
|
|
2542
|
+
* @param parseOptions Options for parsing the content.
|
|
2543
|
+
* @example editor.commands.setContent('<p>Example text</p>')
|
|
2544
|
+
*/
|
|
2545
|
+
setContent: (
|
|
2546
|
+
/**
|
|
2547
|
+
* The new content.
|
|
2548
|
+
*/
|
|
2549
|
+
content: Content | Fragment$1 | Node$1,
|
|
2550
|
+
/**
|
|
2551
|
+
* Options for `setContent`.
|
|
2552
|
+
*/
|
|
2553
|
+
options?: {
|
|
2554
|
+
/**
|
|
2555
|
+
* Options for parsing the content.
|
|
2556
|
+
* @default {}
|
|
2557
|
+
*/
|
|
2558
|
+
parseOptions?: ParseOptions;
|
|
2559
|
+
/**
|
|
2560
|
+
* Whether to throw an error if the content is invalid.
|
|
2561
|
+
*/
|
|
2562
|
+
errorOnInvalidContent?: boolean;
|
|
2563
|
+
/**
|
|
2564
|
+
* Whether to emit an update event.
|
|
2565
|
+
* @default true
|
|
2566
|
+
*/
|
|
2567
|
+
emitUpdate?: boolean;
|
|
2568
|
+
}) => ReturnType;
|
|
2569
|
+
};
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
declare module '@tiptap/core' {
|
|
2574
|
+
interface Commands<ReturnType> {
|
|
2575
|
+
setMark: {
|
|
2576
|
+
/**
|
|
2577
|
+
* Add a mark with new attributes.
|
|
2578
|
+
* @param typeOrName The mark type or name.
|
|
2579
|
+
* @example editor.commands.setMark('bold', { level: 1 })
|
|
2580
|
+
*/
|
|
2581
|
+
setMark: (typeOrName: string | MarkType$1, attributes?: Record<string, any>) => ReturnType;
|
|
2582
|
+
};
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
declare module '@tiptap/core' {
|
|
2587
|
+
interface Commands<ReturnType> {
|
|
2588
|
+
setMeta: {
|
|
2589
|
+
/**
|
|
2590
|
+
* Store a metadata property in the current transaction.
|
|
2591
|
+
* @param key The key of the metadata property.
|
|
2592
|
+
* @param value The value to store.
|
|
2593
|
+
* @example editor.commands.setMeta('foo', 'bar')
|
|
2594
|
+
*/
|
|
2595
|
+
setMeta: (key: string | Plugin | PluginKey, value: any) => ReturnType;
|
|
2596
|
+
};
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2600
|
+
declare module '@tiptap/core' {
|
|
2601
|
+
interface Commands<ReturnType> {
|
|
2602
|
+
setNode: {
|
|
2603
|
+
/**
|
|
2604
|
+
* Replace a given range with a node.
|
|
2605
|
+
* @param typeOrName The type or name of the node
|
|
2606
|
+
* @param attributes The attributes of the node
|
|
2607
|
+
* @example editor.commands.setNode('paragraph')
|
|
2608
|
+
*/
|
|
2609
|
+
setNode: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
|
|
2610
|
+
};
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
declare module '@tiptap/core' {
|
|
2615
|
+
interface Commands<ReturnType> {
|
|
2616
|
+
setNodeSelection: {
|
|
2617
|
+
/**
|
|
2618
|
+
* Creates a NodeSelection.
|
|
2619
|
+
* @param position - Position of the node.
|
|
2620
|
+
* @example editor.commands.setNodeSelection(10)
|
|
2621
|
+
*/
|
|
2622
|
+
setNodeSelection: (position: number) => ReturnType;
|
|
2623
|
+
};
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
declare module '@tiptap/core' {
|
|
2628
|
+
interface Commands<ReturnType> {
|
|
2629
|
+
setTextSelection: {
|
|
2630
|
+
/**
|
|
2631
|
+
* Creates a TextSelection.
|
|
2632
|
+
* @param position The position of the selection.
|
|
2633
|
+
* @example editor.commands.setTextSelection(10)
|
|
2634
|
+
*/
|
|
2635
|
+
setTextSelection: (position: number | Range) => ReturnType;
|
|
2636
|
+
};
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2640
|
+
declare module '@tiptap/core' {
|
|
2641
|
+
interface Commands<ReturnType> {
|
|
2642
|
+
sinkListItem: {
|
|
2643
|
+
/**
|
|
2644
|
+
* Sink the list item down into an inner list.
|
|
2645
|
+
* @param typeOrName The type or name of the node.
|
|
2646
|
+
* @example editor.commands.sinkListItem('listItem')
|
|
2647
|
+
*/
|
|
2648
|
+
sinkListItem: (typeOrName: string | NodeType$1) => ReturnType;
|
|
2649
|
+
};
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
declare module '@tiptap/core' {
|
|
2654
|
+
interface Commands<ReturnType> {
|
|
2655
|
+
splitBlock: {
|
|
2656
|
+
/**
|
|
2657
|
+
* Forks a new node from an existing node.
|
|
2658
|
+
* @param options.keepMarks Keep marks from the previous node.
|
|
2659
|
+
* @example editor.commands.splitBlock()
|
|
2660
|
+
* @example editor.commands.splitBlock({ keepMarks: true })
|
|
2661
|
+
*/
|
|
2662
|
+
splitBlock: (options?: {
|
|
2663
|
+
keepMarks?: boolean;
|
|
2664
|
+
}) => ReturnType;
|
|
2665
|
+
};
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2669
|
+
declare module '@tiptap/core' {
|
|
2670
|
+
interface Commands<ReturnType> {
|
|
2671
|
+
splitListItem: {
|
|
2672
|
+
/**
|
|
2673
|
+
* Splits one list item into two list items.
|
|
2674
|
+
* @param typeOrName The type or name of the node.
|
|
2675
|
+
* @param overrideAttrs The attributes to ensure on the new node.
|
|
2676
|
+
* @example editor.commands.splitListItem('listItem')
|
|
2677
|
+
*/
|
|
2678
|
+
splitListItem: (typeOrName: string | NodeType$1, overrideAttrs?: Record<string, any>) => ReturnType;
|
|
2679
|
+
};
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
|
|
2683
|
+
declare module '@tiptap/core' {
|
|
2684
|
+
interface Commands<ReturnType> {
|
|
2685
|
+
toggleList: {
|
|
2686
|
+
/**
|
|
2687
|
+
* Toggle between different list types.
|
|
2688
|
+
* @param listTypeOrName The type or name of the list.
|
|
2689
|
+
* @param itemTypeOrName The type or name of the list item.
|
|
2690
|
+
* @param keepMarks Keep marks when toggling.
|
|
2691
|
+
* @param attributes Attributes for the new list.
|
|
2692
|
+
* @example editor.commands.toggleList('bulletList', 'listItem')
|
|
2693
|
+
*/
|
|
2694
|
+
toggleList: (listTypeOrName: string | NodeType$1, itemTypeOrName: string | NodeType$1, keepMarks?: boolean, attributes?: Record<string, any>) => ReturnType;
|
|
2695
|
+
};
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
declare module '@tiptap/core' {
|
|
2700
|
+
interface Commands<ReturnType> {
|
|
2701
|
+
toggleMark: {
|
|
2702
|
+
/**
|
|
2703
|
+
* Toggle a mark on and off.
|
|
2704
|
+
* @param typeOrName The mark type or name.
|
|
2705
|
+
* @param attributes The attributes of the mark.
|
|
2706
|
+
* @param options.extendEmptyMarkRange Removes the mark even across the current selection. Defaults to `false`.
|
|
2707
|
+
* @example editor.commands.toggleMark('bold')
|
|
2708
|
+
*/
|
|
2709
|
+
toggleMark: (
|
|
2710
|
+
/**
|
|
2711
|
+
* The mark type or name.
|
|
2712
|
+
*/
|
|
2713
|
+
typeOrName: string | MarkType$1,
|
|
2714
|
+
/**
|
|
2715
|
+
* The attributes of the mark.
|
|
2716
|
+
*/
|
|
2717
|
+
attributes?: Record<string, any>, options?: {
|
|
2718
|
+
/**
|
|
2719
|
+
* Removes the mark even across the current selection. Defaults to `false`.
|
|
2720
|
+
*/
|
|
2721
|
+
extendEmptyMarkRange?: boolean;
|
|
2722
|
+
}) => ReturnType;
|
|
2723
|
+
};
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2727
|
+
declare module '@tiptap/core' {
|
|
2728
|
+
interface Commands<ReturnType> {
|
|
2729
|
+
toggleNode: {
|
|
2730
|
+
/**
|
|
2731
|
+
* Toggle a node with another node.
|
|
2732
|
+
* @param typeOrName The type or name of the node.
|
|
2733
|
+
* @param toggleTypeOrName The type or name of the node to toggle.
|
|
2734
|
+
* @param attributes The attributes of the node.
|
|
2735
|
+
* @example editor.commands.toggleNode('heading', 'paragraph')
|
|
2736
|
+
*/
|
|
2737
|
+
toggleNode: (typeOrName: string | NodeType$1, toggleTypeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
|
|
2738
|
+
};
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
|
|
2742
|
+
declare module '@tiptap/core' {
|
|
2743
|
+
interface Commands<ReturnType> {
|
|
2744
|
+
toggleWrap: {
|
|
2745
|
+
/**
|
|
2746
|
+
* Wraps nodes in another node, or removes an existing wrap.
|
|
2747
|
+
* @param typeOrName The type or name of the node.
|
|
2748
|
+
* @param attributes The attributes of the node.
|
|
2749
|
+
* @example editor.commands.toggleWrap('blockquote')
|
|
2750
|
+
*/
|
|
2751
|
+
toggleWrap: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
|
|
2752
|
+
};
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
declare module '@tiptap/core' {
|
|
2757
|
+
interface Commands<ReturnType> {
|
|
2758
|
+
undoInputRule: {
|
|
2759
|
+
/**
|
|
2760
|
+
* Undo an input rule.
|
|
2761
|
+
* @example editor.commands.undoInputRule()
|
|
2762
|
+
*/
|
|
2763
|
+
undoInputRule: () => ReturnType;
|
|
2764
|
+
};
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
|
|
2768
|
+
declare module '@tiptap/core' {
|
|
2769
|
+
interface Commands<ReturnType> {
|
|
2770
|
+
unsetAllMarks: {
|
|
2771
|
+
/**
|
|
2772
|
+
* Remove all marks in the current selection.
|
|
2773
|
+
* @example editor.commands.unsetAllMarks()
|
|
2774
|
+
*/
|
|
2775
|
+
unsetAllMarks: () => ReturnType;
|
|
2776
|
+
};
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
|
|
2780
|
+
declare module '@tiptap/core' {
|
|
2781
|
+
interface Commands<ReturnType> {
|
|
2782
|
+
unsetMark: {
|
|
2783
|
+
/**
|
|
2784
|
+
* Remove all marks in the current selection.
|
|
2785
|
+
* @param typeOrName The mark type or name.
|
|
2786
|
+
* @param options.extendEmptyMarkRange Removes the mark even across the current selection. Defaults to `false`.
|
|
2787
|
+
* @example editor.commands.unsetMark('bold')
|
|
2788
|
+
*/
|
|
2789
|
+
unsetMark: (
|
|
2790
|
+
/**
|
|
2791
|
+
* The mark type or name.
|
|
2792
|
+
*/
|
|
2793
|
+
typeOrName: string | MarkType$1, options?: {
|
|
2794
|
+
/**
|
|
2795
|
+
* Removes the mark even across the current selection. Defaults to `false`.
|
|
2796
|
+
*/
|
|
2797
|
+
extendEmptyMarkRange?: boolean;
|
|
2798
|
+
}) => ReturnType;
|
|
2799
|
+
};
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
declare module '@tiptap/core' {
|
|
2804
|
+
interface Commands<ReturnType> {
|
|
2805
|
+
updateAttributes: {
|
|
2806
|
+
/**
|
|
2807
|
+
* Update attributes of a node or mark.
|
|
2808
|
+
* @param typeOrName The type or name of the node or mark.
|
|
2809
|
+
* @param attributes The attributes of the node or mark.
|
|
2810
|
+
* @example editor.commands.updateAttributes('mention', { userId: "2" })
|
|
2811
|
+
*/
|
|
2812
|
+
updateAttributes: (
|
|
2813
|
+
/**
|
|
2814
|
+
* The type or name of the node or mark.
|
|
2815
|
+
*/
|
|
2816
|
+
typeOrName: string | NodeType$1 | MarkType$1,
|
|
2817
|
+
/**
|
|
2818
|
+
* The attributes of the node or mark.
|
|
2819
|
+
*/
|
|
2820
|
+
attributes: Record<string, any>) => ReturnType;
|
|
2821
|
+
};
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
|
|
2825
|
+
declare module '@tiptap/core' {
|
|
2826
|
+
interface Commands<ReturnType> {
|
|
2827
|
+
wrapIn: {
|
|
2828
|
+
/**
|
|
2829
|
+
* Wraps nodes in another node.
|
|
2830
|
+
* @param typeOrName The type or name of the node.
|
|
2831
|
+
* @param attributes The attributes of the node.
|
|
2832
|
+
* @example editor.commands.wrapIn('blockquote')
|
|
2833
|
+
*/
|
|
2834
|
+
wrapIn: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
|
|
2835
|
+
};
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2839
|
+
declare module '@tiptap/core' {
|
|
2840
|
+
interface Commands<ReturnType> {
|
|
2841
|
+
wrapInList: {
|
|
2842
|
+
/**
|
|
2843
|
+
* Wrap a node in a list.
|
|
2844
|
+
* @param typeOrName The type or name of the node.
|
|
2845
|
+
* @param attributes The attributes of the node.
|
|
2846
|
+
* @example editor.commands.wrapInList('bulletList')
|
|
2847
|
+
*/
|
|
2848
|
+
wrapInList: (typeOrName: string | NodeType$1, attributes?: Record<string, any>) => ReturnType;
|
|
2849
|
+
};
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
declare const Commands$1: Extension<any, any>;
|
|
2854
|
+
|
|
2855
|
+
/**
|
|
2856
|
+
* This extension allows you to be notified when the user deletes content you are interested in.
|
|
2857
|
+
*/
|
|
2858
|
+
declare const Delete: Extension<any, any>;
|
|
2859
|
+
|
|
2860
|
+
declare const Drop: Extension<any, any>;
|
|
2861
|
+
|
|
2862
|
+
declare const Editable: Extension<any, any>;
|
|
2863
|
+
|
|
2864
|
+
declare const focusEventsPluginKey: PluginKey<any>;
|
|
2865
|
+
declare const FocusEvents: Extension<any, any>;
|
|
2866
|
+
|
|
2867
|
+
declare const Keymap: Extension<any, any>;
|
|
2868
|
+
|
|
2869
|
+
declare const Paste: Extension<any, any>;
|
|
2870
|
+
|
|
2871
|
+
declare const Tabindex: Extension<any, any>;
|
|
2872
|
+
|
|
2873
|
+
declare const index_ClipboardTextSerializer: typeof ClipboardTextSerializer;
|
|
2874
|
+
declare const index_Delete: typeof Delete;
|
|
2875
|
+
declare const index_Drop: typeof Drop;
|
|
2876
|
+
declare const index_Editable: typeof Editable;
|
|
2877
|
+
declare const index_FocusEvents: typeof FocusEvents;
|
|
2878
|
+
declare const index_Keymap: typeof Keymap;
|
|
2879
|
+
declare const index_Paste: typeof Paste;
|
|
2880
|
+
declare const index_Tabindex: typeof Tabindex;
|
|
2881
|
+
declare const index_focusEventsPluginKey: typeof focusEventsPluginKey;
|
|
2882
|
+
declare namespace index {
|
|
2883
|
+
export { index_ClipboardTextSerializer as ClipboardTextSerializer, Commands$1 as Commands, index_Delete as Delete, index_Drop as Drop, index_Editable as Editable, index_FocusEvents as FocusEvents, index_Keymap as Keymap, index_Paste as Paste, index_Tabindex as Tabindex, index_focusEventsPluginKey as focusEventsPluginKey };
|
|
2884
|
+
}
|
|
2885
|
+
|
|
2886
|
+
interface TiptapEditorHTMLElement extends HTMLElement {
|
|
2887
|
+
editor?: Editor;
|
|
2888
|
+
}
|
|
2889
|
+
declare class Editor extends EventEmitter<EditorEvents> {
|
|
2890
|
+
private commandManager;
|
|
2891
|
+
extensionManager: ExtensionManager;
|
|
2892
|
+
private css;
|
|
2893
|
+
schema: Schema;
|
|
2894
|
+
private editorView;
|
|
2895
|
+
isFocused: boolean;
|
|
2896
|
+
private editorState;
|
|
2897
|
+
/**
|
|
2898
|
+
* The editor is considered initialized after the `create` event has been emitted.
|
|
2899
|
+
*/
|
|
2900
|
+
isInitialized: boolean;
|
|
2901
|
+
extensionStorage: Storage;
|
|
2902
|
+
/**
|
|
2903
|
+
* A unique ID for this editor instance.
|
|
2904
|
+
*/
|
|
2905
|
+
instanceId: string;
|
|
2906
|
+
options: EditorOptions;
|
|
2907
|
+
constructor(options?: Partial<EditorOptions>);
|
|
2908
|
+
/**
|
|
2909
|
+
* Attach the editor to the DOM, creating a new editor view.
|
|
2910
|
+
*/
|
|
2911
|
+
mount(el: NonNullable<EditorOptions['element']> & {}): void;
|
|
2912
|
+
/**
|
|
2913
|
+
* Remove the editor from the DOM, but still allow remounting at a different point in time
|
|
2914
|
+
*/
|
|
2915
|
+
unmount(): void;
|
|
2916
|
+
/**
|
|
2917
|
+
* Returns the editor storage.
|
|
2918
|
+
*/
|
|
2919
|
+
get storage(): Storage;
|
|
2920
|
+
/**
|
|
2921
|
+
* An object of all registered commands.
|
|
2922
|
+
*/
|
|
2923
|
+
get commands(): SingleCommands;
|
|
2924
|
+
/**
|
|
2925
|
+
* Create a command chain to call multiple commands at once.
|
|
2926
|
+
*/
|
|
2927
|
+
chain(): ChainedCommands;
|
|
2928
|
+
/**
|
|
2929
|
+
* Check if a command or a command chain can be executed. Without executing it.
|
|
2930
|
+
*/
|
|
2931
|
+
can(): CanCommands;
|
|
2932
|
+
/**
|
|
2933
|
+
* Inject CSS styles.
|
|
2934
|
+
*/
|
|
2935
|
+
private injectCSS;
|
|
2936
|
+
/**
|
|
2937
|
+
* Update editor options.
|
|
2938
|
+
*
|
|
2939
|
+
* @param options A list of options
|
|
2940
|
+
*/
|
|
2941
|
+
setOptions(options?: Partial<EditorOptions>): void;
|
|
2942
|
+
/**
|
|
2943
|
+
* Update editable state of the editor.
|
|
2944
|
+
*/
|
|
2945
|
+
setEditable(editable: boolean, emitUpdate?: boolean): void;
|
|
2946
|
+
/**
|
|
2947
|
+
* Returns whether the editor is editable.
|
|
2948
|
+
*/
|
|
2949
|
+
get isEditable(): boolean;
|
|
2950
|
+
/**
|
|
2951
|
+
* Returns the editor state.
|
|
2952
|
+
*/
|
|
2953
|
+
get view(): EditorView;
|
|
2954
|
+
/**
|
|
2955
|
+
* Returns the editor state.
|
|
2956
|
+
*/
|
|
2957
|
+
get state(): EditorState;
|
|
2958
|
+
/**
|
|
2959
|
+
* Register a ProseMirror plugin.
|
|
2960
|
+
*
|
|
2961
|
+
* @param plugin A ProseMirror plugin
|
|
2962
|
+
* @param handlePlugins Control how to merge the plugin into the existing plugins.
|
|
2963
|
+
* @returns The new editor state
|
|
2964
|
+
*/
|
|
2965
|
+
registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): EditorState;
|
|
2966
|
+
/**
|
|
2967
|
+
* Unregister a ProseMirror plugin.
|
|
2968
|
+
*
|
|
2969
|
+
* @param nameOrPluginKeyToRemove The plugins name
|
|
2970
|
+
* @returns The new editor state or undefined if the editor is destroyed
|
|
2971
|
+
*/
|
|
2972
|
+
unregisterPlugin(nameOrPluginKeyToRemove: string | PluginKey | (string | PluginKey)[]): EditorState | undefined;
|
|
2973
|
+
/**
|
|
2974
|
+
* Creates an extension manager.
|
|
2975
|
+
*/
|
|
2976
|
+
private createExtensionManager;
|
|
2977
|
+
/**
|
|
2978
|
+
* Creates an command manager.
|
|
2979
|
+
*/
|
|
2980
|
+
private createCommandManager;
|
|
2981
|
+
/**
|
|
2982
|
+
* Creates a ProseMirror schema.
|
|
2983
|
+
*/
|
|
2984
|
+
private createSchema;
|
|
2985
|
+
/**
|
|
2986
|
+
* Creates the initial document.
|
|
2987
|
+
*/
|
|
2988
|
+
private createDoc;
|
|
2989
|
+
/**
|
|
2990
|
+
* Creates a ProseMirror view.
|
|
2991
|
+
*/
|
|
2992
|
+
private createView;
|
|
2993
|
+
/**
|
|
2994
|
+
* Creates all node and mark views.
|
|
2995
|
+
*/
|
|
2996
|
+
createNodeViews(): void;
|
|
2997
|
+
/**
|
|
2998
|
+
* Prepend class name to element.
|
|
2999
|
+
*/
|
|
3000
|
+
prependClass(): void;
|
|
3001
|
+
isCapturingTransaction: boolean;
|
|
3002
|
+
private capturedTransaction;
|
|
3003
|
+
captureTransaction(fn: () => void): Transaction | null;
|
|
3004
|
+
/**
|
|
3005
|
+
* The callback over which to send transactions (state updates) produced by the view.
|
|
3006
|
+
*
|
|
3007
|
+
* @param transaction An editor state transaction
|
|
3008
|
+
*/
|
|
3009
|
+
private dispatchTransaction;
|
|
3010
|
+
/**
|
|
3011
|
+
* Get attributes of the currently selected node or mark.
|
|
3012
|
+
*/
|
|
3013
|
+
getAttributes(nameOrType: string | NodeType$1 | MarkType$1): Record<string, any>;
|
|
3014
|
+
/**
|
|
3015
|
+
* Returns if the currently selected node or mark is active.
|
|
3016
|
+
*
|
|
3017
|
+
* @param name Name of the node or mark
|
|
3018
|
+
* @param attributes Attributes of the node or mark
|
|
3019
|
+
*/
|
|
3020
|
+
isActive(name: string, attributes?: {}): boolean;
|
|
3021
|
+
isActive(attributes: {}): boolean;
|
|
3022
|
+
/**
|
|
3023
|
+
* Get the document as JSON.
|
|
3024
|
+
*/
|
|
3025
|
+
getJSON(): DocumentType<Record<string, any> | undefined, NodeType<string, undefined | Record<string, any>, any, (NodeType | TextType)[]>[]>;
|
|
3026
|
+
/**
|
|
3027
|
+
* Get the document as HTML.
|
|
3028
|
+
*/
|
|
3029
|
+
getHTML(): string;
|
|
3030
|
+
/**
|
|
3031
|
+
* Get the document as text.
|
|
3032
|
+
*/
|
|
3033
|
+
getText(options?: {
|
|
3034
|
+
blockSeparator?: string;
|
|
3035
|
+
textSerializers?: Record<string, TextSerializer>;
|
|
3036
|
+
}): string;
|
|
3037
|
+
/**
|
|
3038
|
+
* Check if there is no content.
|
|
3039
|
+
*/
|
|
3040
|
+
get isEmpty(): boolean;
|
|
3041
|
+
/**
|
|
3042
|
+
* Destroy the editor.
|
|
3043
|
+
*/
|
|
3044
|
+
destroy(): void;
|
|
3045
|
+
/**
|
|
3046
|
+
* Check if the editor is already destroyed.
|
|
3047
|
+
*/
|
|
3048
|
+
get isDestroyed(): boolean;
|
|
3049
|
+
$node(selector: string, attributes?: {
|
|
3050
|
+
[key: string]: any;
|
|
3051
|
+
}): NodePos | null;
|
|
3052
|
+
$nodes(selector: string, attributes?: {
|
|
3053
|
+
[key: string]: any;
|
|
3054
|
+
}): NodePos[] | null;
|
|
3055
|
+
$pos(pos: number): NodePos;
|
|
3056
|
+
get $doc(): NodePos;
|
|
3057
|
+
}
|
|
3058
|
+
|
|
3059
|
+
declare class CommandManager {
|
|
3060
|
+
editor: Editor;
|
|
3061
|
+
rawCommands: AnyCommands;
|
|
3062
|
+
customState?: EditorState;
|
|
3063
|
+
constructor(props: {
|
|
3064
|
+
editor: Editor;
|
|
3065
|
+
state?: EditorState;
|
|
3066
|
+
});
|
|
3067
|
+
get hasCustomState(): boolean;
|
|
3068
|
+
get state(): EditorState;
|
|
3069
|
+
get commands(): SingleCommands;
|
|
3070
|
+
get chain(): () => ChainedCommands;
|
|
3071
|
+
get can(): () => CanCommands;
|
|
3072
|
+
createChain(startTr?: Transaction, shouldDispatch?: boolean): ChainedCommands;
|
|
3073
|
+
createCan(startTr?: Transaction): CanCommands;
|
|
3074
|
+
buildProps(tr: Transaction, shouldDispatch?: boolean): CommandProps;
|
|
3075
|
+
}
|
|
3076
|
+
|
|
3077
|
+
/**
|
|
3078
|
+
* Build an input rule that adds a mark when the
|
|
3079
|
+
* matched text is typed into it.
|
|
3080
|
+
* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules
|
|
3081
|
+
*/
|
|
3082
|
+
declare function markInputRule(config: {
|
|
3083
|
+
find: InputRuleFinder;
|
|
3084
|
+
type: MarkType$1;
|
|
3085
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
|
|
3086
|
+
}): InputRule;
|
|
3087
|
+
|
|
3088
|
+
/**
|
|
3089
|
+
* Build an input rule that adds a node when the
|
|
3090
|
+
* matched text is typed into it.
|
|
3091
|
+
* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules
|
|
3092
|
+
*/
|
|
3093
|
+
declare function nodeInputRule(config: {
|
|
3094
|
+
/**
|
|
3095
|
+
* The regex to match.
|
|
3096
|
+
*/
|
|
3097
|
+
find: InputRuleFinder;
|
|
3098
|
+
/**
|
|
3099
|
+
* The node type to add.
|
|
3100
|
+
*/
|
|
3101
|
+
type: NodeType$1;
|
|
3102
|
+
/**
|
|
3103
|
+
* A function that returns the attributes for the node
|
|
3104
|
+
* can also be an object of attributes
|
|
3105
|
+
*/
|
|
3106
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
|
|
3107
|
+
}): InputRule;
|
|
3108
|
+
|
|
3109
|
+
/**
|
|
3110
|
+
* Build an input rule that changes the type of a textblock when the
|
|
3111
|
+
* matched text is typed into it. When using a regular expresion you’ll
|
|
3112
|
+
* probably want the regexp to start with `^`, so that the pattern can
|
|
3113
|
+
* only occur at the start of a textblock.
|
|
3114
|
+
* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules
|
|
3115
|
+
*/
|
|
3116
|
+
declare function textblockTypeInputRule(config: {
|
|
3117
|
+
find: InputRuleFinder;
|
|
3118
|
+
type: NodeType$1;
|
|
3119
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
|
|
3120
|
+
}): InputRule;
|
|
3121
|
+
|
|
3122
|
+
/**
|
|
3123
|
+
* Build an input rule that replaces text when the
|
|
3124
|
+
* matched text is typed into it.
|
|
3125
|
+
* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules
|
|
3126
|
+
*/
|
|
3127
|
+
declare function textInputRule(config: {
|
|
3128
|
+
find: InputRuleFinder;
|
|
3129
|
+
replace: string;
|
|
3130
|
+
}): InputRule;
|
|
3131
|
+
|
|
3132
|
+
/**
|
|
3133
|
+
* Build an input rule for automatically wrapping a textblock when a
|
|
3134
|
+
* given string is typed. When using a regular expresion you’ll
|
|
3135
|
+
* probably want the regexp to start with `^`, so that the pattern can
|
|
3136
|
+
* only occur at the start of a textblock.
|
|
3137
|
+
*
|
|
3138
|
+
* `type` is the type of node to wrap in.
|
|
3139
|
+
*
|
|
3140
|
+
* By default, if there’s a node with the same type above the newly
|
|
3141
|
+
* wrapped node, the rule will try to join those
|
|
3142
|
+
* two nodes. You can pass a join predicate, which takes a regular
|
|
3143
|
+
* expression match and the node before the wrapped node, and can
|
|
3144
|
+
* return a boolean to indicate whether a join should happen.
|
|
3145
|
+
* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules
|
|
3146
|
+
*/
|
|
3147
|
+
declare function wrappingInputRule(config: {
|
|
3148
|
+
find: InputRuleFinder;
|
|
3149
|
+
type: NodeType$1;
|
|
3150
|
+
keepMarks?: boolean;
|
|
3151
|
+
keepAttributes?: boolean;
|
|
3152
|
+
editor?: Editor;
|
|
3153
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
|
|
3154
|
+
joinPredicate?: (match: ExtendedRegExpMatchArray, node: Node$1) => boolean;
|
|
3155
|
+
}): InputRule;
|
|
3156
|
+
|
|
3157
|
+
type Attributes = Record<string, any>;
|
|
3158
|
+
type DOMOutputSpecElement = 0 | Attributes | DOMOutputSpecArray;
|
|
3159
|
+
/**
|
|
3160
|
+
* Better describes the output of a `renderHTML` function in prosemirror
|
|
3161
|
+
* @see https://prosemirror.net/docs/ref/#model.DOMOutputSpec
|
|
3162
|
+
*/
|
|
3163
|
+
type DOMOutputSpecArray = [string] | [string, Attributes] | [string, 0] | [string, Attributes, 0] | [string, Attributes, DOMOutputSpecArray | 0] | [string, DOMOutputSpecArray];
|
|
3164
|
+
declare global {
|
|
3165
|
+
namespace JSX {
|
|
3166
|
+
type Element = [string, ...any[]];
|
|
3167
|
+
interface IntrinsicElements {
|
|
3168
|
+
[key: string]: any;
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
}
|
|
3172
|
+
type JSXRenderer = (tag: 'slot' | string | ((props?: Attributes) => DOMOutputSpecArray | DOMOutputSpecElement), props?: Attributes, ...children: JSXRenderer[]) => DOMOutputSpecArray | DOMOutputSpecElement;
|
|
3173
|
+
declare function Fragment(props: {
|
|
3174
|
+
children: JSXRenderer[];
|
|
3175
|
+
}): JSXRenderer[];
|
|
3176
|
+
declare const h: JSXRenderer;
|
|
3177
|
+
|
|
3178
|
+
declare function updateMarkViewAttributes(checkMark: Mark$1, editor: Editor, attrs?: Record<string, any>): void;
|
|
3179
|
+
declare class MarkView<Component, Options extends MarkViewRendererOptions = MarkViewRendererOptions> {
|
|
3180
|
+
component: Component;
|
|
3181
|
+
editor: Editor;
|
|
3182
|
+
options: Options;
|
|
3183
|
+
mark: MarkViewProps['mark'];
|
|
3184
|
+
HTMLAttributes: MarkViewProps['HTMLAttributes'];
|
|
3185
|
+
constructor(component: Component, props: MarkViewProps, options?: Partial<Options>);
|
|
3186
|
+
get dom(): HTMLElement;
|
|
3187
|
+
get contentDOM(): HTMLElement | null;
|
|
3188
|
+
/**
|
|
3189
|
+
* Update the attributes of the mark in the document.
|
|
3190
|
+
* @param attrs The attributes to update.
|
|
3191
|
+
*/
|
|
3192
|
+
updateAttributes(attrs: Record<string, any>, checkMark?: Mark$1): void;
|
|
3193
|
+
ignoreMutation(mutation: ViewMutationRecord): boolean;
|
|
3194
|
+
}
|
|
3195
|
+
|
|
3196
|
+
/**
|
|
3197
|
+
* Node views are used to customize the rendered DOM structure of a node.
|
|
3198
|
+
* @see https://tiptap.dev/guide/node-views
|
|
3199
|
+
*/
|
|
3200
|
+
declare class NodeView<Component, NodeEditor extends Editor = Editor, Options extends NodeViewRendererOptions = NodeViewRendererOptions> implements NodeView$1 {
|
|
3201
|
+
component: Component;
|
|
3202
|
+
editor: NodeEditor;
|
|
3203
|
+
options: Options;
|
|
3204
|
+
extension: NodeViewRendererProps['extension'];
|
|
3205
|
+
node: NodeViewRendererProps['node'];
|
|
3206
|
+
decorations: NodeViewRendererProps['decorations'];
|
|
3207
|
+
innerDecorations: NodeViewRendererProps['innerDecorations'];
|
|
3208
|
+
view: NodeViewRendererProps['view'];
|
|
3209
|
+
getPos: NodeViewRendererProps['getPos'];
|
|
3210
|
+
HTMLAttributes: NodeViewRendererProps['HTMLAttributes'];
|
|
3211
|
+
isDragging: boolean;
|
|
3212
|
+
constructor(component: Component, props: NodeViewRendererProps, options?: Partial<Options>);
|
|
3213
|
+
mount(): void;
|
|
3214
|
+
get dom(): HTMLElement;
|
|
3215
|
+
get contentDOM(): HTMLElement | null;
|
|
3216
|
+
onDragStart(event: DragEvent): void;
|
|
3217
|
+
stopEvent(event: Event): boolean;
|
|
3218
|
+
/**
|
|
3219
|
+
* Called when a DOM [mutation](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) or a selection change happens within the view.
|
|
3220
|
+
* @return `false` if the editor should re-read the selection or re-parse the range around the mutation
|
|
3221
|
+
* @return `true` if it can safely be ignored.
|
|
3222
|
+
*/
|
|
3223
|
+
ignoreMutation(mutation: ViewMutationRecord): boolean;
|
|
3224
|
+
/**
|
|
3225
|
+
* Update the attributes of the prosemirror node.
|
|
3226
|
+
*/
|
|
3227
|
+
updateAttributes(attributes: Record<string, any>): void;
|
|
3228
|
+
/**
|
|
3229
|
+
* Delete the node.
|
|
3230
|
+
*/
|
|
3231
|
+
deleteNode(): void;
|
|
3232
|
+
}
|
|
3233
|
+
|
|
3234
|
+
/**
|
|
3235
|
+
* Build an paste rule that adds a mark when the
|
|
3236
|
+
* matched text is pasted into it.
|
|
3237
|
+
* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#paste-rules
|
|
3238
|
+
*/
|
|
3239
|
+
declare function markPasteRule(config: {
|
|
3240
|
+
find: PasteRuleFinder;
|
|
3241
|
+
type: MarkType$1;
|
|
3242
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray, event: ClipboardEvent) => Record<string, any>) | false | null;
|
|
3243
|
+
}): PasteRule;
|
|
3244
|
+
|
|
3245
|
+
/**
|
|
3246
|
+
* Build an paste rule that adds a node when the
|
|
3247
|
+
* matched text is pasted into it.
|
|
3248
|
+
* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#paste-rules
|
|
3249
|
+
*/
|
|
3250
|
+
declare function nodePasteRule(config: {
|
|
3251
|
+
find: PasteRuleFinder;
|
|
3252
|
+
type: NodeType$1;
|
|
3253
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray, event: ClipboardEvent) => Record<string, any>) | false | null;
|
|
3254
|
+
getContent?: JSONContent[] | ((attrs: Record<string, any>) => JSONContent[]) | false | null;
|
|
3255
|
+
}): PasteRule;
|
|
3256
|
+
|
|
3257
|
+
/**
|
|
3258
|
+
* Build an paste rule that replaces text when the
|
|
3259
|
+
* matched text is pasted into it.
|
|
3260
|
+
* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#paste-rules
|
|
3261
|
+
*/
|
|
3262
|
+
declare function textPasteRule(config: {
|
|
3263
|
+
find: PasteRuleFinder;
|
|
3264
|
+
replace: string;
|
|
3265
|
+
}): PasteRule;
|
|
3266
|
+
|
|
3267
|
+
interface TrackerResult {
|
|
3268
|
+
position: number;
|
|
3269
|
+
deleted: boolean;
|
|
3270
|
+
}
|
|
3271
|
+
declare class Tracker {
|
|
3272
|
+
transaction: Transaction;
|
|
3273
|
+
currentStep: number;
|
|
3274
|
+
constructor(transaction: Transaction);
|
|
3275
|
+
map(position: number): TrackerResult;
|
|
3276
|
+
}
|
|
3277
|
+
|
|
3278
|
+
/**
|
|
3279
|
+
* Optionally calls `value` as a function.
|
|
3280
|
+
* Otherwise it is returned directly.
|
|
3281
|
+
* @param value Function or any value.
|
|
3282
|
+
* @param context Optional context to bind to function.
|
|
3283
|
+
* @param props Optional props to pass to function.
|
|
3284
|
+
*/
|
|
3285
|
+
declare function callOrReturn<T>(value: T, context?: any, ...props: any[]): MaybeReturnType<T>;
|
|
3286
|
+
|
|
3287
|
+
declare function canInsertNode(state: EditorState, nodeType: NodeType$1): boolean;
|
|
3288
|
+
|
|
3289
|
+
declare function createStyleTag(style: string, nonce?: string, suffix?: string): HTMLStyleElement;
|
|
3290
|
+
|
|
3291
|
+
/**
|
|
3292
|
+
* Remove a property or an array of properties from an object
|
|
3293
|
+
* @param obj Object
|
|
3294
|
+
* @param key Key to remove
|
|
3295
|
+
*/
|
|
3296
|
+
declare function deleteProps(obj: Record<string, any>, propOrProps: string | string[]): Record<string, any>;
|
|
3297
|
+
|
|
3298
|
+
declare function elementFromString(value: string): HTMLElement;
|
|
3299
|
+
|
|
3300
|
+
declare function escapeForRegEx(string: string): string;
|
|
3301
|
+
|
|
3302
|
+
/**
|
|
3303
|
+
* Find duplicates in an array.
|
|
3304
|
+
*/
|
|
3305
|
+
declare function findDuplicates<T>(items: T[]): T[];
|
|
3306
|
+
|
|
3307
|
+
declare function fromString(value: any): any;
|
|
3308
|
+
|
|
3309
|
+
declare function isAndroid(): boolean;
|
|
3310
|
+
|
|
3311
|
+
declare function isEmptyObject(value?: {}): boolean;
|
|
3312
|
+
|
|
3313
|
+
declare function isFunction(value: any): value is Function;
|
|
3314
|
+
|
|
3315
|
+
declare function isiOS(): boolean;
|
|
3316
|
+
|
|
3317
|
+
declare function isMacOS(): boolean;
|
|
3318
|
+
|
|
3319
|
+
declare function isNumber(value: any): value is number;
|
|
3320
|
+
|
|
3321
|
+
declare function isPlainObject(value: any): value is Record<string, any>;
|
|
3322
|
+
|
|
3323
|
+
declare function isRegExp(value: any): value is RegExp;
|
|
3324
|
+
|
|
3325
|
+
declare function isString(value: any): value is string;
|
|
3326
|
+
|
|
3327
|
+
declare function mergeAttributes(...objects: Record<string, any>[]): Record<string, any>;
|
|
3328
|
+
|
|
3329
|
+
declare function mergeDeep(target: Record<string, any>, source: Record<string, any>): Record<string, any>;
|
|
3330
|
+
|
|
3331
|
+
declare function minMax(value?: number, min?: number, max?: number): number;
|
|
3332
|
+
|
|
3333
|
+
/**
|
|
3334
|
+
* Check if object1 includes object2
|
|
3335
|
+
* @param object1 Object
|
|
3336
|
+
* @param object2 Object
|
|
3337
|
+
*/
|
|
3338
|
+
declare function objectIncludes(object1: Record<string, any>, object2: Record<string, any>, options?: {
|
|
3339
|
+
strict: boolean;
|
|
3340
|
+
}): boolean;
|
|
3341
|
+
|
|
3342
|
+
/**
|
|
3343
|
+
* Removes duplicated values within an array.
|
|
3344
|
+
* Supports numbers, strings and objects.
|
|
3345
|
+
*/
|
|
3346
|
+
declare function removeDuplicates<T>(array: T[], by?: {
|
|
3347
|
+
(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
|
|
3348
|
+
(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
|
|
3349
|
+
}): T[];
|
|
3350
|
+
|
|
3351
|
+
interface Commands<ReturnType = any> {
|
|
3352
|
+
}
|
|
3353
|
+
interface Storage {
|
|
3354
|
+
}
|
|
3355
|
+
|
|
3356
|
+
export { type AnyCommands, type AnyConfig, type AnyExtension, type Attribute, type Attributes$1 as Attributes, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type GlobalAttributes, type HTMLContent, InputRule, type InputRuleFinder, type InputRuleMatch, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, callOrReturn, canInsertNode, combineTransactionSteps, createChainableState, createDocument, h as createElement, createNodeFromContent, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, index as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, flattenExtensions, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, h, injectExtensionAttributesToParseRule, inputRulesPlugin, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, markInputRule, markPasteRule, mergeAttributes, mergeDeep, minMax, nodeInputRule, nodePasteRule, objectIncludes, pasteRulesPlugin, posToDOMRect, removeDuplicates, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, selectionToInsertionEnd, sortExtensions, splitExtensions, textInputRule, textPasteRule, textblockTypeInputRule, updateMarkViewAttributes, wrappingInputRule };
|