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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/ReactEditorView.js +71 -75
  3. package/dist/cjs/StaticEditorView.js +19 -22
  4. package/dist/cjs/browser.js +1 -3
  5. package/dist/cjs/commands/reorderSiblings.js +9 -13
  6. package/dist/cjs/components/ChildNodeViews.js +68 -71
  7. package/dist/cjs/components/CursorWrapper.js +26 -17
  8. package/dist/cjs/components/LayoutGroup.js +12 -16
  9. package/dist/cjs/components/NativeWidgetView.js +15 -19
  10. package/dist/cjs/components/OutputSpec.js +9 -13
  11. package/dist/cjs/components/ProseMirror.js +37 -27
  12. package/dist/cjs/components/ProseMirrorDoc.js +25 -18
  13. package/dist/cjs/components/SeparatorHackView.js +20 -21
  14. package/dist/cjs/components/TextNodeView.js +22 -20
  15. package/dist/cjs/components/TrailingHackView.js +13 -17
  16. package/dist/cjs/components/WidgetView.js +14 -18
  17. package/dist/cjs/components/marks/DefaultMarkView.js +27 -15
  18. package/dist/cjs/components/marks/MarkView.js +32 -23
  19. package/dist/cjs/components/marks/MarkViewConstructorView.js +38 -22
  20. package/dist/cjs/components/marks/ReactMarkView.js +27 -16
  21. package/dist/cjs/components/nodes/DefaultNodeView.js +27 -15
  22. package/dist/cjs/components/nodes/DocNodeView.js +12 -16
  23. package/dist/cjs/components/nodes/NodeView.js +33 -26
  24. package/dist/cjs/components/nodes/NodeViewConstructorView.js +45 -29
  25. package/dist/cjs/components/nodes/ReactNodeView.js +39 -27
  26. package/dist/cjs/constants.js +6 -10
  27. package/dist/cjs/contexts/ChildDescriptionsContext.js +1 -3
  28. package/dist/cjs/contexts/EditorContext.js +1 -3
  29. package/dist/cjs/contexts/EditorStateContext.js +1 -3
  30. package/dist/cjs/contexts/IgnoreMutationContext.js +1 -3
  31. package/dist/cjs/contexts/LayoutGroupContext.js +1 -3
  32. package/dist/cjs/contexts/NodeViewContext.js +1 -3
  33. package/dist/cjs/contexts/SelectNodeContext.js +1 -3
  34. package/dist/cjs/contexts/StopEventContext.js +1 -3
  35. package/dist/cjs/decorations/ReactWidgetType.js +13 -19
  36. package/dist/cjs/decorations/computeDocDeco.js +3 -5
  37. package/dist/cjs/decorations/iterDeco.js +17 -19
  38. package/dist/cjs/decorations/viewDecorations.js +12 -15
  39. package/dist/cjs/dom.js +13 -34
  40. package/dist/cjs/findDOMNode.js +5 -9
  41. package/dist/cjs/hooks/useClientLayoutEffect.js +1 -3
  42. package/dist/cjs/hooks/useComponentEventListeners.js +6 -7
  43. package/dist/cjs/hooks/useEditor.js +30 -28
  44. package/dist/cjs/hooks/useEditorEffect.js +7 -9
  45. package/dist/cjs/hooks/useEditorEventCallback.js +7 -9
  46. package/dist/cjs/hooks/useEditorEventListener.js +6 -8
  47. package/dist/cjs/hooks/useEditorState.js +3 -5
  48. package/dist/cjs/hooks/useEffectEvent.js +1 -3
  49. package/dist/cjs/hooks/useForceUpdate.js +1 -3
  50. package/dist/cjs/hooks/useIgnoreMutation.js +7 -9
  51. package/dist/cjs/hooks/useIsEditorStatic.js +5 -5
  52. package/dist/cjs/hooks/useIsNodeSelected.js +3 -5
  53. package/dist/cjs/hooks/useLayoutGroupEffect.js +5 -7
  54. package/dist/cjs/hooks/useMarkViewDescription.js +25 -24
  55. package/dist/cjs/hooks/useNodePos.js +5 -7
  56. package/dist/cjs/hooks/useNodeViewDescription.js +41 -28
  57. package/dist/cjs/hooks/useReactKeys.js +5 -7
  58. package/dist/cjs/hooks/useSelectNode.js +8 -10
  59. package/dist/cjs/hooks/useStopEvent.js +7 -9
  60. package/dist/cjs/index.js +34 -66
  61. package/dist/cjs/plugins/beforeInputPlugin.js +23 -20
  62. package/dist/cjs/plugins/componentEventListeners.js +6 -8
  63. package/dist/cjs/plugins/componentEventListenersPlugin.js +6 -8
  64. package/dist/cjs/plugins/reactKeys.js +10 -15
  65. package/dist/cjs/props.js +19 -23
  66. package/dist/cjs/refs.js +1 -3
  67. package/dist/cjs/testing/editorViewTestHelpers.js +47 -40
  68. package/dist/cjs/testing/setupProseMirrorView.js +4 -7
  69. package/dist/cjs/tiptap/ReactProseMirrorNodeView.js +6 -10
  70. package/dist/cjs/tiptap/TiptapEditor.js +14 -15
  71. package/dist/cjs/tiptap/TiptapEditorContent.js +28 -18
  72. package/dist/cjs/tiptap/TiptapEditorView.js +34 -23
  73. package/dist/cjs/tiptap/contexts/TiptapEditorContext.js +1 -3
  74. package/dist/cjs/tiptap/extensions/ReactProseMirror.js +6 -8
  75. package/dist/cjs/tiptap/extensions/ReactProseMirrorCommands.js +3 -5
  76. package/dist/cjs/tiptap/extensions/commands/updateAttributes.js +2 -4
  77. package/dist/cjs/tiptap/hooks/useIsInReactProseMirror.js +3 -5
  78. package/dist/cjs/tiptap/hooks/useTiptapEditor.js +14 -12
  79. package/dist/cjs/tiptap/hooks/useTiptapEditorEffect.js +10 -12
  80. package/dist/cjs/tiptap/hooks/useTiptapEditorEventCallback.js +4 -6
  81. package/dist/cjs/tiptap/index.js +18 -36
  82. package/dist/cjs/tiptap/tiptapNodeView.js +62 -48
  83. package/dist/cjs/viewdesc.js +95 -119
  84. package/dist/esm/ReactEditorView.js +67 -69
  85. package/dist/esm/StaticEditorView.js +18 -19
  86. package/dist/esm/commands/reorderSiblings.js +5 -5
  87. package/dist/esm/components/ChildNodeViews.js +36 -33
  88. package/dist/esm/components/CursorWrapper.js +18 -5
  89. package/dist/esm/components/LayoutGroup.js +1 -1
  90. package/dist/esm/components/NativeWidgetView.js +2 -2
  91. package/dist/esm/components/OutputSpec.js +1 -1
  92. package/dist/esm/components/ProseMirror.js +17 -3
  93. package/dist/esm/components/ProseMirrorDoc.js +19 -6
  94. package/dist/esm/components/SeparatorHackView.js +8 -5
  95. package/dist/esm/components/TextNodeView.js +10 -6
  96. package/dist/esm/components/TrailingHackView.js +2 -2
  97. package/dist/esm/components/WidgetView.js +3 -3
  98. package/dist/esm/components/marks/DefaultMarkView.js +22 -6
  99. package/dist/esm/components/marks/MarkView.js +24 -11
  100. package/dist/esm/components/marks/MarkViewConstructorView.js +27 -7
  101. package/dist/esm/components/marks/ReactMarkView.js +18 -3
  102. package/dist/esm/components/nodes/DefaultNodeView.js +22 -6
  103. package/dist/esm/components/nodes/DocNodeView.js +2 -2
  104. package/dist/esm/components/nodes/NodeView.js +24 -11
  105. package/dist/esm/components/nodes/NodeViewConstructorView.js +31 -11
  106. package/dist/esm/components/nodes/ReactNodeView.js +22 -6
  107. package/dist/esm/decorations/ReactWidgetType.js +8 -10
  108. package/dist/esm/decorations/iterDeco.js +13 -13
  109. package/dist/esm/decorations/viewDecorations.js +6 -7
  110. package/dist/esm/dom.js +2 -1
  111. package/dist/esm/findDOMNode.js +1 -1
  112. package/dist/esm/hooks/useComponentEventListeners.js +3 -2
  113. package/dist/esm/hooks/useEditor.js +9 -5
  114. package/dist/esm/hooks/useEditorEffect.js +1 -1
  115. package/dist/esm/hooks/useEditorEventCallback.js +1 -1
  116. package/dist/esm/hooks/useEditorEventListener.js +1 -1
  117. package/dist/esm/hooks/useIsEditorStatic.js +3 -1
  118. package/dist/esm/hooks/useMarkViewDescription.js +10 -7
  119. package/dist/esm/hooks/useNodeViewDescription.js +22 -7
  120. package/dist/esm/hooks/useReactKeys.js +1 -1
  121. package/dist/esm/plugins/beforeInputPlugin.js +17 -12
  122. package/dist/esm/plugins/reactKeys.js +4 -3
  123. package/dist/esm/props.js +15 -15
  124. package/dist/esm/testing/editorViewTestHelpers.js +31 -20
  125. package/dist/esm/testing/setupProseMirrorView.js +2 -1
  126. package/dist/esm/tiptap/ReactProseMirrorNodeView.js +5 -7
  127. package/dist/esm/tiptap/TiptapEditor.js +10 -9
  128. package/dist/esm/tiptap/TiptapEditorContent.js +18 -4
  129. package/dist/esm/tiptap/TiptapEditorView.js +23 -8
  130. package/dist/esm/tiptap/extensions/ReactProseMirror.js +1 -1
  131. package/dist/esm/tiptap/extensions/commands/updateAttributes.js +1 -1
  132. package/dist/esm/tiptap/hooks/useTiptapEditor.js +8 -4
  133. package/dist/esm/tiptap/hooks/useTiptapEditorEffect.js +4 -4
  134. package/dist/esm/tiptap/hooks/useTiptapEditorEventCallback.js +1 -1
  135. package/dist/esm/tiptap/tiptapNodeView.js +38 -20
  136. package/dist/esm/viewdesc.js +72 -74
  137. package/dist/tsconfig.tsbuildinfo +1 -1
  138. package/dist/types/ReactEditorView.d.ts +2 -2
  139. package/dist/types/StaticEditorView.d.ts +2 -1
  140. package/dist/types/props.d.ts +26 -26
  141. package/dist/types/viewdesc.d.ts +2 -0
  142. package/package.json +10 -6
@@ -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(()=>{
@@ -3,8 +3,8 @@ import { ChildDescriptionsContext } from "../contexts/ChildDescriptionsContext.j
3
3
  import { useClientLayoutEffect } from "../hooks/useClientLayoutEffect.js";
4
4
  import { WidgetViewDesc, sortViewDescs } from "../viewdesc.js";
5
5
  export function WidgetView(param) {
6
- let { widget, getPos } = param;
7
- const { siblingsRef, parentRef } = useContext(ChildDescriptionsContext);
6
+ let { widget , getPos } = param;
7
+ const { siblingsRef , parentRef } = useContext(ChildDescriptionsContext);
8
8
  const viewDescRef = useRef(null);
9
9
  const domRef = useRef(null);
10
10
  useClientLayoutEffect(()=>{
@@ -33,7 +33,7 @@ export function WidgetView(param) {
33
33
  }
34
34
  siblingsRef.current.sort(sortViewDescs);
35
35
  });
36
- const { Component } = widget.type;
36
+ const { Component } = widget.type;
37
37
  return Component && /*#__PURE__*/ React.createElement(Component, {
38
38
  ref: domRef,
39
39
  widget: widget,
@@ -1,19 +1,35 @@
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, useMemo } from "react";
2
16
  import { OutputSpec } from "../OutputSpec.js";
3
17
  export const DefaultMarkView = /*#__PURE__*/ forwardRef(function DefaultMarkView(param, ref) {
4
- let { markProps: { mark, inline, contentDOMRef }, children, ...props } = param;
5
- const spec = useMemo(()=>mark.type.spec.toDOM?.(mark, inline), [
18
+ let { markProps: { mark , inline , contentDOMRef } , children , ...props } = param;
19
+ const spec = useMemo(()=>{
20
+ var _spec, ref;
21
+ return (ref = (_spec = mark.type.spec).toDOM) === null || ref === void 0 ? void 0 : ref.call(_spec, mark, inline);
22
+ }, [
6
23
  mark,
7
24
  inline
8
25
  ]);
9
26
  if (!spec) {
10
- throw new Error(`Mark spec for ${mark.type.name} is missing toDOM`);
27
+ throw new Error("Mark spec for ".concat(mark.type.name, " is missing toDOM"));
11
28
  }
12
- return /*#__PURE__*/ React.createElement(OutputSpec, {
13
- ...props,
29
+ return /*#__PURE__*/ React.createElement(OutputSpec, _extends({}, props, {
14
30
  outputSpec: spec,
15
31
  contentDOMRef: contentDOMRef,
16
32
  ref: ref,
17
33
  isMark: true
18
- }, children);
34
+ }), children);
19
35
  });
@@ -1,11 +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, { memo, useContext, useMemo } from "react";
2
16
  import { NodeViewContext } from "../../contexts/NodeViewContext.js";
3
17
  import { DefaultMarkView } from "./DefaultMarkView.js";
4
18
  import { MarkViewConstructorView } from "./MarkViewConstructorView.js";
5
19
  import { ReactMarkView } from "./ReactMarkView.js";
6
20
  export const MarkView = /*#__PURE__*/ memo(function MarkView(props) {
7
- const { components, constructors } = useContext(NodeViewContext);
8
- const component = components[props.mark.type.name] ?? DefaultMarkView;
21
+ const { components , constructors } = useContext(NodeViewContext);
22
+ var _name;
23
+ const component = (_name = components[props.mark.type.name]) !== null && _name !== void 0 ? _name : DefaultMarkView;
9
24
  const constructor = constructors[props.mark.type.name];
10
25
  // Construct a wrapper component so that the mark view remounts when either
11
26
  // its component or constructor changes. A React mark view would remount
@@ -14,21 +29,19 @@ export const MarkView = /*#__PURE__*/ memo(function MarkView(props) {
14
29
  const Component = useMemo(()=>{
15
30
  if (constructor) {
16
31
  return function MarkView(props) {
17
- return /*#__PURE__*/ React.createElement(MarkViewConstructorView, {
18
- constructor: constructor,
19
- ...props
20
- });
32
+ return /*#__PURE__*/ React.createElement(MarkViewConstructorView, _extends({
33
+ constructor: constructor
34
+ }, props));
21
35
  };
22
36
  }
23
37
  return function NodeView(props) {
24
- return /*#__PURE__*/ React.createElement(ReactMarkView, {
25
- component: component,
26
- ...props
27
- });
38
+ return /*#__PURE__*/ React.createElement(ReactMarkView, _extends({
39
+ component: component
40
+ }, props));
28
41
  };
29
42
  }, [
30
43
  component,
31
44
  constructor
32
45
  ]);
33
- return /*#__PURE__*/ React.createElement(Component, props);
46
+ return /*#__PURE__*/ React.createElement(Component, _extends({}, props));
34
47
  });
@@ -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 { DOMSerializer } from "prosemirror-model";
2
16
  import React, { memo, useMemo, useRef } from "react";
3
17
  import { createPortal } from "react-dom";
@@ -5,7 +19,7 @@ import { ChildDescriptionsContext } from "../../contexts/ChildDescriptionsContex
5
19
  import { useForceUpdate } from "../../hooks/useForceUpdate.js";
6
20
  import { useMarkViewDescription } from "../../hooks/useMarkViewDescription.js";
7
21
  export const MarkViewConstructorView = /*#__PURE__*/ memo(function MarkViewConstructorView(param) {
8
- let { constructor, mark, inline, getPos, children } = param;
22
+ let { constructor , mark , inline , getPos , children } = param;
9
23
  const ref = useRef(null);
10
24
  const innerRef = useRef(null);
11
25
  const forceUpdate = useForceUpdate();
@@ -27,21 +41,26 @@ export const MarkViewConstructorView = /*#__PURE__*/ memo(function MarkViewConst
27
41
  }
28
42
  const markView = constructor(...args);
29
43
  if (!markView || !markView.dom) {
30
- const spec = mark.type.spec.toDOM?.(mark, inline);
44
+ var _spec, ref;
45
+ const spec = (ref = (_spec = mark.type.spec).toDOM) === null || ref === void 0 ? void 0 : ref.call(_spec, mark, inline);
31
46
  if (!spec) {
32
- throw new Error(`Mark spec for ${mark.type.name} is missing toDOM`);
47
+ throw new Error("Mark spec for ".concat(mark.type.name, " is missing toDOM"));
33
48
  }
34
49
  return DOMSerializer.renderSpec(document, spec, null);
35
50
  }
36
51
  return markView;
37
52
  };
38
- const { childContextValue, contentDOM } = useMarkViewDescription(()=>ref.current, (markView)=>markView?.contentDOM ?? null, function() {
53
+ var ref1;
54
+ const { childContextValue , contentDOM } = useMarkViewDescription(()=>ref.current, (markView)=>{
55
+ return (ref1 = markView === null || markView === void 0 ? void 0 : markView.contentDOM) !== null && ref1 !== void 0 ? ref1 : null;
56
+ }, function() {
39
57
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
40
58
  args[_key] = arguments[_key];
41
59
  }
42
60
  const markView = createMarkView(...args);
43
61
  const dom = markView.dom;
44
- const wrapperDOM = innerRef.current ?? ref.current;
62
+ var _current;
63
+ const wrapperDOM = (_current = innerRef.current) !== null && _current !== void 0 ? _current : ref.current;
45
64
  wrapperDOM.appendChild(dom);
46
65
  // Force a re-render so that we properly create
47
66
  // a portal into the contentDOM/dom
@@ -49,7 +68,8 @@ export const MarkViewConstructorView = /*#__PURE__*/ memo(function MarkViewConst
49
68
  return {
50
69
  ...markView,
51
70
  destroy () {
52
- markView.destroy?.();
71
+ var ref;
72
+ (ref = markView.destroy) === null || ref === void 0 ? void 0 : ref.call(markView);
53
73
  wrapperDOM.removeChild(dom);
54
74
  },
55
75
  ignoreMutation: markView.ignoreMutation
@@ -59,7 +79,7 @@ export const MarkViewConstructorView = /*#__PURE__*/ memo(function MarkViewConst
59
79
  const props = {
60
80
  ref: innerRef
61
81
  };
62
- return /*#__PURE__*/ React.createElement(Component, props, contentDOM ? /*#__PURE__*/ createPortal(/*#__PURE__*/ React.createElement(ChildDescriptionsContext.Provider, {
82
+ return /*#__PURE__*/ React.createElement(Component, _extends({}, props), contentDOM ? /*#__PURE__*/ createPortal(/*#__PURE__*/ React.createElement(ChildDescriptionsContext.Provider, {
63
83
  value: childContextValue
64
84
  }, children), contentDOM) : null);
65
85
  });
@@ -1,9 +1,23 @@
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, { memo, useCallback, useMemo, useRef } from "react";
2
16
  import { ChildDescriptionsContext } from "../../contexts/ChildDescriptionsContext.js";
3
17
  import { IgnoreMutationContext } from "../../contexts/IgnoreMutationContext.js";
4
18
  import { useMarkViewDescription } from "../../hooks/useMarkViewDescription.js";
5
19
  export const ReactMarkView = /*#__PURE__*/ memo(function ReactMarkView(param) {
6
- let { component: Component, mark, inline, getPos, children } = param;
20
+ let { component: Component , mark , inline , getPos , children } = param;
7
21
  const ref = useRef(null);
8
22
  const contentDOMRef = useRef(null);
9
23
  const ignoreMutationRef = useRef(null);
@@ -25,7 +39,8 @@ export const ReactMarkView = /*#__PURE__*/ memo(function ReactMarkView(param) {
25
39
  inline,
26
40
  mark
27
41
  ]);
28
- const { childContextValue, refUpdated } = useMarkViewDescription(()=>ref.current, ()=>contentDOMRef.current ?? ref.current, ()=>({
42
+ var _current;
43
+ const { childContextValue , refUpdated } = useMarkViewDescription(()=>ref.current, ()=>(_current = contentDOMRef.current) !== null && _current !== void 0 ? _current : ref.current, ()=>({
29
44
  dom: ref.current,
30
45
  ignoreMutation (mutation) {
31
46
  const ignoreMutation = ignoreMutationRef.current;
@@ -62,5 +77,5 @@ export const ReactMarkView = /*#__PURE__*/ memo(function ReactMarkView(param) {
62
77
  value: setIgnoreMutation
63
78
  }, /*#__PURE__*/ React.createElement(ChildDescriptionsContext.Provider, {
64
79
  value: childContextValue
65
- }, /*#__PURE__*/ React.createElement(Component, props, children)));
80
+ }, /*#__PURE__*/ React.createElement(Component, _extends({}, props), children)));
66
81
  });
@@ -1,17 +1,33 @@
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, useMemo } from "react";
2
16
  import { OutputSpec } from "../OutputSpec.js";
3
17
  export const DefaultNodeView = /*#__PURE__*/ forwardRef(function DefaultNodeView(param, ref) {
4
- let { nodeProps: { node, contentDOMRef }, children, ...props } = param;
5
- const spec = useMemo(()=>node.type.spec.toDOM?.(node), [
18
+ let { nodeProps: { node , contentDOMRef } , children , ...props } = param;
19
+ const spec = useMemo(()=>{
20
+ var _spec, ref;
21
+ return (ref = (_spec = node.type.spec).toDOM) === null || ref === void 0 ? void 0 : ref.call(_spec, node);
22
+ }, [
6
23
  node
7
24
  ]);
8
25
  if (!spec) {
9
- throw new Error(`Node spec for ${node.type.name} is missing toDOM`);
26
+ throw new Error("Node spec for ".concat(node.type.name, " is missing toDOM"));
10
27
  }
11
- return /*#__PURE__*/ React.createElement(OutputSpec, {
12
- ...props,
28
+ return /*#__PURE__*/ React.createElement(OutputSpec, _extends({}, props, {
13
29
  outputSpec: spec,
14
30
  ref: ref,
15
31
  contentDOMRef: contentDOMRef
16
- }, children);
32
+ }), children);
17
33
  });
@@ -3,7 +3,7 @@ import { ChildDescriptionsContext } from "../../contexts/ChildDescriptionsContex
3
3
  import { useNodeViewDescription } from "../../hooks/useNodeViewDescription.js";
4
4
  import { ChildNodeViews, wrapInDeco } from "../ChildNodeViews.js";
5
5
  export const DocNodeView = /*#__PURE__*/ memo(/*#__PURE__*/ forwardRef(function DocNodeView(param, ref) {
6
- let { as, node, getPos, decorations, innerDecorations, setMount, ...elementProps } = param;
6
+ let { as , node , getPos , decorations , innerDecorations , setMount , ...elementProps } = param;
7
7
  const innerRef = useRef(null);
8
8
  useImperativeHandle(ref, ()=>innerRef.current);
9
9
  useImperativeHandle(setMount, ()=>innerRef.current);
@@ -19,7 +19,7 @@ export const DocNodeView = /*#__PURE__*/ memo(/*#__PURE__*/ forwardRef(function
19
19
  decorations,
20
20
  innerDecorations
21
21
  ]);
22
- const { childContextValue } = useNodeViewDescription(()=>innerRef.current, ()=>innerRef.current, ()=>{
22
+ const { childContextValue } = useNodeViewDescription(()=>innerRef.current, ()=>innerRef.current, ()=>{
23
23
  const dom = innerRef.current;
24
24
  return {
25
25
  dom,
@@ -1,11 +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, memo, useContext, useMemo } from "react";
2
16
  import { NodeViewContext } from "../../contexts/NodeViewContext.js";
3
17
  import { DefaultNodeView } from "./DefaultNodeView.js";
4
18
  import { NodeViewConstructorView } from "./NodeViewConstructorView.js";
5
19
  import { ReactNodeView } from "./ReactNodeView.js";
6
20
  export const NodeView = /*#__PURE__*/ memo(function NodeView(props) {
7
- const { components, constructors } = useContext(NodeViewContext);
8
- const component = components[props.node.type.name] ?? DefaultNodeView;
21
+ const { components , constructors } = useContext(NodeViewContext);
22
+ var _name;
23
+ const component = (_name = components[props.node.type.name]) !== null && _name !== void 0 ? _name : DefaultNodeView;
9
24
  const constructor = constructors[props.node.type.name];
10
25
  // Construct a wrapper component so that the node view remounts when either
11
26
  // its component or constructor changes. A React node view would remount if
@@ -14,17 +29,15 @@ export const NodeView = /*#__PURE__*/ memo(function NodeView(props) {
14
29
  const Component = useMemo(()=>{
15
30
  if (constructor) {
16
31
  return function NodeView(props) {
17
- return /*#__PURE__*/ React.createElement(NodeViewConstructorView, {
18
- constructor: constructor,
19
- ...props
20
- });
32
+ return /*#__PURE__*/ React.createElement(NodeViewConstructorView, _extends({
33
+ constructor: constructor
34
+ }, props));
21
35
  };
22
36
  } else {
23
37
  return function NodeView(props) {
24
- return /*#__PURE__*/ React.createElement(ReactNodeView, {
25
- component: component,
26
- ...props
27
- });
38
+ return /*#__PURE__*/ React.createElement(ReactNodeView, _extends({
39
+ component: component
40
+ }, props));
28
41
  };
29
42
  }
30
43
  }, [
@@ -33,6 +46,6 @@ export const NodeView = /*#__PURE__*/ memo(function NodeView(props) {
33
46
  ]);
34
47
  return /*#__PURE__*/ React.createElement(GetPosContext.Provider, {
35
48
  value: props.getPos
36
- }, /*#__PURE__*/ React.createElement(Component, props));
49
+ }, /*#__PURE__*/ React.createElement(Component, _extends({}, props)));
37
50
  });
38
51
  export const GetPosContext = /*#__PURE__*/ createContext(null);
@@ -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 { DOMSerializer } from "prosemirror-model";
2
16
  import React, { cloneElement, memo, useMemo, useRef } from "react";
3
17
  import { createPortal } from "react-dom";
@@ -6,7 +20,7 @@ import { useForceUpdate } from "../../hooks/useForceUpdate.js";
6
20
  import { useNodeViewDescription } from "../../hooks/useNodeViewDescription.js";
7
21
  import { ChildNodeViews, wrapInDeco } from "../ChildNodeViews.js";
8
22
  export const NodeViewConstructorView = /*#__PURE__*/ memo(function NodeViewConstructorView(param) {
9
- let { constructor, node, getPos, innerDeco, outerDeco } = param;
23
+ let { constructor , node , getPos , innerDeco , outerDeco } = param;
10
24
  const ref = useRef(null);
11
25
  const innerRef = useRef(null);
12
26
  const forceUpdate = useForceUpdate();
@@ -30,22 +44,28 @@ export const NodeViewConstructorView = /*#__PURE__*/ memo(function NodeViewConst
30
44
  }
31
45
  const nodeView = constructor(...args);
32
46
  if (!nodeView || !nodeView.dom) {
33
- const spec = node.type.spec.toDOM?.(node);
47
+ var _spec, ref;
48
+ const spec = (ref = (_spec = node.type.spec).toDOM) === null || ref === void 0 ? void 0 : ref.call(_spec, node);
34
49
  if (!spec) {
35
- throw new Error(`Node spec for ${node.type.name} is missing toDOM`);
50
+ throw new Error("Node spec for ".concat(node.type.name, " is missing toDOM"));
36
51
  }
37
52
  return DOMSerializer.renderSpec(document, spec, null);
38
53
  }
39
54
  return nodeView;
40
55
  };
41
- const { childContextValue, contentDOM } = useNodeViewDescription(()=>ref.current, (source)=>source?.contentDOM ?? null, function() {
56
+ var ref1;
57
+ const { childContextValue , contentDOM } = useNodeViewDescription(()=>ref.current, (source)=>{
58
+ return (ref1 = source === null || source === void 0 ? void 0 : source.contentDOM) !== null && ref1 !== void 0 ? ref1 : null;
59
+ }, function() {
42
60
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
43
61
  args[_key] = arguments[_key];
44
62
  }
63
+ var ref1, ref2, ref3, ref4, ref5;
45
64
  const nodeView = createNodeView(...args);
46
65
  const contentDOM = nodeView.contentDOM;
47
66
  const nodeDOM = nodeView.dom;
48
- const wrapperDOM = innerRef.current ?? ref.current;
67
+ var _current;
68
+ const wrapperDOM = (_current = innerRef.current) !== null && _current !== void 0 ? _current : ref.current;
49
69
  wrapperDOM.appendChild(nodeDOM);
50
70
  if (!contentDOM && nodeDOM instanceof HTMLElement && nodeDOM.tagName !== "BR") {
51
71
  if (!nodeDOM.hasAttribute("contenteditable")) {
@@ -70,11 +90,11 @@ export const NodeViewConstructorView = /*#__PURE__*/ memo(function NodeViewConst
70
90
  dom: nodeView.dom,
71
91
  contentDOM: nodeView.contentDOM,
72
92
  multiType: nodeView.multiType,
73
- update: nodeView.update?.bind(nodeView),
74
- selectNode: nodeView.selectNode?.bind(nodeView),
75
- deselectNode: nodeView.deselectNode?.bind(nodeView),
76
- stopEvent: nodeView.stopEvent?.bind(nodeView),
77
- ignoreMutation: nodeView.ignoreMutation?.bind(nodeView)
93
+ update: (ref1 = nodeView.update) === null || ref1 === void 0 ? void 0 : ref1.bind(nodeView),
94
+ selectNode: (ref2 = nodeView.selectNode) === null || ref2 === void 0 ? void 0 : ref2.bind(nodeView),
95
+ deselectNode: (ref3 = nodeView.deselectNode) === null || ref3 === void 0 ? void 0 : ref3.bind(nodeView),
96
+ stopEvent: (ref4 = nodeView.stopEvent) === null || ref4 === void 0 ? void 0 : ref4.bind(nodeView),
97
+ ignoreMutation: (ref5 = nodeView.ignoreMutation) === null || ref5 === void 0 ? void 0 : ref5.bind(nodeView)
78
98
  };
79
99
  }, nodeProps);
80
100
  const Component = node.isInline ? "span" : "div";
@@ -88,7 +108,7 @@ export const NodeViewConstructorView = /*#__PURE__*/ memo(function NodeViewConst
88
108
  node: node,
89
109
  innerDecorations: innerDeco
90
110
  })), contentDOM) : null;
91
- return /*#__PURE__*/ cloneElement(outerDeco.reduce(wrapInDeco, /*#__PURE__*/ React.createElement(Component, props, children)), {
111
+ return /*#__PURE__*/ cloneElement(outerDeco.reduce(wrapInDeco, /*#__PURE__*/ React.createElement(Component, _extends({}, props), children)), {
92
112
  ref
93
113
  });
94
114
  });
@@ -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, { cloneElement, memo, useCallback, useMemo, useRef, useState } from "react";
2
16
  import { ChildDescriptionsContext } from "../../contexts/ChildDescriptionsContext.js";
3
17
  import { IgnoreMutationContext } from "../../contexts/IgnoreMutationContext.js";
@@ -7,7 +21,8 @@ import { useForceUpdate } from "../../hooks/useForceUpdate.js";
7
21
  import { useNodeViewDescription } from "../../hooks/useNodeViewDescription.js";
8
22
  import { ChildNodeViews, wrapInDeco } from "../ChildNodeViews.js";
9
23
  export const ReactNodeView = /*#__PURE__*/ memo(function ReactNodeView(param) {
10
- let { component: Component, outerDeco, getPos, node, innerDeco } = param;
24
+ let { component: Component , outerDeco , getPos , node , innerDeco } = param;
25
+ var ref, ref1;
11
26
  const [hasCustomSelectNode, setHasCustomSelectNode] = useState(false);
12
27
  const [selected, setSelected] = useState(false);
13
28
  const forceUpdate = useForceUpdate();
@@ -54,10 +69,11 @@ export const ReactNodeView = /*#__PURE__*/ memo(function ReactNodeView(param) {
54
69
  node,
55
70
  outerDeco
56
71
  ]);
57
- const { childContextValue, refUpdated } = useNodeViewDescription(()=>domRef.current, ()=>contentDOMRef.current, ()=>{
72
+ const { childContextValue , refUpdated } = useNodeViewDescription(()=>domRef.current, ()=>contentDOMRef.current, ()=>{
58
73
  setSelected(false);
74
+ var _current;
59
75
  return {
60
- dom: nodeDOMRef.current ?? domRef.current,
76
+ dom: (_current = nodeDOMRef.current) !== null && _current !== void 0 ? _current : domRef.current,
61
77
  update () {
62
78
  return true;
63
79
  },
@@ -133,14 +149,14 @@ export const ReactNodeView = /*#__PURE__*/ memo(function ReactNodeView(param) {
133
149
  ]);
134
150
  const props = {
135
151
  nodeProps,
136
- ...!contentDOMRef.current && !nodeProps.node.isText && nodeDOMRef.current?.nodeName !== "BR" ? {
152
+ ...!contentDOMRef.current && !nodeProps.node.isText && ((ref = nodeDOMRef.current) === null || ref === void 0 ? void 0 : ref.nodeName) !== "BR" ? {
137
153
  contentEditable: false,
138
154
  suppressContentEditableWarning: true
139
155
  } : null,
140
156
  ...!hasCustomSelectNode && selected ? {
141
157
  className: "ProseMirror-selectednode"
142
158
  } : null,
143
- ...!hasCustomSelectNode && selected || !contentDOMRef.current && !nodeProps.node.isText && domRef.current?.nodeName !== "BR" && node.type.spec.draggable ? {
159
+ ...!hasCustomSelectNode && selected || !contentDOMRef.current && !nodeProps.node.isText && ((ref1 = domRef.current) === null || ref1 === void 0 ? void 0 : ref1.nodeName) !== "BR" && node.type.spec.draggable ? {
144
160
  draggable: true
145
161
  } : null,
146
162
  ref: setNodeDOM
@@ -150,7 +166,7 @@ export const ReactNodeView = /*#__PURE__*/ memo(function ReactNodeView(param) {
150
166
  node: node,
151
167
  innerDecorations: innerDeco
152
168
  }) : null;
153
- const element = /*#__PURE__*/ cloneElement(outerDeco.reduce(wrapInDeco, /*#__PURE__*/ React.createElement(Component, props, children)), {
169
+ const element = /*#__PURE__*/ cloneElement(outerDeco.reduce(wrapInDeco, /*#__PURE__*/ React.createElement(Component, _extends({}, props), children)), {
154
170
  ref: setDOM
155
171
  });
156
172
  return /*#__PURE__*/ React.createElement(SelectNodeContext.Provider, {
@@ -2,23 +2,15 @@ import { Decoration } from "prosemirror-view";
2
2
  function compareObjs(a, b) {
3
3
  if (a == b) return true;
4
4
  for(const p in a)if (a[p] !== b[p]) return false;
5
- for(const p in b)if (!(p in a)) return false;
5
+ for(const p1 in b)if (!(p1 in a)) return false;
6
6
  return true;
7
7
  }
8
8
  const noSpec = {
9
9
  side: 0
10
10
  };
11
11
  export class ReactWidgetType {
12
- Component;
13
- side;
14
- spec;
15
- constructor(Component, spec){
16
- this.Component = Component;
17
- this.spec = spec ?? noSpec;
18
- this.side = this.spec.side ?? 0;
19
- }
20
12
  map(mapping, span, offset, oldOffset) {
21
- const { pos, deleted } = mapping.mapResult(span.from + oldOffset, this.side < 0 ? -1 : 1);
13
+ const { pos , deleted } = mapping.mapResult(span.from + oldOffset, this.side < 0 ? -1 : 1);
22
14
  // @ts-expect-error The Decoration constructor is private/internal, but
23
15
  // we need to use it for our custom widget implementation here.
24
16
  return deleted ? null : new Decoration(pos - offset, pos - offset, this);
@@ -32,6 +24,12 @@ export class ReactWidgetType {
32
24
  destroy() {
33
25
  // Can be implemented with React effect hooks
34
26
  }
27
+ constructor(Component, spec){
28
+ this.Component = Component;
29
+ this.spec = spec !== null && spec !== void 0 ? spec : noSpec;
30
+ var _side;
31
+ this.side = (_side = this.spec.side) !== null && _side !== void 0 ? _side : 0;
32
+ }
35
33
  }
36
34
  export function widget(pos, component, spec) {
37
35
  // @ts-expect-error The Decoration constructor is private/internal, but