@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.
- package/README.md +26 -0
- package/dist/cjs/ReactEditorView.js +74 -70
- package/dist/cjs/StaticEditorView.js +21 -18
- package/dist/cjs/browser.js +3 -1
- package/dist/cjs/commands/reorderSiblings.js +13 -9
- package/dist/cjs/components/ChildNodeViews.js +71 -68
- package/dist/cjs/components/CursorWrapper.js +17 -26
- package/dist/cjs/components/LayoutGroup.js +16 -12
- package/dist/cjs/components/NativeWidgetView.js +19 -15
- package/dist/cjs/components/OutputSpec.js +13 -9
- package/dist/cjs/components/ProseMirror.js +27 -37
- package/dist/cjs/components/ProseMirrorDoc.js +18 -25
- package/dist/cjs/components/SeparatorHackView.js +20 -17
- package/dist/cjs/components/TextNodeView.js +20 -22
- package/dist/cjs/components/TrailingHackView.js +17 -13
- package/dist/cjs/components/WidgetView.js +18 -14
- package/dist/cjs/components/marks/DefaultMarkView.js +15 -27
- package/dist/cjs/components/marks/MarkView.js +23 -32
- package/dist/cjs/components/marks/MarkViewConstructorView.js +22 -38
- package/dist/cjs/components/marks/ReactMarkView.js +16 -27
- package/dist/cjs/components/nodes/DefaultNodeView.js +15 -27
- package/dist/cjs/components/nodes/DocNodeView.js +16 -12
- package/dist/cjs/components/nodes/NodeView.js +26 -33
- package/dist/cjs/components/nodes/NodeViewConstructorView.js +29 -45
- package/dist/cjs/components/nodes/ReactNodeView.js +27 -39
- package/dist/cjs/constants.js +10 -6
- package/dist/cjs/contexts/ChildDescriptionsContext.js +3 -1
- package/dist/cjs/contexts/EditorContext.js +3 -1
- package/dist/cjs/contexts/EditorStateContext.js +3 -1
- package/dist/cjs/contexts/IgnoreMutationContext.js +3 -1
- package/dist/cjs/contexts/LayoutGroupContext.js +3 -1
- package/dist/cjs/contexts/NodeViewContext.js +3 -1
- package/dist/cjs/contexts/SelectNodeContext.js +3 -1
- package/dist/cjs/contexts/StopEventContext.js +3 -1
- package/dist/cjs/decorations/ReactWidgetType.js +19 -13
- package/dist/cjs/decorations/computeDocDeco.js +5 -3
- package/dist/cjs/decorations/iterDeco.js +19 -17
- package/dist/cjs/decorations/viewDecorations.js +15 -12
- package/dist/cjs/dom.js +34 -13
- package/dist/cjs/findDOMNode.js +9 -5
- package/dist/cjs/hooks/useClientLayoutEffect.js +3 -1
- package/dist/cjs/hooks/useComponentEventListeners.js +7 -6
- package/dist/cjs/hooks/useEditor.js +28 -30
- package/dist/cjs/hooks/useEditorEffect.js +9 -7
- package/dist/cjs/hooks/useEditorEventCallback.js +9 -7
- package/dist/cjs/hooks/useEditorEventListener.js +8 -6
- package/dist/cjs/hooks/useEditorState.js +5 -3
- package/dist/cjs/hooks/useEffectEvent.js +3 -1
- package/dist/cjs/hooks/useForceUpdate.js +3 -1
- package/dist/cjs/hooks/useIgnoreMutation.js +9 -7
- package/dist/cjs/hooks/useIsEditorStatic.js +5 -5
- package/dist/cjs/hooks/useIsNodeSelected.js +5 -3
- package/dist/cjs/hooks/useLayoutGroupEffect.js +7 -5
- package/dist/cjs/hooks/useMarkViewDescription.js +31 -25
- package/dist/cjs/hooks/useNodePos.js +7 -5
- package/dist/cjs/hooks/useNodeViewDescription.js +32 -28
- package/dist/cjs/hooks/useReactKeys.js +7 -5
- package/dist/cjs/hooks/useSelectNode.js +10 -8
- package/dist/cjs/hooks/useStopEvent.js +9 -7
- package/dist/cjs/index.js +66 -34
- package/dist/cjs/plugins/beforeInputPlugin.js +20 -23
- package/dist/cjs/plugins/componentEventListeners.js +8 -6
- package/dist/cjs/plugins/componentEventListenersPlugin.js +8 -6
- package/dist/cjs/plugins/reactKeys.js +15 -10
- package/dist/cjs/props.js +23 -19
- package/dist/cjs/refs.js +3 -1
- package/dist/cjs/testing/editorViewTestHelpers.js +40 -47
- package/dist/cjs/testing/setupProseMirrorView.js +7 -4
- package/dist/cjs/tiptap/ReactProseMirrorNodeView.js +10 -6
- package/dist/cjs/tiptap/TiptapEditor.js +15 -14
- package/dist/cjs/tiptap/TiptapEditorContent.js +18 -28
- package/dist/cjs/tiptap/TiptapEditorView.js +23 -34
- package/dist/cjs/tiptap/contexts/TiptapEditorContext.js +3 -1
- package/dist/cjs/tiptap/extensions/ReactProseMirror.js +8 -6
- package/dist/cjs/tiptap/extensions/ReactProseMirrorCommands.js +5 -3
- package/dist/cjs/tiptap/extensions/commands/updateAttributes.js +4 -2
- package/dist/cjs/tiptap/hooks/useIsInReactProseMirror.js +5 -3
- package/dist/cjs/tiptap/hooks/useTiptapEditor.js +12 -14
- package/dist/cjs/tiptap/hooks/useTiptapEditorEffect.js +12 -10
- package/dist/cjs/tiptap/hooks/useTiptapEditorEventCallback.js +6 -4
- package/dist/cjs/tiptap/index.js +36 -18
- package/dist/cjs/tiptap/tiptapNodeView.js +48 -62
- package/dist/cjs/viewdesc.js +119 -89
- package/dist/esm/ReactEditorView.js +68 -66
- package/dist/esm/StaticEditorView.js +18 -17
- package/dist/esm/commands/reorderSiblings.js +5 -5
- package/dist/esm/components/ChildNodeViews.js +33 -36
- package/dist/esm/components/CursorWrapper.js +5 -18
- package/dist/esm/components/LayoutGroup.js +1 -1
- package/dist/esm/components/NativeWidgetView.js +2 -2
- package/dist/esm/components/OutputSpec.js +1 -1
- package/dist/esm/components/ProseMirror.js +3 -17
- package/dist/esm/components/ProseMirrorDoc.js +6 -19
- package/dist/esm/components/SeparatorHackView.js +3 -4
- package/dist/esm/components/TextNodeView.js +6 -10
- package/dist/esm/components/TrailingHackView.js +2 -2
- package/dist/esm/components/WidgetView.js +3 -3
- package/dist/esm/components/marks/DefaultMarkView.js +6 -22
- package/dist/esm/components/marks/MarkView.js +11 -24
- package/dist/esm/components/marks/MarkViewConstructorView.js +7 -27
- package/dist/esm/components/marks/ReactMarkView.js +3 -18
- package/dist/esm/components/nodes/DefaultNodeView.js +6 -22
- package/dist/esm/components/nodes/DocNodeView.js +2 -2
- package/dist/esm/components/nodes/NodeView.js +11 -24
- package/dist/esm/components/nodes/NodeViewConstructorView.js +11 -31
- package/dist/esm/components/nodes/ReactNodeView.js +6 -22
- package/dist/esm/decorations/ReactWidgetType.js +10 -8
- package/dist/esm/decorations/iterDeco.js +13 -13
- package/dist/esm/decorations/viewDecorations.js +7 -6
- package/dist/esm/dom.js +1 -2
- package/dist/esm/findDOMNode.js +1 -1
- package/dist/esm/hooks/useComponentEventListeners.js +2 -3
- package/dist/esm/hooks/useEditor.js +5 -9
- package/dist/esm/hooks/useEditorEffect.js +1 -1
- package/dist/esm/hooks/useEditorEventCallback.js +1 -1
- package/dist/esm/hooks/useEditorEventListener.js +1 -1
- package/dist/esm/hooks/useIsEditorStatic.js +1 -3
- package/dist/esm/hooks/useMarkViewDescription.js +14 -10
- package/dist/esm/hooks/useNodeViewDescription.js +10 -8
- package/dist/esm/hooks/useReactKeys.js +1 -1
- package/dist/esm/plugins/beforeInputPlugin.js +12 -17
- package/dist/esm/plugins/reactKeys.js +3 -4
- package/dist/esm/props.js +15 -15
- package/dist/esm/testing/editorViewTestHelpers.js +20 -31
- package/dist/esm/testing/setupProseMirrorView.js +1 -2
- package/dist/esm/tiptap/ReactProseMirrorNodeView.js +7 -5
- package/dist/esm/tiptap/TiptapEditor.js +9 -10
- package/dist/esm/tiptap/TiptapEditorContent.js +4 -18
- package/dist/esm/tiptap/TiptapEditorView.js +8 -23
- package/dist/esm/tiptap/extensions/ReactProseMirror.js +1 -1
- package/dist/esm/tiptap/extensions/commands/updateAttributes.js +1 -1
- package/dist/esm/tiptap/hooks/useTiptapEditor.js +4 -8
- package/dist/esm/tiptap/hooks/useTiptapEditorEffect.js +4 -4
- package/dist/esm/tiptap/hooks/useTiptapEditorEventCallback.js +1 -1
- package/dist/esm/tiptap/tiptapNodeView.js +20 -38
- package/dist/esm/viewdesc.js +74 -66
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/constants.d.ts +1 -1
- package/dist/types/props.d.ts +8 -8
- 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: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return TiptapEditorContent;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _react = /*#__PURE__*/
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
104
|
+
let { editor: editorProp, ...props } = param;
|
|
115
105
|
const editor = editorProp;
|
|
116
|
-
const { onEditorInitialize
|
|
117
|
-
(0,
|
|
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(
|
|
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: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return TiptapEditorView;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _react = require("@tiptap/react");
|
|
10
|
-
const _classnames = /*#__PURE__*/
|
|
11
|
-
const _react1 = /*#__PURE__*/
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
function
|
|
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
|
|
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
|
|
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 =
|
|
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,
|
|
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
|
|
89
|
+
class: (0, _classnames.default)(attributes?.class, "tiptap")
|
|
101
90
|
}
|
|
102
91
|
};
|
|
103
|
-
const { nodeViews
|
|
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(
|
|
128
|
-
static: isStatic
|
|
129
|
-
|
|
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
|
-
}
|
|
125
|
+
}, /*#__PURE__*/ _react1.default.createElement(_react.EditorContext.Provider, {
|
|
137
126
|
value: contextValue
|
|
138
|
-
}, /*#__PURE__*/ _react1.default.createElement(
|
|
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: ()
|
|
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: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return ReactProseMirror;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _core = require("@tiptap/core");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
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,
|
|
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
|
|
33
|
-
return (0,
|
|
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: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return ReactProseMirrorCommands;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _core = require("@tiptap/core");
|
|
10
|
-
const
|
|
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:
|
|
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: ()
|
|
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
|
|
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: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return useIsInReactProseMirror;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _react = require("react");
|
|
10
|
-
const
|
|
12
|
+
const _EditorContext = require("../../contexts/EditorContext.js");
|
|
11
13
|
function useIsInReactProseMirror() {
|
|
12
|
-
return (0, _react.useContext)(
|
|
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: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return useTiptapEditor;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _react = require("@tiptap/react");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
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
|
-
|
|
20
|
-
...
|
|
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" &&
|
|
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(
|
|
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
|
-
|
|
39
|
-
|
|
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: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return useTiptapEditorEffect;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _react = require("@tiptap/react");
|
|
10
12
|
const _react1 = require("react");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
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
|
|
17
|
-
const { editor
|
|
18
|
-
const { isEditorInitialized
|
|
19
|
-
(0,
|
|
20
|
-
if (
|
|
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: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return useTiptapEditorEventCallback;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _react = require("@tiptap/react");
|
|
10
12
|
const _react1 = require("react");
|
|
11
|
-
const
|
|
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
|
|
19
|
-
(0,
|
|
20
|
+
const { editor } = (0, _react.useCurrentEditor)();
|
|
21
|
+
(0, _useEditorEffect.useEditorEffect)(()=>{
|
|
20
22
|
ref.current = callback;
|
|
21
23
|
}, [
|
|
22
24
|
callback
|
package/dist/cjs/tiptap/index.js
CHANGED
|
@@ -9,22 +9,40 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
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");
|