@tiptap/core 2.0.0-beta.21 → 2.0.0-beta.210
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/README.md +2 -2
- package/dist/index.cjs +4311 -0
- package/dist/index.d.ts +2330 -0
- package/dist/index.js +4311 -0
- package/package.json +39 -25
- package/src/CommandManager.ts +76 -86
- package/src/Editor.ts +120 -81
- package/src/EventEmitter.ts +14 -4
- package/src/Extension.ts +280 -108
- package/src/ExtensionManager.ts +254 -108
- package/src/InputRule.ts +260 -0
- package/src/Mark.ts +398 -147
- package/src/Node.ts +437 -171
- package/src/NodeView.ts +132 -63
- package/src/PasteRule.ts +240 -0
- package/src/Tracker.ts +38 -0
- package/src/commands/blur.ts +12 -6
- package/src/commands/clearContent.ts +3 -3
- package/src/commands/clearNodes.ts +31 -19
- package/src/commands/command.ts +2 -2
- package/src/commands/createParagraphNear.ts +5 -4
- package/src/commands/deleteCurrentNode.ts +41 -0
- package/src/commands/deleteNode.ts +37 -0
- package/src/commands/deleteRange.ts +3 -3
- package/src/commands/deleteSelection.ts +5 -4
- package/src/commands/enter.ts +3 -3
- package/src/commands/exitCode.ts +5 -4
- package/src/commands/extendMarkRange.ts +16 -12
- package/src/commands/first.ts +3 -3
- package/src/commands/focus.ts +47 -44
- package/src/commands/forEach.ts +24 -0
- package/src/commands/index.ts +50 -0
- package/src/commands/insertContent.ts +17 -24
- package/src/commands/insertContentAt.ts +94 -0
- package/src/commands/join.ts +53 -0
- package/src/commands/keyboardShortcut.ts +6 -6
- package/src/commands/lift.ts +8 -7
- package/src/commands/liftEmptyBlock.ts +5 -4
- package/src/commands/liftListItem.ts +7 -6
- package/src/commands/newlineInCode.ts +5 -4
- package/src/commands/resetAttributes.ts +18 -12
- package/src/commands/scrollIntoView.ts +3 -3
- package/src/commands/selectAll.ts +8 -6
- package/src/commands/selectNodeBackward.ts +5 -4
- package/src/commands/selectNodeForward.ts +5 -4
- package/src/commands/selectParentNode.ts +5 -4
- package/src/commands/selectTextblockEnd.ts +20 -0
- package/src/commands/selectTextblockStart.ts +20 -0
- package/src/commands/setContent.ts +9 -16
- package/src/commands/setMark.ts +90 -14
- package/src/commands/setMeta.ts +18 -0
- package/src/commands/setNode.ts +32 -8
- package/src/commands/setNodeSelection.ts +27 -0
- package/src/commands/setTextSelection.ts +31 -0
- package/src/commands/sinkListItem.ts +7 -6
- package/src/commands/splitBlock.ts +31 -41
- package/src/commands/splitListItem.ts +46 -29
- package/src/commands/toggleList.ts +88 -20
- package/src/commands/toggleMark.ts +19 -8
- package/src/commands/toggleNode.ts +11 -6
- package/src/commands/toggleWrap.ts +10 -10
- package/src/commands/undoInputRule.ts +34 -5
- package/src/commands/unsetAllMarks.ts +7 -11
- package/src/commands/unsetMark.ts +36 -23
- package/src/commands/updateAttributes.ts +27 -15
- package/src/commands/wrapIn.ts +7 -12
- package/src/commands/wrapInList.ts +7 -6
- package/src/extensions/clipboardTextSerializer.ts +15 -36
- package/src/extensions/commands.ts +3 -147
- package/src/extensions/editable.ts +2 -1
- package/src/extensions/focusEvents.ts +4 -6
- package/src/extensions/index.ts +1 -0
- package/src/extensions/keymap.ts +106 -13
- package/src/extensions/tabindex.ts +18 -0
- package/src/helpers/combineTransactionSteps.ts +21 -0
- package/src/helpers/createChainableState.ts +38 -0
- package/src/helpers/createDocument.ts +5 -6
- package/src/helpers/createNodeFromContent.ts +20 -28
- package/src/helpers/defaultBlockAt.ts +13 -0
- package/src/helpers/findChildren.ts +18 -0
- package/src/helpers/findChildrenInRange.ts +36 -0
- package/src/helpers/findParentNode.ts +4 -3
- package/src/helpers/findParentNodeClosestToPos.ts +13 -7
- package/src/helpers/generateHTML.ts +7 -6
- package/src/helpers/generateJSON.ts +12 -0
- package/src/helpers/generateText.ts +27 -0
- package/src/helpers/getAttributes.ts +26 -0
- package/src/helpers/getAttributesFromExtensions.ts +42 -14
- package/src/helpers/getChangedRanges.ts +83 -0
- package/src/helpers/getDebugJSON.ts +54 -0
- package/src/helpers/getExtensionField.ts +25 -0
- package/src/helpers/getHTMLFromFragment.ts +5 -6
- package/src/helpers/getMarkAttributes.ts +18 -11
- package/src/helpers/getMarkRange.ts +41 -8
- package/src/helpers/getMarkType.ts +8 -2
- package/src/helpers/getMarksBetween.ts +34 -10
- package/src/helpers/getNodeAttributes.ts +14 -13
- package/src/helpers/getNodeType.ts +8 -2
- package/src/helpers/getRenderedAttributes.ts +9 -7
- package/src/helpers/getSchema.ts +7 -133
- package/src/helpers/getSchemaByResolvedExtensions.ts +192 -0
- package/src/helpers/getSchemaTypeByName.ts +3 -11
- package/src/helpers/getSchemaTypeNameByName.ts +2 -2
- package/src/helpers/getSplittedAttributes.ts +4 -4
- package/src/helpers/getText.ts +19 -0
- package/src/helpers/getTextBetween.ts +46 -0
- package/src/helpers/getTextContentFromNodes.ts +26 -0
- package/src/helpers/getTextSerializersFromSchema.ts +11 -0
- package/src/helpers/index.ts +33 -0
- package/src/helpers/injectExtensionAttributesToParseRule.ts +22 -23
- package/src/helpers/isActive.ts +10 -6
- package/src/helpers/isExtensionRulesEnabled.ts +15 -0
- package/src/helpers/isList.ts +14 -7
- package/src/helpers/isMarkActive.ts +49 -27
- package/src/helpers/isNodeActive.ts +29 -39
- package/src/helpers/isNodeEmpty.ts +2 -2
- package/src/helpers/isNodeSelection.ts +3 -4
- package/src/helpers/isTextSelection.ts +3 -4
- package/src/helpers/posToDOMRect.ts +35 -0
- package/src/helpers/resolveFocusPosition.ts +42 -0
- package/src/helpers/selectionToInsertionEnd.ts +3 -3
- package/src/helpers/splitExtensions.ts +3 -3
- package/src/index.ts +15 -24
- package/src/inputRules/index.ts +5 -0
- package/src/inputRules/markInputRule.ts +59 -40
- package/src/inputRules/nodeInputRule.ts +45 -12
- package/src/inputRules/textInputRule.ts +35 -0
- package/src/inputRules/textblockTypeInputRule.ts +37 -0
- package/src/inputRules/wrappingInputRule.ts +59 -0
- package/src/pasteRules/index.ts +3 -0
- package/src/pasteRules/markPasteRule.ts +61 -53
- package/src/pasteRules/nodePasteRule.ts +37 -0
- package/src/pasteRules/textPasteRule.ts +35 -0
- package/src/style.ts +16 -3
- package/src/types.ts +170 -97
- package/src/utilities/callOrReturn.ts +6 -3
- package/src/utilities/createStyleTag.ts +12 -1
- package/src/utilities/deleteProps.ts +2 -4
- package/src/utilities/elementFromString.ts +4 -5
- package/src/utilities/escapeForRegEx.ts +4 -0
- package/src/utilities/findDuplicates.ts +5 -0
- package/src/utilities/fromString.ts +2 -2
- package/src/utilities/index.ts +20 -0
- package/src/utilities/isEmptyObject.ts +2 -2
- package/src/utilities/isFunction.ts +3 -0
- package/src/utilities/isMacOS.ts +5 -0
- package/src/utilities/isNumber.ts +3 -0
- package/src/utilities/isPlainObject.ts +8 -5
- package/src/utilities/isRegExp.ts +3 -0
- package/src/utilities/isString.ts +3 -0
- package/src/utilities/isiOS.ts +12 -0
- package/src/utilities/mergeAttributes.ts +2 -3
- package/src/utilities/mergeDeep.ts +2 -3
- package/src/utilities/minMax.ts +1 -1
- package/src/utilities/objectIncludes.ts +17 -5
- package/src/utilities/removeDuplicates.ts +15 -0
- package/CHANGELOG.md +0 -365
- package/LICENSE.md +0 -21
- package/dist/packages/core/src/CommandManager.d.ts +0 -13
- package/dist/packages/core/src/Editor.d.ts +0 -142
- package/dist/packages/core/src/EventEmitter.d.ts +0 -7
- package/dist/packages/core/src/Extension.d.ts +0 -148
- package/dist/packages/core/src/ExtensionManager.d.ts +0 -24
- package/dist/packages/core/src/Mark.d.ts +0 -211
- package/dist/packages/core/src/Node.d.ts +0 -265
- package/dist/packages/core/src/NodeView.d.ts +0 -31
- package/dist/packages/core/src/commands/blur.d.ts +0 -12
- package/dist/packages/core/src/commands/clearContent.d.ts +0 -12
- package/dist/packages/core/src/commands/clearNodes.d.ts +0 -12
- package/dist/packages/core/src/commands/command.d.ts +0 -12
- package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -12
- package/dist/packages/core/src/commands/deleteRange.d.ts +0 -12
- package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -12
- package/dist/packages/core/src/commands/enter.d.ts +0 -12
- package/dist/packages/core/src/commands/exitCode.d.ts +0 -12
- package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -13
- package/dist/packages/core/src/commands/first.d.ts +0 -12
- package/dist/packages/core/src/commands/focus.d.ts +0 -12
- package/dist/packages/core/src/commands/insertContent.d.ts +0 -12
- package/dist/packages/core/src/commands/insertHTML.d.ts +0 -12
- package/dist/packages/core/src/commands/insertNode.d.ts +0 -13
- package/dist/packages/core/src/commands/insertText.d.ts +0 -12
- package/dist/packages/core/src/commands/joinBackward.d.ts +0 -12
- package/dist/packages/core/src/commands/joinForward.d.ts +0 -12
- package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -12
- package/dist/packages/core/src/commands/lift.d.ts +0 -13
- package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -12
- package/dist/packages/core/src/commands/liftListItem.d.ts +0 -13
- package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -12
- package/dist/packages/core/src/commands/replace.d.ts +0 -13
- package/dist/packages/core/src/commands/replaceRange.d.ts +0 -13
- package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -13
- package/dist/packages/core/src/commands/resetNodeAttributes.d.ts +0 -13
- package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -12
- package/dist/packages/core/src/commands/selectAll.d.ts +0 -12
- package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -12
- package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -12
- package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -12
- package/dist/packages/core/src/commands/setContent.d.ts +0 -12
- package/dist/packages/core/src/commands/setMark.d.ts +0 -13
- package/dist/packages/core/src/commands/setNode.d.ts +0 -13
- package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -13
- package/dist/packages/core/src/commands/splitBlock.d.ts +0 -14
- package/dist/packages/core/src/commands/splitListItem.d.ts +0 -13
- package/dist/packages/core/src/commands/toggleList.d.ts +0 -13
- package/dist/packages/core/src/commands/toggleMark.d.ts +0 -13
- package/dist/packages/core/src/commands/toggleNode.d.ts +0 -13
- package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -13
- package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -12
- package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -12
- package/dist/packages/core/src/commands/unsetMark.d.ts +0 -13
- package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -13
- package/dist/packages/core/src/commands/updateNodeAttributes.d.ts +0 -13
- package/dist/packages/core/src/commands/wrapIn.d.ts +0 -13
- package/dist/packages/core/src/commands/wrapInList.d.ts +0 -13
- package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -2
- package/dist/packages/core/src/extensions/commands.d.ts +0 -100
- 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 -5
- package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
- package/dist/packages/core/src/helpers/createDocument.d.ts +0 -4
- package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -8
- package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -9
- package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -8
- package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -2
- package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
- package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
- package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -4
- 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/getNodeAttributes.d.ts +0 -4
- 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 -3
- package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -2
- package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -2
- package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -2
- package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
- package/dist/packages/core/src/helpers/isActive.d.ts +0 -3
- package/dist/packages/core/src/helpers/isList.d.ts +0 -2
- package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -4
- package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -4
- 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/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 -30
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -3
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -3
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -3
- package/dist/packages/core/src/style.d.ts +0 -2
- package/dist/packages/core/src/types.d.ts +0 -154
- package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -8
- package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
- package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -7
- package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
- package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
- package/dist/packages/core/src/utilities/isClass.d.ts +0 -1
- package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -2
- package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -2
- package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
- package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -7
- package/dist/packages/core/src/utilities/removeElement.d.ts +0 -1
- package/dist/tiptap-core.bundle.umd.min.js +0 -17
- package/dist/tiptap-core.bundle.umd.min.js.map +0 -1
- package/dist/tiptap-core.cjs.js +0 -3027
- package/dist/tiptap-core.cjs.js.map +0 -1
- package/dist/tiptap-core.esm.js +0 -3002
- package/dist/tiptap-core.esm.js.map +0 -1
- package/dist/tiptap-core.umd.js +0 -3024
- package/dist/tiptap-core.umd.js.map +0 -1
- package/src/commands/insertHTML.ts +0 -30
- package/src/commands/insertNode.ts +0 -33
- package/src/commands/insertText.ts +0 -22
- package/src/commands/joinBackward.ts +0 -17
- package/src/commands/joinForward.ts +0 -17
- package/src/commands/replace.ts +0 -20
- package/src/commands/replaceRange.ts +0 -36
- package/src/commands/resetNodeAttributes.ts +0 -33
- package/src/commands/updateNodeAttributes.ts +0 -35
- package/src/utilities/isClass.ts +0 -7
- package/src/utilities/isObject.ts +0 -10
- package/src/utilities/removeElement.ts +0 -5
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2330 @@
|
|
|
1
|
+
import { EditorState, Plugin, Transaction, PluginKey, Selection, NodeSelection, TextSelection } from '@tiptap/pm/state';
|
|
2
|
+
import { NodeType, NodeSpec, Node as Node$1, DOMOutputSpec, MarkType, MarkSpec, Mark as Mark$1, ParseOptions, Schema, ContentMatch, ResolvedPos, Fragment } from '@tiptap/pm/model';
|
|
3
|
+
import { NodeView as NodeView$1, EditorProps, EditorView, Decoration } from '@tiptap/pm/view';
|
|
4
|
+
import { Transform } from '@tiptap/pm/transform';
|
|
5
|
+
import * as prosemirror_model from 'prosemirror-model';
|
|
6
|
+
|
|
7
|
+
declare type StringKeyOf<T> = Extract<keyof T, string>;
|
|
8
|
+
declare type CallbackType<T extends Record<string, any>, EventName extends StringKeyOf<T>> = T[EventName] extends any[] ? T[EventName] : [T[EventName]];
|
|
9
|
+
declare type CallbackFunction<T extends Record<string, any>, EventName extends StringKeyOf<T>> = (...props: CallbackType<T, EventName>) => any;
|
|
10
|
+
declare class EventEmitter<T extends Record<string, any>> {
|
|
11
|
+
private callbacks;
|
|
12
|
+
on<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this;
|
|
13
|
+
protected emit<EventName extends StringKeyOf<T>>(event: EventName, ...args: CallbackType<T, EventName>): this;
|
|
14
|
+
off<EventName extends StringKeyOf<T>>(event: EventName, fn?: CallbackFunction<T, EventName>): this;
|
|
15
|
+
protected removeAllListeners(): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare type InputRuleMatch = {
|
|
19
|
+
index: number;
|
|
20
|
+
text: string;
|
|
21
|
+
replaceWith?: string;
|
|
22
|
+
match?: RegExpMatchArray;
|
|
23
|
+
data?: Record<string, any>;
|
|
24
|
+
};
|
|
25
|
+
declare type InputRuleFinder = RegExp | ((text: string) => InputRuleMatch | null);
|
|
26
|
+
declare class InputRule {
|
|
27
|
+
find: InputRuleFinder;
|
|
28
|
+
handler: (props: {
|
|
29
|
+
state: EditorState;
|
|
30
|
+
range: Range;
|
|
31
|
+
match: ExtendedRegExpMatchArray;
|
|
32
|
+
commands: SingleCommands;
|
|
33
|
+
chain: () => ChainedCommands;
|
|
34
|
+
can: () => CanCommands;
|
|
35
|
+
}) => void | null;
|
|
36
|
+
constructor(config: {
|
|
37
|
+
find: InputRuleFinder;
|
|
38
|
+
handler: (props: {
|
|
39
|
+
state: EditorState;
|
|
40
|
+
range: Range;
|
|
41
|
+
match: ExtendedRegExpMatchArray;
|
|
42
|
+
commands: SingleCommands;
|
|
43
|
+
chain: () => ChainedCommands;
|
|
44
|
+
can: () => CanCommands;
|
|
45
|
+
}) => void | null;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Create an input rules plugin. When enabled, it will cause text
|
|
50
|
+
* input that matches any of the given rules to trigger the rule’s
|
|
51
|
+
* action.
|
|
52
|
+
*/
|
|
53
|
+
declare function inputRulesPlugin(props: {
|
|
54
|
+
editor: Editor;
|
|
55
|
+
rules: InputRule[];
|
|
56
|
+
}): Plugin;
|
|
57
|
+
|
|
58
|
+
declare type PasteRuleMatch = {
|
|
59
|
+
index: number;
|
|
60
|
+
text: string;
|
|
61
|
+
replaceWith?: string;
|
|
62
|
+
match?: RegExpMatchArray;
|
|
63
|
+
data?: Record<string, any>;
|
|
64
|
+
};
|
|
65
|
+
declare type PasteRuleFinder = RegExp | ((text: string) => PasteRuleMatch[] | null | undefined);
|
|
66
|
+
declare class PasteRule {
|
|
67
|
+
find: PasteRuleFinder;
|
|
68
|
+
handler: (props: {
|
|
69
|
+
state: EditorState;
|
|
70
|
+
range: Range;
|
|
71
|
+
match: ExtendedRegExpMatchArray;
|
|
72
|
+
commands: SingleCommands;
|
|
73
|
+
chain: () => ChainedCommands;
|
|
74
|
+
can: () => CanCommands;
|
|
75
|
+
}) => void | null;
|
|
76
|
+
constructor(config: {
|
|
77
|
+
find: PasteRuleFinder;
|
|
78
|
+
handler: (props: {
|
|
79
|
+
state: EditorState;
|
|
80
|
+
range: Range;
|
|
81
|
+
match: ExtendedRegExpMatchArray;
|
|
82
|
+
commands: SingleCommands;
|
|
83
|
+
chain: () => ChainedCommands;
|
|
84
|
+
can: () => CanCommands;
|
|
85
|
+
}) => void | null;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Create an paste rules plugin. When enabled, it will cause pasted
|
|
90
|
+
* text that matches any of the given rules to trigger the rule’s
|
|
91
|
+
* action.
|
|
92
|
+
*/
|
|
93
|
+
declare function pasteRulesPlugin(props: {
|
|
94
|
+
editor: Editor;
|
|
95
|
+
rules: PasteRule[];
|
|
96
|
+
}): Plugin[];
|
|
97
|
+
|
|
98
|
+
declare module '@tiptap/core' {
|
|
99
|
+
interface NodeConfig<Options = any, Storage = any> {
|
|
100
|
+
[key: string]: any;
|
|
101
|
+
/**
|
|
102
|
+
* Name
|
|
103
|
+
*/
|
|
104
|
+
name: string;
|
|
105
|
+
/**
|
|
106
|
+
* Priority
|
|
107
|
+
*/
|
|
108
|
+
priority?: number;
|
|
109
|
+
/**
|
|
110
|
+
* Default options
|
|
111
|
+
*/
|
|
112
|
+
defaultOptions?: Options;
|
|
113
|
+
/**
|
|
114
|
+
* Default Options
|
|
115
|
+
*/
|
|
116
|
+
addOptions?: (this: {
|
|
117
|
+
name: string;
|
|
118
|
+
parent: Exclude<ParentConfig<NodeConfig<Options, Storage>>['addOptions'], undefined>;
|
|
119
|
+
}) => Options;
|
|
120
|
+
/**
|
|
121
|
+
* Default Storage
|
|
122
|
+
*/
|
|
123
|
+
addStorage?: (this: {
|
|
124
|
+
name: string;
|
|
125
|
+
options: Options;
|
|
126
|
+
parent: Exclude<ParentConfig<NodeConfig<Options, Storage>>['addStorage'], undefined>;
|
|
127
|
+
}) => Storage;
|
|
128
|
+
/**
|
|
129
|
+
* Global attributes
|
|
130
|
+
*/
|
|
131
|
+
addGlobalAttributes?: (this: {
|
|
132
|
+
name: string;
|
|
133
|
+
options: Options;
|
|
134
|
+
storage: Storage;
|
|
135
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addGlobalAttributes'];
|
|
136
|
+
}) => GlobalAttributes | {};
|
|
137
|
+
/**
|
|
138
|
+
* Raw
|
|
139
|
+
*/
|
|
140
|
+
addCommands?: (this: {
|
|
141
|
+
name: string;
|
|
142
|
+
options: Options;
|
|
143
|
+
storage: Storage;
|
|
144
|
+
editor: Editor;
|
|
145
|
+
type: NodeType;
|
|
146
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addCommands'];
|
|
147
|
+
}) => Partial<RawCommands>;
|
|
148
|
+
/**
|
|
149
|
+
* Keyboard shortcuts
|
|
150
|
+
*/
|
|
151
|
+
addKeyboardShortcuts?: (this: {
|
|
152
|
+
name: string;
|
|
153
|
+
options: Options;
|
|
154
|
+
storage: Storage;
|
|
155
|
+
editor: Editor;
|
|
156
|
+
type: NodeType;
|
|
157
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addKeyboardShortcuts'];
|
|
158
|
+
}) => {
|
|
159
|
+
[key: string]: KeyboardShortcutCommand;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Input rules
|
|
163
|
+
*/
|
|
164
|
+
addInputRules?: (this: {
|
|
165
|
+
name: string;
|
|
166
|
+
options: Options;
|
|
167
|
+
storage: Storage;
|
|
168
|
+
editor: Editor;
|
|
169
|
+
type: NodeType;
|
|
170
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addInputRules'];
|
|
171
|
+
}) => InputRule[];
|
|
172
|
+
/**
|
|
173
|
+
* Paste rules
|
|
174
|
+
*/
|
|
175
|
+
addPasteRules?: (this: {
|
|
176
|
+
name: string;
|
|
177
|
+
options: Options;
|
|
178
|
+
storage: Storage;
|
|
179
|
+
editor: Editor;
|
|
180
|
+
type: NodeType;
|
|
181
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addPasteRules'];
|
|
182
|
+
}) => PasteRule[];
|
|
183
|
+
/**
|
|
184
|
+
* ProseMirror plugins
|
|
185
|
+
*/
|
|
186
|
+
addProseMirrorPlugins?: (this: {
|
|
187
|
+
name: string;
|
|
188
|
+
options: Options;
|
|
189
|
+
storage: Storage;
|
|
190
|
+
editor: Editor;
|
|
191
|
+
type: NodeType;
|
|
192
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addProseMirrorPlugins'];
|
|
193
|
+
}) => Plugin[];
|
|
194
|
+
/**
|
|
195
|
+
* Extensions
|
|
196
|
+
*/
|
|
197
|
+
addExtensions?: (this: {
|
|
198
|
+
name: string;
|
|
199
|
+
options: Options;
|
|
200
|
+
storage: Storage;
|
|
201
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addExtensions'];
|
|
202
|
+
}) => Extensions;
|
|
203
|
+
/**
|
|
204
|
+
* Extend Node Schema
|
|
205
|
+
*/
|
|
206
|
+
extendNodeSchema?: ((this: {
|
|
207
|
+
name: string;
|
|
208
|
+
options: Options;
|
|
209
|
+
storage: Storage;
|
|
210
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['extendNodeSchema'];
|
|
211
|
+
}, extension: Node) => Record<string, any>) | null;
|
|
212
|
+
/**
|
|
213
|
+
* Extend Mark Schema
|
|
214
|
+
*/
|
|
215
|
+
extendMarkSchema?: ((this: {
|
|
216
|
+
name: string;
|
|
217
|
+
options: Options;
|
|
218
|
+
storage: Storage;
|
|
219
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['extendMarkSchema'];
|
|
220
|
+
}, extension: Node) => Record<string, any>) | null;
|
|
221
|
+
/**
|
|
222
|
+
* The editor is not ready yet.
|
|
223
|
+
*/
|
|
224
|
+
onBeforeCreate?: ((this: {
|
|
225
|
+
name: string;
|
|
226
|
+
options: Options;
|
|
227
|
+
storage: Storage;
|
|
228
|
+
editor: Editor;
|
|
229
|
+
type: NodeType;
|
|
230
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['onBeforeCreate'];
|
|
231
|
+
}) => void) | null;
|
|
232
|
+
/**
|
|
233
|
+
* The editor is ready.
|
|
234
|
+
*/
|
|
235
|
+
onCreate?: ((this: {
|
|
236
|
+
name: string;
|
|
237
|
+
options: Options;
|
|
238
|
+
storage: Storage;
|
|
239
|
+
editor: Editor;
|
|
240
|
+
type: NodeType;
|
|
241
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['onCreate'];
|
|
242
|
+
}) => void) | null;
|
|
243
|
+
/**
|
|
244
|
+
* The content has changed.
|
|
245
|
+
*/
|
|
246
|
+
onUpdate?: ((this: {
|
|
247
|
+
name: string;
|
|
248
|
+
options: Options;
|
|
249
|
+
storage: Storage;
|
|
250
|
+
editor: Editor;
|
|
251
|
+
type: NodeType;
|
|
252
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['onUpdate'];
|
|
253
|
+
}) => void) | null;
|
|
254
|
+
/**
|
|
255
|
+
* The selection has changed.
|
|
256
|
+
*/
|
|
257
|
+
onSelectionUpdate?: ((this: {
|
|
258
|
+
name: string;
|
|
259
|
+
options: Options;
|
|
260
|
+
storage: Storage;
|
|
261
|
+
editor: Editor;
|
|
262
|
+
type: NodeType;
|
|
263
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['onSelectionUpdate'];
|
|
264
|
+
}) => void) | null;
|
|
265
|
+
/**
|
|
266
|
+
* The editor state has changed.
|
|
267
|
+
*/
|
|
268
|
+
onTransaction?: ((this: {
|
|
269
|
+
name: string;
|
|
270
|
+
options: Options;
|
|
271
|
+
storage: Storage;
|
|
272
|
+
editor: Editor;
|
|
273
|
+
type: NodeType;
|
|
274
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['onTransaction'];
|
|
275
|
+
}, props: {
|
|
276
|
+
transaction: Transaction;
|
|
277
|
+
}) => void) | null;
|
|
278
|
+
/**
|
|
279
|
+
* The editor is focused.
|
|
280
|
+
*/
|
|
281
|
+
onFocus?: ((this: {
|
|
282
|
+
name: string;
|
|
283
|
+
options: Options;
|
|
284
|
+
storage: Storage;
|
|
285
|
+
editor: Editor;
|
|
286
|
+
type: NodeType;
|
|
287
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['onFocus'];
|
|
288
|
+
}, props: {
|
|
289
|
+
event: FocusEvent;
|
|
290
|
+
}) => void) | null;
|
|
291
|
+
/**
|
|
292
|
+
* The editor isn’t focused anymore.
|
|
293
|
+
*/
|
|
294
|
+
onBlur?: ((this: {
|
|
295
|
+
name: string;
|
|
296
|
+
options: Options;
|
|
297
|
+
storage: Storage;
|
|
298
|
+
editor: Editor;
|
|
299
|
+
type: NodeType;
|
|
300
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['onBlur'];
|
|
301
|
+
}, props: {
|
|
302
|
+
event: FocusEvent;
|
|
303
|
+
}) => void) | null;
|
|
304
|
+
/**
|
|
305
|
+
* The editor is destroyed.
|
|
306
|
+
*/
|
|
307
|
+
onDestroy?: ((this: {
|
|
308
|
+
name: string;
|
|
309
|
+
options: Options;
|
|
310
|
+
storage: Storage;
|
|
311
|
+
editor: Editor;
|
|
312
|
+
type: NodeType;
|
|
313
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['onDestroy'];
|
|
314
|
+
}) => void) | null;
|
|
315
|
+
/**
|
|
316
|
+
* Node View
|
|
317
|
+
*/
|
|
318
|
+
addNodeView?: ((this: {
|
|
319
|
+
name: string;
|
|
320
|
+
options: Options;
|
|
321
|
+
storage: Storage;
|
|
322
|
+
editor: Editor;
|
|
323
|
+
type: NodeType;
|
|
324
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addNodeView'];
|
|
325
|
+
}) => NodeViewRenderer) | null;
|
|
326
|
+
/**
|
|
327
|
+
* TopNode
|
|
328
|
+
*/
|
|
329
|
+
topNode?: boolean;
|
|
330
|
+
/**
|
|
331
|
+
* Content
|
|
332
|
+
*/
|
|
333
|
+
content?: NodeSpec['content'] | ((this: {
|
|
334
|
+
name: string;
|
|
335
|
+
options: Options;
|
|
336
|
+
storage: Storage;
|
|
337
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['content'];
|
|
338
|
+
}) => NodeSpec['content']);
|
|
339
|
+
/**
|
|
340
|
+
* Marks
|
|
341
|
+
*/
|
|
342
|
+
marks?: NodeSpec['marks'] | ((this: {
|
|
343
|
+
name: string;
|
|
344
|
+
options: Options;
|
|
345
|
+
storage: Storage;
|
|
346
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['marks'];
|
|
347
|
+
}) => NodeSpec['marks']);
|
|
348
|
+
/**
|
|
349
|
+
* Group
|
|
350
|
+
*/
|
|
351
|
+
group?: NodeSpec['group'] | ((this: {
|
|
352
|
+
name: string;
|
|
353
|
+
options: Options;
|
|
354
|
+
storage: Storage;
|
|
355
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['group'];
|
|
356
|
+
}) => NodeSpec['group']);
|
|
357
|
+
/**
|
|
358
|
+
* Inline
|
|
359
|
+
*/
|
|
360
|
+
inline?: NodeSpec['inline'] | ((this: {
|
|
361
|
+
name: string;
|
|
362
|
+
options: Options;
|
|
363
|
+
storage: Storage;
|
|
364
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['inline'];
|
|
365
|
+
}) => NodeSpec['inline']);
|
|
366
|
+
/**
|
|
367
|
+
* Atom
|
|
368
|
+
*/
|
|
369
|
+
atom?: NodeSpec['atom'] | ((this: {
|
|
370
|
+
name: string;
|
|
371
|
+
options: Options;
|
|
372
|
+
storage: Storage;
|
|
373
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['atom'];
|
|
374
|
+
}) => NodeSpec['atom']);
|
|
375
|
+
/**
|
|
376
|
+
* Selectable
|
|
377
|
+
*/
|
|
378
|
+
selectable?: NodeSpec['selectable'] | ((this: {
|
|
379
|
+
name: string;
|
|
380
|
+
options: Options;
|
|
381
|
+
storage: Storage;
|
|
382
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['selectable'];
|
|
383
|
+
}) => NodeSpec['selectable']);
|
|
384
|
+
/**
|
|
385
|
+
* Draggable
|
|
386
|
+
*/
|
|
387
|
+
draggable?: NodeSpec['draggable'] | ((this: {
|
|
388
|
+
name: string;
|
|
389
|
+
options: Options;
|
|
390
|
+
storage: Storage;
|
|
391
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['draggable'];
|
|
392
|
+
}) => NodeSpec['draggable']);
|
|
393
|
+
/**
|
|
394
|
+
* Code
|
|
395
|
+
*/
|
|
396
|
+
code?: NodeSpec['code'] | ((this: {
|
|
397
|
+
name: string;
|
|
398
|
+
options: Options;
|
|
399
|
+
storage: Storage;
|
|
400
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['code'];
|
|
401
|
+
}) => NodeSpec['code']);
|
|
402
|
+
/**
|
|
403
|
+
* Whitespace
|
|
404
|
+
*/
|
|
405
|
+
whitespace?: NodeSpec['whitespace'] | ((this: {
|
|
406
|
+
name: string;
|
|
407
|
+
options: Options;
|
|
408
|
+
storage: Storage;
|
|
409
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['whitespace'];
|
|
410
|
+
}) => NodeSpec['whitespace']);
|
|
411
|
+
/**
|
|
412
|
+
* Defining
|
|
413
|
+
*/
|
|
414
|
+
defining?: NodeSpec['defining'] | ((this: {
|
|
415
|
+
name: string;
|
|
416
|
+
options: Options;
|
|
417
|
+
storage: Storage;
|
|
418
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['defining'];
|
|
419
|
+
}) => NodeSpec['defining']);
|
|
420
|
+
/**
|
|
421
|
+
* Isolating
|
|
422
|
+
*/
|
|
423
|
+
isolating?: NodeSpec['isolating'] | ((this: {
|
|
424
|
+
name: string;
|
|
425
|
+
options: Options;
|
|
426
|
+
storage: Storage;
|
|
427
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['isolating'];
|
|
428
|
+
}) => NodeSpec['isolating']);
|
|
429
|
+
/**
|
|
430
|
+
* Parse HTML
|
|
431
|
+
*/
|
|
432
|
+
parseHTML?: (this: {
|
|
433
|
+
name: string;
|
|
434
|
+
options: Options;
|
|
435
|
+
storage: Storage;
|
|
436
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['parseHTML'];
|
|
437
|
+
}) => NodeSpec['parseDOM'];
|
|
438
|
+
/**
|
|
439
|
+
* Render HTML
|
|
440
|
+
*/
|
|
441
|
+
renderHTML?: ((this: {
|
|
442
|
+
name: string;
|
|
443
|
+
options: Options;
|
|
444
|
+
storage: Storage;
|
|
445
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['renderHTML'];
|
|
446
|
+
}, props: {
|
|
447
|
+
node: Node$1;
|
|
448
|
+
HTMLAttributes: Record<string, any>;
|
|
449
|
+
}) => DOMOutputSpec) | null;
|
|
450
|
+
/**
|
|
451
|
+
* Render Text
|
|
452
|
+
*/
|
|
453
|
+
renderText?: ((this: {
|
|
454
|
+
name: string;
|
|
455
|
+
options: Options;
|
|
456
|
+
storage: Storage;
|
|
457
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['renderText'];
|
|
458
|
+
}, props: {
|
|
459
|
+
node: Node$1;
|
|
460
|
+
pos: number;
|
|
461
|
+
parent: Node$1;
|
|
462
|
+
index: number;
|
|
463
|
+
}) => string) | null;
|
|
464
|
+
/**
|
|
465
|
+
* Add Attributes
|
|
466
|
+
*/
|
|
467
|
+
addAttributes?: (this: {
|
|
468
|
+
name: string;
|
|
469
|
+
options: Options;
|
|
470
|
+
storage: Storage;
|
|
471
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addAttributes'];
|
|
472
|
+
}) => Attributes | {};
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
declare class Node<Options = any, Storage = any> {
|
|
476
|
+
type: string;
|
|
477
|
+
name: string;
|
|
478
|
+
parent: Node | null;
|
|
479
|
+
child: Node | null;
|
|
480
|
+
options: Options;
|
|
481
|
+
storage: Storage;
|
|
482
|
+
config: NodeConfig;
|
|
483
|
+
constructor(config?: Partial<NodeConfig<Options, Storage>>);
|
|
484
|
+
static create<O = any, S = any>(config?: Partial<NodeConfig<O, S>>): Node<O, S>;
|
|
485
|
+
configure(options?: Partial<Options>): Node<Options, Storage>;
|
|
486
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage>(extendedConfig?: Partial<NodeConfig<ExtendedOptions, ExtendedStorage>>): Node<ExtendedOptions, ExtendedStorage>;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
declare module '@tiptap/core' {
|
|
490
|
+
interface MarkConfig<Options = any, Storage = any> {
|
|
491
|
+
[key: string]: any;
|
|
492
|
+
/**
|
|
493
|
+
* Name
|
|
494
|
+
*/
|
|
495
|
+
name: string;
|
|
496
|
+
/**
|
|
497
|
+
* Priority
|
|
498
|
+
*/
|
|
499
|
+
priority?: number;
|
|
500
|
+
/**
|
|
501
|
+
* Default options
|
|
502
|
+
*/
|
|
503
|
+
defaultOptions?: Options;
|
|
504
|
+
/**
|
|
505
|
+
* Default Options
|
|
506
|
+
*/
|
|
507
|
+
addOptions?: (this: {
|
|
508
|
+
name: string;
|
|
509
|
+
parent: Exclude<ParentConfig<MarkConfig<Options, Storage>>['addOptions'], undefined>;
|
|
510
|
+
}) => Options;
|
|
511
|
+
/**
|
|
512
|
+
* Default Storage
|
|
513
|
+
*/
|
|
514
|
+
addStorage?: (this: {
|
|
515
|
+
name: string;
|
|
516
|
+
options: Options;
|
|
517
|
+
parent: Exclude<ParentConfig<MarkConfig<Options, Storage>>['addStorage'], undefined>;
|
|
518
|
+
}) => Storage;
|
|
519
|
+
/**
|
|
520
|
+
* Global attributes
|
|
521
|
+
*/
|
|
522
|
+
addGlobalAttributes?: (this: {
|
|
523
|
+
name: string;
|
|
524
|
+
options: Options;
|
|
525
|
+
storage: Storage;
|
|
526
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['addGlobalAttributes'];
|
|
527
|
+
}) => GlobalAttributes | {};
|
|
528
|
+
/**
|
|
529
|
+
* Raw
|
|
530
|
+
*/
|
|
531
|
+
addCommands?: (this: {
|
|
532
|
+
name: string;
|
|
533
|
+
options: Options;
|
|
534
|
+
storage: Storage;
|
|
535
|
+
editor: Editor;
|
|
536
|
+
type: MarkType;
|
|
537
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['addCommands'];
|
|
538
|
+
}) => Partial<RawCommands>;
|
|
539
|
+
/**
|
|
540
|
+
* Keyboard shortcuts
|
|
541
|
+
*/
|
|
542
|
+
addKeyboardShortcuts?: (this: {
|
|
543
|
+
name: string;
|
|
544
|
+
options: Options;
|
|
545
|
+
storage: Storage;
|
|
546
|
+
editor: Editor;
|
|
547
|
+
type: MarkType;
|
|
548
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['addKeyboardShortcuts'];
|
|
549
|
+
}) => {
|
|
550
|
+
[key: string]: KeyboardShortcutCommand;
|
|
551
|
+
};
|
|
552
|
+
/**
|
|
553
|
+
* Input rules
|
|
554
|
+
*/
|
|
555
|
+
addInputRules?: (this: {
|
|
556
|
+
name: string;
|
|
557
|
+
options: Options;
|
|
558
|
+
storage: Storage;
|
|
559
|
+
editor: Editor;
|
|
560
|
+
type: MarkType;
|
|
561
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['addInputRules'];
|
|
562
|
+
}) => InputRule[];
|
|
563
|
+
/**
|
|
564
|
+
* Paste rules
|
|
565
|
+
*/
|
|
566
|
+
addPasteRules?: (this: {
|
|
567
|
+
name: string;
|
|
568
|
+
options: Options;
|
|
569
|
+
storage: Storage;
|
|
570
|
+
editor: Editor;
|
|
571
|
+
type: MarkType;
|
|
572
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['addPasteRules'];
|
|
573
|
+
}) => PasteRule[];
|
|
574
|
+
/**
|
|
575
|
+
* ProseMirror plugins
|
|
576
|
+
*/
|
|
577
|
+
addProseMirrorPlugins?: (this: {
|
|
578
|
+
name: string;
|
|
579
|
+
options: Options;
|
|
580
|
+
storage: Storage;
|
|
581
|
+
editor: Editor;
|
|
582
|
+
type: MarkType;
|
|
583
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['addProseMirrorPlugins'];
|
|
584
|
+
}) => Plugin[];
|
|
585
|
+
/**
|
|
586
|
+
* Extensions
|
|
587
|
+
*/
|
|
588
|
+
addExtensions?: (this: {
|
|
589
|
+
name: string;
|
|
590
|
+
options: Options;
|
|
591
|
+
storage: Storage;
|
|
592
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['addExtensions'];
|
|
593
|
+
}) => Extensions;
|
|
594
|
+
/**
|
|
595
|
+
* Extend Node Schema
|
|
596
|
+
*/
|
|
597
|
+
extendNodeSchema?: ((this: {
|
|
598
|
+
name: string;
|
|
599
|
+
options: Options;
|
|
600
|
+
storage: Storage;
|
|
601
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['extendNodeSchema'];
|
|
602
|
+
}, extension: Node) => Record<string, any>) | null;
|
|
603
|
+
/**
|
|
604
|
+
* Extend Mark Schema
|
|
605
|
+
*/
|
|
606
|
+
extendMarkSchema?: ((this: {
|
|
607
|
+
name: string;
|
|
608
|
+
options: Options;
|
|
609
|
+
storage: Storage;
|
|
610
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['extendMarkSchema'];
|
|
611
|
+
}, extension: Mark) => Record<string, any>) | null;
|
|
612
|
+
/**
|
|
613
|
+
* The editor is not ready yet.
|
|
614
|
+
*/
|
|
615
|
+
onBeforeCreate?: ((this: {
|
|
616
|
+
name: string;
|
|
617
|
+
options: Options;
|
|
618
|
+
storage: Storage;
|
|
619
|
+
editor: Editor;
|
|
620
|
+
type: MarkType;
|
|
621
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['onBeforeCreate'];
|
|
622
|
+
}) => void) | null;
|
|
623
|
+
/**
|
|
624
|
+
* The editor is ready.
|
|
625
|
+
*/
|
|
626
|
+
onCreate?: ((this: {
|
|
627
|
+
name: string;
|
|
628
|
+
options: Options;
|
|
629
|
+
storage: Storage;
|
|
630
|
+
editor: Editor;
|
|
631
|
+
type: MarkType;
|
|
632
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['onCreate'];
|
|
633
|
+
}) => void) | null;
|
|
634
|
+
/**
|
|
635
|
+
* The content has changed.
|
|
636
|
+
*/
|
|
637
|
+
onUpdate?: ((this: {
|
|
638
|
+
name: string;
|
|
639
|
+
options: Options;
|
|
640
|
+
storage: Storage;
|
|
641
|
+
editor: Editor;
|
|
642
|
+
type: MarkType;
|
|
643
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['onUpdate'];
|
|
644
|
+
}) => void) | null;
|
|
645
|
+
/**
|
|
646
|
+
* The selection has changed.
|
|
647
|
+
*/
|
|
648
|
+
onSelectionUpdate?: ((this: {
|
|
649
|
+
name: string;
|
|
650
|
+
options: Options;
|
|
651
|
+
storage: Storage;
|
|
652
|
+
editor: Editor;
|
|
653
|
+
type: MarkType;
|
|
654
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['onSelectionUpdate'];
|
|
655
|
+
}) => void) | null;
|
|
656
|
+
/**
|
|
657
|
+
* The editor state has changed.
|
|
658
|
+
*/
|
|
659
|
+
onTransaction?: ((this: {
|
|
660
|
+
name: string;
|
|
661
|
+
options: Options;
|
|
662
|
+
storage: Storage;
|
|
663
|
+
editor: Editor;
|
|
664
|
+
type: MarkType;
|
|
665
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['onTransaction'];
|
|
666
|
+
}, props: {
|
|
667
|
+
transaction: Transaction;
|
|
668
|
+
}) => void) | null;
|
|
669
|
+
/**
|
|
670
|
+
* The editor is focused.
|
|
671
|
+
*/
|
|
672
|
+
onFocus?: ((this: {
|
|
673
|
+
name: string;
|
|
674
|
+
options: Options;
|
|
675
|
+
storage: Storage;
|
|
676
|
+
editor: Editor;
|
|
677
|
+
type: MarkType;
|
|
678
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['onFocus'];
|
|
679
|
+
}, props: {
|
|
680
|
+
event: FocusEvent;
|
|
681
|
+
}) => void) | null;
|
|
682
|
+
/**
|
|
683
|
+
* The editor isn’t focused anymore.
|
|
684
|
+
*/
|
|
685
|
+
onBlur?: ((this: {
|
|
686
|
+
name: string;
|
|
687
|
+
options: Options;
|
|
688
|
+
storage: Storage;
|
|
689
|
+
editor: Editor;
|
|
690
|
+
type: MarkType;
|
|
691
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['onBlur'];
|
|
692
|
+
}, props: {
|
|
693
|
+
event: FocusEvent;
|
|
694
|
+
}) => void) | null;
|
|
695
|
+
/**
|
|
696
|
+
* The editor is destroyed.
|
|
697
|
+
*/
|
|
698
|
+
onDestroy?: ((this: {
|
|
699
|
+
name: string;
|
|
700
|
+
options: Options;
|
|
701
|
+
storage: Storage;
|
|
702
|
+
editor: Editor;
|
|
703
|
+
type: MarkType;
|
|
704
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['onDestroy'];
|
|
705
|
+
}) => void) | null;
|
|
706
|
+
/**
|
|
707
|
+
* Keep mark after split node
|
|
708
|
+
*/
|
|
709
|
+
keepOnSplit?: boolean | (() => boolean);
|
|
710
|
+
/**
|
|
711
|
+
* Inclusive
|
|
712
|
+
*/
|
|
713
|
+
inclusive?: MarkSpec['inclusive'] | ((this: {
|
|
714
|
+
name: string;
|
|
715
|
+
options: Options;
|
|
716
|
+
storage: Storage;
|
|
717
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['inclusive'];
|
|
718
|
+
}) => MarkSpec['inclusive']);
|
|
719
|
+
/**
|
|
720
|
+
* Excludes
|
|
721
|
+
*/
|
|
722
|
+
excludes?: MarkSpec['excludes'] | ((this: {
|
|
723
|
+
name: string;
|
|
724
|
+
options: Options;
|
|
725
|
+
storage: Storage;
|
|
726
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['excludes'];
|
|
727
|
+
}) => MarkSpec['excludes']);
|
|
728
|
+
/**
|
|
729
|
+
* Marks this Mark as exitable
|
|
730
|
+
*/
|
|
731
|
+
exitable?: boolean | (() => boolean);
|
|
732
|
+
/**
|
|
733
|
+
* Group
|
|
734
|
+
*/
|
|
735
|
+
group?: MarkSpec['group'] | ((this: {
|
|
736
|
+
name: string;
|
|
737
|
+
options: Options;
|
|
738
|
+
storage: Storage;
|
|
739
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['group'];
|
|
740
|
+
}) => MarkSpec['group']);
|
|
741
|
+
/**
|
|
742
|
+
* Spanning
|
|
743
|
+
*/
|
|
744
|
+
spanning?: MarkSpec['spanning'] | ((this: {
|
|
745
|
+
name: string;
|
|
746
|
+
options: Options;
|
|
747
|
+
storage: Storage;
|
|
748
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['spanning'];
|
|
749
|
+
}) => MarkSpec['spanning']);
|
|
750
|
+
/**
|
|
751
|
+
* Code
|
|
752
|
+
*/
|
|
753
|
+
code?: boolean | ((this: {
|
|
754
|
+
name: string;
|
|
755
|
+
options: Options;
|
|
756
|
+
storage: Storage;
|
|
757
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['code'];
|
|
758
|
+
}) => boolean);
|
|
759
|
+
/**
|
|
760
|
+
* Parse HTML
|
|
761
|
+
*/
|
|
762
|
+
parseHTML?: (this: {
|
|
763
|
+
name: string;
|
|
764
|
+
options: Options;
|
|
765
|
+
storage: Storage;
|
|
766
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['parseHTML'];
|
|
767
|
+
}) => MarkSpec['parseDOM'];
|
|
768
|
+
/**
|
|
769
|
+
* Render HTML
|
|
770
|
+
*/
|
|
771
|
+
renderHTML?: ((this: {
|
|
772
|
+
name: string;
|
|
773
|
+
options: Options;
|
|
774
|
+
storage: Storage;
|
|
775
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['renderHTML'];
|
|
776
|
+
}, props: {
|
|
777
|
+
mark: Mark$1;
|
|
778
|
+
HTMLAttributes: Record<string, any>;
|
|
779
|
+
}) => DOMOutputSpec) | null;
|
|
780
|
+
/**
|
|
781
|
+
* Attributes
|
|
782
|
+
*/
|
|
783
|
+
addAttributes?: (this: {
|
|
784
|
+
name: string;
|
|
785
|
+
options: Options;
|
|
786
|
+
storage: Storage;
|
|
787
|
+
parent: ParentConfig<MarkConfig<Options, Storage>>['addAttributes'];
|
|
788
|
+
}) => Attributes | {};
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
declare class Mark<Options = any, Storage = any> {
|
|
792
|
+
type: string;
|
|
793
|
+
name: string;
|
|
794
|
+
parent: Mark | null;
|
|
795
|
+
child: Mark | null;
|
|
796
|
+
options: Options;
|
|
797
|
+
storage: Storage;
|
|
798
|
+
config: MarkConfig;
|
|
799
|
+
constructor(config?: Partial<MarkConfig<Options, Storage>>);
|
|
800
|
+
static create<O = any, S = any>(config?: Partial<MarkConfig<O, S>>): Mark<O, S>;
|
|
801
|
+
configure(options?: Partial<Options>): Mark<Options, Storage>;
|
|
802
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage>(extendedConfig?: Partial<MarkConfig<ExtendedOptions, ExtendedStorage>>): Mark<ExtendedOptions, ExtendedStorage>;
|
|
803
|
+
static handleExit({ editor, mark }: {
|
|
804
|
+
editor: Editor;
|
|
805
|
+
mark: Mark;
|
|
806
|
+
}): boolean;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
declare module '@tiptap/core' {
|
|
810
|
+
interface ExtensionConfig<Options = any, Storage = any> {
|
|
811
|
+
[key: string]: any;
|
|
812
|
+
/**
|
|
813
|
+
* Name
|
|
814
|
+
*/
|
|
815
|
+
name: string;
|
|
816
|
+
/**
|
|
817
|
+
* Priority
|
|
818
|
+
*/
|
|
819
|
+
priority?: number;
|
|
820
|
+
/**
|
|
821
|
+
* Default options
|
|
822
|
+
*/
|
|
823
|
+
defaultOptions?: Options;
|
|
824
|
+
/**
|
|
825
|
+
* Default Options
|
|
826
|
+
*/
|
|
827
|
+
addOptions?: (this: {
|
|
828
|
+
name: string;
|
|
829
|
+
parent: Exclude<ParentConfig<ExtensionConfig<Options, Storage>>['addOptions'], undefined>;
|
|
830
|
+
}) => Options;
|
|
831
|
+
/**
|
|
832
|
+
* Default Storage
|
|
833
|
+
*/
|
|
834
|
+
addStorage?: (this: {
|
|
835
|
+
name: string;
|
|
836
|
+
options: Options;
|
|
837
|
+
parent: Exclude<ParentConfig<ExtensionConfig<Options, Storage>>['addStorage'], undefined>;
|
|
838
|
+
}) => Storage;
|
|
839
|
+
/**
|
|
840
|
+
* Global attributes
|
|
841
|
+
*/
|
|
842
|
+
addGlobalAttributes?: (this: {
|
|
843
|
+
name: string;
|
|
844
|
+
options: Options;
|
|
845
|
+
storage: Storage;
|
|
846
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addGlobalAttributes'];
|
|
847
|
+
}) => GlobalAttributes | {};
|
|
848
|
+
/**
|
|
849
|
+
* Raw
|
|
850
|
+
*/
|
|
851
|
+
addCommands?: (this: {
|
|
852
|
+
name: string;
|
|
853
|
+
options: Options;
|
|
854
|
+
storage: Storage;
|
|
855
|
+
editor: Editor;
|
|
856
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addCommands'];
|
|
857
|
+
}) => Partial<RawCommands>;
|
|
858
|
+
/**
|
|
859
|
+
* Keyboard shortcuts
|
|
860
|
+
*/
|
|
861
|
+
addKeyboardShortcuts?: (this: {
|
|
862
|
+
name: string;
|
|
863
|
+
options: Options;
|
|
864
|
+
storage: Storage;
|
|
865
|
+
editor: Editor;
|
|
866
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addKeyboardShortcuts'];
|
|
867
|
+
}) => {
|
|
868
|
+
[key: string]: KeyboardShortcutCommand;
|
|
869
|
+
};
|
|
870
|
+
/**
|
|
871
|
+
* Input rules
|
|
872
|
+
*/
|
|
873
|
+
addInputRules?: (this: {
|
|
874
|
+
name: string;
|
|
875
|
+
options: Options;
|
|
876
|
+
storage: Storage;
|
|
877
|
+
editor: Editor;
|
|
878
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addInputRules'];
|
|
879
|
+
}) => InputRule[];
|
|
880
|
+
/**
|
|
881
|
+
* Paste rules
|
|
882
|
+
*/
|
|
883
|
+
addPasteRules?: (this: {
|
|
884
|
+
name: string;
|
|
885
|
+
options: Options;
|
|
886
|
+
storage: Storage;
|
|
887
|
+
editor: Editor;
|
|
888
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addPasteRules'];
|
|
889
|
+
}) => PasteRule[];
|
|
890
|
+
/**
|
|
891
|
+
* ProseMirror plugins
|
|
892
|
+
*/
|
|
893
|
+
addProseMirrorPlugins?: (this: {
|
|
894
|
+
name: string;
|
|
895
|
+
options: Options;
|
|
896
|
+
storage: Storage;
|
|
897
|
+
editor: Editor;
|
|
898
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addProseMirrorPlugins'];
|
|
899
|
+
}) => Plugin[];
|
|
900
|
+
/**
|
|
901
|
+
* Extensions
|
|
902
|
+
*/
|
|
903
|
+
addExtensions?: (this: {
|
|
904
|
+
name: string;
|
|
905
|
+
options: Options;
|
|
906
|
+
storage: Storage;
|
|
907
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addExtensions'];
|
|
908
|
+
}) => Extensions;
|
|
909
|
+
/**
|
|
910
|
+
* Extend Node Schema
|
|
911
|
+
*/
|
|
912
|
+
extendNodeSchema?: ((this: {
|
|
913
|
+
name: string;
|
|
914
|
+
options: Options;
|
|
915
|
+
storage: Storage;
|
|
916
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['extendNodeSchema'];
|
|
917
|
+
}, extension: Node) => Record<string, any>) | null;
|
|
918
|
+
/**
|
|
919
|
+
* Extend Mark Schema
|
|
920
|
+
*/
|
|
921
|
+
extendMarkSchema?: ((this: {
|
|
922
|
+
name: string;
|
|
923
|
+
options: Options;
|
|
924
|
+
storage: Storage;
|
|
925
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['extendMarkSchema'];
|
|
926
|
+
}, extension: Mark) => Record<string, any>) | null;
|
|
927
|
+
/**
|
|
928
|
+
* The editor is not ready yet.
|
|
929
|
+
*/
|
|
930
|
+
onBeforeCreate?: ((this: {
|
|
931
|
+
name: string;
|
|
932
|
+
options: Options;
|
|
933
|
+
storage: Storage;
|
|
934
|
+
editor: Editor;
|
|
935
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onBeforeCreate'];
|
|
936
|
+
}) => void) | null;
|
|
937
|
+
/**
|
|
938
|
+
* The editor is ready.
|
|
939
|
+
*/
|
|
940
|
+
onCreate?: ((this: {
|
|
941
|
+
name: string;
|
|
942
|
+
options: Options;
|
|
943
|
+
storage: Storage;
|
|
944
|
+
editor: Editor;
|
|
945
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onCreate'];
|
|
946
|
+
}) => void) | null;
|
|
947
|
+
/**
|
|
948
|
+
* The content has changed.
|
|
949
|
+
*/
|
|
950
|
+
onUpdate?: ((this: {
|
|
951
|
+
name: string;
|
|
952
|
+
options: Options;
|
|
953
|
+
storage: Storage;
|
|
954
|
+
editor: Editor;
|
|
955
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onUpdate'];
|
|
956
|
+
}) => void) | null;
|
|
957
|
+
/**
|
|
958
|
+
* The selection has changed.
|
|
959
|
+
*/
|
|
960
|
+
onSelectionUpdate?: ((this: {
|
|
961
|
+
name: string;
|
|
962
|
+
options: Options;
|
|
963
|
+
storage: Storage;
|
|
964
|
+
editor: Editor;
|
|
965
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onSelectionUpdate'];
|
|
966
|
+
}) => void) | null;
|
|
967
|
+
/**
|
|
968
|
+
* The editor state has changed.
|
|
969
|
+
*/
|
|
970
|
+
onTransaction?: ((this: {
|
|
971
|
+
name: string;
|
|
972
|
+
options: Options;
|
|
973
|
+
storage: Storage;
|
|
974
|
+
editor: Editor;
|
|
975
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onTransaction'];
|
|
976
|
+
}, props: {
|
|
977
|
+
transaction: Transaction;
|
|
978
|
+
}) => void) | null;
|
|
979
|
+
/**
|
|
980
|
+
* The editor is focused.
|
|
981
|
+
*/
|
|
982
|
+
onFocus?: ((this: {
|
|
983
|
+
name: string;
|
|
984
|
+
options: Options;
|
|
985
|
+
storage: Storage;
|
|
986
|
+
editor: Editor;
|
|
987
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onFocus'];
|
|
988
|
+
}, props: {
|
|
989
|
+
event: FocusEvent;
|
|
990
|
+
}) => void) | null;
|
|
991
|
+
/**
|
|
992
|
+
* The editor isn’t focused anymore.
|
|
993
|
+
*/
|
|
994
|
+
onBlur?: ((this: {
|
|
995
|
+
name: string;
|
|
996
|
+
options: Options;
|
|
997
|
+
storage: Storage;
|
|
998
|
+
editor: Editor;
|
|
999
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onBlur'];
|
|
1000
|
+
}, props: {
|
|
1001
|
+
event: FocusEvent;
|
|
1002
|
+
}) => void) | null;
|
|
1003
|
+
/**
|
|
1004
|
+
* The editor is destroyed.
|
|
1005
|
+
*/
|
|
1006
|
+
onDestroy?: ((this: {
|
|
1007
|
+
name: string;
|
|
1008
|
+
options: Options;
|
|
1009
|
+
storage: Storage;
|
|
1010
|
+
editor: Editor;
|
|
1011
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onDestroy'];
|
|
1012
|
+
}) => void) | null;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
declare class Extension<Options = any, Storage = any> {
|
|
1016
|
+
type: string;
|
|
1017
|
+
name: string;
|
|
1018
|
+
parent: Extension | null;
|
|
1019
|
+
child: Extension | null;
|
|
1020
|
+
options: Options;
|
|
1021
|
+
storage: Storage;
|
|
1022
|
+
config: ExtensionConfig;
|
|
1023
|
+
constructor(config?: Partial<ExtensionConfig<Options, Storage>>);
|
|
1024
|
+
static create<O = any, S = any>(config?: Partial<ExtensionConfig<O, S>>): Extension<O, S>;
|
|
1025
|
+
configure(options?: Partial<Options>): Extension<Options, Storage>;
|
|
1026
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage>(extendedConfig?: Partial<ExtensionConfig<ExtendedOptions, ExtendedStorage>>): Extension<ExtendedOptions, ExtendedStorage>;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
declare type AnyConfig = ExtensionConfig | NodeConfig | MarkConfig;
|
|
1030
|
+
declare type AnyExtension = Extension | Node | Mark;
|
|
1031
|
+
declare type Extensions = AnyExtension[];
|
|
1032
|
+
declare type ParentConfig<T> = Partial<{
|
|
1033
|
+
[P in keyof T]: Required<T>[P] extends (...args: any) => any ? (...args: Parameters<Required<T>[P]>) => ReturnType<Required<T>[P]> : T[P];
|
|
1034
|
+
}>;
|
|
1035
|
+
declare type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
1036
|
+
declare type RemoveThis<T> = T extends (...args: any) => any ? (...args: Parameters<T>) => ReturnType<T> : T;
|
|
1037
|
+
declare type MaybeReturnType<T> = T extends (...args: any) => any ? ReturnType<T> : T;
|
|
1038
|
+
declare type MaybeThisParameterType<T> = Exclude<T, Primitive> extends (...args: any) => any ? ThisParameterType<Exclude<T, Primitive>> : any;
|
|
1039
|
+
interface EditorEvents {
|
|
1040
|
+
beforeCreate: {
|
|
1041
|
+
editor: Editor;
|
|
1042
|
+
};
|
|
1043
|
+
create: {
|
|
1044
|
+
editor: Editor;
|
|
1045
|
+
};
|
|
1046
|
+
update: {
|
|
1047
|
+
editor: Editor;
|
|
1048
|
+
transaction: Transaction;
|
|
1049
|
+
};
|
|
1050
|
+
selectionUpdate: {
|
|
1051
|
+
editor: Editor;
|
|
1052
|
+
transaction: Transaction;
|
|
1053
|
+
};
|
|
1054
|
+
transaction: {
|
|
1055
|
+
editor: Editor;
|
|
1056
|
+
transaction: Transaction;
|
|
1057
|
+
};
|
|
1058
|
+
focus: {
|
|
1059
|
+
editor: Editor;
|
|
1060
|
+
event: FocusEvent;
|
|
1061
|
+
transaction: Transaction;
|
|
1062
|
+
};
|
|
1063
|
+
blur: {
|
|
1064
|
+
editor: Editor;
|
|
1065
|
+
event: FocusEvent;
|
|
1066
|
+
transaction: Transaction;
|
|
1067
|
+
};
|
|
1068
|
+
destroy: void;
|
|
1069
|
+
}
|
|
1070
|
+
declare type EnableRules = (AnyExtension | string)[] | boolean;
|
|
1071
|
+
interface EditorOptions {
|
|
1072
|
+
element: Element;
|
|
1073
|
+
content: Content;
|
|
1074
|
+
extensions: Extensions;
|
|
1075
|
+
injectCSS: boolean;
|
|
1076
|
+
injectNonce: string | undefined;
|
|
1077
|
+
autofocus: FocusPosition;
|
|
1078
|
+
editable: boolean;
|
|
1079
|
+
editorProps: EditorProps;
|
|
1080
|
+
parseOptions: ParseOptions;
|
|
1081
|
+
enableInputRules: EnableRules;
|
|
1082
|
+
enablePasteRules: EnableRules;
|
|
1083
|
+
enableCoreExtensions: boolean;
|
|
1084
|
+
onBeforeCreate: (props: EditorEvents['beforeCreate']) => void;
|
|
1085
|
+
onCreate: (props: EditorEvents['create']) => void;
|
|
1086
|
+
onUpdate: (props: EditorEvents['update']) => void;
|
|
1087
|
+
onSelectionUpdate: (props: EditorEvents['selectionUpdate']) => void;
|
|
1088
|
+
onTransaction: (props: EditorEvents['transaction']) => void;
|
|
1089
|
+
onFocus: (props: EditorEvents['focus']) => void;
|
|
1090
|
+
onBlur: (props: EditorEvents['blur']) => void;
|
|
1091
|
+
onDestroy: (props: EditorEvents['destroy']) => void;
|
|
1092
|
+
}
|
|
1093
|
+
declare type HTMLContent = string;
|
|
1094
|
+
declare type JSONContent = {
|
|
1095
|
+
type?: string;
|
|
1096
|
+
attrs?: Record<string, any>;
|
|
1097
|
+
content?: JSONContent[];
|
|
1098
|
+
marks?: {
|
|
1099
|
+
type: string;
|
|
1100
|
+
attrs?: Record<string, any>;
|
|
1101
|
+
[key: string]: any;
|
|
1102
|
+
}[];
|
|
1103
|
+
text?: string;
|
|
1104
|
+
[key: string]: any;
|
|
1105
|
+
};
|
|
1106
|
+
declare type Content = HTMLContent | JSONContent | JSONContent[] | null;
|
|
1107
|
+
declare type CommandProps = {
|
|
1108
|
+
editor: Editor;
|
|
1109
|
+
tr: Transaction;
|
|
1110
|
+
commands: SingleCommands;
|
|
1111
|
+
can: () => CanCommands;
|
|
1112
|
+
chain: () => ChainedCommands;
|
|
1113
|
+
state: EditorState;
|
|
1114
|
+
view: EditorView;
|
|
1115
|
+
dispatch: ((args?: any) => any) | undefined;
|
|
1116
|
+
};
|
|
1117
|
+
declare type Command = (props: CommandProps) => boolean;
|
|
1118
|
+
declare type CommandSpec = (...args: any[]) => Command;
|
|
1119
|
+
declare type KeyboardShortcutCommand = (props: {
|
|
1120
|
+
editor: Editor;
|
|
1121
|
+
}) => boolean;
|
|
1122
|
+
declare type Attribute = {
|
|
1123
|
+
default: any;
|
|
1124
|
+
rendered?: boolean;
|
|
1125
|
+
renderHTML?: ((attributes: Record<string, any>) => Record<string, any> | null) | null;
|
|
1126
|
+
parseHTML?: ((element: HTMLElement) => any | null) | null;
|
|
1127
|
+
keepOnSplit: boolean;
|
|
1128
|
+
isRequired?: boolean;
|
|
1129
|
+
};
|
|
1130
|
+
declare type Attributes = {
|
|
1131
|
+
[key: string]: Attribute;
|
|
1132
|
+
};
|
|
1133
|
+
declare type ExtensionAttribute = {
|
|
1134
|
+
type: string;
|
|
1135
|
+
name: string;
|
|
1136
|
+
attribute: Required<Attribute>;
|
|
1137
|
+
};
|
|
1138
|
+
declare type GlobalAttributes = {
|
|
1139
|
+
types: string[];
|
|
1140
|
+
attributes: {
|
|
1141
|
+
[key: string]: Attribute;
|
|
1142
|
+
};
|
|
1143
|
+
}[];
|
|
1144
|
+
declare type PickValue<T, K extends keyof T> = T[K];
|
|
1145
|
+
declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
1146
|
+
declare type Diff<T extends keyof any, U extends keyof any> = ({
|
|
1147
|
+
[P in T]: P;
|
|
1148
|
+
} & {
|
|
1149
|
+
[P in U]: never;
|
|
1150
|
+
} & {
|
|
1151
|
+
[x: string]: never;
|
|
1152
|
+
})[T];
|
|
1153
|
+
declare type Overwrite<T, U> = Pick<T, Diff<keyof T, keyof U>> & U;
|
|
1154
|
+
declare type ValuesOf<T> = T[keyof T];
|
|
1155
|
+
declare type KeysWithTypeOf<T, Type> = {
|
|
1156
|
+
[P in keyof T]: T[P] extends Type ? P : never;
|
|
1157
|
+
}[keyof T];
|
|
1158
|
+
declare type NodeViewProps = {
|
|
1159
|
+
editor: Editor;
|
|
1160
|
+
node: Node$1;
|
|
1161
|
+
decorations: Decoration[];
|
|
1162
|
+
selected: boolean;
|
|
1163
|
+
extension: Node;
|
|
1164
|
+
getPos: () => number;
|
|
1165
|
+
updateAttributes: (attributes: Record<string, any>) => void;
|
|
1166
|
+
deleteNode: () => void;
|
|
1167
|
+
};
|
|
1168
|
+
interface NodeViewRendererOptions {
|
|
1169
|
+
stopEvent: ((props: {
|
|
1170
|
+
event: Event;
|
|
1171
|
+
}) => boolean) | null;
|
|
1172
|
+
ignoreMutation: ((props: {
|
|
1173
|
+
mutation: MutationRecord | {
|
|
1174
|
+
type: 'selection';
|
|
1175
|
+
target: Element;
|
|
1176
|
+
};
|
|
1177
|
+
}) => boolean) | null;
|
|
1178
|
+
}
|
|
1179
|
+
declare type NodeViewRendererProps = {
|
|
1180
|
+
editor: Editor;
|
|
1181
|
+
node: Node$1;
|
|
1182
|
+
getPos: (() => number) | boolean;
|
|
1183
|
+
HTMLAttributes: Record<string, any>;
|
|
1184
|
+
decorations: Decoration[];
|
|
1185
|
+
extension: Node;
|
|
1186
|
+
};
|
|
1187
|
+
declare type NodeViewRenderer = (props: NodeViewRendererProps) => NodeView$1 | {};
|
|
1188
|
+
declare type AnyCommands = Record<string, (...args: any[]) => Command>;
|
|
1189
|
+
declare type UnionCommands<T = Command> = UnionToIntersection<ValuesOf<Pick<Commands<T>, KeysWithTypeOf<Commands<T>, {}>>>>;
|
|
1190
|
+
declare type RawCommands = {
|
|
1191
|
+
[Item in keyof UnionCommands]: UnionCommands<Command>[Item];
|
|
1192
|
+
};
|
|
1193
|
+
declare type SingleCommands = {
|
|
1194
|
+
[Item in keyof UnionCommands]: UnionCommands<boolean>[Item];
|
|
1195
|
+
};
|
|
1196
|
+
declare type ChainedCommands = {
|
|
1197
|
+
[Item in keyof UnionCommands]: UnionCommands<ChainedCommands>[Item];
|
|
1198
|
+
} & {
|
|
1199
|
+
run: () => boolean;
|
|
1200
|
+
};
|
|
1201
|
+
declare type CanCommands = SingleCommands & {
|
|
1202
|
+
chain: () => ChainedCommands;
|
|
1203
|
+
};
|
|
1204
|
+
declare type FocusPosition = 'start' | 'end' | 'all' | number | boolean | null;
|
|
1205
|
+
declare type Range = {
|
|
1206
|
+
from: number;
|
|
1207
|
+
to: number;
|
|
1208
|
+
};
|
|
1209
|
+
declare type NodeRange = {
|
|
1210
|
+
node: Node$1;
|
|
1211
|
+
from: number;
|
|
1212
|
+
to: number;
|
|
1213
|
+
};
|
|
1214
|
+
declare type MarkRange = {
|
|
1215
|
+
mark: Mark$1;
|
|
1216
|
+
from: number;
|
|
1217
|
+
to: number;
|
|
1218
|
+
};
|
|
1219
|
+
declare type Predicate = (node: Node$1) => boolean;
|
|
1220
|
+
declare type NodeWithPos = {
|
|
1221
|
+
node: Node$1;
|
|
1222
|
+
pos: number;
|
|
1223
|
+
};
|
|
1224
|
+
declare type TextSerializer = (props: {
|
|
1225
|
+
node: Node$1;
|
|
1226
|
+
pos: number;
|
|
1227
|
+
parent: Node$1;
|
|
1228
|
+
index: number;
|
|
1229
|
+
range: Range;
|
|
1230
|
+
}) => string;
|
|
1231
|
+
declare type ExtendedRegExpMatchArray = RegExpMatchArray & {
|
|
1232
|
+
data?: Record<string, any>;
|
|
1233
|
+
};
|
|
1234
|
+
declare type Dispatch = ((args?: any) => any) | undefined;
|
|
1235
|
+
|
|
1236
|
+
declare class ExtensionManager {
|
|
1237
|
+
editor: Editor;
|
|
1238
|
+
schema: Schema;
|
|
1239
|
+
extensions: Extensions;
|
|
1240
|
+
splittableMarks: string[];
|
|
1241
|
+
constructor(extensions: Extensions, editor: Editor);
|
|
1242
|
+
static resolve(extensions: Extensions): Extensions;
|
|
1243
|
+
static flatten(extensions: Extensions): Extensions;
|
|
1244
|
+
static sort(extensions: Extensions): Extensions;
|
|
1245
|
+
get commands(): RawCommands;
|
|
1246
|
+
get plugins(): Plugin[];
|
|
1247
|
+
get attributes(): ExtensionAttribute[];
|
|
1248
|
+
get nodeViews(): any;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
declare const ClipboardTextSerializer: Extension<any, any>;
|
|
1252
|
+
|
|
1253
|
+
declare module '@tiptap/core' {
|
|
1254
|
+
interface Commands<ReturnType> {
|
|
1255
|
+
blur: {
|
|
1256
|
+
/**
|
|
1257
|
+
* Removes focus from the editor.
|
|
1258
|
+
*/
|
|
1259
|
+
blur: () => ReturnType;
|
|
1260
|
+
};
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
declare module '@tiptap/core' {
|
|
1265
|
+
interface Commands<ReturnType> {
|
|
1266
|
+
clearContent: {
|
|
1267
|
+
/**
|
|
1268
|
+
* Clear the whole document.
|
|
1269
|
+
*/
|
|
1270
|
+
clearContent: (emitUpdate?: boolean) => ReturnType;
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
declare module '@tiptap/core' {
|
|
1276
|
+
interface Commands<ReturnType> {
|
|
1277
|
+
clearNodes: {
|
|
1278
|
+
/**
|
|
1279
|
+
* Normalize nodes to a simple paragraph.
|
|
1280
|
+
*/
|
|
1281
|
+
clearNodes: () => ReturnType;
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
declare module '@tiptap/core' {
|
|
1287
|
+
interface Commands<ReturnType> {
|
|
1288
|
+
command: {
|
|
1289
|
+
/**
|
|
1290
|
+
* Define a command inline.
|
|
1291
|
+
*/
|
|
1292
|
+
command: (fn: (props: Parameters<Command>[0]) => boolean) => ReturnType;
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
declare module '@tiptap/core' {
|
|
1298
|
+
interface Commands<ReturnType> {
|
|
1299
|
+
createParagraphNear: {
|
|
1300
|
+
/**
|
|
1301
|
+
* Create a paragraph nearby.
|
|
1302
|
+
*/
|
|
1303
|
+
createParagraphNear: () => ReturnType;
|
|
1304
|
+
};
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
declare module '@tiptap/core' {
|
|
1309
|
+
interface Commands<ReturnType> {
|
|
1310
|
+
deleteCurrentNode: {
|
|
1311
|
+
/**
|
|
1312
|
+
* Delete the node that currently has the selection anchor.
|
|
1313
|
+
*/
|
|
1314
|
+
deleteCurrentNode: () => ReturnType;
|
|
1315
|
+
};
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
declare module '@tiptap/core' {
|
|
1320
|
+
interface Commands<ReturnType> {
|
|
1321
|
+
deleteNode: {
|
|
1322
|
+
/**
|
|
1323
|
+
* Delete a node.
|
|
1324
|
+
*/
|
|
1325
|
+
deleteNode: (typeOrName: string | NodeType) => ReturnType;
|
|
1326
|
+
};
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
declare module '@tiptap/core' {
|
|
1331
|
+
interface Commands<ReturnType> {
|
|
1332
|
+
deleteRange: {
|
|
1333
|
+
/**
|
|
1334
|
+
* Delete a given range.
|
|
1335
|
+
*/
|
|
1336
|
+
deleteRange: (range: Range) => ReturnType;
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
declare module '@tiptap/core' {
|
|
1342
|
+
interface Commands<ReturnType> {
|
|
1343
|
+
deleteSelection: {
|
|
1344
|
+
/**
|
|
1345
|
+
* Delete the selection, if there is one.
|
|
1346
|
+
*/
|
|
1347
|
+
deleteSelection: () => ReturnType;
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
declare module '@tiptap/core' {
|
|
1353
|
+
interface Commands<ReturnType> {
|
|
1354
|
+
enter: {
|
|
1355
|
+
/**
|
|
1356
|
+
* Trigger enter.
|
|
1357
|
+
*/
|
|
1358
|
+
enter: () => ReturnType;
|
|
1359
|
+
};
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
declare module '@tiptap/core' {
|
|
1364
|
+
interface Commands<ReturnType> {
|
|
1365
|
+
exitCode: {
|
|
1366
|
+
/**
|
|
1367
|
+
* Exit from a code block.
|
|
1368
|
+
*/
|
|
1369
|
+
exitCode: () => ReturnType;
|
|
1370
|
+
};
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
declare module '@tiptap/core' {
|
|
1375
|
+
interface Commands<ReturnType> {
|
|
1376
|
+
extendMarkRange: {
|
|
1377
|
+
/**
|
|
1378
|
+
* Extends the text selection to the current mark.
|
|
1379
|
+
*/
|
|
1380
|
+
extendMarkRange: (typeOrName: string | MarkType, attributes?: Record<string, any>) => ReturnType;
|
|
1381
|
+
};
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
declare module '@tiptap/core' {
|
|
1386
|
+
interface Commands<ReturnType> {
|
|
1387
|
+
first: {
|
|
1388
|
+
/**
|
|
1389
|
+
* Runs one command after the other and stops at the first which returns true.
|
|
1390
|
+
*/
|
|
1391
|
+
first: (commands: Command[] | ((props: CommandProps) => Command[])) => ReturnType;
|
|
1392
|
+
};
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
declare module '@tiptap/core' {
|
|
1397
|
+
interface Commands<ReturnType> {
|
|
1398
|
+
focus: {
|
|
1399
|
+
/**
|
|
1400
|
+
* Focus the editor at the given position.
|
|
1401
|
+
*/
|
|
1402
|
+
focus: (position?: FocusPosition, options?: {
|
|
1403
|
+
scrollIntoView?: boolean;
|
|
1404
|
+
}) => ReturnType;
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
declare module '@tiptap/core' {
|
|
1410
|
+
interface Commands<ReturnType> {
|
|
1411
|
+
forEach: {
|
|
1412
|
+
/**
|
|
1413
|
+
* Loop through an array of items.
|
|
1414
|
+
*/
|
|
1415
|
+
forEach: <T>(items: T[], fn: (item: T, props: CommandProps & {
|
|
1416
|
+
index: number;
|
|
1417
|
+
}) => boolean) => ReturnType;
|
|
1418
|
+
};
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
declare module '@tiptap/core' {
|
|
1423
|
+
interface Commands<ReturnType> {
|
|
1424
|
+
insertContent: {
|
|
1425
|
+
/**
|
|
1426
|
+
* Insert a node or string of HTML at the current position.
|
|
1427
|
+
*/
|
|
1428
|
+
insertContent: (value: Content, options?: {
|
|
1429
|
+
parseOptions?: ParseOptions;
|
|
1430
|
+
updateSelection?: boolean;
|
|
1431
|
+
}) => ReturnType;
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
declare module '@tiptap/core' {
|
|
1437
|
+
interface Commands<ReturnType> {
|
|
1438
|
+
insertContentAt: {
|
|
1439
|
+
/**
|
|
1440
|
+
* Insert a node or string of HTML at a specific position.
|
|
1441
|
+
*/
|
|
1442
|
+
insertContentAt: (position: number | Range, value: Content, options?: {
|
|
1443
|
+
parseOptions?: ParseOptions;
|
|
1444
|
+
updateSelection?: boolean;
|
|
1445
|
+
}) => ReturnType;
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
declare module '@tiptap/core' {
|
|
1451
|
+
interface Commands<ReturnType> {
|
|
1452
|
+
joinUp: {
|
|
1453
|
+
/**
|
|
1454
|
+
* Join two nodes Up.
|
|
1455
|
+
*/
|
|
1456
|
+
joinUp: () => ReturnType;
|
|
1457
|
+
};
|
|
1458
|
+
joinDown: {
|
|
1459
|
+
/**
|
|
1460
|
+
* Join two nodes Down.
|
|
1461
|
+
*/
|
|
1462
|
+
joinDown: () => ReturnType;
|
|
1463
|
+
};
|
|
1464
|
+
joinBackward: {
|
|
1465
|
+
/**
|
|
1466
|
+
* Join two nodes Backwards.
|
|
1467
|
+
*/
|
|
1468
|
+
joinBackward: () => ReturnType;
|
|
1469
|
+
};
|
|
1470
|
+
joinForward: {
|
|
1471
|
+
/**
|
|
1472
|
+
* Join two nodes Forwards.
|
|
1473
|
+
*/
|
|
1474
|
+
joinForward: () => ReturnType;
|
|
1475
|
+
};
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
declare module '@tiptap/core' {
|
|
1480
|
+
interface Commands<ReturnType> {
|
|
1481
|
+
keyboardShortcut: {
|
|
1482
|
+
/**
|
|
1483
|
+
* Trigger a keyboard shortcut.
|
|
1484
|
+
*/
|
|
1485
|
+
keyboardShortcut: (name: string) => ReturnType;
|
|
1486
|
+
};
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
declare module '@tiptap/core' {
|
|
1491
|
+
interface Commands<ReturnType> {
|
|
1492
|
+
lift: {
|
|
1493
|
+
/**
|
|
1494
|
+
* Removes an existing wrap.
|
|
1495
|
+
*/
|
|
1496
|
+
lift: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType;
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
declare module '@tiptap/core' {
|
|
1502
|
+
interface Commands<ReturnType> {
|
|
1503
|
+
liftEmptyBlock: {
|
|
1504
|
+
/**
|
|
1505
|
+
* Lift block if empty.
|
|
1506
|
+
*/
|
|
1507
|
+
liftEmptyBlock: () => ReturnType;
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
declare module '@tiptap/core' {
|
|
1513
|
+
interface Commands<ReturnType> {
|
|
1514
|
+
liftListItem: {
|
|
1515
|
+
/**
|
|
1516
|
+
* Lift the list item into a wrapping list.
|
|
1517
|
+
*/
|
|
1518
|
+
liftListItem: (typeOrName: string | NodeType) => ReturnType;
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
declare module '@tiptap/core' {
|
|
1524
|
+
interface Commands<ReturnType> {
|
|
1525
|
+
newlineInCode: {
|
|
1526
|
+
/**
|
|
1527
|
+
* Add a newline character in code.
|
|
1528
|
+
*/
|
|
1529
|
+
newlineInCode: () => ReturnType;
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
declare module '@tiptap/core' {
|
|
1535
|
+
interface Commands<ReturnType> {
|
|
1536
|
+
resetAttributes: {
|
|
1537
|
+
/**
|
|
1538
|
+
* Resets some node attributes to the default value.
|
|
1539
|
+
*/
|
|
1540
|
+
resetAttributes: (typeOrName: string | NodeType | MarkType, attributes: string | string[]) => ReturnType;
|
|
1541
|
+
};
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
declare module '@tiptap/core' {
|
|
1546
|
+
interface Commands<ReturnType> {
|
|
1547
|
+
scrollIntoView: {
|
|
1548
|
+
/**
|
|
1549
|
+
* Scroll the selection into view.
|
|
1550
|
+
*/
|
|
1551
|
+
scrollIntoView: () => ReturnType;
|
|
1552
|
+
};
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
declare module '@tiptap/core' {
|
|
1557
|
+
interface Commands<ReturnType> {
|
|
1558
|
+
selectAll: {
|
|
1559
|
+
/**
|
|
1560
|
+
* Select the whole document.
|
|
1561
|
+
*/
|
|
1562
|
+
selectAll: () => ReturnType;
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
declare module '@tiptap/core' {
|
|
1568
|
+
interface Commands<ReturnType> {
|
|
1569
|
+
selectNodeBackward: {
|
|
1570
|
+
/**
|
|
1571
|
+
* Select a node backward.
|
|
1572
|
+
*/
|
|
1573
|
+
selectNodeBackward: () => ReturnType;
|
|
1574
|
+
};
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
declare module '@tiptap/core' {
|
|
1579
|
+
interface Commands<ReturnType> {
|
|
1580
|
+
selectNodeForward: {
|
|
1581
|
+
/**
|
|
1582
|
+
* Select a node forward.
|
|
1583
|
+
*/
|
|
1584
|
+
selectNodeForward: () => ReturnType;
|
|
1585
|
+
};
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
declare module '@tiptap/core' {
|
|
1590
|
+
interface Commands<ReturnType> {
|
|
1591
|
+
selectParentNode: {
|
|
1592
|
+
/**
|
|
1593
|
+
* Select the parent node.
|
|
1594
|
+
*/
|
|
1595
|
+
selectParentNode: () => ReturnType;
|
|
1596
|
+
};
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
declare module '@tiptap/core' {
|
|
1601
|
+
interface Commands<ReturnType> {
|
|
1602
|
+
selectTextblockEnd: {
|
|
1603
|
+
/**
|
|
1604
|
+
* Moves the cursor to the end of current text block.
|
|
1605
|
+
*/
|
|
1606
|
+
selectTextblockEnd: () => ReturnType;
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
declare module '@tiptap/core' {
|
|
1612
|
+
interface Commands<ReturnType> {
|
|
1613
|
+
selectTextblockStart: {
|
|
1614
|
+
/**
|
|
1615
|
+
* Moves the cursor to the start of current text block.
|
|
1616
|
+
*/
|
|
1617
|
+
selectTextblockStart: () => ReturnType;
|
|
1618
|
+
};
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
declare module '@tiptap/core' {
|
|
1623
|
+
interface Commands<ReturnType> {
|
|
1624
|
+
setContent: {
|
|
1625
|
+
/**
|
|
1626
|
+
* Replace the whole document with new content.
|
|
1627
|
+
*/
|
|
1628
|
+
setContent: (content: Content, emitUpdate?: boolean, parseOptions?: ParseOptions) => ReturnType;
|
|
1629
|
+
};
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
declare module '@tiptap/core' {
|
|
1634
|
+
interface Commands<ReturnType> {
|
|
1635
|
+
setMark: {
|
|
1636
|
+
/**
|
|
1637
|
+
* Add a mark with new attributes.
|
|
1638
|
+
*/
|
|
1639
|
+
setMark: (typeOrName: string | MarkType, attributes?: Record<string, any>) => ReturnType;
|
|
1640
|
+
};
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
declare module '@tiptap/core' {
|
|
1645
|
+
interface Commands<ReturnType> {
|
|
1646
|
+
setMeta: {
|
|
1647
|
+
/**
|
|
1648
|
+
* Store a metadata property in the current transaction.
|
|
1649
|
+
*/
|
|
1650
|
+
setMeta: (key: string, value: any) => ReturnType;
|
|
1651
|
+
};
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
declare module '@tiptap/core' {
|
|
1656
|
+
interface Commands<ReturnType> {
|
|
1657
|
+
setNode: {
|
|
1658
|
+
/**
|
|
1659
|
+
* Replace a given range with a node.
|
|
1660
|
+
*/
|
|
1661
|
+
setNode: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType;
|
|
1662
|
+
};
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
declare module '@tiptap/core' {
|
|
1667
|
+
interface Commands<ReturnType> {
|
|
1668
|
+
setNodeSelection: {
|
|
1669
|
+
/**
|
|
1670
|
+
* Creates a NodeSelection.
|
|
1671
|
+
*/
|
|
1672
|
+
setNodeSelection: (position: number) => ReturnType;
|
|
1673
|
+
};
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
declare module '@tiptap/core' {
|
|
1678
|
+
interface Commands<ReturnType> {
|
|
1679
|
+
setTextSelection: {
|
|
1680
|
+
/**
|
|
1681
|
+
* Creates a TextSelection.
|
|
1682
|
+
*/
|
|
1683
|
+
setTextSelection: (position: number | Range) => ReturnType;
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
declare module '@tiptap/core' {
|
|
1689
|
+
interface Commands<ReturnType> {
|
|
1690
|
+
sinkListItem: {
|
|
1691
|
+
/**
|
|
1692
|
+
* Sink the list item down into an inner list.
|
|
1693
|
+
*/
|
|
1694
|
+
sinkListItem: (typeOrName: string | NodeType) => ReturnType;
|
|
1695
|
+
};
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
declare module '@tiptap/core' {
|
|
1700
|
+
interface Commands<ReturnType> {
|
|
1701
|
+
splitBlock: {
|
|
1702
|
+
/**
|
|
1703
|
+
* Forks a new node from an existing node.
|
|
1704
|
+
*/
|
|
1705
|
+
splitBlock: (options?: {
|
|
1706
|
+
keepMarks?: boolean;
|
|
1707
|
+
}) => ReturnType;
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
declare module '@tiptap/core' {
|
|
1713
|
+
interface Commands<ReturnType> {
|
|
1714
|
+
splitListItem: {
|
|
1715
|
+
/**
|
|
1716
|
+
* Splits one list item into two list items.
|
|
1717
|
+
*/
|
|
1718
|
+
splitListItem: (typeOrName: string | NodeType) => ReturnType;
|
|
1719
|
+
};
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
declare module '@tiptap/core' {
|
|
1724
|
+
interface Commands<ReturnType> {
|
|
1725
|
+
toggleList: {
|
|
1726
|
+
/**
|
|
1727
|
+
* Toggle between different list types.
|
|
1728
|
+
*/
|
|
1729
|
+
toggleList: (listTypeOrName: string | NodeType, itemTypeOrName: string | NodeType) => ReturnType;
|
|
1730
|
+
};
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
declare module '@tiptap/core' {
|
|
1735
|
+
interface Commands<ReturnType> {
|
|
1736
|
+
toggleMark: {
|
|
1737
|
+
/**
|
|
1738
|
+
* Toggle a mark on and off.
|
|
1739
|
+
*/
|
|
1740
|
+
toggleMark: (typeOrName: string | MarkType, attributes?: Record<string, any>, options?: {
|
|
1741
|
+
/**
|
|
1742
|
+
* Removes the mark even across the current selection. Defaults to `false`.
|
|
1743
|
+
*/
|
|
1744
|
+
extendEmptyMarkRange?: boolean;
|
|
1745
|
+
}) => ReturnType;
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
declare module '@tiptap/core' {
|
|
1751
|
+
interface Commands<ReturnType> {
|
|
1752
|
+
toggleNode: {
|
|
1753
|
+
/**
|
|
1754
|
+
* Toggle a node with another node.
|
|
1755
|
+
*/
|
|
1756
|
+
toggleNode: (typeOrName: string | NodeType, toggleTypeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType;
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
declare module '@tiptap/core' {
|
|
1762
|
+
interface Commands<ReturnType> {
|
|
1763
|
+
toggleWrap: {
|
|
1764
|
+
/**
|
|
1765
|
+
* Wraps nodes in another node, or removes an existing wrap.
|
|
1766
|
+
*/
|
|
1767
|
+
toggleWrap: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType;
|
|
1768
|
+
};
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
declare module '@tiptap/core' {
|
|
1773
|
+
interface Commands<ReturnType> {
|
|
1774
|
+
undoInputRule: {
|
|
1775
|
+
/**
|
|
1776
|
+
* Undo an input rule.
|
|
1777
|
+
*/
|
|
1778
|
+
undoInputRule: () => ReturnType;
|
|
1779
|
+
};
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
declare module '@tiptap/core' {
|
|
1784
|
+
interface Commands<ReturnType> {
|
|
1785
|
+
unsetAllMarks: {
|
|
1786
|
+
/**
|
|
1787
|
+
* Remove all marks in the current selection.
|
|
1788
|
+
*/
|
|
1789
|
+
unsetAllMarks: () => ReturnType;
|
|
1790
|
+
};
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
declare module '@tiptap/core' {
|
|
1795
|
+
interface Commands<ReturnType> {
|
|
1796
|
+
unsetMark: {
|
|
1797
|
+
/**
|
|
1798
|
+
* Remove all marks in the current selection.
|
|
1799
|
+
*/
|
|
1800
|
+
unsetMark: (typeOrName: string | MarkType, options?: {
|
|
1801
|
+
/**
|
|
1802
|
+
* Removes the mark even across the current selection. Defaults to `false`.
|
|
1803
|
+
*/
|
|
1804
|
+
extendEmptyMarkRange?: boolean;
|
|
1805
|
+
}) => ReturnType;
|
|
1806
|
+
};
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
declare module '@tiptap/core' {
|
|
1811
|
+
interface Commands<ReturnType> {
|
|
1812
|
+
updateAttributes: {
|
|
1813
|
+
/**
|
|
1814
|
+
* Update attributes of a node or mark.
|
|
1815
|
+
*/
|
|
1816
|
+
updateAttributes: (typeOrName: string | NodeType | MarkType, attributes: Record<string, any>) => ReturnType;
|
|
1817
|
+
};
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
declare module '@tiptap/core' {
|
|
1822
|
+
interface Commands<ReturnType> {
|
|
1823
|
+
wrapIn: {
|
|
1824
|
+
/**
|
|
1825
|
+
* Wraps nodes in another node.
|
|
1826
|
+
*/
|
|
1827
|
+
wrapIn: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType;
|
|
1828
|
+
};
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
declare module '@tiptap/core' {
|
|
1833
|
+
interface Commands<ReturnType> {
|
|
1834
|
+
wrapInList: {
|
|
1835
|
+
/**
|
|
1836
|
+
* Wrap a node in a list.
|
|
1837
|
+
*/
|
|
1838
|
+
wrapInList: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType;
|
|
1839
|
+
};
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
declare const Commands$1: Extension<any, any>;
|
|
1844
|
+
|
|
1845
|
+
declare const Editable: Extension<any, any>;
|
|
1846
|
+
|
|
1847
|
+
declare const FocusEvents: Extension<any, any>;
|
|
1848
|
+
|
|
1849
|
+
declare const Keymap: Extension<any, any>;
|
|
1850
|
+
|
|
1851
|
+
declare const Tabindex: Extension<any, any>;
|
|
1852
|
+
|
|
1853
|
+
declare const index_ClipboardTextSerializer: typeof ClipboardTextSerializer;
|
|
1854
|
+
declare const index_Editable: typeof Editable;
|
|
1855
|
+
declare const index_FocusEvents: typeof FocusEvents;
|
|
1856
|
+
declare const index_Keymap: typeof Keymap;
|
|
1857
|
+
declare const index_Tabindex: typeof Tabindex;
|
|
1858
|
+
declare namespace index {
|
|
1859
|
+
export {
|
|
1860
|
+
index_ClipboardTextSerializer as ClipboardTextSerializer,
|
|
1861
|
+
Commands$1 as Commands,
|
|
1862
|
+
index_Editable as Editable,
|
|
1863
|
+
index_FocusEvents as FocusEvents,
|
|
1864
|
+
index_Keymap as Keymap,
|
|
1865
|
+
index_Tabindex as Tabindex,
|
|
1866
|
+
};
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
interface HTMLElement$1 {
|
|
1870
|
+
editor?: Editor;
|
|
1871
|
+
}
|
|
1872
|
+
declare class Editor extends EventEmitter<EditorEvents> {
|
|
1873
|
+
private commandManager;
|
|
1874
|
+
extensionManager: ExtensionManager;
|
|
1875
|
+
private css;
|
|
1876
|
+
schema: Schema;
|
|
1877
|
+
view: EditorView;
|
|
1878
|
+
isFocused: boolean;
|
|
1879
|
+
extensionStorage: Record<string, any>;
|
|
1880
|
+
options: EditorOptions;
|
|
1881
|
+
constructor(options?: Partial<EditorOptions>);
|
|
1882
|
+
/**
|
|
1883
|
+
* Returns the editor storage.
|
|
1884
|
+
*/
|
|
1885
|
+
get storage(): Record<string, any>;
|
|
1886
|
+
/**
|
|
1887
|
+
* An object of all registered commands.
|
|
1888
|
+
*/
|
|
1889
|
+
get commands(): SingleCommands;
|
|
1890
|
+
/**
|
|
1891
|
+
* Create a command chain to call multiple commands at once.
|
|
1892
|
+
*/
|
|
1893
|
+
chain(): ChainedCommands;
|
|
1894
|
+
/**
|
|
1895
|
+
* Check if a command or a command chain can be executed. Without executing it.
|
|
1896
|
+
*/
|
|
1897
|
+
can(): CanCommands;
|
|
1898
|
+
/**
|
|
1899
|
+
* Inject CSS styles.
|
|
1900
|
+
*/
|
|
1901
|
+
private injectCSS;
|
|
1902
|
+
/**
|
|
1903
|
+
* Update editor options.
|
|
1904
|
+
*
|
|
1905
|
+
* @param options A list of options
|
|
1906
|
+
*/
|
|
1907
|
+
setOptions(options?: Partial<EditorOptions>): void;
|
|
1908
|
+
/**
|
|
1909
|
+
* Update editable state of the editor.
|
|
1910
|
+
*/
|
|
1911
|
+
setEditable(editable: boolean, emitUpdate?: boolean): void;
|
|
1912
|
+
/**
|
|
1913
|
+
* Returns whether the editor is editable.
|
|
1914
|
+
*/
|
|
1915
|
+
get isEditable(): boolean;
|
|
1916
|
+
/**
|
|
1917
|
+
* Returns the editor state.
|
|
1918
|
+
*/
|
|
1919
|
+
get state(): EditorState;
|
|
1920
|
+
/**
|
|
1921
|
+
* Register a ProseMirror plugin.
|
|
1922
|
+
*
|
|
1923
|
+
* @param plugin A ProseMirror plugin
|
|
1924
|
+
* @param handlePlugins Control how to merge the plugin into the existing plugins.
|
|
1925
|
+
*/
|
|
1926
|
+
registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): void;
|
|
1927
|
+
/**
|
|
1928
|
+
* Unregister a ProseMirror plugin.
|
|
1929
|
+
*
|
|
1930
|
+
* @param nameOrPluginKey The plugins name
|
|
1931
|
+
*/
|
|
1932
|
+
unregisterPlugin(nameOrPluginKey: string | PluginKey): void;
|
|
1933
|
+
/**
|
|
1934
|
+
* Creates an extension manager.
|
|
1935
|
+
*/
|
|
1936
|
+
private createExtensionManager;
|
|
1937
|
+
/**
|
|
1938
|
+
* Creates an command manager.
|
|
1939
|
+
*/
|
|
1940
|
+
private createCommandManager;
|
|
1941
|
+
/**
|
|
1942
|
+
* Creates a ProseMirror schema.
|
|
1943
|
+
*/
|
|
1944
|
+
private createSchema;
|
|
1945
|
+
/**
|
|
1946
|
+
* Creates a ProseMirror view.
|
|
1947
|
+
*/
|
|
1948
|
+
private createView;
|
|
1949
|
+
/**
|
|
1950
|
+
* Creates all node views.
|
|
1951
|
+
*/
|
|
1952
|
+
createNodeViews(): void;
|
|
1953
|
+
isCapturingTransaction: boolean;
|
|
1954
|
+
private capturedTransaction;
|
|
1955
|
+
captureTransaction(fn: Function): Transaction | null;
|
|
1956
|
+
/**
|
|
1957
|
+
* The callback over which to send transactions (state updates) produced by the view.
|
|
1958
|
+
*
|
|
1959
|
+
* @param transaction An editor state transaction
|
|
1960
|
+
*/
|
|
1961
|
+
private dispatchTransaction;
|
|
1962
|
+
/**
|
|
1963
|
+
* Get attributes of the currently selected node or mark.
|
|
1964
|
+
*/
|
|
1965
|
+
getAttributes(nameOrType: string | NodeType | MarkType): Record<string, any>;
|
|
1966
|
+
/**
|
|
1967
|
+
* Returns if the currently selected node or mark is active.
|
|
1968
|
+
*
|
|
1969
|
+
* @param name Name of the node or mark
|
|
1970
|
+
* @param attributes Attributes of the node or mark
|
|
1971
|
+
*/
|
|
1972
|
+
isActive(name: string, attributes?: {}): boolean;
|
|
1973
|
+
isActive(attributes: {}): boolean;
|
|
1974
|
+
/**
|
|
1975
|
+
* Get the document as JSON.
|
|
1976
|
+
*/
|
|
1977
|
+
getJSON(): JSONContent;
|
|
1978
|
+
/**
|
|
1979
|
+
* Get the document as HTML.
|
|
1980
|
+
*/
|
|
1981
|
+
getHTML(): string;
|
|
1982
|
+
/**
|
|
1983
|
+
* Get the document as text.
|
|
1984
|
+
*/
|
|
1985
|
+
getText(options?: {
|
|
1986
|
+
blockSeparator?: string;
|
|
1987
|
+
textSerializers?: Record<string, TextSerializer>;
|
|
1988
|
+
}): string;
|
|
1989
|
+
/**
|
|
1990
|
+
* Check if there is no content.
|
|
1991
|
+
*/
|
|
1992
|
+
get isEmpty(): boolean;
|
|
1993
|
+
/**
|
|
1994
|
+
* Get the number of characters for the current document.
|
|
1995
|
+
*
|
|
1996
|
+
* @deprecated
|
|
1997
|
+
*/
|
|
1998
|
+
getCharacterCount(): number;
|
|
1999
|
+
/**
|
|
2000
|
+
* Destroy the editor.
|
|
2001
|
+
*/
|
|
2002
|
+
destroy(): void;
|
|
2003
|
+
/**
|
|
2004
|
+
* Check if the editor is already destroyed.
|
|
2005
|
+
*/
|
|
2006
|
+
get isDestroyed(): boolean;
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
declare class CommandManager {
|
|
2010
|
+
editor: Editor;
|
|
2011
|
+
rawCommands: AnyCommands;
|
|
2012
|
+
customState?: EditorState;
|
|
2013
|
+
constructor(props: {
|
|
2014
|
+
editor: Editor;
|
|
2015
|
+
state?: EditorState;
|
|
2016
|
+
});
|
|
2017
|
+
get hasCustomState(): boolean;
|
|
2018
|
+
get state(): EditorState;
|
|
2019
|
+
get commands(): SingleCommands;
|
|
2020
|
+
get chain(): () => ChainedCommands;
|
|
2021
|
+
get can(): () => CanCommands;
|
|
2022
|
+
createChain(startTr?: Transaction, shouldDispatch?: boolean): ChainedCommands;
|
|
2023
|
+
createCan(startTr?: Transaction): CanCommands;
|
|
2024
|
+
buildProps(tr: Transaction, shouldDispatch?: boolean): CommandProps;
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
/**
|
|
2028
|
+
* Returns a new `Transform` based on all steps of the passed transactions.
|
|
2029
|
+
*/
|
|
2030
|
+
declare function combineTransactionSteps(oldDoc: Node$1, transactions: Transaction[]): Transform;
|
|
2031
|
+
|
|
2032
|
+
declare function defaultBlockAt(match: ContentMatch): NodeType | null;
|
|
2033
|
+
|
|
2034
|
+
declare function findChildren(node: Node$1, predicate: Predicate): NodeWithPos[];
|
|
2035
|
+
|
|
2036
|
+
/**
|
|
2037
|
+
* Same as `findChildren` but searches only within a `range`.
|
|
2038
|
+
*/
|
|
2039
|
+
declare function findChildrenInRange(node: Node$1, range: Range, predicate: Predicate): NodeWithPos[];
|
|
2040
|
+
|
|
2041
|
+
declare function findParentNode(predicate: Predicate): (selection: Selection) => {
|
|
2042
|
+
pos: number;
|
|
2043
|
+
start: number;
|
|
2044
|
+
depth: number;
|
|
2045
|
+
node: prosemirror_model.Node;
|
|
2046
|
+
} | undefined;
|
|
2047
|
+
|
|
2048
|
+
declare function findParentNodeClosestToPos($pos: ResolvedPos, predicate: Predicate): {
|
|
2049
|
+
pos: number;
|
|
2050
|
+
start: number;
|
|
2051
|
+
depth: number;
|
|
2052
|
+
node: Node$1;
|
|
2053
|
+
} | undefined;
|
|
2054
|
+
|
|
2055
|
+
declare function generateHTML(doc: JSONContent, extensions: Extensions): string;
|
|
2056
|
+
|
|
2057
|
+
declare function generateJSON(html: string, extensions: Extensions): Record<string, any>;
|
|
2058
|
+
|
|
2059
|
+
declare function generateText(doc: JSONContent, extensions: Extensions, options?: {
|
|
2060
|
+
blockSeparator?: string;
|
|
2061
|
+
textSerializers?: Record<string, TextSerializer>;
|
|
2062
|
+
}): string;
|
|
2063
|
+
|
|
2064
|
+
declare function getAttributes(state: EditorState, typeOrName: string | NodeType | MarkType): Record<string, any>;
|
|
2065
|
+
|
|
2066
|
+
declare type ChangedRange = {
|
|
2067
|
+
oldRange: Range;
|
|
2068
|
+
newRange: Range;
|
|
2069
|
+
};
|
|
2070
|
+
/**
|
|
2071
|
+
* Returns a list of changed ranges
|
|
2072
|
+
* based on the first and last state of all steps.
|
|
2073
|
+
*/
|
|
2074
|
+
declare function getChangedRanges(transform: Transform): ChangedRange[];
|
|
2075
|
+
|
|
2076
|
+
interface DebugJSONContent extends JSONContent {
|
|
2077
|
+
from: number;
|
|
2078
|
+
to: number;
|
|
2079
|
+
}
|
|
2080
|
+
declare function getDebugJSON(node: Node$1, startOffset?: number): DebugJSONContent;
|
|
2081
|
+
|
|
2082
|
+
declare function getExtensionField<T = any>(extension: AnyExtension, field: string, context?: Omit<MaybeThisParameterType<T>, 'parent'>): RemoveThis<T>;
|
|
2083
|
+
|
|
2084
|
+
declare function getHTMLFromFragment(fragment: Fragment, schema: Schema): string;
|
|
2085
|
+
|
|
2086
|
+
declare function getMarkAttributes(state: EditorState, typeOrName: string | MarkType): Record<string, any>;
|
|
2087
|
+
|
|
2088
|
+
declare function getMarkRange($pos: ResolvedPos, type: MarkType, attributes?: Record<string, any>): Range | void;
|
|
2089
|
+
|
|
2090
|
+
declare function getMarksBetween(from: number, to: number, doc: Node$1): MarkRange[];
|
|
2091
|
+
|
|
2092
|
+
declare function getMarkType(nameOrType: string | MarkType, schema: Schema): MarkType;
|
|
2093
|
+
|
|
2094
|
+
declare function getNodeAttributes(state: EditorState, typeOrName: string | NodeType): Record<string, any>;
|
|
2095
|
+
|
|
2096
|
+
declare function getNodeType(nameOrType: string | NodeType, schema: Schema): NodeType;
|
|
2097
|
+
|
|
2098
|
+
declare function getSchema(extensions: Extensions): Schema;
|
|
2099
|
+
|
|
2100
|
+
declare function getText(node: Node$1, options?: {
|
|
2101
|
+
blockSeparator?: string;
|
|
2102
|
+
textSerializers?: Record<string, TextSerializer>;
|
|
2103
|
+
}): string;
|
|
2104
|
+
|
|
2105
|
+
declare function getTextBetween(startNode: Node$1, range: Range, options?: {
|
|
2106
|
+
blockSeparator?: string;
|
|
2107
|
+
textSerializers?: Record<string, TextSerializer>;
|
|
2108
|
+
}): string;
|
|
2109
|
+
|
|
2110
|
+
declare const getTextContentFromNodes: ($from: ResolvedPos, maxMatch?: number) => string;
|
|
2111
|
+
|
|
2112
|
+
declare function getTextSerializersFromSchema(schema: Schema): Record<string, TextSerializer>;
|
|
2113
|
+
|
|
2114
|
+
declare function isActive(state: EditorState, name: string | null, attributes?: Record<string, any>): boolean;
|
|
2115
|
+
|
|
2116
|
+
declare function isList(name: string, extensions: Extensions): boolean;
|
|
2117
|
+
|
|
2118
|
+
declare function isMarkActive(state: EditorState, typeOrName: MarkType | string | null, attributes?: Record<string, any>): boolean;
|
|
2119
|
+
|
|
2120
|
+
declare function isNodeActive(state: EditorState, typeOrName: NodeType | string | null, attributes?: Record<string, any>): boolean;
|
|
2121
|
+
|
|
2122
|
+
declare function isNodeEmpty(node: Node$1): boolean;
|
|
2123
|
+
|
|
2124
|
+
declare function isNodeSelection(value: unknown): value is NodeSelection;
|
|
2125
|
+
|
|
2126
|
+
declare function isTextSelection(value: unknown): value is TextSelection;
|
|
2127
|
+
|
|
2128
|
+
declare function posToDOMRect(view: EditorView, from: number, to: number): DOMRect;
|
|
2129
|
+
|
|
2130
|
+
/**
|
|
2131
|
+
* Build an input rule that adds a mark when the
|
|
2132
|
+
* matched text is typed into it.
|
|
2133
|
+
*/
|
|
2134
|
+
declare function markInputRule(config: {
|
|
2135
|
+
find: InputRuleFinder;
|
|
2136
|
+
type: MarkType;
|
|
2137
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
|
|
2138
|
+
}): InputRule;
|
|
2139
|
+
|
|
2140
|
+
/**
|
|
2141
|
+
* Build an input rule that adds a node when the
|
|
2142
|
+
* matched text is typed into it.
|
|
2143
|
+
*/
|
|
2144
|
+
declare function nodeInputRule(config: {
|
|
2145
|
+
find: InputRuleFinder;
|
|
2146
|
+
type: NodeType;
|
|
2147
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
|
|
2148
|
+
}): InputRule;
|
|
2149
|
+
|
|
2150
|
+
/**
|
|
2151
|
+
* Build an input rule that changes the type of a textblock when the
|
|
2152
|
+
* matched text is typed into it. When using a regular expresion you’ll
|
|
2153
|
+
* probably want the regexp to start with `^`, so that the pattern can
|
|
2154
|
+
* only occur at the start of a textblock.
|
|
2155
|
+
*/
|
|
2156
|
+
declare function textblockTypeInputRule(config: {
|
|
2157
|
+
find: InputRuleFinder;
|
|
2158
|
+
type: NodeType;
|
|
2159
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
|
|
2160
|
+
}): InputRule;
|
|
2161
|
+
|
|
2162
|
+
/**
|
|
2163
|
+
* Build an input rule that replaces text when the
|
|
2164
|
+
* matched text is typed into it.
|
|
2165
|
+
*/
|
|
2166
|
+
declare function textInputRule(config: {
|
|
2167
|
+
find: InputRuleFinder;
|
|
2168
|
+
replace: string;
|
|
2169
|
+
}): InputRule;
|
|
2170
|
+
|
|
2171
|
+
/**
|
|
2172
|
+
* Build an input rule for automatically wrapping a textblock when a
|
|
2173
|
+
* given string is typed. When using a regular expresion you’ll
|
|
2174
|
+
* probably want the regexp to start with `^`, so that the pattern can
|
|
2175
|
+
* only occur at the start of a textblock.
|
|
2176
|
+
*
|
|
2177
|
+
* `type` is the type of node to wrap in.
|
|
2178
|
+
*
|
|
2179
|
+
* By default, if there’s a node with the same type above the newly
|
|
2180
|
+
* wrapped node, the rule will try to join those
|
|
2181
|
+
* two nodes. You can pass a join predicate, which takes a regular
|
|
2182
|
+
* expression match and the node before the wrapped node, and can
|
|
2183
|
+
* return a boolean to indicate whether a join should happen.
|
|
2184
|
+
*/
|
|
2185
|
+
declare function wrappingInputRule(config: {
|
|
2186
|
+
find: InputRuleFinder;
|
|
2187
|
+
type: NodeType;
|
|
2188
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
|
|
2189
|
+
joinPredicate?: (match: ExtendedRegExpMatchArray, node: Node$1) => boolean;
|
|
2190
|
+
}): InputRule;
|
|
2191
|
+
|
|
2192
|
+
declare class NodeView<Component, Editor extends Editor = Editor, Options extends NodeViewRendererOptions = NodeViewRendererOptions> implements NodeView$1 {
|
|
2193
|
+
component: Component;
|
|
2194
|
+
editor: Editor;
|
|
2195
|
+
options: Options;
|
|
2196
|
+
extension: Node;
|
|
2197
|
+
node: Node$1;
|
|
2198
|
+
decorations: Decoration[];
|
|
2199
|
+
getPos: any;
|
|
2200
|
+
isDragging: boolean;
|
|
2201
|
+
constructor(component: Component, props: NodeViewRendererProps, options?: Partial<Options>);
|
|
2202
|
+
mount(): void;
|
|
2203
|
+
get dom(): HTMLElement;
|
|
2204
|
+
get contentDOM(): HTMLElement | null;
|
|
2205
|
+
onDragStart(event: DragEvent): void;
|
|
2206
|
+
stopEvent(event: Event): boolean;
|
|
2207
|
+
ignoreMutation(mutation: MutationRecord | {
|
|
2208
|
+
type: 'selection';
|
|
2209
|
+
target: Element;
|
|
2210
|
+
}): boolean;
|
|
2211
|
+
updateAttributes(attributes: {}): void;
|
|
2212
|
+
deleteNode(): void;
|
|
2213
|
+
}
|
|
2214
|
+
|
|
2215
|
+
/**
|
|
2216
|
+
* Build an paste rule that adds a mark when the
|
|
2217
|
+
* matched text is pasted into it.
|
|
2218
|
+
*/
|
|
2219
|
+
declare function markPasteRule(config: {
|
|
2220
|
+
find: PasteRuleFinder;
|
|
2221
|
+
type: MarkType;
|
|
2222
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
|
|
2223
|
+
}): PasteRule;
|
|
2224
|
+
|
|
2225
|
+
/**
|
|
2226
|
+
* Build an paste rule that adds a node when the
|
|
2227
|
+
* matched text is pasted into it.
|
|
2228
|
+
*/
|
|
2229
|
+
declare function nodePasteRule(config: {
|
|
2230
|
+
find: RegExp;
|
|
2231
|
+
type: NodeType;
|
|
2232
|
+
getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null;
|
|
2233
|
+
}): PasteRule;
|
|
2234
|
+
|
|
2235
|
+
/**
|
|
2236
|
+
* Build an paste rule that replaces text when the
|
|
2237
|
+
* matched text is pasted into it.
|
|
2238
|
+
*/
|
|
2239
|
+
declare function textPasteRule(config: {
|
|
2240
|
+
find: PasteRuleFinder;
|
|
2241
|
+
replace: string;
|
|
2242
|
+
}): PasteRule;
|
|
2243
|
+
|
|
2244
|
+
interface TrackerResult {
|
|
2245
|
+
position: number;
|
|
2246
|
+
deleted: boolean;
|
|
2247
|
+
}
|
|
2248
|
+
declare class Tracker {
|
|
2249
|
+
transaction: Transaction;
|
|
2250
|
+
currentStep: number;
|
|
2251
|
+
constructor(transaction: Transaction);
|
|
2252
|
+
map(position: number): TrackerResult;
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
/**
|
|
2256
|
+
* Optionally calls `value` as a function.
|
|
2257
|
+
* Otherwise it is returned directly.
|
|
2258
|
+
* @param value Function or any value.
|
|
2259
|
+
* @param context Optional context to bind to function.
|
|
2260
|
+
* @param props Optional props to pass to function.
|
|
2261
|
+
*/
|
|
2262
|
+
declare function callOrReturn<T>(value: T, context?: any, ...props: any[]): MaybeReturnType<T>;
|
|
2263
|
+
|
|
2264
|
+
declare function createStyleTag(style: string, nonce?: string): HTMLStyleElement;
|
|
2265
|
+
|
|
2266
|
+
/**
|
|
2267
|
+
* Remove a property or an array of properties from an object
|
|
2268
|
+
* @param obj Object
|
|
2269
|
+
* @param key Key to remove
|
|
2270
|
+
*/
|
|
2271
|
+
declare function deleteProps(obj: Record<string, any>, propOrProps: string | string[]): Record<string, any>;
|
|
2272
|
+
|
|
2273
|
+
declare function elementFromString(value: string): HTMLElement;
|
|
2274
|
+
|
|
2275
|
+
declare function escapeForRegEx(string: string): string;
|
|
2276
|
+
|
|
2277
|
+
declare function findDuplicates(items: any[]): any[];
|
|
2278
|
+
|
|
2279
|
+
declare function fromString(value: any): any;
|
|
2280
|
+
|
|
2281
|
+
declare function isEmptyObject(value?: {}): boolean;
|
|
2282
|
+
|
|
2283
|
+
declare function isFunction(value: any): value is Function;
|
|
2284
|
+
|
|
2285
|
+
declare function isiOS(): boolean;
|
|
2286
|
+
|
|
2287
|
+
declare function isMacOS(): boolean;
|
|
2288
|
+
|
|
2289
|
+
declare function isNumber(value: any): value is number;
|
|
2290
|
+
|
|
2291
|
+
declare function isPlainObject(value: any): value is Record<string, any>;
|
|
2292
|
+
|
|
2293
|
+
declare function isRegExp(value: any): value is RegExp;
|
|
2294
|
+
|
|
2295
|
+
declare function isString(value: any): value is string;
|
|
2296
|
+
|
|
2297
|
+
declare function mergeAttributes(...objects: Record<string, any>[]): Record<string, any>;
|
|
2298
|
+
|
|
2299
|
+
declare function mergeDeep(target: Record<string, any>, source: Record<string, any>): Record<string, any>;
|
|
2300
|
+
|
|
2301
|
+
declare function minMax(value?: number, min?: number, max?: number): number;
|
|
2302
|
+
|
|
2303
|
+
/**
|
|
2304
|
+
* Check if object1 includes object2
|
|
2305
|
+
* @param object1 Object
|
|
2306
|
+
* @param object2 Object
|
|
2307
|
+
*/
|
|
2308
|
+
declare function objectIncludes(object1: Record<string, any>, object2: Record<string, any>, options?: {
|
|
2309
|
+
strict: boolean;
|
|
2310
|
+
}): boolean;
|
|
2311
|
+
|
|
2312
|
+
/**
|
|
2313
|
+
* Removes duplicated values within an array.
|
|
2314
|
+
* Supports numbers, strings and objects.
|
|
2315
|
+
*/
|
|
2316
|
+
declare function removeDuplicates<T>(array: T[], by?: {
|
|
2317
|
+
(value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string;
|
|
2318
|
+
(value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string;
|
|
2319
|
+
}): T[];
|
|
2320
|
+
|
|
2321
|
+
interface Commands<ReturnType = any> {
|
|
2322
|
+
}
|
|
2323
|
+
interface ExtensionConfig<Options = any, Storage = any> {
|
|
2324
|
+
}
|
|
2325
|
+
interface NodeConfig<Options = any, Storage = any> {
|
|
2326
|
+
}
|
|
2327
|
+
interface MarkConfig<Options = any, Storage = any> {
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
export { AnyCommands, AnyConfig, AnyExtension, Attribute, Attributes, CanCommands, ChainedCommands, ChangedRange, Command, CommandManager, CommandProps, CommandSpec, Commands, Content, Diff, Dispatch, Editor, EditorEvents, EditorOptions, EnableRules, ExtendedRegExpMatchArray, Extension, ExtensionAttribute, ExtensionConfig, Extensions, FocusPosition, GlobalAttributes, HTMLContent, HTMLElement$1 as HTMLElement, InputRule, InputRuleFinder, InputRuleMatch, JSONContent, KeyboardShortcutCommand, KeysWithTypeOf, Mark, MarkConfig, MarkRange, MaybeReturnType, MaybeThisParameterType, Node, NodeConfig, NodeRange, NodeView, NodeViewProps, NodeViewRenderer, NodeViewRendererOptions, NodeViewRendererProps, NodeWithPos, Overwrite, ParentConfig, PasteRule, PasteRuleFinder, PasteRuleMatch, PickValue, Predicate, Primitive, Range, RawCommands, RemoveThis, SingleCommands, TextSerializer, Tracker, TrackerResult, UnionCommands, UnionToIntersection, ValuesOf, callOrReturn, combineTransactionSteps, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, index as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, fromString, generateHTML, generateJSON, generateText, getAttributes, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAttributes, getNodeType, getSchema, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, inputRulesPlugin, isActive, isEmptyObject, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, markInputRule, markPasteRule, mergeAttributes, mergeDeep, minMax, nodeInputRule, nodePasteRule, objectIncludes, pasteRulesPlugin, posToDOMRect, removeDuplicates, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };
|