@handlewithcare/react-prosemirror 3.1.0-tiptap.41 → 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 (140) hide show
  1. package/dist/cjs/ReactEditorView.js +70 -74
  2. package/dist/cjs/StaticEditorView.js +18 -21
  3. package/dist/cjs/browser.js +1 -3
  4. package/dist/cjs/commands/reorderSiblings.js +9 -13
  5. package/dist/cjs/components/ChildNodeViews.js +68 -71
  6. package/dist/cjs/components/CursorWrapper.js +26 -17
  7. package/dist/cjs/components/LayoutGroup.js +12 -16
  8. package/dist/cjs/components/NativeWidgetView.js +15 -19
  9. package/dist/cjs/components/OutputSpec.js +9 -13
  10. package/dist/cjs/components/ProseMirror.js +37 -27
  11. package/dist/cjs/components/ProseMirrorDoc.js +25 -18
  12. package/dist/cjs/components/SeparatorHackView.js +17 -20
  13. package/dist/cjs/components/TextNodeView.js +22 -20
  14. package/dist/cjs/components/TrailingHackView.js +13 -17
  15. package/dist/cjs/components/WidgetView.js +14 -18
  16. package/dist/cjs/components/marks/DefaultMarkView.js +27 -15
  17. package/dist/cjs/components/marks/MarkView.js +32 -23
  18. package/dist/cjs/components/marks/MarkViewConstructorView.js +38 -22
  19. package/dist/cjs/components/marks/ReactMarkView.js +27 -16
  20. package/dist/cjs/components/nodes/DefaultNodeView.js +27 -15
  21. package/dist/cjs/components/nodes/DocNodeView.js +12 -16
  22. package/dist/cjs/components/nodes/NodeView.js +33 -26
  23. package/dist/cjs/components/nodes/NodeViewConstructorView.js +45 -29
  24. package/dist/cjs/components/nodes/ReactNodeView.js +39 -27
  25. package/dist/cjs/constants.js +6 -10
  26. package/dist/cjs/contexts/ChildDescriptionsContext.js +1 -3
  27. package/dist/cjs/contexts/EditorContext.js +1 -3
  28. package/dist/cjs/contexts/EditorStateContext.js +1 -3
  29. package/dist/cjs/contexts/IgnoreMutationContext.js +1 -3
  30. package/dist/cjs/contexts/LayoutGroupContext.js +1 -3
  31. package/dist/cjs/contexts/NodeViewContext.js +1 -3
  32. package/dist/cjs/contexts/SelectNodeContext.js +1 -3
  33. package/dist/cjs/contexts/StopEventContext.js +1 -3
  34. package/dist/cjs/decorations/ReactWidgetType.js +13 -19
  35. package/dist/cjs/decorations/computeDocDeco.js +3 -5
  36. package/dist/cjs/decorations/iterDeco.js +17 -19
  37. package/dist/cjs/decorations/viewDecorations.js +12 -15
  38. package/dist/cjs/dom.js +13 -34
  39. package/dist/cjs/findDOMNode.js +5 -9
  40. package/dist/cjs/hooks/useClientLayoutEffect.js +1 -3
  41. package/dist/cjs/hooks/useComponentEventListeners.js +6 -7
  42. package/dist/cjs/hooks/useEditor.js +30 -28
  43. package/dist/cjs/hooks/useEditorEffect.js +7 -9
  44. package/dist/cjs/hooks/useEditorEventCallback.js +7 -9
  45. package/dist/cjs/hooks/useEditorEventListener.js +6 -8
  46. package/dist/cjs/hooks/useEditorState.js +3 -5
  47. package/dist/cjs/hooks/useEffectEvent.js +1 -3
  48. package/dist/cjs/hooks/useForceUpdate.js +1 -3
  49. package/dist/cjs/hooks/useIgnoreMutation.js +7 -9
  50. package/dist/cjs/hooks/useIsEditorStatic.js +5 -5
  51. package/dist/cjs/hooks/useIsNodeSelected.js +3 -5
  52. package/dist/cjs/hooks/useLayoutGroupEffect.js +5 -7
  53. package/dist/cjs/hooks/useMarkViewDescription.js +25 -24
  54. package/dist/cjs/hooks/useNodePos.js +5 -7
  55. package/dist/cjs/hooks/useNodeViewDescription.js +28 -29
  56. package/dist/cjs/hooks/useReactKeys.js +5 -7
  57. package/dist/cjs/hooks/useSelectNode.js +8 -10
  58. package/dist/cjs/hooks/useStopEvent.js +7 -9
  59. package/dist/cjs/index.js +34 -66
  60. package/dist/cjs/plugins/beforeInputPlugin.js +23 -20
  61. package/dist/cjs/plugins/componentEventListeners.js +6 -8
  62. package/dist/cjs/plugins/componentEventListenersPlugin.js +6 -8
  63. package/dist/cjs/plugins/reactKeys.js +10 -15
  64. package/dist/cjs/props.js +19 -23
  65. package/dist/cjs/refs.js +1 -3
  66. package/dist/cjs/testing/editorViewTestHelpers.js +47 -40
  67. package/dist/cjs/testing/setupProseMirrorView.js +4 -7
  68. package/dist/cjs/tiptap/ReactProseMirrorNodeView.js +6 -10
  69. package/dist/cjs/tiptap/TiptapEditor.js +14 -15
  70. package/dist/cjs/tiptap/TiptapEditorContent.js +28 -18
  71. package/dist/cjs/tiptap/TiptapEditorView.js +34 -23
  72. package/dist/cjs/tiptap/contexts/TiptapEditorContext.js +1 -3
  73. package/dist/cjs/tiptap/extensions/ReactProseMirror.js +6 -8
  74. package/dist/cjs/tiptap/extensions/ReactProseMirrorCommands.js +3 -5
  75. package/dist/cjs/tiptap/extensions/commands/updateAttributes.js +2 -4
  76. package/dist/cjs/tiptap/hooks/useIsInReactProseMirror.js +3 -5
  77. package/dist/cjs/tiptap/hooks/useTiptapEditor.js +14 -12
  78. package/dist/cjs/tiptap/hooks/useTiptapEditorEffect.js +10 -12
  79. package/dist/cjs/tiptap/hooks/useTiptapEditorEventCallback.js +4 -6
  80. package/dist/cjs/tiptap/index.js +18 -36
  81. package/dist/cjs/tiptap/tiptapNodeView.js +62 -48
  82. package/dist/cjs/viewdesc.js +95 -119
  83. package/dist/esm/ReactEditorView.js +66 -68
  84. package/dist/esm/StaticEditorView.js +17 -18
  85. package/dist/esm/commands/reorderSiblings.js +5 -5
  86. package/dist/esm/components/ChildNodeViews.js +36 -33
  87. package/dist/esm/components/CursorWrapper.js +18 -5
  88. package/dist/esm/components/LayoutGroup.js +1 -1
  89. package/dist/esm/components/NativeWidgetView.js +2 -2
  90. package/dist/esm/components/OutputSpec.js +1 -1
  91. package/dist/esm/components/ProseMirror.js +17 -3
  92. package/dist/esm/components/ProseMirrorDoc.js +19 -6
  93. package/dist/esm/components/SeparatorHackView.js +4 -3
  94. package/dist/esm/components/TextNodeView.js +10 -6
  95. package/dist/esm/components/TrailingHackView.js +2 -2
  96. package/dist/esm/components/WidgetView.js +3 -3
  97. package/dist/esm/components/marks/DefaultMarkView.js +22 -6
  98. package/dist/esm/components/marks/MarkView.js +24 -11
  99. package/dist/esm/components/marks/MarkViewConstructorView.js +27 -7
  100. package/dist/esm/components/marks/ReactMarkView.js +18 -3
  101. package/dist/esm/components/nodes/DefaultNodeView.js +22 -6
  102. package/dist/esm/components/nodes/DocNodeView.js +2 -2
  103. package/dist/esm/components/nodes/NodeView.js +24 -11
  104. package/dist/esm/components/nodes/NodeViewConstructorView.js +31 -11
  105. package/dist/esm/components/nodes/ReactNodeView.js +22 -6
  106. package/dist/esm/decorations/ReactWidgetType.js +8 -10
  107. package/dist/esm/decorations/iterDeco.js +13 -13
  108. package/dist/esm/decorations/viewDecorations.js +6 -7
  109. package/dist/esm/dom.js +2 -1
  110. package/dist/esm/findDOMNode.js +1 -1
  111. package/dist/esm/hooks/useComponentEventListeners.js +3 -2
  112. package/dist/esm/hooks/useEditor.js +9 -5
  113. package/dist/esm/hooks/useEditorEffect.js +1 -1
  114. package/dist/esm/hooks/useEditorEventCallback.js +1 -1
  115. package/dist/esm/hooks/useEditorEventListener.js +1 -1
  116. package/dist/esm/hooks/useIsEditorStatic.js +3 -1
  117. package/dist/esm/hooks/useMarkViewDescription.js +10 -7
  118. package/dist/esm/hooks/useNodeViewDescription.js +8 -7
  119. package/dist/esm/hooks/useReactKeys.js +1 -1
  120. package/dist/esm/plugins/beforeInputPlugin.js +17 -12
  121. package/dist/esm/plugins/reactKeys.js +4 -3
  122. package/dist/esm/props.js +15 -15
  123. package/dist/esm/testing/editorViewTestHelpers.js +31 -20
  124. package/dist/esm/testing/setupProseMirrorView.js +2 -1
  125. package/dist/esm/tiptap/ReactProseMirrorNodeView.js +5 -7
  126. package/dist/esm/tiptap/TiptapEditor.js +10 -9
  127. package/dist/esm/tiptap/TiptapEditorContent.js +18 -4
  128. package/dist/esm/tiptap/TiptapEditorView.js +23 -8
  129. package/dist/esm/tiptap/extensions/ReactProseMirror.js +1 -1
  130. package/dist/esm/tiptap/extensions/commands/updateAttributes.js +1 -1
  131. package/dist/esm/tiptap/hooks/useTiptapEditor.js +8 -4
  132. package/dist/esm/tiptap/hooks/useTiptapEditorEffect.js +4 -4
  133. package/dist/esm/tiptap/hooks/useTiptapEditorEventCallback.js +1 -1
  134. package/dist/esm/tiptap/tiptapNodeView.js +38 -20
  135. package/dist/esm/viewdesc.js +72 -74
  136. package/dist/tsconfig.tsbuildinfo +1 -1
  137. package/dist/types/constants.d.ts +1 -1
  138. package/dist/types/props.d.ts +8 -8
  139. package/dist/types/viewdesc.d.ts +3 -1
  140. package/package.json +2 -1
@@ -30,62 +30,6 @@ function changedNodeViews(a, b) {
30
30
  * latest, uncommitted props. The base class can then be told to update when the
31
31
  * React effects are commit an update, applying the pending, uncommitted props.
32
32
  */ export class ReactEditorView extends 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: 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 = 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
- }
89
33
  get props() {
90
34
  return this.nextProps;
91
35
  }
@@ -135,21 +79,22 @@ function changedNodeViews(a, b) {
135
79
  return result;
136
80
  }
137
81
  }
138
- for (const plugin of this.props.plugins ?? []){
139
- const prop = plugin.props[propName];
140
- if (prop != null) {
141
- const result = f ? f(prop) : prop;
142
- if (result) {
143
- return result;
82
+ var _plugins;
83
+ for (const plugin of (_plugins = this.props.plugins) !== null && _plugins !== void 0 ? _plugins : []){
84
+ const prop1 = plugin.props[propName];
85
+ if (prop1 != null) {
86
+ const result1 = f ? f(prop1) : prop1;
87
+ if (result1) {
88
+ return result1;
144
89
  }
145
90
  }
146
91
  }
147
- for (const plugin of this.state.plugins){
148
- const prop = plugin.props[propName];
149
- if (prop != null) {
150
- const result = f ? f(prop) : prop;
151
- if (result) {
152
- return result;
92
+ for (const plugin1 of this.state.plugins){
93
+ const prop2 = plugin1.props[propName];
94
+ if (prop2 != null) {
95
+ const result2 = f ? f(prop2) : prop2;
96
+ if (result2) {
97
+ return result2;
153
98
  }
154
99
  }
155
100
  }
@@ -189,4 +134,57 @@ function changedNodeViews(a, b) {
189
134
  // Store the new previous state.
190
135
  this.prevState = this.state;
191
136
  }
137
+ constructor(place, props){
138
+ // Prevent the base class from destroying the React-managed nodes.
139
+ // Restore them below after invoking the base class constructor.
140
+ const reactContent = [
141
+ ...place.mount.childNodes
142
+ ];
143
+ // Prevent the base class from mutating the React-managed attributes.
144
+ // Restore them below after invoking the base class constructor.
145
+ const reactAttrs = [
146
+ ...place.mount.attributes
147
+ ];
148
+ for (const attr of reactAttrs){
149
+ place.mount.removeAttributeNode(attr);
150
+ }
151
+ try {
152
+ // Call the superclass constructor with only a state and no plugins.
153
+ // We'll set everything else ourselves and apply props during layout.
154
+ super(place, {
155
+ state: EMPTY_STATE
156
+ });
157
+ this.domObserver.stop();
158
+ this.domObserver.observer = null;
159
+ this.domObserver.queue = [];
160
+ const originalOnSelectionChange = this.domObserver.onSelectionChange;
161
+ this.domObserver.onSelectionChange = ()=>{
162
+ // During a composition, we completely pause React-driven
163
+ // selection and DOM updates. Compositions are "fragile";
164
+ // in Safari, even updating the selection to the same
165
+ // position it's already set to will end the current
166
+ // composition.
167
+ if (this.composing) return;
168
+ originalOnSelectionChange();
169
+ };
170
+ } finally{
171
+ place.mount.replaceChildren(...reactContent);
172
+ for (const attr1 of place.mount.attributes){
173
+ place.mount.removeAttributeNode(attr1);
174
+ }
175
+ for (const attr2 of reactAttrs){
176
+ place.mount.setAttributeNode(attr2);
177
+ }
178
+ }
179
+ this.prevState = EMPTY_STATE;
180
+ this.nextProps = props;
181
+ this.state = props.state;
182
+ this.nodeViews = buildNodeViews(this);
183
+ // Destroy the document view description that the base class makes.
184
+ // A React document view will assign itself to this attribute later.
185
+ this.docView.destroy();
186
+ // @ts-expect-error this violates the typing but class does it, too.
187
+ this.docView = null;
188
+ this._destroyed = false;
189
+ }
192
190
  }
@@ -1,10 +1,4 @@
1
1
  export class StaticEditorView {
2
- props;
3
- nodeViews;
4
- constructor(props){
5
- this.props = props;
6
- this.nodeViews = {};
7
- }
8
2
  get composing() {
9
3
  return false;
10
4
  }
@@ -42,21 +36,22 @@ export class StaticEditorView {
42
36
  return result;
43
37
  }
44
38
  }
45
- for (const plugin of this.props.plugins ?? []){
46
- const prop = plugin.props[propName];
47
- if (prop != null) {
48
- const result = f ? f(prop) : prop;
49
- if (result) {
50
- return result;
39
+ var _plugins;
40
+ for (const plugin of (_plugins = this.props.plugins) !== null && _plugins !== void 0 ? _plugins : []){
41
+ const prop1 = plugin.props[propName];
42
+ if (prop1 != null) {
43
+ const result1 = f ? f(prop1) : prop1;
44
+ if (result1) {
45
+ return result1;
51
46
  }
52
47
  }
53
48
  }
54
- for (const plugin of this.state.plugins){
55
- const prop = plugin.props[propName];
56
- if (prop != null) {
57
- const result = f ? f(prop) : prop;
58
- if (result) {
59
- return result;
49
+ for (const plugin1 of this.state.plugins){
50
+ const prop2 = plugin1.props[propName];
51
+ if (prop2 != null) {
52
+ const result2 = f ? f(prop2) : prop2;
53
+ if (result2) {
54
+ return result2;
60
55
  }
61
56
  }
62
57
  }
@@ -76,4 +71,8 @@ export class StaticEditorView {
76
71
  domSelection() {
77
72
  return null;
78
73
  }
74
+ constructor(props){
75
+ this.props = props;
76
+ this.nodeViews = {};
77
+ }
79
78
  }
@@ -48,13 +48,13 @@ export function reorderSiblingsOnTransaction(pos, order, tr, state, dispatch) {
48
48
  start = pos;
49
49
  const newPositions = [];
50
50
  for(let i = 0; i < reordered.length; i++){
51
- const node = reordered[i];
51
+ const node1 = reordered[i];
52
52
  newPositions[order[i]] = start;
53
- start += node.nodeSize;
53
+ start += node1.nodeSize;
54
54
  }
55
- for(let i = 0; i < oldPositions.length; i++){
56
- const oldPosition = oldPositions[i];
57
- const newPosition = newPositions[i];
55
+ for(let i1 = 0; i1 < oldPositions.length; i1++){
56
+ const oldPosition = oldPositions[i1];
57
+ const newPosition = newPositions[i1];
58
58
  meta.overrides[oldPosition] = newPosition;
59
59
  }
60
60
  tr.setMeta(reactKeysPluginKey, meta);
@@ -13,13 +13,13 @@ import { WidgetView } from "./WidgetView.js";
13
13
  import { MarkView } from "./marks/MarkView.js";
14
14
  import { NodeView } from "./nodes/NodeView.js";
15
15
  export function wrapInDeco(reactNode, deco) {
16
- const { nodeName, ...attrs } = deco.type.attrs;
16
+ const { nodeName , ...attrs } = deco.type.attrs;
17
17
  const props = htmlAttrsToReactProps(attrs);
18
18
  // We auto-wrap text nodes in spans so that we can apply attributes
19
19
  // and styles, but we want to avoid double-wrapping the same
20
20
  // text node
21
21
  if (nodeName || typeof reactNode === "string") {
22
- return /*#__PURE__*/ createElement(nodeName ?? "span", props, reactNode);
22
+ return /*#__PURE__*/ createElement(nodeName !== null && nodeName !== void 0 ? nodeName : "span", props, reactNode);
23
23
  }
24
24
  return /*#__PURE__*/ cloneElement(reactNode, mergeReactProps(reactNode.props, props));
25
25
  }
@@ -27,8 +27,8 @@ function areChildrenEqual(a, b) {
27
27
  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) && sameOuterDeco(a.outerDeco, b.outerDeco) && a.innerDeco.eq(b.innerDeco)) && a.widget === b.widget;
28
28
  }
29
29
  const ChildView = /*#__PURE__*/ memo(function ChildView(param) {
30
- let { child, getInnerPos } = param;
31
- const { view } = useContext(EditorContext);
30
+ let { child , getInnerPos } = param;
31
+ const { view } = useContext(EditorContext);
32
32
  const childRef = useRef(child);
33
33
  childRef.current = child;
34
34
  const getPos = useCallback(()=>{
@@ -49,9 +49,9 @@ const ChildView = /*#__PURE__*/ memo(function ChildView(param) {
49
49
  getPos: getPos
50
50
  }) : child.node.isText ? /*#__PURE__*/ React.createElement(ChildDescriptionsContext.Consumer, {
51
51
  key: child.key
52
- }, (param)=>{
53
- let { siblingsRef, parentRef } = param;
54
- return /*#__PURE__*/ React.createElement(TextNodeView, {
52
+ }, (param)=>/*#__PURE__*/ {
53
+ let { siblingsRef , parentRef } = param;
54
+ return React.createElement(TextNodeView, {
55
55
  view: view,
56
56
  node: child.node,
57
57
  getPos: getPos,
@@ -68,7 +68,7 @@ const ChildView = /*#__PURE__*/ memo(function ChildView(param) {
68
68
  });
69
69
  });
70
70
  const InlinePartition = /*#__PURE__*/ memo(function InlinePartition(param) {
71
- let { childViews, getInnerPos } = param;
71
+ let { childViews , getInnerPos } = param;
72
72
  const firstChild = childViews[0];
73
73
  const firstChildRef = useRef(firstChild);
74
74
  firstChildRef.current = firstChild;
@@ -102,9 +102,11 @@ const InlinePartition = /*#__PURE__*/ memo(function InlinePartition(param) {
102
102
  }));
103
103
  });
104
104
  const InlineView = /*#__PURE__*/ memo(function InlineView(param) {
105
- let { getInnerPos, childViews } = param;
105
+ let { getInnerPos , childViews } = param;
106
106
  // const editorState = useEditorState();
107
107
  const partitioned = childViews.reduce((acc, child)=>{
108
+ var // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
109
+ ref;
108
110
  const lastPartition = acc[acc.length - 1];
109
111
  if (!lastPartition) {
110
112
  return [
@@ -122,8 +124,7 @@ const InlineView = /*#__PURE__*/ memo(function InlineView(param) {
122
124
  ]
123
125
  ];
124
126
  }
125
- if (!child.marks.length && !lastChild.marks.length || child.marks.length && lastChild.marks.length && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
126
- child.marks[0]?.eq(lastChild.marks[0])) {
127
+ 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]))) {
127
128
  return [
128
129
  ...acc.slice(0, acc.length - 1),
129
130
  [
@@ -151,22 +152,22 @@ const InlineView = /*#__PURE__*/ memo(function InlineView(param) {
151
152
  });
152
153
  function createKey(innerPos, offset, index, type, posToKey, widget) {
153
154
  const pos = innerPos + offset;
154
- const key = posToKey?.get(pos);
155
+ const key = posToKey === null || posToKey === void 0 ? void 0 : posToKey.get(pos);
155
156
  if (type === "widget" || type === "native-widget") {
156
157
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
157
158
  if (widget.type.spec.key) // eslint-disable-next-line @typescript-eslint/no-explicit-any
158
159
  return widget.type.spec.key;
159
160
  if (type === "widget") {
160
161
  // eslint-disable-next-line no-console
161
- 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.`);
162
+ 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."));
162
163
  }
163
- return `${key}-${index}`;
164
+ return "".concat(key, "-").concat(index);
164
165
  }
165
166
  if (key) return key;
166
167
  // if (!doc) return pos;
167
168
  const parentPos = innerPos - 1;
168
- const parentKey = posToKey?.get(parentPos);
169
- if (parentKey) return `${parentKey}-${offset}`;
169
+ const parentKey = posToKey === null || posToKey === void 0 ? void 0 : posToKey.get(parentPos);
170
+ if (parentKey) return "".concat(parentKey, "-").concat(offset);
170
171
  return pos;
171
172
  }
172
173
  function adjustWidgetMarksForward(lastNodeChild, widgetChild) {
@@ -192,7 +193,7 @@ function adjustWidgetMarksBack(widgetChildren, nodeChild) {
192
193
  }
193
194
  }
194
195
  const ChildElement = /*#__PURE__*/ memo(function ChildElement(param) {
195
- let { child, getInnerPos } = param;
196
+ let { child , getInnerPos } = param;
196
197
  const childRef = useRef(child);
197
198
  childRef.current = child;
198
199
  const getPos = useCallback(()=>{
@@ -243,7 +244,7 @@ function createChildElements(children, getInnerPos) {
243
244
  });
244
245
  }
245
246
  export const ChildNodeViews = /*#__PURE__*/ memo(function ChildNodeViews(param) {
246
- let { getPos, node, innerDecorations } = param;
247
+ let { getPos , node , innerDecorations } = param;
247
248
  const reactKeys = useReactKeys();
248
249
  const getInnerPos = useCallback(()=>getPos() + 1, [
249
250
  getPos
@@ -254,11 +255,12 @@ export const ChildNodeViews = /*#__PURE__*/ memo(function ChildNodeViews(param)
254
255
  let widgetChildren = [];
255
256
  let lastNodeChild = null;
256
257
  iterDeco(node, innerDecorations, (widget, isNative, offset, index)=>{
258
+ var _marks;
257
259
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
258
- const widgetMarks = widget.type.spec.marks ?? [];
260
+ const widgetMarks = (_marks = widget.type.spec.marks) !== null && _marks !== void 0 ? _marks : [];
259
261
  let key;
260
262
  if (isNative) {
261
- key = createKey(getInnerPos(), offset, index, "native-widget", reactKeys?.posToKey, widget);
263
+ key = createKey(getInnerPos(), offset, index, "native-widget", reactKeys === null || reactKeys === void 0 ? void 0 : reactKeys.posToKey, widget);
262
264
  const child = {
263
265
  type: "native-widget",
264
266
  widget,
@@ -275,8 +277,8 @@ export const ChildNodeViews = /*#__PURE__*/ memo(function ChildNodeViews(param)
275
277
  }
276
278
  keysSeen.set(key, keysSeen.size);
277
279
  } else {
278
- key = createKey(getInnerPos(), offset, index, "widget", reactKeys?.posToKey, widget);
279
- const child = {
280
+ key = createKey(getInnerPos(), offset, index, "widget", reactKeys === null || reactKeys === void 0 ? void 0 : reactKeys.posToKey, widget);
281
+ const child1 = {
280
282
  type: "widget",
281
283
  widget: widget,
282
284
  marks: widgetMarks,
@@ -284,19 +286,19 @@ export const ChildNodeViews = /*#__PURE__*/ memo(function ChildNodeViews(param)
284
286
  index,
285
287
  key
286
288
  };
287
- const prevChild = childMap.get(key);
288
- if (prevChild && areChildrenEqual(prevChild, child)) {
289
- prevChild.offset = offset;
289
+ const prevChild1 = childMap.get(key);
290
+ if (prevChild1 && areChildrenEqual(prevChild1, child1)) {
291
+ prevChild1.offset = offset;
290
292
  } else {
291
- childMap.set(key, child);
293
+ childMap.set(key, child1);
292
294
  }
293
295
  keysSeen.set(key, keysSeen.size);
294
296
  }
295
- const child = childMap.get(key);
296
- widgetChildren.push(child);
297
+ const child2 = childMap.get(key);
298
+ widgetChildren.push(child2);
297
299
  adjustWidgetMarksForward(lastNodeChild, childMap.get(key));
298
300
  }, (childNode, outerDeco, innerDeco, offset, index)=>{
299
- const key = createKey(getInnerPos(), offset, index, "node", reactKeys?.posToKey);
301
+ const key = createKey(getInnerPos(), offset, index, "node", reactKeys === null || reactKeys === void 0 ? void 0 : reactKeys.posToKey);
300
302
  const child = {
301
303
  type: "node",
302
304
  node: childNode,
@@ -333,19 +335,20 @@ export const ChildNodeViews = /*#__PURE__*/ memo(function ChildNodeViews(param)
333
335
  if (!lastChild || lastChild.type !== "node" || lastChild.node.isInline && !lastChild.node.isText || // RegExp.test actually handles undefined just fine
334
336
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
335
337
  /\n$/.test(lastChild.node.text)) {
338
+ var ref, ref1, ref2, ref3;
336
339
  children.push({
337
340
  type: "hack",
338
341
  component: SeparatorHackView,
339
342
  marks: [],
340
- offset: lastChild?.offset ?? 0,
341
- index: (lastChild?.index ?? 0) + 2,
343
+ offset: (ref = lastChild === null || lastChild === void 0 ? void 0 : lastChild.offset) !== null && ref !== void 0 ? ref : 0,
344
+ index: ((ref1 = lastChild === null || lastChild === void 0 ? void 0 : lastChild.index) !== null && ref1 !== void 0 ? ref1 : 0) + 2,
342
345
  key: "trailing-hack-img"
343
346
  }, {
344
347
  type: "hack",
345
348
  component: TrailingHackView,
346
349
  marks: [],
347
- offset: lastChild?.offset ?? 0,
348
- index: (lastChild?.index ?? 0) + 1,
350
+ offset: (ref2 = lastChild === null || lastChild === void 0 ? void 0 : lastChild.offset) !== null && ref2 !== void 0 ? ref2 : 0,
351
+ index: ((ref3 = lastChild === null || lastChild === void 0 ? void 0 : lastChild.index) !== null && ref3 !== void 0 ? ref3 : 0) + 1,
349
352
  key: "trailing-hack-br"
350
353
  });
351
354
  }
@@ -1,8 +1,22 @@
1
+ function _extends() {
2
+ _extends = Object.assign || function(target) {
3
+ for(var i = 1; i < arguments.length; i++){
4
+ var source = arguments[i];
5
+ for(var key in source){
6
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
7
+ target[key] = source[key];
8
+ }
9
+ }
10
+ }
11
+ return target;
12
+ };
13
+ return _extends.apply(this, arguments);
14
+ }
1
15
  import React, { forwardRef, useImperativeHandle, useRef, useState } from "react";
2
16
  import { domIndex } from "../dom.js";
3
17
  import { useEditorEffect } from "../hooks/useEditorEffect.js";
4
18
  export const CursorWrapper = /*#__PURE__*/ forwardRef(function CursorWrapper(param, ref) {
5
- let { widget, getPos, ...props } = param;
19
+ let { widget , getPos , ...props } = param;
6
20
  const [shouldRender, setShouldRender] = useState(true);
7
21
  const innerRef = useRef(null);
8
22
  useImperativeHandle(ref, ()=>{
@@ -29,12 +43,11 @@ export const CursorWrapper = /*#__PURE__*/ forwardRef(function CursorWrapper(par
29
43
  // @ts-expect-error Internal property - domObserver
30
44
  view.domObserver.connectSelection();
31
45
  }, []);
32
- return shouldRender ? /*#__PURE__*/ React.createElement("img", {
46
+ return shouldRender ? /*#__PURE__*/ React.createElement("img", _extends({
33
47
  ref: innerRef,
34
48
  className: "ProseMirror-separator",
35
49
  // eslint-disable-next-line react/no-unknown-property
36
50
  "mark-placeholder": "true",
37
- alt: "",
38
- ...props
39
- }) : null;
51
+ alt: ""
52
+ }, props)) : null;
40
53
  });
@@ -9,7 +9,7 @@ import { useForceUpdate } from "../hooks/useForceUpdate.js";
9
9
  * effects that run after all descendants within the group have processed their
10
10
  * regular layout effects.
11
11
  */ export function LayoutGroup(param) {
12
- let { children } = param;
12
+ let { children } = param;
13
13
  const createQueue = useRef(new Set()).current;
14
14
  const destroyQueue = useRef(new Set()).current;
15
15
  const isMounted = useRef(false);
@@ -4,8 +4,8 @@ import { useClientLayoutEffect } from "../hooks/useClientLayoutEffect.js";
4
4
  import { useEditorEffect } from "../hooks/useEditorEffect.js";
5
5
  import { WidgetViewDesc, sortViewDescs } from "../viewdesc.js";
6
6
  export function NativeWidgetView(param) {
7
- let { widget, getPos } = param;
8
- const { siblingsRef, parentRef } = useContext(ChildDescriptionsContext);
7
+ let { widget , getPos } = param;
8
+ const { siblingsRef , parentRef } = useContext(ChildDescriptionsContext);
9
9
  const viewDescRef = useRef(null);
10
10
  const rootDomRef = useRef(null);
11
11
  useClientLayoutEffect(()=>{
@@ -22,7 +22,7 @@ import { useMergedDOMRefs } from "../refs.js";
22
22
  return false;
23
23
  }
24
24
  const ForwardedOutputSpec = /*#__PURE__*/ memo(/*#__PURE__*/ forwardRef(function OutputSpec(param, ref) {
25
- let { outputSpec, isMark, contentDOMRef, children, ...propOverrides } = param;
25
+ let { outputSpec , isMark , contentDOMRef , children , ...propOverrides } = param;
26
26
  const mergedRef = useMergedDOMRefs(ref, contentDOMRef);
27
27
  if (typeof outputSpec === "string") {
28
28
  return /*#__PURE__*/ React.createElement(React.Fragment, null, outputSpec);
@@ -1,3 +1,17 @@
1
+ function _extends() {
2
+ _extends = Object.assign || function(target) {
3
+ for(var i = 1; i < arguments.length; i++){
4
+ var source = arguments[i];
5
+ for(var key in source){
6
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
7
+ target[key] = source[key];
8
+ }
9
+ }
10
+ }
11
+ return target;
12
+ };
13
+ return _extends.apply(this, arguments);
14
+ }
1
15
  import React, { useMemo, useState } from "react";
2
16
  import { ChildDescriptionsContext } from "../contexts/ChildDescriptionsContext.js";
3
17
  import { EditorContext } from "../contexts/EditorContext.js";
@@ -20,9 +34,9 @@ const rootChildDescriptionsContextValue = {
20
34
  }
21
35
  };
22
36
  function ProseMirrorInner(param) {
23
- let { children, nodeViewComponents, markViewComponents, ...props } = param;
37
+ let { children , nodeViewComponents , markViewComponents , ...props } = param;
24
38
  const [mount, setMount] = useState(null);
25
- const { editor, state } = useEditor(mount, props);
39
+ const { editor , state } = useEditor(mount, props);
26
40
  const nodeViewConstructors = editor.view.nodeViews;
27
41
  const nodeViewContextValue = useMemo(()=>{
28
42
  return {
@@ -64,5 +78,5 @@ function ProseMirrorInner(param) {
64
78
  }, children)))));
65
79
  }
66
80
  export function ProseMirror(props) {
67
- return /*#__PURE__*/ React.createElement(LayoutGroup, null, /*#__PURE__*/ React.createElement(ProseMirrorInner, props));
81
+ return /*#__PURE__*/ React.createElement(LayoutGroup, null, /*#__PURE__*/ React.createElement(ProseMirrorInner, _extends({}, props)));
68
82
  }
@@ -1,13 +1,26 @@
1
+ function _extends() {
2
+ _extends = Object.assign || function(target) {
3
+ for(var i = 1; i < arguments.length; i++){
4
+ var source = arguments[i];
5
+ for(var key in source){
6
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
7
+ target[key] = source[key];
8
+ }
9
+ }
10
+ }
11
+ return target;
12
+ };
13
+ return _extends.apply(this, arguments);
14
+ }
1
15
  import React, { createContext, forwardRef, useContext } from "react";
2
16
  import { DocNodeView } from "./nodes/DocNodeView.js";
3
17
  export const DocNodeViewContext = /*#__PURE__*/ createContext(null);
4
18
  export const ProseMirrorDoc = /*#__PURE__*/ forwardRef(function ProseMirrorDoc(param, ref) {
5
- let { as, ...props } = param;
19
+ let { as , ...props } = param;
6
20
  const docProps = useContext(DocNodeViewContext);
7
- return /*#__PURE__*/ React.createElement(DocNodeView, {
8
- ref: ref,
9
- ...props,
10
- ...docProps,
21
+ return /*#__PURE__*/ React.createElement(DocNodeView, _extends({
22
+ ref: ref
23
+ }, props, docProps, {
11
24
  as: as
12
- });
25
+ }));
13
26
  });
@@ -4,8 +4,8 @@ import { ChildDescriptionsContext } from "../contexts/ChildDescriptionsContext.j
4
4
  import { useClientLayoutEffect } from "../hooks/useClientLayoutEffect.js";
5
5
  import { TrailingHackViewDesc, sortViewDescs } from "../viewdesc.js";
6
6
  export function SeparatorHackView(param) {
7
- let { getPos } = param;
8
- const { siblingsRef, parentRef } = useContext(ChildDescriptionsContext);
7
+ let { getPos } = param;
8
+ const { siblingsRef , parentRef } = useContext(ChildDescriptionsContext);
9
9
  const viewDescRef = useRef(null);
10
10
  const ref = useRef(null);
11
11
  const [shouldRender, setShouldRender] = useState(false);
@@ -25,9 +25,10 @@ export function SeparatorHackView(param) {
25
25
  // we call setShouldRender conditionally
26
26
  // eslint-disable-next-line react-hooks/exhaustive-deps
27
27
  useClientLayoutEffect(()=>{
28
+ var ref1;
28
29
  const nonHackSiblings = siblingsRef.current.filter((viewdesc)=>!(viewdesc instanceof TrailingHackViewDesc));
29
30
  const lastSibling = nonHackSiblings[nonHackSiblings.length - 1];
30
- if ((browser.safari || browser.chrome) && lastSibling?.dom?.contentEditable == "false") {
31
+ if ((browser.safari || browser.chrome) && ((ref1 = lastSibling === null || lastSibling === void 0 ? void 0 : lastSibling.dom) === null || ref1 === void 0 ? void 0 : ref1.contentEditable) == "false") {
31
32
  setShouldRender(true);
32
33
  return;
33
34
  }
@@ -26,10 +26,8 @@ function shallowEqual(objA, objB) {
26
26
  return true;
27
27
  }
28
28
  export class TextNodeView extends Component {
29
- viewDescRef = null;
30
- renderRef = null;
31
29
  updateEffect() {
32
- const { view, decorations, siblingsRef, parentRef, getPos, node } = this.props;
30
+ const { view , decorations , siblingsRef , parentRef , getPos , node } = this.props;
33
31
  // There simply is no other way to ref a text node
34
32
  // eslint-disable-next-line react/no-find-dom-node
35
33
  const dom = findDOMNode(this);
@@ -38,12 +36,13 @@ export class TextNodeView extends Component {
38
36
  // Otherwise we just rely on re-rendering the renderRef
39
37
  if (!dom) {
40
38
  if (!view.composing) return;
39
+ var _text, _text1;
41
40
  this.viewDescRef = new CompositionViewDesc(parentRef.current, getPos, // These are just placeholders/dummies. We can't
42
41
  // actually find the correct DOM nodes from here,
43
42
  // so we let our parent do it.
44
43
  // Passing a valid element here just so that the
45
44
  // ViewDesc constructor doesn't blow up.
46
- document.createElement("div"), document.createTextNode(node.text ?? ""), node.text ?? "");
45
+ document.createElement("div"), document.createTextNode((_text = node.text) !== null && _text !== void 0 ? _text : ""), (_text1 = node.text) !== null && _text1 !== void 0 ? _text1 : "");
47
46
  return;
48
47
  }
49
48
  let textNode = dom;
@@ -77,7 +76,7 @@ export class TextNodeView extends Component {
77
76
  this.updateEffect();
78
77
  }
79
78
  componentWillUnmount() {
80
- const { siblingsRef } = this.props;
79
+ const { siblingsRef } = this.props;
81
80
  if (!this.viewDescRef) return;
82
81
  if (siblingsRef.current.includes(this.viewDescRef)) {
83
82
  const index = siblingsRef.current.indexOf(this.viewDescRef);
@@ -85,7 +84,7 @@ export class TextNodeView extends Component {
85
84
  }
86
85
  }
87
86
  render() {
88
- const { view, getPos, node, decorations } = this.props;
87
+ const { view , getPos , node , decorations } = this.props;
89
88
  // During a composition, it's crucial that we don't try to
90
89
  // update the DOM that the user is working in. If there's
91
90
  // an active composition and the selection is in this node,
@@ -97,4 +96,9 @@ export class TextNodeView extends Component {
97
96
  this.renderRef = decorations.reduce(wrapInDeco, node.text);
98
97
  return this.renderRef;
99
98
  }
99
+ constructor(...args){
100
+ super(...args);
101
+ this.viewDescRef = null;
102
+ this.renderRef = null;
103
+ }
100
104
  }
@@ -3,8 +3,8 @@ import { ChildDescriptionsContext } from "../contexts/ChildDescriptionsContext.j
3
3
  import { useClientLayoutEffect } from "../hooks/useClientLayoutEffect.js";
4
4
  import { TrailingHackViewDesc, sortViewDescs } from "../viewdesc.js";
5
5
  export function TrailingHackView(param) {
6
- let { getPos } = param;
7
- const { siblingsRef, parentRef } = useContext(ChildDescriptionsContext);
6
+ let { getPos } = param;
7
+ const { siblingsRef , parentRef } = useContext(ChildDescriptionsContext);
8
8
  const viewDescRef = useRef(null);
9
9
  const ref = useRef(null);
10
10
  useClientLayoutEffect(()=>{