@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.
Files changed (259) hide show
  1. package/dist/index.cjs +4311 -0
  2. package/dist/index.d.ts +2330 -0
  3. package/dist/index.js +4311 -0
  4. package/package.json +24 -23
  5. package/src/CommandManager.ts +27 -36
  6. package/src/Editor.ts +27 -37
  7. package/src/Extension.ts +193 -179
  8. package/src/ExtensionManager.ts +82 -98
  9. package/src/InputRule.ts +38 -43
  10. package/src/Mark.ts +277 -264
  11. package/src/Node.ts +349 -314
  12. package/src/NodeView.ts +24 -23
  13. package/src/PasteRule.ts +37 -44
  14. package/src/Tracker.ts +4 -8
  15. package/src/commands/clearNodes.ts +1 -1
  16. package/src/commands/createParagraphNear.ts +2 -2
  17. package/src/commands/deleteNode.ts +1 -1
  18. package/src/commands/deleteSelection.ts +2 -2
  19. package/src/commands/exitCode.ts +2 -2
  20. package/src/commands/extendMarkRange.ts +6 -3
  21. package/src/commands/insertContent.ts +9 -5
  22. package/src/commands/insertContentAt.ts +10 -24
  23. package/src/commands/join.ts +9 -6
  24. package/src/commands/lift.ts +3 -3
  25. package/src/commands/liftEmptyBlock.ts +1 -1
  26. package/src/commands/liftListItem.ts +3 -3
  27. package/src/commands/newlineInCode.ts +2 -2
  28. package/src/commands/resetAttributes.ts +11 -6
  29. package/src/commands/selectNodeBackward.ts +2 -2
  30. package/src/commands/selectNodeForward.ts +2 -2
  31. package/src/commands/selectParentNode.ts +2 -2
  32. package/src/commands/selectTextblockEnd.ts +2 -2
  33. package/src/commands/selectTextblockStart.ts +2 -2
  34. package/src/commands/setContent.ts +3 -4
  35. package/src/commands/setMark.ts +26 -16
  36. package/src/commands/setNode.ts +19 -17
  37. package/src/commands/setNodeSelection.ts +2 -2
  38. package/src/commands/setTextSelection.ts +3 -5
  39. package/src/commands/sinkListItem.ts +3 -3
  40. package/src/commands/splitBlock.ts +20 -25
  41. package/src/commands/splitListItem.ts +15 -25
  42. package/src/commands/toggleList.ts +27 -24
  43. package/src/commands/toggleMark.ts +3 -3
  44. package/src/commands/toggleNode.ts +6 -2
  45. package/src/commands/toggleWrap.ts +2 -2
  46. package/src/commands/unsetMark.ts +3 -3
  47. package/src/commands/updateAttributes.ts +14 -9
  48. package/src/commands/wrapIn.ts +3 -3
  49. package/src/commands/wrapInList.ts +3 -3
  50. package/src/extensions/clipboardTextSerializer.ts +1 -1
  51. package/src/extensions/editable.ts +1 -1
  52. package/src/extensions/focusEvents.ts +1 -1
  53. package/src/extensions/keymap.ts +2 -7
  54. package/src/extensions/tabindex.ts +1 -1
  55. package/src/helpers/combineTransactionSteps.ts +7 -4
  56. package/src/helpers/createChainableState.ts +3 -3
  57. package/src/helpers/createDocument.ts +1 -1
  58. package/src/helpers/createNodeFromContent.ts +4 -10
  59. package/src/helpers/defaultBlockAt.ts +1 -1
  60. package/src/helpers/findChildren.ts +1 -1
  61. package/src/helpers/findChildrenInRange.ts +6 -2
  62. package/src/helpers/findParentNode.ts +1 -1
  63. package/src/helpers/findParentNodeClosestToPos.ts +12 -7
  64. package/src/helpers/generateHTML.ts +1 -1
  65. package/src/helpers/generateJSON.ts +2 -4
  66. package/src/helpers/generateText.ts +4 -7
  67. package/src/helpers/getAttributes.ts +3 -5
  68. package/src/helpers/getChangedRanges.ts +1 -1
  69. package/src/helpers/getDebugJSON.ts +4 -4
  70. package/src/helpers/getHTMLFromFragment.ts +2 -4
  71. package/src/helpers/getMarkAttributes.ts +6 -3
  72. package/src/helpers/getMarkRange.ts +1 -1
  73. package/src/helpers/getMarkType.ts +4 -2
  74. package/src/helpers/getMarksBetween.ts +8 -6
  75. package/src/helpers/getNodeAttributes.ts +7 -6
  76. package/src/helpers/getNodeType.ts +4 -2
  77. package/src/helpers/getRenderedAttributes.ts +5 -2
  78. package/src/helpers/getSchema.ts +1 -1
  79. package/src/helpers/getSchemaByResolvedExtensions.ts +151 -107
  80. package/src/helpers/getSchemaTypeByName.ts +1 -1
  81. package/src/helpers/getSchemaTypeNameByName.ts +1 -1
  82. package/src/helpers/getText.ts +3 -3
  83. package/src/helpers/getTextBetween.ts +4 -7
  84. package/src/helpers/getTextContentFromNodes.ts +8 -3
  85. package/src/helpers/getTextSerializersFromSchema.ts +6 -5
  86. package/src/helpers/injectExtensionAttributesToParseRule.ts +6 -5
  87. package/src/helpers/isActive.ts +6 -2
  88. package/src/helpers/isMarkActive.ts +12 -15
  89. package/src/helpers/isNodeActive.ts +4 -7
  90. package/src/helpers/isNodeEmpty.ts +1 -1
  91. package/src/helpers/isNodeSelection.ts +1 -1
  92. package/src/helpers/isTextSelection.ts +1 -1
  93. package/src/helpers/posToDOMRect.ts +1 -1
  94. package/src/helpers/resolveFocusPosition.ts +2 -3
  95. package/src/helpers/selectionToInsertionEnd.ts +2 -2
  96. package/src/inputRules/markInputRule.ts +3 -4
  97. package/src/inputRules/nodeInputRule.ts +3 -4
  98. package/src/inputRules/textblockTypeInputRule.ts +3 -4
  99. package/src/inputRules/wrappingInputRule.ts +5 -6
  100. package/src/pasteRules/markPasteRule.ts +3 -4
  101. package/src/pasteRules/nodePasteRule.ts +8 -10
  102. package/src/types.ts +109 -125
  103. package/dist/packages/core/src/CommandManager.d.ts +0 -20
  104. package/dist/packages/core/src/Editor.d.ts +0 -147
  105. package/dist/packages/core/src/EventEmitter.d.ts +0 -11
  106. package/dist/packages/core/src/Extension.d.ts +0 -227
  107. package/dist/packages/core/src/ExtensionManager.d.ts +0 -18
  108. package/dist/packages/core/src/InputRule.d.ts +0 -42
  109. package/dist/packages/core/src/Mark.d.ts +0 -327
  110. package/dist/packages/core/src/Node.d.ts +0 -397
  111. package/dist/packages/core/src/NodeView.d.ts +0 -27
  112. package/dist/packages/core/src/PasteRule.d.ts +0 -42
  113. package/dist/packages/core/src/Tracker.d.ts +0 -11
  114. package/dist/packages/core/src/commands/blur.d.ts +0 -12
  115. package/dist/packages/core/src/commands/clearContent.d.ts +0 -12
  116. package/dist/packages/core/src/commands/clearNodes.d.ts +0 -12
  117. package/dist/packages/core/src/commands/command.d.ts +0 -12
  118. package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -12
  119. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -12
  120. package/dist/packages/core/src/commands/deleteNode.d.ts +0 -13
  121. package/dist/packages/core/src/commands/deleteRange.d.ts +0 -12
  122. package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -12
  123. package/dist/packages/core/src/commands/enter.d.ts +0 -12
  124. package/dist/packages/core/src/commands/exitCode.d.ts +0 -12
  125. package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -13
  126. package/dist/packages/core/src/commands/first.d.ts +0 -12
  127. package/dist/packages/core/src/commands/focus.d.ts +0 -14
  128. package/dist/packages/core/src/commands/forEach.d.ts +0 -14
  129. package/dist/packages/core/src/commands/index.d.ts +0 -50
  130. package/dist/packages/core/src/commands/insertContent.d.ts +0 -16
  131. package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -16
  132. package/dist/packages/core/src/commands/join.d.ts +0 -33
  133. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -12
  134. package/dist/packages/core/src/commands/lift.d.ts +0 -13
  135. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -12
  136. package/dist/packages/core/src/commands/liftListItem.d.ts +0 -13
  137. package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -12
  138. package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -13
  139. package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -12
  140. package/dist/packages/core/src/commands/selectAll.d.ts +0 -12
  141. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -12
  142. package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -12
  143. package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -12
  144. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -12
  145. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -12
  146. package/dist/packages/core/src/commands/setContent.d.ts +0 -13
  147. package/dist/packages/core/src/commands/setMark.d.ts +0 -13
  148. package/dist/packages/core/src/commands/setMeta.d.ts +0 -12
  149. package/dist/packages/core/src/commands/setNode.d.ts +0 -13
  150. package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -12
  151. package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -12
  152. package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -13
  153. package/dist/packages/core/src/commands/splitBlock.d.ts +0 -14
  154. package/dist/packages/core/src/commands/splitListItem.d.ts +0 -13
  155. package/dist/packages/core/src/commands/toggleList.d.ts +0 -13
  156. package/dist/packages/core/src/commands/toggleMark.d.ts +0 -18
  157. package/dist/packages/core/src/commands/toggleNode.d.ts +0 -13
  158. package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -13
  159. package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -12
  160. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -12
  161. package/dist/packages/core/src/commands/unsetMark.d.ts +0 -18
  162. package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -13
  163. package/dist/packages/core/src/commands/wrapIn.d.ts +0 -13
  164. package/dist/packages/core/src/commands/wrapInList.d.ts +0 -13
  165. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -2
  166. package/dist/packages/core/src/extensions/commands.d.ts +0 -3
  167. package/dist/packages/core/src/extensions/editable.d.ts +0 -2
  168. package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
  169. package/dist/packages/core/src/extensions/index.d.ts +0 -6
  170. package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
  171. package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
  172. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -7
  173. package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -5
  174. package/dist/packages/core/src/helpers/createDocument.d.ts +0 -3
  175. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -7
  176. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -2
  177. package/dist/packages/core/src/helpers/findChildren.d.ts +0 -3
  178. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -6
  179. package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -8
  180. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -8
  181. package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -2
  182. package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -2
  183. package/dist/packages/core/src/helpers/generateText.d.ts +0 -5
  184. package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -3
  185. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
  186. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
  187. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
  188. package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -2
  189. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
  190. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
  191. package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
  192. package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
  193. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
  194. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
  195. package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
  196. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
  197. package/dist/packages/core/src/helpers/getSchema.d.ts +0 -3
  198. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -3
  199. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -2
  200. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -2
  201. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -2
  202. package/dist/packages/core/src/helpers/getText.d.ts +0 -6
  203. package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -6
  204. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -2
  205. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -3
  206. package/dist/packages/core/src/helpers/index.d.ts +0 -33
  207. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
  208. package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
  209. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
  210. package/dist/packages/core/src/helpers/isList.d.ts +0 -2
  211. package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
  212. package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
  213. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -2
  214. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
  215. package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
  216. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
  217. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
  218. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
  219. package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
  220. package/dist/packages/core/src/index.d.ts +0 -23
  221. package/dist/packages/core/src/inputRules/index.d.ts +0 -5
  222. package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -12
  223. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -12
  224. package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -9
  225. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -14
  226. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -23
  227. package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
  228. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -12
  229. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -12
  230. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -9
  231. package/dist/packages/core/src/style.d.ts +0 -1
  232. package/dist/packages/core/src/types.d.ts +0 -214
  233. package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
  234. package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
  235. package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
  236. package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
  237. package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
  238. package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
  239. package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
  240. package/dist/packages/core/src/utilities/index.d.ts +0 -20
  241. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
  242. package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
  243. package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
  244. package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
  245. package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
  246. package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
  247. package/dist/packages/core/src/utilities/isString.d.ts +0 -1
  248. package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
  249. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
  250. package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
  251. package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
  252. package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
  253. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
  254. package/dist/tiptap-core.cjs +0 -4360
  255. package/dist/tiptap-core.cjs.map +0 -1
  256. package/dist/tiptap-core.esm.js +0 -4284
  257. package/dist/tiptap-core.esm.js.map +0 -1
  258. package/dist/tiptap-core.umd.js +0 -4358
  259. package/dist/tiptap-core.umd.js.map +0 -1
package/src/Mark.ts CHANGED
@@ -1,10 +1,7 @@
1
1
  import {
2
- DOMOutputSpec,
3
- Mark as ProseMirrorMark,
4
- MarkSpec,
5
- MarkType,
6
- } from 'prosemirror-model'
7
- import { Plugin, Transaction } from 'prosemirror-state'
2
+ DOMOutputSpec, Mark as ProseMirrorMark, MarkSpec, MarkType,
3
+ } from '@tiptap/pm/model'
4
+ import { Plugin, Transaction } from '@tiptap/pm/state'
8
5
 
9
6
  import { MarkConfig } from '.'
10
7
  import { Editor } from './Editor'
@@ -26,358 +23,386 @@ import { mergeDeep } from './utilities/mergeDeep'
26
23
 
27
24
  declare module '@tiptap/core' {
28
25
  export interface MarkConfig<Options = any, Storage = any> {
29
- [key: string]: any;
26
+ [key: string]: any
30
27
 
31
28
  /**
32
29
  * Name
33
30
  */
34
- name: string,
31
+ name: string
35
32
 
36
33
  /**
37
34
  * Priority
38
35
  */
39
- priority?: number,
36
+ priority?: number
40
37
 
41
38
  /**
42
39
  * Default options
43
40
  */
44
- defaultOptions?: Options,
41
+ defaultOptions?: Options
45
42
 
46
43
  /**
47
44
  * Default Options
48
45
  */
49
46
  addOptions?: (this: {
50
- name: string,
51
- parent: Exclude<ParentConfig<MarkConfig<Options, Storage>>['addOptions'], undefined>,
52
- }) => Options,
47
+ name: string
48
+ parent: Exclude<ParentConfig<MarkConfig<Options, Storage>>['addOptions'], undefined>
49
+ }) => Options
53
50
 
54
51
  /**
55
52
  * Default Storage
56
53
  */
57
54
  addStorage?: (this: {
58
- name: string,
59
- options: Options,
60
- parent: Exclude<ParentConfig<MarkConfig<Options, Storage>>['addStorage'], undefined>,
61
- }) => Storage,
55
+ name: string
56
+ options: Options
57
+ parent: Exclude<ParentConfig<MarkConfig<Options, Storage>>['addStorage'], undefined>
58
+ }) => Storage
62
59
 
63
60
  /**
64
61
  * Global attributes
65
62
  */
66
63
  addGlobalAttributes?: (this: {
67
- name: string,
68
- options: Options,
69
- storage: Storage,
70
- parent: ParentConfig<MarkConfig<Options, Storage>>['addGlobalAttributes'],
71
- }) => GlobalAttributes | {},
64
+ name: string
65
+ options: Options
66
+ storage: Storage
67
+ parent: ParentConfig<MarkConfig<Options, Storage>>['addGlobalAttributes']
68
+ }) => GlobalAttributes | {}
72
69
 
73
70
  /**
74
71
  * Raw
75
72
  */
76
73
  addCommands?: (this: {
77
- name: string,
78
- options: Options,
79
- storage: Storage,
80
- editor: Editor,
81
- type: MarkType,
82
- parent: ParentConfig<MarkConfig<Options, Storage>>['addCommands'],
83
- }) => Partial<RawCommands>,
74
+ name: string
75
+ options: Options
76
+ storage: Storage
77
+ editor: Editor
78
+ type: MarkType
79
+ parent: ParentConfig<MarkConfig<Options, Storage>>['addCommands']
80
+ }) => Partial<RawCommands>
84
81
 
85
82
  /**
86
83
  * Keyboard shortcuts
87
84
  */
88
85
  addKeyboardShortcuts?: (this: {
89
- name: string,
90
- options: Options,
91
- storage: Storage,
92
- editor: Editor,
93
- type: MarkType,
94
- parent: ParentConfig<MarkConfig<Options, Storage>>['addKeyboardShortcuts'],
86
+ name: string
87
+ options: Options
88
+ storage: Storage
89
+ editor: Editor
90
+ type: MarkType
91
+ parent: ParentConfig<MarkConfig<Options, Storage>>['addKeyboardShortcuts']
95
92
  }) => {
96
- [key: string]: KeyboardShortcutCommand,
97
- },
93
+ [key: string]: KeyboardShortcutCommand
94
+ }
98
95
 
99
96
  /**
100
97
  * Input rules
101
98
  */
102
99
  addInputRules?: (this: {
103
- name: string,
104
- options: Options,
105
- storage: Storage,
106
- editor: Editor,
107
- type: MarkType,
108
- parent: ParentConfig<MarkConfig<Options, Storage>>['addInputRules'],
109
- }) => InputRule[],
100
+ name: string
101
+ options: Options
102
+ storage: Storage
103
+ editor: Editor
104
+ type: MarkType
105
+ parent: ParentConfig<MarkConfig<Options, Storage>>['addInputRules']
106
+ }) => InputRule[]
110
107
 
111
108
  /**
112
109
  * Paste rules
113
110
  */
114
111
  addPasteRules?: (this: {
115
- name: string,
116
- options: Options,
117
- storage: Storage,
118
- editor: Editor,
119
- type: MarkType,
120
- parent: ParentConfig<MarkConfig<Options, Storage>>['addPasteRules'],
121
- }) => PasteRule[],
112
+ name: string
113
+ options: Options
114
+ storage: Storage
115
+ editor: Editor
116
+ type: MarkType
117
+ parent: ParentConfig<MarkConfig<Options, Storage>>['addPasteRules']
118
+ }) => PasteRule[]
122
119
 
123
120
  /**
124
121
  * ProseMirror plugins
125
122
  */
126
123
  addProseMirrorPlugins?: (this: {
127
- name: string,
128
- options: Options,
129
- storage: Storage,
130
- editor: Editor,
131
- type: MarkType,
132
- parent: ParentConfig<MarkConfig<Options, Storage>>['addProseMirrorPlugins'],
133
- }) => Plugin[],
124
+ name: string
125
+ options: Options
126
+ storage: Storage
127
+ editor: Editor
128
+ type: MarkType
129
+ parent: ParentConfig<MarkConfig<Options, Storage>>['addProseMirrorPlugins']
130
+ }) => Plugin[]
134
131
 
135
132
  /**
136
133
  * Extensions
137
134
  */
138
135
  addExtensions?: (this: {
139
- name: string,
140
- options: Options,
141
- storage: Storage,
142
- parent: ParentConfig<MarkConfig<Options, Storage>>['addExtensions'],
143
- }) => Extensions,
136
+ name: string
137
+ options: Options
138
+ storage: Storage
139
+ parent: ParentConfig<MarkConfig<Options, Storage>>['addExtensions']
140
+ }) => Extensions
144
141
 
145
142
  /**
146
143
  * Extend Node Schema
147
144
  */
148
- extendNodeSchema?: ((
149
- this: {
150
- name: string,
151
- options: Options,
152
- storage: Storage,
153
- parent: ParentConfig<MarkConfig<Options, Storage>>['extendNodeSchema'],
154
- },
155
- extension: Node,
156
- ) => Record<string, any>) | null,
145
+ extendNodeSchema?:
146
+ | ((
147
+ this: {
148
+ name: string
149
+ options: Options
150
+ storage: Storage
151
+ parent: ParentConfig<MarkConfig<Options, Storage>>['extendNodeSchema']
152
+ },
153
+ extension: Node,
154
+ ) => Record<string, any>)
155
+ | null
157
156
 
158
157
  /**
159
158
  * Extend Mark Schema
160
159
  */
161
- extendMarkSchema?: ((
162
- this: {
163
- name: string,
164
- options: Options,
165
- storage: Storage,
166
- parent: ParentConfig<MarkConfig<Options, Storage>>['extendMarkSchema'],
167
- },
168
- extension: Mark,
169
- ) => Record<string, any>) | null,
160
+ extendMarkSchema?:
161
+ | ((
162
+ this: {
163
+ name: string
164
+ options: Options
165
+ storage: Storage
166
+ parent: ParentConfig<MarkConfig<Options, Storage>>['extendMarkSchema']
167
+ },
168
+ extension: Mark,
169
+ ) => Record<string, any>)
170
+ | null
170
171
 
171
172
  /**
172
173
  * The editor is not ready yet.
173
174
  */
174
- onBeforeCreate?: ((this: {
175
- name: string,
176
- options: Options,
177
- storage: Storage,
178
- editor: Editor,
179
- type: MarkType,
180
- parent: ParentConfig<MarkConfig<Options, Storage>>['onBeforeCreate'],
181
- }) => void) | null,
175
+ onBeforeCreate?:
176
+ | ((this: {
177
+ name: string
178
+ options: Options
179
+ storage: Storage
180
+ editor: Editor
181
+ type: MarkType
182
+ parent: ParentConfig<MarkConfig<Options, Storage>>['onBeforeCreate']
183
+ }) => void)
184
+ | null
182
185
 
183
186
  /**
184
187
  * The editor is ready.
185
188
  */
186
- onCreate?: ((this: {
187
- name: string,
188
- options: Options,
189
- storage: Storage,
190
- editor: Editor,
191
- type: MarkType,
192
- parent: ParentConfig<MarkConfig<Options, Storage>>['onCreate'],
193
- }) => void) | null,
189
+ onCreate?:
190
+ | ((this: {
191
+ name: string
192
+ options: Options
193
+ storage: Storage
194
+ editor: Editor
195
+ type: MarkType
196
+ parent: ParentConfig<MarkConfig<Options, Storage>>['onCreate']
197
+ }) => void)
198
+ | null
194
199
 
195
200
  /**
196
201
  * The content has changed.
197
202
  */
198
- onUpdate?: ((this: {
199
- name: string,
200
- options: Options,
201
- storage: Storage,
202
- editor: Editor,
203
- type: MarkType,
204
- parent: ParentConfig<MarkConfig<Options, Storage>>['onUpdate'],
205
- }) => void) | null,
203
+ onUpdate?:
204
+ | ((this: {
205
+ name: string
206
+ options: Options
207
+ storage: Storage
208
+ editor: Editor
209
+ type: MarkType
210
+ parent: ParentConfig<MarkConfig<Options, Storage>>['onUpdate']
211
+ }) => void)
212
+ | null
206
213
 
207
214
  /**
208
215
  * The selection has changed.
209
216
  */
210
- onSelectionUpdate?: ((this: {
211
- name: string,
212
- options: Options,
213
- storage: Storage,
214
- editor: Editor,
215
- type: MarkType,
216
- parent: ParentConfig<MarkConfig<Options, Storage>>['onSelectionUpdate'],
217
- }) => void) | null,
217
+ onSelectionUpdate?:
218
+ | ((this: {
219
+ name: string
220
+ options: Options
221
+ storage: Storage
222
+ editor: Editor
223
+ type: MarkType
224
+ parent: ParentConfig<MarkConfig<Options, Storage>>['onSelectionUpdate']
225
+ }) => void)
226
+ | null
218
227
 
219
228
  /**
220
229
  * The editor state has changed.
221
230
  */
222
- onTransaction?: ((
223
- this: {
224
- name: string,
225
- options: Options,
226
- storage: Storage,
227
- editor: Editor,
228
- type: MarkType,
229
- parent: ParentConfig<MarkConfig<Options, Storage>>['onTransaction'],
230
- },
231
- props: {
232
- transaction: Transaction,
233
- },
234
- ) => void) | null,
231
+ onTransaction?:
232
+ | ((
233
+ this: {
234
+ name: string
235
+ options: Options
236
+ storage: Storage
237
+ editor: Editor
238
+ type: MarkType
239
+ parent: ParentConfig<MarkConfig<Options, Storage>>['onTransaction']
240
+ },
241
+ props: {
242
+ transaction: Transaction
243
+ },
244
+ ) => void)
245
+ | null
235
246
 
236
247
  /**
237
248
  * The editor is focused.
238
249
  */
239
- onFocus?: ((
240
- this: {
241
- name: string,
242
- options: Options,
243
- storage: Storage,
244
- editor: Editor,
245
- type: MarkType,
246
- parent: ParentConfig<MarkConfig<Options, Storage>>['onFocus'],
247
- },
248
- props: {
249
- event: FocusEvent,
250
- },
251
- ) => void) | null,
250
+ onFocus?:
251
+ | ((
252
+ this: {
253
+ name: string
254
+ options: Options
255
+ storage: Storage
256
+ editor: Editor
257
+ type: MarkType
258
+ parent: ParentConfig<MarkConfig<Options, Storage>>['onFocus']
259
+ },
260
+ props: {
261
+ event: FocusEvent
262
+ },
263
+ ) => void)
264
+ | null
252
265
 
253
266
  /**
254
267
  * The editor isn’t focused anymore.
255
268
  */
256
- onBlur?: ((
257
- this: {
258
- name: string,
259
- options: Options,
260
- storage: Storage,
261
- editor: Editor,
262
- type: MarkType,
263
- parent: ParentConfig<MarkConfig<Options, Storage>>['onBlur'],
264
- },
265
- props: {
266
- event: FocusEvent,
267
- },
268
- ) => void) | null,
269
+ onBlur?:
270
+ | ((
271
+ this: {
272
+ name: string
273
+ options: Options
274
+ storage: Storage
275
+ editor: Editor
276
+ type: MarkType
277
+ parent: ParentConfig<MarkConfig<Options, Storage>>['onBlur']
278
+ },
279
+ props: {
280
+ event: FocusEvent
281
+ },
282
+ ) => void)
283
+ | null
269
284
 
270
285
  /**
271
286
  * The editor is destroyed.
272
287
  */
273
- onDestroy?: ((this: {
274
- name: string,
275
- options: Options,
276
- storage: Storage,
277
- editor: Editor,
278
- type: MarkType,
279
- parent: ParentConfig<MarkConfig<Options, Storage>>['onDestroy'],
280
- }) => void) | null,
288
+ onDestroy?:
289
+ | ((this: {
290
+ name: string
291
+ options: Options
292
+ storage: Storage
293
+ editor: Editor
294
+ type: MarkType
295
+ parent: ParentConfig<MarkConfig<Options, Storage>>['onDestroy']
296
+ }) => void)
297
+ | null
281
298
 
282
299
  /**
283
300
  * Keep mark after split node
284
301
  */
285
- keepOnSplit?: boolean | (() => boolean),
302
+ keepOnSplit?: boolean | (() => boolean)
286
303
 
287
304
  /**
288
305
  * Inclusive
289
306
  */
290
- inclusive?: MarkSpec['inclusive'] | ((this: {
291
- name: string,
292
- options: Options,
293
- storage: Storage,
294
- parent: ParentConfig<MarkConfig<Options, Storage>>['inclusive'],
295
- }) => MarkSpec['inclusive']),
307
+ inclusive?:
308
+ | MarkSpec['inclusive']
309
+ | ((this: {
310
+ name: string
311
+ options: Options
312
+ storage: Storage
313
+ parent: ParentConfig<MarkConfig<Options, Storage>>['inclusive']
314
+ }) => MarkSpec['inclusive'])
296
315
 
297
316
  /**
298
317
  * Excludes
299
318
  */
300
- excludes?: MarkSpec['excludes'] | ((this: {
301
- name: string,
302
- options: Options,
303
- storage: Storage,
304
- parent: ParentConfig<MarkConfig<Options, Storage>>['excludes'],
305
- }) => MarkSpec['excludes']),
319
+ excludes?:
320
+ | MarkSpec['excludes']
321
+ | ((this: {
322
+ name: string
323
+ options: Options
324
+ storage: Storage
325
+ parent: ParentConfig<MarkConfig<Options, Storage>>['excludes']
326
+ }) => MarkSpec['excludes'])
306
327
 
307
328
  /**
308
329
  * Marks this Mark as exitable
309
330
  */
310
- exitable?: boolean | (() => boolean),
331
+ exitable?: boolean | (() => boolean)
311
332
 
312
333
  /**
313
334
  * Group
314
335
  */
315
- group?: MarkSpec['group'] | ((this: {
316
- name: string,
317
- options: Options,
318
- storage: Storage,
319
- parent: ParentConfig<MarkConfig<Options, Storage>>['group'],
320
- }) => MarkSpec['group']),
336
+ group?:
337
+ | MarkSpec['group']
338
+ | ((this: {
339
+ name: string
340
+ options: Options
341
+ storage: Storage
342
+ parent: ParentConfig<MarkConfig<Options, Storage>>['group']
343
+ }) => MarkSpec['group'])
321
344
 
322
345
  /**
323
346
  * Spanning
324
347
  */
325
- spanning?: MarkSpec['spanning'] | ((this: {
326
- name: string,
327
- options: Options,
328
- storage: Storage,
329
- parent: ParentConfig<MarkConfig<Options, Storage>>['spanning'],
330
- }) => MarkSpec['spanning']),
348
+ spanning?:
349
+ | MarkSpec['spanning']
350
+ | ((this: {
351
+ name: string
352
+ options: Options
353
+ storage: Storage
354
+ parent: ParentConfig<MarkConfig<Options, Storage>>['spanning']
355
+ }) => MarkSpec['spanning'])
331
356
 
332
357
  /**
333
358
  * Code
334
359
  */
335
- code?: boolean | ((this: {
336
- name: string,
337
- options: Options,
338
- storage: Storage,
339
- parent: ParentConfig<MarkConfig<Options, Storage>>['code'],
340
- }) => boolean),
360
+ code?:
361
+ | boolean
362
+ | ((this: {
363
+ name: string
364
+ options: Options
365
+ storage: Storage
366
+ parent: ParentConfig<MarkConfig<Options, Storage>>['code']
367
+ }) => boolean)
341
368
 
342
369
  /**
343
370
  * Parse HTML
344
371
  */
345
- parseHTML?: (
346
- this: {
347
- name: string,
348
- options: Options,
349
- storage: Storage,
350
- parent: ParentConfig<MarkConfig<Options, Storage>>['parseHTML'],
351
- },
352
- ) => MarkSpec['parseDOM'],
372
+ parseHTML?: (this: {
373
+ name: string
374
+ options: Options
375
+ storage: Storage
376
+ parent: ParentConfig<MarkConfig<Options, Storage>>['parseHTML']
377
+ }) => MarkSpec['parseDOM']
353
378
 
354
379
  /**
355
380
  * Render HTML
356
381
  */
357
- renderHTML?: ((
358
- this: {
359
- name: string,
360
- options: Options,
361
- storage: Storage,
362
- parent: ParentConfig<MarkConfig<Options, Storage>>['renderHTML'],
363
- },
364
- props: {
365
- mark: ProseMirrorMark,
366
- HTMLAttributes: Record<string, any>,
367
- },
368
- ) => DOMOutputSpec) | null,
382
+ renderHTML?:
383
+ | ((
384
+ this: {
385
+ name: string
386
+ options: Options
387
+ storage: Storage
388
+ parent: ParentConfig<MarkConfig<Options, Storage>>['renderHTML']
389
+ },
390
+ props: {
391
+ mark: ProseMirrorMark
392
+ HTMLAttributes: Record<string, any>
393
+ },
394
+ ) => DOMOutputSpec)
395
+ | null
369
396
 
370
397
  /**
371
398
  * Attributes
372
399
  */
373
- addAttributes?: (
374
- this: {
375
- name: string,
376
- options: Options,
377
- storage: Storage,
378
- parent: ParentConfig<MarkConfig<Options, Storage>>['addAttributes'],
379
- },
380
- ) => Attributes | {},
400
+ addAttributes?: (this: {
401
+ name: string
402
+ options: Options
403
+ storage: Storage
404
+ parent: ParentConfig<MarkConfig<Options, Storage>>['addAttributes']
405
+ }) => Attributes | {}
381
406
  }
382
407
  }
383
408
 
@@ -408,30 +433,28 @@ export class Mark<Options = any, Storage = any> {
408
433
  this.name = this.config.name
409
434
 
410
435
  if (config.defaultOptions) {
411
- console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`)
436
+ console.warn(
437
+ `[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`,
438
+ )
412
439
  }
413
440
 
414
441
  // TODO: remove `addOptions` fallback
415
442
  this.options = this.config.defaultOptions
416
443
 
417
444
  if (this.config.addOptions) {
418
- this.options = callOrReturn(getExtensionField<AnyConfig['addOptions']>(
419
- this,
420
- 'addOptions',
421
- {
445
+ this.options = callOrReturn(
446
+ getExtensionField<AnyConfig['addOptions']>(this, 'addOptions', {
422
447
  name: this.name,
423
- },
424
- ))
448
+ }),
449
+ )
425
450
  }
426
451
 
427
- this.storage = callOrReturn(getExtensionField<AnyConfig['addStorage']>(
428
- this,
429
- 'addStorage',
430
- {
452
+ this.storage = callOrReturn(
453
+ getExtensionField<AnyConfig['addStorage']>(this, 'addStorage', {
431
454
  name: this.name,
432
455
  options: this.options,
433
- },
434
- )) || {}
456
+ }),
457
+ ) || {}
435
458
  }
436
459
 
437
460
  static create<O = any, S = any>(config: Partial<MarkConfig<O, S>> = {}) {
@@ -443,62 +466,52 @@ export class Mark<Options = any, Storage = any> {
443
466
  // with different calls of `configure`
444
467
  const extension = this.extend()
445
468
 
446
- extension.options = mergeDeep(this.options, options) as Options
469
+ extension.options = mergeDeep(this.options as Record<string, any>, options) as Options
447
470
 
448
- extension.storage = callOrReturn(getExtensionField<AnyConfig['addStorage']>(
449
- extension,
450
- 'addStorage',
451
- {
471
+ extension.storage = callOrReturn(
472
+ getExtensionField<AnyConfig['addStorage']>(extension, 'addStorage', {
452
473
  name: extension.name,
453
474
  options: extension.options,
454
- },
455
- ))
475
+ }),
476
+ )
456
477
 
457
478
  return extension
458
479
  }
459
480
 
460
- extend<ExtendedOptions = Options, ExtendedStorage = Storage>(extendedConfig: Partial<MarkConfig<ExtendedOptions, ExtendedStorage>> = {}) {
481
+ extend<ExtendedOptions = Options, ExtendedStorage = Storage>(
482
+ extendedConfig: Partial<MarkConfig<ExtendedOptions, ExtendedStorage>> = {},
483
+ ) {
461
484
  const extension = new Mark<ExtendedOptions, ExtendedStorage>(extendedConfig)
462
485
 
463
486
  extension.parent = this
464
487
 
465
488
  this.child = extension
466
489
 
467
- extension.name = extendedConfig.name
468
- ? extendedConfig.name
469
- : extension.parent.name
490
+ extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name
470
491
 
471
492
  if (extendedConfig.defaultOptions) {
472
- console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`)
493
+ console.warn(
494
+ `[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`,
495
+ )
473
496
  }
474
497
 
475
- extension.options = callOrReturn(getExtensionField<AnyConfig['addOptions']>(
476
- extension,
477
- 'addOptions',
478
- {
498
+ extension.options = callOrReturn(
499
+ getExtensionField<AnyConfig['addOptions']>(extension, 'addOptions', {
479
500
  name: extension.name,
480
- },
481
- ))
501
+ }),
502
+ )
482
503
 
483
- extension.storage = callOrReturn(getExtensionField<AnyConfig['addStorage']>(
484
- extension,
485
- 'addStorage',
486
- {
504
+ extension.storage = callOrReturn(
505
+ getExtensionField<AnyConfig['addStorage']>(extension, 'addStorage', {
487
506
  name: extension.name,
488
507
  options: extension.options,
489
- },
490
- ))
508
+ }),
509
+ )
491
510
 
492
511
  return extension
493
512
  }
494
513
 
495
- static handleExit({
496
- editor,
497
- mark,
498
- }: {
499
- editor: Editor
500
- mark: Mark
501
- }) {
514
+ static handleExit({ editor, mark }: { editor: Editor; mark: Mark }) {
502
515
  const { tr } = editor.state
503
516
  const currentPos = editor.state.selection.$from
504
517
  const isAtEnd = currentPos.pos === currentPos.end()