@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.
- package/README.md +2 -2
- package/dist/cjs/ReactEditorView.js +71 -75
- package/dist/cjs/StaticEditorView.js +19 -22
- package/dist/cjs/browser.js +1 -3
- package/dist/cjs/commands/reorderSiblings.js +9 -13
- package/dist/cjs/components/ChildNodeViews.js +68 -71
- package/dist/cjs/components/CursorWrapper.js +26 -17
- package/dist/cjs/components/LayoutGroup.js +12 -16
- package/dist/cjs/components/NativeWidgetView.js +15 -19
- package/dist/cjs/components/OutputSpec.js +9 -13
- package/dist/cjs/components/ProseMirror.js +37 -27
- package/dist/cjs/components/ProseMirrorDoc.js +25 -18
- package/dist/cjs/components/SeparatorHackView.js +20 -21
- package/dist/cjs/components/TextNodeView.js +22 -20
- package/dist/cjs/components/TrailingHackView.js +13 -17
- package/dist/cjs/components/WidgetView.js +14 -18
- package/dist/cjs/components/marks/DefaultMarkView.js +27 -15
- package/dist/cjs/components/marks/MarkView.js +32 -23
- package/dist/cjs/components/marks/MarkViewConstructorView.js +38 -22
- package/dist/cjs/components/marks/ReactMarkView.js +27 -16
- package/dist/cjs/components/nodes/DefaultNodeView.js +27 -15
- package/dist/cjs/components/nodes/DocNodeView.js +12 -16
- package/dist/cjs/components/nodes/NodeView.js +33 -26
- package/dist/cjs/components/nodes/NodeViewConstructorView.js +45 -29
- package/dist/cjs/components/nodes/ReactNodeView.js +39 -27
- package/dist/cjs/constants.js +6 -10
- package/dist/cjs/contexts/ChildDescriptionsContext.js +1 -3
- package/dist/cjs/contexts/EditorContext.js +1 -3
- package/dist/cjs/contexts/EditorStateContext.js +1 -3
- package/dist/cjs/contexts/IgnoreMutationContext.js +1 -3
- package/dist/cjs/contexts/LayoutGroupContext.js +1 -3
- package/dist/cjs/contexts/NodeViewContext.js +1 -3
- package/dist/cjs/contexts/SelectNodeContext.js +1 -3
- package/dist/cjs/contexts/StopEventContext.js +1 -3
- package/dist/cjs/decorations/ReactWidgetType.js +13 -19
- package/dist/cjs/decorations/computeDocDeco.js +3 -5
- package/dist/cjs/decorations/iterDeco.js +17 -19
- package/dist/cjs/decorations/viewDecorations.js +12 -15
- package/dist/cjs/dom.js +13 -34
- package/dist/cjs/findDOMNode.js +5 -9
- package/dist/cjs/hooks/useClientLayoutEffect.js +1 -3
- package/dist/cjs/hooks/useComponentEventListeners.js +6 -7
- package/dist/cjs/hooks/useEditor.js +30 -28
- package/dist/cjs/hooks/useEditorEffect.js +7 -9
- package/dist/cjs/hooks/useEditorEventCallback.js +7 -9
- package/dist/cjs/hooks/useEditorEventListener.js +6 -8
- package/dist/cjs/hooks/useEditorState.js +3 -5
- package/dist/cjs/hooks/useEffectEvent.js +1 -3
- package/dist/cjs/hooks/useForceUpdate.js +1 -3
- package/dist/cjs/hooks/useIgnoreMutation.js +7 -9
- package/dist/cjs/hooks/useIsEditorStatic.js +5 -5
- package/dist/cjs/hooks/useIsNodeSelected.js +3 -5
- package/dist/cjs/hooks/useLayoutGroupEffect.js +5 -7
- package/dist/cjs/hooks/useMarkViewDescription.js +25 -24
- package/dist/cjs/hooks/useNodePos.js +5 -7
- package/dist/cjs/hooks/useNodeViewDescription.js +41 -28
- package/dist/cjs/hooks/useReactKeys.js +5 -7
- package/dist/cjs/hooks/useSelectNode.js +8 -10
- package/dist/cjs/hooks/useStopEvent.js +7 -9
- package/dist/cjs/index.js +34 -66
- package/dist/cjs/plugins/beforeInputPlugin.js +23 -20
- package/dist/cjs/plugins/componentEventListeners.js +6 -8
- package/dist/cjs/plugins/componentEventListenersPlugin.js +6 -8
- package/dist/cjs/plugins/reactKeys.js +10 -15
- package/dist/cjs/props.js +19 -23
- package/dist/cjs/refs.js +1 -3
- package/dist/cjs/testing/editorViewTestHelpers.js +47 -40
- package/dist/cjs/testing/setupProseMirrorView.js +4 -7
- package/dist/cjs/tiptap/ReactProseMirrorNodeView.js +6 -10
- package/dist/cjs/tiptap/TiptapEditor.js +14 -15
- package/dist/cjs/tiptap/TiptapEditorContent.js +28 -18
- package/dist/cjs/tiptap/TiptapEditorView.js +34 -23
- package/dist/cjs/tiptap/contexts/TiptapEditorContext.js +1 -3
- package/dist/cjs/tiptap/extensions/ReactProseMirror.js +6 -8
- package/dist/cjs/tiptap/extensions/ReactProseMirrorCommands.js +3 -5
- package/dist/cjs/tiptap/extensions/commands/updateAttributes.js +2 -4
- package/dist/cjs/tiptap/hooks/useIsInReactProseMirror.js +3 -5
- package/dist/cjs/tiptap/hooks/useTiptapEditor.js +14 -12
- package/dist/cjs/tiptap/hooks/useTiptapEditorEffect.js +10 -12
- package/dist/cjs/tiptap/hooks/useTiptapEditorEventCallback.js +4 -6
- package/dist/cjs/tiptap/index.js +18 -36
- package/dist/cjs/tiptap/tiptapNodeView.js +62 -48
- package/dist/cjs/viewdesc.js +95 -119
- package/dist/esm/ReactEditorView.js +67 -69
- package/dist/esm/StaticEditorView.js +18 -19
- package/dist/esm/commands/reorderSiblings.js +5 -5
- package/dist/esm/components/ChildNodeViews.js +36 -33
- package/dist/esm/components/CursorWrapper.js +18 -5
- 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 +17 -3
- package/dist/esm/components/ProseMirrorDoc.js +19 -6
- package/dist/esm/components/SeparatorHackView.js +8 -5
- package/dist/esm/components/TextNodeView.js +10 -6
- package/dist/esm/components/TrailingHackView.js +2 -2
- package/dist/esm/components/WidgetView.js +3 -3
- package/dist/esm/components/marks/DefaultMarkView.js +22 -6
- package/dist/esm/components/marks/MarkView.js +24 -11
- package/dist/esm/components/marks/MarkViewConstructorView.js +27 -7
- package/dist/esm/components/marks/ReactMarkView.js +18 -3
- package/dist/esm/components/nodes/DefaultNodeView.js +22 -6
- package/dist/esm/components/nodes/DocNodeView.js +2 -2
- package/dist/esm/components/nodes/NodeView.js +24 -11
- package/dist/esm/components/nodes/NodeViewConstructorView.js +31 -11
- package/dist/esm/components/nodes/ReactNodeView.js +22 -6
- package/dist/esm/decorations/ReactWidgetType.js +8 -10
- package/dist/esm/decorations/iterDeco.js +13 -13
- package/dist/esm/decorations/viewDecorations.js +6 -7
- package/dist/esm/dom.js +2 -1
- package/dist/esm/findDOMNode.js +1 -1
- package/dist/esm/hooks/useComponentEventListeners.js +3 -2
- package/dist/esm/hooks/useEditor.js +9 -5
- 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 +3 -1
- package/dist/esm/hooks/useMarkViewDescription.js +10 -7
- package/dist/esm/hooks/useNodeViewDescription.js +22 -7
- package/dist/esm/hooks/useReactKeys.js +1 -1
- package/dist/esm/plugins/beforeInputPlugin.js +17 -12
- package/dist/esm/plugins/reactKeys.js +4 -3
- package/dist/esm/props.js +15 -15
- package/dist/esm/testing/editorViewTestHelpers.js +31 -20
- package/dist/esm/testing/setupProseMirrorView.js +2 -1
- package/dist/esm/tiptap/ReactProseMirrorNodeView.js +5 -7
- package/dist/esm/tiptap/TiptapEditor.js +10 -9
- package/dist/esm/tiptap/TiptapEditorContent.js +18 -4
- package/dist/esm/tiptap/TiptapEditorView.js +23 -8
- 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 +8 -4
- package/dist/esm/tiptap/hooks/useTiptapEditorEffect.js +4 -4
- package/dist/esm/tiptap/hooks/useTiptapEditorEventCallback.js +1 -1
- package/dist/esm/tiptap/tiptapNodeView.js +38 -20
- package/dist/esm/viewdesc.js +72 -74
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/ReactEditorView.d.ts +2 -2
- package/dist/types/StaticEditorView.d.ts +2 -1
- package/dist/types/props.d.ts +26 -26
- package/dist/types/viewdesc.d.ts +2 -0
- package/package.json +10 -6
|
@@ -4,13 +4,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "CursorWrapper", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get:
|
|
8
|
-
return CursorWrapper;
|
|
9
|
-
}
|
|
7
|
+
get: ()=>CursorWrapper
|
|
10
8
|
});
|
|
11
|
-
const _react = /*#__PURE__*/
|
|
12
|
-
const
|
|
13
|
-
const
|
|
9
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
10
|
+
const _domJs = require("../dom.js");
|
|
11
|
+
const _useEditorEffectJs = require("../hooks/useEditorEffect.js");
|
|
12
|
+
function _extends() {
|
|
13
|
+
_extends = Object.assign || function(target) {
|
|
14
|
+
for(var i = 1; i < arguments.length; i++){
|
|
15
|
+
var source = arguments[i];
|
|
16
|
+
for(var key in source){
|
|
17
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
18
|
+
target[key] = source[key];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return target;
|
|
23
|
+
};
|
|
24
|
+
return _extends.apply(this, arguments);
|
|
25
|
+
}
|
|
14
26
|
function _getRequireWildcardCache(nodeInterop) {
|
|
15
27
|
if (typeof WeakMap !== "function") return null;
|
|
16
28
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -19,7 +31,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
19
31
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
20
32
|
})(nodeInterop);
|
|
21
33
|
}
|
|
22
|
-
function
|
|
34
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
23
35
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
24
36
|
return obj;
|
|
25
37
|
}
|
|
@@ -32,9 +44,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
32
44
|
if (cache && cache.has(obj)) {
|
|
33
45
|
return cache.get(obj);
|
|
34
46
|
}
|
|
35
|
-
var newObj = {
|
|
36
|
-
__proto__: null
|
|
37
|
-
};
|
|
47
|
+
var newObj = {};
|
|
38
48
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
39
49
|
for(var key in obj){
|
|
40
50
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -53,13 +63,13 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
53
63
|
return newObj;
|
|
54
64
|
}
|
|
55
65
|
const CursorWrapper = /*#__PURE__*/ (0, _react.forwardRef)(function CursorWrapper(param, ref) {
|
|
56
|
-
let { widget, getPos, ...props } = param;
|
|
66
|
+
let { widget , getPos , ...props } = param;
|
|
57
67
|
const [shouldRender, setShouldRender] = (0, _react.useState)(true);
|
|
58
68
|
const innerRef = (0, _react.useRef)(null);
|
|
59
69
|
(0, _react.useImperativeHandle)(ref, ()=>{
|
|
60
70
|
return innerRef.current;
|
|
61
71
|
}, []);
|
|
62
|
-
(0,
|
|
72
|
+
(0, _useEditorEffectJs.useEditorEffect)((view)=>{
|
|
63
73
|
if (!view || !innerRef.current) return;
|
|
64
74
|
// @ts-expect-error Internal property - domObserver
|
|
65
75
|
view.domObserver.disconnectSelection();
|
|
@@ -69,7 +79,7 @@ const CursorWrapper = /*#__PURE__*/ (0, _react.forwardRef)(function CursorWrappe
|
|
|
69
79
|
const node = innerRef.current;
|
|
70
80
|
const img = node.nodeName == "IMG";
|
|
71
81
|
if (img && node.parentNode) {
|
|
72
|
-
range.setEnd(node.parentNode, (0,
|
|
82
|
+
range.setEnd(node.parentNode, (0, _domJs.domIndex)(node) + 1);
|
|
73
83
|
} else {
|
|
74
84
|
range.setEnd(node, 0);
|
|
75
85
|
}
|
|
@@ -80,12 +90,11 @@ const CursorWrapper = /*#__PURE__*/ (0, _react.forwardRef)(function CursorWrappe
|
|
|
80
90
|
// @ts-expect-error Internal property - domObserver
|
|
81
91
|
view.domObserver.connectSelection();
|
|
82
92
|
}, []);
|
|
83
|
-
return shouldRender ? /*#__PURE__*/ _react.default.createElement("img", {
|
|
93
|
+
return shouldRender ? /*#__PURE__*/ _react.default.createElement("img", _extends({
|
|
84
94
|
ref: innerRef,
|
|
85
95
|
className: "ProseMirror-separator",
|
|
86
96
|
// eslint-disable-next-line react/no-unknown-property
|
|
87
97
|
"mark-placeholder": "true",
|
|
88
|
-
alt: ""
|
|
89
|
-
|
|
90
|
-
}) : null;
|
|
98
|
+
alt: ""
|
|
99
|
+
}, props)) : null;
|
|
91
100
|
});
|
|
@@ -4,14 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "LayoutGroup", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get:
|
|
8
|
-
return LayoutGroup;
|
|
9
|
-
}
|
|
7
|
+
get: ()=>LayoutGroup
|
|
10
8
|
});
|
|
11
|
-
const _react = /*#__PURE__*/
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
9
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
10
|
+
const _layoutGroupContextJs = require("../contexts/LayoutGroupContext.js");
|
|
11
|
+
const _useClientLayoutEffectJs = require("../hooks/useClientLayoutEffect.js");
|
|
12
|
+
const _useForceUpdateJs = require("../hooks/useForceUpdate.js");
|
|
15
13
|
function _getRequireWildcardCache(nodeInterop) {
|
|
16
14
|
if (typeof WeakMap !== "function") return null;
|
|
17
15
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -20,7 +18,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
20
18
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
21
19
|
})(nodeInterop);
|
|
22
20
|
}
|
|
23
|
-
function
|
|
21
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
24
22
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
25
23
|
return obj;
|
|
26
24
|
}
|
|
@@ -33,9 +31,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
33
31
|
if (cache && cache.has(obj)) {
|
|
34
32
|
return cache.get(obj);
|
|
35
33
|
}
|
|
36
|
-
var newObj = {
|
|
37
|
-
__proto__: null
|
|
38
|
-
};
|
|
34
|
+
var newObj = {};
|
|
39
35
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
40
36
|
for(var key in obj){
|
|
41
37
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -54,11 +50,11 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
54
50
|
return newObj;
|
|
55
51
|
}
|
|
56
52
|
function LayoutGroup(param) {
|
|
57
|
-
let { children
|
|
53
|
+
let { children } = param;
|
|
58
54
|
const createQueue = (0, _react.useRef)(new Set()).current;
|
|
59
55
|
const destroyQueue = (0, _react.useRef)(new Set()).current;
|
|
60
56
|
const isMounted = (0, _react.useRef)(false);
|
|
61
|
-
const forceUpdate = (0,
|
|
57
|
+
const forceUpdate = (0, _useForceUpdateJs.useForceUpdate)();
|
|
62
58
|
const isUpdatePending = (0, _react.useRef)(true);
|
|
63
59
|
const ensureFlush = (0, _react.useCallback)(()=>{
|
|
64
60
|
if (!isUpdatePending.current) {
|
|
@@ -91,7 +87,7 @@ function LayoutGroup(param) {
|
|
|
91
87
|
destroyQueue,
|
|
92
88
|
ensureFlush
|
|
93
89
|
]);
|
|
94
|
-
(0,
|
|
90
|
+
(0, _useClientLayoutEffectJs.useClientLayoutEffect)(()=>{
|
|
95
91
|
isUpdatePending.current = false;
|
|
96
92
|
createQueue.forEach((create)=>create());
|
|
97
93
|
createQueue.clear();
|
|
@@ -100,13 +96,13 @@ function LayoutGroup(param) {
|
|
|
100
96
|
destroyQueue.clear();
|
|
101
97
|
};
|
|
102
98
|
});
|
|
103
|
-
(0,
|
|
99
|
+
(0, _useClientLayoutEffectJs.useClientLayoutEffect)(()=>{
|
|
104
100
|
isMounted.current = true;
|
|
105
101
|
return ()=>{
|
|
106
102
|
isMounted.current = false;
|
|
107
103
|
};
|
|
108
104
|
}, []);
|
|
109
|
-
return /*#__PURE__*/ _react.default.createElement(
|
|
105
|
+
return /*#__PURE__*/ _react.default.createElement(_layoutGroupContextJs.LayoutGroupContext.Provider, {
|
|
110
106
|
value: register
|
|
111
107
|
}, children);
|
|
112
108
|
}
|
|
@@ -4,15 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "NativeWidgetView", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get:
|
|
8
|
-
return NativeWidgetView;
|
|
9
|
-
}
|
|
7
|
+
get: ()=>NativeWidgetView
|
|
10
8
|
});
|
|
11
|
-
const _react = /*#__PURE__*/
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
9
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
10
|
+
const _childDescriptionsContextJs = require("../contexts/ChildDescriptionsContext.js");
|
|
11
|
+
const _useClientLayoutEffectJs = require("../hooks/useClientLayoutEffect.js");
|
|
12
|
+
const _useEditorEffectJs = require("../hooks/useEditorEffect.js");
|
|
13
|
+
const _viewdescJs = require("../viewdesc.js");
|
|
16
14
|
function _getRequireWildcardCache(nodeInterop) {
|
|
17
15
|
if (typeof WeakMap !== "function") return null;
|
|
18
16
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -21,7 +19,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
21
19
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
22
20
|
})(nodeInterop);
|
|
23
21
|
}
|
|
24
|
-
function
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
25
23
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
26
24
|
return obj;
|
|
27
25
|
}
|
|
@@ -34,9 +32,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
34
32
|
if (cache && cache.has(obj)) {
|
|
35
33
|
return cache.get(obj);
|
|
36
34
|
}
|
|
37
|
-
var newObj = {
|
|
38
|
-
__proto__: null
|
|
39
|
-
};
|
|
35
|
+
var newObj = {};
|
|
40
36
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
41
37
|
for(var key in obj){
|
|
42
38
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -55,11 +51,11 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
55
51
|
return newObj;
|
|
56
52
|
}
|
|
57
53
|
function NativeWidgetView(param) {
|
|
58
|
-
let { widget, getPos
|
|
59
|
-
const { siblingsRef, parentRef
|
|
54
|
+
let { widget , getPos } = param;
|
|
55
|
+
const { siblingsRef , parentRef } = (0, _react.useContext)(_childDescriptionsContextJs.ChildDescriptionsContext);
|
|
60
56
|
const viewDescRef = (0, _react.useRef)(null);
|
|
61
57
|
const rootDomRef = (0, _react.useRef)(null);
|
|
62
|
-
(0,
|
|
58
|
+
(0, _useClientLayoutEffectJs.useClientLayoutEffect)(()=>{
|
|
63
59
|
const siblings = siblingsRef.current;
|
|
64
60
|
return ()=>{
|
|
65
61
|
if (!viewDescRef.current) return;
|
|
@@ -71,7 +67,7 @@ function NativeWidgetView(param) {
|
|
|
71
67
|
}, [
|
|
72
68
|
siblingsRef
|
|
73
69
|
]);
|
|
74
|
-
(0,
|
|
70
|
+
(0, _useEditorEffectJs.useEditorEffect)((view)=>{
|
|
75
71
|
if (!rootDomRef.current) return;
|
|
76
72
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
73
|
const toDOM = widget.type.toDOM;
|
|
@@ -89,10 +85,10 @@ function NativeWidgetView(param) {
|
|
|
89
85
|
if (rootDomRef.current.firstElementChild === dom) return;
|
|
90
86
|
rootDomRef.current.replaceChildren(dom);
|
|
91
87
|
});
|
|
92
|
-
(0,
|
|
88
|
+
(0, _useClientLayoutEffectJs.useClientLayoutEffect)(()=>{
|
|
93
89
|
if (!rootDomRef.current) return;
|
|
94
90
|
if (!viewDescRef.current) {
|
|
95
|
-
viewDescRef.current = new
|
|
91
|
+
viewDescRef.current = new _viewdescJs.WidgetViewDesc(parentRef.current, getPos, widget, rootDomRef.current);
|
|
96
92
|
} else {
|
|
97
93
|
viewDescRef.current.parent = parentRef.current;
|
|
98
94
|
viewDescRef.current.widget = widget;
|
|
@@ -101,7 +97,7 @@ function NativeWidgetView(param) {
|
|
|
101
97
|
if (!siblingsRef.current.includes(viewDescRef.current)) {
|
|
102
98
|
siblingsRef.current.push(viewDescRef.current);
|
|
103
99
|
}
|
|
104
|
-
siblingsRef.current.sort(
|
|
100
|
+
siblingsRef.current.sort(_viewdescJs.sortViewDescs);
|
|
105
101
|
});
|
|
106
102
|
return /*#__PURE__*/ _react.default.createElement("span", {
|
|
107
103
|
ref: rootDomRef
|
|
@@ -4,13 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "OutputSpec", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get:
|
|
8
|
-
return ForwardedOutputSpec;
|
|
9
|
-
}
|
|
7
|
+
get: ()=>ForwardedOutputSpec
|
|
10
8
|
});
|
|
11
|
-
const _react = /*#__PURE__*/
|
|
12
|
-
const
|
|
13
|
-
const
|
|
9
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
10
|
+
const _propsJs = require("../props.js");
|
|
11
|
+
const _refsJs = require("../refs.js");
|
|
14
12
|
function _getRequireWildcardCache(nodeInterop) {
|
|
15
13
|
if (typeof WeakMap !== "function") return null;
|
|
16
14
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -19,7 +17,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
19
17
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
20
18
|
})(nodeInterop);
|
|
21
19
|
}
|
|
22
|
-
function
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
23
21
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
24
22
|
return obj;
|
|
25
23
|
}
|
|
@@ -32,9 +30,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
32
30
|
if (cache && cache.has(obj)) {
|
|
33
31
|
return cache.get(obj);
|
|
34
32
|
}
|
|
35
|
-
var newObj = {
|
|
36
|
-
__proto__: null
|
|
37
|
-
};
|
|
33
|
+
var newObj = {};
|
|
38
34
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
39
35
|
for(var key in obj){
|
|
40
36
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -73,8 +69,8 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
73
69
|
return false;
|
|
74
70
|
}
|
|
75
71
|
const ForwardedOutputSpec = /*#__PURE__*/ (0, _react.memo)(/*#__PURE__*/ (0, _react.forwardRef)(function OutputSpec(param, ref) {
|
|
76
|
-
let { outputSpec, isMark, contentDOMRef, children, ...propOverrides } = param;
|
|
77
|
-
const mergedRef = (0,
|
|
72
|
+
let { outputSpec , isMark , contentDOMRef , children , ...propOverrides } = param;
|
|
73
|
+
const mergedRef = (0, _refsJs.useMergedDOMRefs)(ref, contentDOMRef);
|
|
78
74
|
if (typeof outputSpec === "string") {
|
|
79
75
|
return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, outputSpec);
|
|
80
76
|
}
|
|
@@ -91,7 +87,7 @@ const ForwardedOutputSpec = /*#__PURE__*/ (0, _react.memo)(/*#__PURE__*/ (0, _re
|
|
|
91
87
|
let start = 1;
|
|
92
88
|
if (attrs && typeof attrs === "object" && attrs.nodeType == null && !Array.isArray(attrs)) {
|
|
93
89
|
start = 2;
|
|
94
|
-
props = (0,
|
|
90
|
+
props = (0, _propsJs.mergeReactProps)((0, _propsJs.htmlAttrsToReactProps)(attrs), props);
|
|
95
91
|
}
|
|
96
92
|
const content = [];
|
|
97
93
|
for(let i = start; i < outputSpec.length; i++){
|
|
@@ -4,20 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "ProseMirror", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get:
|
|
8
|
-
return ProseMirror;
|
|
9
|
-
}
|
|
7
|
+
get: ()=>ProseMirror
|
|
10
8
|
});
|
|
11
|
-
const _react = /*#__PURE__*/
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
9
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
10
|
+
const _childDescriptionsContextJs = require("../contexts/ChildDescriptionsContext.js");
|
|
11
|
+
const _editorContextJs = require("../contexts/EditorContext.js");
|
|
12
|
+
const _editorStateContextJs = require("../contexts/EditorStateContext.js");
|
|
13
|
+
const _nodeViewContextJs = require("../contexts/NodeViewContext.js");
|
|
14
|
+
const _computeDocDecoJs = require("../decorations/computeDocDeco.js");
|
|
15
|
+
const _viewDecorationsJs = require("../decorations/viewDecorations.js");
|
|
16
|
+
const _useEditorJs = require("../hooks/useEditor.js");
|
|
17
|
+
const _layoutGroupJs = require("./LayoutGroup.js");
|
|
18
|
+
const _proseMirrorDocJs = require("./ProseMirrorDoc.js");
|
|
19
|
+
function _extends() {
|
|
20
|
+
_extends = Object.assign || function(target) {
|
|
21
|
+
for(var i = 1; i < arguments.length; i++){
|
|
22
|
+
var source = arguments[i];
|
|
23
|
+
for(var key in source){
|
|
24
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
25
|
+
target[key] = source[key];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return target;
|
|
30
|
+
};
|
|
31
|
+
return _extends.apply(this, arguments);
|
|
32
|
+
}
|
|
21
33
|
function _getRequireWildcardCache(nodeInterop) {
|
|
22
34
|
if (typeof WeakMap !== "function") return null;
|
|
23
35
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -26,7 +38,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
26
38
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
27
39
|
})(nodeInterop);
|
|
28
40
|
}
|
|
29
|
-
function
|
|
41
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
30
42
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
31
43
|
return obj;
|
|
32
44
|
}
|
|
@@ -39,9 +51,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
39
51
|
if (cache && cache.has(obj)) {
|
|
40
52
|
return cache.get(obj);
|
|
41
53
|
}
|
|
42
|
-
var newObj = {
|
|
43
|
-
__proto__: null
|
|
44
|
-
};
|
|
54
|
+
var newObj = {};
|
|
45
55
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
46
56
|
for(var key in obj){
|
|
47
57
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -71,9 +81,9 @@ const rootChildDescriptionsContextValue = {
|
|
|
71
81
|
}
|
|
72
82
|
};
|
|
73
83
|
function ProseMirrorInner(param) {
|
|
74
|
-
let { children, nodeViewComponents, markViewComponents, ...props } = param;
|
|
84
|
+
let { children , nodeViewComponents , markViewComponents , ...props } = param;
|
|
75
85
|
const [mount, setMount] = (0, _react.useState)(null);
|
|
76
|
-
const { editor, state
|
|
86
|
+
const { editor , state } = (0, _useEditorJs.useEditor)(mount, props);
|
|
77
87
|
const nodeViewConstructors = editor.view.nodeViews;
|
|
78
88
|
const nodeViewContextValue = (0, _react.useMemo)(()=>{
|
|
79
89
|
return {
|
|
@@ -89,8 +99,8 @@ function ProseMirrorInner(param) {
|
|
|
89
99
|
nodeViewConstructors
|
|
90
100
|
]);
|
|
91
101
|
const node = state.doc;
|
|
92
|
-
const decorations = (0,
|
|
93
|
-
const innerDecorations = (0,
|
|
102
|
+
const decorations = (0, _computeDocDecoJs.computeDocDeco)(editor.view);
|
|
103
|
+
const innerDecorations = (0, _viewDecorationsJs.viewDecorations)(editor.view, editor.cursorWrapper);
|
|
94
104
|
const docNodeViewContextValue = (0, _react.useMemo)(()=>({
|
|
95
105
|
setMount,
|
|
96
106
|
node,
|
|
@@ -102,18 +112,18 @@ function ProseMirrorInner(param) {
|
|
|
102
112
|
decorations,
|
|
103
113
|
innerDecorations
|
|
104
114
|
]);
|
|
105
|
-
return /*#__PURE__*/ _react.default.createElement(
|
|
115
|
+
return /*#__PURE__*/ _react.default.createElement(_editorContextJs.EditorContext.Provider, {
|
|
106
116
|
value: editor
|
|
107
|
-
}, /*#__PURE__*/ _react.default.createElement(
|
|
117
|
+
}, /*#__PURE__*/ _react.default.createElement(_editorStateContextJs.EditorStateContext.Provider, {
|
|
108
118
|
value: state
|
|
109
|
-
}, /*#__PURE__*/ _react.default.createElement(
|
|
119
|
+
}, /*#__PURE__*/ _react.default.createElement(_nodeViewContextJs.NodeViewContext.Provider, {
|
|
110
120
|
value: nodeViewContextValue
|
|
111
|
-
}, /*#__PURE__*/ _react.default.createElement(
|
|
121
|
+
}, /*#__PURE__*/ _react.default.createElement(_childDescriptionsContextJs.ChildDescriptionsContext.Provider, {
|
|
112
122
|
value: rootChildDescriptionsContextValue
|
|
113
|
-
}, /*#__PURE__*/ _react.default.createElement(
|
|
123
|
+
}, /*#__PURE__*/ _react.default.createElement(_proseMirrorDocJs.DocNodeViewContext.Provider, {
|
|
114
124
|
value: docNodeViewContextValue
|
|
115
125
|
}, children)))));
|
|
116
126
|
}
|
|
117
127
|
function ProseMirror(props) {
|
|
118
|
-
return /*#__PURE__*/ _react.default.createElement(
|
|
128
|
+
return /*#__PURE__*/ _react.default.createElement(_layoutGroupJs.LayoutGroup, null, /*#__PURE__*/ _react.default.createElement(ProseMirrorInner, _extends({}, props)));
|
|
119
129
|
}
|
|
@@ -9,15 +9,25 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
DocNodeViewContext:
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
ProseMirrorDoc: function() {
|
|
16
|
-
return ProseMirrorDoc;
|
|
17
|
-
}
|
|
12
|
+
DocNodeViewContext: ()=>DocNodeViewContext,
|
|
13
|
+
ProseMirrorDoc: ()=>ProseMirrorDoc
|
|
18
14
|
});
|
|
19
|
-
const _react = /*#__PURE__*/
|
|
20
|
-
const
|
|
15
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
16
|
+
const _docNodeViewJs = require("./nodes/DocNodeView.js");
|
|
17
|
+
function _extends() {
|
|
18
|
+
_extends = Object.assign || function(target) {
|
|
19
|
+
for(var i = 1; i < arguments.length; i++){
|
|
20
|
+
var source = arguments[i];
|
|
21
|
+
for(var key in source){
|
|
22
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
23
|
+
target[key] = source[key];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
29
|
+
return _extends.apply(this, arguments);
|
|
30
|
+
}
|
|
21
31
|
function _getRequireWildcardCache(nodeInterop) {
|
|
22
32
|
if (typeof WeakMap !== "function") return null;
|
|
23
33
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -26,7 +36,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
26
36
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
27
37
|
})(nodeInterop);
|
|
28
38
|
}
|
|
29
|
-
function
|
|
39
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
30
40
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
31
41
|
return obj;
|
|
32
42
|
}
|
|
@@ -39,9 +49,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
39
49
|
if (cache && cache.has(obj)) {
|
|
40
50
|
return cache.get(obj);
|
|
41
51
|
}
|
|
42
|
-
var newObj = {
|
|
43
|
-
__proto__: null
|
|
44
|
-
};
|
|
52
|
+
var newObj = {};
|
|
45
53
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
46
54
|
for(var key in obj){
|
|
47
55
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -61,12 +69,11 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
61
69
|
}
|
|
62
70
|
const DocNodeViewContext = /*#__PURE__*/ (0, _react.createContext)(null);
|
|
63
71
|
const ProseMirrorDoc = /*#__PURE__*/ (0, _react.forwardRef)(function ProseMirrorDoc(param, ref) {
|
|
64
|
-
let { as, ...props } = param;
|
|
72
|
+
let { as , ...props } = param;
|
|
65
73
|
const docProps = (0, _react.useContext)(DocNodeViewContext);
|
|
66
|
-
return /*#__PURE__*/ _react.default.createElement(
|
|
67
|
-
ref: ref
|
|
68
|
-
|
|
69
|
-
...docProps,
|
|
74
|
+
return /*#__PURE__*/ _react.default.createElement(_docNodeViewJs.DocNodeView, _extends({
|
|
75
|
+
ref: ref
|
|
76
|
+
}, props, docProps, {
|
|
70
77
|
as: as
|
|
71
|
-
});
|
|
78
|
+
}));
|
|
72
79
|
});
|
|
@@ -4,15 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "SeparatorHackView", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get:
|
|
8
|
-
return SeparatorHackView;
|
|
9
|
-
}
|
|
7
|
+
get: ()=>SeparatorHackView
|
|
10
8
|
});
|
|
11
|
-
const _react = /*#__PURE__*/
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
9
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
10
|
+
const _browserJs = require("../browser.js");
|
|
11
|
+
const _childDescriptionsContextJs = require("../contexts/ChildDescriptionsContext.js");
|
|
12
|
+
const _useClientLayoutEffectJs = require("../hooks/useClientLayoutEffect.js");
|
|
13
|
+
const _viewdescJs = require("../viewdesc.js");
|
|
16
14
|
function _getRequireWildcardCache(nodeInterop) {
|
|
17
15
|
if (typeof WeakMap !== "function") return null;
|
|
18
16
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -21,7 +19,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
21
19
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
22
20
|
})(nodeInterop);
|
|
23
21
|
}
|
|
24
|
-
function
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
25
23
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
26
24
|
return obj;
|
|
27
25
|
}
|
|
@@ -34,9 +32,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
34
32
|
if (cache && cache.has(obj)) {
|
|
35
33
|
return cache.get(obj);
|
|
36
34
|
}
|
|
37
|
-
var newObj = {
|
|
38
|
-
__proto__: null
|
|
39
|
-
};
|
|
35
|
+
var newObj = {};
|
|
40
36
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
41
37
|
for(var key in obj){
|
|
42
38
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -55,12 +51,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
55
51
|
return newObj;
|
|
56
52
|
}
|
|
57
53
|
function SeparatorHackView(param) {
|
|
58
|
-
let { getPos
|
|
59
|
-
const { siblingsRef, parentRef
|
|
54
|
+
let { getPos } = param;
|
|
55
|
+
const { siblingsRef , parentRef } = (0, _react.useContext)(_childDescriptionsContextJs.ChildDescriptionsContext);
|
|
60
56
|
const viewDescRef = (0, _react.useRef)(null);
|
|
61
57
|
const ref = (0, _react.useRef)(null);
|
|
62
58
|
const [shouldRender, setShouldRender] = (0, _react.useState)(false);
|
|
63
|
-
(0,
|
|
59
|
+
(0, _useClientLayoutEffectJs.useClientLayoutEffect)(()=>{
|
|
64
60
|
const siblings = siblingsRef.current;
|
|
65
61
|
return ()=>{
|
|
66
62
|
if (!viewDescRef.current) return;
|
|
@@ -75,15 +71,17 @@ function SeparatorHackView(param) {
|
|
|
75
71
|
// There's no risk of an infinite loop here, because
|
|
76
72
|
// we call setShouldRender conditionally
|
|
77
73
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
|
-
(0,
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
(0, _useClientLayoutEffectJs.useClientLayoutEffect)(()=>{
|
|
75
|
+
var ref1;
|
|
76
|
+
const nonHackSiblings = siblingsRef.current.filter((viewdesc)=>!(viewdesc instanceof _viewdescJs.TrailingHackViewDesc));
|
|
77
|
+
const lastSibling = nonHackSiblings[nonHackSiblings.length - 1];
|
|
78
|
+
if ((_browserJs.browser.safari || _browserJs.browser.chrome) && ((ref1 = lastSibling === null || lastSibling === void 0 ? void 0 : lastSibling.dom) === null || ref1 === void 0 ? void 0 : ref1.contentEditable) == "false") {
|
|
81
79
|
setShouldRender(true);
|
|
82
80
|
return;
|
|
83
81
|
}
|
|
84
82
|
if (!ref.current) return;
|
|
85
83
|
if (!viewDescRef.current) {
|
|
86
|
-
viewDescRef.current = new
|
|
84
|
+
viewDescRef.current = new _viewdescJs.TrailingHackViewDesc(parentRef.current, [], getPos, ref.current, null);
|
|
87
85
|
} else {
|
|
88
86
|
viewDescRef.current.parent = parentRef.current;
|
|
89
87
|
viewDescRef.current.dom = ref.current;
|
|
@@ -91,10 +89,11 @@ function SeparatorHackView(param) {
|
|
|
91
89
|
if (!siblingsRef.current.includes(viewDescRef.current)) {
|
|
92
90
|
siblingsRef.current.push(viewDescRef.current);
|
|
93
91
|
}
|
|
94
|
-
siblingsRef.current.sort(
|
|
92
|
+
siblingsRef.current.sort(_viewdescJs.sortViewDescs);
|
|
95
93
|
});
|
|
96
94
|
return shouldRender ? /*#__PURE__*/ _react.default.createElement("img", {
|
|
97
95
|
ref: ref,
|
|
98
|
-
className: "ProseMirror-separator"
|
|
96
|
+
className: "ProseMirror-separator",
|
|
97
|
+
alt: ""
|
|
99
98
|
}) : null;
|
|
100
99
|
}
|