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