@tiptap/core 3.0.0-next.6 → 3.0.0-next.7

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 (138) hide show
  1. package/dist/index.cjs +48 -13
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +32 -17
  4. package/dist/index.d.ts +32 -17
  5. package/dist/index.js +74 -39
  6. package/dist/index.js.map +1 -1
  7. package/package.json +2 -2
  8. package/src/CommandManager.ts +3 -3
  9. package/src/Editor.ts +30 -15
  10. package/src/Extendable.ts +10 -9
  11. package/src/Extension.ts +17 -1
  12. package/src/ExtensionManager.ts +8 -6
  13. package/src/InputRule.ts +6 -4
  14. package/src/Mark.ts +13 -1
  15. package/src/MarkView.ts +3 -3
  16. package/src/Node.ts +13 -1
  17. package/src/NodePos.ts +3 -3
  18. package/src/NodeView.ts +3 -3
  19. package/src/PasteRule.ts +6 -4
  20. package/src/Tracker.ts +1 -1
  21. package/src/commands/blur.ts +1 -1
  22. package/src/commands/clearContent.ts +1 -1
  23. package/src/commands/clearNodes.ts +1 -1
  24. package/src/commands/command.ts +1 -1
  25. package/src/commands/createParagraphNear.ts +1 -1
  26. package/src/commands/cut.ts +1 -1
  27. package/src/commands/deleteCurrentNode.ts +1 -1
  28. package/src/commands/deleteNode.ts +2 -2
  29. package/src/commands/deleteRange.ts +1 -1
  30. package/src/commands/deleteSelection.ts +1 -1
  31. package/src/commands/enter.ts +1 -1
  32. package/src/commands/exitCode.ts +1 -1
  33. package/src/commands/extendMarkRange.ts +2 -2
  34. package/src/commands/first.ts +1 -1
  35. package/src/commands/focus.ts +1 -1
  36. package/src/commands/forEach.ts +1 -1
  37. package/src/commands/insertContent.ts +2 -2
  38. package/src/commands/insertContentAt.ts +3 -2
  39. package/src/commands/join.ts +1 -1
  40. package/src/commands/joinItemBackward.ts +1 -1
  41. package/src/commands/joinItemForward.ts +1 -1
  42. package/src/commands/joinTextblockBackward.ts +1 -1
  43. package/src/commands/joinTextblockForward.ts +1 -1
  44. package/src/commands/keyboardShortcut.ts +1 -1
  45. package/src/commands/lift.ts +2 -2
  46. package/src/commands/liftEmptyBlock.ts +1 -1
  47. package/src/commands/liftListItem.ts +2 -2
  48. package/src/commands/newlineInCode.ts +1 -1
  49. package/src/commands/resetAttributes.ts +2 -2
  50. package/src/commands/scrollIntoView.ts +1 -1
  51. package/src/commands/selectAll.ts +1 -1
  52. package/src/commands/selectNodeBackward.ts +1 -1
  53. package/src/commands/selectNodeForward.ts +1 -1
  54. package/src/commands/selectParentNode.ts +1 -1
  55. package/src/commands/selectTextblockEnd.ts +1 -1
  56. package/src/commands/selectTextblockStart.ts +1 -1
  57. package/src/commands/setContent.ts +2 -2
  58. package/src/commands/setMark.ts +3 -3
  59. package/src/commands/setMeta.ts +1 -1
  60. package/src/commands/setNode.ts +2 -2
  61. package/src/commands/setNodeSelection.ts +1 -1
  62. package/src/commands/setTextSelection.ts +1 -1
  63. package/src/commands/sinkListItem.ts +2 -2
  64. package/src/commands/splitBlock.ts +3 -2
  65. package/src/commands/splitListItem.ts +3 -2
  66. package/src/commands/toggleList.ts +3 -3
  67. package/src/commands/toggleMark.ts +2 -2
  68. package/src/commands/toggleNode.ts +2 -2
  69. package/src/commands/toggleWrap.ts +2 -2
  70. package/src/commands/undoInputRule.ts +1 -1
  71. package/src/commands/unsetAllMarks.ts +1 -1
  72. package/src/commands/unsetMark.ts +2 -2
  73. package/src/commands/updateAttributes.ts +3 -3
  74. package/src/commands/wrapIn.ts +2 -2
  75. package/src/commands/wrapInList.ts +2 -2
  76. package/src/extensions/focusEvents.ts +3 -1
  77. package/src/extensions/index.ts +1 -1
  78. package/src/helpers/combineTransactionSteps.ts +2 -2
  79. package/src/helpers/createChainableState.ts +1 -1
  80. package/src/helpers/createDocument.ts +2 -2
  81. package/src/helpers/createNodeFromContent.ts +3 -2
  82. package/src/helpers/defaultBlockAt.ts +1 -1
  83. package/src/helpers/findChildren.ts +2 -2
  84. package/src/helpers/findChildrenInRange.ts +2 -2
  85. package/src/helpers/findParentNode.ts +2 -2
  86. package/src/helpers/findParentNodeClosestToPos.ts +2 -2
  87. package/src/helpers/flattenExtensions.ts +1 -1
  88. package/src/helpers/generateHTML.ts +1 -1
  89. package/src/helpers/generateJSON.ts +1 -1
  90. package/src/helpers/generateText.ts +1 -1
  91. package/src/helpers/getAttributes.ts +2 -2
  92. package/src/helpers/getAttributesFromExtensions.ts +1 -1
  93. package/src/helpers/getChangedRanges.ts +2 -2
  94. package/src/helpers/getDebugJSON.ts +2 -2
  95. package/src/helpers/getExtensionField.ts +4 -4
  96. package/src/helpers/getHTMLFromFragment.ts +2 -1
  97. package/src/helpers/getMarkAttributes.ts +2 -2
  98. package/src/helpers/getMarkRange.ts +2 -2
  99. package/src/helpers/getMarkType.ts +1 -1
  100. package/src/helpers/getMarksBetween.ts +2 -2
  101. package/src/helpers/getNodeAtPosition.ts +2 -2
  102. package/src/helpers/getNodeAttributes.ts +2 -2
  103. package/src/helpers/getNodeType.ts +1 -1
  104. package/src/helpers/getRenderedAttributes.ts +2 -2
  105. package/src/helpers/getSchema.ts +3 -3
  106. package/src/helpers/getSchemaByResolvedExtensions.ts +3 -2
  107. package/src/helpers/getSchemaTypeByName.ts +1 -1
  108. package/src/helpers/getSchemaTypeNameByName.ts +1 -1
  109. package/src/helpers/getSplittedAttributes.ts +1 -1
  110. package/src/helpers/getText.ts +2 -2
  111. package/src/helpers/getTextBetween.ts +2 -2
  112. package/src/helpers/getTextContentFromNodes.ts +1 -1
  113. package/src/helpers/getTextSerializersFromSchema.ts +2 -2
  114. package/src/helpers/injectExtensionAttributesToParseRule.ts +2 -2
  115. package/src/helpers/isActive.ts +1 -1
  116. package/src/helpers/isAtEndOfNode.ts +1 -1
  117. package/src/helpers/isAtStartOfNode.ts +1 -1
  118. package/src/helpers/isExtensionRulesEnabled.ts +1 -1
  119. package/src/helpers/isList.ts +1 -1
  120. package/src/helpers/isMarkActive.ts +3 -3
  121. package/src/helpers/isNodeActive.ts +3 -3
  122. package/src/helpers/isNodeEmpty.ts +1 -1
  123. package/src/helpers/posToDOMRect.ts +1 -1
  124. package/src/helpers/resolveExtensions.ts +1 -1
  125. package/src/helpers/resolveFocusPosition.ts +2 -2
  126. package/src/helpers/selectionToInsertionEnd.ts +2 -1
  127. package/src/helpers/sortExtensions.ts +1 -1
  128. package/src/helpers/splitExtensions.ts +4 -4
  129. package/src/inputRules/markInputRule.ts +4 -3
  130. package/src/inputRules/nodeInputRule.ts +4 -3
  131. package/src/inputRules/textInputRule.ts +2 -1
  132. package/src/inputRules/textblockTypeInputRule.ts +4 -3
  133. package/src/inputRules/wrappingInputRule.ts +5 -4
  134. package/src/pasteRules/markPasteRule.ts +4 -3
  135. package/src/pasteRules/nodePasteRule.ts +4 -3
  136. package/src/pasteRules/textPasteRule.ts +2 -1
  137. package/src/types.ts +10 -10
  138. package/src/utilities/callOrReturn.ts +1 -1
@@ -1,4 +1,4 @@
1
- import { Schema } from '@tiptap/pm/model'
1
+ import type { Schema } from '@tiptap/pm/model'
2
2
 
3
3
  /**
4
4
  * Get the type of a schema item by its name.
@@ -1,4 +1,4 @@
1
- import { ExtensionAttribute } from '../types.js'
1
+ import type { ExtensionAttribute } from '../types.js'
2
2
 
3
3
  /**
4
4
  * Return attributes of an extension that should be splitted by keepOnSplit flag
@@ -1,6 +1,6 @@
1
- import { Node as ProseMirrorNode } from '@tiptap/pm/model'
1
+ import type { Node as ProseMirrorNode } from '@tiptap/pm/model'
2
2
 
3
- import { TextSerializer } from '../types.js'
3
+ import type { TextSerializer } from '../types.js'
4
4
  import { getTextBetween } from './getTextBetween.js'
5
5
 
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { Node as ProseMirrorNode } from '@tiptap/pm/model'
1
+ import type { Node as ProseMirrorNode } from '@tiptap/pm/model'
2
2
 
3
- import { Range, TextSerializer } from '../types.js'
3
+ import type { Range, TextSerializer } from '../types.js'
4
4
 
5
5
  /**
6
6
  * Gets the text between two positions in a Prosemirror node
@@ -1,4 +1,4 @@
1
- import { ResolvedPos } from '@tiptap/pm/model'
1
+ import type { ResolvedPos } from '@tiptap/pm/model'
2
2
 
3
3
  /**
4
4
  * Returns the text content of a resolved prosemirror position
@@ -1,6 +1,6 @@
1
- import { Schema } from '@tiptap/pm/model'
1
+ import type { Schema } from '@tiptap/pm/model'
2
2
 
3
- import { TextSerializer } from '../types.js'
3
+ import type { TextSerializer } from '../types.js'
4
4
 
5
5
  /**
6
6
  * Find text serializers `toText` in a Prosemirror schema
@@ -1,6 +1,6 @@
1
- import { ParseRule } from '@tiptap/pm/model'
1
+ import type { ParseRule } from '@tiptap/pm/model'
2
2
 
3
- import { ExtensionAttribute } from '../types.js'
3
+ import type { ExtensionAttribute } from '../types.js'
4
4
  import { fromString } from '../utilities/fromString.js'
5
5
 
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { EditorState } from '@tiptap/pm/state'
1
+ import type { EditorState } from '@tiptap/pm/state'
2
2
 
3
3
  import { getSchemaTypeNameByName } from './getSchemaTypeNameByName.js'
4
4
  import { isMarkActive } from './isMarkActive.js'
@@ -1,4 +1,4 @@
1
- import { EditorState } from '@tiptap/pm/state'
1
+ import type { EditorState } from '@tiptap/pm/state'
2
2
 
3
3
  import { findParentNode } from './findParentNode.js'
4
4
 
@@ -1,4 +1,4 @@
1
- import { EditorState } from '@tiptap/pm/state'
1
+ import type { EditorState } from '@tiptap/pm/state'
2
2
 
3
3
  export const isAtStartOfNode = (state: EditorState) => {
4
4
  const { $from, $to } = state.selection
@@ -1,4 +1,4 @@
1
- import { AnyExtension, EnableRules } from '../types.js'
1
+ import type { AnyExtension, EnableRules } from '../types.js'
2
2
 
3
3
  export function isExtensionRulesEnabled(extension: AnyExtension, enabled: EnableRules): boolean {
4
4
  if (Array.isArray(enabled)) {
@@ -1,6 +1,6 @@
1
1
  import { getExtensionField } from '../helpers/getExtensionField.js'
2
2
  import type { NodeConfig } from '../index.js'
3
- import { Extensions } from '../types.js'
3
+ import type { Extensions } from '../types.js'
4
4
  import { callOrReturn } from '../utilities/callOrReturn.js'
5
5
  import { splitExtensions } from './splitExtensions.js'
6
6
 
@@ -1,7 +1,7 @@
1
- import { MarkType } from '@tiptap/pm/model'
2
- import { EditorState } from '@tiptap/pm/state'
1
+ import type { MarkType } from '@tiptap/pm/model'
2
+ import type { EditorState } from '@tiptap/pm/state'
3
3
 
4
- import { MarkRange } from '../types.js'
4
+ import type { MarkRange } from '../types.js'
5
5
  import { objectIncludes } from '../utilities/objectIncludes.js'
6
6
  import { getMarkType } from './getMarkType.js'
7
7
 
@@ -1,7 +1,7 @@
1
- import { NodeType } from '@tiptap/pm/model'
2
- import { EditorState } from '@tiptap/pm/state'
1
+ import type { NodeType } from '@tiptap/pm/model'
2
+ import type { EditorState } from '@tiptap/pm/state'
3
3
 
4
- import { NodeRange } from '../types.js'
4
+ import type { NodeRange } from '../types.js'
5
5
  import { objectIncludes } from '../utilities/objectIncludes.js'
6
6
  import { getNodeType } from './getNodeType.js'
7
7
 
@@ -1,4 +1,4 @@
1
- import { Node as ProseMirrorNode } from '@tiptap/pm/model'
1
+ import type { Node as ProseMirrorNode } from '@tiptap/pm/model'
2
2
 
3
3
  /**
4
4
  * Returns true if the given prosemirror node is empty.
@@ -1,4 +1,4 @@
1
- import { EditorView } from '@tiptap/pm/view'
1
+ import type { EditorView } from '@tiptap/pm/view'
2
2
 
3
3
  import { minMax } from '../utilities/minMax.js'
4
4
 
@@ -1,4 +1,4 @@
1
- import { Extensions } from '../types.js'
1
+ import type { Extensions } from '../types.js'
2
2
  import { findDuplicates } from '../utilities/findDuplicates.js'
3
3
  import { flattenExtensions } from './flattenExtensions.js'
4
4
  import { sortExtensions } from './sortExtensions.js'
@@ -1,7 +1,7 @@
1
- import { Node as ProseMirrorNode } from '@tiptap/pm/model'
1
+ import type { Node as ProseMirrorNode } from '@tiptap/pm/model'
2
2
  import { Selection, TextSelection } from '@tiptap/pm/state'
3
3
 
4
- import { FocusPosition } from '../types.js'
4
+ import type { FocusPosition } from '../types.js'
5
5
  import { minMax } from '../utilities/minMax.js'
6
6
 
7
7
  export function resolveFocusPosition(doc: ProseMirrorNode, position: FocusPosition = null): Selection | null {
@@ -1,4 +1,5 @@
1
- import { Selection, Transaction } from '@tiptap/pm/state'
1
+ import type { Transaction } from '@tiptap/pm/state'
2
+ import { Selection } from '@tiptap/pm/state'
2
3
  import { ReplaceAroundStep, ReplaceStep } from '@tiptap/pm/transform'
3
4
 
4
5
  // source: https://github.com/ProseMirror/prosemirror-state/blob/master/src/selection.js#L466
@@ -1,4 +1,4 @@
1
- import { AnyConfig, Extensions } from '../types.js'
1
+ import type { AnyConfig, Extensions } from '../types.js'
2
2
  import { getExtensionField } from './getExtensionField.js'
3
3
 
4
4
  /**
@@ -1,7 +1,7 @@
1
- import { Extension } from '../Extension.js'
2
- import { Mark } from '../Mark.js'
3
- import { Node } from '../Node.js'
4
- import { Extensions } from '../types.js'
1
+ import type { Extension } from '../Extension.js'
2
+ import type { Mark } from '../Mark.js'
3
+ import type { Node } from '../Node.js'
4
+ import type { Extensions } from '../types.js'
5
5
 
6
6
  export function splitExtensions(extensions: Extensions) {
7
7
  const baseExtensions = extensions.filter(extension => extension.type === 'extension') as Extension[]
@@ -1,8 +1,9 @@
1
- import { MarkType } from '@tiptap/pm/model'
1
+ import type { MarkType } from '@tiptap/pm/model'
2
2
 
3
3
  import { getMarksBetween } from '../helpers/getMarksBetween.js'
4
- import { InputRule, InputRuleFinder } from '../InputRule.js'
5
- import { ExtendedRegExpMatchArray } from '../types.js'
4
+ import type { InputRuleFinder } from '../InputRule.js'
5
+ import { InputRule } from '../InputRule.js'
6
+ import type { ExtendedRegExpMatchArray } from '../types.js'
6
7
  import { callOrReturn } from '../utilities/callOrReturn.js'
7
8
 
8
9
  /**
@@ -1,7 +1,8 @@
1
- import { NodeType } from '@tiptap/pm/model'
1
+ import type { NodeType } from '@tiptap/pm/model'
2
2
 
3
- import { InputRule, InputRuleFinder } from '../InputRule.js'
4
- import { ExtendedRegExpMatchArray } from '../types.js'
3
+ import type { InputRuleFinder } from '../InputRule.js'
4
+ import { InputRule } from '../InputRule.js'
5
+ import type { ExtendedRegExpMatchArray } from '../types.js'
5
6
  import { callOrReturn } from '../utilities/callOrReturn.js'
6
7
 
7
8
  /**
@@ -1,4 +1,5 @@
1
- import { InputRule, InputRuleFinder } from '../InputRule.js'
1
+ import type { InputRuleFinder } from '../InputRule.js'
2
+ import { InputRule } from '../InputRule.js'
2
3
 
3
4
  /**
4
5
  * Build an input rule that replaces text when the
@@ -1,7 +1,8 @@
1
- import { NodeType } from '@tiptap/pm/model'
1
+ import type { NodeType } from '@tiptap/pm/model'
2
2
 
3
- import { InputRule, InputRuleFinder } from '../InputRule.js'
4
- import { ExtendedRegExpMatchArray } from '../types.js'
3
+ import type { InputRuleFinder } from '../InputRule.js'
4
+ import { InputRule } from '../InputRule.js'
5
+ import type { ExtendedRegExpMatchArray } from '../types.js'
5
6
  import { callOrReturn } from '../utilities/callOrReturn.js'
6
7
 
7
8
  /**
@@ -1,9 +1,10 @@
1
- import { Node as ProseMirrorNode, NodeType } from '@tiptap/pm/model'
1
+ import type { Node as ProseMirrorNode, NodeType } from '@tiptap/pm/model'
2
2
  import { canJoin, findWrapping } from '@tiptap/pm/transform'
3
3
 
4
- import { Editor } from '../Editor.js'
5
- import { InputRule, InputRuleFinder } from '../InputRule.js'
6
- import { ExtendedRegExpMatchArray } from '../types.js'
4
+ import type { Editor } from '../Editor.js'
5
+ import type { InputRuleFinder } from '../InputRule.js'
6
+ import { InputRule } from '../InputRule.js'
7
+ import type { ExtendedRegExpMatchArray } from '../types.js'
7
8
  import { callOrReturn } from '../utilities/callOrReturn.js'
8
9
 
9
10
  /**
@@ -1,8 +1,9 @@
1
- import { MarkType } from '@tiptap/pm/model'
1
+ import type { MarkType } from '@tiptap/pm/model'
2
2
 
3
3
  import { getMarksBetween } from '../helpers/getMarksBetween.js'
4
- import { PasteRule, PasteRuleFinder } from '../PasteRule.js'
5
- import { ExtendedRegExpMatchArray } from '../types.js'
4
+ import type { PasteRuleFinder } from '../PasteRule.js'
5
+ import { PasteRule } from '../PasteRule.js'
6
+ import type { ExtendedRegExpMatchArray } from '../types.js'
6
7
  import { callOrReturn } from '../utilities/callOrReturn.js'
7
8
 
8
9
  /**
@@ -1,7 +1,8 @@
1
- import { NodeType } from '@tiptap/pm/model'
1
+ import type { NodeType } from '@tiptap/pm/model'
2
2
 
3
- import { PasteRule, PasteRuleFinder } from '../PasteRule.js'
4
- import { ExtendedRegExpMatchArray, JSONContent } from '../types.js'
3
+ import type { PasteRuleFinder } from '../PasteRule.js'
4
+ import { PasteRule } from '../PasteRule.js'
5
+ import type { ExtendedRegExpMatchArray, JSONContent } from '../types.js'
5
6
  import { callOrReturn } from '../utilities/index.js'
6
7
 
7
8
  /**
@@ -1,4 +1,5 @@
1
- import { PasteRule, PasteRuleFinder } from '../PasteRule.js'
1
+ import type { PasteRuleFinder } from '../PasteRule.js'
2
+ import { PasteRule } from '../PasteRule.js'
2
3
 
3
4
  /**
4
5
  * Build an paste rule that replaces text when the
package/src/types.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Mark as ProseMirrorMark, Node as ProseMirrorNode, ParseOptions, Slice } from '@tiptap/pm/model'
2
- import { EditorState, Transaction } from '@tiptap/pm/state'
3
- import { Mappable, Transform } from '@tiptap/pm/transform'
4
- import {
1
+ import type { Mark as ProseMirrorMark, Node as ProseMirrorNode, ParseOptions, Slice } from '@tiptap/pm/model'
2
+ import type { EditorState, Transaction } from '@tiptap/pm/state'
3
+ import type { Mappable, Transform } from '@tiptap/pm/transform'
4
+ import type {
5
5
  Decoration,
6
6
  DecorationAttrs,
7
7
  EditorProps,
@@ -13,14 +13,14 @@ import {
13
13
  ViewMutationRecord,
14
14
  } from '@tiptap/pm/view'
15
15
 
16
- import { Editor } from './Editor.js'
17
- import { Extension } from './Extension.js'
18
- import { Commands, ExtensionConfig, MarkConfig, NodeConfig } from './index.js'
19
- import { Mark } from './Mark.js'
20
- import { Node } from './Node.js'
16
+ import type { Editor } from './Editor.js'
17
+ import type { Extendable } from './Extendable.js'
18
+ import type { Commands, ExtensionConfig, MarkConfig, NodeConfig } from './index.js'
19
+ import type { Mark } from './Mark.js'
20
+ import type { Node } from './Node.js'
21
21
 
22
22
  export type AnyConfig = ExtensionConfig | NodeConfig | MarkConfig
23
- export type AnyExtension = Extension | Node | Mark
23
+ export type AnyExtension = Extendable
24
24
  export type Extensions = AnyExtension[]
25
25
 
26
26
  export type ParentConfig<T> = Partial<{
@@ -1,4 +1,4 @@
1
- import { MaybeReturnType } from '../types.js'
1
+ import type { MaybeReturnType } from '../types.js'
2
2
  import { isFunction } from './isFunction.js'
3
3
 
4
4
  /**