@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
@@ -4,13 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "TextNodeView", {
6
6
  enumerable: true,
7
- get: ()=>TextNodeView
7
+ get: function() {
8
+ return TextNodeView;
9
+ }
8
10
  });
9
- const _prosemirrorView = require("prosemirror-view");
11
+ const _prosemirrorview = require("prosemirror-view");
10
12
  const _react = require("react");
11
- const _findDOMNodeJs = require("../findDOMNode.js");
12
- const _viewdescJs = require("../viewdesc.js");
13
- const _childNodeViewsJs = require("./ChildNodeViews.js");
13
+ const _findDOMNode = require("../findDOMNode.js");
14
+ const _viewdesc = require("../viewdesc.js");
15
+ const _ChildNodeViews = require("./ChildNodeViews.js");
14
16
  function shallowEqual(objA, objB) {
15
17
  if (objA === objB) {
16
18
  return true;
@@ -34,37 +36,38 @@ function shallowEqual(objA, objB) {
34
36
  return true;
35
37
  }
36
38
  let TextNodeView = class TextNodeView extends _react.Component {
39
+ viewDescRef = null;
40
+ renderRef = null;
37
41
  updateEffect() {
38
- const { view , decorations , siblingsRef , parentRef , getPos , node } = this.props;
42
+ const { view, decorations, siblingsRef, parentRef, getPos, node } = this.props;
39
43
  // There simply is no other way to ref a text node
40
44
  // eslint-disable-next-line react/no-find-dom-node
41
- const dom = (0, _findDOMNodeJs.findDOMNode)(this);
45
+ const dom = (0, _findDOMNode.findDOMNode)(this);
42
46
  // We only need to explicitly create a CompositionViewDesc
43
47
  // when a composition was started that produces a new text node.
44
48
  // Otherwise we just rely on re-rendering the renderRef
45
49
  if (!dom) {
46
50
  if (!view.composing) return;
47
- var _text, _text1;
48
- this.viewDescRef = new _viewdescJs.CompositionViewDesc(parentRef.current, getPos, // These are just placeholders/dummies. We can't
51
+ this.viewDescRef = new _viewdesc.CompositionViewDesc(parentRef.current, getPos, // These are just placeholders/dummies. We can't
49
52
  // actually find the correct DOM nodes from here,
50
53
  // so we let our parent do it.
51
54
  // Passing a valid element here just so that the
52
55
  // ViewDesc constructor doesn't blow up.
53
- document.createElement("div"), document.createTextNode((_text = node.text) !== null && _text !== void 0 ? _text : ""), (_text1 = node.text) !== null && _text1 !== void 0 ? _text1 : "");
56
+ document.createElement("div"), document.createTextNode(node.text ?? ""), node.text ?? "");
54
57
  return;
55
58
  }
56
59
  let textNode = dom;
57
60
  while(textNode.firstChild){
58
61
  textNode = textNode.firstChild;
59
62
  }
60
- if (!this.viewDescRef || this.viewDescRef instanceof _viewdescJs.CompositionViewDesc) {
61
- this.viewDescRef = new _viewdescJs.TextViewDesc(undefined, [], getPos, node, decorations, _prosemirrorView.DecorationSet.empty, dom, textNode);
63
+ if (!this.viewDescRef || this.viewDescRef instanceof _viewdesc.CompositionViewDesc) {
64
+ this.viewDescRef = new _viewdesc.TextViewDesc(undefined, [], getPos, node, decorations, _prosemirrorview.DecorationSet.empty, dom, textNode);
62
65
  } else {
63
66
  this.viewDescRef.parent = parentRef.current;
64
67
  this.viewDescRef.children = [];
65
68
  this.viewDescRef.node = node;
66
69
  this.viewDescRef.outerDeco = decorations;
67
- this.viewDescRef.innerDeco = _prosemirrorView.DecorationSet.empty;
70
+ this.viewDescRef.innerDeco = _prosemirrorview.DecorationSet.empty;
68
71
  this.viewDescRef.dom = dom;
69
72
  this.viewDescRef.dom.pmViewDesc = this.viewDescRef;
70
73
  this.viewDescRef.nodeDOM = textNode;
@@ -72,7 +75,7 @@ let TextNodeView = class TextNodeView extends _react.Component {
72
75
  if (!siblingsRef.current.includes(this.viewDescRef)) {
73
76
  siblingsRef.current.push(this.viewDescRef);
74
77
  }
75
- siblingsRef.current.sort(_viewdescJs.sortViewDescs);
78
+ siblingsRef.current.sort(_viewdesc.sortViewDescs);
76
79
  }
77
80
  shouldComponentUpdate(nextProps) {
78
81
  return !shallowEqual(this.props, nextProps);
@@ -84,7 +87,7 @@ let TextNodeView = class TextNodeView extends _react.Component {
84
87
  this.updateEffect();
85
88
  }
86
89
  componentWillUnmount() {
87
- const { siblingsRef } = this.props;
90
+ const { siblingsRef } = this.props;
88
91
  if (!this.viewDescRef) return;
89
92
  if (siblingsRef.current.includes(this.viewDescRef)) {
90
93
  const index = siblingsRef.current.indexOf(this.viewDescRef);
@@ -92,7 +95,7 @@ let TextNodeView = class TextNodeView extends _react.Component {
92
95
  }
93
96
  }
94
97
  render() {
95
- const { view , getPos , node , decorations } = this.props;
98
+ const { view, getPos, node, decorations } = this.props;
96
99
  // During a composition, it's crucial that we don't try to
97
100
  // update the DOM that the user is working in. If there's
98
101
  // an active composition and the selection is in this node,
@@ -101,12 +104,7 @@ let TextNodeView = class TextNodeView extends _react.Component {
101
104
  if (view.composing && view.state.selection.from >= getPos() && view.state.selection.from <= getPos() + node.nodeSize) {
102
105
  return this.renderRef;
103
106
  }
104
- this.renderRef = decorations.reduce(_childNodeViewsJs.wrapInDeco, node.text);
107
+ this.renderRef = decorations.reduce(_ChildNodeViews.wrapInDeco, node.text);
105
108
  return this.renderRef;
106
109
  }
107
- constructor(...args){
108
- super(...args);
109
- this.viewDescRef = null;
110
- this.renderRef = null;
111
- }
112
110
  };
@@ -4,12 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "TrailingHackView", {
6
6
  enumerable: true,
7
- get: ()=>TrailingHackView
7
+ get: function() {
8
+ return TrailingHackView;
9
+ }
8
10
  });
9
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
10
- const _childDescriptionsContextJs = require("../contexts/ChildDescriptionsContext.js");
11
- const _useClientLayoutEffectJs = require("../hooks/useClientLayoutEffect.js");
12
- const _viewdescJs = require("../viewdesc.js");
11
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
12
+ const _ChildDescriptionsContext = require("../contexts/ChildDescriptionsContext.js");
13
+ const _useClientLayoutEffect = require("../hooks/useClientLayoutEffect.js");
14
+ const _viewdesc = require("../viewdesc.js");
13
15
  function _getRequireWildcardCache(nodeInterop) {
14
16
  if (typeof WeakMap !== "function") return null;
15
17
  var cacheBabelInterop = new WeakMap();
@@ -18,7 +20,7 @@ function _getRequireWildcardCache(nodeInterop) {
18
20
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
19
21
  })(nodeInterop);
20
22
  }
21
- function _interopRequireWildcard(obj, nodeInterop) {
23
+ function _interop_require_wildcard(obj, nodeInterop) {
22
24
  if (!nodeInterop && obj && obj.__esModule) {
23
25
  return obj;
24
26
  }
@@ -31,7 +33,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
31
33
  if (cache && cache.has(obj)) {
32
34
  return cache.get(obj);
33
35
  }
34
- var newObj = {};
36
+ var newObj = {
37
+ __proto__: null
38
+ };
35
39
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
36
40
  for(var key in obj){
37
41
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -50,11 +54,11 @@ function _interopRequireWildcard(obj, nodeInterop) {
50
54
  return newObj;
51
55
  }
52
56
  function TrailingHackView(param) {
53
- let { getPos } = param;
54
- const { siblingsRef , parentRef } = (0, _react.useContext)(_childDescriptionsContextJs.ChildDescriptionsContext);
57
+ let { getPos } = param;
58
+ const { siblingsRef, parentRef } = (0, _react.useContext)(_ChildDescriptionsContext.ChildDescriptionsContext);
55
59
  const viewDescRef = (0, _react.useRef)(null);
56
60
  const ref = (0, _react.useRef)(null);
57
- (0, _useClientLayoutEffectJs.useClientLayoutEffect)(()=>{
61
+ (0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
58
62
  const siblings = siblingsRef.current;
59
63
  return ()=>{
60
64
  if (!viewDescRef.current) return;
@@ -66,10 +70,10 @@ function TrailingHackView(param) {
66
70
  }, [
67
71
  siblingsRef
68
72
  ]);
69
- (0, _useClientLayoutEffectJs.useClientLayoutEffect)(()=>{
73
+ (0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
70
74
  if (!ref.current) return;
71
75
  if (!viewDescRef.current) {
72
- viewDescRef.current = new _viewdescJs.TrailingHackViewDesc(parentRef.current, [], getPos, ref.current, null);
76
+ viewDescRef.current = new _viewdesc.TrailingHackViewDesc(parentRef.current, [], getPos, ref.current, null);
73
77
  } else {
74
78
  viewDescRef.current.parent = parentRef.current;
75
79
  viewDescRef.current.dom = ref.current;
@@ -77,7 +81,7 @@ function TrailingHackView(param) {
77
81
  if (!siblingsRef.current.includes(viewDescRef.current)) {
78
82
  siblingsRef.current.push(viewDescRef.current);
79
83
  }
80
- siblingsRef.current.sort(_viewdescJs.sortViewDescs);
84
+ siblingsRef.current.sort(_viewdesc.sortViewDescs);
81
85
  });
82
86
  return /*#__PURE__*/ _react.default.createElement("br", {
83
87
  ref: ref,
@@ -4,12 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "WidgetView", {
6
6
  enumerable: true,
7
- get: ()=>WidgetView
7
+ get: function() {
8
+ return WidgetView;
9
+ }
8
10
  });
9
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
10
- const _childDescriptionsContextJs = require("../contexts/ChildDescriptionsContext.js");
11
- const _useClientLayoutEffectJs = require("../hooks/useClientLayoutEffect.js");
12
- const _viewdescJs = require("../viewdesc.js");
11
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
12
+ const _ChildDescriptionsContext = require("../contexts/ChildDescriptionsContext.js");
13
+ const _useClientLayoutEffect = require("../hooks/useClientLayoutEffect.js");
14
+ const _viewdesc = require("../viewdesc.js");
13
15
  function _getRequireWildcardCache(nodeInterop) {
14
16
  if (typeof WeakMap !== "function") return null;
15
17
  var cacheBabelInterop = new WeakMap();
@@ -18,7 +20,7 @@ function _getRequireWildcardCache(nodeInterop) {
18
20
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
19
21
  })(nodeInterop);
20
22
  }
21
- function _interopRequireWildcard(obj, nodeInterop) {
23
+ function _interop_require_wildcard(obj, nodeInterop) {
22
24
  if (!nodeInterop && obj && obj.__esModule) {
23
25
  return obj;
24
26
  }
@@ -31,7 +33,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
31
33
  if (cache && cache.has(obj)) {
32
34
  return cache.get(obj);
33
35
  }
34
- var newObj = {};
36
+ var newObj = {
37
+ __proto__: null
38
+ };
35
39
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
36
40
  for(var key in obj){
37
41
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -50,11 +54,11 @@ function _interopRequireWildcard(obj, nodeInterop) {
50
54
  return newObj;
51
55
  }
52
56
  function WidgetView(param) {
53
- let { widget , getPos } = param;
54
- const { siblingsRef , parentRef } = (0, _react.useContext)(_childDescriptionsContextJs.ChildDescriptionsContext);
57
+ let { widget, getPos } = param;
58
+ const { siblingsRef, parentRef } = (0, _react.useContext)(_ChildDescriptionsContext.ChildDescriptionsContext);
55
59
  const viewDescRef = (0, _react.useRef)(null);
56
60
  const domRef = (0, _react.useRef)(null);
57
- (0, _useClientLayoutEffectJs.useClientLayoutEffect)(()=>{
61
+ (0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
58
62
  const siblings = siblingsRef.current;
59
63
  return ()=>{
60
64
  if (!viewDescRef.current) return;
@@ -66,10 +70,10 @@ function WidgetView(param) {
66
70
  }, [
67
71
  siblingsRef
68
72
  ]);
69
- (0, _useClientLayoutEffectJs.useClientLayoutEffect)(()=>{
73
+ (0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
70
74
  if (!domRef.current) return;
71
75
  if (!viewDescRef.current) {
72
- viewDescRef.current = new _viewdescJs.WidgetViewDesc(parentRef.current, getPos, widget, domRef.current);
76
+ viewDescRef.current = new _viewdesc.WidgetViewDesc(parentRef.current, getPos, widget, domRef.current);
73
77
  } else {
74
78
  viewDescRef.current.parent = parentRef.current;
75
79
  viewDescRef.current.widget = widget;
@@ -78,9 +82,9 @@ function WidgetView(param) {
78
82
  if (!siblingsRef.current.includes(viewDescRef.current)) {
79
83
  siblingsRef.current.push(viewDescRef.current);
80
84
  }
81
- siblingsRef.current.sort(_viewdescJs.sortViewDescs);
85
+ siblingsRef.current.sort(_viewdesc.sortViewDescs);
82
86
  });
83
- const { Component } = widget.type;
87
+ const { Component } = widget.type;
84
88
  return Component && /*#__PURE__*/ _react.default.createElement(Component, {
85
89
  ref: domRef,
86
90
  widget: widget,
@@ -4,24 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "DefaultMarkView", {
6
6
  enumerable: true,
7
- get: ()=>DefaultMarkView
7
+ get: function() {
8
+ return DefaultMarkView;
9
+ }
8
10
  });
9
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
10
- const _outputSpecJs = require("../OutputSpec.js");
11
- function _extends() {
12
- _extends = Object.assign || function(target) {
13
- for(var i = 1; i < arguments.length; i++){
14
- var source = arguments[i];
15
- for(var key in source){
16
- if (Object.prototype.hasOwnProperty.call(source, key)) {
17
- target[key] = source[key];
18
- }
19
- }
20
- }
21
- return target;
22
- };
23
- return _extends.apply(this, arguments);
24
- }
11
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
12
+ const _OutputSpec = require("../OutputSpec.js");
25
13
  function _getRequireWildcardCache(nodeInterop) {
26
14
  if (typeof WeakMap !== "function") return null;
27
15
  var cacheBabelInterop = new WeakMap();
@@ -30,7 +18,7 @@ function _getRequireWildcardCache(nodeInterop) {
30
18
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
31
19
  })(nodeInterop);
32
20
  }
33
- function _interopRequireWildcard(obj, nodeInterop) {
21
+ function _interop_require_wildcard(obj, nodeInterop) {
34
22
  if (!nodeInterop && obj && obj.__esModule) {
35
23
  return obj;
36
24
  }
@@ -43,7 +31,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
43
31
  if (cache && cache.has(obj)) {
44
32
  return cache.get(obj);
45
33
  }
46
- var newObj = {};
34
+ var newObj = {
35
+ __proto__: null
36
+ };
47
37
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
48
38
  for(var key in obj){
49
39
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -62,21 +52,19 @@ function _interopRequireWildcard(obj, nodeInterop) {
62
52
  return newObj;
63
53
  }
64
54
  const DefaultMarkView = /*#__PURE__*/ (0, _react.forwardRef)(function DefaultMarkView(param, ref) {
65
- let { markProps: { mark , inline , contentDOMRef } , children , ...props } = param;
66
- const spec = (0, _react.useMemo)(()=>{
67
- var _spec, ref;
68
- return (ref = (_spec = mark.type.spec).toDOM) === null || ref === void 0 ? void 0 : ref.call(_spec, mark, inline);
69
- }, [
55
+ let { markProps: { mark, inline, contentDOMRef }, children, ...props } = param;
56
+ const spec = (0, _react.useMemo)(()=>mark.type.spec.toDOM?.(mark, inline), [
70
57
  mark,
71
58
  inline
72
59
  ]);
73
60
  if (!spec) {
74
- throw new Error("Mark spec for ".concat(mark.type.name, " is missing toDOM"));
61
+ throw new Error(`Mark spec for ${mark.type.name} is missing toDOM`);
75
62
  }
76
- return /*#__PURE__*/ _react.default.createElement(_outputSpecJs.OutputSpec, _extends({}, props, {
63
+ return /*#__PURE__*/ _react.default.createElement(_OutputSpec.OutputSpec, {
64
+ ...props,
77
65
  outputSpec: spec,
78
66
  contentDOMRef: contentDOMRef,
79
67
  ref: ref,
80
68
  isMark: true
81
- }), children);
69
+ }, children);
82
70
  });
@@ -4,27 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "MarkView", {
6
6
  enumerable: true,
7
- get: ()=>MarkView
7
+ get: function() {
8
+ return MarkView;
9
+ }
8
10
  });
9
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
10
- const _nodeViewContextJs = require("../../contexts/NodeViewContext.js");
11
- const _defaultMarkViewJs = require("./DefaultMarkView.js");
12
- const _markViewConstructorViewJs = require("./MarkViewConstructorView.js");
13
- const _reactMarkViewJs = require("./ReactMarkView.js");
14
- function _extends() {
15
- _extends = Object.assign || function(target) {
16
- for(var i = 1; i < arguments.length; i++){
17
- var source = arguments[i];
18
- for(var key in source){
19
- if (Object.prototype.hasOwnProperty.call(source, key)) {
20
- target[key] = source[key];
21
- }
22
- }
23
- }
24
- return target;
25
- };
26
- return _extends.apply(this, arguments);
27
- }
11
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
12
+ const _NodeViewContext = require("../../contexts/NodeViewContext.js");
13
+ const _DefaultMarkView = require("./DefaultMarkView.js");
14
+ const _MarkViewConstructorView = require("./MarkViewConstructorView.js");
15
+ const _ReactMarkView = require("./ReactMarkView.js");
28
16
  function _getRequireWildcardCache(nodeInterop) {
29
17
  if (typeof WeakMap !== "function") return null;
30
18
  var cacheBabelInterop = new WeakMap();
@@ -33,7 +21,7 @@ function _getRequireWildcardCache(nodeInterop) {
33
21
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
34
22
  })(nodeInterop);
35
23
  }
36
- function _interopRequireWildcard(obj, nodeInterop) {
24
+ function _interop_require_wildcard(obj, nodeInterop) {
37
25
  if (!nodeInterop && obj && obj.__esModule) {
38
26
  return obj;
39
27
  }
@@ -46,7 +34,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
46
34
  if (cache && cache.has(obj)) {
47
35
  return cache.get(obj);
48
36
  }
49
- var newObj = {};
37
+ var newObj = {
38
+ __proto__: null
39
+ };
50
40
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
51
41
  for(var key in obj){
52
42
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -65,9 +55,8 @@ function _interopRequireWildcard(obj, nodeInterop) {
65
55
  return newObj;
66
56
  }
67
57
  const MarkView = /*#__PURE__*/ (0, _react.memo)(function MarkView(props) {
68
- const { components , constructors } = (0, _react.useContext)(_nodeViewContextJs.NodeViewContext);
69
- var _name;
70
- const component = (_name = components[props.mark.type.name]) !== null && _name !== void 0 ? _name : _defaultMarkViewJs.DefaultMarkView;
58
+ const { components, constructors } = (0, _react.useContext)(_NodeViewContext.NodeViewContext);
59
+ const component = components[props.mark.type.name] ?? _DefaultMarkView.DefaultMarkView;
71
60
  const constructor = constructors[props.mark.type.name];
72
61
  // Construct a wrapper component so that the mark view remounts when either
73
62
  // its component or constructor changes. A React mark view would remount
@@ -76,19 +65,21 @@ const MarkView = /*#__PURE__*/ (0, _react.memo)(function MarkView(props) {
76
65
  const Component = (0, _react.useMemo)(()=>{
77
66
  if (constructor) {
78
67
  return function MarkView(props) {
79
- return /*#__PURE__*/ _react.default.createElement(_markViewConstructorViewJs.MarkViewConstructorView, _extends({
80
- constructor: constructor
81
- }, props));
68
+ return /*#__PURE__*/ _react.default.createElement(_MarkViewConstructorView.MarkViewConstructorView, {
69
+ constructor: constructor,
70
+ ...props
71
+ });
82
72
  };
83
73
  }
84
74
  return function NodeView(props) {
85
- return /*#__PURE__*/ _react.default.createElement(_reactMarkViewJs.ReactMarkView, _extends({
86
- component: component
87
- }, props));
75
+ return /*#__PURE__*/ _react.default.createElement(_ReactMarkView.ReactMarkView, {
76
+ component: component,
77
+ ...props
78
+ });
88
79
  };
89
80
  }, [
90
81
  component,
91
82
  constructor
92
83
  ]);
93
- return /*#__PURE__*/ _react.default.createElement(Component, _extends({}, props));
84
+ return /*#__PURE__*/ _react.default.createElement(Component, props);
94
85
  });
@@ -4,28 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "MarkViewConstructorView", {
6
6
  enumerable: true,
7
- get: ()=>MarkViewConstructorView
7
+ get: function() {
8
+ return MarkViewConstructorView;
9
+ }
8
10
  });
9
- const _prosemirrorModel = require("prosemirror-model");
10
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
- const _reactDom = require("react-dom");
12
- const _childDescriptionsContextJs = require("../../contexts/ChildDescriptionsContext.js");
13
- const _useForceUpdateJs = require("../../hooks/useForceUpdate.js");
14
- const _useMarkViewDescriptionJs = require("../../hooks/useMarkViewDescription.js");
15
- function _extends() {
16
- _extends = Object.assign || function(target) {
17
- for(var i = 1; i < arguments.length; i++){
18
- var source = arguments[i];
19
- for(var key in source){
20
- if (Object.prototype.hasOwnProperty.call(source, key)) {
21
- target[key] = source[key];
22
- }
23
- }
24
- }
25
- return target;
26
- };
27
- return _extends.apply(this, arguments);
28
- }
11
+ const _prosemirrormodel = require("prosemirror-model");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
13
+ const _reactdom = require("react-dom");
14
+ const _ChildDescriptionsContext = require("../../contexts/ChildDescriptionsContext.js");
15
+ const _useForceUpdate = require("../../hooks/useForceUpdate.js");
16
+ const _useMarkViewDescription = require("../../hooks/useMarkViewDescription.js");
29
17
  function _getRequireWildcardCache(nodeInterop) {
30
18
  if (typeof WeakMap !== "function") return null;
31
19
  var cacheBabelInterop = new WeakMap();
@@ -34,7 +22,7 @@ function _getRequireWildcardCache(nodeInterop) {
34
22
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
35
23
  })(nodeInterop);
36
24
  }
37
- function _interopRequireWildcard(obj, nodeInterop) {
25
+ function _interop_require_wildcard(obj, nodeInterop) {
38
26
  if (!nodeInterop && obj && obj.__esModule) {
39
27
  return obj;
40
28
  }
@@ -47,7 +35,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
47
35
  if (cache && cache.has(obj)) {
48
36
  return cache.get(obj);
49
37
  }
50
- var newObj = {};
38
+ var newObj = {
39
+ __proto__: null
40
+ };
51
41
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
52
42
  for(var key in obj){
53
43
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -66,10 +56,10 @@ function _interopRequireWildcard(obj, nodeInterop) {
66
56
  return newObj;
67
57
  }
68
58
  const MarkViewConstructorView = /*#__PURE__*/ (0, _react.memo)(function MarkViewConstructorView(param) {
69
- let { constructor , mark , inline , getPos , children } = param;
59
+ let { constructor, mark, inline, getPos, children } = param;
70
60
  const ref = (0, _react.useRef)(null);
71
61
  const innerRef = (0, _react.useRef)(null);
72
- const forceUpdate = (0, _useForceUpdateJs.useForceUpdate)();
62
+ const forceUpdate = (0, _useForceUpdate.useForceUpdate)();
73
63
  const markProps = (0, _react.useMemo)(()=>({
74
64
  mark,
75
65
  inline,
@@ -88,26 +78,21 @@ const MarkViewConstructorView = /*#__PURE__*/ (0, _react.memo)(function MarkView
88
78
  }
89
79
  const markView = constructor(...args);
90
80
  if (!markView || !markView.dom) {
91
- var _spec, ref;
92
- const spec = (ref = (_spec = mark.type.spec).toDOM) === null || ref === void 0 ? void 0 : ref.call(_spec, mark, inline);
81
+ const spec = mark.type.spec.toDOM?.(mark, inline);
93
82
  if (!spec) {
94
- throw new Error("Mark spec for ".concat(mark.type.name, " is missing toDOM"));
83
+ throw new Error(`Mark spec for ${mark.type.name} is missing toDOM`);
95
84
  }
96
- return _prosemirrorModel.DOMSerializer.renderSpec(document, spec, null);
85
+ return _prosemirrormodel.DOMSerializer.renderSpec(document, spec, null);
97
86
  }
98
87
  return markView;
99
88
  };
100
- var ref1;
101
- const { childContextValue , contentDOM } = (0, _useMarkViewDescriptionJs.useMarkViewDescription)(()=>ref.current, (markView)=>{
102
- return (ref1 = markView === null || markView === void 0 ? void 0 : markView.contentDOM) !== null && ref1 !== void 0 ? ref1 : null;
103
- }, function() {
89
+ const { childContextValue, contentDOM } = (0, _useMarkViewDescription.useMarkViewDescription)(()=>ref.current, (markView)=>markView?.contentDOM ?? null, function() {
104
90
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
105
91
  args[_key] = arguments[_key];
106
92
  }
107
93
  const markView = createMarkView(...args);
108
94
  const dom = markView.dom;
109
- var _current;
110
- const wrapperDOM = (_current = innerRef.current) !== null && _current !== void 0 ? _current : ref.current;
95
+ const wrapperDOM = innerRef.current ?? ref.current;
111
96
  wrapperDOM.appendChild(dom);
112
97
  // Force a re-render so that we properly create
113
98
  // a portal into the contentDOM/dom
@@ -115,8 +100,7 @@ const MarkViewConstructorView = /*#__PURE__*/ (0, _react.memo)(function MarkView
115
100
  return {
116
101
  ...markView,
117
102
  destroy () {
118
- var ref;
119
- (ref = markView.destroy) === null || ref === void 0 ? void 0 : ref.call(markView);
103
+ markView.destroy?.();
120
104
  wrapperDOM.removeChild(dom);
121
105
  },
122
106
  ignoreMutation: markView.ignoreMutation
@@ -126,7 +110,7 @@ const MarkViewConstructorView = /*#__PURE__*/ (0, _react.memo)(function MarkView
126
110
  const props = {
127
111
  ref: innerRef
128
112
  };
129
- return /*#__PURE__*/ _react.default.createElement(Component, _extends({}, props), contentDOM ? /*#__PURE__*/ (0, _reactDom.createPortal)(/*#__PURE__*/ _react.default.createElement(_childDescriptionsContextJs.ChildDescriptionsContext.Provider, {
113
+ return /*#__PURE__*/ _react.default.createElement(Component, props, contentDOM ? /*#__PURE__*/ (0, _reactdom.createPortal)(/*#__PURE__*/ _react.default.createElement(_ChildDescriptionsContext.ChildDescriptionsContext.Provider, {
130
114
  value: childContextValue
131
115
  }, children), contentDOM) : null);
132
116
  });
@@ -4,26 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "ReactMarkView", {
6
6
  enumerable: true,
7
- get: ()=>ReactMarkView
7
+ get: function() {
8
+ return ReactMarkView;
9
+ }
8
10
  });
9
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
10
- const _childDescriptionsContextJs = require("../../contexts/ChildDescriptionsContext.js");
11
- const _ignoreMutationContextJs = require("../../contexts/IgnoreMutationContext.js");
12
- const _useMarkViewDescriptionJs = require("../../hooks/useMarkViewDescription.js");
13
- function _extends() {
14
- _extends = Object.assign || function(target) {
15
- for(var i = 1; i < arguments.length; i++){
16
- var source = arguments[i];
17
- for(var key in source){
18
- if (Object.prototype.hasOwnProperty.call(source, key)) {
19
- target[key] = source[key];
20
- }
21
- }
22
- }
23
- return target;
24
- };
25
- return _extends.apply(this, arguments);
26
- }
11
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
12
+ const _ChildDescriptionsContext = require("../../contexts/ChildDescriptionsContext.js");
13
+ const _IgnoreMutationContext = require("../../contexts/IgnoreMutationContext.js");
14
+ const _useMarkViewDescription = require("../../hooks/useMarkViewDescription.js");
27
15
  function _getRequireWildcardCache(nodeInterop) {
28
16
  if (typeof WeakMap !== "function") return null;
29
17
  var cacheBabelInterop = new WeakMap();
@@ -32,7 +20,7 @@ function _getRequireWildcardCache(nodeInterop) {
32
20
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
33
21
  })(nodeInterop);
34
22
  }
35
- function _interopRequireWildcard(obj, nodeInterop) {
23
+ function _interop_require_wildcard(obj, nodeInterop) {
36
24
  if (!nodeInterop && obj && obj.__esModule) {
37
25
  return obj;
38
26
  }
@@ -45,7 +33,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
45
33
  if (cache && cache.has(obj)) {
46
34
  return cache.get(obj);
47
35
  }
48
- var newObj = {};
36
+ var newObj = {
37
+ __proto__: null
38
+ };
49
39
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
50
40
  for(var key in obj){
51
41
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -64,7 +54,7 @@ function _interopRequireWildcard(obj, nodeInterop) {
64
54
  return newObj;
65
55
  }
66
56
  const ReactMarkView = /*#__PURE__*/ (0, _react.memo)(function ReactMarkView(param) {
67
- let { component: Component , mark , inline , getPos , children } = param;
57
+ let { component: Component, mark, inline, getPos, children } = param;
68
58
  const ref = (0, _react.useRef)(null);
69
59
  const contentDOMRef = (0, _react.useRef)(null);
70
60
  const ignoreMutationRef = (0, _react.useRef)(null);
@@ -86,8 +76,7 @@ const ReactMarkView = /*#__PURE__*/ (0, _react.memo)(function ReactMarkView(para
86
76
  inline,
87
77
  mark
88
78
  ]);
89
- var _current;
90
- const { childContextValue , refUpdated } = (0, _useMarkViewDescriptionJs.useMarkViewDescription)(()=>ref.current, ()=>(_current = contentDOMRef.current) !== null && _current !== void 0 ? _current : ref.current, ()=>({
79
+ const { childContextValue, refUpdated } = (0, _useMarkViewDescription.useMarkViewDescription)(()=>ref.current, ()=>contentDOMRef.current ?? ref.current, ()=>({
91
80
  dom: ref.current,
92
81
  ignoreMutation (mutation) {
93
82
  const ignoreMutation = ignoreMutationRef.current;
@@ -120,9 +109,9 @@ const ReactMarkView = /*#__PURE__*/ (0, _react.memo)(function ReactMarkView(para
120
109
  markProps,
121
110
  ref: setDOM
122
111
  };
123
- return /*#__PURE__*/ _react.default.createElement(_ignoreMutationContextJs.IgnoreMutationContext.Provider, {
112
+ return /*#__PURE__*/ _react.default.createElement(_IgnoreMutationContext.IgnoreMutationContext.Provider, {
124
113
  value: setIgnoreMutation
125
- }, /*#__PURE__*/ _react.default.createElement(_childDescriptionsContextJs.ChildDescriptionsContext.Provider, {
114
+ }, /*#__PURE__*/ _react.default.createElement(_ChildDescriptionsContext.ChildDescriptionsContext.Provider, {
126
115
  value: childContextValue
127
- }, /*#__PURE__*/ _react.default.createElement(Component, _extends({}, props), children)));
116
+ }, /*#__PURE__*/ _react.default.createElement(Component, props, children)));
128
117
  });