@tiptap/core 2.0.0-beta.99 → 2.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/index.cjs +4360 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{tiptap-core.esm.js → index.js} +2349 -1447
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +4358 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/packages/core/src/CommandManager.d.ts +14 -7
- package/dist/packages/core/src/Editor.d.ts +25 -11
- package/dist/packages/core/src/EventEmitter.d.ts +8 -4
- package/dist/packages/core/src/Extension.d.ts +63 -29
- package/dist/packages/core/src/ExtensionManager.d.ts +3 -4
- package/dist/packages/core/src/InputRule.d.ts +42 -0
- package/dist/packages/core/src/Mark.d.ts +94 -36
- package/dist/packages/core/src/Node.d.ts +104 -45
- package/dist/packages/core/src/NodeView.d.ts +8 -8
- package/dist/packages/core/src/PasteRule.d.ts +42 -0
- package/dist/packages/core/src/Tracker.d.ts +1 -1
- package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +12 -0
- package/dist/packages/core/src/commands/deleteNode.d.ts +1 -1
- package/dist/packages/core/src/commands/deleteRange.d.ts +1 -1
- package/dist/packages/core/src/commands/extendMarkRange.d.ts +1 -1
- package/dist/packages/core/src/commands/focus.d.ts +4 -2
- package/dist/packages/core/src/commands/index.d.ts +50 -0
- package/dist/packages/core/src/commands/insertContent.d.ts +6 -3
- package/dist/packages/core/src/commands/insertContentAt.d.ts +6 -3
- package/dist/packages/core/src/commands/join.d.ts +33 -0
- package/dist/packages/core/src/commands/lift.d.ts +1 -1
- package/dist/packages/core/src/commands/liftListItem.d.ts +1 -1
- package/dist/packages/core/src/commands/resetAttributes.d.ts +1 -1
- package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +12 -0
- package/dist/packages/core/src/commands/selectTextblockStart.d.ts +12 -0
- package/dist/packages/core/src/commands/setContent.d.ts +2 -2
- package/dist/packages/core/src/commands/setMark.d.ts +1 -1
- package/dist/packages/core/src/commands/setNode.d.ts +1 -1
- package/dist/packages/core/src/commands/setTextSelection.d.ts +1 -1
- package/dist/packages/core/src/commands/sinkListItem.d.ts +1 -1
- package/dist/packages/core/src/commands/splitListItem.d.ts +1 -1
- package/dist/packages/core/src/commands/toggleList.d.ts +2 -2
- package/dist/packages/core/src/commands/toggleMark.d.ts +7 -2
- package/dist/packages/core/src/commands/toggleNode.d.ts +1 -1
- package/dist/packages/core/src/commands/toggleWrap.d.ts +1 -1
- package/dist/packages/core/src/commands/unsetMark.d.ts +7 -2
- package/dist/packages/core/src/commands/updateAttributes.d.ts +1 -1
- package/dist/packages/core/src/commands/wrapIn.d.ts +1 -1
- package/dist/packages/core/src/commands/wrapInList.d.ts +1 -1
- package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +1 -1
- package/dist/packages/core/src/extensions/commands.d.ts +2 -97
- package/dist/packages/core/src/extensions/editable.d.ts +1 -1
- package/dist/packages/core/src/extensions/focusEvents.d.ts +1 -1
- package/dist/packages/core/src/extensions/index.d.ts +1 -0
- package/dist/packages/core/src/extensions/keymap.d.ts +1 -1
- package/dist/packages/core/src/extensions/tabindex.d.ts +2 -0
- package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +7 -0
- package/dist/packages/core/src/helpers/createChainableState.d.ts +5 -0
- package/dist/packages/core/src/helpers/createDocument.d.ts +2 -2
- package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +2 -2
- package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +2 -0
- package/dist/packages/core/src/helpers/findChildren.d.ts +3 -3
- package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +3 -3
- package/dist/packages/core/src/helpers/findParentNode.d.ts +3 -4
- package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +3 -3
- package/dist/packages/core/src/helpers/generateHTML.d.ts +1 -1
- package/dist/packages/core/src/helpers/generateJSON.d.ts +1 -1
- package/dist/packages/core/src/helpers/generateText.d.ts +5 -0
- package/dist/packages/core/src/helpers/getAttributes.d.ts +3 -3
- package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +2 -2
- package/dist/packages/core/src/helpers/getChangedRanges.d.ts +11 -0
- package/dist/packages/core/src/helpers/getDebugJSON.d.ts +2 -5
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +2 -2
- package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +2 -2
- package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +3 -3
- package/dist/packages/core/src/helpers/getMarkRange.d.ts +2 -2
- package/dist/packages/core/src/helpers/getMarkType.d.ts +2 -2
- package/dist/packages/core/src/helpers/getMarksBetween.d.ts +2 -2
- package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +3 -3
- package/dist/packages/core/src/helpers/getNodeType.d.ts +2 -2
- package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +2 -2
- package/dist/packages/core/src/helpers/getSchema.d.ts +2 -2
- package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +2 -2
- package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +2 -2
- package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +2 -2
- package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +1 -1
- package/dist/packages/core/src/helpers/getText.d.ts +6 -0
- package/dist/packages/core/src/helpers/getTextBetween.d.ts +6 -0
- package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +2 -0
- package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +3 -0
- package/dist/packages/core/src/helpers/index.d.ts +47 -0
- package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +2 -2
- package/dist/packages/core/src/helpers/isActive.d.ts +2 -2
- package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +2 -0
- package/dist/packages/core/src/helpers/isList.d.ts +1 -1
- package/dist/packages/core/src/helpers/isMarkActive.d.ts +3 -3
- package/dist/packages/core/src/helpers/isNodeActive.d.ts +3 -3
- package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +2 -2
- package/dist/packages/core/src/helpers/isNodeSelection.d.ts +2 -2
- package/dist/packages/core/src/helpers/isTextSelection.d.ts +2 -2
- package/dist/packages/core/src/helpers/posToDOMRect.d.ts +2 -2
- package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +4 -0
- package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +2 -2
- package/dist/packages/core/src/helpers/splitExtensions.d.ts +6 -6
- package/dist/packages/core/src/index.d.ts +12 -34
- package/dist/packages/core/src/inputRules/index.d.ts +5 -0
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +12 -3
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +12 -3
- package/dist/packages/core/src/inputRules/textInputRule.d.ts +9 -0
- package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +14 -0
- package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +27 -0
- package/dist/packages/core/src/pasteRules/index.d.ts +3 -0
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +12 -3
- package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +12 -0
- package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +9 -0
- package/dist/packages/core/src/style.d.ts +1 -2
- package/dist/packages/core/src/types.d.ts +70 -40
- package/dist/packages/core/src/utilities/callOrReturn.d.ts +1 -1
- package/dist/packages/core/src/utilities/createStyleTag.d.ts +1 -1
- package/dist/packages/core/src/utilities/deleteProps.d.ts +1 -1
- package/dist/packages/core/src/utilities/elementFromString.d.ts +1 -1
- package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +1 -0
- package/dist/packages/core/src/utilities/findDuplicates.d.ts +1 -0
- package/dist/packages/core/src/utilities/fromString.d.ts +1 -1
- package/dist/packages/core/src/utilities/index.d.ts +20 -0
- package/dist/packages/core/src/utilities/isEmptyObject.d.ts +1 -1
- package/dist/packages/core/src/utilities/isFunction.d.ts +1 -0
- package/dist/packages/core/src/utilities/isMacOS.d.ts +1 -0
- package/dist/packages/core/src/utilities/isNumber.d.ts +1 -0
- package/dist/packages/core/src/utilities/isPlainObject.d.ts +1 -1
- package/dist/packages/core/src/utilities/isRegExp.d.ts +1 -0
- package/dist/packages/core/src/utilities/isString.d.ts +1 -0
- package/dist/packages/core/src/utilities/isiOS.d.ts +1 -1
- package/dist/packages/core/src/utilities/mergeAttributes.d.ts +1 -1
- package/dist/packages/core/src/utilities/mergeDeep.d.ts +1 -1
- package/dist/packages/core/src/utilities/minMax.d.ts +1 -1
- package/dist/packages/core/src/utilities/objectIncludes.d.ts +3 -1
- package/dist/packages/core/src/utilities/removeDuplicates.d.ts +8 -0
- package/package.json +25 -24
- package/src/CommandManager.ts +73 -83
- package/src/Editor.ts +101 -53
- package/src/EventEmitter.ts +14 -4
- package/src/Extension.ts +244 -138
- package/src/ExtensionManager.ts +153 -152
- package/src/InputRule.ts +260 -0
- package/src/Mark.ts +365 -204
- package/src/Node.ts +406 -253
- package/src/NodeView.ts +59 -38
- package/src/PasteRule.ts +240 -0
- package/src/Tracker.ts +4 -8
- package/src/commands/blur.ts +4 -0
- package/src/commands/clearNodes.ts +15 -9
- package/src/commands/createParagraphNear.ts +3 -2
- package/src/commands/deleteCurrentNode.ts +41 -0
- package/src/commands/deleteNode.ts +3 -2
- package/src/commands/deleteRange.ts +1 -1
- package/src/commands/deleteSelection.ts +3 -2
- package/src/commands/exitCode.ts +3 -2
- package/src/commands/extendMarkRange.ts +9 -5
- package/src/commands/focus.ts +31 -42
- package/src/commands/index.ts +50 -0
- package/src/commands/insertContent.ts +15 -4
- package/src/commands/insertContentAt.ts +71 -14
- package/src/commands/join.ts +53 -0
- package/src/commands/keyboardShortcut.ts +3 -3
- package/src/commands/lift.ts +6 -5
- package/src/commands/liftEmptyBlock.ts +2 -1
- package/src/commands/liftListItem.ts +5 -4
- package/src/commands/newlineInCode.ts +3 -2
- package/src/commands/resetAttributes.ts +16 -10
- package/src/commands/selectAll.ts +5 -3
- package/src/commands/selectNodeBackward.ts +3 -2
- package/src/commands/selectNodeForward.ts +3 -2
- package/src/commands/selectParentNode.ts +3 -2
- package/src/commands/selectTextblockEnd.ts +20 -0
- package/src/commands/selectTextblockStart.ts +20 -0
- package/src/commands/setContent.ts +6 -9
- package/src/commands/setMark.ts +66 -13
- package/src/commands/setNode.ts +30 -6
- package/src/commands/setNodeSelection.ts +6 -7
- package/src/commands/setTextSelection.ts +8 -9
- package/src/commands/sinkListItem.ts +5 -4
- package/src/commands/splitBlock.ts +23 -38
- package/src/commands/splitListItem.ts +30 -27
- package/src/commands/toggleList.ts +108 -19
- package/src/commands/toggleMark.ts +17 -6
- package/src/commands/toggleNode.ts +9 -4
- package/src/commands/toggleWrap.ts +8 -8
- package/src/commands/undoInputRule.ts +31 -2
- package/src/commands/unsetAllMarks.ts +4 -8
- package/src/commands/unsetMark.ts +34 -21
- package/src/commands/updateAttributes.ts +18 -12
- package/src/commands/wrapIn.ts +5 -10
- package/src/commands/wrapInList.ts +5 -4
- package/src/extensions/clipboardTextSerializer.ts +15 -36
- package/src/extensions/commands.ts +3 -144
- 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 +111 -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 +4 -3
- package/src/helpers/createNodeFromContent.ts +10 -15
- package/src/helpers/defaultBlockAt.ts +13 -0
- package/src/helpers/findChildren.ts +4 -3
- package/src/helpers/findChildrenInRange.ts +8 -3
- package/src/helpers/findParentNode.ts +4 -3
- package/src/helpers/findParentNodeClosestToPos.ts +13 -7
- package/src/helpers/generateHTML.ts +6 -5
- package/src/helpers/generateJSON.ts +6 -7
- package/src/helpers/generateText.ts +27 -0
- package/src/helpers/getAttributes.ts +8 -9
- package/src/helpers/getAttributesFromExtensions.ts +25 -12
- package/src/helpers/getChangedRanges.ts +83 -0
- package/src/helpers/getDebugJSON.ts +42 -38
- package/src/helpers/getExtensionField.ts +3 -3
- package/src/helpers/getHTMLFromFragment.ts +5 -6
- package/src/helpers/getMarkAttributes.ts +18 -10
- package/src/helpers/getMarkRange.ts +13 -8
- package/src/helpers/getMarkType.ts +5 -3
- package/src/helpers/getMarksBetween.ts +34 -10
- package/src/helpers/getNodeAttributes.ts +14 -12
- package/src/helpers/getNodeType.ts +5 -3
- package/src/helpers/getRenderedAttributes.ts +8 -6
- package/src/helpers/getSchema.ts +5 -4
- package/src/helpers/getSchemaByResolvedExtensions.ts +165 -111
- package/src/helpers/getSchemaTypeByName.ts +3 -11
- package/src/helpers/getSchemaTypeNameByName.ts +2 -2
- package/src/helpers/getSplittedAttributes.ts +1 -1
- 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 +47 -0
- package/src/helpers/injectExtensionAttributesToParseRule.ts +22 -23
- package/src/helpers/isActive.ts +10 -5
- package/src/helpers/isExtensionRulesEnabled.ts +15 -0
- package/src/helpers/isList.ts +6 -5
- package/src/helpers/isMarkActive.ts +32 -35
- package/src/helpers/isNodeActive.ts +27 -37
- 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 +10 -4
- 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 +12 -37
- 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 +84 -0
- package/src/pasteRules/index.ts +3 -0
- package/src/pasteRules/markPasteRule.ts +49 -56
- package/src/pasteRules/nodePasteRule.ts +37 -0
- package/src/pasteRules/textPasteRule.ts +35 -0
- package/src/style.ts +12 -3
- package/src/types.ts +140 -106
- package/src/utilities/callOrReturn.ts +3 -2
- package/src/utilities/createStyleTag.ts +8 -4
- package/src/utilities/deleteProps.ts +1 -1
- package/src/utilities/elementFromString.ts +1 -1
- 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 +1 -1
- package/src/utilities/mergeAttributes.ts +2 -1
- package/src/utilities/mergeDeep.ts +2 -2
- package/src/utilities/minMax.ts +1 -1
- package/src/utilities/objectIncludes.ts +18 -4
- package/src/utilities/removeDuplicates.ts +15 -0
- package/CHANGELOG.md +0 -1190
- package/LICENSE.md +0 -21
- 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/utilities/isClass.d.ts +0 -1
- package/dist/packages/core/src/utilities/isObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/removeElement.d.ts +0 -1
- package/dist/tiptap-core.cjs.js +0 -3408
- package/dist/tiptap-core.cjs.js.map +0 -1
- package/dist/tiptap-core.esm.js.map +0 -1
- package/dist/tiptap-core.umd.js +0 -3405
- package/dist/tiptap-core.umd.js.map +0 -1
- package/src/commands/joinBackward.ts +0 -17
- package/src/commands/joinForward.ts +0 -17
- package/src/utilities/isClass.ts +0 -7
- package/src/utilities/isObject.ts +0 -10
- package/src/utilities/removeElement.ts +0 -5
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import { EditorState, Transaction } from '
|
|
1
|
+
import { EditorState, Transaction } from '@tiptap/pm/state';
|
|
2
2
|
import { Editor } from './Editor';
|
|
3
|
-
import {
|
|
4
|
-
export
|
|
3
|
+
import { AnyCommands, CanCommands, ChainedCommands, CommandProps, SingleCommands } from './types';
|
|
4
|
+
export declare class CommandManager {
|
|
5
5
|
editor: Editor;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
rawCommands: AnyCommands;
|
|
7
|
+
customState?: EditorState;
|
|
8
|
+
constructor(props: {
|
|
9
|
+
editor: Editor;
|
|
10
|
+
state?: EditorState;
|
|
11
|
+
});
|
|
12
|
+
get hasCustomState(): boolean;
|
|
13
|
+
get state(): EditorState;
|
|
14
|
+
get commands(): SingleCommands;
|
|
15
|
+
get chain(): () => ChainedCommands;
|
|
16
|
+
get can(): () => CanCommands;
|
|
9
17
|
createChain(startTr?: Transaction, shouldDispatch?: boolean): ChainedCommands;
|
|
10
18
|
createCan(startTr?: Transaction): CanCommands;
|
|
11
19
|
buildProps(tr: Transaction, shouldDispatch?: boolean): CommandProps;
|
|
12
|
-
chainableState(tr: Transaction, state: EditorState): EditorState;
|
|
13
20
|
}
|
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { EditorOptions, CanCommands, ChainedCommands, SingleCommands } from './types';
|
|
1
|
+
import { MarkType, NodeType, Schema } from '@tiptap/pm/model';
|
|
2
|
+
import { EditorState, Plugin, PluginKey, Transaction } from '@tiptap/pm/state';
|
|
3
|
+
import { EditorView } from '@tiptap/pm/view';
|
|
4
|
+
import { EventEmitter } from './EventEmitter';
|
|
5
|
+
import { ExtensionManager } from './ExtensionManager';
|
|
7
6
|
import * as extensions from './extensions';
|
|
7
|
+
import { CanCommands, ChainedCommands, EditorEvents, EditorOptions, JSONContent, SingleCommands, TextSerializer } from './types';
|
|
8
8
|
export { extensions };
|
|
9
9
|
export interface HTMLElement {
|
|
10
10
|
editor?: Editor;
|
|
11
11
|
}
|
|
12
|
-
export declare class Editor extends EventEmitter {
|
|
12
|
+
export declare class Editor extends EventEmitter<EditorEvents> {
|
|
13
13
|
private commandManager;
|
|
14
14
|
extensionManager: ExtensionManager;
|
|
15
15
|
private css;
|
|
16
16
|
schema: Schema;
|
|
17
17
|
view: EditorView;
|
|
18
18
|
isFocused: boolean;
|
|
19
|
+
extensionStorage: Record<string, any>;
|
|
19
20
|
options: EditorOptions;
|
|
20
21
|
constructor(options?: Partial<EditorOptions>);
|
|
22
|
+
/**
|
|
23
|
+
* Returns the editor storage.
|
|
24
|
+
*/
|
|
25
|
+
get storage(): Record<string, any>;
|
|
21
26
|
/**
|
|
22
27
|
* An object of all registered commands.
|
|
23
28
|
*/
|
|
@@ -43,7 +48,7 @@ export declare class Editor extends EventEmitter {
|
|
|
43
48
|
/**
|
|
44
49
|
* Update editable state of the editor.
|
|
45
50
|
*/
|
|
46
|
-
setEditable(editable: boolean): void;
|
|
51
|
+
setEditable(editable: boolean, emitUpdate?: boolean): void;
|
|
47
52
|
/**
|
|
48
53
|
* Returns whether the editor is editable.
|
|
49
54
|
*/
|
|
@@ -62,7 +67,7 @@ export declare class Editor extends EventEmitter {
|
|
|
62
67
|
/**
|
|
63
68
|
* Unregister a ProseMirror plugin.
|
|
64
69
|
*
|
|
65
|
-
* @param
|
|
70
|
+
* @param nameOrPluginKey The plugins name
|
|
66
71
|
*/
|
|
67
72
|
unregisterPlugin(nameOrPluginKey: string | PluginKey): void;
|
|
68
73
|
/**
|
|
@@ -87,7 +92,7 @@ export declare class Editor extends EventEmitter {
|
|
|
87
92
|
createNodeViews(): void;
|
|
88
93
|
isCapturingTransaction: boolean;
|
|
89
94
|
private capturedTransaction;
|
|
90
|
-
captureTransaction(fn: Function): Transaction
|
|
95
|
+
captureTransaction(fn: Function): Transaction | null;
|
|
91
96
|
/**
|
|
92
97
|
* The callback over which to send transactions (state updates) produced by the view.
|
|
93
98
|
*
|
|
@@ -109,17 +114,26 @@ export declare class Editor extends EventEmitter {
|
|
|
109
114
|
/**
|
|
110
115
|
* Get the document as JSON.
|
|
111
116
|
*/
|
|
112
|
-
getJSON():
|
|
117
|
+
getJSON(): JSONContent;
|
|
113
118
|
/**
|
|
114
119
|
* Get the document as HTML.
|
|
115
120
|
*/
|
|
116
121
|
getHTML(): string;
|
|
122
|
+
/**
|
|
123
|
+
* Get the document as text.
|
|
124
|
+
*/
|
|
125
|
+
getText(options?: {
|
|
126
|
+
blockSeparator?: string;
|
|
127
|
+
textSerializers?: Record<string, TextSerializer>;
|
|
128
|
+
}): string;
|
|
117
129
|
/**
|
|
118
130
|
* Check if there is no content.
|
|
119
131
|
*/
|
|
120
132
|
get isEmpty(): boolean;
|
|
121
133
|
/**
|
|
122
134
|
* Get the number of characters for the current document.
|
|
135
|
+
*
|
|
136
|
+
* @deprecated
|
|
123
137
|
*/
|
|
124
138
|
getCharacterCount(): number;
|
|
125
139
|
/**
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
declare type StringKeyOf<T> = Extract<keyof T, string>;
|
|
2
|
+
declare type CallbackType<T extends Record<string, any>, EventName extends StringKeyOf<T>> = T[EventName] extends any[] ? T[EventName] : [T[EventName]];
|
|
3
|
+
declare type CallbackFunction<T extends Record<string, any>, EventName extends StringKeyOf<T>> = (...props: CallbackType<T, EventName>) => any;
|
|
4
|
+
export declare class EventEmitter<T extends Record<string, any>> {
|
|
2
5
|
private callbacks;
|
|
3
|
-
on(event:
|
|
4
|
-
protected emit(event:
|
|
5
|
-
off(event:
|
|
6
|
+
on<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this;
|
|
7
|
+
protected emit<EventName extends StringKeyOf<T>>(event: EventName, ...args: CallbackType<T, EventName>): this;
|
|
8
|
+
off<EventName extends StringKeyOf<T>>(event: EventName, fn?: CallbackFunction<T, EventName>): this;
|
|
6
9
|
protected removeAllListeners(): void;
|
|
7
10
|
}
|
|
11
|
+
export {};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { Plugin, Transaction } from '
|
|
2
|
-
import {
|
|
1
|
+
import { Plugin, Transaction } from '@tiptap/pm/state';
|
|
2
|
+
import { ExtensionConfig } from '.';
|
|
3
3
|
import { Editor } from './Editor';
|
|
4
|
-
import {
|
|
4
|
+
import { InputRule } from './InputRule';
|
|
5
5
|
import { Mark } from './Mark';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { Node } from './Node';
|
|
7
|
+
import { PasteRule } from './PasteRule';
|
|
8
|
+
import { Extensions, GlobalAttributes, KeyboardShortcutCommand, ParentConfig, RawCommands } from './types';
|
|
8
9
|
declare module '@tiptap/core' {
|
|
9
|
-
interface ExtensionConfig<Options = any> {
|
|
10
|
+
interface ExtensionConfig<Options = any, Storage = any> {
|
|
10
11
|
[key: string]: any;
|
|
11
12
|
/**
|
|
12
13
|
* Name
|
|
@@ -20,13 +21,29 @@ declare module '@tiptap/core' {
|
|
|
20
21
|
* Default options
|
|
21
22
|
*/
|
|
22
23
|
defaultOptions?: Options;
|
|
24
|
+
/**
|
|
25
|
+
* Default Options
|
|
26
|
+
*/
|
|
27
|
+
addOptions?: (this: {
|
|
28
|
+
name: string;
|
|
29
|
+
parent: Exclude<ParentConfig<ExtensionConfig<Options, Storage>>['addOptions'], undefined>;
|
|
30
|
+
}) => Options;
|
|
31
|
+
/**
|
|
32
|
+
* Default Storage
|
|
33
|
+
*/
|
|
34
|
+
addStorage?: (this: {
|
|
35
|
+
name: string;
|
|
36
|
+
options: Options;
|
|
37
|
+
parent: Exclude<ParentConfig<ExtensionConfig<Options, Storage>>['addStorage'], undefined>;
|
|
38
|
+
}) => Storage;
|
|
23
39
|
/**
|
|
24
40
|
* Global attributes
|
|
25
41
|
*/
|
|
26
42
|
addGlobalAttributes?: (this: {
|
|
27
43
|
name: string;
|
|
28
44
|
options: Options;
|
|
29
|
-
|
|
45
|
+
storage: Storage;
|
|
46
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addGlobalAttributes'];
|
|
30
47
|
}) => GlobalAttributes | {};
|
|
31
48
|
/**
|
|
32
49
|
* Raw
|
|
@@ -34,8 +51,9 @@ declare module '@tiptap/core' {
|
|
|
34
51
|
addCommands?: (this: {
|
|
35
52
|
name: string;
|
|
36
53
|
options: Options;
|
|
54
|
+
storage: Storage;
|
|
37
55
|
editor: Editor;
|
|
38
|
-
parent: ParentConfig<ExtensionConfig<Options>>['addCommands'];
|
|
56
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addCommands'];
|
|
39
57
|
}) => Partial<RawCommands>;
|
|
40
58
|
/**
|
|
41
59
|
* Keyboard shortcuts
|
|
@@ -43,8 +61,9 @@ declare module '@tiptap/core' {
|
|
|
43
61
|
addKeyboardShortcuts?: (this: {
|
|
44
62
|
name: string;
|
|
45
63
|
options: Options;
|
|
64
|
+
storage: Storage;
|
|
46
65
|
editor: Editor;
|
|
47
|
-
parent: ParentConfig<ExtensionConfig<Options>>['addKeyboardShortcuts'];
|
|
66
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addKeyboardShortcuts'];
|
|
48
67
|
}) => {
|
|
49
68
|
[key: string]: KeyboardShortcutCommand;
|
|
50
69
|
};
|
|
@@ -54,8 +73,9 @@ declare module '@tiptap/core' {
|
|
|
54
73
|
addInputRules?: (this: {
|
|
55
74
|
name: string;
|
|
56
75
|
options: Options;
|
|
76
|
+
storage: Storage;
|
|
57
77
|
editor: Editor;
|
|
58
|
-
parent: ParentConfig<ExtensionConfig<Options>>['addInputRules'];
|
|
78
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addInputRules'];
|
|
59
79
|
}) => InputRule[];
|
|
60
80
|
/**
|
|
61
81
|
* Paste rules
|
|
@@ -63,17 +83,19 @@ declare module '@tiptap/core' {
|
|
|
63
83
|
addPasteRules?: (this: {
|
|
64
84
|
name: string;
|
|
65
85
|
options: Options;
|
|
86
|
+
storage: Storage;
|
|
66
87
|
editor: Editor;
|
|
67
|
-
parent: ParentConfig<ExtensionConfig<Options>>['addPasteRules'];
|
|
68
|
-
}) =>
|
|
88
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addPasteRules'];
|
|
89
|
+
}) => PasteRule[];
|
|
69
90
|
/**
|
|
70
91
|
* ProseMirror plugins
|
|
71
92
|
*/
|
|
72
93
|
addProseMirrorPlugins?: (this: {
|
|
73
94
|
name: string;
|
|
74
95
|
options: Options;
|
|
96
|
+
storage: Storage;
|
|
75
97
|
editor: Editor;
|
|
76
|
-
parent: ParentConfig<ExtensionConfig<Options>>['addProseMirrorPlugins'];
|
|
98
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addProseMirrorPlugins'];
|
|
77
99
|
}) => Plugin[];
|
|
78
100
|
/**
|
|
79
101
|
* Extensions
|
|
@@ -81,7 +103,8 @@ declare module '@tiptap/core' {
|
|
|
81
103
|
addExtensions?: (this: {
|
|
82
104
|
name: string;
|
|
83
105
|
options: Options;
|
|
84
|
-
|
|
106
|
+
storage: Storage;
|
|
107
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addExtensions'];
|
|
85
108
|
}) => Extensions;
|
|
86
109
|
/**
|
|
87
110
|
* Extend Node Schema
|
|
@@ -89,7 +112,8 @@ declare module '@tiptap/core' {
|
|
|
89
112
|
extendNodeSchema?: ((this: {
|
|
90
113
|
name: string;
|
|
91
114
|
options: Options;
|
|
92
|
-
|
|
115
|
+
storage: Storage;
|
|
116
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['extendNodeSchema'];
|
|
93
117
|
}, extension: Node) => Record<string, any>) | null;
|
|
94
118
|
/**
|
|
95
119
|
* Extend Mark Schema
|
|
@@ -97,7 +121,8 @@ declare module '@tiptap/core' {
|
|
|
97
121
|
extendMarkSchema?: ((this: {
|
|
98
122
|
name: string;
|
|
99
123
|
options: Options;
|
|
100
|
-
|
|
124
|
+
storage: Storage;
|
|
125
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['extendMarkSchema'];
|
|
101
126
|
}, extension: Mark) => Record<string, any>) | null;
|
|
102
127
|
/**
|
|
103
128
|
* The editor is not ready yet.
|
|
@@ -105,8 +130,9 @@ declare module '@tiptap/core' {
|
|
|
105
130
|
onBeforeCreate?: ((this: {
|
|
106
131
|
name: string;
|
|
107
132
|
options: Options;
|
|
133
|
+
storage: Storage;
|
|
108
134
|
editor: Editor;
|
|
109
|
-
parent: ParentConfig<ExtensionConfig<Options>>['onBeforeCreate'];
|
|
135
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onBeforeCreate'];
|
|
110
136
|
}) => void) | null;
|
|
111
137
|
/**
|
|
112
138
|
* The editor is ready.
|
|
@@ -114,8 +140,9 @@ declare module '@tiptap/core' {
|
|
|
114
140
|
onCreate?: ((this: {
|
|
115
141
|
name: string;
|
|
116
142
|
options: Options;
|
|
143
|
+
storage: Storage;
|
|
117
144
|
editor: Editor;
|
|
118
|
-
parent: ParentConfig<ExtensionConfig<Options>>['onCreate'];
|
|
145
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onCreate'];
|
|
119
146
|
}) => void) | null;
|
|
120
147
|
/**
|
|
121
148
|
* The content has changed.
|
|
@@ -123,8 +150,9 @@ declare module '@tiptap/core' {
|
|
|
123
150
|
onUpdate?: ((this: {
|
|
124
151
|
name: string;
|
|
125
152
|
options: Options;
|
|
153
|
+
storage: Storage;
|
|
126
154
|
editor: Editor;
|
|
127
|
-
parent: ParentConfig<ExtensionConfig<Options>>['onUpdate'];
|
|
155
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onUpdate'];
|
|
128
156
|
}) => void) | null;
|
|
129
157
|
/**
|
|
130
158
|
* The selection has changed.
|
|
@@ -132,8 +160,9 @@ declare module '@tiptap/core' {
|
|
|
132
160
|
onSelectionUpdate?: ((this: {
|
|
133
161
|
name: string;
|
|
134
162
|
options: Options;
|
|
163
|
+
storage: Storage;
|
|
135
164
|
editor: Editor;
|
|
136
|
-
parent: ParentConfig<ExtensionConfig<Options>>['onSelectionUpdate'];
|
|
165
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onSelectionUpdate'];
|
|
137
166
|
}) => void) | null;
|
|
138
167
|
/**
|
|
139
168
|
* The editor state has changed.
|
|
@@ -141,8 +170,9 @@ declare module '@tiptap/core' {
|
|
|
141
170
|
onTransaction?: ((this: {
|
|
142
171
|
name: string;
|
|
143
172
|
options: Options;
|
|
173
|
+
storage: Storage;
|
|
144
174
|
editor: Editor;
|
|
145
|
-
parent: ParentConfig<ExtensionConfig<Options>>['onTransaction'];
|
|
175
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onTransaction'];
|
|
146
176
|
}, props: {
|
|
147
177
|
transaction: Transaction;
|
|
148
178
|
}) => void) | null;
|
|
@@ -152,8 +182,9 @@ declare module '@tiptap/core' {
|
|
|
152
182
|
onFocus?: ((this: {
|
|
153
183
|
name: string;
|
|
154
184
|
options: Options;
|
|
185
|
+
storage: Storage;
|
|
155
186
|
editor: Editor;
|
|
156
|
-
parent: ParentConfig<ExtensionConfig<Options>>['onFocus'];
|
|
187
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onFocus'];
|
|
157
188
|
}, props: {
|
|
158
189
|
event: FocusEvent;
|
|
159
190
|
}) => void) | null;
|
|
@@ -163,8 +194,9 @@ declare module '@tiptap/core' {
|
|
|
163
194
|
onBlur?: ((this: {
|
|
164
195
|
name: string;
|
|
165
196
|
options: Options;
|
|
197
|
+
storage: Storage;
|
|
166
198
|
editor: Editor;
|
|
167
|
-
parent: ParentConfig<ExtensionConfig<Options>>['onBlur'];
|
|
199
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onBlur'];
|
|
168
200
|
}, props: {
|
|
169
201
|
event: FocusEvent;
|
|
170
202
|
}) => void) | null;
|
|
@@ -174,20 +206,22 @@ declare module '@tiptap/core' {
|
|
|
174
206
|
onDestroy?: ((this: {
|
|
175
207
|
name: string;
|
|
176
208
|
options: Options;
|
|
209
|
+
storage: Storage;
|
|
177
210
|
editor: Editor;
|
|
178
|
-
parent: ParentConfig<ExtensionConfig<Options>>['onDestroy'];
|
|
211
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onDestroy'];
|
|
179
212
|
}) => void) | null;
|
|
180
213
|
}
|
|
181
214
|
}
|
|
182
|
-
export declare class Extension<Options = any> {
|
|
215
|
+
export declare class Extension<Options = any, Storage = any> {
|
|
183
216
|
type: string;
|
|
184
217
|
name: string;
|
|
185
218
|
parent: Extension | null;
|
|
186
219
|
child: Extension | null;
|
|
187
220
|
options: Options;
|
|
221
|
+
storage: Storage;
|
|
188
222
|
config: ExtensionConfig;
|
|
189
|
-
constructor(config?: Partial<ExtensionConfig<Options>>);
|
|
190
|
-
static create<O>(config?: Partial<ExtensionConfig<O>>): Extension<O>;
|
|
191
|
-
configure(options?: Partial<Options>): Extension<Options>;
|
|
192
|
-
extend<ExtendedOptions = Options>(extendedConfig?: Partial<ExtensionConfig<ExtendedOptions>>): Extension<ExtendedOptions>;
|
|
223
|
+
constructor(config?: Partial<ExtensionConfig<Options, Storage>>);
|
|
224
|
+
static create<O = any, S = any>(config?: Partial<ExtensionConfig<O, S>>): Extension<O, S>;
|
|
225
|
+
configure(options?: Partial<Options>): Extension<Options, Storage>;
|
|
226
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage>(extendedConfig?: Partial<ExtensionConfig<ExtendedOptions, ExtendedStorage>>): Extension<ExtendedOptions, ExtendedStorage>;
|
|
193
227
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Schema } from '
|
|
2
|
-
import { Plugin } from '
|
|
1
|
+
import { Schema } from '@tiptap/pm/model';
|
|
2
|
+
import { Plugin } from '@tiptap/pm/state';
|
|
3
3
|
import { Editor } from './Editor';
|
|
4
4
|
import { Extensions, RawCommands } from './types';
|
|
5
|
-
export
|
|
5
|
+
export declare class ExtensionManager {
|
|
6
6
|
editor: Editor;
|
|
7
7
|
schema: Schema;
|
|
8
8
|
extensions: Extensions;
|
|
@@ -15,5 +15,4 @@ export default class ExtensionManager {
|
|
|
15
15
|
get plugins(): Plugin[];
|
|
16
16
|
get attributes(): import("@tiptap/core").ExtensionAttribute[];
|
|
17
17
|
get nodeViews(): any;
|
|
18
|
-
get textSerializers(): any;
|
|
19
18
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { EditorState, Plugin } from '@tiptap/pm/state';
|
|
2
|
+
import { Editor } from './Editor';
|
|
3
|
+
import { CanCommands, ChainedCommands, ExtendedRegExpMatchArray, Range, SingleCommands } from './types';
|
|
4
|
+
export declare type InputRuleMatch = {
|
|
5
|
+
index: number;
|
|
6
|
+
text: string;
|
|
7
|
+
replaceWith?: string;
|
|
8
|
+
match?: RegExpMatchArray;
|
|
9
|
+
data?: Record<string, any>;
|
|
10
|
+
};
|
|
11
|
+
export declare type InputRuleFinder = RegExp | ((text: string) => InputRuleMatch | null);
|
|
12
|
+
export declare class InputRule {
|
|
13
|
+
find: InputRuleFinder;
|
|
14
|
+
handler: (props: {
|
|
15
|
+
state: EditorState;
|
|
16
|
+
range: Range;
|
|
17
|
+
match: ExtendedRegExpMatchArray;
|
|
18
|
+
commands: SingleCommands;
|
|
19
|
+
chain: () => ChainedCommands;
|
|
20
|
+
can: () => CanCommands;
|
|
21
|
+
}) => void | null;
|
|
22
|
+
constructor(config: {
|
|
23
|
+
find: InputRuleFinder;
|
|
24
|
+
handler: (props: {
|
|
25
|
+
state: EditorState;
|
|
26
|
+
range: Range;
|
|
27
|
+
match: ExtendedRegExpMatchArray;
|
|
28
|
+
commands: SingleCommands;
|
|
29
|
+
chain: () => ChainedCommands;
|
|
30
|
+
can: () => CanCommands;
|
|
31
|
+
}) => void | null;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create an input rules plugin. When enabled, it will cause text
|
|
36
|
+
* input that matches any of the given rules to trigger the rule’s
|
|
37
|
+
* action.
|
|
38
|
+
*/
|
|
39
|
+
export declare function inputRulesPlugin(props: {
|
|
40
|
+
editor: Editor;
|
|
41
|
+
rules: InputRule[];
|
|
42
|
+
}): Plugin;
|