@tiptap/core 2.0.0-beta.209 → 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/dist/index.cjs +4311 -0
- package/dist/index.d.ts +2330 -0
- package/dist/index.js +4311 -0
- package/package.json +24 -23
- package/src/CommandManager.ts +27 -36
- package/src/Editor.ts +27 -37
- package/src/Extension.ts +193 -179
- package/src/ExtensionManager.ts +82 -98
- package/src/InputRule.ts +38 -43
- package/src/Mark.ts +277 -264
- package/src/Node.ts +349 -314
- package/src/NodeView.ts +24 -23
- package/src/PasteRule.ts +37 -44
- package/src/Tracker.ts +4 -8
- package/src/commands/clearNodes.ts +1 -1
- package/src/commands/createParagraphNear.ts +2 -2
- package/src/commands/deleteNode.ts +1 -1
- package/src/commands/deleteSelection.ts +2 -2
- package/src/commands/exitCode.ts +2 -2
- package/src/commands/extendMarkRange.ts +6 -3
- package/src/commands/insertContent.ts +9 -5
- package/src/commands/insertContentAt.ts +10 -24
- package/src/commands/join.ts +9 -6
- package/src/commands/lift.ts +3 -3
- package/src/commands/liftEmptyBlock.ts +1 -1
- package/src/commands/liftListItem.ts +3 -3
- package/src/commands/newlineInCode.ts +2 -2
- package/src/commands/resetAttributes.ts +11 -6
- package/src/commands/selectNodeBackward.ts +2 -2
- package/src/commands/selectNodeForward.ts +2 -2
- package/src/commands/selectParentNode.ts +2 -2
- package/src/commands/selectTextblockEnd.ts +2 -2
- package/src/commands/selectTextblockStart.ts +2 -2
- package/src/commands/setContent.ts +3 -4
- package/src/commands/setMark.ts +26 -16
- package/src/commands/setNode.ts +19 -17
- package/src/commands/setNodeSelection.ts +2 -2
- package/src/commands/setTextSelection.ts +3 -5
- package/src/commands/sinkListItem.ts +3 -3
- package/src/commands/splitBlock.ts +20 -25
- package/src/commands/splitListItem.ts +15 -25
- package/src/commands/toggleList.ts +27 -24
- package/src/commands/toggleMark.ts +3 -3
- package/src/commands/toggleNode.ts +6 -2
- package/src/commands/toggleWrap.ts +2 -2
- package/src/commands/unsetMark.ts +3 -3
- package/src/commands/updateAttributes.ts +14 -9
- package/src/commands/wrapIn.ts +3 -3
- package/src/commands/wrapInList.ts +3 -3
- package/src/extensions/clipboardTextSerializer.ts +1 -1
- package/src/extensions/editable.ts +1 -1
- package/src/extensions/focusEvents.ts +1 -1
- package/src/extensions/keymap.ts +2 -7
- package/src/extensions/tabindex.ts +1 -1
- package/src/helpers/combineTransactionSteps.ts +7 -4
- package/src/helpers/createChainableState.ts +3 -3
- package/src/helpers/createDocument.ts +1 -1
- package/src/helpers/createNodeFromContent.ts +4 -10
- package/src/helpers/defaultBlockAt.ts +1 -1
- package/src/helpers/findChildren.ts +1 -1
- package/src/helpers/findChildrenInRange.ts +6 -2
- package/src/helpers/findParentNode.ts +1 -1
- package/src/helpers/findParentNodeClosestToPos.ts +12 -7
- package/src/helpers/generateHTML.ts +1 -1
- package/src/helpers/generateJSON.ts +2 -4
- package/src/helpers/generateText.ts +4 -7
- package/src/helpers/getAttributes.ts +3 -5
- package/src/helpers/getChangedRanges.ts +1 -1
- package/src/helpers/getDebugJSON.ts +4 -4
- package/src/helpers/getHTMLFromFragment.ts +2 -4
- package/src/helpers/getMarkAttributes.ts +6 -3
- package/src/helpers/getMarkRange.ts +1 -1
- package/src/helpers/getMarkType.ts +4 -2
- package/src/helpers/getMarksBetween.ts +8 -6
- package/src/helpers/getNodeAttributes.ts +7 -6
- package/src/helpers/getNodeType.ts +4 -2
- package/src/helpers/getRenderedAttributes.ts +5 -2
- package/src/helpers/getSchema.ts +1 -1
- package/src/helpers/getSchemaByResolvedExtensions.ts +151 -107
- package/src/helpers/getSchemaTypeByName.ts +1 -1
- package/src/helpers/getSchemaTypeNameByName.ts +1 -1
- package/src/helpers/getText.ts +3 -3
- package/src/helpers/getTextBetween.ts +4 -7
- package/src/helpers/getTextContentFromNodes.ts +8 -3
- package/src/helpers/getTextSerializersFromSchema.ts +6 -5
- package/src/helpers/injectExtensionAttributesToParseRule.ts +6 -5
- package/src/helpers/isActive.ts +6 -2
- package/src/helpers/isMarkActive.ts +12 -15
- package/src/helpers/isNodeActive.ts +4 -7
- package/src/helpers/isNodeEmpty.ts +1 -1
- package/src/helpers/isNodeSelection.ts +1 -1
- package/src/helpers/isTextSelection.ts +1 -1
- package/src/helpers/posToDOMRect.ts +1 -1
- package/src/helpers/resolveFocusPosition.ts +2 -3
- package/src/helpers/selectionToInsertionEnd.ts +2 -2
- package/src/inputRules/markInputRule.ts +3 -4
- package/src/inputRules/nodeInputRule.ts +3 -4
- package/src/inputRules/textblockTypeInputRule.ts +3 -4
- package/src/inputRules/wrappingInputRule.ts +5 -6
- package/src/pasteRules/markPasteRule.ts +3 -4
- package/src/pasteRules/nodePasteRule.ts +8 -10
- package/src/types.ts +109 -125
- package/dist/packages/core/src/CommandManager.d.ts +0 -20
- package/dist/packages/core/src/Editor.d.ts +0 -147
- package/dist/packages/core/src/EventEmitter.d.ts +0 -11
- package/dist/packages/core/src/Extension.d.ts +0 -227
- package/dist/packages/core/src/ExtensionManager.d.ts +0 -18
- package/dist/packages/core/src/InputRule.d.ts +0 -42
- package/dist/packages/core/src/Mark.d.ts +0 -327
- package/dist/packages/core/src/Node.d.ts +0 -397
- package/dist/packages/core/src/NodeView.d.ts +0 -27
- package/dist/packages/core/src/PasteRule.d.ts +0 -42
- package/dist/packages/core/src/Tracker.d.ts +0 -11
- 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/deleteCurrentNode.d.ts +0 -12
- package/dist/packages/core/src/commands/deleteNode.d.ts +0 -13
- 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 -14
- package/dist/packages/core/src/commands/forEach.d.ts +0 -14
- package/dist/packages/core/src/commands/index.d.ts +0 -50
- package/dist/packages/core/src/commands/insertContent.d.ts +0 -16
- package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -16
- package/dist/packages/core/src/commands/join.d.ts +0 -33
- 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/resetAttributes.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/selectTextblockEnd.d.ts +0 -12
- package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -12
- package/dist/packages/core/src/commands/setContent.d.ts +0 -13
- package/dist/packages/core/src/commands/setMark.d.ts +0 -13
- package/dist/packages/core/src/commands/setMeta.d.ts +0 -12
- package/dist/packages/core/src/commands/setNode.d.ts +0 -13
- package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -12
- package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -12
- 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 -18
- 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 -18
- package/dist/packages/core/src/commands/updateAttributes.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 -3
- package/dist/packages/core/src/extensions/editable.d.ts +0 -2
- package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
- package/dist/packages/core/src/extensions/index.d.ts +0 -6
- package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
- package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
- package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -7
- package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -5
- package/dist/packages/core/src/helpers/createDocument.d.ts +0 -3
- package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -7
- package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -2
- package/dist/packages/core/src/helpers/findChildren.d.ts +0 -3
- package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -6
- package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -8
- 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/generateJSON.d.ts +0 -2
- package/dist/packages/core/src/helpers/generateText.d.ts +0 -5
- package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
- package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
- package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
- package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -2
- package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
- package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
- package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
- package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
- package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
- package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
- package/dist/packages/core/src/helpers/getSchema.d.ts +0 -3
- package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.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/getText.d.ts +0 -6
- package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -6
- package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -2
- package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -3
- package/dist/packages/core/src/helpers/index.d.ts +0 -33
- package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
- package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
- package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
- package/dist/packages/core/src/helpers/isList.d.ts +0 -2
- package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
- package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
- package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -2
- package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
- package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
- package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
- package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
- package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
- package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
- package/dist/packages/core/src/index.d.ts +0 -23
- package/dist/packages/core/src/inputRules/index.d.ts +0 -5
- package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -12
- package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -12
- package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -9
- package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -14
- package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -23
- package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
- package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -12
- package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -12
- package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -9
- package/dist/packages/core/src/style.d.ts +0 -1
- package/dist/packages/core/src/types.d.ts +0 -214
- package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
- package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
- package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
- package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
- package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
- package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
- package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
- package/dist/packages/core/src/utilities/index.d.ts +0 -20
- package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
- package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
- package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
- package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
- package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
- package/dist/packages/core/src/utilities/isString.d.ts +0 -1
- package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
- package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
- package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
- package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
- package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
- package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
- package/dist/tiptap-core.cjs +0 -4360
- package/dist/tiptap-core.cjs.map +0 -1
- package/dist/tiptap-core.esm.js +0 -4284
- package/dist/tiptap-core.esm.js.map +0 -1
- package/dist/tiptap-core.umd.js +0 -4358
- package/dist/tiptap-core.umd.js.map +0 -1
package/src/Extension.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin, Transaction } from '
|
|
1
|
+
import { Plugin, Transaction } from '@tiptap/pm/state'
|
|
2
2
|
|
|
3
3
|
import { ExtensionConfig } from '.'
|
|
4
4
|
import { Editor } from './Editor'
|
|
@@ -20,245 +20,265 @@ import { mergeDeep } from './utilities/mergeDeep'
|
|
|
20
20
|
|
|
21
21
|
declare module '@tiptap/core' {
|
|
22
22
|
interface ExtensionConfig<Options = any, Storage = any> {
|
|
23
|
-
[key: string]: any
|
|
23
|
+
[key: string]: any
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Name
|
|
27
27
|
*/
|
|
28
|
-
name: string
|
|
28
|
+
name: string
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Priority
|
|
32
32
|
*/
|
|
33
|
-
priority?: number
|
|
33
|
+
priority?: number
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* Default options
|
|
37
37
|
*/
|
|
38
|
-
defaultOptions?: Options
|
|
38
|
+
defaultOptions?: Options
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Default Options
|
|
42
42
|
*/
|
|
43
43
|
addOptions?: (this: {
|
|
44
|
-
name: string
|
|
45
|
-
parent: Exclude<ParentConfig<ExtensionConfig<Options, Storage>>['addOptions'], undefined
|
|
46
|
-
}) => Options
|
|
44
|
+
name: string
|
|
45
|
+
parent: Exclude<ParentConfig<ExtensionConfig<Options, Storage>>['addOptions'], undefined>
|
|
46
|
+
}) => Options
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Default Storage
|
|
50
50
|
*/
|
|
51
51
|
addStorage?: (this: {
|
|
52
|
-
name: string
|
|
53
|
-
options: Options
|
|
54
|
-
parent: Exclude<ParentConfig<ExtensionConfig<Options, Storage>>['addStorage'], undefined
|
|
55
|
-
}) => Storage
|
|
52
|
+
name: string
|
|
53
|
+
options: Options
|
|
54
|
+
parent: Exclude<ParentConfig<ExtensionConfig<Options, Storage>>['addStorage'], undefined>
|
|
55
|
+
}) => Storage
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* Global attributes
|
|
59
59
|
*/
|
|
60
60
|
addGlobalAttributes?: (this: {
|
|
61
|
-
name: string
|
|
62
|
-
options: Options
|
|
63
|
-
storage: Storage
|
|
64
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addGlobalAttributes']
|
|
65
|
-
}) => GlobalAttributes | {}
|
|
61
|
+
name: string
|
|
62
|
+
options: Options
|
|
63
|
+
storage: Storage
|
|
64
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addGlobalAttributes']
|
|
65
|
+
}) => GlobalAttributes | {}
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* Raw
|
|
69
69
|
*/
|
|
70
70
|
addCommands?: (this: {
|
|
71
|
-
name: string
|
|
72
|
-
options: Options
|
|
73
|
-
storage: Storage
|
|
74
|
-
editor: Editor
|
|
75
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addCommands']
|
|
76
|
-
}) => Partial<RawCommands
|
|
71
|
+
name: string
|
|
72
|
+
options: Options
|
|
73
|
+
storage: Storage
|
|
74
|
+
editor: Editor
|
|
75
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addCommands']
|
|
76
|
+
}) => Partial<RawCommands>
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* Keyboard shortcuts
|
|
80
80
|
*/
|
|
81
81
|
addKeyboardShortcuts?: (this: {
|
|
82
|
-
name: string
|
|
83
|
-
options: Options
|
|
84
|
-
storage: Storage
|
|
85
|
-
editor: Editor
|
|
86
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addKeyboardShortcuts']
|
|
82
|
+
name: string
|
|
83
|
+
options: Options
|
|
84
|
+
storage: Storage
|
|
85
|
+
editor: Editor
|
|
86
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addKeyboardShortcuts']
|
|
87
87
|
}) => {
|
|
88
|
-
[key: string]: KeyboardShortcutCommand
|
|
89
|
-
}
|
|
88
|
+
[key: string]: KeyboardShortcutCommand
|
|
89
|
+
}
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* Input rules
|
|
93
93
|
*/
|
|
94
94
|
addInputRules?: (this: {
|
|
95
|
-
name: string
|
|
96
|
-
options: Options
|
|
97
|
-
storage: Storage
|
|
98
|
-
editor: Editor
|
|
99
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addInputRules']
|
|
100
|
-
}) => InputRule[]
|
|
95
|
+
name: string
|
|
96
|
+
options: Options
|
|
97
|
+
storage: Storage
|
|
98
|
+
editor: Editor
|
|
99
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addInputRules']
|
|
100
|
+
}) => InputRule[]
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
103
|
* Paste rules
|
|
104
104
|
*/
|
|
105
105
|
addPasteRules?: (this: {
|
|
106
|
-
name: string
|
|
107
|
-
options: Options
|
|
108
|
-
storage: Storage
|
|
109
|
-
editor: Editor
|
|
110
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addPasteRules']
|
|
111
|
-
}) => PasteRule[]
|
|
106
|
+
name: string
|
|
107
|
+
options: Options
|
|
108
|
+
storage: Storage
|
|
109
|
+
editor: Editor
|
|
110
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addPasteRules']
|
|
111
|
+
}) => PasteRule[]
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
114
|
* ProseMirror plugins
|
|
115
115
|
*/
|
|
116
116
|
addProseMirrorPlugins?: (this: {
|
|
117
|
-
name: string
|
|
118
|
-
options: Options
|
|
119
|
-
storage: Storage
|
|
120
|
-
editor: Editor
|
|
121
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addProseMirrorPlugins']
|
|
122
|
-
}) => Plugin[]
|
|
117
|
+
name: string
|
|
118
|
+
options: Options
|
|
119
|
+
storage: Storage
|
|
120
|
+
editor: Editor
|
|
121
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addProseMirrorPlugins']
|
|
122
|
+
}) => Plugin[]
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* Extensions
|
|
126
126
|
*/
|
|
127
127
|
addExtensions?: (this: {
|
|
128
|
-
name: string
|
|
129
|
-
options: Options
|
|
130
|
-
storage: Storage
|
|
131
|
-
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addExtensions']
|
|
132
|
-
}) => Extensions
|
|
128
|
+
name: string
|
|
129
|
+
options: Options
|
|
130
|
+
storage: Storage
|
|
131
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['addExtensions']
|
|
132
|
+
}) => Extensions
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
135
|
* Extend Node Schema
|
|
136
136
|
*/
|
|
137
|
-
extendNodeSchema?:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
137
|
+
extendNodeSchema?:
|
|
138
|
+
| ((
|
|
139
|
+
this: {
|
|
140
|
+
name: string
|
|
141
|
+
options: Options
|
|
142
|
+
storage: Storage
|
|
143
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['extendNodeSchema']
|
|
144
|
+
},
|
|
145
|
+
extension: Node,
|
|
146
|
+
) => Record<string, any>)
|
|
147
|
+
| null
|
|
146
148
|
|
|
147
149
|
/**
|
|
148
150
|
* Extend Mark Schema
|
|
149
151
|
*/
|
|
150
|
-
extendMarkSchema?:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
152
|
+
extendMarkSchema?:
|
|
153
|
+
| ((
|
|
154
|
+
this: {
|
|
155
|
+
name: string
|
|
156
|
+
options: Options
|
|
157
|
+
storage: Storage
|
|
158
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['extendMarkSchema']
|
|
159
|
+
},
|
|
160
|
+
extension: Mark,
|
|
161
|
+
) => Record<string, any>)
|
|
162
|
+
| null
|
|
159
163
|
|
|
160
164
|
/**
|
|
161
165
|
* The editor is not ready yet.
|
|
162
166
|
*/
|
|
163
|
-
onBeforeCreate?:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
onBeforeCreate?:
|
|
168
|
+
| ((this: {
|
|
169
|
+
name: string
|
|
170
|
+
options: Options
|
|
171
|
+
storage: Storage
|
|
172
|
+
editor: Editor
|
|
173
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onBeforeCreate']
|
|
174
|
+
}) => void)
|
|
175
|
+
| null
|
|
170
176
|
|
|
171
177
|
/**
|
|
172
178
|
* The editor is ready.
|
|
173
179
|
*/
|
|
174
|
-
onCreate?:
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
onCreate?:
|
|
181
|
+
| ((this: {
|
|
182
|
+
name: string
|
|
183
|
+
options: Options
|
|
184
|
+
storage: Storage
|
|
185
|
+
editor: Editor
|
|
186
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onCreate']
|
|
187
|
+
}) => void)
|
|
188
|
+
| null
|
|
181
189
|
|
|
182
190
|
/**
|
|
183
191
|
* The content has changed.
|
|
184
192
|
*/
|
|
185
|
-
onUpdate?:
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
193
|
+
onUpdate?:
|
|
194
|
+
| ((this: {
|
|
195
|
+
name: string
|
|
196
|
+
options: Options
|
|
197
|
+
storage: Storage
|
|
198
|
+
editor: Editor
|
|
199
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onUpdate']
|
|
200
|
+
}) => void)
|
|
201
|
+
| null
|
|
192
202
|
|
|
193
203
|
/**
|
|
194
204
|
* The selection has changed.
|
|
195
205
|
*/
|
|
196
|
-
onSelectionUpdate?:
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
206
|
+
onSelectionUpdate?:
|
|
207
|
+
| ((this: {
|
|
208
|
+
name: string
|
|
209
|
+
options: Options
|
|
210
|
+
storage: Storage
|
|
211
|
+
editor: Editor
|
|
212
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onSelectionUpdate']
|
|
213
|
+
}) => void)
|
|
214
|
+
| null
|
|
203
215
|
|
|
204
216
|
/**
|
|
205
217
|
* The editor state has changed.
|
|
206
218
|
*/
|
|
207
|
-
onTransaction?:
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
+
onTransaction?:
|
|
220
|
+
| ((
|
|
221
|
+
this: {
|
|
222
|
+
name: string
|
|
223
|
+
options: Options
|
|
224
|
+
storage: Storage
|
|
225
|
+
editor: Editor
|
|
226
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onTransaction']
|
|
227
|
+
},
|
|
228
|
+
props: {
|
|
229
|
+
transaction: Transaction
|
|
230
|
+
},
|
|
231
|
+
) => void)
|
|
232
|
+
| null
|
|
219
233
|
|
|
220
234
|
/**
|
|
221
235
|
* The editor is focused.
|
|
222
236
|
*/
|
|
223
|
-
onFocus?:
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
237
|
+
onFocus?:
|
|
238
|
+
| ((
|
|
239
|
+
this: {
|
|
240
|
+
name: string
|
|
241
|
+
options: Options
|
|
242
|
+
storage: Storage
|
|
243
|
+
editor: Editor
|
|
244
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onFocus']
|
|
245
|
+
},
|
|
246
|
+
props: {
|
|
247
|
+
event: FocusEvent
|
|
248
|
+
},
|
|
249
|
+
) => void)
|
|
250
|
+
| null
|
|
235
251
|
|
|
236
252
|
/**
|
|
237
253
|
* The editor isn’t focused anymore.
|
|
238
254
|
*/
|
|
239
|
-
onBlur?:
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
255
|
+
onBlur?:
|
|
256
|
+
| ((
|
|
257
|
+
this: {
|
|
258
|
+
name: string
|
|
259
|
+
options: Options
|
|
260
|
+
storage: Storage
|
|
261
|
+
editor: Editor
|
|
262
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onBlur']
|
|
263
|
+
},
|
|
264
|
+
props: {
|
|
265
|
+
event: FocusEvent
|
|
266
|
+
},
|
|
267
|
+
) => void)
|
|
268
|
+
| null
|
|
251
269
|
|
|
252
270
|
/**
|
|
253
271
|
* The editor is destroyed.
|
|
254
272
|
*/
|
|
255
|
-
onDestroy?:
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
273
|
+
onDestroy?:
|
|
274
|
+
| ((this: {
|
|
275
|
+
name: string
|
|
276
|
+
options: Options
|
|
277
|
+
storage: Storage
|
|
278
|
+
editor: Editor
|
|
279
|
+
parent: ParentConfig<ExtensionConfig<Options, Storage>>['onDestroy']
|
|
280
|
+
}) => void)
|
|
281
|
+
| null
|
|
262
282
|
}
|
|
263
283
|
}
|
|
264
284
|
|
|
@@ -289,30 +309,28 @@ export class Extension<Options = any, Storage = any> {
|
|
|
289
309
|
this.name = this.config.name
|
|
290
310
|
|
|
291
311
|
if (config.defaultOptions) {
|
|
292
|
-
console.warn(
|
|
312
|
+
console.warn(
|
|
313
|
+
`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`,
|
|
314
|
+
)
|
|
293
315
|
}
|
|
294
316
|
|
|
295
317
|
// TODO: remove `addOptions` fallback
|
|
296
318
|
this.options = this.config.defaultOptions
|
|
297
319
|
|
|
298
320
|
if (this.config.addOptions) {
|
|
299
|
-
this.options = callOrReturn(
|
|
300
|
-
this,
|
|
301
|
-
'addOptions',
|
|
302
|
-
{
|
|
321
|
+
this.options = callOrReturn(
|
|
322
|
+
getExtensionField<AnyConfig['addOptions']>(this, 'addOptions', {
|
|
303
323
|
name: this.name,
|
|
304
|
-
},
|
|
305
|
-
)
|
|
324
|
+
}),
|
|
325
|
+
)
|
|
306
326
|
}
|
|
307
327
|
|
|
308
|
-
this.storage = callOrReturn(
|
|
309
|
-
this,
|
|
310
|
-
'addStorage',
|
|
311
|
-
{
|
|
328
|
+
this.storage = callOrReturn(
|
|
329
|
+
getExtensionField<AnyConfig['addStorage']>(this, 'addStorage', {
|
|
312
330
|
name: this.name,
|
|
313
331
|
options: this.options,
|
|
314
|
-
},
|
|
315
|
-
)
|
|
332
|
+
}),
|
|
333
|
+
) || {}
|
|
316
334
|
}
|
|
317
335
|
|
|
318
336
|
static create<O = any, S = any>(config: Partial<ExtensionConfig<O, S>> = {}) {
|
|
@@ -324,51 +342,47 @@ export class Extension<Options = any, Storage = any> {
|
|
|
324
342
|
// with different calls of `configure`
|
|
325
343
|
const extension = this.extend()
|
|
326
344
|
|
|
327
|
-
extension.options = mergeDeep(this.options, options) as Options
|
|
345
|
+
extension.options = mergeDeep(this.options as Record<string, any>, options) as Options
|
|
328
346
|
|
|
329
|
-
extension.storage = callOrReturn(
|
|
330
|
-
extension,
|
|
331
|
-
'addStorage',
|
|
332
|
-
{
|
|
347
|
+
extension.storage = callOrReturn(
|
|
348
|
+
getExtensionField<AnyConfig['addStorage']>(extension, 'addStorage', {
|
|
333
349
|
name: extension.name,
|
|
334
350
|
options: extension.options,
|
|
335
|
-
},
|
|
336
|
-
)
|
|
351
|
+
}),
|
|
352
|
+
)
|
|
337
353
|
|
|
338
354
|
return extension
|
|
339
355
|
}
|
|
340
356
|
|
|
341
|
-
extend<ExtendedOptions = Options, ExtendedStorage = Storage>(
|
|
357
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage>(
|
|
358
|
+
extendedConfig: Partial<ExtensionConfig<ExtendedOptions, ExtendedStorage>> = {},
|
|
359
|
+
) {
|
|
342
360
|
const extension = new Extension<ExtendedOptions, ExtendedStorage>(extendedConfig)
|
|
343
361
|
|
|
344
362
|
extension.parent = this
|
|
345
363
|
|
|
346
364
|
this.child = extension
|
|
347
365
|
|
|
348
|
-
extension.name = extendedConfig.name
|
|
349
|
-
? extendedConfig.name
|
|
350
|
-
: extension.parent.name
|
|
366
|
+
extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name
|
|
351
367
|
|
|
352
368
|
if (extendedConfig.defaultOptions) {
|
|
353
|
-
console.warn(
|
|
369
|
+
console.warn(
|
|
370
|
+
`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`,
|
|
371
|
+
)
|
|
354
372
|
}
|
|
355
373
|
|
|
356
|
-
extension.options = callOrReturn(
|
|
357
|
-
extension,
|
|
358
|
-
'addOptions',
|
|
359
|
-
{
|
|
374
|
+
extension.options = callOrReturn(
|
|
375
|
+
getExtensionField<AnyConfig['addOptions']>(extension, 'addOptions', {
|
|
360
376
|
name: extension.name,
|
|
361
|
-
},
|
|
362
|
-
)
|
|
377
|
+
}),
|
|
378
|
+
)
|
|
363
379
|
|
|
364
|
-
extension.storage = callOrReturn(
|
|
365
|
-
extension,
|
|
366
|
-
'addStorage',
|
|
367
|
-
{
|
|
380
|
+
extension.storage = callOrReturn(
|
|
381
|
+
getExtensionField<AnyConfig['addStorage']>(extension, 'addStorage', {
|
|
368
382
|
name: extension.name,
|
|
369
383
|
options: extension.options,
|
|
370
|
-
},
|
|
371
|
-
)
|
|
384
|
+
}),
|
|
385
|
+
)
|
|
372
386
|
|
|
373
387
|
return extension
|
|
374
388
|
}
|