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

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 (156) hide show
  1. package/dist/packages/core/src/CommandManager.d.ts +1 -1
  2. package/dist/packages/core/src/Editor.d.ts +4 -4
  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 +4 -4
  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/findParentNode.d.ts +1 -2
  24. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +1 -1
  25. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +1 -1
  26. package/dist/packages/core/src/helpers/getExtensionField.d.ts +1 -1
  27. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +1 -1
  28. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +1 -1
  29. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +1 -1
  30. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +1 -1
  31. package/dist/packages/core/src/helpers/getText.d.ts +1 -1
  32. package/dist/packages/core/src/helpers/getTextBetween.d.ts +1 -1
  33. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +2 -0
  34. package/dist/packages/core/src/helpers/index.d.ts +33 -0
  35. package/dist/packages/core/src/helpers/isMarkActive.d.ts +1 -1
  36. package/dist/packages/core/src/helpers/isNodeActive.d.ts +1 -1
  37. package/dist/packages/core/src/helpers/splitExtensions.d.ts +2 -2
  38. package/dist/packages/core/src/index.d.ts +9 -48
  39. package/dist/packages/core/src/inputRules/index.d.ts +5 -0
  40. package/dist/packages/core/src/inputRules/markInputRule.d.ts +1 -1
  41. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +1 -1
  42. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +1 -1
  43. package/dist/packages/core/src/pasteRules/index.d.ts +2 -0
  44. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +1 -1
  45. package/dist/packages/core/src/types.d.ts +6 -5
  46. package/dist/packages/core/src/utilities/index.d.ts +3 -0
  47. package/dist/tiptap-core.cjs.js +3471 -3703
  48. package/dist/tiptap-core.cjs.js.map +1 -1
  49. package/dist/tiptap-core.esm.js +3431 -3664
  50. package/dist/tiptap-core.esm.js.map +1 -1
  51. package/dist/tiptap-core.umd.js +3276 -3508
  52. package/dist/tiptap-core.umd.js.map +1 -1
  53. package/package.json +9 -16
  54. package/src/CommandManager.ts +4 -3
  55. package/src/Editor.ts +16 -15
  56. package/src/Extension.ts +10 -9
  57. package/src/ExtensionManager.ts +11 -10
  58. package/src/InputRule.ts +10 -13
  59. package/src/Mark.ts +11 -10
  60. package/src/Node.ts +11 -10
  61. package/src/NodeView.ts +7 -6
  62. package/src/PasteRule.ts +8 -7
  63. package/src/commands/clearNodes.ts +1 -0
  64. package/src/commands/createParagraphNear.ts +1 -0
  65. package/src/commands/deleteNode.ts +1 -0
  66. package/src/commands/deleteRange.ts +1 -1
  67. package/src/commands/deleteSelection.ts +1 -0
  68. package/src/commands/exitCode.ts +1 -0
  69. package/src/commands/extendMarkRange.ts +4 -3
  70. package/src/commands/focus.ts +3 -3
  71. package/src/commands/index.ts +50 -0
  72. package/src/commands/insertContent.ts +2 -1
  73. package/src/commands/insertContentAt.ts +2 -1
  74. package/src/commands/joinBackward.ts +1 -0
  75. package/src/commands/joinForward.ts +1 -0
  76. package/src/commands/lift.ts +3 -2
  77. package/src/commands/liftEmptyBlock.ts +1 -0
  78. package/src/commands/liftListItem.ts +3 -2
  79. package/src/commands/newlineInCode.ts +1 -0
  80. package/src/commands/resetAttributes.ts +4 -3
  81. package/src/commands/selectNodeBackward.ts +1 -0
  82. package/src/commands/selectNodeForward.ts +1 -0
  83. package/src/commands/selectParentNode.ts +1 -0
  84. package/src/commands/selectTextblockEnd.ts +1 -0
  85. package/src/commands/selectTextblockStart.ts +1 -0
  86. package/src/commands/setContent.ts +3 -2
  87. package/src/commands/setMark.ts +3 -2
  88. package/src/commands/setNode.ts +3 -2
  89. package/src/commands/setNodeSelection.ts +3 -2
  90. package/src/commands/setTextSelection.ts +2 -1
  91. package/src/commands/sinkListItem.ts +3 -2
  92. package/src/commands/splitBlock.ts +3 -2
  93. package/src/commands/splitListItem.ts +5 -4
  94. package/src/commands/toggleList.ts +3 -2
  95. package/src/commands/toggleMark.ts +2 -1
  96. package/src/commands/toggleNode.ts +3 -2
  97. package/src/commands/toggleWrap.ts +3 -2
  98. package/src/commands/unsetMark.ts +3 -2
  99. package/src/commands/updateAttributes.ts +3 -2
  100. package/src/commands/wrapIn.ts +2 -1
  101. package/src/commands/wrapInList.ts +3 -2
  102. package/src/extensions/clipboardTextSerializer.ts +1 -0
  103. package/src/extensions/commands.ts +3 -150
  104. package/src/extensions/editable.ts +1 -0
  105. package/src/extensions/focusEvents.ts +1 -0
  106. package/src/extensions/keymap.ts +3 -2
  107. package/src/extensions/tabindex.ts +2 -7
  108. package/src/helpers/createChainableState.ts +3 -2
  109. package/src/helpers/createDocument.ts +2 -1
  110. package/src/helpers/createNodeFromContent.ts +4 -3
  111. package/src/helpers/findChildren.ts +2 -1
  112. package/src/helpers/findChildrenInRange.ts +2 -1
  113. package/src/helpers/findParentNode.ts +2 -1
  114. package/src/helpers/findParentNodeClosestToPos.ts +2 -1
  115. package/src/helpers/generateHTML.ts +3 -2
  116. package/src/helpers/generateJSON.ts +3 -2
  117. package/src/helpers/generateText.ts +3 -2
  118. package/src/helpers/getAttributes.ts +3 -2
  119. package/src/helpers/getAttributesFromExtensions.ts +18 -11
  120. package/src/helpers/getChangedRanges.ts +2 -1
  121. package/src/helpers/getDebugJSON.ts +1 -0
  122. package/src/helpers/getExtensionField.ts +1 -1
  123. package/src/helpers/getHTMLFromFragment.ts +1 -1
  124. package/src/helpers/getMarkAttributes.ts +2 -1
  125. package/src/helpers/getMarkRange.ts +5 -4
  126. package/src/helpers/getMarksBetween.ts +1 -0
  127. package/src/helpers/getNodeAttributes.ts +2 -1
  128. package/src/helpers/getRenderedAttributes.ts +2 -1
  129. package/src/helpers/getSchema.ts +2 -1
  130. package/src/helpers/getSchemaByResolvedExtensions.ts +7 -6
  131. package/src/helpers/getText.ts +2 -1
  132. package/src/helpers/getTextBetween.ts +12 -9
  133. package/src/helpers/getTextContentFromNodes.ts +17 -0
  134. package/src/helpers/getTextSerializersFromSchema.ts +1 -0
  135. package/src/helpers/index.ts +33 -0
  136. package/src/helpers/injectExtensionAttributesToParseRule.ts +1 -0
  137. package/src/helpers/isActive.ts +3 -2
  138. package/src/helpers/isList.ts +3 -3
  139. package/src/helpers/isMarkActive.ts +3 -2
  140. package/src/helpers/isNodeActive.ts +3 -2
  141. package/src/helpers/isNodeSelection.ts +1 -0
  142. package/src/helpers/isTextSelection.ts +1 -0
  143. package/src/helpers/posToDOMRect.ts +1 -0
  144. package/src/helpers/resolveFocusPosition.ts +1 -0
  145. package/src/helpers/selectionToInsertionEnd.ts +1 -1
  146. package/src/helpers/splitExtensions.ts +2 -2
  147. package/src/index.ts +9 -52
  148. package/src/inputRules/index.ts +5 -0
  149. package/src/inputRules/markInputRule.ts +3 -2
  150. package/src/inputRules/nodeInputRule.ts +1 -0
  151. package/src/inputRules/textblockTypeInputRule.ts +2 -1
  152. package/src/inputRules/wrappingInputRule.ts +3 -2
  153. package/src/pasteRules/index.ts +2 -0
  154. package/src/pasteRules/markPasteRule.ts +3 -2
  155. package/src/types.ts +11 -9
  156. package/src/utilities/index.ts +3 -0
@@ -1,7 +1,8 @@
1
- import { TextSelection } from 'prosemirror-state'
2
1
  import { ParseOptions } from 'prosemirror-model'
2
+ import { TextSelection } from 'prosemirror-state'
3
+
3
4
  import { createDocument } from '../helpers/createDocument'
4
- import { RawCommands, Content } from '../types'
5
+ import { Content, 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 { getMarkAttributes } from '../helpers/getMarkAttributes'
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,7 +1,8 @@
1
- import { NodeType } from 'prosemirror-model'
2
1
  import { setBlockType } from 'prosemirror-commands'
3
- import { RawCommands } from '../types'
2
+ import { NodeType } from 'prosemirror-model'
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,6 +1,7 @@
1
- import { Selection, NodeSelection } from 'prosemirror-state'
2
- import { minMax } from '../utilities/minMax'
1
+ import { NodeSelection, Selection } from 'prosemirror-state'
2
+
3
3
  import { RawCommands } from '../types'
4
+ import { minMax } from '../utilities/minMax'
4
5
 
5
6
  declare module '@tiptap/core' {
6
7
  interface Commands<ReturnType> {
@@ -1,6 +1,7 @@
1
1
  import { TextSelection } from 'prosemirror-state'
2
+
3
+ import { Range, RawCommands } from '../types'
2
4
  import { minMax } from '../utilities/minMax'
3
- import { RawCommands, Range } from '../types'
4
5
 
5
6
  declare module '@tiptap/core' {
6
7
  interface Commands<ReturnType> {
@@ -1,7 +1,8 @@
1
- import { sinkListItem as originalSinkListItem } from 'prosemirror-schema-list'
2
1
  import { NodeType } from 'prosemirror-model'
3
- import { RawCommands } from '../types'
2
+ import { sinkListItem as originalSinkListItem } 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,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({
@@ -9,13 +10,7 @@ export const Tabindex = Extension.create({
9
10
  new Plugin({
10
11
  key: new PluginKey('tabindex'),
11
12
  props: {
12
- attributes: () => {
13
- if (this.editor.isEditable) {
14
- return {
15
- tabindex: '0',
16
- }
17
- }
18
- },
13
+ attributes: this.editor.isEditable ? { tabindex: '0' } : {},
19
14
  },
20
15
  }),
21
16
  ]
@@ -11,10 +11,11 @@ export function createChainableState(config: {
11
11
 
12
12
  return {
13
13
  ...state,
14
- schema: state.schema,
15
- plugins: state.plugins,
16
14
  apply: state.apply.bind(state),
17
15
  applyTransaction: state.applyTransaction.bind(state),
16
+ filterTransaction: state.filterTransaction,
17
+ plugins: state.plugins,
18
+ schema: state.schema,
18
19
  reconfigure: state.reconfigure.bind(state),
19
20
  toJSON: state.toJSON.bind(state),
20
21
  get storedMarks() {
@@ -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> {