@tiptap/core 2.0.0-beta.176 → 2.0.0-beta.179

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 (154) hide show
  1. package/dist/packages/core/src/CommandManager.d.ts +1 -1
  2. package/dist/packages/core/src/Editor.d.ts +3 -3
  3. package/dist/packages/core/src/Extension.d.ts +5 -5
  4. package/dist/packages/core/src/InputRule.d.ts +1 -1
  5. package/dist/packages/core/src/Mark.d.ts +5 -5
  6. package/dist/packages/core/src/Node.d.ts +4 -4
  7. package/dist/packages/core/src/NodeView.d.ts +2 -2
  8. package/dist/packages/core/src/PasteRule.d.ts +1 -1
  9. package/dist/packages/core/src/commands/deleteRange.d.ts +1 -1
  10. package/dist/packages/core/src/commands/focus.d.ts +1 -1
  11. package/dist/packages/core/src/commands/index.d.ts +50 -0
  12. package/dist/packages/core/src/commands/insertContent.d.ts +1 -1
  13. package/dist/packages/core/src/commands/insertContentAt.d.ts +1 -1
  14. package/dist/packages/core/src/commands/resetAttributes.d.ts +1 -1
  15. package/dist/packages/core/src/commands/setContent.d.ts +1 -1
  16. package/dist/packages/core/src/commands/setTextSelection.d.ts +1 -1
  17. package/dist/packages/core/src/commands/updateAttributes.d.ts +1 -1
  18. package/dist/packages/core/src/extensions/commands.d.ts +1 -100
  19. package/dist/packages/core/src/helpers/createDocument.d.ts +1 -1
  20. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +1 -1
  21. package/dist/packages/core/src/helpers/findChildren.d.ts +1 -1
  22. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +1 -1
  23. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +1 -1
  24. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +1 -1
  25. package/dist/packages/core/src/helpers/getExtensionField.d.ts +1 -1
  26. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +1 -1
  27. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +1 -1
  28. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +1 -1
  29. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +1 -1
  30. package/dist/packages/core/src/helpers/getText.d.ts +1 -1
  31. package/dist/packages/core/src/helpers/getTextBetween.d.ts +1 -1
  32. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +2 -0
  33. package/dist/packages/core/src/helpers/index.d.ts +33 -0
  34. package/dist/packages/core/src/helpers/isMarkActive.d.ts +1 -1
  35. package/dist/packages/core/src/helpers/isNodeActive.d.ts +1 -1
  36. package/dist/packages/core/src/helpers/splitExtensions.d.ts +2 -2
  37. package/dist/packages/core/src/index.d.ts +9 -48
  38. package/dist/packages/core/src/inputRules/index.d.ts +5 -0
  39. package/dist/packages/core/src/inputRules/markInputRule.d.ts +1 -1
  40. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +1 -1
  41. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +1 -1
  42. package/dist/packages/core/src/pasteRules/index.d.ts +2 -0
  43. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +1 -1
  44. package/dist/packages/core/src/types.d.ts +6 -5
  45. package/dist/packages/core/src/utilities/index.d.ts +3 -0
  46. package/dist/tiptap-core.cjs.js +3477 -3706
  47. package/dist/tiptap-core.cjs.js.map +1 -1
  48. package/dist/tiptap-core.esm.js +3467 -3697
  49. package/dist/tiptap-core.esm.js.map +1 -1
  50. package/dist/tiptap-core.umd.js +3466 -3695
  51. package/dist/tiptap-core.umd.js.map +1 -1
  52. package/package.json +2 -2
  53. package/src/CommandManager.ts +4 -3
  54. package/src/Editor.ts +14 -13
  55. package/src/Extension.ts +10 -9
  56. package/src/ExtensionManager.ts +11 -10
  57. package/src/InputRule.ts +9 -12
  58. package/src/Mark.ts +11 -10
  59. package/src/Node.ts +11 -10
  60. package/src/NodeView.ts +4 -3
  61. package/src/PasteRule.ts +7 -6
  62. package/src/commands/clearNodes.ts +1 -0
  63. package/src/commands/createParagraphNear.ts +1 -0
  64. package/src/commands/deleteNode.ts +1 -0
  65. package/src/commands/deleteRange.ts +1 -1
  66. package/src/commands/deleteSelection.ts +1 -0
  67. package/src/commands/exitCode.ts +1 -0
  68. package/src/commands/extendMarkRange.ts +4 -3
  69. package/src/commands/focus.ts +3 -3
  70. package/src/commands/index.ts +50 -0
  71. package/src/commands/insertContent.ts +2 -1
  72. package/src/commands/insertContentAt.ts +2 -1
  73. package/src/commands/joinBackward.ts +1 -0
  74. package/src/commands/joinForward.ts +1 -0
  75. package/src/commands/lift.ts +3 -2
  76. package/src/commands/liftEmptyBlock.ts +1 -0
  77. package/src/commands/liftListItem.ts +3 -2
  78. package/src/commands/newlineInCode.ts +1 -0
  79. package/src/commands/resetAttributes.ts +4 -3
  80. package/src/commands/selectNodeBackward.ts +1 -0
  81. package/src/commands/selectNodeForward.ts +1 -0
  82. package/src/commands/selectParentNode.ts +1 -0
  83. package/src/commands/selectTextblockEnd.ts +1 -0
  84. package/src/commands/selectTextblockStart.ts +1 -0
  85. package/src/commands/setContent.ts +3 -2
  86. package/src/commands/setMark.ts +3 -2
  87. package/src/commands/setNode.ts +3 -2
  88. package/src/commands/setNodeSelection.ts +3 -2
  89. package/src/commands/setTextSelection.ts +2 -1
  90. package/src/commands/sinkListItem.ts +3 -2
  91. package/src/commands/splitBlock.ts +3 -2
  92. package/src/commands/splitListItem.ts +5 -4
  93. package/src/commands/toggleList.ts +3 -2
  94. package/src/commands/toggleMark.ts +2 -1
  95. package/src/commands/toggleNode.ts +3 -2
  96. package/src/commands/toggleWrap.ts +3 -2
  97. package/src/commands/unsetMark.ts +3 -2
  98. package/src/commands/updateAttributes.ts +3 -2
  99. package/src/commands/wrapIn.ts +2 -1
  100. package/src/commands/wrapInList.ts +3 -2
  101. package/src/extensions/clipboardTextSerializer.ts +1 -0
  102. package/src/extensions/commands.ts +3 -150
  103. package/src/extensions/editable.ts +1 -0
  104. package/src/extensions/focusEvents.ts +1 -0
  105. package/src/extensions/keymap.ts +3 -2
  106. package/src/extensions/tabindex.ts +1 -0
  107. package/src/helpers/createDocument.ts +2 -1
  108. package/src/helpers/createNodeFromContent.ts +4 -3
  109. package/src/helpers/findChildren.ts +2 -1
  110. package/src/helpers/findChildrenInRange.ts +2 -1
  111. package/src/helpers/findParentNode.ts +2 -1
  112. package/src/helpers/findParentNodeClosestToPos.ts +2 -1
  113. package/src/helpers/generateHTML.ts +3 -2
  114. package/src/helpers/generateJSON.ts +3 -2
  115. package/src/helpers/generateText.ts +3 -2
  116. package/src/helpers/getAttributes.ts +3 -2
  117. package/src/helpers/getAttributesFromExtensions.ts +18 -11
  118. package/src/helpers/getChangedRanges.ts +2 -1
  119. package/src/helpers/getDebugJSON.ts +1 -0
  120. package/src/helpers/getExtensionField.ts +1 -1
  121. package/src/helpers/getHTMLFromFragment.ts +1 -1
  122. package/src/helpers/getMarkAttributes.ts +2 -1
  123. package/src/helpers/getMarkRange.ts +2 -1
  124. package/src/helpers/getMarksBetween.ts +1 -0
  125. package/src/helpers/getNodeAttributes.ts +2 -1
  126. package/src/helpers/getRenderedAttributes.ts +2 -1
  127. package/src/helpers/getSchema.ts +2 -1
  128. package/src/helpers/getSchemaByResolvedExtensions.ts +7 -6
  129. package/src/helpers/getText.ts +2 -1
  130. package/src/helpers/getTextBetween.ts +3 -2
  131. package/src/helpers/getTextContentFromNodes.ts +17 -0
  132. package/src/helpers/getTextSerializersFromSchema.ts +1 -0
  133. package/src/helpers/index.ts +33 -0
  134. package/src/helpers/injectExtensionAttributesToParseRule.ts +1 -0
  135. package/src/helpers/isActive.ts +3 -2
  136. package/src/helpers/isList.ts +3 -3
  137. package/src/helpers/isMarkActive.ts +3 -2
  138. package/src/helpers/isNodeActive.ts +3 -2
  139. package/src/helpers/isNodeSelection.ts +1 -0
  140. package/src/helpers/isTextSelection.ts +1 -0
  141. package/src/helpers/posToDOMRect.ts +1 -0
  142. package/src/helpers/resolveFocusPosition.ts +1 -0
  143. package/src/helpers/selectionToInsertionEnd.ts +1 -1
  144. package/src/helpers/splitExtensions.ts +2 -2
  145. package/src/index.ts +9 -52
  146. package/src/inputRules/index.ts +5 -0
  147. package/src/inputRules/markInputRule.ts +3 -2
  148. package/src/inputRules/nodeInputRule.ts +1 -0
  149. package/src/inputRules/textblockTypeInputRule.ts +2 -1
  150. package/src/inputRules/wrappingInputRule.ts +3 -2
  151. package/src/pasteRules/index.ts +2 -0
  152. package/src/pasteRules/markPasteRule.ts +3 -2
  153. package/src/types.ts +11 -9
  154. package/src/utilities/index.ts +3 -0
@@ -1,8 +1,9 @@
1
- import { canSplit } from 'prosemirror-transform'
2
1
  import { ContentMatch } from 'prosemirror-model'
3
2
  import { EditorState, NodeSelection, TextSelection } from 'prosemirror-state'
4
- import { RawCommands } from '../types'
3
+ import { canSplit } from 'prosemirror-transform'
4
+
5
5
  import { getSplittedAttributes } from '../helpers/getSplittedAttributes'
6
+ import { RawCommands } from '../types'
6
7
 
7
8
  function defaultBlockAt(match: ContentMatch) {
8
9
  for (let i = 0; i < match.edgeCount; i += 1) {
@@ -1,14 +1,15 @@
1
1
  import {
2
- NodeType,
3
- Node as ProseMirrorNode,
4
2
  Fragment,
3
+ Node as ProseMirrorNode,
4
+ NodeType,
5
5
  Slice,
6
6
  } from 'prosemirror-model'
7
- import { canSplit } from 'prosemirror-transform'
8
7
  import { TextSelection } from 'prosemirror-state'
9
- import { RawCommands } from '../types'
8
+ import { canSplit } from 'prosemirror-transform'
9
+
10
10
  import { getNodeType } from '../helpers/getNodeType'
11
11
  import { getSplittedAttributes } from '../helpers/getSplittedAttributes'
12
+ import { RawCommands } from '../types'
12
13
 
13
14
  declare module '@tiptap/core' {
14
15
  interface Commands<ReturnType> {
@@ -1,10 +1,11 @@
1
1
  import { NodeType } from 'prosemirror-model'
2
2
  import { Transaction } from 'prosemirror-state'
3
3
  import { canJoin } from 'prosemirror-transform'
4
- import { RawCommands } from '../types'
5
- import { getNodeType } from '../helpers/getNodeType'
4
+
6
5
  import { findParentNode } from '../helpers/findParentNode'
6
+ import { getNodeType } from '../helpers/getNodeType'
7
7
  import { isList } from '../helpers/isList'
8
+ import { RawCommands } from '../types'
8
9
 
9
10
  const joinListBackwards = (tr: Transaction, listType: NodeType): boolean => {
10
11
  const list = findParentNode(node => node.type === listType)(tr.selection)
@@ -1,7 +1,8 @@
1
1
  import { MarkType } from 'prosemirror-model'
2
- import { RawCommands } from '../types'
2
+
3
3
  import { getMarkType } from '../helpers/getMarkType'
4
4
  import { isMarkActive } from '../helpers/isMarkActive'
5
+ import { RawCommands } from '../types'
5
6
 
6
7
  declare module '@tiptap/core' {
7
8
  interface Commands<ReturnType> {
@@ -1,7 +1,8 @@
1
1
  import { NodeType } from 'prosemirror-model'
2
- import { RawCommands } from '../types'
3
- import { isNodeActive } from '../helpers/isNodeActive'
2
+
4
3
  import { getNodeType } from '../helpers/getNodeType'
4
+ import { isNodeActive } from '../helpers/isNodeActive'
5
+ import { RawCommands } from '../types'
5
6
 
6
7
  declare module '@tiptap/core' {
7
8
  interface Commands<ReturnType> {
@@ -1,7 +1,8 @@
1
1
  import { NodeType } from 'prosemirror-model'
2
- import { RawCommands } from '../types'
3
- import { isNodeActive } from '../helpers/isNodeActive'
2
+
4
3
  import { getNodeType } from '../helpers/getNodeType'
4
+ import { isNodeActive } from '../helpers/isNodeActive'
5
+ import { RawCommands } from '../types'
5
6
 
6
7
  declare module '@tiptap/core' {
7
8
  interface Commands<ReturnType> {
@@ -1,7 +1,8 @@
1
1
  import { MarkType } from 'prosemirror-model'
2
- import { RawCommands } from '../types'
3
- import { getMarkType } from '../helpers/getMarkType'
2
+
4
3
  import { getMarkRange } from '../helpers/getMarkRange'
4
+ import { getMarkType } from '../helpers/getMarkType'
5
+ import { RawCommands } from '../types'
5
6
 
6
7
  declare module '@tiptap/core' {
7
8
  interface Commands<ReturnType> {
@@ -1,6 +1,7 @@
1
- import { NodeType, MarkType } from 'prosemirror-model'
2
- import { getNodeType } from '../helpers/getNodeType'
1
+ import { MarkType, NodeType } from 'prosemirror-model'
2
+
3
3
  import { getMarkType } from '../helpers/getMarkType'
4
+ import { getNodeType } from '../helpers/getNodeType'
4
5
  import { getSchemaTypeNameByName } from '../helpers/getSchemaTypeNameByName'
5
6
  import { RawCommands } from '../types'
6
7
 
@@ -1,7 +1,8 @@
1
1
  import { wrapIn as originalWrapIn } from 'prosemirror-commands'
2
2
  import { NodeType } from 'prosemirror-model'
3
- import { RawCommands } from '../types'
3
+
4
4
  import { getNodeType } from '../helpers/getNodeType'
5
+ import { RawCommands } from '../types'
5
6
 
6
7
  declare module '@tiptap/core' {
7
8
  interface Commands<ReturnType> {
@@ -1,7 +1,8 @@
1
- import { wrapInList as originalWrapInList } from 'prosemirror-schema-list'
2
1
  import { NodeType } from 'prosemirror-model'
3
- import { RawCommands } from '../types'
2
+ import { wrapInList as originalWrapInList } from 'prosemirror-schema-list'
3
+
4
4
  import { getNodeType } from '../helpers/getNodeType'
5
+ import { RawCommands } from '../types'
5
6
 
6
7
  declare module '@tiptap/core' {
7
8
  interface Commands<ReturnType> {
@@ -1,4 +1,5 @@
1
1
  import { Plugin, PluginKey } from 'prosemirror-state'
2
+
2
3
  import { Extension } from '../Extension'
3
4
  import { getTextBetween } from '../helpers/getTextBetween'
4
5
  import { getTextSerializersFromSchema } from '../helpers/getTextSerializersFromSchema'
@@ -1,161 +1,14 @@
1
+ import * as commands from '../commands'
1
2
  import { Extension } from '../Extension'
2
- import * as blur from '../commands/blur'
3
- import * as clearContent from '../commands/clearContent'
4
- import * as clearNodes from '../commands/clearNodes'
5
- import * as command from '../commands/command'
6
- import * as createParagraphNear from '../commands/createParagraphNear'
7
- import * as deleteNode from '../commands/deleteNode'
8
- import * as deleteRange from '../commands/deleteRange'
9
- import * as deleteSelection from '../commands/deleteSelection'
10
- import * as enter from '../commands/enter'
11
- import * as exitCode from '../commands/exitCode'
12
- import * as extendMarkRange from '../commands/extendMarkRange'
13
- import * as first from '../commands/first'
14
- import * as focus from '../commands/focus'
15
- import * as forEach from '../commands/forEach'
16
- import * as insertContent from '../commands/insertContent'
17
- import * as insertContentAt from '../commands/insertContentAt'
18
- import * as joinBackward from '../commands/joinBackward'
19
- import * as joinForward from '../commands/joinForward'
20
- import * as keyboardShortcut from '../commands/keyboardShortcut'
21
- import * as lift from '../commands/lift'
22
- import * as liftEmptyBlock from '../commands/liftEmptyBlock'
23
- import * as liftListItem from '../commands/liftListItem'
24
- import * as newlineInCode from '../commands/newlineInCode'
25
- import * as resetAttributes from '../commands/resetAttributes'
26
- import * as scrollIntoView from '../commands/scrollIntoView'
27
- import * as selectAll from '../commands/selectAll'
28
- import * as selectNodeBackward from '../commands/selectNodeBackward'
29
- import * as selectNodeForward from '../commands/selectNodeForward'
30
- import * as selectParentNode from '../commands/selectParentNode'
31
- import * as selectTextblockEnd from '../commands/selectTextblockEnd'
32
- import * as selectTextblockStart from '../commands/selectTextblockStart'
33
- import * as setContent from '../commands/setContent'
34
- import * as setMark from '../commands/setMark'
35
- import * as setMeta from '../commands/setMeta'
36
- import * as setNode from '../commands/setNode'
37
- import * as setNodeSelection from '../commands/setNodeSelection'
38
- import * as setTextSelection from '../commands/setTextSelection'
39
- import * as sinkListItem from '../commands/sinkListItem'
40
- import * as splitBlock from '../commands/splitBlock'
41
- import * as splitListItem from '../commands/splitListItem'
42
- import * as toggleList from '../commands/toggleList'
43
- import * as toggleMark from '../commands/toggleMark'
44
- import * as toggleNode from '../commands/toggleNode'
45
- import * as toggleWrap from '../commands/toggleWrap'
46
- import * as undoInputRule from '../commands/undoInputRule'
47
- import * as unsetAllMarks from '../commands/unsetAllMarks'
48
- import * as unsetMark from '../commands/unsetMark'
49
- import * as updateAttributes from '../commands/updateAttributes'
50
- import * as wrapIn from '../commands/wrapIn'
51
- import * as wrapInList from '../commands/wrapInList'
52
3
 
53
- export { blur }
54
- export { clearContent }
55
- export { clearNodes }
56
- export { command }
57
- export { createParagraphNear }
58
- export { deleteNode }
59
- export { deleteRange }
60
- export { deleteSelection }
61
- export { enter }
62
- export { exitCode }
63
- export { extendMarkRange }
64
- export { first }
65
- export { focus }
66
- export { forEach }
67
- export { insertContent }
68
- export { insertContentAt }
69
- export { joinBackward }
70
- export { joinForward }
71
- export { keyboardShortcut }
72
- export { lift }
73
- export { liftEmptyBlock }
74
- export { liftListItem }
75
- export { newlineInCode }
76
- export { resetAttributes }
77
- export { scrollIntoView }
78
- export { selectAll }
79
- export { selectNodeBackward }
80
- export { selectNodeForward }
81
- export { selectParentNode }
82
- export { selectTextblockEnd }
83
- export { selectTextblockStart }
84
- export { setContent }
85
- export { setMark }
86
- export { setMeta }
87
- export { setNode }
88
- export { setNodeSelection }
89
- export { setTextSelection }
90
- export { sinkListItem }
91
- export { splitBlock }
92
- export { splitListItem }
93
- export { toggleList }
94
- export { toggleMark }
95
- export { toggleNode }
96
- export { toggleWrap }
97
- export { undoInputRule }
98
- export { unsetAllMarks }
99
- export { unsetMark }
100
- export { updateAttributes }
101
- export { wrapIn }
102
- export { wrapInList }
4
+ export * from '../commands'
103
5
 
104
6
  export const Commands = Extension.create({
105
7
  name: 'commands',
106
8
 
107
9
  addCommands() {
108
10
  return {
109
- ...blur,
110
- ...clearContent,
111
- ...clearNodes,
112
- ...command,
113
- ...createParagraphNear,
114
- ...deleteNode,
115
- ...deleteRange,
116
- ...deleteSelection,
117
- ...enter,
118
- ...exitCode,
119
- ...extendMarkRange,
120
- ...first,
121
- ...focus,
122
- ...forEach,
123
- ...insertContent,
124
- ...insertContentAt,
125
- ...joinBackward,
126
- ...joinForward,
127
- ...keyboardShortcut,
128
- ...lift,
129
- ...liftEmptyBlock,
130
- ...liftListItem,
131
- ...newlineInCode,
132
- ...resetAttributes,
133
- ...scrollIntoView,
134
- ...selectAll,
135
- ...selectNodeBackward,
136
- ...selectNodeForward,
137
- ...selectParentNode,
138
- ...selectTextblockEnd,
139
- ...selectTextblockStart,
140
- ...setContent,
141
- ...setMark,
142
- ...setMeta,
143
- ...setNode,
144
- ...setNodeSelection,
145
- ...setTextSelection,
146
- ...sinkListItem,
147
- ...splitBlock,
148
- ...splitListItem,
149
- ...toggleList,
150
- ...toggleMark,
151
- ...toggleNode,
152
- ...toggleWrap,
153
- ...undoInputRule,
154
- ...unsetAllMarks,
155
- ...unsetMark,
156
- ...updateAttributes,
157
- ...wrapIn,
158
- ...wrapInList,
11
+ ...commands,
159
12
  }
160
13
  },
161
14
  })
@@ -1,4 +1,5 @@
1
1
  import { Plugin, PluginKey } from 'prosemirror-state'
2
+
2
3
  import { Extension } from '../Extension'
3
4
 
4
5
  export const Editable = Extension.create({
@@ -1,4 +1,5 @@
1
1
  import { Plugin, PluginKey } from 'prosemirror-state'
2
+
2
3
  import { Extension } from '../Extension'
3
4
 
4
5
  export const FocusEvents = Extension.create({
@@ -1,9 +1,10 @@
1
1
  import { Plugin, PluginKey, Selection } from 'prosemirror-state'
2
+
3
+ import { CommandManager } from '../CommandManager'
4
+ import { Extension } from '../Extension'
2
5
  import { createChainableState } from '../helpers/createChainableState'
3
6
  import { isiOS } from '../utilities/isiOS'
4
7
  import { isMacOS } from '../utilities/isMacOS'
5
- import { CommandManager } from '../CommandManager'
6
- import { Extension } from '../Extension'
7
8
 
8
9
  export const Keymap = Extension.create({
9
10
  name: 'keymap',
@@ -1,4 +1,5 @@
1
1
  import { Plugin, PluginKey } from 'prosemirror-state'
2
+
2
3
  import { Extension } from '../Extension'
3
4
 
4
5
  export const Tabindex = Extension.create({
@@ -1,4 +1,5 @@
1
- import { Schema, Node as ProseMirrorNode, ParseOptions } from 'prosemirror-model'
1
+ import { Node as ProseMirrorNode, ParseOptions, Schema } from 'prosemirror-model'
2
+
2
3
  import { Content } from '../types'
3
4
  import { createNodeFromContent } from './createNodeFromContent'
4
5
 
@@ -1,12 +1,13 @@
1
1
  import {
2
- Schema,
3
2
  DOMParser,
4
- Node as ProseMirrorNode,
5
3
  Fragment,
4
+ Node as ProseMirrorNode,
6
5
  ParseOptions,
6
+ Schema,
7
7
  } from 'prosemirror-model'
8
- import { elementFromString } from '../utilities/elementFromString'
8
+
9
9
  import { Content } from '../types'
10
+ import { elementFromString } from '../utilities/elementFromString'
10
11
 
11
12
  export type CreateNodeFromContentOptions = {
12
13
  slice?: boolean,
@@ -1,5 +1,6 @@
1
1
  import { Node as ProseMirrorNode } from 'prosemirror-model'
2
- import { Predicate, NodeWithPos } from '../types'
2
+
3
+ import { NodeWithPos, Predicate } from '../types'
3
4
 
4
5
  export function findChildren(node: ProseMirrorNode, predicate: Predicate): NodeWithPos[] {
5
6
  const nodesWithPos: NodeWithPos[] = []
@@ -1,5 +1,6 @@
1
1
  import { Node as ProseMirrorNode } from 'prosemirror-model'
2
- import { Predicate, Range, NodeWithPos } from '../types'
2
+
3
+ import { NodeWithPos, Predicate, Range } from '../types'
3
4
 
4
5
  /**
5
6
  * Same as `findChildren` but searches only within a `range`.
@@ -1,6 +1,7 @@
1
1
  import { Selection } from 'prosemirror-state'
2
- import { findParentNodeClosestToPos } from './findParentNodeClosestToPos'
2
+
3
3
  import { Predicate } from '../types'
4
+ import { findParentNodeClosestToPos } from './findParentNodeClosestToPos'
4
5
 
5
6
  export function findParentNode(predicate: Predicate) {
6
7
  return (selection: Selection) => findParentNodeClosestToPos(selection.$from, predicate)
@@ -1,4 +1,5 @@
1
- import { ResolvedPos, Node as ProseMirrorNode } from 'prosemirror-model'
1
+ import { Node as ProseMirrorNode, ResolvedPos } from 'prosemirror-model'
2
+
2
3
  import { Predicate } from '../types'
3
4
 
4
5
  export function findParentNodeClosestToPos($pos: ResolvedPos, predicate: Predicate): ({
@@ -1,7 +1,8 @@
1
1
  import { Node } from 'prosemirror-model'
2
- import { getSchema } from './getSchema'
3
- import { getHTMLFromFragment } from './getHTMLFromFragment'
2
+
4
3
  import { Extensions, JSONContent } from '../types'
4
+ import { getHTMLFromFragment } from './getHTMLFromFragment'
5
+ import { getSchema } from './getSchema'
5
6
 
6
7
  export function generateHTML(doc: JSONContent, extensions: Extensions): string {
7
8
  const schema = getSchema(extensions)
@@ -1,7 +1,8 @@
1
1
  import { DOMParser } from 'prosemirror-model'
2
- import { getSchema } from './getSchema'
3
- import { elementFromString } from '../utilities/elementFromString'
2
+
4
3
  import { Extensions } from '../types'
4
+ import { elementFromString } from '../utilities/elementFromString'
5
+ import { getSchema } from './getSchema'
5
6
 
6
7
  export function generateJSON(html: string, extensions: Extensions): Record<string, any> {
7
8
  const schema = getSchema(extensions)
@@ -1,8 +1,9 @@
1
1
  import { Node } from 'prosemirror-model'
2
- import { getSchema } from './getSchema'
2
+
3
3
  import { Extensions, JSONContent, TextSerializer } from '../types'
4
- import { getTextSerializersFromSchema } from './getTextSerializersFromSchema'
4
+ import { getSchema } from './getSchema'
5
5
  import { getText } from './getText'
6
+ import { getTextSerializersFromSchema } from './getTextSerializersFromSchema'
6
7
 
7
8
  export function generateText(
8
9
  doc: JSONContent,
@@ -1,8 +1,9 @@
1
1
  import { MarkType, NodeType } from 'prosemirror-model'
2
2
  import { EditorState } from 'prosemirror-state'
3
- import { getSchemaTypeNameByName } from './getSchemaTypeNameByName'
4
- import { getNodeAttributes } from './getNodeAttributes'
3
+
5
4
  import { getMarkAttributes } from './getMarkAttributes'
5
+ import { getNodeAttributes } from './getNodeAttributes'
6
+ import { getSchemaTypeNameByName } from './getSchemaTypeNameByName'
6
7
 
7
8
  export function getAttributes(
8
9
  state: EditorState,
@@ -1,14 +1,14 @@
1
- import { splitExtensions } from './splitExtensions'
2
- import { getExtensionField } from './getExtensionField'
1
+ import { MarkConfig, NodeConfig } from '..'
3
2
  import {
4
- Extensions,
5
- GlobalAttributes,
6
- Attributes,
3
+ AnyConfig,
7
4
  Attribute,
5
+ Attributes,
8
6
  ExtensionAttribute,
9
- AnyConfig,
7
+ Extensions,
8
+ GlobalAttributes,
10
9
  } from '../types'
11
- import { NodeConfig, MarkConfig } from '..'
10
+ import { getExtensionField } from './getExtensionField'
11
+ import { splitExtensions } from './splitExtensions'
12
12
 
13
13
  /**
14
14
  * Get a list of all extension attributes defined in `addAttribute` and `addGlobalAttribute`.
@@ -24,6 +24,7 @@ export function getAttributesFromExtensions(extensions: Extensions): ExtensionAt
24
24
  renderHTML: null,
25
25
  parseHTML: null,
26
26
  keepOnSplit: true,
27
+ isRequired: false,
27
28
  }
28
29
 
29
30
  extensions.forEach(extension => {
@@ -87,13 +88,19 @@ export function getAttributesFromExtensions(extensions: Extensions): ExtensionAt
87
88
  Object
88
89
  .entries(attributes)
89
90
  .forEach(([name, attribute]) => {
91
+ const mergedAttr = {
92
+ ...defaultAttribute,
93
+ ...attribute,
94
+ }
95
+
96
+ if (attribute.isRequired && attribute.default === undefined) {
97
+ delete mergedAttr.default
98
+ }
99
+
90
100
  extensionAttributes.push({
91
101
  type: extension.name,
92
102
  name,
93
- attribute: {
94
- ...defaultAttribute,
95
- ...attribute,
96
- },
103
+ attribute: mergedAttr,
97
104
  })
98
105
  })
99
106
  })
@@ -1,4 +1,5 @@
1
- import { Transform, Step } from 'prosemirror-transform'
1
+ import { Step, Transform } from 'prosemirror-transform'
2
+
2
3
  import { Range } from '../types'
3
4
  import { removeDuplicates } from '../utilities/removeDuplicates'
4
5
 
@@ -1,4 +1,5 @@
1
1
  import { Node as ProseMirrorNode } from 'prosemirror-model'
2
+
2
3
  import { JSONContent } from '../types'
3
4
 
4
5
  interface DebugJSONContent extends JSONContent {
@@ -1,4 +1,4 @@
1
- import { AnyExtension, RemoveThis, MaybeThisParameterType } from '../types'
1
+ import { AnyExtension, MaybeThisParameterType, RemoveThis } from '../types'
2
2
 
3
3
  export function getExtensionField<T = any>(
4
4
  extension: AnyExtension,
@@ -1,4 +1,4 @@
1
- import { DOMSerializer, Schema, Fragment } from 'prosemirror-model'
1
+ import { DOMSerializer, Fragment, Schema } from 'prosemirror-model'
2
2
 
3
3
  export function getHTMLFromFragment(fragment: Fragment, schema: Schema): string {
4
4
  const documentFragment = DOMSerializer
@@ -1,5 +1,6 @@
1
- import { EditorState } from 'prosemirror-state'
2
1
  import { Mark, MarkType } from 'prosemirror-model'
2
+ import { EditorState } from 'prosemirror-state'
3
+
3
4
  import { getMarkType } from './getMarkType'
4
5
 
5
6
  export function getMarkAttributes(state: EditorState, typeOrName: string | MarkType): Record<string, any> {
@@ -1,6 +1,7 @@
1
1
  import { Mark as ProseMirrorMark, MarkType, ResolvedPos } from 'prosemirror-model'
2
- import { objectIncludes } from '../utilities/objectIncludes'
2
+
3
3
  import { Range } from '../types'
4
+ import { objectIncludes } from '../utilities/objectIncludes'
4
5
 
5
6
  function findMarkInSet(
6
7
  marks: ProseMirrorMark[],
@@ -1,4 +1,5 @@
1
1
  import { Node as ProseMirrorNode } from 'prosemirror-model'
2
+
2
3
  import { MarkRange } from '../types'
3
4
  import { getMarkRange } from './getMarkRange'
4
5
 
@@ -1,5 +1,6 @@
1
- import { EditorState } from 'prosemirror-state'
2
1
  import { Node, NodeType } from 'prosemirror-model'
2
+ import { EditorState } from 'prosemirror-state'
3
+
3
4
  import { getNodeType } from './getNodeType'
4
5
 
5
6
  export function getNodeAttributes(state: EditorState, typeOrName: string | NodeType): Record<string, any> {
@@ -1,4 +1,5 @@
1
- import { Node, Mark } from 'prosemirror-model'
1
+ import { Mark, Node } from 'prosemirror-model'
2
+
2
3
  import { ExtensionAttribute } from '../types'
3
4
  import { mergeAttributes } from '../utilities/mergeAttributes'
4
5
 
@@ -1,7 +1,8 @@
1
1
  import { Schema } from 'prosemirror-model'
2
- import { getSchemaByResolvedExtensions } from './getSchemaByResolvedExtensions'
2
+
3
3
  import { ExtensionManager } from '../ExtensionManager'
4
4
  import { Extensions } from '../types'
5
+ import { getSchemaByResolvedExtensions } from './getSchemaByResolvedExtensions'
5
6
 
6
7
  export function getSchema(extensions: Extensions): Schema {
7
8
  const resolvedExtensions = ExtensionManager.resolve(extensions)
@@ -1,13 +1,14 @@
1
- import { NodeSpec, MarkSpec, Schema } from 'prosemirror-model'
1
+ import { MarkSpec, NodeSpec, Schema } from 'prosemirror-model'
2
+
3
+ import { MarkConfig, NodeConfig } from '..'
2
4
  import { AnyConfig, Extensions } from '../types'
3
- import { NodeConfig, MarkConfig } from '..'
4
- import { splitExtensions } from './splitExtensions'
5
+ import { callOrReturn } from '../utilities/callOrReturn'
6
+ import { isEmptyObject } from '../utilities/isEmptyObject'
5
7
  import { getAttributesFromExtensions } from './getAttributesFromExtensions'
8
+ import { getExtensionField } from './getExtensionField'
6
9
  import { getRenderedAttributes } from './getRenderedAttributes'
7
- import { isEmptyObject } from '../utilities/isEmptyObject'
8
10
  import { injectExtensionAttributesToParseRule } from './injectExtensionAttributesToParseRule'
9
- import { callOrReturn } from '../utilities/callOrReturn'
10
- import { getExtensionField } from './getExtensionField'
11
+ import { splitExtensions } from './splitExtensions'
11
12
 
12
13
  function cleanUpSchemaItem<T>(data: T) {
13
14
  return Object.fromEntries(Object.entries(data).filter(([key, value]) => {
@@ -1,5 +1,6 @@
1
- import { TextSerializer } from '../types'
2
1
  import { Node as ProseMirrorNode } from 'prosemirror-model'
2
+
3
+ import { TextSerializer } from '../types'
3
4
  import { getTextBetween } from './getTextBetween'
4
5
 
5
6
  export function getText(
@@ -1,6 +1,7 @@
1
- import { Range, TextSerializer } from '../types'
2
1
  import { Node as ProseMirrorNode } from 'prosemirror-model'
3
2
 
3
+ import { Range, TextSerializer } from '../types'
4
+
4
5
  export function getTextBetween(
5
6
  startNode: ProseMirrorNode,
6
7
  range: Range,
@@ -34,7 +35,7 @@ export function getTextBetween(
34
35
  range,
35
36
  })
36
37
  } else if (node.isText) {
37
- text += node?.text?.slice(Math.max(from, pos) - pos, to - pos)
38
+ text += node?.text?.slice(Math.max(from, pos) - pos, to - pos) // eslint-disable-line
38
39
  separated = false
39
40
  } else if (node.isBlock && !separated) {
40
41
  text += blockSeparator