@tiptap/core 2.1.0-rc.1 → 2.1.0-rc.10

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 (244) hide show
  1. package/dist/index.cjs +94 -31
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +92 -32
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.umd.js +94 -31
  6. package/dist/index.umd.js.map +1 -1
  7. package/dist/packages/core/src/CommandManager.d.ts +2 -2
  8. package/dist/packages/core/src/Editor.d.ts +8 -4
  9. package/dist/packages/core/src/Extension.d.ts +7 -7
  10. package/dist/packages/core/src/ExtensionManager.d.ts +2 -2
  11. package/dist/packages/core/src/InputRule.d.ts +2 -2
  12. package/dist/packages/core/src/Mark.d.ts +6 -6
  13. package/dist/packages/core/src/Node.d.ts +5 -5
  14. package/dist/packages/core/src/NodeView.d.ts +3 -3
  15. package/dist/packages/core/src/PasteRule.d.ts +2 -2
  16. package/dist/packages/core/src/commands/blur.d.ts +1 -1
  17. package/dist/packages/core/src/commands/clearContent.d.ts +1 -1
  18. package/dist/packages/core/src/commands/clearNodes.d.ts +1 -1
  19. package/dist/packages/core/src/commands/command.d.ts +1 -1
  20. package/dist/packages/core/src/commands/createParagraphNear.d.ts +1 -1
  21. package/dist/packages/core/src/commands/cut.d.ts +15 -0
  22. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +1 -1
  23. package/dist/packages/core/src/commands/deleteNode.d.ts +1 -1
  24. package/dist/packages/core/src/commands/deleteRange.d.ts +1 -1
  25. package/dist/packages/core/src/commands/deleteSelection.d.ts +1 -1
  26. package/dist/packages/core/src/commands/enter.d.ts +1 -1
  27. package/dist/packages/core/src/commands/exitCode.d.ts +1 -1
  28. package/dist/packages/core/src/commands/extendMarkRange.d.ts +1 -1
  29. package/dist/packages/core/src/commands/first.d.ts +1 -1
  30. package/dist/packages/core/src/commands/focus.d.ts +1 -1
  31. package/dist/packages/core/src/commands/forEach.d.ts +1 -1
  32. package/dist/packages/core/src/commands/index.d.ts +51 -50
  33. package/dist/packages/core/src/commands/insertContent.d.ts +1 -1
  34. package/dist/packages/core/src/commands/insertContentAt.d.ts +1 -1
  35. package/dist/packages/core/src/commands/join.d.ts +1 -1
  36. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +1 -1
  37. package/dist/packages/core/src/commands/lift.d.ts +1 -1
  38. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +1 -1
  39. package/dist/packages/core/src/commands/liftListItem.d.ts +1 -1
  40. package/dist/packages/core/src/commands/newlineInCode.d.ts +1 -1
  41. package/dist/packages/core/src/commands/resetAttributes.d.ts +1 -1
  42. package/dist/packages/core/src/commands/scrollIntoView.d.ts +1 -1
  43. package/dist/packages/core/src/commands/selectAll.d.ts +1 -1
  44. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +1 -1
  45. package/dist/packages/core/src/commands/selectNodeForward.d.ts +1 -1
  46. package/dist/packages/core/src/commands/selectParentNode.d.ts +1 -1
  47. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +1 -1
  48. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +1 -1
  49. package/dist/packages/core/src/commands/setContent.d.ts +1 -1
  50. package/dist/packages/core/src/commands/setMark.d.ts +1 -1
  51. package/dist/packages/core/src/commands/setMeta.d.ts +1 -1
  52. package/dist/packages/core/src/commands/setNode.d.ts +1 -1
  53. package/dist/packages/core/src/commands/setNodeSelection.d.ts +1 -1
  54. package/dist/packages/core/src/commands/setTextSelection.d.ts +1 -1
  55. package/dist/packages/core/src/commands/sinkListItem.d.ts +1 -1
  56. package/dist/packages/core/src/commands/splitBlock.d.ts +1 -1
  57. package/dist/packages/core/src/commands/splitListItem.d.ts +1 -1
  58. package/dist/packages/core/src/commands/toggleList.d.ts +1 -1
  59. package/dist/packages/core/src/commands/toggleMark.d.ts +1 -1
  60. package/dist/packages/core/src/commands/toggleNode.d.ts +1 -1
  61. package/dist/packages/core/src/commands/toggleWrap.d.ts +1 -1
  62. package/dist/packages/core/src/commands/undoInputRule.d.ts +1 -1
  63. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +1 -1
  64. package/dist/packages/core/src/commands/unsetMark.d.ts +1 -1
  65. package/dist/packages/core/src/commands/updateAttributes.d.ts +1 -1
  66. package/dist/packages/core/src/commands/wrapIn.d.ts +1 -1
  67. package/dist/packages/core/src/commands/wrapInList.d.ts +1 -1
  68. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +1 -1
  69. package/dist/packages/core/src/extensions/commands.d.ts +2 -2
  70. package/dist/packages/core/src/extensions/editable.d.ts +1 -1
  71. package/dist/packages/core/src/extensions/focusEvents.d.ts +1 -1
  72. package/dist/packages/core/src/extensions/index.d.ts +6 -6
  73. package/dist/packages/core/src/extensions/keymap.d.ts +1 -1
  74. package/dist/packages/core/src/extensions/tabindex.d.ts +1 -1
  75. package/dist/packages/core/src/helpers/createDocument.d.ts +1 -1
  76. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +1 -1
  77. package/dist/packages/core/src/helpers/findChildren.d.ts +1 -1
  78. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +1 -1
  79. package/dist/packages/core/src/helpers/findParentNode.d.ts +1 -1
  80. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +1 -1
  81. package/dist/packages/core/src/helpers/generateHTML.d.ts +1 -1
  82. package/dist/packages/core/src/helpers/generateJSON.d.ts +1 -1
  83. package/dist/packages/core/src/helpers/generateText.d.ts +1 -1
  84. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +1 -1
  85. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +1 -1
  86. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +1 -1
  87. package/dist/packages/core/src/helpers/getExtensionField.d.ts +1 -1
  88. package/dist/packages/core/src/helpers/getMarkRange.d.ts +1 -1
  89. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +1 -1
  90. package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +11 -0
  91. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +1 -1
  92. package/dist/packages/core/src/helpers/getSchema.d.ts +2 -2
  93. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +2 -2
  94. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +1 -1
  95. package/dist/packages/core/src/helpers/getText.d.ts +1 -1
  96. package/dist/packages/core/src/helpers/getTextBetween.d.ts +1 -1
  97. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +1 -1
  98. package/dist/packages/core/src/helpers/index.d.ts +50 -47
  99. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +1 -1
  100. package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +2 -0
  101. package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +2 -0
  102. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +1 -1
  103. package/dist/packages/core/src/helpers/isList.d.ts +1 -1
  104. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +1 -1
  105. package/dist/packages/core/src/helpers/splitExtensions.d.ts +4 -4
  106. package/dist/packages/core/src/index.d.ts +15 -15
  107. package/dist/packages/core/src/inputRules/index.d.ts +5 -5
  108. package/dist/packages/core/src/inputRules/markInputRule.d.ts +2 -2
  109. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +2 -2
  110. package/dist/packages/core/src/inputRules/textInputRule.d.ts +1 -1
  111. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +2 -2
  112. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +3 -3
  113. package/dist/packages/core/src/pasteRules/index.d.ts +3 -3
  114. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +2 -2
  115. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +2 -2
  116. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +1 -1
  117. package/dist/packages/core/src/types.d.ts +5 -5
  118. package/dist/packages/core/src/utilities/callOrReturn.d.ts +1 -1
  119. package/dist/packages/core/src/utilities/index.d.ts +20 -20
  120. package/dist/packages/core/src/utilities/isAndroid.d.ts +1 -0
  121. package/package.json +2 -2
  122. package/src/CommandManager.ts +4 -8
  123. package/src/Editor.ts +24 -16
  124. package/src/Extension.ts +10 -10
  125. package/src/ExtensionManager.ts +15 -15
  126. package/src/InputRule.ts +6 -6
  127. package/src/Mark.ts +9 -9
  128. package/src/Node.ts +8 -8
  129. package/src/NodeView.ts +8 -6
  130. package/src/PasteRule.ts +6 -6
  131. package/src/commands/blur.ts +1 -1
  132. package/src/commands/clearContent.ts +1 -1
  133. package/src/commands/clearNodes.ts +1 -1
  134. package/src/commands/command.ts +1 -1
  135. package/src/commands/createParagraphNear.ts +1 -1
  136. package/src/commands/cut.ts +25 -0
  137. package/src/commands/deleteCurrentNode.ts +1 -1
  138. package/src/commands/deleteNode.ts +2 -2
  139. package/src/commands/deleteRange.ts +1 -1
  140. package/src/commands/deleteSelection.ts +1 -1
  141. package/src/commands/enter.ts +1 -1
  142. package/src/commands/exitCode.ts +1 -1
  143. package/src/commands/extendMarkRange.ts +3 -3
  144. package/src/commands/first.ts +1 -1
  145. package/src/commands/focus.ts +4 -4
  146. package/src/commands/forEach.ts +1 -1
  147. package/src/commands/index.ts +51 -50
  148. package/src/commands/insertContent.ts +1 -1
  149. package/src/commands/insertContentAt.ts +4 -4
  150. package/src/commands/join.ts +1 -1
  151. package/src/commands/keyboardShortcut.ts +3 -3
  152. package/src/commands/lift.ts +3 -3
  153. package/src/commands/liftEmptyBlock.ts +1 -1
  154. package/src/commands/liftListItem.ts +2 -2
  155. package/src/commands/newlineInCode.ts +1 -1
  156. package/src/commands/resetAttributes.ts +5 -5
  157. package/src/commands/scrollIntoView.ts +1 -1
  158. package/src/commands/selectAll.ts +1 -1
  159. package/src/commands/selectNodeBackward.ts +1 -1
  160. package/src/commands/selectNodeForward.ts +1 -1
  161. package/src/commands/selectParentNode.ts +1 -1
  162. package/src/commands/selectTextblockEnd.ts +1 -1
  163. package/src/commands/selectTextblockStart.ts +1 -1
  164. package/src/commands/setContent.ts +2 -2
  165. package/src/commands/setMark.ts +4 -4
  166. package/src/commands/setMeta.ts +1 -1
  167. package/src/commands/setNode.ts +2 -2
  168. package/src/commands/setNodeSelection.ts +2 -2
  169. package/src/commands/setTextSelection.ts +2 -2
  170. package/src/commands/sinkListItem.ts +2 -2
  171. package/src/commands/splitBlock.ts +3 -3
  172. package/src/commands/splitListItem.ts +3 -3
  173. package/src/commands/toggleList.ts +4 -4
  174. package/src/commands/toggleMark.ts +3 -3
  175. package/src/commands/toggleNode.ts +3 -3
  176. package/src/commands/toggleWrap.ts +3 -3
  177. package/src/commands/undoInputRule.ts +1 -1
  178. package/src/commands/unsetAllMarks.ts +1 -1
  179. package/src/commands/unsetMark.ts +3 -3
  180. package/src/commands/updateAttributes.ts +4 -4
  181. package/src/commands/wrapIn.ts +2 -2
  182. package/src/commands/wrapInList.ts +2 -2
  183. package/src/extensions/clipboardTextSerializer.ts +3 -3
  184. package/src/extensions/commands.ts +3 -3
  185. package/src/extensions/editable.ts +1 -1
  186. package/src/extensions/focusEvents.ts +1 -1
  187. package/src/extensions/index.ts +6 -6
  188. package/src/extensions/keymap.ts +5 -5
  189. package/src/extensions/tabindex.ts +1 -1
  190. package/src/helpers/createDocument.ts +2 -2
  191. package/src/helpers/createNodeFromContent.ts +2 -2
  192. package/src/helpers/findChildren.ts +1 -1
  193. package/src/helpers/findChildrenInRange.ts +1 -1
  194. package/src/helpers/findParentNode.ts +2 -2
  195. package/src/helpers/findParentNodeClosestToPos.ts +1 -1
  196. package/src/helpers/generateHTML.ts +3 -3
  197. package/src/helpers/generateJSON.ts +3 -3
  198. package/src/helpers/generateText.ts +4 -4
  199. package/src/helpers/getAttributes.ts +3 -3
  200. package/src/helpers/getAttributesFromExtensions.ts +4 -4
  201. package/src/helpers/getChangedRanges.ts +2 -2
  202. package/src/helpers/getDebugJSON.ts +1 -1
  203. package/src/helpers/getExtensionField.ts +1 -1
  204. package/src/helpers/getMarkAttributes.ts +1 -1
  205. package/src/helpers/getMarkRange.ts +2 -2
  206. package/src/helpers/getMarksBetween.ts +2 -2
  207. package/src/helpers/getNodeAtPosition.ts +29 -0
  208. package/src/helpers/getNodeAttributes.ts +1 -1
  209. package/src/helpers/getRenderedAttributes.ts +2 -2
  210. package/src/helpers/getSchema.ts +4 -4
  211. package/src/helpers/getSchemaByResolvedExtensions.ts +9 -9
  212. package/src/helpers/getSplittedAttributes.ts +1 -1
  213. package/src/helpers/getText.ts +2 -2
  214. package/src/helpers/getTextBetween.ts +1 -1
  215. package/src/helpers/getTextSerializersFromSchema.ts +1 -1
  216. package/src/helpers/index.ts +50 -47
  217. package/src/helpers/injectExtensionAttributesToParseRule.ts +2 -2
  218. package/src/helpers/isActive.ts +3 -3
  219. package/src/helpers/isAtEndOfNode.ts +11 -0
  220. package/src/helpers/isAtStartOfNode.ts +11 -0
  221. package/src/helpers/isExtensionRulesEnabled.ts +1 -1
  222. package/src/helpers/isList.ts +5 -5
  223. package/src/helpers/isMarkActive.ts +3 -3
  224. package/src/helpers/isNodeActive.ts +3 -3
  225. package/src/helpers/posToDOMRect.ts +1 -1
  226. package/src/helpers/resolveFocusPosition.ts +2 -2
  227. package/src/helpers/splitExtensions.ts +4 -4
  228. package/src/index.ts +15 -15
  229. package/src/inputRules/index.ts +5 -5
  230. package/src/inputRules/markInputRule.ts +5 -6
  231. package/src/inputRules/nodeInputRule.ts +3 -3
  232. package/src/inputRules/textInputRule.ts +1 -1
  233. package/src/inputRules/textblockTypeInputRule.ts +3 -3
  234. package/src/inputRules/wrappingInputRule.ts +4 -4
  235. package/src/pasteRules/index.ts +3 -3
  236. package/src/pasteRules/markPasteRule.ts +4 -4
  237. package/src/pasteRules/nodePasteRule.ts +3 -3
  238. package/src/pasteRules/textPasteRule.ts +1 -1
  239. package/src/types.ts +5 -5
  240. package/src/utilities/callOrReturn.ts +2 -2
  241. package/src/utilities/index.ts +20 -20
  242. package/src/utilities/isAndroid.ts +3 -0
  243. package/src/utilities/mergeDeep.ts +1 -1
  244. package/src/utilities/objectIncludes.ts +1 -1
@@ -1,7 +1,7 @@
1
1
  import { Mark as ProseMirrorMark, MarkType, ResolvedPos } from '@tiptap/pm/model'
2
2
 
3
- import { Range } from '../types'
4
- import { objectIncludes } from '../utilities/objectIncludes'
3
+ import { Range } from '../types.js'
4
+ import { objectIncludes } from '../utilities/objectIncludes.js'
5
5
 
6
6
  function findMarkInSet(
7
7
  marks: ProseMirrorMark[],
@@ -1,7 +1,7 @@
1
1
  import { Node as ProseMirrorNode } from '@tiptap/pm/model'
2
2
 
3
- import { MarkRange } from '../types'
4
- import { getMarkRange } from './getMarkRange'
3
+ import { MarkRange } from '../types.js'
4
+ import { getMarkRange } from './getMarkRange.js'
5
5
 
6
6
  export function getMarksBetween(from: number, to: number, doc: ProseMirrorNode): MarkRange[] {
7
7
  const marks: MarkRange[] = []
@@ -0,0 +1,29 @@
1
+ import { Node, NodeType } from '@tiptap/pm/model'
2
+ import { EditorState } from '@tiptap/pm/state'
3
+
4
+ /**
5
+ * Finds the first node of a given type or name in the current selection.
6
+ * @param state The editor state.
7
+ * @param typeOrName The node type or name.
8
+ * @param pos The position to start searching from.
9
+ * @param maxDepth The maximum depth to search.
10
+ * @returns The node and the depth as an array.
11
+ */
12
+ export const getNodeAtPosition = (state: EditorState, typeOrName: string | NodeType, pos: number, maxDepth = 20) => {
13
+ const $pos = state.doc.resolve(pos)
14
+
15
+ let currentDepth = maxDepth
16
+ let node: Node | null = null
17
+
18
+ while (currentDepth > 0 && node === null) {
19
+ const currentNode = $pos.node(currentDepth)
20
+
21
+ if (currentNode?.type.name === typeOrName) {
22
+ node = currentNode
23
+ } else {
24
+ currentDepth -= 1
25
+ }
26
+ }
27
+
28
+ return [node, currentDepth] as [Node | null, number]
29
+ }
@@ -1,7 +1,7 @@
1
1
  import { Node, NodeType } from '@tiptap/pm/model'
2
2
  import { EditorState } from '@tiptap/pm/state'
3
3
 
4
- import { getNodeType } from './getNodeType'
4
+ import { getNodeType } from './getNodeType.js'
5
5
 
6
6
  export function getNodeAttributes(
7
7
  state: EditorState,
@@ -1,7 +1,7 @@
1
1
  import { Mark, Node } from '@tiptap/pm/model'
2
2
 
3
- import { ExtensionAttribute } from '../types'
4
- import { mergeAttributes } from '../utilities/mergeAttributes'
3
+ import { ExtensionAttribute } from '../types.js'
4
+ import { mergeAttributes } from '../utilities/mergeAttributes.js'
5
5
 
6
6
  export function getRenderedAttributes(
7
7
  nodeOrMark: Node | Mark,
@@ -1,9 +1,9 @@
1
1
  import { Schema } from '@tiptap/pm/model'
2
2
 
3
- import { Editor } from '../Editor'
4
- import { ExtensionManager } from '../ExtensionManager'
5
- import { Extensions } from '../types'
6
- import { getSchemaByResolvedExtensions } from './getSchemaByResolvedExtensions'
3
+ import { Editor } from '../Editor.js'
4
+ import { ExtensionManager } from '../ExtensionManager.js'
5
+ import { Extensions } from '../types.js'
6
+ import { getSchemaByResolvedExtensions } from './getSchemaByResolvedExtensions.js'
7
7
 
8
8
  export function getSchema(extensions: Extensions, editor?: Editor): Schema {
9
9
  const resolvedExtensions = ExtensionManager.resolve(extensions)
@@ -1,14 +1,14 @@
1
1
  import { MarkSpec, NodeSpec, Schema } from '@tiptap/pm/model'
2
2
 
3
- import { Editor, MarkConfig, NodeConfig } from '..'
4
- import { AnyConfig, Extensions } from '../types'
5
- import { callOrReturn } from '../utilities/callOrReturn'
6
- import { isEmptyObject } from '../utilities/isEmptyObject'
7
- import { getAttributesFromExtensions } from './getAttributesFromExtensions'
8
- import { getExtensionField } from './getExtensionField'
9
- import { getRenderedAttributes } from './getRenderedAttributes'
10
- import { injectExtensionAttributesToParseRule } from './injectExtensionAttributesToParseRule'
11
- import { splitExtensions } from './splitExtensions'
3
+ import { Editor, MarkConfig, NodeConfig } from '../index.js'
4
+ import { AnyConfig, Extensions } from '../types.js'
5
+ import { callOrReturn } from '../utilities/callOrReturn.js'
6
+ import { isEmptyObject } from '../utilities/isEmptyObject.js'
7
+ import { getAttributesFromExtensions } from './getAttributesFromExtensions.js'
8
+ import { getExtensionField } from './getExtensionField.js'
9
+ import { getRenderedAttributes } from './getRenderedAttributes.js'
10
+ import { injectExtensionAttributesToParseRule } from './injectExtensionAttributesToParseRule.js'
11
+ import { splitExtensions } from './splitExtensions.js'
12
12
 
13
13
  function cleanUpSchemaItem<T>(data: T) {
14
14
  return Object.fromEntries(
@@ -1,4 +1,4 @@
1
- import { ExtensionAttribute } from '../types'
1
+ import { ExtensionAttribute } from '../types.js'
2
2
 
3
3
  export function getSplittedAttributes(
4
4
  extensionAttributes: ExtensionAttribute[],
@@ -1,7 +1,7 @@
1
1
  import { Node as ProseMirrorNode } from '@tiptap/pm/model'
2
2
 
3
- import { TextSerializer } from '../types'
4
- import { getTextBetween } from './getTextBetween'
3
+ import { TextSerializer } from '../types.js'
4
+ import { getTextBetween } from './getTextBetween.js'
5
5
 
6
6
  export function getText(
7
7
  node: ProseMirrorNode,
@@ -1,6 +1,6 @@
1
1
  import { Node as ProseMirrorNode } from '@tiptap/pm/model'
2
2
 
3
- import { Range, TextSerializer } from '../types'
3
+ import { Range, TextSerializer } from '../types.js'
4
4
 
5
5
  export function getTextBetween(
6
6
  startNode: ProseMirrorNode,
@@ -1,6 +1,6 @@
1
1
  import { Schema } from '@tiptap/pm/model'
2
2
 
3
- import { TextSerializer } from '../types'
3
+ import { TextSerializer } from '../types.js'
4
4
 
5
5
  export function getTextSerializersFromSchema(schema: Schema): Record<string, TextSerializer> {
6
6
  return Object.fromEntries(
@@ -1,47 +1,50 @@
1
- export * from './combineTransactionSteps'
2
- export * from './createChainableState'
3
- export * from './createDocument'
4
- export * from './createNodeFromContent'
5
- export * from './defaultBlockAt'
6
- export * from './findChildren'
7
- export * from './findChildrenInRange'
8
- export * from './findParentNode'
9
- export * from './findParentNodeClosestToPos'
10
- export * from './generateHTML'
11
- export * from './generateJSON'
12
- export * from './generateText'
13
- export * from './getAttributes'
14
- export * from './getAttributesFromExtensions'
15
- export * from './getChangedRanges'
16
- export * from './getDebugJSON'
17
- export * from './getExtensionField'
18
- export * from './getHTMLFromFragment'
19
- export * from './getMarkAttributes'
20
- export * from './getMarkRange'
21
- export * from './getMarksBetween'
22
- export * from './getMarkType'
23
- export * from './getNodeAttributes'
24
- export * from './getNodeType'
25
- export * from './getRenderedAttributes'
26
- export * from './getSchema'
27
- export * from './getSchemaByResolvedExtensions'
28
- export * from './getSchemaTypeByName'
29
- export * from './getSchemaTypeNameByName'
30
- export * from './getSplittedAttributes'
31
- export * from './getText'
32
- export * from './getTextBetween'
33
- export * from './getTextContentFromNodes'
34
- export * from './getTextSerializersFromSchema'
35
- export * from './injectExtensionAttributesToParseRule'
36
- export * from './isActive'
37
- export * from './isExtensionRulesEnabled'
38
- export * from './isList'
39
- export * from './isMarkActive'
40
- export * from './isNodeActive'
41
- export * from './isNodeEmpty'
42
- export * from './isNodeSelection'
43
- export * from './isTextSelection'
44
- export * from './posToDOMRect'
45
- export * from './resolveFocusPosition'
46
- export * from './selectionToInsertionEnd'
47
- export * from './splitExtensions'
1
+ export * from './combineTransactionSteps.js'
2
+ export * from './createChainableState.js'
3
+ export * from './createDocument.js'
4
+ export * from './createNodeFromContent.js'
5
+ export * from './defaultBlockAt.js'
6
+ export * from './findChildren.js'
7
+ export * from './findChildrenInRange.js'
8
+ export * from './findParentNode.js'
9
+ export * from './findParentNodeClosestToPos.js'
10
+ export * from './generateHTML.js'
11
+ export * from './generateJSON.js'
12
+ export * from './generateText.js'
13
+ export * from './getAttributes.js'
14
+ export * from './getAttributesFromExtensions.js'
15
+ export * from './getChangedRanges.js'
16
+ export * from './getDebugJSON.js'
17
+ export * from './getExtensionField.js'
18
+ export * from './getHTMLFromFragment.js'
19
+ export * from './getMarkAttributes.js'
20
+ export * from './getMarkRange.js'
21
+ export * from './getMarksBetween.js'
22
+ export * from './getMarkType.js'
23
+ export * from './getNodeAtPosition.js'
24
+ export * from './getNodeAttributes.js'
25
+ export * from './getNodeType.js'
26
+ export * from './getRenderedAttributes.js'
27
+ export * from './getSchema.js'
28
+ export * from './getSchemaByResolvedExtensions.js'
29
+ export * from './getSchemaTypeByName.js'
30
+ export * from './getSchemaTypeNameByName.js'
31
+ export * from './getSplittedAttributes.js'
32
+ export * from './getText.js'
33
+ export * from './getTextBetween.js'
34
+ export * from './getTextContentFromNodes.js'
35
+ export * from './getTextSerializersFromSchema.js'
36
+ export * from './injectExtensionAttributesToParseRule.js'
37
+ export * from './isActive.js'
38
+ export * from './isAtEndOfNode.js'
39
+ export * from './isAtStartOfNode.js'
40
+ export * from './isExtensionRulesEnabled.js'
41
+ export * from './isList.js'
42
+ export * from './isMarkActive.js'
43
+ export * from './isNodeActive.js'
44
+ export * from './isNodeEmpty.js'
45
+ export * from './isNodeSelection.js'
46
+ export * from './isTextSelection.js'
47
+ export * from './posToDOMRect.js'
48
+ export * from './resolveFocusPosition.js'
49
+ export * from './selectionToInsertionEnd.js'
50
+ export * from './splitExtensions.js'
@@ -1,7 +1,7 @@
1
1
  import { ParseRule } from '@tiptap/pm/model'
2
2
 
3
- import { ExtensionAttribute } from '../types'
4
- import { fromString } from '../utilities/fromString'
3
+ import { ExtensionAttribute } from '../types.js'
4
+ import { fromString } from '../utilities/fromString.js'
5
5
 
6
6
  /**
7
7
  * This function merges extension attributes into parserule attributes (`attrs` or `getAttrs`).
@@ -1,8 +1,8 @@
1
1
  import { EditorState } from '@tiptap/pm/state'
2
2
 
3
- import { getSchemaTypeNameByName } from './getSchemaTypeNameByName'
4
- import { isMarkActive } from './isMarkActive'
5
- import { isNodeActive } from './isNodeActive'
3
+ import { getSchemaTypeNameByName } from './getSchemaTypeNameByName.js'
4
+ import { isMarkActive } from './isMarkActive.js'
5
+ import { isNodeActive } from './isNodeActive.js'
6
6
 
7
7
  export function isActive(
8
8
  state: EditorState,
@@ -0,0 +1,11 @@
1
+ import { EditorState } from '@tiptap/pm/state'
2
+
3
+ export const istAtEndOfNode = (state: EditorState) => {
4
+ const { $from, $to } = state.selection
5
+
6
+ if ($to.parentOffset < $to.parent.nodeSize - 2 || $from.pos !== $to.pos) {
7
+ return false
8
+ }
9
+
10
+ return true
11
+ }
@@ -0,0 +1,11 @@
1
+ import { EditorState } from '@tiptap/pm/state'
2
+
3
+ export const isAtStartOfNode = (state: EditorState) => {
4
+ const { $from, $to } = state.selection
5
+
6
+ if ($from.parentOffset > 0 || $from.pos !== $to.pos) {
7
+ return false
8
+ }
9
+
10
+ return true
11
+ }
@@ -1,4 +1,4 @@
1
- import { AnyExtension, EnableRules } from '../types'
1
+ import { AnyExtension, EnableRules } from '../types.js'
2
2
 
3
3
  export function isExtensionRulesEnabled(extension: AnyExtension, enabled: EnableRules): boolean {
4
4
  if (Array.isArray(enabled)) {
@@ -1,8 +1,8 @@
1
- import { NodeConfig } from '..'
2
- import { getExtensionField } from '../helpers/getExtensionField'
3
- import { Extensions } from '../types'
4
- import { callOrReturn } from '../utilities/callOrReturn'
5
- import { splitExtensions } from './splitExtensions'
1
+ import { getExtensionField } from '../helpers/getExtensionField.js'
2
+ import { NodeConfig } from '../index.js'
3
+ import { Extensions } from '../types.js'
4
+ import { callOrReturn } from '../utilities/callOrReturn.js'
5
+ import { splitExtensions } from './splitExtensions.js'
6
6
 
7
7
  export function isList(name: string, extensions: Extensions): boolean {
8
8
  const { nodeExtensions } = splitExtensions(extensions)
@@ -1,9 +1,9 @@
1
1
  import { MarkType } from '@tiptap/pm/model'
2
2
  import { EditorState } from '@tiptap/pm/state'
3
3
 
4
- import { MarkRange } from '../types'
5
- import { objectIncludes } from '../utilities/objectIncludes'
6
- import { getMarkType } from './getMarkType'
4
+ import { MarkRange } from '../types.js'
5
+ import { objectIncludes } from '../utilities/objectIncludes.js'
6
+ import { getMarkType } from './getMarkType.js'
7
7
 
8
8
  export function isMarkActive(
9
9
  state: EditorState,
@@ -1,9 +1,9 @@
1
1
  import { NodeType } from '@tiptap/pm/model'
2
2
  import { EditorState } from '@tiptap/pm/state'
3
3
 
4
- import { NodeRange } from '../types'
5
- import { objectIncludes } from '../utilities/objectIncludes'
6
- import { getNodeType } from './getNodeType'
4
+ import { NodeRange } from '../types.js'
5
+ import { objectIncludes } from '../utilities/objectIncludes.js'
6
+ import { getNodeType } from './getNodeType.js'
7
7
 
8
8
  export function isNodeActive(
9
9
  state: EditorState,
@@ -1,6 +1,6 @@
1
1
  import { EditorView } from '@tiptap/pm/view'
2
2
 
3
- import { minMax } from '../utilities/minMax'
3
+ import { minMax } from '../utilities/minMax.js'
4
4
 
5
5
  export function posToDOMRect(view: EditorView, from: number, to: number): DOMRect {
6
6
  const minPos = 0
@@ -1,8 +1,8 @@
1
1
  import { Node as ProseMirrorNode } from '@tiptap/pm/model'
2
2
  import { Selection, TextSelection } from '@tiptap/pm/state'
3
3
 
4
- import { FocusPosition } from '../types'
5
- import { minMax } from '../utilities/minMax'
4
+ import { FocusPosition } from '../types.js'
5
+ import { minMax } from '../utilities/minMax.js'
6
6
 
7
7
  export function resolveFocusPosition(
8
8
  doc: ProseMirrorNode,
@@ -1,7 +1,7 @@
1
- import { Extension } from '../Extension'
2
- import { Mark } from '../Mark'
3
- import { Node } from '../Node'
4
- import { Extensions } from '../types'
1
+ import { Extension } from '../Extension.js'
2
+ import { Mark } from '../Mark.js'
3
+ import { Node } from '../Node.js'
4
+ import { 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[]
package/src/index.ts CHANGED
@@ -1,18 +1,18 @@
1
- export * from './CommandManager'
2
- export * from './Editor'
3
- export * from './Extension'
4
- export * as extensions from './extensions'
5
- export * from './helpers'
6
- export * from './InputRule'
7
- export * from './inputRules'
8
- export * from './Mark'
9
- export * from './Node'
10
- export * from './NodeView'
11
- export * from './PasteRule'
12
- export * from './pasteRules'
13
- export * from './Tracker'
14
- export * from './types'
15
- export * from './utilities'
1
+ export * from './CommandManager.js'
2
+ export * from './Editor.js'
3
+ export * from './Extension.js'
4
+ export * as extensions from './extensions/index.js'
5
+ export * from './helpers/index.js'
6
+ export * from './InputRule.js'
7
+ export * from './inputRules/index.js'
8
+ export * from './Mark.js'
9
+ export * from './Node.js'
10
+ export * from './NodeView.js'
11
+ export * from './PasteRule.js'
12
+ export * from './pasteRules/index.js'
13
+ export * from './Tracker.js'
14
+ export * from './types.js'
15
+ export * from './utilities/index.js'
16
16
 
17
17
  // eslint-disable-next-line
18
18
  export interface Commands<ReturnType = any> {}
@@ -1,5 +1,5 @@
1
- export * from './markInputRule'
2
- export * from './nodeInputRule'
3
- export * from './textblockTypeInputRule'
4
- export * from './textInputRule'
5
- export * from './wrappingInputRule'
1
+ export * from './markInputRule.js'
2
+ export * from './nodeInputRule.js'
3
+ export * from './textblockTypeInputRule.js'
4
+ export * from './textInputRule.js'
5
+ export * from './wrappingInputRule.js'
@@ -1,9 +1,9 @@
1
1
  import { MarkType } from '@tiptap/pm/model'
2
2
 
3
- import { getMarksBetween } from '../helpers/getMarksBetween'
4
- import { InputRule, InputRuleFinder } from '../InputRule'
5
- import { ExtendedRegExpMatchArray } from '../types'
6
- import { callOrReturn } from '../utilities/callOrReturn'
3
+ import { getMarksBetween } from '../helpers/getMarksBetween.js'
4
+ import { InputRule, InputRuleFinder } from '../InputRule.js'
5
+ import { ExtendedRegExpMatchArray } from '../types.js'
6
+ import { callOrReturn } from '../utilities/callOrReturn.js'
7
7
 
8
8
  /**
9
9
  * Build an input rule that adds a mark when the
@@ -30,7 +30,6 @@ export function markInputRule(config: {
30
30
  const { tr } = state
31
31
  const captureGroup = match[match.length - 1]
32
32
  const fullMatch = match[0]
33
- let markEnd = range.to
34
33
 
35
34
  if (captureGroup) {
36
35
  const startSpaces = fullMatch.search(/\S/)
@@ -58,7 +57,7 @@ export function markInputRule(config: {
58
57
  tr.delete(range.from + startSpaces, textStart)
59
58
  }
60
59
 
61
- markEnd = range.from + startSpaces + captureGroup.length
60
+ const markEnd = range.from + startSpaces + captureGroup.length
62
61
 
63
62
  tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}))
64
63
 
@@ -1,8 +1,8 @@
1
1
  import { NodeType } from '@tiptap/pm/model'
2
2
 
3
- import { InputRule, InputRuleFinder } from '../InputRule'
4
- import { ExtendedRegExpMatchArray } from '../types'
5
- import { callOrReturn } from '../utilities/callOrReturn'
3
+ import { InputRule, InputRuleFinder } from '../InputRule.js'
4
+ import { ExtendedRegExpMatchArray } from '../types.js'
5
+ import { callOrReturn } from '../utilities/callOrReturn.js'
6
6
 
7
7
  /**
8
8
  * Build an input rule that adds a node when the
@@ -1,4 +1,4 @@
1
- import { InputRule, InputRuleFinder } from '../InputRule'
1
+ import { InputRule, InputRuleFinder } from '../InputRule.js'
2
2
 
3
3
  /**
4
4
  * Build an input rule that replaces text when the
@@ -1,8 +1,8 @@
1
1
  import { NodeType } from '@tiptap/pm/model'
2
2
 
3
- import { InputRule, InputRuleFinder } from '../InputRule'
4
- import { ExtendedRegExpMatchArray } from '../types'
5
- import { callOrReturn } from '../utilities/callOrReturn'
3
+ import { InputRule, InputRuleFinder } from '../InputRule.js'
4
+ import { ExtendedRegExpMatchArray } from '../types.js'
5
+ import { callOrReturn } from '../utilities/callOrReturn.js'
6
6
 
7
7
  /**
8
8
  * Build an input rule that changes the type of a textblock when the
@@ -1,10 +1,10 @@
1
1
  import { Node as ProseMirrorNode, NodeType } from '@tiptap/pm/model'
2
2
  import { canJoin, findWrapping } from '@tiptap/pm/transform'
3
3
 
4
- import { Editor } from '../Editor'
5
- import { InputRule, InputRuleFinder } from '../InputRule'
6
- import { ExtendedRegExpMatchArray } from '../types'
7
- import { callOrReturn } from '../utilities/callOrReturn'
4
+ import { Editor } from '../Editor.js'
5
+ import { InputRule, InputRuleFinder } from '../InputRule.js'
6
+ import { ExtendedRegExpMatchArray } from '../types.js'
7
+ import { callOrReturn } from '../utilities/callOrReturn.js'
8
8
 
9
9
  /**
10
10
  * Build an input rule for automatically wrapping a textblock when a
@@ -1,3 +1,3 @@
1
- export * from './markPasteRule'
2
- export * from './nodePasteRule'
3
- export * from './textPasteRule'
1
+ export * from './markPasteRule.js'
2
+ export * from './nodePasteRule.js'
3
+ export * from './textPasteRule.js'
@@ -1,9 +1,9 @@
1
1
  import { MarkType } from '@tiptap/pm/model'
2
2
 
3
- import { getMarksBetween } from '../helpers/getMarksBetween'
4
- import { PasteRule, PasteRuleFinder } from '../PasteRule'
5
- import { ExtendedRegExpMatchArray } from '../types'
6
- import { callOrReturn } from '../utilities/callOrReturn'
3
+ import { getMarksBetween } from '../helpers/getMarksBetween.js'
4
+ import { PasteRule, PasteRuleFinder } from '../PasteRule.js'
5
+ import { ExtendedRegExpMatchArray } from '../types.js'
6
+ import { callOrReturn } from '../utilities/callOrReturn.js'
7
7
 
8
8
  /**
9
9
  * Build an paste rule that adds a mark when the
@@ -1,8 +1,8 @@
1
1
  import { NodeType } from '@tiptap/pm/model'
2
2
 
3
- import { PasteRule, PasteRuleFinder } from '../PasteRule'
4
- import { ExtendedRegExpMatchArray } from '../types'
5
- import { callOrReturn } from '../utilities'
3
+ import { PasteRule, PasteRuleFinder } from '../PasteRule.js'
4
+ import { ExtendedRegExpMatchArray } from '../types.js'
5
+ import { callOrReturn } from '../utilities/index.js'
6
6
 
7
7
  /**
8
8
  * Build an paste rule that adds a node when the
@@ -1,4 +1,4 @@
1
- import { PasteRule, PasteRuleFinder } from '../PasteRule'
1
+ import { PasteRule, PasteRuleFinder } from '../PasteRule.js'
2
2
 
3
3
  /**
4
4
  * Build an paste rule that replaces text when the
package/src/types.ts CHANGED
@@ -6,13 +6,13 @@ import {
6
6
  Decoration, EditorProps, EditorView, NodeView,
7
7
  } from '@tiptap/pm/view'
8
8
 
9
+ import { Editor } from './Editor.js'
10
+ import { Extension } from './Extension.js'
9
11
  import {
10
12
  Commands, ExtensionConfig, MarkConfig, NodeConfig,
11
- } from '.'
12
- import { Editor } from './Editor'
13
- import { Extension } from './Extension'
14
- import { Mark } from './Mark'
15
- import { Node } from './Node'
13
+ } from './index.js'
14
+ import { Mark } from './Mark.js'
15
+ import { Node } from './Node.js'
16
16
 
17
17
  export type AnyConfig = ExtensionConfig | NodeConfig | MarkConfig
18
18
  export type AnyExtension = Extension | Node | Mark
@@ -1,5 +1,5 @@
1
- import { MaybeReturnType } from '../types'
2
- import { isFunction } from './isFunction'
1
+ import { MaybeReturnType } from '../types.js'
2
+ import { isFunction } from './isFunction.js'
3
3
 
4
4
  /**
5
5
  * Optionally calls `value` as a function.
@@ -1,20 +1,20 @@
1
- export * from './callOrReturn'
2
- export * from './createStyleTag'
3
- export * from './deleteProps'
4
- export * from './elementFromString'
5
- export * from './escapeForRegEx'
6
- export * from './findDuplicates'
7
- export * from './fromString'
8
- export * from './isEmptyObject'
9
- export * from './isFunction'
10
- export * from './isiOS'
11
- export * from './isMacOS'
12
- export * from './isNumber'
13
- export * from './isPlainObject'
14
- export * from './isRegExp'
15
- export * from './isString'
16
- export * from './mergeAttributes'
17
- export * from './mergeDeep'
18
- export * from './minMax'
19
- export * from './objectIncludes'
20
- export * from './removeDuplicates'
1
+ export * from './callOrReturn.js'
2
+ export * from './createStyleTag.js'
3
+ export * from './deleteProps.js'
4
+ export * from './elementFromString.js'
5
+ export * from './escapeForRegEx.js'
6
+ export * from './findDuplicates.js'
7
+ export * from './fromString.js'
8
+ export * from './isEmptyObject.js'
9
+ export * from './isFunction.js'
10
+ export * from './isiOS.js'
11
+ export * from './isMacOS.js'
12
+ export * from './isNumber.js'
13
+ export * from './isPlainObject.js'
14
+ export * from './isRegExp.js'
15
+ export * from './isString.js'
16
+ export * from './mergeAttributes.js'
17
+ export * from './mergeDeep.js'
18
+ export * from './minMax.js'
19
+ export * from './objectIncludes.js'
20
+ export * from './removeDuplicates.js'
@@ -0,0 +1,3 @@
1
+ export function isAndroid(): boolean {
2
+ return navigator.platform === 'Android' || /android/i.test(navigator.userAgent)
3
+ }