@tiptap/core 2.0.0-beta.98 → 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 -1182
- 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
package/src/Node.ts
CHANGED
|
@@ -1,407 +1,513 @@
|
|
|
1
1
|
import {
|
|
2
|
-
DOMOutputSpec,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from '
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
2
|
+
DOMOutputSpec, Node as ProseMirrorNode, NodeSpec, NodeType,
|
|
3
|
+
} from '@tiptap/pm/model'
|
|
4
|
+
import { Plugin, Transaction } from '@tiptap/pm/state'
|
|
5
|
+
|
|
6
|
+
import { NodeConfig } from '.'
|
|
7
|
+
import { Editor } from './Editor'
|
|
8
|
+
import { getExtensionField } from './helpers/getExtensionField'
|
|
9
|
+
import { InputRule } from './InputRule'
|
|
10
|
+
import { PasteRule } from './PasteRule'
|
|
10
11
|
import {
|
|
11
|
-
|
|
12
|
+
AnyConfig,
|
|
12
13
|
Attributes,
|
|
13
|
-
|
|
14
|
+
Extensions,
|
|
14
15
|
GlobalAttributes,
|
|
15
|
-
RawCommands,
|
|
16
|
-
ParentConfig,
|
|
17
16
|
KeyboardShortcutCommand,
|
|
17
|
+
NodeViewRenderer,
|
|
18
|
+
ParentConfig,
|
|
19
|
+
RawCommands,
|
|
18
20
|
} from './types'
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
+
import { callOrReturn } from './utilities/callOrReturn'
|
|
22
|
+
import { mergeDeep } from './utilities/mergeDeep'
|
|
21
23
|
|
|
22
24
|
declare module '@tiptap/core' {
|
|
23
|
-
interface NodeConfig<Options = any> {
|
|
24
|
-
[key: string]: any
|
|
25
|
+
interface NodeConfig<Options = any, Storage = any> {
|
|
26
|
+
[key: string]: any
|
|
25
27
|
|
|
26
28
|
/**
|
|
27
29
|
* Name
|
|
28
30
|
*/
|
|
29
|
-
name: string
|
|
31
|
+
name: string
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
34
|
* Priority
|
|
33
35
|
*/
|
|
34
|
-
priority?: number
|
|
36
|
+
priority?: number
|
|
35
37
|
|
|
36
38
|
/**
|
|
37
39
|
* Default options
|
|
38
40
|
*/
|
|
39
|
-
defaultOptions?: Options
|
|
41
|
+
defaultOptions?: Options
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Default Options
|
|
45
|
+
*/
|
|
46
|
+
addOptions?: (this: {
|
|
47
|
+
name: string
|
|
48
|
+
parent: Exclude<ParentConfig<NodeConfig<Options, Storage>>['addOptions'], undefined>
|
|
49
|
+
}) => Options
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Default Storage
|
|
53
|
+
*/
|
|
54
|
+
addStorage?: (this: {
|
|
55
|
+
name: string
|
|
56
|
+
options: Options
|
|
57
|
+
parent: Exclude<ParentConfig<NodeConfig<Options, Storage>>['addStorage'], undefined>
|
|
58
|
+
}) => Storage
|
|
40
59
|
|
|
41
60
|
/**
|
|
42
61
|
* Global attributes
|
|
43
62
|
*/
|
|
44
63
|
addGlobalAttributes?: (this: {
|
|
45
|
-
name: string
|
|
46
|
-
options: Options
|
|
47
|
-
|
|
48
|
-
|
|
64
|
+
name: string
|
|
65
|
+
options: Options
|
|
66
|
+
storage: Storage
|
|
67
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addGlobalAttributes']
|
|
68
|
+
}) => GlobalAttributes | {}
|
|
49
69
|
|
|
50
70
|
/**
|
|
51
71
|
* Raw
|
|
52
72
|
*/
|
|
53
73
|
addCommands?: (this: {
|
|
54
|
-
name: string
|
|
55
|
-
options: Options
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
74
|
+
name: string
|
|
75
|
+
options: Options
|
|
76
|
+
storage: Storage
|
|
77
|
+
editor: Editor
|
|
78
|
+
type: NodeType
|
|
79
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addCommands']
|
|
80
|
+
}) => Partial<RawCommands>
|
|
60
81
|
|
|
61
82
|
/**
|
|
62
83
|
* Keyboard shortcuts
|
|
63
84
|
*/
|
|
64
85
|
addKeyboardShortcuts?: (this: {
|
|
65
|
-
name: string
|
|
66
|
-
options: Options
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
86
|
+
name: string
|
|
87
|
+
options: Options
|
|
88
|
+
storage: Storage
|
|
89
|
+
editor: Editor
|
|
90
|
+
type: NodeType
|
|
91
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addKeyboardShortcuts']
|
|
70
92
|
}) => {
|
|
71
|
-
[key: string]: KeyboardShortcutCommand
|
|
72
|
-
}
|
|
93
|
+
[key: string]: KeyboardShortcutCommand
|
|
94
|
+
}
|
|
73
95
|
|
|
74
96
|
/**
|
|
75
97
|
* Input rules
|
|
76
98
|
*/
|
|
77
99
|
addInputRules?: (this: {
|
|
78
|
-
name: string
|
|
79
|
-
options: Options
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
100
|
+
name: string
|
|
101
|
+
options: Options
|
|
102
|
+
storage: Storage
|
|
103
|
+
editor: Editor
|
|
104
|
+
type: NodeType
|
|
105
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addInputRules']
|
|
106
|
+
}) => InputRule[]
|
|
84
107
|
|
|
85
108
|
/**
|
|
86
109
|
* Paste rules
|
|
87
110
|
*/
|
|
88
111
|
addPasteRules?: (this: {
|
|
89
|
-
name: string
|
|
90
|
-
options: Options
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
112
|
+
name: string
|
|
113
|
+
options: Options
|
|
114
|
+
storage: Storage
|
|
115
|
+
editor: Editor
|
|
116
|
+
type: NodeType
|
|
117
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addPasteRules']
|
|
118
|
+
}) => PasteRule[]
|
|
95
119
|
|
|
96
120
|
/**
|
|
97
121
|
* ProseMirror plugins
|
|
98
122
|
*/
|
|
99
123
|
addProseMirrorPlugins?: (this: {
|
|
100
|
-
name: string
|
|
101
|
-
options: Options
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
124
|
+
name: string
|
|
125
|
+
options: Options
|
|
126
|
+
storage: Storage
|
|
127
|
+
editor: Editor
|
|
128
|
+
type: NodeType
|
|
129
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addProseMirrorPlugins']
|
|
130
|
+
}) => Plugin[]
|
|
106
131
|
|
|
107
132
|
/**
|
|
108
133
|
* Extensions
|
|
109
134
|
*/
|
|
110
135
|
addExtensions?: (this: {
|
|
111
|
-
name: string
|
|
112
|
-
options: Options
|
|
113
|
-
|
|
114
|
-
|
|
136
|
+
name: string
|
|
137
|
+
options: Options
|
|
138
|
+
storage: Storage
|
|
139
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addExtensions']
|
|
140
|
+
}) => Extensions
|
|
115
141
|
|
|
116
142
|
/**
|
|
117
143
|
* Extend Node Schema
|
|
118
144
|
*/
|
|
119
|
-
extendNodeSchema?:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
145
|
+
extendNodeSchema?:
|
|
146
|
+
| ((
|
|
147
|
+
this: {
|
|
148
|
+
name: string
|
|
149
|
+
options: Options
|
|
150
|
+
storage: Storage
|
|
151
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['extendNodeSchema']
|
|
152
|
+
},
|
|
153
|
+
extension: Node,
|
|
154
|
+
) => Record<string, any>)
|
|
155
|
+
| null
|
|
127
156
|
|
|
128
157
|
/**
|
|
129
158
|
* Extend Mark Schema
|
|
130
159
|
*/
|
|
131
|
-
extendMarkSchema?:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
160
|
+
extendMarkSchema?:
|
|
161
|
+
| ((
|
|
162
|
+
this: {
|
|
163
|
+
name: string
|
|
164
|
+
options: Options
|
|
165
|
+
storage: Storage
|
|
166
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['extendMarkSchema']
|
|
167
|
+
},
|
|
168
|
+
extension: Node,
|
|
169
|
+
) => Record<string, any>)
|
|
170
|
+
| null
|
|
139
171
|
|
|
140
172
|
/**
|
|
141
173
|
* The editor is not ready yet.
|
|
142
174
|
*/
|
|
143
|
-
onBeforeCreate?:
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
175
|
+
onBeforeCreate?:
|
|
176
|
+
| ((this: {
|
|
177
|
+
name: string
|
|
178
|
+
options: Options
|
|
179
|
+
storage: Storage
|
|
180
|
+
editor: Editor
|
|
181
|
+
type: NodeType
|
|
182
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['onBeforeCreate']
|
|
183
|
+
}) => void)
|
|
184
|
+
| null
|
|
150
185
|
|
|
151
186
|
/**
|
|
152
187
|
* The editor is ready.
|
|
153
188
|
*/
|
|
154
|
-
onCreate?:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
189
|
+
onCreate?:
|
|
190
|
+
| ((this: {
|
|
191
|
+
name: string
|
|
192
|
+
options: Options
|
|
193
|
+
storage: Storage
|
|
194
|
+
editor: Editor
|
|
195
|
+
type: NodeType
|
|
196
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['onCreate']
|
|
197
|
+
}) => void)
|
|
198
|
+
| null
|
|
161
199
|
|
|
162
200
|
/**
|
|
163
201
|
* The content has changed.
|
|
164
202
|
*/
|
|
165
|
-
onUpdate?:
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
203
|
+
onUpdate?:
|
|
204
|
+
| ((this: {
|
|
205
|
+
name: string
|
|
206
|
+
options: Options
|
|
207
|
+
storage: Storage
|
|
208
|
+
editor: Editor
|
|
209
|
+
type: NodeType
|
|
210
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['onUpdate']
|
|
211
|
+
}) => void)
|
|
212
|
+
| null
|
|
172
213
|
|
|
173
214
|
/**
|
|
174
215
|
* The selection has changed.
|
|
175
216
|
*/
|
|
176
|
-
onSelectionUpdate?:
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
217
|
+
onSelectionUpdate?:
|
|
218
|
+
| ((this: {
|
|
219
|
+
name: string
|
|
220
|
+
options: Options
|
|
221
|
+
storage: Storage
|
|
222
|
+
editor: Editor
|
|
223
|
+
type: NodeType
|
|
224
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['onSelectionUpdate']
|
|
225
|
+
}) => void)
|
|
226
|
+
| null
|
|
183
227
|
|
|
184
228
|
/**
|
|
185
229
|
* The editor state has changed.
|
|
186
230
|
*/
|
|
187
|
-
onTransaction?:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
231
|
+
onTransaction?:
|
|
232
|
+
| ((
|
|
233
|
+
this: {
|
|
234
|
+
name: string
|
|
235
|
+
options: Options
|
|
236
|
+
storage: Storage
|
|
237
|
+
editor: Editor
|
|
238
|
+
type: NodeType
|
|
239
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['onTransaction']
|
|
240
|
+
},
|
|
241
|
+
props: {
|
|
242
|
+
transaction: Transaction
|
|
243
|
+
},
|
|
244
|
+
) => void)
|
|
245
|
+
| null
|
|
199
246
|
|
|
200
247
|
/**
|
|
201
248
|
* The editor is focused.
|
|
202
249
|
*/
|
|
203
|
-
onFocus?:
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
250
|
+
onFocus?:
|
|
251
|
+
| ((
|
|
252
|
+
this: {
|
|
253
|
+
name: string
|
|
254
|
+
options: Options
|
|
255
|
+
storage: Storage
|
|
256
|
+
editor: Editor
|
|
257
|
+
type: NodeType
|
|
258
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['onFocus']
|
|
259
|
+
},
|
|
260
|
+
props: {
|
|
261
|
+
event: FocusEvent
|
|
262
|
+
},
|
|
263
|
+
) => void)
|
|
264
|
+
| null
|
|
215
265
|
|
|
216
266
|
/**
|
|
217
267
|
* The editor isn’t focused anymore.
|
|
218
268
|
*/
|
|
219
|
-
onBlur?:
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
269
|
+
onBlur?:
|
|
270
|
+
| ((
|
|
271
|
+
this: {
|
|
272
|
+
name: string
|
|
273
|
+
options: Options
|
|
274
|
+
storage: Storage
|
|
275
|
+
editor: Editor
|
|
276
|
+
type: NodeType
|
|
277
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['onBlur']
|
|
278
|
+
},
|
|
279
|
+
props: {
|
|
280
|
+
event: FocusEvent
|
|
281
|
+
},
|
|
282
|
+
) => void)
|
|
283
|
+
| null
|
|
231
284
|
|
|
232
285
|
/**
|
|
233
286
|
* The editor is destroyed.
|
|
234
287
|
*/
|
|
235
|
-
onDestroy?:
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
288
|
+
onDestroy?:
|
|
289
|
+
| ((this: {
|
|
290
|
+
name: string
|
|
291
|
+
options: Options
|
|
292
|
+
storage: Storage
|
|
293
|
+
editor: Editor
|
|
294
|
+
type: NodeType
|
|
295
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['onDestroy']
|
|
296
|
+
}) => void)
|
|
297
|
+
| null
|
|
242
298
|
|
|
243
299
|
/**
|
|
244
300
|
* Node View
|
|
245
301
|
*/
|
|
246
|
-
addNodeView?:
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
302
|
+
addNodeView?:
|
|
303
|
+
| ((this: {
|
|
304
|
+
name: string
|
|
305
|
+
options: Options
|
|
306
|
+
storage: Storage
|
|
307
|
+
editor: Editor
|
|
308
|
+
type: NodeType
|
|
309
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addNodeView']
|
|
310
|
+
}) => NodeViewRenderer)
|
|
311
|
+
| null
|
|
253
312
|
|
|
254
313
|
/**
|
|
255
314
|
* TopNode
|
|
256
315
|
*/
|
|
257
|
-
topNode?: boolean
|
|
316
|
+
topNode?: boolean
|
|
258
317
|
|
|
259
318
|
/**
|
|
260
319
|
* Content
|
|
261
320
|
*/
|
|
262
|
-
content?:
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
321
|
+
content?:
|
|
322
|
+
| NodeSpec['content']
|
|
323
|
+
| ((this: {
|
|
324
|
+
name: string
|
|
325
|
+
options: Options
|
|
326
|
+
storage: Storage
|
|
327
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['content']
|
|
328
|
+
}) => NodeSpec['content'])
|
|
267
329
|
|
|
268
330
|
/**
|
|
269
331
|
* Marks
|
|
270
332
|
*/
|
|
271
|
-
marks?:
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
333
|
+
marks?:
|
|
334
|
+
| NodeSpec['marks']
|
|
335
|
+
| ((this: {
|
|
336
|
+
name: string
|
|
337
|
+
options: Options
|
|
338
|
+
storage: Storage
|
|
339
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['marks']
|
|
340
|
+
}) => NodeSpec['marks'])
|
|
276
341
|
|
|
277
342
|
/**
|
|
278
343
|
* Group
|
|
279
344
|
*/
|
|
280
|
-
group?:
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
345
|
+
group?:
|
|
346
|
+
| NodeSpec['group']
|
|
347
|
+
| ((this: {
|
|
348
|
+
name: string
|
|
349
|
+
options: Options
|
|
350
|
+
storage: Storage
|
|
351
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['group']
|
|
352
|
+
}) => NodeSpec['group'])
|
|
285
353
|
|
|
286
354
|
/**
|
|
287
355
|
* Inline
|
|
288
356
|
*/
|
|
289
|
-
inline?:
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
357
|
+
inline?:
|
|
358
|
+
| NodeSpec['inline']
|
|
359
|
+
| ((this: {
|
|
360
|
+
name: string
|
|
361
|
+
options: Options
|
|
362
|
+
storage: Storage
|
|
363
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['inline']
|
|
364
|
+
}) => NodeSpec['inline'])
|
|
294
365
|
|
|
295
366
|
/**
|
|
296
367
|
* Atom
|
|
297
368
|
*/
|
|
298
|
-
atom?:
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
369
|
+
atom?:
|
|
370
|
+
| NodeSpec['atom']
|
|
371
|
+
| ((this: {
|
|
372
|
+
name: string
|
|
373
|
+
options: Options
|
|
374
|
+
storage: Storage
|
|
375
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['atom']
|
|
376
|
+
}) => NodeSpec['atom'])
|
|
303
377
|
|
|
304
378
|
/**
|
|
305
379
|
* Selectable
|
|
306
380
|
*/
|
|
307
|
-
selectable?:
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
381
|
+
selectable?:
|
|
382
|
+
| NodeSpec['selectable']
|
|
383
|
+
| ((this: {
|
|
384
|
+
name: string
|
|
385
|
+
options: Options
|
|
386
|
+
storage: Storage
|
|
387
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['selectable']
|
|
388
|
+
}) => NodeSpec['selectable'])
|
|
312
389
|
|
|
313
390
|
/**
|
|
314
391
|
* Draggable
|
|
315
392
|
*/
|
|
316
|
-
draggable?:
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
393
|
+
draggable?:
|
|
394
|
+
| NodeSpec['draggable']
|
|
395
|
+
| ((this: {
|
|
396
|
+
name: string
|
|
397
|
+
options: Options
|
|
398
|
+
storage: Storage
|
|
399
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['draggable']
|
|
400
|
+
}) => NodeSpec['draggable'])
|
|
321
401
|
|
|
322
402
|
/**
|
|
323
403
|
* Code
|
|
324
404
|
*/
|
|
325
|
-
code?:
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
405
|
+
code?:
|
|
406
|
+
| NodeSpec['code']
|
|
407
|
+
| ((this: {
|
|
408
|
+
name: string
|
|
409
|
+
options: Options
|
|
410
|
+
storage: Storage
|
|
411
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['code']
|
|
412
|
+
}) => NodeSpec['code'])
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Whitespace
|
|
416
|
+
*/
|
|
417
|
+
whitespace?:
|
|
418
|
+
| NodeSpec['whitespace']
|
|
419
|
+
| ((this: {
|
|
420
|
+
name: string
|
|
421
|
+
options: Options
|
|
422
|
+
storage: Storage
|
|
423
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['whitespace']
|
|
424
|
+
}) => NodeSpec['whitespace'])
|
|
330
425
|
|
|
331
426
|
/**
|
|
332
427
|
* Defining
|
|
333
428
|
*/
|
|
334
|
-
defining?:
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
429
|
+
defining?:
|
|
430
|
+
| NodeSpec['defining']
|
|
431
|
+
| ((this: {
|
|
432
|
+
name: string
|
|
433
|
+
options: Options
|
|
434
|
+
storage: Storage
|
|
435
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['defining']
|
|
436
|
+
}) => NodeSpec['defining'])
|
|
339
437
|
|
|
340
438
|
/**
|
|
341
439
|
* Isolating
|
|
342
440
|
*/
|
|
343
|
-
isolating?:
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
441
|
+
isolating?:
|
|
442
|
+
| NodeSpec['isolating']
|
|
443
|
+
| ((this: {
|
|
444
|
+
name: string
|
|
445
|
+
options: Options
|
|
446
|
+
storage: Storage
|
|
447
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['isolating']
|
|
448
|
+
}) => NodeSpec['isolating'])
|
|
348
449
|
|
|
349
450
|
/**
|
|
350
451
|
* Parse HTML
|
|
351
452
|
*/
|
|
352
|
-
parseHTML?: (
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
) => NodeSpec['parseDOM'],
|
|
453
|
+
parseHTML?: (this: {
|
|
454
|
+
name: string
|
|
455
|
+
options: Options
|
|
456
|
+
storage: Storage
|
|
457
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['parseHTML']
|
|
458
|
+
}) => NodeSpec['parseDOM']
|
|
359
459
|
|
|
360
460
|
/**
|
|
361
461
|
* Render HTML
|
|
362
462
|
*/
|
|
363
|
-
renderHTML?:
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
463
|
+
renderHTML?:
|
|
464
|
+
| ((
|
|
465
|
+
this: {
|
|
466
|
+
name: string
|
|
467
|
+
options: Options
|
|
468
|
+
storage: Storage
|
|
469
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['renderHTML']
|
|
470
|
+
},
|
|
471
|
+
props: {
|
|
472
|
+
node: ProseMirrorNode
|
|
473
|
+
HTMLAttributes: Record<string, any>
|
|
474
|
+
},
|
|
475
|
+
) => DOMOutputSpec)
|
|
476
|
+
| null
|
|
374
477
|
|
|
375
478
|
/**
|
|
376
479
|
* Render Text
|
|
377
480
|
*/
|
|
378
|
-
renderText?:
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
481
|
+
renderText?:
|
|
482
|
+
| ((
|
|
483
|
+
this: {
|
|
484
|
+
name: string
|
|
485
|
+
options: Options
|
|
486
|
+
storage: Storage
|
|
487
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['renderText']
|
|
488
|
+
},
|
|
489
|
+
props: {
|
|
490
|
+
node: ProseMirrorNode
|
|
491
|
+
pos: number
|
|
492
|
+
parent: ProseMirrorNode
|
|
493
|
+
index: number
|
|
494
|
+
},
|
|
495
|
+
) => string)
|
|
496
|
+
| null
|
|
390
497
|
|
|
391
498
|
/**
|
|
392
499
|
* Add Attributes
|
|
393
500
|
*/
|
|
394
|
-
addAttributes?: (
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
) => Attributes | {},
|
|
501
|
+
addAttributes?: (this: {
|
|
502
|
+
name: string
|
|
503
|
+
options: Options
|
|
504
|
+
storage: Storage
|
|
505
|
+
parent: ParentConfig<NodeConfig<Options, Storage>>['addAttributes']
|
|
506
|
+
}) => Attributes | {}
|
|
401
507
|
}
|
|
402
508
|
}
|
|
403
509
|
|
|
404
|
-
export class Node<Options = any> {
|
|
510
|
+
export class Node<Options = any, Storage = any> {
|
|
405
511
|
type = 'node'
|
|
406
512
|
|
|
407
513
|
name = 'node'
|
|
@@ -412,23 +518,48 @@ export class Node<Options = any> {
|
|
|
412
518
|
|
|
413
519
|
options: Options
|
|
414
520
|
|
|
521
|
+
storage: Storage
|
|
522
|
+
|
|
415
523
|
config: NodeConfig = {
|
|
416
524
|
name: this.name,
|
|
417
525
|
defaultOptions: {},
|
|
418
526
|
}
|
|
419
527
|
|
|
420
|
-
constructor(config: Partial<NodeConfig<Options>> = {}) {
|
|
528
|
+
constructor(config: Partial<NodeConfig<Options, Storage>> = {}) {
|
|
421
529
|
this.config = {
|
|
422
530
|
...this.config,
|
|
423
531
|
...config,
|
|
424
532
|
}
|
|
425
533
|
|
|
426
534
|
this.name = this.config.name
|
|
535
|
+
|
|
536
|
+
if (config.defaultOptions) {
|
|
537
|
+
console.warn(
|
|
538
|
+
`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`,
|
|
539
|
+
)
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// TODO: remove `addOptions` fallback
|
|
427
543
|
this.options = this.config.defaultOptions
|
|
544
|
+
|
|
545
|
+
if (this.config.addOptions) {
|
|
546
|
+
this.options = callOrReturn(
|
|
547
|
+
getExtensionField<AnyConfig['addOptions']>(this, 'addOptions', {
|
|
548
|
+
name: this.name,
|
|
549
|
+
}),
|
|
550
|
+
)
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
this.storage = callOrReturn(
|
|
554
|
+
getExtensionField<AnyConfig['addStorage']>(this, 'addStorage', {
|
|
555
|
+
name: this.name,
|
|
556
|
+
options: this.options,
|
|
557
|
+
}),
|
|
558
|
+
) || {}
|
|
428
559
|
}
|
|
429
560
|
|
|
430
|
-
static create<O>(config: Partial<NodeConfig<O>> = {}) {
|
|
431
|
-
return new Node<O>(config)
|
|
561
|
+
static create<O = any, S = any>(config: Partial<NodeConfig<O, S>> = {}) {
|
|
562
|
+
return new Node<O, S>(config)
|
|
432
563
|
}
|
|
433
564
|
|
|
434
565
|
configure(options: Partial<Options> = {}) {
|
|
@@ -436,25 +567,47 @@ export class Node<Options = any> {
|
|
|
436
567
|
// with different calls of `configure`
|
|
437
568
|
const extension = this.extend()
|
|
438
569
|
|
|
439
|
-
extension.options = mergeDeep(this.options, options) as Options
|
|
570
|
+
extension.options = mergeDeep(this.options as Record<string, any>, options) as Options
|
|
571
|
+
|
|
572
|
+
extension.storage = callOrReturn(
|
|
573
|
+
getExtensionField<AnyConfig['addStorage']>(extension, 'addStorage', {
|
|
574
|
+
name: extension.name,
|
|
575
|
+
options: extension.options,
|
|
576
|
+
}),
|
|
577
|
+
)
|
|
440
578
|
|
|
441
579
|
return extension
|
|
442
580
|
}
|
|
443
581
|
|
|
444
|
-
extend<ExtendedOptions = Options
|
|
445
|
-
|
|
582
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage>(
|
|
583
|
+
extendedConfig: Partial<NodeConfig<ExtendedOptions, ExtendedStorage>> = {},
|
|
584
|
+
) {
|
|
585
|
+
const extension = new Node<ExtendedOptions, ExtendedStorage>(extendedConfig)
|
|
446
586
|
|
|
447
587
|
extension.parent = this
|
|
448
588
|
|
|
449
589
|
this.child = extension
|
|
450
590
|
|
|
451
|
-
extension.name = extendedConfig.name
|
|
452
|
-
|
|
453
|
-
|
|
591
|
+
extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name
|
|
592
|
+
|
|
593
|
+
if (extendedConfig.defaultOptions) {
|
|
594
|
+
console.warn(
|
|
595
|
+
`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`,
|
|
596
|
+
)
|
|
597
|
+
}
|
|
454
598
|
|
|
455
|
-
extension.options =
|
|
456
|
-
|
|
457
|
-
|
|
599
|
+
extension.options = callOrReturn(
|
|
600
|
+
getExtensionField<AnyConfig['addOptions']>(extension, 'addOptions', {
|
|
601
|
+
name: extension.name,
|
|
602
|
+
}),
|
|
603
|
+
)
|
|
604
|
+
|
|
605
|
+
extension.storage = callOrReturn(
|
|
606
|
+
getExtensionField<AnyConfig['addStorage']>(extension, 'addStorage', {
|
|
607
|
+
name: extension.name,
|
|
608
|
+
options: extension.options,
|
|
609
|
+
}),
|
|
610
|
+
)
|
|
458
611
|
|
|
459
612
|
return extension
|
|
460
613
|
}
|