@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
@@ -4,15 +4,27 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "TiptapEditorContent", {
6
6
  enumerable: true,
7
- get: function() {
8
- return TiptapEditorContent;
9
- }
7
+ get: ()=>TiptapEditorContent
10
8
  });
11
- const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
12
- const _reactdom = require("react-dom");
13
- const _ProseMirrorDoc = require("../components/ProseMirrorDoc.js");
14
- const _useEditorEffect = require("../hooks/useEditorEffect.js");
15
- const _TiptapEditorContext = require("./contexts/TiptapEditorContext.js");
9
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
10
+ const _reactDom = require("react-dom");
11
+ const _proseMirrorDocJs = require("../components/ProseMirrorDoc.js");
12
+ const _useEditorEffectJs = require("../hooks/useEditorEffect.js");
13
+ const _tiptapEditorContextJs = require("./contexts/TiptapEditorContext.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
+ }
16
28
  function _getRequireWildcardCache(nodeInterop) {
17
29
  if (typeof WeakMap !== "function") return null;
18
30
  var cacheBabelInterop = new WeakMap();
@@ -21,7 +33,7 @@ function _getRequireWildcardCache(nodeInterop) {
21
33
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
22
34
  })(nodeInterop);
23
35
  }
24
- function _interop_require_wildcard(obj, nodeInterop) {
36
+ function _interopRequireWildcard(obj, nodeInterop) {
25
37
  if (!nodeInterop && obj && obj.__esModule) {
26
38
  return obj;
27
39
  }
@@ -34,9 +46,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
34
46
  if (cache && cache.has(obj)) {
35
47
  return cache.get(obj);
36
48
  }
37
- var newObj = {
38
- __proto__: null
39
- };
49
+ var newObj = {};
40
50
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
41
51
  for(var key in obj){
42
52
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -57,7 +67,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
57
67
  /**
58
68
  * This component renders all of the editor's registered "React renderers".
59
69
  */ const Portals = (param)=>{
60
- let { contentComponent } = param;
70
+ let { contentComponent } = param;
61
71
  const renderers = (0, _react.useSyncExternalStore)(contentComponent.subscribe, contentComponent.getSnapshot, contentComponent.getServerSnapshot);
62
72
  return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, Object.values(renderers));
63
73
  };
@@ -84,7 +94,7 @@ function getInstance() {
84
94
  */ setRenderer (id, renderer) {
85
95
  renderers = {
86
96
  ...renderers,
87
- [id]: /*#__PURE__*/ (0, _reactdom.createPortal)(renderer.reactElement, renderer.element, id)
97
+ [id]: /*#__PURE__*/ (0, _reactDom.createPortal)(renderer.reactElement, renderer.element, id)
88
98
  };
89
99
  subscribers.forEach((subscriber)=>subscriber());
90
100
  },
@@ -101,10 +111,10 @@ function getInstance() {
101
111
  };
102
112
  }
103
113
  function TiptapEditorContent(param) {
104
- let { editor: editorProp, ...props } = param;
114
+ let { editor: editorProp , ...props } = param;
105
115
  const editor = editorProp;
106
- const { onEditorInitialize, onEditorDeinitialize } = (0, _react.useContext)(_TiptapEditorContext.TiptapEditorContext);
107
- (0, _useEditorEffect.useEditorEffect)((view)=>{
116
+ const { onEditorInitialize , onEditorDeinitialize } = (0, _react.useContext)(_tiptapEditorContextJs.TiptapEditorContext);
117
+ (0, _useEditorEffectJs.useEditorEffect)((view)=>{
108
118
  if (editor.view === view) {
109
119
  return;
110
120
  }
@@ -137,7 +147,7 @@ function TiptapEditorContent(param) {
137
147
  onEditorDeinitialize,
138
148
  onEditorInitialize
139
149
  ]);
140
- return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/ _react.default.createElement(_ProseMirrorDoc.ProseMirrorDoc, props), editor?.contentComponent && /*#__PURE__*/ _react.default.createElement(Portals, {
150
+ return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/ _react.default.createElement(_proseMirrorDocJs.ProseMirrorDoc, _extends({}, props)), (editor === null || editor === void 0 ? void 0 : editor.contentComponent) && /*#__PURE__*/ _react.default.createElement(Portals, {
141
151
  contentComponent: editor.contentComponent
142
152
  }));
143
153
  }
@@ -4,17 +4,29 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "TiptapEditorView", {
6
6
  enumerable: true,
7
- get: function() {
8
- return TiptapEditorView;
9
- }
7
+ get: ()=>TiptapEditorView
10
8
  });
11
9
  const _react = require("@tiptap/react");
12
- const _classnames = /*#__PURE__*/ _interop_require_default(require("classnames"));
13
- const _react1 = /*#__PURE__*/ _interop_require_wildcard(require("react"));
14
- const _ProseMirror = require("../components/ProseMirror.js");
15
- const _useForceUpdate = require("../hooks/useForceUpdate.js");
16
- const _TiptapEditorContext = require("./contexts/TiptapEditorContext.js");
17
- function _interop_require_default(obj) {
10
+ const _classnames = /*#__PURE__*/ _interopRequireDefault(require("classnames"));
11
+ const _react1 = /*#__PURE__*/ _interopRequireWildcard(require("react"));
12
+ const _proseMirrorJs = require("../components/ProseMirror.js");
13
+ const _useForceUpdateJs = require("../hooks/useForceUpdate.js");
14
+ const _tiptapEditorContextJs = require("./contexts/TiptapEditorContext.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
+ }
29
+ function _interopRequireDefault(obj) {
18
30
  return obj && obj.__esModule ? obj : {
19
31
  default: obj
20
32
  };
@@ -27,7 +39,7 @@ function _getRequireWildcardCache(nodeInterop) {
27
39
  return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
28
40
  })(nodeInterop);
29
41
  }
30
- function _interop_require_wildcard(obj, nodeInterop) {
42
+ function _interopRequireWildcard(obj, nodeInterop) {
31
43
  if (!nodeInterop && obj && obj.__esModule) {
32
44
  return obj;
33
45
  }
@@ -40,9 +52,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
40
52
  if (cache && cache.has(obj)) {
41
53
  return cache.get(obj);
42
54
  }
43
- var newObj = {
44
- __proto__: null
45
- };
55
+ var newObj = {};
46
56
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
47
57
  for(var key in obj){
48
58
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -61,11 +71,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
61
71
  return newObj;
62
72
  }
63
73
  function TiptapEditorView(param) {
64
- let { editor, nodeViewComponents, markViewComponents, children, static: isStatic = false } = param;
74
+ let { editor , nodeViewComponents , markViewComponents , children , static: isStatic = false } = param;
75
+ var ref;
65
76
  const [isEditorInitialized, setIsEditorInitialized] = (0, _react1.useState)(editor.isInitialized);
66
- const attributesProp = editor.options.editorProps?.attributes;
77
+ const attributesProp = (ref = editor.options.editorProps) === null || ref === void 0 ? void 0 : ref.attributes;
67
78
  const [attributes, setAttributes] = (0, _react1.useState)(typeof attributesProp === "function" ? attributesProp(editor.state) : attributesProp);
68
- const forceUpdate = (0, _useForceUpdate.useForceUpdate)();
79
+ const forceUpdate = (0, _useForceUpdateJs.useForceUpdate)();
69
80
  const dispatchTransaction = (0, _react1.useCallback)((tr)=>{
70
81
  // @ts-expect-error calling private method
71
82
  editor.dispatchTransaction(tr);
@@ -86,10 +97,10 @@ function TiptapEditorView(param) {
86
97
  attributes: {
87
98
  role: "textbox",
88
99
  ...attributes,
89
- class: (0, _classnames.default)(attributes?.class, "tiptap")
100
+ class: (0, _classnames.default)(attributes === null || attributes === void 0 ? void 0 : attributes.class, "tiptap")
90
101
  }
91
102
  };
92
- const { nodeViews, markViews } = editor.isDestroyed ? {
103
+ const { nodeViews , markViews } = editor.isDestroyed ? {
93
104
  nodeViews: undefined,
94
105
  markViews: undefined
95
106
  } : editor.view.props;
@@ -113,18 +124,18 @@ function TiptapEditorView(param) {
113
124
  onEditorDeinitialize,
114
125
  onEditorInitialize
115
126
  ]);
116
- return /*#__PURE__*/ _react1.default.createElement(_ProseMirror.ProseMirror, {
117
- static: isStatic,
118
- ...editorProps,
127
+ return /*#__PURE__*/ _react1.default.createElement(_proseMirrorJs.ProseMirror, _extends({
128
+ static: isStatic
129
+ }, editorProps, {
119
130
  markViewComponents: markViewComponents,
120
131
  markViews: markViews,
121
132
  nodeViewComponents: nodeViewComponents,
122
133
  nodeViews: nodeViews,
123
134
  state: editor.state,
124
135
  dispatchTransaction: dispatchTransaction
125
- }, /*#__PURE__*/ _react1.default.createElement(_react.EditorContext.Provider, {
136
+ }), /*#__PURE__*/ _react1.default.createElement(_react.EditorContext.Provider, {
126
137
  value: contextValue
127
- }, /*#__PURE__*/ _react1.default.createElement(_TiptapEditorContext.TiptapEditorContext.Provider, {
138
+ }, /*#__PURE__*/ _react1.default.createElement(_tiptapEditorContextJs.TiptapEditorContext.Provider, {
128
139
  value: tiptapEditorContextValue
129
140
  }, children)));
130
141
  }
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "TiptapEditorContext", {
6
6
  enumerable: true,
7
- get: function() {
8
- return TiptapEditorContext;
9
- }
7
+ get: ()=>TiptapEditorContext
10
8
  });
11
9
  const _react = require("react");
12
10
  const TiptapEditorContext = (0, _react.createContext)(null);
@@ -4,18 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "ReactProseMirror", {
6
6
  enumerable: true,
7
- get: function() {
8
- return ReactProseMirror;
9
- }
7
+ get: ()=>ReactProseMirror
10
8
  });
11
9
  const _core = require("@tiptap/core");
12
- const _reorderSiblings = require("../../commands/reorderSiblings.js");
13
- const _reactKeys = require("../../plugins/reactKeys.js");
10
+ const _reorderSiblingsJs = require("../../commands/reorderSiblings.js");
11
+ const _reactKeysJs = require("../../plugins/reactKeys.js");
14
12
  const ReactProseMirror = _core.Extension.create({
15
13
  name: "@handlewithcare/react-prosemirror/reactKeys",
16
14
  addProseMirrorPlugins () {
17
15
  return [
18
- (0, _reactKeys.reactKeys)()
16
+ (0, _reactKeysJs.reactKeys)()
19
17
  ];
20
18
  },
21
19
  addCommands () {
@@ -31,8 +29,8 @@ const ReactProseMirror = _core.Extension.create({
31
29
  * and keep the other two in relative order, set `order` to `[1, 2, 0]`.
32
30
  */ reorderSiblings (initialPos, order) {
33
31
  return function reorderSiblingsCommand(param) {
34
- let { tr, state, dispatch } = param;
35
- return (0, _reorderSiblings.reorderSiblingsOnTransaction)(initialPos, order, tr, state, dispatch);
32
+ let { tr , state , dispatch } = param;
33
+ return (0, _reorderSiblingsJs.reorderSiblingsOnTransaction)(initialPos, order, tr, state, dispatch);
36
34
  };
37
35
  }
38
36
  };
@@ -4,18 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "ReactProseMirrorCommands", {
6
6
  enumerable: true,
7
- get: function() {
8
- return ReactProseMirrorCommands;
9
- }
7
+ get: ()=>ReactProseMirrorCommands
10
8
  });
11
9
  const _core = require("@tiptap/core");
12
- const _updateAttributes = require("./commands/updateAttributes.js");
10
+ const _updateAttributesJs = require("./commands/updateAttributes.js");
13
11
  const ReactProseMirrorCommands = _core.Extension.create({
14
12
  name: "reactProseMirrorCommands",
15
13
  addCommands () {
16
14
  return {
17
15
  ..._core.commands,
18
- updateAttributes: _updateAttributes.updateAttributes
16
+ updateAttributes: _updateAttributesJs.updateAttributes
19
17
  };
20
18
  }
21
19
  });
@@ -4,15 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "updateAttributes", {
6
6
  enumerable: true,
7
- get: function() {
8
- return updateAttributes;
9
- }
7
+ get: ()=>updateAttributes
10
8
  });
11
9
  const _core = require("@tiptap/core");
12
10
  const updateAttributes = function(typeOrName) {
13
11
  let attributes = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
14
12
  return (param)=>{
15
- let { tr, state, dispatch } = param;
13
+ let { tr , state , dispatch } = param;
16
14
  let nodeType = null;
17
15
  let markType = null;
18
16
  const schemaType = (0, _core.getSchemaTypeNameByName)(typeof typeOrName === "string" ? typeOrName : typeOrName.name, state.schema);
@@ -4,12 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useIsInReactProseMirror", {
6
6
  enumerable: true,
7
- get: function() {
8
- return useIsInReactProseMirror;
9
- }
7
+ get: ()=>useIsInReactProseMirror
10
8
  });
11
9
  const _react = require("react");
12
- const _EditorContext = require("../../contexts/EditorContext.js");
10
+ const _editorContextJs = require("../../contexts/EditorContext.js");
13
11
  function useIsInReactProseMirror() {
14
- return (0, _react.useContext)(_EditorContext.EditorContext) !== null;
12
+ return (0, _react.useContext)(_editorContextJs.EditorContext) !== null;
15
13
  }
@@ -4,37 +4,39 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useTiptapEditor", {
6
6
  enumerable: true,
7
- get: function() {
8
- return useTiptapEditor;
9
- }
7
+ get: ()=>useTiptapEditor
10
8
  });
11
9
  const _react = require("@tiptap/react");
12
- const _StaticEditorView = require("../../StaticEditorView.js");
13
- const _ReactProseMirror = require("../extensions/ReactProseMirror.js");
14
- const _ReactProseMirrorCommands = require("../extensions/ReactProseMirrorCommands.js");
10
+ const _staticEditorViewJs = require("../../StaticEditorView.js");
11
+ const _reactProseMirrorJs = require("../extensions/ReactProseMirror.js");
12
+ const _reactProseMirrorCommandsJs = require("../extensions/ReactProseMirrorCommands.js");
13
+ var // @ts-expect-error private property
14
+ _editor;
15
15
  function useTiptapEditor(options, deps) {
16
+ var ref;
17
+ var _extensions;
16
18
  const extensions = [
17
- _ReactProseMirror.ReactProseMirror,
18
- ...options.extensions ?? []
19
+ _reactProseMirrorJs.ReactProseMirror,
20
+ ...(_extensions = options.extensions) !== null && _extensions !== void 0 ? _extensions : []
19
21
  ];
20
22
  // If a consumer explicitly disables core extensions (or the Commands core extension)
21
23
  // do not re-add our custom Commands
22
- if (options.enableCoreExtensions === false || typeof options.enableCoreExtensions === "object" && options?.enableCoreExtensions?.commands === false) {
24
+ if (options.enableCoreExtensions === false || typeof options.enableCoreExtensions === "object" && (options === null || options === void 0 ? void 0 : (ref = options.enableCoreExtensions) === null || ref === void 0 ? void 0 : ref.commands) === false) {
23
25
  // Do nothing
24
26
  } else {
25
27
  options.enableCoreExtensions = {
26
28
  ...typeof options.enableCoreExtensions === "object" ? options.enableCoreExtensions : {},
27
29
  commands: false
28
30
  };
29
- extensions.push(_ReactProseMirrorCommands.ReactProseMirrorCommands);
31
+ extensions.push(_reactProseMirrorCommandsJs.ReactProseMirrorCommands);
30
32
  }
31
33
  const editor = (0, _react.useEditor)({
32
34
  ...options,
33
35
  extensions,
34
36
  element: null
35
37
  }, deps);
36
- // @ts-expect-error private property
37
- editor.editorView ??= new _StaticEditorView.StaticEditorView({
38
+ var _editorView;
39
+ (_editorView = (_editor = editor).editorView) !== null && _editorView !== void 0 ? _editorView : _editor.editorView = new _staticEditorViewJs.StaticEditorView({
38
40
  // @ts-expect-error private property
39
41
  state: editor.editorState,
40
42
  ...editor.options.editorProps,
@@ -4,22 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useTiptapEditorEffect", {
6
6
  enumerable: true,
7
- get: function() {
8
- return useTiptapEditorEffect;
9
- }
7
+ get: ()=>useTiptapEditorEffect
10
8
  });
11
9
  const _react = require("@tiptap/react");
12
10
  const _react1 = require("react");
13
- const _ReactEditorView = require("../../ReactEditorView.js");
14
- const _EditorContext = require("../../contexts/EditorContext.js");
15
- const _useEditorEffect = require("../../hooks/useEditorEffect.js");
16
- const _TiptapEditorContext = require("../contexts/TiptapEditorContext.js");
11
+ const _reactEditorViewJs = require("../../ReactEditorView.js");
12
+ const _editorContextJs = require("../../contexts/EditorContext.js");
13
+ const _useEditorEffectJs = require("../../hooks/useEditorEffect.js");
14
+ const _tiptapEditorContextJs = require("../contexts/TiptapEditorContext.js");
17
15
  function useTiptapEditorEffect(effect, dependencies) {
18
- const { view } = (0, _react1.useContext)(_EditorContext.EditorContext);
19
- const { editor } = (0, _react.useCurrentEditor)();
20
- const { isEditorInitialized } = (0, _react1.useContext)(_TiptapEditorContext.TiptapEditorContext);
21
- (0, _useEditorEffect.useEditorEffect)(()=>{
22
- if (editor?.view instanceof _ReactEditorView.ReactEditorView && view instanceof _ReactEditorView.ReactEditorView && isEditorInitialized) {
16
+ const { view } = (0, _react1.useContext)(_editorContextJs.EditorContext);
17
+ const { editor } = (0, _react.useCurrentEditor)();
18
+ const { isEditorInitialized } = (0, _react1.useContext)(_tiptapEditorContextJs.TiptapEditorContext);
19
+ (0, _useEditorEffectJs.useEditorEffect)(()=>{
20
+ if ((editor === null || editor === void 0 ? void 0 : editor.view) instanceof _reactEditorViewJs.ReactEditorView && view instanceof _reactEditorViewJs.ReactEditorView && isEditorInitialized) {
23
21
  return effect(editor);
24
22
  }
25
23
  // The rules of hooks want to be able to statically
@@ -4,21 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useTiptapEditorEventCallback", {
6
6
  enumerable: true,
7
- get: function() {
8
- return useTiptapEditorEventCallback;
9
- }
7
+ get: ()=>useTiptapEditorEventCallback
10
8
  });
11
9
  const _react = require("@tiptap/react");
12
10
  const _react1 = require("react");
13
- const _useEditorEffect = require("../../hooks/useEditorEffect.js");
11
+ const _useEditorEffectJs = require("../../hooks/useEditorEffect.js");
14
12
  function assertEditor(editor) {
15
13
  if (editor) return;
16
14
  throw new DOMException("Tiptap Editor is not initialized", "InvalidStateError");
17
15
  }
18
16
  function useTiptapEditorEventCallback(callback) {
19
17
  const ref = (0, _react1.useRef)(callback);
20
- const { editor } = (0, _react.useCurrentEditor)();
21
- (0, _useEditorEffect.useEditorEffect)(()=>{
18
+ const { editor } = (0, _react.useCurrentEditor)();
19
+ (0, _useEditorEffectJs.useEditorEffect)(()=>{
22
20
  ref.current = callback;
23
21
  }, [
24
22
  callback
@@ -9,40 +9,22 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- ReactProseMirror: function() {
13
- return _ReactProseMirror.ReactProseMirror;
14
- },
15
- TiptapEditor: function() {
16
- return _TiptapEditor.TiptapEditor;
17
- },
18
- TiptapEditorContent: function() {
19
- return _TiptapEditorContent.TiptapEditorContent;
20
- },
21
- TiptapEditorView: function() {
22
- return _TiptapEditorView.TiptapEditorView;
23
- },
24
- tiptapNodeView: function() {
25
- return _tiptapNodeView.tiptapNodeView;
26
- },
27
- useIsInReactProseMirror: function() {
28
- return _useIsInReactProseMirror.useIsInReactProseMirror;
29
- },
30
- useTiptapEditor: function() {
31
- return _useTiptapEditor.useTiptapEditor;
32
- },
33
- useTiptapEditorEffect: function() {
34
- return _useTiptapEditorEffect.useTiptapEditorEffect;
35
- },
36
- useTiptapEditorEventCallback: function() {
37
- return _useTiptapEditorEventCallback.useTiptapEditorEventCallback;
38
- }
12
+ tiptapNodeView: ()=>_tiptapNodeViewJs.tiptapNodeView,
13
+ TiptapEditorView: ()=>_tiptapEditorViewJs.TiptapEditorView,
14
+ TiptapEditorContent: ()=>_tiptapEditorContentJs.TiptapEditorContent,
15
+ useTiptapEditorEffect: ()=>_useTiptapEditorEffectJs.useTiptapEditorEffect,
16
+ useIsInReactProseMirror: ()=>_useIsInReactProseMirrorJs.useIsInReactProseMirror,
17
+ useTiptapEditorEventCallback: ()=>_useTiptapEditorEventCallbackJs.useTiptapEditorEventCallback,
18
+ TiptapEditor: ()=>_tiptapEditorJs.TiptapEditor,
19
+ useTiptapEditor: ()=>_useTiptapEditorJs.useTiptapEditor,
20
+ ReactProseMirror: ()=>_reactProseMirrorJs.ReactProseMirror
39
21
  });
40
- const _tiptapNodeView = require("./tiptapNodeView.js");
41
- const _TiptapEditorView = require("./TiptapEditorView.js");
42
- const _TiptapEditorContent = require("./TiptapEditorContent.js");
43
- const _useTiptapEditorEffect = require("./hooks/useTiptapEditorEffect.js");
44
- const _useIsInReactProseMirror = require("./hooks/useIsInReactProseMirror.js");
45
- const _useTiptapEditorEventCallback = require("./hooks/useTiptapEditorEventCallback.js");
46
- const _TiptapEditor = require("./TiptapEditor.js");
47
- const _useTiptapEditor = require("./hooks/useTiptapEditor.js");
48
- const _ReactProseMirror = require("./extensions/ReactProseMirror.js");
22
+ const _tiptapNodeViewJs = require("./tiptapNodeView.js");
23
+ const _tiptapEditorViewJs = require("./TiptapEditorView.js");
24
+ const _tiptapEditorContentJs = require("./TiptapEditorContent.js");
25
+ const _useTiptapEditorEffectJs = require("./hooks/useTiptapEditorEffect.js");
26
+ const _useIsInReactProseMirrorJs = require("./hooks/useIsInReactProseMirror.js");
27
+ const _useTiptapEditorEventCallbackJs = require("./hooks/useTiptapEditorEventCallback.js");
28
+ const _tiptapEditorJs = require("./TiptapEditor.js");
29
+ const _useTiptapEditorJs = require("./hooks/useTiptapEditor.js");
30
+ const _reactProseMirrorJs = require("./extensions/ReactProseMirror.js");