@handlewithcare/react-prosemirror 3.1.0-tiptap.40 → 3.1.0-tiptap.42

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 (142) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/ReactEditorView.js +71 -75
  3. package/dist/cjs/StaticEditorView.js +19 -22
  4. package/dist/cjs/browser.js +1 -3
  5. package/dist/cjs/commands/reorderSiblings.js +9 -13
  6. package/dist/cjs/components/ChildNodeViews.js +68 -71
  7. package/dist/cjs/components/CursorWrapper.js +26 -17
  8. package/dist/cjs/components/LayoutGroup.js +12 -16
  9. package/dist/cjs/components/NativeWidgetView.js +15 -19
  10. package/dist/cjs/components/OutputSpec.js +9 -13
  11. package/dist/cjs/components/ProseMirror.js +37 -27
  12. package/dist/cjs/components/ProseMirrorDoc.js +25 -18
  13. package/dist/cjs/components/SeparatorHackView.js +20 -21
  14. package/dist/cjs/components/TextNodeView.js +22 -20
  15. package/dist/cjs/components/TrailingHackView.js +13 -17
  16. package/dist/cjs/components/WidgetView.js +14 -18
  17. package/dist/cjs/components/marks/DefaultMarkView.js +27 -15
  18. package/dist/cjs/components/marks/MarkView.js +32 -23
  19. package/dist/cjs/components/marks/MarkViewConstructorView.js +38 -22
  20. package/dist/cjs/components/marks/ReactMarkView.js +27 -16
  21. package/dist/cjs/components/nodes/DefaultNodeView.js +27 -15
  22. package/dist/cjs/components/nodes/DocNodeView.js +12 -16
  23. package/dist/cjs/components/nodes/NodeView.js +33 -26
  24. package/dist/cjs/components/nodes/NodeViewConstructorView.js +45 -29
  25. package/dist/cjs/components/nodes/ReactNodeView.js +39 -27
  26. package/dist/cjs/constants.js +6 -10
  27. package/dist/cjs/contexts/ChildDescriptionsContext.js +1 -3
  28. package/dist/cjs/contexts/EditorContext.js +1 -3
  29. package/dist/cjs/contexts/EditorStateContext.js +1 -3
  30. package/dist/cjs/contexts/IgnoreMutationContext.js +1 -3
  31. package/dist/cjs/contexts/LayoutGroupContext.js +1 -3
  32. package/dist/cjs/contexts/NodeViewContext.js +1 -3
  33. package/dist/cjs/contexts/SelectNodeContext.js +1 -3
  34. package/dist/cjs/contexts/StopEventContext.js +1 -3
  35. package/dist/cjs/decorations/ReactWidgetType.js +13 -19
  36. package/dist/cjs/decorations/computeDocDeco.js +3 -5
  37. package/dist/cjs/decorations/iterDeco.js +17 -19
  38. package/dist/cjs/decorations/viewDecorations.js +12 -15
  39. package/dist/cjs/dom.js +13 -34
  40. package/dist/cjs/findDOMNode.js +5 -9
  41. package/dist/cjs/hooks/useClientLayoutEffect.js +1 -3
  42. package/dist/cjs/hooks/useComponentEventListeners.js +6 -7
  43. package/dist/cjs/hooks/useEditor.js +30 -28
  44. package/dist/cjs/hooks/useEditorEffect.js +7 -9
  45. package/dist/cjs/hooks/useEditorEventCallback.js +7 -9
  46. package/dist/cjs/hooks/useEditorEventListener.js +6 -8
  47. package/dist/cjs/hooks/useEditorState.js +3 -5
  48. package/dist/cjs/hooks/useEffectEvent.js +1 -3
  49. package/dist/cjs/hooks/useForceUpdate.js +1 -3
  50. package/dist/cjs/hooks/useIgnoreMutation.js +7 -9
  51. package/dist/cjs/hooks/useIsEditorStatic.js +5 -5
  52. package/dist/cjs/hooks/useIsNodeSelected.js +3 -5
  53. package/dist/cjs/hooks/useLayoutGroupEffect.js +5 -7
  54. package/dist/cjs/hooks/useMarkViewDescription.js +25 -24
  55. package/dist/cjs/hooks/useNodePos.js +5 -7
  56. package/dist/cjs/hooks/useNodeViewDescription.js +41 -28
  57. package/dist/cjs/hooks/useReactKeys.js +5 -7
  58. package/dist/cjs/hooks/useSelectNode.js +8 -10
  59. package/dist/cjs/hooks/useStopEvent.js +7 -9
  60. package/dist/cjs/index.js +34 -66
  61. package/dist/cjs/plugins/beforeInputPlugin.js +23 -20
  62. package/dist/cjs/plugins/componentEventListeners.js +6 -8
  63. package/dist/cjs/plugins/componentEventListenersPlugin.js +6 -8
  64. package/dist/cjs/plugins/reactKeys.js +10 -15
  65. package/dist/cjs/props.js +19 -23
  66. package/dist/cjs/refs.js +1 -3
  67. package/dist/cjs/testing/editorViewTestHelpers.js +47 -40
  68. package/dist/cjs/testing/setupProseMirrorView.js +4 -7
  69. package/dist/cjs/tiptap/ReactProseMirrorNodeView.js +6 -10
  70. package/dist/cjs/tiptap/TiptapEditor.js +14 -15
  71. package/dist/cjs/tiptap/TiptapEditorContent.js +28 -18
  72. package/dist/cjs/tiptap/TiptapEditorView.js +34 -23
  73. package/dist/cjs/tiptap/contexts/TiptapEditorContext.js +1 -3
  74. package/dist/cjs/tiptap/extensions/ReactProseMirror.js +6 -8
  75. package/dist/cjs/tiptap/extensions/ReactProseMirrorCommands.js +3 -5
  76. package/dist/cjs/tiptap/extensions/commands/updateAttributes.js +2 -4
  77. package/dist/cjs/tiptap/hooks/useIsInReactProseMirror.js +3 -5
  78. package/dist/cjs/tiptap/hooks/useTiptapEditor.js +14 -12
  79. package/dist/cjs/tiptap/hooks/useTiptapEditorEffect.js +10 -12
  80. package/dist/cjs/tiptap/hooks/useTiptapEditorEventCallback.js +4 -6
  81. package/dist/cjs/tiptap/index.js +18 -36
  82. package/dist/cjs/tiptap/tiptapNodeView.js +62 -48
  83. package/dist/cjs/viewdesc.js +95 -119
  84. package/dist/esm/ReactEditorView.js +67 -69
  85. package/dist/esm/StaticEditorView.js +18 -19
  86. package/dist/esm/commands/reorderSiblings.js +5 -5
  87. package/dist/esm/components/ChildNodeViews.js +36 -33
  88. package/dist/esm/components/CursorWrapper.js +18 -5
  89. package/dist/esm/components/LayoutGroup.js +1 -1
  90. package/dist/esm/components/NativeWidgetView.js +2 -2
  91. package/dist/esm/components/OutputSpec.js +1 -1
  92. package/dist/esm/components/ProseMirror.js +17 -3
  93. package/dist/esm/components/ProseMirrorDoc.js +19 -6
  94. package/dist/esm/components/SeparatorHackView.js +8 -5
  95. package/dist/esm/components/TextNodeView.js +10 -6
  96. package/dist/esm/components/TrailingHackView.js +2 -2
  97. package/dist/esm/components/WidgetView.js +3 -3
  98. package/dist/esm/components/marks/DefaultMarkView.js +22 -6
  99. package/dist/esm/components/marks/MarkView.js +24 -11
  100. package/dist/esm/components/marks/MarkViewConstructorView.js +27 -7
  101. package/dist/esm/components/marks/ReactMarkView.js +18 -3
  102. package/dist/esm/components/nodes/DefaultNodeView.js +22 -6
  103. package/dist/esm/components/nodes/DocNodeView.js +2 -2
  104. package/dist/esm/components/nodes/NodeView.js +24 -11
  105. package/dist/esm/components/nodes/NodeViewConstructorView.js +31 -11
  106. package/dist/esm/components/nodes/ReactNodeView.js +22 -6
  107. package/dist/esm/decorations/ReactWidgetType.js +8 -10
  108. package/dist/esm/decorations/iterDeco.js +13 -13
  109. package/dist/esm/decorations/viewDecorations.js +6 -7
  110. package/dist/esm/dom.js +2 -1
  111. package/dist/esm/findDOMNode.js +1 -1
  112. package/dist/esm/hooks/useComponentEventListeners.js +3 -2
  113. package/dist/esm/hooks/useEditor.js +9 -5
  114. package/dist/esm/hooks/useEditorEffect.js +1 -1
  115. package/dist/esm/hooks/useEditorEventCallback.js +1 -1
  116. package/dist/esm/hooks/useEditorEventListener.js +1 -1
  117. package/dist/esm/hooks/useIsEditorStatic.js +3 -1
  118. package/dist/esm/hooks/useMarkViewDescription.js +10 -7
  119. package/dist/esm/hooks/useNodeViewDescription.js +22 -7
  120. package/dist/esm/hooks/useReactKeys.js +1 -1
  121. package/dist/esm/plugins/beforeInputPlugin.js +17 -12
  122. package/dist/esm/plugins/reactKeys.js +4 -3
  123. package/dist/esm/props.js +15 -15
  124. package/dist/esm/testing/editorViewTestHelpers.js +31 -20
  125. package/dist/esm/testing/setupProseMirrorView.js +2 -1
  126. package/dist/esm/tiptap/ReactProseMirrorNodeView.js +5 -7
  127. package/dist/esm/tiptap/TiptapEditor.js +10 -9
  128. package/dist/esm/tiptap/TiptapEditorContent.js +18 -4
  129. package/dist/esm/tiptap/TiptapEditorView.js +23 -8
  130. package/dist/esm/tiptap/extensions/ReactProseMirror.js +1 -1
  131. package/dist/esm/tiptap/extensions/commands/updateAttributes.js +1 -1
  132. package/dist/esm/tiptap/hooks/useTiptapEditor.js +8 -4
  133. package/dist/esm/tiptap/hooks/useTiptapEditorEffect.js +4 -4
  134. package/dist/esm/tiptap/hooks/useTiptapEditorEventCallback.js +1 -1
  135. package/dist/esm/tiptap/tiptapNodeView.js +38 -20
  136. package/dist/esm/viewdesc.js +72 -74
  137. package/dist/tsconfig.tsbuildinfo +1 -1
  138. package/dist/types/ReactEditorView.d.ts +2 -2
  139. package/dist/types/StaticEditorView.d.ts +2 -1
  140. package/dist/types/props.d.ts +26 -26
  141. package/dist/types/viewdesc.d.ts +2 -0
  142. package/package.json +10 -6
package/README.md CHANGED
@@ -35,7 +35,7 @@ npm install @handlewithcare/react-prosemirror \
35
35
  react@^19.1.0 \
36
36
  react-dom@^19.1.0 \
37
37
  react-reconciler@0.32.0 \
38
- prosemirror-view@1.39.2 \
38
+ prosemirror-view@1.41.7 \
39
39
  prosemirror-state \
40
40
  prosemirror-model
41
41
  ```
@@ -47,7 +47,7 @@ yarn add @handlewithcare/react-prosemirror \
47
47
  react@^19.1.0 \
48
48
  react-dom@^19.1.0 \
49
49
  react-reconciler@0.32.0 \
50
- prosemirror-view@1.39.2 \
50
+ prosemirror-view@1.41.7 \
51
51
  prosemirror-state \
52
52
  prosemirror-model
53
53
  ```
@@ -4,12 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "ReactEditorView", {
6
6
  enumerable: true,
7
- get: function() {
8
- return ReactEditorView;
9
- }
7
+ get: ()=>ReactEditorView
10
8
  });
11
- const _prosemirrorview = require("prosemirror-view");
12
- const _constants = require("./constants.js");
9
+ const _prosemirrorView = require("prosemirror-view");
10
+ const _constantsJs = require("./constants.js");
13
11
  function buildNodeViews(view) {
14
12
  const result = Object.create(null);
15
13
  function add(obj) {
@@ -29,63 +27,7 @@ function changedNodeViews(a, b) {
29
27
  for(const _ in b)nB++;
30
28
  return nA != nB;
31
29
  }
32
- let ReactEditorView = class ReactEditorView extends _prosemirrorview.EditorView {
33
- nextProps;
34
- prevState;
35
- _destroyed;
36
- constructor(place, props){
37
- // Prevent the base class from destroying the React-managed nodes.
38
- // Restore them below after invoking the base class constructor.
39
- const reactContent = [
40
- ...place.mount.childNodes
41
- ];
42
- // Prevent the base class from mutating the React-managed attributes.
43
- // Restore them below after invoking the base class constructor.
44
- const reactAttrs = [
45
- ...place.mount.attributes
46
- ];
47
- for (const attr of reactAttrs){
48
- place.mount.removeAttributeNode(attr);
49
- }
50
- try {
51
- // Call the superclass constructor with only a state and no plugins.
52
- // We'll set everything else ourselves and apply props during layout.
53
- super(place, {
54
- state: _constants.EMPTY_STATE
55
- });
56
- this.domObserver.stop();
57
- this.domObserver.observer = null;
58
- this.domObserver.queue = [];
59
- const originalOnSelectionChange = this.domObserver.onSelectionChange;
60
- this.domObserver.onSelectionChange = ()=>{
61
- // During a composition, we completely pause React-driven
62
- // selection and DOM updates. Compositions are "fragile";
63
- // in Safari, even updating the selection to the same
64
- // position it's already set to will end the current
65
- // composition.
66
- if (this.composing) return;
67
- originalOnSelectionChange();
68
- };
69
- } finally{
70
- place.mount.replaceChildren(...reactContent);
71
- for (const attr of place.mount.attributes){
72
- place.mount.removeAttributeNode(attr);
73
- }
74
- for (const attr of reactAttrs){
75
- place.mount.setAttributeNode(attr);
76
- }
77
- }
78
- this.prevState = _constants.EMPTY_STATE;
79
- this.nextProps = props;
80
- this.state = props.state;
81
- this.nodeViews = buildNodeViews(this);
82
- // Destroy the document view description that the base class makes.
83
- // A React document view will assign itself to this attribute later.
84
- this.docView.destroy();
85
- // @ts-expect-error this violates the typing but class does it, too.
86
- this.docView = null;
87
- this._destroyed = false;
88
- }
30
+ let ReactEditorView = class ReactEditorView extends _prosemirrorView.EditorView {
89
31
  get props() {
90
32
  return this.nextProps;
91
33
  }
@@ -129,27 +71,28 @@ let ReactEditorView = class ReactEditorView extends _prosemirrorview.EditorView
129
71
  return undefined;
130
72
  }
131
73
  const prop = this.props[propName];
132
- if (prop) {
74
+ if (prop != null) {
133
75
  const result = f ? f(prop) : prop;
134
76
  if (result) {
135
77
  return result;
136
78
  }
137
79
  }
138
- for (const plugin of this.props.plugins ?? []){
139
- const prop = plugin.props[propName];
140
- if (prop) {
141
- const result = f ? f(prop) : prop;
142
- if (result) {
143
- return result;
80
+ var _plugins;
81
+ for (const plugin of (_plugins = this.props.plugins) !== null && _plugins !== void 0 ? _plugins : []){
82
+ const prop1 = plugin.props[propName];
83
+ if (prop1 != null) {
84
+ const result1 = f ? f(prop1) : prop1;
85
+ if (result1) {
86
+ return result1;
144
87
  }
145
88
  }
146
89
  }
147
- for (const plugin of this.state.plugins){
148
- const prop = plugin.props[propName];
149
- if (prop) {
150
- const result = f ? f(prop) : prop;
151
- if (result) {
152
- return result;
90
+ for (const plugin1 of this.state.plugins){
91
+ const prop2 = plugin1.props[propName];
92
+ if (prop2 != null) {
93
+ const result2 = f ? f(prop2) : prop2;
94
+ if (result2) {
95
+ return result2;
153
96
  }
154
97
  }
155
98
  }
@@ -189,4 +132,57 @@ let ReactEditorView = class ReactEditorView extends _prosemirrorview.EditorView
189
132
  // Store the new previous state.
190
133
  this.prevState = this.state;
191
134
  }
135
+ constructor(place, props){
136
+ // Prevent the base class from destroying the React-managed nodes.
137
+ // Restore them below after invoking the base class constructor.
138
+ const reactContent = [
139
+ ...place.mount.childNodes
140
+ ];
141
+ // Prevent the base class from mutating the React-managed attributes.
142
+ // Restore them below after invoking the base class constructor.
143
+ const reactAttrs = [
144
+ ...place.mount.attributes
145
+ ];
146
+ for (const attr of reactAttrs){
147
+ place.mount.removeAttributeNode(attr);
148
+ }
149
+ try {
150
+ // Call the superclass constructor with only a state and no plugins.
151
+ // We'll set everything else ourselves and apply props during layout.
152
+ super(place, {
153
+ state: _constantsJs.EMPTY_STATE
154
+ });
155
+ this.domObserver.stop();
156
+ this.domObserver.observer = null;
157
+ this.domObserver.queue = [];
158
+ const originalOnSelectionChange = this.domObserver.onSelectionChange;
159
+ this.domObserver.onSelectionChange = ()=>{
160
+ // During a composition, we completely pause React-driven
161
+ // selection and DOM updates. Compositions are "fragile";
162
+ // in Safari, even updating the selection to the same
163
+ // position it's already set to will end the current
164
+ // composition.
165
+ if (this.composing) return;
166
+ originalOnSelectionChange();
167
+ };
168
+ } finally{
169
+ place.mount.replaceChildren(...reactContent);
170
+ for (const attr1 of place.mount.attributes){
171
+ place.mount.removeAttributeNode(attr1);
172
+ }
173
+ for (const attr2 of reactAttrs){
174
+ place.mount.setAttributeNode(attr2);
175
+ }
176
+ }
177
+ this.prevState = _constantsJs.EMPTY_STATE;
178
+ this.nextProps = props;
179
+ this.state = props.state;
180
+ this.nodeViews = buildNodeViews(this);
181
+ // Destroy the document view description that the base class makes.
182
+ // A React document view will assign itself to this attribute later.
183
+ this.docView.destroy();
184
+ // @ts-expect-error this violates the typing but class does it, too.
185
+ this.docView = null;
186
+ this._destroyed = false;
187
+ }
192
188
  };
@@ -4,17 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "StaticEditorView", {
6
6
  enumerable: true,
7
- get: function() {
8
- return StaticEditorView;
9
- }
7
+ get: ()=>StaticEditorView
10
8
  });
11
9
  let StaticEditorView = class StaticEditorView {
12
- props;
13
- nodeViews;
14
- constructor(props){
15
- this.props = props;
16
- this.nodeViews = {};
17
- }
18
10
  get composing() {
19
11
  return false;
20
12
  }
@@ -46,27 +38,28 @@ let StaticEditorView = class StaticEditorView {
46
38
  }
47
39
  someProp(propName, f) {
48
40
  const prop = this.props[propName];
49
- if (prop) {
41
+ if (prop != null) {
50
42
  const result = f ? f(prop) : prop;
51
43
  if (result) {
52
44
  return result;
53
45
  }
54
46
  }
55
- for (const plugin of this.props.plugins ?? []){
56
- const prop = plugin.props[propName];
57
- if (prop) {
58
- const result = f ? f(prop) : prop;
59
- if (result) {
60
- return result;
47
+ var _plugins;
48
+ for (const plugin of (_plugins = this.props.plugins) !== null && _plugins !== void 0 ? _plugins : []){
49
+ const prop1 = plugin.props[propName];
50
+ if (prop1 != null) {
51
+ const result1 = f ? f(prop1) : prop1;
52
+ if (result1) {
53
+ return result1;
61
54
  }
62
55
  }
63
56
  }
64
- for (const plugin of this.state.plugins){
65
- const prop = plugin.props[propName];
66
- if (prop) {
67
- const result = f ? f(prop) : prop;
68
- if (result) {
69
- return result;
57
+ for (const plugin1 of this.state.plugins){
58
+ const prop2 = plugin1.props[propName];
59
+ if (prop2 != null) {
60
+ const result2 = f ? f(prop2) : prop2;
61
+ if (result2) {
62
+ return result2;
70
63
  }
71
64
  }
72
65
  }
@@ -86,4 +79,8 @@ let StaticEditorView = class StaticEditorView {
86
79
  domSelection() {
87
80
  return null;
88
81
  }
82
+ constructor(props){
83
+ this.props = props;
84
+ this.nodeViews = {};
85
+ }
89
86
  };
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "browser", {
6
6
  enumerable: true,
7
- get: function() {
8
- return browser;
9
- }
7
+ get: ()=>browser
10
8
  });
11
9
  const nav = typeof navigator != "undefined" ? navigator : null;
12
10
  const doc = typeof document != "undefined" ? document : null;
@@ -9,14 +9,10 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- reorderSiblings: function() {
13
- return reorderSiblings;
14
- },
15
- reorderSiblingsOnTransaction: function() {
16
- return reorderSiblingsOnTransaction;
17
- }
12
+ reorderSiblings: ()=>reorderSiblings,
13
+ reorderSiblingsOnTransaction: ()=>reorderSiblingsOnTransaction
18
14
  });
19
- const _reactKeys = require("../plugins/reactKeys.js");
15
+ const _reactKeysJs = require("../plugins/reactKeys.js");
20
16
  function reorderSiblings(pos, order) {
21
17
  return function reorderSiblingsCommand(state, dispatch) {
22
18
  const tr = state.tr;
@@ -57,16 +53,16 @@ function reorderSiblingsOnTransaction(pos, order, tr, state, dispatch) {
57
53
  start = pos;
58
54
  const newPositions = [];
59
55
  for(let i = 0; i < reordered.length; i++){
60
- const node = reordered[i];
56
+ const node1 = reordered[i];
61
57
  newPositions[order[i]] = start;
62
- start += node.nodeSize;
58
+ start += node1.nodeSize;
63
59
  }
64
- for(let i = 0; i < oldPositions.length; i++){
65
- const oldPosition = oldPositions[i];
66
- const newPosition = newPositions[i];
60
+ for(let i1 = 0; i1 < oldPositions.length; i1++){
61
+ const oldPosition = oldPositions[i1];
62
+ const newPosition = newPositions[i1];
67
63
  meta.overrides[oldPosition] = newPosition;
68
64
  }
69
- tr.setMeta(_reactKeys.reactKeysPluginKey, meta);
65
+ tr.setMeta(_reactKeysJs.reactKeysPluginKey, meta);
70
66
  dispatch(tr);
71
67
  return true;
72
68
  }
@@ -9,27 +9,23 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- ChildNodeViews: function() {
13
- return ChildNodeViews;
14
- },
15
- wrapInDeco: function() {
16
- return wrapInDeco;
17
- }
12
+ wrapInDeco: ()=>wrapInDeco,
13
+ ChildNodeViews: ()=>ChildNodeViews
18
14
  });
19
- const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
20
- const _ChildDescriptionsContext = require("../contexts/ChildDescriptionsContext.js");
21
- const _EditorContext = require("../contexts/EditorContext.js");
22
- const _iterDeco = require("../decorations/iterDeco.js");
23
- const _useReactKeys = require("../hooks/useReactKeys.js");
24
- const _props = require("../props.js");
25
- const _viewdesc = require("../viewdesc.js");
26
- const _NativeWidgetView = require("./NativeWidgetView.js");
27
- const _SeparatorHackView = require("./SeparatorHackView.js");
28
- const _TextNodeView = require("./TextNodeView.js");
29
- const _TrailingHackView = require("./TrailingHackView.js");
30
- const _WidgetView = require("./WidgetView.js");
31
- const _MarkView = require("./marks/MarkView.js");
32
- const _NodeView = require("./nodes/NodeView.js");
15
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
16
+ const _childDescriptionsContextJs = require("../contexts/ChildDescriptionsContext.js");
17
+ const _editorContextJs = require("../contexts/EditorContext.js");
18
+ const _iterDecoJs = require("../decorations/iterDeco.js");
19
+ const _useReactKeysJs = require("../hooks/useReactKeys.js");
20
+ const _propsJs = require("../props.js");
21
+ const _viewdescJs = require("../viewdesc.js");
22
+ const _nativeWidgetViewJs = require("./NativeWidgetView.js");
23
+ const _separatorHackViewJs = require("./SeparatorHackView.js");
24
+ const _textNodeViewJs = require("./TextNodeView.js");
25
+ const _trailingHackViewJs = require("./TrailingHackView.js");
26
+ const _widgetViewJs = require("./WidgetView.js");
27
+ const _markViewJs = require("./marks/MarkView.js");
28
+ const _nodeViewJs = require("./nodes/NodeView.js");
33
29
  function _getRequireWildcardCache(nodeInterop) {
34
30
  if (typeof WeakMap !== "function") return null;
35
31
  var cacheBabelInterop = new WeakMap();
@@ -38,7 +34,7 @@ function _getRequireWildcardCache(nodeInterop) {
38
34
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
39
35
  })(nodeInterop);
40
36
  }
41
- function _interop_require_wildcard(obj, nodeInterop) {
37
+ function _interopRequireWildcard(obj, nodeInterop) {
42
38
  if (!nodeInterop && obj && obj.__esModule) {
43
39
  return obj;
44
40
  }
@@ -51,9 +47,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
51
47
  if (cache && cache.has(obj)) {
52
48
  return cache.get(obj);
53
49
  }
54
- var newObj = {
55
- __proto__: null
56
- };
50
+ var newObj = {};
57
51
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
58
52
  for(var key in obj){
59
53
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -72,22 +66,22 @@ function _interop_require_wildcard(obj, nodeInterop) {
72
66
  return newObj;
73
67
  }
74
68
  function wrapInDeco(reactNode, deco) {
75
- const { nodeName, ...attrs } = deco.type.attrs;
76
- const props = (0, _props.htmlAttrsToReactProps)(attrs);
69
+ const { nodeName , ...attrs } = deco.type.attrs;
70
+ const props = (0, _propsJs.htmlAttrsToReactProps)(attrs);
77
71
  // We auto-wrap text nodes in spans so that we can apply attributes
78
72
  // and styles, but we want to avoid double-wrapping the same
79
73
  // text node
80
74
  if (nodeName || typeof reactNode === "string") {
81
- return /*#__PURE__*/ (0, _react.createElement)(nodeName ?? "span", props, reactNode);
75
+ return /*#__PURE__*/ (0, _react.createElement)(nodeName !== null && nodeName !== void 0 ? nodeName : "span", props, reactNode);
82
76
  }
83
- return /*#__PURE__*/ (0, _react.cloneElement)(reactNode, (0, _props.mergeReactProps)(reactNode.props, props));
77
+ return /*#__PURE__*/ (0, _react.cloneElement)(reactNode, (0, _propsJs.mergeReactProps)(reactNode.props, props));
84
78
  }
85
79
  function areChildrenEqual(a, b) {
86
- return a.type === b.type && a.marks.every((mark)=>mark.isInSet(b.marks)) && b.marks.every((mark)=>mark.isInSet(a.marks)) && a.key === b.key && (a.type !== "node" || b.type !== "node" || a.node.eq(b.node) && (0, _viewdesc.sameOuterDeco)(a.outerDeco, b.outerDeco) && a.innerDeco.eq(b.innerDeco)) && a.widget === b.widget;
80
+ return a.type === b.type && a.marks.every((mark)=>mark.isInSet(b.marks)) && b.marks.every((mark)=>mark.isInSet(a.marks)) && a.key === b.key && (a.type !== "node" || b.type !== "node" || a.node.eq(b.node) && (0, _viewdescJs.sameOuterDeco)(a.outerDeco, b.outerDeco) && a.innerDeco.eq(b.innerDeco)) && a.widget === b.widget;
87
81
  }
88
82
  const ChildView = /*#__PURE__*/ (0, _react.memo)(function ChildView(param) {
89
- let { child, getInnerPos } = param;
90
- const { view } = (0, _react.useContext)(_EditorContext.EditorContext);
83
+ let { child , getInnerPos } = param;
84
+ const { view } = (0, _react.useContext)(_editorContextJs.EditorContext);
91
85
  const childRef = (0, _react.useRef)(child);
92
86
  childRef.current = child;
93
87
  const getPos = (0, _react.useCallback)(()=>{
@@ -95,22 +89,22 @@ const ChildView = /*#__PURE__*/ (0, _react.memo)(function ChildView(param) {
95
89
  }, [
96
90
  getInnerPos
97
91
  ]);
98
- return child.type === "widget" ? /*#__PURE__*/ _react.default.createElement(_WidgetView.WidgetView, {
92
+ return child.type === "widget" ? /*#__PURE__*/ _react.default.createElement(_widgetViewJs.WidgetView, {
99
93
  key: child.key,
100
94
  widget: child.widget,
101
95
  getPos: getPos
102
- }) : child.type === "native-widget" ? /*#__PURE__*/ _react.default.createElement(_NativeWidgetView.NativeWidgetView, {
96
+ }) : child.type === "native-widget" ? /*#__PURE__*/ _react.default.createElement(_nativeWidgetViewJs.NativeWidgetView, {
103
97
  key: child.key,
104
98
  widget: child.widget,
105
99
  getPos: getPos
106
100
  }) : child.type === "hack" ? /*#__PURE__*/ _react.default.createElement(child.component, {
107
101
  key: child.key,
108
102
  getPos: getPos
109
- }) : child.node.isText ? /*#__PURE__*/ _react.default.createElement(_ChildDescriptionsContext.ChildDescriptionsContext.Consumer, {
103
+ }) : child.node.isText ? /*#__PURE__*/ _react.default.createElement(_childDescriptionsContextJs.ChildDescriptionsContext.Consumer, {
110
104
  key: child.key
111
- }, (param)=>{
112
- let { siblingsRef, parentRef } = param;
113
- return /*#__PURE__*/ _react.default.createElement(_TextNodeView.TextNodeView, {
105
+ }, (param)=>/*#__PURE__*/ {
106
+ let { siblingsRef , parentRef } = param;
107
+ return _react.default.createElement(_textNodeViewJs.TextNodeView, {
114
108
  view: view,
115
109
  node: child.node,
116
110
  getPos: getPos,
@@ -118,7 +112,7 @@ const ChildView = /*#__PURE__*/ (0, _react.memo)(function ChildView(param) {
118
112
  parentRef: parentRef,
119
113
  decorations: child.outerDeco
120
114
  });
121
- }) : /*#__PURE__*/ _react.default.createElement(_NodeView.NodeView, {
115
+ }) : /*#__PURE__*/ _react.default.createElement(_nodeViewJs.NodeView, {
122
116
  key: child.key,
123
117
  node: child.node,
124
118
  getPos: getPos,
@@ -127,7 +121,7 @@ const ChildView = /*#__PURE__*/ (0, _react.memo)(function ChildView(param) {
127
121
  });
128
122
  });
129
123
  const InlinePartition = /*#__PURE__*/ (0, _react.memo)(function InlinePartition(param) {
130
- let { childViews, getInnerPos } = param;
124
+ let { childViews , getInnerPos } = param;
131
125
  const firstChild = childViews[0];
132
126
  const firstChildRef = (0, _react.useRef)(firstChild);
133
127
  firstChildRef.current = firstChild;
@@ -146,7 +140,7 @@ const InlinePartition = /*#__PURE__*/ (0, _react.memo)(function InlinePartition(
146
140
  });
147
141
  }));
148
142
  }
149
- return /*#__PURE__*/ _react.default.createElement(_MarkView.MarkView, {
143
+ return /*#__PURE__*/ _react.default.createElement(_markViewJs.MarkView, {
150
144
  key: firstChild.key,
151
145
  mark: firstMark,
152
146
  getPos: getPos,
@@ -161,9 +155,11 @@ const InlinePartition = /*#__PURE__*/ (0, _react.memo)(function InlinePartition(
161
155
  }));
162
156
  });
163
157
  const InlineView = /*#__PURE__*/ (0, _react.memo)(function InlineView(param) {
164
- let { getInnerPos, childViews } = param;
158
+ let { getInnerPos , childViews } = param;
165
159
  // const editorState = useEditorState();
166
160
  const partitioned = childViews.reduce((acc, child)=>{
161
+ var // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
162
+ ref;
167
163
  const lastPartition = acc[acc.length - 1];
168
164
  if (!lastPartition) {
169
165
  return [
@@ -181,8 +177,7 @@ const InlineView = /*#__PURE__*/ (0, _react.memo)(function InlineView(param) {
181
177
  ]
182
178
  ];
183
179
  }
184
- if (!child.marks.length && !lastChild.marks.length || child.marks.length && lastChild.marks.length && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
185
- child.marks[0]?.eq(lastChild.marks[0])) {
180
+ if (!child.marks.length && !lastChild.marks.length || child.marks.length && lastChild.marks.length && ((ref = child.marks[0]) === null || ref === void 0 ? void 0 : ref.eq(lastChild.marks[0]))) {
186
181
  return [
187
182
  ...acc.slice(0, acc.length - 1),
188
183
  [
@@ -210,22 +205,22 @@ const InlineView = /*#__PURE__*/ (0, _react.memo)(function InlineView(param) {
210
205
  });
211
206
  function createKey(innerPos, offset, index, type, posToKey, widget) {
212
207
  const pos = innerPos + offset;
213
- const key = posToKey?.get(pos);
208
+ const key = posToKey === null || posToKey === void 0 ? void 0 : posToKey.get(pos);
214
209
  if (type === "widget" || type === "native-widget") {
215
210
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
216
211
  if (widget.type.spec.key) // eslint-disable-next-line @typescript-eslint/no-explicit-any
217
212
  return widget.type.spec.key;
218
213
  if (type === "widget") {
219
214
  // eslint-disable-next-line no-console
220
- console.warn(`Widget at position ${pos} doesn't have a key specified. React ProseMirror will generate a key partially based on this widget’s index into its parent’s children. This can cause issues if there are multiple adjacent widgets.`);
215
+ console.warn("Widget at position ".concat(pos, " doesn't have a key specified. React ProseMirror will generate a key partially based on this widget’s index into its parent’s children. This can cause issues if there are multiple adjacent widgets."));
221
216
  }
222
- return `${key}-${index}`;
217
+ return "".concat(key, "-").concat(index);
223
218
  }
224
219
  if (key) return key;
225
220
  // if (!doc) return pos;
226
221
  const parentPos = innerPos - 1;
227
- const parentKey = posToKey?.get(parentPos);
228
- if (parentKey) return `${parentKey}-${offset}`;
222
+ const parentKey = posToKey === null || posToKey === void 0 ? void 0 : posToKey.get(parentPos);
223
+ if (parentKey) return "".concat(parentKey, "-").concat(offset);
229
224
  return pos;
230
225
  }
231
226
  function adjustWidgetMarksForward(lastNodeChild, widgetChild) {
@@ -251,7 +246,7 @@ function adjustWidgetMarksBack(widgetChildren, nodeChild) {
251
246
  }
252
247
  }
253
248
  const ChildElement = /*#__PURE__*/ (0, _react.memo)(function ChildElement(param) {
254
- let { child, getInnerPos } = param;
249
+ let { child , getInnerPos } = param;
255
250
  const childRef = (0, _react.useRef)(child);
256
251
  childRef.current = child;
257
252
  const getPos = (0, _react.useCallback)(()=>{
@@ -260,11 +255,11 @@ const ChildElement = /*#__PURE__*/ (0, _react.memo)(function ChildElement(param)
260
255
  getInnerPos
261
256
  ]);
262
257
  if (child.type === "node") {
263
- return child.marks.reduce((element, mark)=>/*#__PURE__*/ _react.default.createElement(_MarkView.MarkView, {
258
+ return child.marks.reduce((element, mark)=>/*#__PURE__*/ _react.default.createElement(_markViewJs.MarkView, {
264
259
  mark: mark,
265
260
  getPos: getPos,
266
261
  inline: false
267
- }, element), /*#__PURE__*/ _react.default.createElement(_NodeView.NodeView, {
262
+ }, element), /*#__PURE__*/ _react.default.createElement(_nodeViewJs.NodeView, {
268
263
  key: child.key,
269
264
  outerDeco: child.outerDeco,
270
265
  node: child.node,
@@ -302,8 +297,8 @@ function createChildElements(children, getInnerPos) {
302
297
  });
303
298
  }
304
299
  const ChildNodeViews = /*#__PURE__*/ (0, _react.memo)(function ChildNodeViews(param) {
305
- let { getPos, node, innerDecorations } = param;
306
- const reactKeys = (0, _useReactKeys.useReactKeys)();
300
+ let { getPos , node , innerDecorations } = param;
301
+ const reactKeys = (0, _useReactKeysJs.useReactKeys)();
307
302
  const getInnerPos = (0, _react.useCallback)(()=>getPos() + 1, [
308
303
  getPos
309
304
  ]);
@@ -312,12 +307,13 @@ const ChildNodeViews = /*#__PURE__*/ (0, _react.memo)(function ChildNodeViews(pa
312
307
  const keysSeen = new Map();
313
308
  let widgetChildren = [];
314
309
  let lastNodeChild = null;
315
- (0, _iterDeco.iterDeco)(node, innerDecorations, (widget, isNative, offset, index)=>{
310
+ (0, _iterDecoJs.iterDeco)(node, innerDecorations, (widget, isNative, offset, index)=>{
311
+ var _marks;
316
312
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
317
- const widgetMarks = widget.type.spec.marks ?? [];
313
+ const widgetMarks = (_marks = widget.type.spec.marks) !== null && _marks !== void 0 ? _marks : [];
318
314
  let key;
319
315
  if (isNative) {
320
- key = createKey(getInnerPos(), offset, index, "native-widget", reactKeys?.posToKey, widget);
316
+ key = createKey(getInnerPos(), offset, index, "native-widget", reactKeys === null || reactKeys === void 0 ? void 0 : reactKeys.posToKey, widget);
321
317
  const child = {
322
318
  type: "native-widget",
323
319
  widget,
@@ -334,8 +330,8 @@ const ChildNodeViews = /*#__PURE__*/ (0, _react.memo)(function ChildNodeViews(pa
334
330
  }
335
331
  keysSeen.set(key, keysSeen.size);
336
332
  } else {
337
- key = createKey(getInnerPos(), offset, index, "widget", reactKeys?.posToKey, widget);
338
- const child = {
333
+ key = createKey(getInnerPos(), offset, index, "widget", reactKeys === null || reactKeys === void 0 ? void 0 : reactKeys.posToKey, widget);
334
+ const child1 = {
339
335
  type: "widget",
340
336
  widget: widget,
341
337
  marks: widgetMarks,
@@ -343,19 +339,19 @@ const ChildNodeViews = /*#__PURE__*/ (0, _react.memo)(function ChildNodeViews(pa
343
339
  index,
344
340
  key
345
341
  };
346
- const prevChild = childMap.get(key);
347
- if (prevChild && areChildrenEqual(prevChild, child)) {
348
- prevChild.offset = offset;
342
+ const prevChild1 = childMap.get(key);
343
+ if (prevChild1 && areChildrenEqual(prevChild1, child1)) {
344
+ prevChild1.offset = offset;
349
345
  } else {
350
- childMap.set(key, child);
346
+ childMap.set(key, child1);
351
347
  }
352
348
  keysSeen.set(key, keysSeen.size);
353
349
  }
354
- const child = childMap.get(key);
355
- widgetChildren.push(child);
350
+ const child2 = childMap.get(key);
351
+ widgetChildren.push(child2);
356
352
  adjustWidgetMarksForward(lastNodeChild, childMap.get(key));
357
353
  }, (childNode, outerDeco, innerDeco, offset, index)=>{
358
- const key = createKey(getInnerPos(), offset, index, "node", reactKeys?.posToKey);
354
+ const key = createKey(getInnerPos(), offset, index, "node", reactKeys === null || reactKeys === void 0 ? void 0 : reactKeys.posToKey);
359
355
  const child = {
360
356
  type: "node",
361
357
  node: childNode,
@@ -392,19 +388,20 @@ const ChildNodeViews = /*#__PURE__*/ (0, _react.memo)(function ChildNodeViews(pa
392
388
  if (!lastChild || lastChild.type !== "node" || lastChild.node.isInline && !lastChild.node.isText || // RegExp.test actually handles undefined just fine
393
389
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
394
390
  /\n$/.test(lastChild.node.text)) {
391
+ var ref, ref1, ref2, ref3;
395
392
  children.push({
396
393
  type: "hack",
397
- component: _SeparatorHackView.SeparatorHackView,
394
+ component: _separatorHackViewJs.SeparatorHackView,
398
395
  marks: [],
399
- offset: lastChild?.offset ?? 0,
400
- index: (lastChild?.index ?? 0) + 2,
396
+ offset: (ref = lastChild === null || lastChild === void 0 ? void 0 : lastChild.offset) !== null && ref !== void 0 ? ref : 0,
397
+ index: ((ref1 = lastChild === null || lastChild === void 0 ? void 0 : lastChild.index) !== null && ref1 !== void 0 ? ref1 : 0) + 2,
401
398
  key: "trailing-hack-img"
402
399
  }, {
403
400
  type: "hack",
404
- component: _TrailingHackView.TrailingHackView,
401
+ component: _trailingHackViewJs.TrailingHackView,
405
402
  marks: [],
406
- offset: lastChild?.offset ?? 0,
407
- index: (lastChild?.index ?? 0) + 1,
403
+ offset: (ref2 = lastChild === null || lastChild === void 0 ? void 0 : lastChild.offset) !== null && ref2 !== void 0 ? ref2 : 0,
404
+ index: ((ref3 = lastChild === null || lastChild === void 0 ? void 0 : lastChild.index) !== null && ref3 !== void 0 ? ref3 : 0) + 1,
408
405
  key: "trailing-hack-br"
409
406
  });
410
407
  }