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

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/README.md +26 -0
  2. package/dist/cjs/ReactEditorView.js +74 -70
  3. package/dist/cjs/StaticEditorView.js +21 -18
  4. package/dist/cjs/browser.js +3 -1
  5. package/dist/cjs/commands/reorderSiblings.js +13 -9
  6. package/dist/cjs/components/ChildNodeViews.js +71 -68
  7. package/dist/cjs/components/CursorWrapper.js +17 -26
  8. package/dist/cjs/components/LayoutGroup.js +16 -12
  9. package/dist/cjs/components/NativeWidgetView.js +19 -15
  10. package/dist/cjs/components/OutputSpec.js +13 -9
  11. package/dist/cjs/components/ProseMirror.js +27 -37
  12. package/dist/cjs/components/ProseMirrorDoc.js +18 -25
  13. package/dist/cjs/components/SeparatorHackView.js +20 -17
  14. package/dist/cjs/components/TextNodeView.js +20 -22
  15. package/dist/cjs/components/TrailingHackView.js +17 -13
  16. package/dist/cjs/components/WidgetView.js +18 -14
  17. package/dist/cjs/components/marks/DefaultMarkView.js +15 -27
  18. package/dist/cjs/components/marks/MarkView.js +23 -32
  19. package/dist/cjs/components/marks/MarkViewConstructorView.js +22 -38
  20. package/dist/cjs/components/marks/ReactMarkView.js +16 -27
  21. package/dist/cjs/components/nodes/DefaultNodeView.js +15 -27
  22. package/dist/cjs/components/nodes/DocNodeView.js +16 -12
  23. package/dist/cjs/components/nodes/NodeView.js +26 -33
  24. package/dist/cjs/components/nodes/NodeViewConstructorView.js +29 -45
  25. package/dist/cjs/components/nodes/ReactNodeView.js +27 -39
  26. package/dist/cjs/constants.js +10 -6
  27. package/dist/cjs/contexts/ChildDescriptionsContext.js +3 -1
  28. package/dist/cjs/contexts/EditorContext.js +3 -1
  29. package/dist/cjs/contexts/EditorStateContext.js +3 -1
  30. package/dist/cjs/contexts/IgnoreMutationContext.js +3 -1
  31. package/dist/cjs/contexts/LayoutGroupContext.js +3 -1
  32. package/dist/cjs/contexts/NodeViewContext.js +3 -1
  33. package/dist/cjs/contexts/SelectNodeContext.js +3 -1
  34. package/dist/cjs/contexts/StopEventContext.js +3 -1
  35. package/dist/cjs/decorations/ReactWidgetType.js +19 -13
  36. package/dist/cjs/decorations/computeDocDeco.js +5 -3
  37. package/dist/cjs/decorations/iterDeco.js +19 -17
  38. package/dist/cjs/decorations/viewDecorations.js +15 -12
  39. package/dist/cjs/dom.js +34 -13
  40. package/dist/cjs/findDOMNode.js +9 -5
  41. package/dist/cjs/hooks/useClientLayoutEffect.js +3 -1
  42. package/dist/cjs/hooks/useComponentEventListeners.js +7 -6
  43. package/dist/cjs/hooks/useEditor.js +28 -30
  44. package/dist/cjs/hooks/useEditorEffect.js +9 -7
  45. package/dist/cjs/hooks/useEditorEventCallback.js +9 -7
  46. package/dist/cjs/hooks/useEditorEventListener.js +8 -6
  47. package/dist/cjs/hooks/useEditorState.js +5 -3
  48. package/dist/cjs/hooks/useEffectEvent.js +3 -1
  49. package/dist/cjs/hooks/useForceUpdate.js +3 -1
  50. package/dist/cjs/hooks/useIgnoreMutation.js +9 -7
  51. package/dist/cjs/hooks/useIsEditorStatic.js +5 -5
  52. package/dist/cjs/hooks/useIsNodeSelected.js +5 -3
  53. package/dist/cjs/hooks/useLayoutGroupEffect.js +7 -5
  54. package/dist/cjs/hooks/useMarkViewDescription.js +31 -25
  55. package/dist/cjs/hooks/useNodePos.js +7 -5
  56. package/dist/cjs/hooks/useNodeViewDescription.js +32 -28
  57. package/dist/cjs/hooks/useReactKeys.js +7 -5
  58. package/dist/cjs/hooks/useSelectNode.js +10 -8
  59. package/dist/cjs/hooks/useStopEvent.js +9 -7
  60. package/dist/cjs/index.js +66 -34
  61. package/dist/cjs/plugins/beforeInputPlugin.js +20 -23
  62. package/dist/cjs/plugins/componentEventListeners.js +8 -6
  63. package/dist/cjs/plugins/componentEventListenersPlugin.js +8 -6
  64. package/dist/cjs/plugins/reactKeys.js +15 -10
  65. package/dist/cjs/props.js +23 -19
  66. package/dist/cjs/refs.js +3 -1
  67. package/dist/cjs/testing/editorViewTestHelpers.js +40 -47
  68. package/dist/cjs/testing/setupProseMirrorView.js +7 -4
  69. package/dist/cjs/tiptap/ReactProseMirrorNodeView.js +10 -6
  70. package/dist/cjs/tiptap/TiptapEditor.js +15 -14
  71. package/dist/cjs/tiptap/TiptapEditorContent.js +18 -28
  72. package/dist/cjs/tiptap/TiptapEditorView.js +23 -34
  73. package/dist/cjs/tiptap/contexts/TiptapEditorContext.js +3 -1
  74. package/dist/cjs/tiptap/extensions/ReactProseMirror.js +8 -6
  75. package/dist/cjs/tiptap/extensions/ReactProseMirrorCommands.js +5 -3
  76. package/dist/cjs/tiptap/extensions/commands/updateAttributes.js +4 -2
  77. package/dist/cjs/tiptap/hooks/useIsInReactProseMirror.js +5 -3
  78. package/dist/cjs/tiptap/hooks/useTiptapEditor.js +12 -14
  79. package/dist/cjs/tiptap/hooks/useTiptapEditorEffect.js +12 -10
  80. package/dist/cjs/tiptap/hooks/useTiptapEditorEventCallback.js +6 -4
  81. package/dist/cjs/tiptap/index.js +36 -18
  82. package/dist/cjs/tiptap/tiptapNodeView.js +48 -62
  83. package/dist/cjs/viewdesc.js +119 -89
  84. package/dist/esm/ReactEditorView.js +68 -66
  85. package/dist/esm/StaticEditorView.js +18 -17
  86. package/dist/esm/commands/reorderSiblings.js +5 -5
  87. package/dist/esm/components/ChildNodeViews.js +33 -36
  88. package/dist/esm/components/CursorWrapper.js +5 -18
  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 +3 -17
  93. package/dist/esm/components/ProseMirrorDoc.js +6 -19
  94. package/dist/esm/components/SeparatorHackView.js +3 -4
  95. package/dist/esm/components/TextNodeView.js +6 -10
  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 +6 -22
  99. package/dist/esm/components/marks/MarkView.js +11 -24
  100. package/dist/esm/components/marks/MarkViewConstructorView.js +7 -27
  101. package/dist/esm/components/marks/ReactMarkView.js +3 -18
  102. package/dist/esm/components/nodes/DefaultNodeView.js +6 -22
  103. package/dist/esm/components/nodes/DocNodeView.js +2 -2
  104. package/dist/esm/components/nodes/NodeView.js +11 -24
  105. package/dist/esm/components/nodes/NodeViewConstructorView.js +11 -31
  106. package/dist/esm/components/nodes/ReactNodeView.js +6 -22
  107. package/dist/esm/decorations/ReactWidgetType.js +10 -8
  108. package/dist/esm/decorations/iterDeco.js +13 -13
  109. package/dist/esm/decorations/viewDecorations.js +7 -6
  110. package/dist/esm/dom.js +1 -2
  111. package/dist/esm/findDOMNode.js +1 -1
  112. package/dist/esm/hooks/useComponentEventListeners.js +2 -3
  113. package/dist/esm/hooks/useEditor.js +5 -9
  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 +1 -3
  118. package/dist/esm/hooks/useMarkViewDescription.js +14 -10
  119. package/dist/esm/hooks/useNodeViewDescription.js +10 -8
  120. package/dist/esm/hooks/useReactKeys.js +1 -1
  121. package/dist/esm/plugins/beforeInputPlugin.js +12 -17
  122. package/dist/esm/plugins/reactKeys.js +3 -4
  123. package/dist/esm/props.js +15 -15
  124. package/dist/esm/testing/editorViewTestHelpers.js +20 -31
  125. package/dist/esm/testing/setupProseMirrorView.js +1 -2
  126. package/dist/esm/tiptap/ReactProseMirrorNodeView.js +7 -5
  127. package/dist/esm/tiptap/TiptapEditor.js +9 -10
  128. package/dist/esm/tiptap/TiptapEditorContent.js +4 -18
  129. package/dist/esm/tiptap/TiptapEditorView.js +8 -23
  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 +4 -8
  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 +20 -38
  136. package/dist/esm/viewdesc.js +74 -66
  137. package/dist/tsconfig.tsbuildinfo +1 -1
  138. package/dist/types/constants.d.ts +1 -1
  139. package/dist/types/props.d.ts +8 -8
  140. package/package.json +1 -2
@@ -9,25 +9,37 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- ReactWidgetType: ()=>ReactWidgetType,
13
- widget: ()=>widget
12
+ ReactWidgetType: function() {
13
+ return ReactWidgetType;
14
+ },
15
+ widget: function() {
16
+ return widget;
17
+ }
14
18
  });
15
- const _prosemirrorView = require("prosemirror-view");
19
+ const _prosemirrorview = require("prosemirror-view");
16
20
  function compareObjs(a, b) {
17
21
  if (a == b) return true;
18
22
  for(const p in a)if (a[p] !== b[p]) return false;
19
- for(const p1 in b)if (!(p1 in a)) return false;
23
+ for(const p in b)if (!(p in a)) return false;
20
24
  return true;
21
25
  }
22
26
  const noSpec = {
23
27
  side: 0
24
28
  };
25
29
  let ReactWidgetType = class ReactWidgetType {
30
+ Component;
31
+ side;
32
+ spec;
33
+ constructor(Component, spec){
34
+ this.Component = Component;
35
+ this.spec = spec ?? noSpec;
36
+ this.side = this.spec.side ?? 0;
37
+ }
26
38
  map(mapping, span, offset, oldOffset) {
27
- const { pos , deleted } = mapping.mapResult(span.from + oldOffset, this.side < 0 ? -1 : 1);
39
+ const { pos, deleted } = mapping.mapResult(span.from + oldOffset, this.side < 0 ? -1 : 1);
28
40
  // @ts-expect-error The Decoration constructor is private/internal, but
29
41
  // we need to use it for our custom widget implementation here.
30
- return deleted ? null : new _prosemirrorView.Decoration(pos - offset, pos - offset, this);
42
+ return deleted ? null : new _prosemirrorview.Decoration(pos - offset, pos - offset, this);
31
43
  }
32
44
  valid() {
33
45
  return true;
@@ -38,15 +50,9 @@ let ReactWidgetType = class ReactWidgetType {
38
50
  destroy() {
39
51
  // Can be implemented with React effect hooks
40
52
  }
41
- constructor(Component, spec){
42
- this.Component = Component;
43
- this.spec = spec !== null && spec !== void 0 ? spec : noSpec;
44
- var _side;
45
- this.side = (_side = this.spec.side) !== null && _side !== void 0 ? _side : 0;
46
- }
47
53
  };
48
54
  function widget(pos, component, spec) {
49
55
  // @ts-expect-error The Decoration constructor is private/internal, but
50
56
  // we need to use it for our custom widget implementation here.
51
- return new _prosemirrorView.Decoration(pos, pos, new ReactWidgetType(component, spec));
57
+ return new _prosemirrorview.Decoration(pos, pos, new ReactWidgetType(component, spec));
52
58
  }
@@ -4,9 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "computeDocDeco", {
6
6
  enumerable: true,
7
- get: ()=>computeDocDeco
7
+ get: function() {
8
+ return computeDocDeco;
9
+ }
8
10
  });
9
- const _prosemirrorView = require("prosemirror-view");
11
+ const _prosemirrorview = require("prosemirror-view");
10
12
  const DocDecorationsCache = new WeakMap();
11
13
  function computeDocDeco(view) {
12
14
  const attrs = Object.create(null);
@@ -22,7 +24,7 @@ function computeDocDeco(view) {
22
24
  });
23
25
  if (!attrs.translate) attrs.translate = "no";
24
26
  const next = [
25
- _prosemirrorView.Decoration.node(0, view.state.doc.content.size, attrs)
27
+ _prosemirrorview.Decoration.node(0, view.state.doc.content.size, attrs)
26
28
  ];
27
29
  const previous = DocDecorationsCache.get(view);
28
30
  if (!previous) {
@@ -4,9 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "iterDeco", {
6
6
  enumerable: true,
7
- get: ()=>iterDeco
7
+ get: function() {
8
+ return iterDeco;
9
+ }
8
10
  });
9
- const _reactWidgetTypeJs = require("./ReactWidgetType.js");
11
+ const _ReactWidgetType = require("./ReactWidgetType.js");
10
12
  function compareSide(a, b) {
11
13
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
14
  return a.type.side - b.type.side;
@@ -37,7 +39,7 @@ onWidget, onNode) {
37
39
  const next = locals[decoIndex++];
38
40
  if (next.widget || // FORK: Our custom widget type can't report itself as a widget,
39
41
  // so we have to explicitly check
40
- next.type instanceof _reactWidgetTypeJs.ReactWidgetType) {
42
+ next.type instanceof _ReactWidgetType.ReactWidgetType) {
41
43
  if (!widget) widget = next;
42
44
  else (widgets || (widgets = [
43
45
  widget
@@ -47,41 +49,41 @@ onWidget, onNode) {
47
49
  if (widget) {
48
50
  if (widgets) {
49
51
  widgets.sort(compareSide);
50
- for(let i1 = 0; i1 < widgets.length; i1++)onWidget(widgets[i1], // eslint-disable-next-line @typescript-eslint/no-explicit-any
51
- !(widgets[i1].type instanceof _reactWidgetTypeJs.ReactWidgetType), offset, parentIndex + i1, !!restNode);
52
+ for(let i = 0; i < widgets.length; i++)onWidget(widgets[i], // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ !(widgets[i].type instanceof _ReactWidgetType.ReactWidgetType), offset, parentIndex + i, !!restNode);
52
54
  } else {
53
55
  onWidget(widget, // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
- !(widget.type instanceof _reactWidgetTypeJs.ReactWidgetType), offset, parentIndex, !!restNode);
56
+ !(widget.type instanceof _ReactWidgetType.ReactWidgetType), offset, parentIndex, !!restNode);
55
57
  }
56
58
  }
57
59
  }
58
- let child1, index;
60
+ let child, index;
59
61
  if (restNode) {
60
62
  index = -1;
61
- child1 = restNode;
63
+ child = restNode;
62
64
  restNode = null;
63
65
  } else if (parentIndex < parent.childCount) {
64
66
  index = parentIndex;
65
- child1 = parent.child(parentIndex++);
67
+ child = parent.child(parentIndex++);
66
68
  } else {
67
69
  break;
68
70
  }
69
- for(let i2 = 0; i2 < active.length; i2++)if (active[i2].to <= offset) active.splice(i2--, 1);
71
+ for(let i = 0; i < active.length; i++)if (active[i].to <= offset) active.splice(i--, 1);
70
72
  while(decoIndex < locals.length && locals[decoIndex].from <= offset && locals[decoIndex].to > offset)active.push(locals[decoIndex++]);
71
- let end = offset + child1.nodeSize;
72
- if (child1.isText) {
73
+ let end = offset + child.nodeSize;
74
+ if (child.isText) {
73
75
  let cutAt = end;
74
76
  if (decoIndex < locals.length && locals[decoIndex].from < cutAt) cutAt = locals[decoIndex].from;
75
- for(let i3 = 0; i3 < active.length; i3++)if (active[i3].to < cutAt) cutAt = active[i3].to;
77
+ for(let i = 0; i < active.length; i++)if (active[i].to < cutAt) cutAt = active[i].to;
76
78
  if (cutAt < end) {
77
- restNode = child1.cut(cutAt - offset);
78
- child1 = child1.cut(0, cutAt - offset);
79
+ restNode = child.cut(cutAt - offset);
80
+ child = child.cut(0, cutAt - offset);
79
81
  end = cutAt;
80
82
  index = -1;
81
83
  }
82
84
  }
83
- const outerDeco = child1.isInline && !child1.isLeaf ? active.filter((d)=>!d.inline) : active.slice();
84
- onNode(child1, outerDeco, deco.forChild(offset, child1), offset, index);
85
+ const outerDeco = child.isInline && !child.isLeaf ? active.filter((d)=>!d.inline) : active.slice();
86
+ onNode(child, outerDeco, deco.forChild(offset, child), offset, index);
85
87
  offset = end;
86
88
  }
87
89
  }
@@ -4,22 +4,28 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "viewDecorations", {
6
6
  enumerable: true,
7
- get: ()=>viewDecorations
7
+ get: function() {
8
+ return viewDecorations;
9
+ }
8
10
  });
9
- const _prosemirrorView = require("prosemirror-view");
11
+ const _prosemirrorview = require("prosemirror-view");
10
12
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
13
  const none = [], noSpec = {};
12
- const empty = _prosemirrorView.DecorationSet.empty;
14
+ const empty = _prosemirrorview.DecorationSet.empty;
13
15
  // An abstraction that allows the code dealing with decorations to
14
16
  // treat multiple DecorationSet objects as if it were a single object
15
17
  // with (a subset of) the same interface.
16
18
  let DecorationGroup = class DecorationGroup {
19
+ members;
20
+ constructor(members){
21
+ this.members = members;
22
+ }
17
23
  map(mapping, doc) {
18
24
  const mappedDecos = this.members.map((member)=>member.map(mapping, doc, noSpec));
19
25
  return DecorationGroup.from(mappedDecos);
20
26
  }
21
27
  forChild(offset, child) {
22
- if (child.isLeaf) return _prosemirrorView.DecorationSet.empty;
28
+ if (child.isLeaf) return _prosemirrorview.DecorationSet.empty;
23
29
  let found = [];
24
30
  for(let i = 0; i < this.members.length; i++){
25
31
  const result = this.members[i].forChild(offset, child);
@@ -62,16 +68,13 @@ let DecorationGroup = class DecorationGroup {
62
68
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
63
69
  return members[0];
64
70
  default:
65
- return new DecorationGroup(members.every((m)=>m instanceof _prosemirrorView.DecorationSet) ? members : members.reduce((r, m)=>r.concat(m instanceof _prosemirrorView.DecorationSet ? m : m.members), []));
71
+ return new DecorationGroup(members.every((m)=>m instanceof _prosemirrorview.DecorationSet) ? members : members.reduce((r, m)=>r.concat(m instanceof _prosemirrorview.DecorationSet ? m : m.members), []));
66
72
  }
67
73
  }
68
74
  forEachSet(f) {
69
75
  for(let i = 0; i < this.members.length; i++)// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
70
76
  this.members[i].forEachSet(f);
71
77
  }
72
- constructor(members){
73
- this.members = members;
74
- }
75
78
  };
76
79
  // Used to sort decorations so that ones with a low start position
77
80
  // come first, and within a set with the same start position, those
@@ -127,7 +130,7 @@ function viewDecorations(view, cursorWrapper) {
127
130
  if (result && result != empty) found.push(result);
128
131
  });
129
132
  if (cursorWrapper) {
130
- found.push(_prosemirrorView.DecorationSet.create(view.state.doc, [
133
+ found.push(_prosemirrorview.DecorationSet.create(view.state.doc, [
131
134
  cursorWrapper
132
135
  ]));
133
136
  }
@@ -149,9 +152,9 @@ function viewDecorations(view, cursorWrapper) {
149
152
  areSetsEqual = false;
150
153
  }
151
154
  if (!areSetsEqual) {
152
- const result1 = DecorationGroup.from(found);
153
- ViewDecorationsCache.set(view, result1);
154
- return result1;
155
+ const result = DecorationGroup.from(found);
156
+ ViewDecorationsCache.set(view, result);
157
+ return result;
155
158
  }
156
159
  return previous;
157
160
  }
package/dist/cjs/dom.js CHANGED
@@ -9,17 +9,39 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- domIndex: ()=>domIndex,
13
- parentNode: ()=>parentNode,
14
- textRange: ()=>textRange,
15
- isEquivalentPosition: ()=>isEquivalentPosition,
16
- nodeSize: ()=>nodeSize,
17
- isOnEdge: ()=>isOnEdge,
18
- hasBlockDesc: ()=>hasBlockDesc,
19
- selectionCollapsed: ()=>selectionCollapsed,
20
- keyEvent: ()=>keyEvent,
21
- deepActiveElement: ()=>deepActiveElement,
22
- caretFromPoint: ()=>caretFromPoint
12
+ caretFromPoint: function() {
13
+ return caretFromPoint;
14
+ },
15
+ deepActiveElement: function() {
16
+ return deepActiveElement;
17
+ },
18
+ domIndex: function() {
19
+ return domIndex;
20
+ },
21
+ hasBlockDesc: function() {
22
+ return hasBlockDesc;
23
+ },
24
+ isEquivalentPosition: function() {
25
+ return isEquivalentPosition;
26
+ },
27
+ isOnEdge: function() {
28
+ return isOnEdge;
29
+ },
30
+ keyEvent: function() {
31
+ return keyEvent;
32
+ },
33
+ nodeSize: function() {
34
+ return nodeSize;
35
+ },
36
+ parentNode: function() {
37
+ return parentNode;
38
+ },
39
+ selectionCollapsed: function() {
40
+ return selectionCollapsed;
41
+ },
42
+ textRange: function() {
43
+ return textRange;
44
+ }
23
45
  });
24
46
  const domIndex = function(node) {
25
47
  for(let index = 0;; index++){
@@ -53,8 +75,7 @@ function scanFor(node, off, targetNode, targetOff, dir) {
53
75
  } else if (node.nodeType == 1) {
54
76
  const child = node.childNodes[off + (dir < 0 ? -1 : 0)];
55
77
  if (child.nodeType == 1 && child.contentEditable == "false") {
56
- var ref;
57
- if ((ref = child.pmViewDesc) === null || ref === void 0 ? void 0 : ref.ignoreForSelection) off += dir;
78
+ if (child.pmViewDesc?.ignoreForSelection) off += dir;
58
79
  else return false;
59
80
  } else {
60
81
  node = child;
@@ -9,10 +9,14 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- getInstance: ()=>getInstance,
13
- findDOMNode: ()=>findDOMNode
12
+ findDOMNode: function() {
13
+ return findDOMNode;
14
+ },
15
+ getInstance: function() {
16
+ return getInstance;
17
+ }
14
18
  });
15
- const _reflectionJs = require("react-reconciler/reflection.js");
19
+ const _reflection = require("react-reconciler/reflection.js");
16
20
  function getInstance(key) {
17
21
  return key._reactInternals;
18
22
  }
@@ -28,10 +32,10 @@ function findHostInstance(component) {
28
32
  throw new Error("Unable to find node on an unmounted component.");
29
33
  } else {
30
34
  const keys = Object.keys(component).join(",");
31
- throw new Error("Argument appears to not be a ReactComponent. Keys: ".concat(keys));
35
+ throw new Error(`Argument appears to not be a ReactComponent. Keys: ${keys}`);
32
36
  }
33
37
  }
34
- const hostFiber = (0, _reflectionJs.findCurrentHostFiber)(fiber);
38
+ const hostFiber = (0, _reflection.findCurrentHostFiber)(fiber);
35
39
  if (hostFiber === null) {
36
40
  return null;
37
41
  }
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useClientLayoutEffect", {
6
6
  enumerable: true,
7
- get: ()=>useClientLayoutEffect
7
+ get: function() {
8
+ return useClientLayoutEffect;
9
+ }
8
10
  });
9
11
  const _react = require("react");
10
12
  function useClientLayoutEffect() {
@@ -4,15 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useComponentEventListeners", {
6
6
  enumerable: true,
7
- get: ()=>useComponentEventListeners
7
+ get: function() {
8
+ return useComponentEventListeners;
9
+ }
8
10
  });
9
11
  const _react = require("react");
10
- const _componentEventListenersJs = require("../plugins/componentEventListeners.js");
12
+ const _componentEventListeners = require("../plugins/componentEventListeners.js");
11
13
  function useComponentEventListeners() {
12
14
  const [registry, setRegistry] = (0, _react.useState)(new Map());
13
15
  const registerEventListener = (0, _react.useCallback)((eventType, handler)=>{
14
- var ref;
15
- const handlers = (ref = registry.get(eventType)) !== null && ref !== void 0 ? ref : [];
16
+ const handlers = registry.get(eventType) ?? [];
16
17
  handlers.unshift(handler);
17
18
  if (!registry.has(eventType)) {
18
19
  registry.set(eventType, handlers);
@@ -23,11 +24,11 @@ function useComponentEventListeners() {
23
24
  ]);
24
25
  const unregisterEventListener = (0, _react.useCallback)((eventType, handler)=>{
25
26
  const handlers = registry.get(eventType);
26
- handlers === null || handlers === void 0 ? void 0 : handlers.splice(handlers.indexOf(handler), 1);
27
+ handlers?.splice(handlers.indexOf(handler), 1);
27
28
  }, [
28
29
  registry
29
30
  ]);
30
- const componentEventListenersPlugin = (0, _react.useMemo)(()=>(0, _componentEventListenersJs.componentEventListeners)(registry), [
31
+ const componentEventListenersPlugin = (0, _react.useMemo)(()=>(0, _componentEventListeners.componentEventListeners)(registry), [
31
32
  registry
32
33
  ]);
33
34
  return {
@@ -4,18 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useEditor", {
6
6
  enumerable: true,
7
- get: ()=>useEditor
7
+ get: function() {
8
+ return useEditor;
9
+ }
8
10
  });
9
11
  const _react = require("react");
10
- const _reactDom = require("react-dom");
11
- const _reactEditorViewJs = require("../ReactEditorView.js");
12
- const _staticEditorViewJs = require("../StaticEditorView.js");
13
- const _constantsJs = require("../constants.js");
14
- const _beforeInputPluginJs = require("../plugins/beforeInputPlugin.js");
15
- const _useClientLayoutEffectJs = require("./useClientLayoutEffect.js");
16
- const _useComponentEventListenersJs = require("./useComponentEventListeners.js");
17
- const _useEffectEventJs = require("./useEffectEvent.js");
18
- const _useForceUpdateJs = require("./useForceUpdate.js");
12
+ const _reactdom = require("react-dom");
13
+ const _ReactEditorView = require("../ReactEditorView.js");
14
+ const _StaticEditorView = require("../StaticEditorView.js");
15
+ const _constants = require("../constants.js");
16
+ const _beforeInputPlugin = require("../plugins/beforeInputPlugin.js");
17
+ const _useClientLayoutEffect = require("./useClientLayoutEffect.js");
18
+ const _useComponentEventListeners = require("./useComponentEventListeners.js");
19
+ const _useEffectEvent = require("./useEffectEvent.js");
20
+ const _useForceUpdate = require("./useForceUpdate.js");
19
21
  let didWarnValueDefaultValue = false;
20
22
  function useEditor(mount, options) {
21
23
  if (process.env.NODE_ENV !== "production") {
@@ -26,23 +28,20 @@ function useEditor(mount, options) {
26
28
  }
27
29
  const flushSyncRef = (0, _react.useRef)(true);
28
30
  const [cursorWrapper, _setCursorWrapper] = (0, _react.useState)(null);
29
- const forceUpdate = (0, _useForceUpdateJs.useForceUpdate)();
30
- var _defaultState;
31
- const defaultState = (_defaultState = options.defaultState) !== null && _defaultState !== void 0 ? _defaultState : _constantsJs.EMPTY_STATE;
31
+ const forceUpdate = (0, _useForceUpdate.useForceUpdate)();
32
+ const defaultState = options.defaultState ?? _constants.EMPTY_STATE;
32
33
  const [_state, setState] = (0, _react.useState)(defaultState);
33
- var _state1;
34
- const state = (_state1 = options.state) !== null && _state1 !== void 0 ? _state1 : _state;
35
- const { componentEventListenersPlugin , registerEventListener , unregisterEventListener } = (0, _useComponentEventListenersJs.useComponentEventListeners)();
34
+ const state = options.state ?? _state;
35
+ const { componentEventListenersPlugin, registerEventListener, unregisterEventListener } = (0, _useComponentEventListeners.useComponentEventListeners)();
36
36
  const setCursorWrapper = (0, _react.useCallback)((deco)=>{
37
- (0, _reactDom.flushSync)(()=>{
37
+ (0, _reactdom.flushSync)(()=>{
38
38
  _setCursorWrapper(deco);
39
39
  });
40
40
  }, []);
41
- var _plugins;
42
41
  const plugins = (0, _react.useMemo)(()=>[
43
- ...(_plugins = options.plugins) !== null && _plugins !== void 0 ? _plugins : [],
42
+ ...options.plugins ?? [],
44
43
  componentEventListenersPlugin,
45
- (0, _beforeInputPluginJs.beforeInputPlugin)(setCursorWrapper)
44
+ (0, _beforeInputPlugin.beforeInputPlugin)(setCursorWrapper)
46
45
  ], [
47
46
  options.plugins,
48
47
  componentEventListenersPlugin,
@@ -50,7 +49,7 @@ function useEditor(mount, options) {
50
49
  ]);
51
50
  const dispatchTransaction = (0, _react.useCallback)(function dispatchTransaction(tr) {
52
51
  if (flushSyncRef.current) {
53
- (0, _reactDom.flushSync)(()=>{
52
+ (0, _reactdom.flushSync)(()=>{
54
53
  if (!options.state) {
55
54
  setState((s)=>s.apply(tr));
56
55
  }
@@ -77,19 +76,19 @@ function useEditor(mount, options) {
77
76
  dispatchTransaction
78
77
  };
79
78
  const [view, setView] = (0, _react.useState)(()=>{
80
- return new _staticEditorViewJs.StaticEditorView(directEditorProps);
79
+ return new _StaticEditorView.StaticEditorView(directEditorProps);
81
80
  });
82
- const createEditorView = (0, _useEffectEventJs.useEffectEvent)((mount)=>{
81
+ const createEditorView = (0, _useEffectEvent.useEffectEvent)((mount)=>{
83
82
  if (mount && !options.static) {
84
- const view = new _reactEditorViewJs.ReactEditorView({
83
+ const view = new _ReactEditorView.ReactEditorView({
85
84
  mount
86
85
  }, directEditorProps);
87
86
  view.dom.addEventListener("compositionend", forceUpdate);
88
87
  return view;
89
88
  }
90
- return new _staticEditorViewJs.StaticEditorView(directEditorProps);
89
+ return new _StaticEditorView.StaticEditorView(directEditorProps);
91
90
  });
92
- (0, _useClientLayoutEffectJs.useClientLayoutEffect)(()=>{
91
+ (0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
93
92
  const view = createEditorView(mount);
94
93
  setView(view);
95
94
  return ()=>{
@@ -99,11 +98,11 @@ function useEditor(mount, options) {
99
98
  createEditorView,
100
99
  mount
101
100
  ]);
102
- (0, _useClientLayoutEffectJs.useClientLayoutEffect)(()=>{
101
+ (0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
103
102
  // Ensure that the EditorView hasn't been destroyed before
104
103
  // running effects. Running effects will reattach selection
105
104
  // change listeners if the EditorView has been destroyed.
106
- if (view instanceof _reactEditorViewJs.ReactEditorView && !view.isDestroyed) {
105
+ if (view instanceof _ReactEditorView.ReactEditorView && !view.isDestroyed) {
107
106
  // Plugins might dispatch transactions from their
108
107
  // view update lifecycle hooks
109
108
  flushSyncRef.current = false;
@@ -112,14 +111,13 @@ function useEditor(mount, options) {
112
111
  }
113
112
  });
114
113
  view.update(directEditorProps);
115
- var _static;
116
114
  const editor = (0, _react.useMemo)(()=>({
117
115
  view,
118
116
  cursorWrapper,
119
117
  flushSyncRef,
120
118
  registerEventListener,
121
119
  unregisterEventListener,
122
- isStatic: (_static = options.static) !== null && _static !== void 0 ? _static : false
120
+ isStatic: options.static ?? false
123
121
  }), [
124
122
  cursorWrapper,
125
123
  options.static,
@@ -4,14 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useEditorEffect", {
6
6
  enumerable: true,
7
- get: ()=>useEditorEffect
7
+ get: function() {
8
+ return useEditorEffect;
9
+ }
8
10
  });
9
11
  const _react = require("react");
10
- const _reactEditorViewJs = require("../ReactEditorView.js");
11
- const _editorContextJs = require("../contexts/EditorContext.js");
12
- const _useLayoutGroupEffectJs = require("./useLayoutGroupEffect.js");
12
+ const _ReactEditorView = require("../ReactEditorView.js");
13
+ const _EditorContext = require("../contexts/EditorContext.js");
14
+ const _useLayoutGroupEffect = require("./useLayoutGroupEffect.js");
13
15
  function useEditorEffect(effect, dependencies) {
14
- const { view , flushSyncRef } = (0, _react.useContext)(_editorContextJs.EditorContext);
16
+ const { view, flushSyncRef } = (0, _react.useContext)(_EditorContext.EditorContext);
15
17
  // The rules of hooks want `effect` to be included in the
16
18
  // dependency list, but dependency issues for `effect` will
17
19
  // be caught by the linter at the call-site for
@@ -19,8 +21,8 @@ function useEditorEffect(effect, dependencies) {
19
21
  // Note: we specifically don't want to re-run the effect
20
22
  // every time it changes, because it will most likely
21
23
  // be defined inline and run on every re-render.
22
- (0, _useLayoutGroupEffectJs.useLayoutGroupEffect)(()=>{
23
- if (view instanceof _reactEditorViewJs.ReactEditorView) {
24
+ (0, _useLayoutGroupEffect.useLayoutGroupEffect)(()=>{
25
+ if (view instanceof _ReactEditorView.ReactEditorView) {
24
26
  flushSyncRef.current = false;
25
27
  const result = effect(view);
26
28
  flushSyncRef.current = true;
@@ -4,22 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useEditorEventCallback", {
6
6
  enumerable: true,
7
- get: ()=>useEditorEventCallback
7
+ get: function() {
8
+ return useEditorEventCallback;
9
+ }
8
10
  });
9
11
  const _react = require("react");
10
- const _reactEditorViewJs = require("../ReactEditorView.js");
11
- const _editorContextJs = require("../contexts/EditorContext.js");
12
- const _useEditorEffectJs = require("./useEditorEffect.js");
12
+ const _ReactEditorView = require("../ReactEditorView.js");
13
+ const _EditorContext = require("../contexts/EditorContext.js");
14
+ const _useEditorEffect = require("./useEditorEffect.js");
13
15
  function assertIsReactEditorView(view) {
14
- if (view instanceof _reactEditorViewJs.ReactEditorView) {
16
+ if (view instanceof _ReactEditorView.ReactEditorView) {
15
17
  return;
16
18
  }
17
19
  throw new DOMException("ProseMirror document is not mounted", "InvalidStateError");
18
20
  }
19
21
  function useEditorEventCallback(callback) {
20
22
  const ref = (0, _react.useRef)(callback);
21
- const { view } = (0, _react.useContext)(_editorContextJs.EditorContext);
22
- (0, _useEditorEffectJs.useEditorEffect)(()=>{
23
+ const { view } = (0, _react.useContext)(_EditorContext.EditorContext);
24
+ (0, _useEditorEffect.useEditorEffect)(()=>{
23
25
  ref.current = callback;
24
26
  }, [
25
27
  callback
@@ -4,15 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useEditorEventListener", {
6
6
  enumerable: true,
7
- get: ()=>useEditorEventListener
7
+ get: function() {
8
+ return useEditorEventListener;
9
+ }
8
10
  });
9
11
  const _react = require("react");
10
- const _editorContextJs = require("../contexts/EditorContext.js");
11
- const _useEditorEffectJs = require("./useEditorEffect.js");
12
+ const _EditorContext = require("../contexts/EditorContext.js");
13
+ const _useEditorEffect = require("./useEditorEffect.js");
12
14
  function useEditorEventListener(eventType, handler) {
13
- const { registerEventListener , unregisterEventListener } = (0, _react.useContext)(_editorContextJs.EditorContext);
15
+ const { registerEventListener, unregisterEventListener } = (0, _react.useContext)(_EditorContext.EditorContext);
14
16
  const ref = (0, _react.useRef)(handler);
15
- (0, _useEditorEffectJs.useEditorEffect)(()=>{
17
+ (0, _useEditorEffect.useEditorEffect)(()=>{
16
18
  ref.current = handler;
17
19
  }, [
18
20
  handler
@@ -20,7 +22,7 @@ function useEditorEventListener(eventType, handler) {
20
22
  const eventHandler = (0, _react.useCallback)(function(view, event) {
21
23
  return ref.current.call(this, view, event);
22
24
  }, []);
23
- (0, _useEditorEffectJs.useEditorEffect)(()=>{
25
+ (0, _useEditorEffect.useEditorEffect)(()=>{
24
26
  registerEventListener(eventType, eventHandler);
25
27
  return ()=>unregisterEventListener(eventType, eventHandler);
26
28
  }, [
@@ -4,11 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useEditorState", {
6
6
  enumerable: true,
7
- get: ()=>useEditorState
7
+ get: function() {
8
+ return useEditorState;
9
+ }
8
10
  });
9
11
  const _react = require("react");
10
- const _editorStateContextJs = require("../contexts/EditorStateContext.js");
12
+ const _EditorStateContext = require("../contexts/EditorStateContext.js");
11
13
  function useEditorState() {
12
- const editorState = (0, _react.useContext)(_editorStateContextJs.EditorStateContext);
14
+ const editorState = (0, _react.useContext)(_EditorStateContext.EditorStateContext);
13
15
  return editorState;
14
16
  }
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useEffectEvent", {
6
6
  enumerable: true,
7
- get: ()=>useEffectEvent
7
+ get: function() {
8
+ return useEffectEvent;
9
+ }
8
10
  });
9
11
  const _react = require("react");
10
12
  function useEffectEvent(fn) {
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useForceUpdate", {
6
6
  enumerable: true,
7
- get: ()=>useForceUpdate
7
+ get: function() {
8
+ return useForceUpdate;
9
+ }
8
10
  });
9
11
  const _react = require("react");
10
12
  function useForceUpdate() {