@tiptap/core 2.0.0-beta.99 → 2.0.0-rc.1

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