@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,25 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "CursorWrapper", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return CursorWrapper;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _react = /*#__PURE__*/
|
|
10
|
-
const
|
|
11
|
-
const
|
|
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
|
-
}
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
+
const _dom = require("../dom.js");
|
|
13
|
+
const _useEditorEffect = require("../hooks/useEditorEffect.js");
|
|
26
14
|
function _getRequireWildcardCache(nodeInterop) {
|
|
27
15
|
if (typeof WeakMap !== "function") return null;
|
|
28
16
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -31,7 +19,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
31
19
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
32
20
|
})(nodeInterop);
|
|
33
21
|
}
|
|
34
|
-
function
|
|
22
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
35
23
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
36
24
|
return obj;
|
|
37
25
|
}
|
|
@@ -44,7 +32,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
44
32
|
if (cache && cache.has(obj)) {
|
|
45
33
|
return cache.get(obj);
|
|
46
34
|
}
|
|
47
|
-
var newObj = {
|
|
35
|
+
var newObj = {
|
|
36
|
+
__proto__: null
|
|
37
|
+
};
|
|
48
38
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
49
39
|
for(var key in obj){
|
|
50
40
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -63,13 +53,13 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
63
53
|
return newObj;
|
|
64
54
|
}
|
|
65
55
|
const CursorWrapper = /*#__PURE__*/ (0, _react.forwardRef)(function CursorWrapper(param, ref) {
|
|
66
|
-
let { widget
|
|
56
|
+
let { widget, getPos, ...props } = param;
|
|
67
57
|
const [shouldRender, setShouldRender] = (0, _react.useState)(true);
|
|
68
58
|
const innerRef = (0, _react.useRef)(null);
|
|
69
59
|
(0, _react.useImperativeHandle)(ref, ()=>{
|
|
70
60
|
return innerRef.current;
|
|
71
61
|
}, []);
|
|
72
|
-
(0,
|
|
62
|
+
(0, _useEditorEffect.useEditorEffect)((view)=>{
|
|
73
63
|
if (!view || !innerRef.current) return;
|
|
74
64
|
// @ts-expect-error Internal property - domObserver
|
|
75
65
|
view.domObserver.disconnectSelection();
|
|
@@ -79,7 +69,7 @@ const CursorWrapper = /*#__PURE__*/ (0, _react.forwardRef)(function CursorWrappe
|
|
|
79
69
|
const node = innerRef.current;
|
|
80
70
|
const img = node.nodeName == "IMG";
|
|
81
71
|
if (img && node.parentNode) {
|
|
82
|
-
range.setEnd(node.parentNode, (0,
|
|
72
|
+
range.setEnd(node.parentNode, (0, _dom.domIndex)(node) + 1);
|
|
83
73
|
} else {
|
|
84
74
|
range.setEnd(node, 0);
|
|
85
75
|
}
|
|
@@ -90,11 +80,12 @@ const CursorWrapper = /*#__PURE__*/ (0, _react.forwardRef)(function CursorWrappe
|
|
|
90
80
|
// @ts-expect-error Internal property - domObserver
|
|
91
81
|
view.domObserver.connectSelection();
|
|
92
82
|
}, []);
|
|
93
|
-
return shouldRender ? /*#__PURE__*/ _react.default.createElement("img",
|
|
83
|
+
return shouldRender ? /*#__PURE__*/ _react.default.createElement("img", {
|
|
94
84
|
ref: innerRef,
|
|
95
85
|
className: "ProseMirror-separator",
|
|
96
86
|
// eslint-disable-next-line react/no-unknown-property
|
|
97
87
|
"mark-placeholder": "true",
|
|
98
|
-
alt: ""
|
|
99
|
-
|
|
88
|
+
alt: "",
|
|
89
|
+
...props
|
|
90
|
+
}) : null;
|
|
100
91
|
});
|
|
@@ -4,12 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "LayoutGroup", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return LayoutGroup;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _react = /*#__PURE__*/
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
+
const _LayoutGroupContext = require("../contexts/LayoutGroupContext.js");
|
|
13
|
+
const _useClientLayoutEffect = require("../hooks/useClientLayoutEffect.js");
|
|
14
|
+
const _useForceUpdate = require("../hooks/useForceUpdate.js");
|
|
13
15
|
function _getRequireWildcardCache(nodeInterop) {
|
|
14
16
|
if (typeof WeakMap !== "function") return null;
|
|
15
17
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -18,7 +20,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
18
20
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
19
21
|
})(nodeInterop);
|
|
20
22
|
}
|
|
21
|
-
function
|
|
23
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
22
24
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
23
25
|
return obj;
|
|
24
26
|
}
|
|
@@ -31,7 +33,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
31
33
|
if (cache && cache.has(obj)) {
|
|
32
34
|
return cache.get(obj);
|
|
33
35
|
}
|
|
34
|
-
var newObj = {
|
|
36
|
+
var newObj = {
|
|
37
|
+
__proto__: null
|
|
38
|
+
};
|
|
35
39
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
36
40
|
for(var key in obj){
|
|
37
41
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -50,11 +54,11 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
50
54
|
return newObj;
|
|
51
55
|
}
|
|
52
56
|
function LayoutGroup(param) {
|
|
53
|
-
let { children
|
|
57
|
+
let { children } = param;
|
|
54
58
|
const createQueue = (0, _react.useRef)(new Set()).current;
|
|
55
59
|
const destroyQueue = (0, _react.useRef)(new Set()).current;
|
|
56
60
|
const isMounted = (0, _react.useRef)(false);
|
|
57
|
-
const forceUpdate = (0,
|
|
61
|
+
const forceUpdate = (0, _useForceUpdate.useForceUpdate)();
|
|
58
62
|
const isUpdatePending = (0, _react.useRef)(true);
|
|
59
63
|
const ensureFlush = (0, _react.useCallback)(()=>{
|
|
60
64
|
if (!isUpdatePending.current) {
|
|
@@ -87,7 +91,7 @@ function LayoutGroup(param) {
|
|
|
87
91
|
destroyQueue,
|
|
88
92
|
ensureFlush
|
|
89
93
|
]);
|
|
90
|
-
(0,
|
|
94
|
+
(0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
|
|
91
95
|
isUpdatePending.current = false;
|
|
92
96
|
createQueue.forEach((create)=>create());
|
|
93
97
|
createQueue.clear();
|
|
@@ -96,13 +100,13 @@ function LayoutGroup(param) {
|
|
|
96
100
|
destroyQueue.clear();
|
|
97
101
|
};
|
|
98
102
|
});
|
|
99
|
-
(0,
|
|
103
|
+
(0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
|
|
100
104
|
isMounted.current = true;
|
|
101
105
|
return ()=>{
|
|
102
106
|
isMounted.current = false;
|
|
103
107
|
};
|
|
104
108
|
}, []);
|
|
105
|
-
return /*#__PURE__*/ _react.default.createElement(
|
|
109
|
+
return /*#__PURE__*/ _react.default.createElement(_LayoutGroupContext.LayoutGroupContext.Provider, {
|
|
106
110
|
value: register
|
|
107
111
|
}, children);
|
|
108
112
|
}
|
|
@@ -4,13 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "NativeWidgetView", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return NativeWidgetView;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _react = /*#__PURE__*/
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
+
const _ChildDescriptionsContext = require("../contexts/ChildDescriptionsContext.js");
|
|
13
|
+
const _useClientLayoutEffect = require("../hooks/useClientLayoutEffect.js");
|
|
14
|
+
const _useEditorEffect = require("../hooks/useEditorEffect.js");
|
|
15
|
+
const _viewdesc = require("../viewdesc.js");
|
|
14
16
|
function _getRequireWildcardCache(nodeInterop) {
|
|
15
17
|
if (typeof WeakMap !== "function") return null;
|
|
16
18
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -19,7 +21,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
19
21
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
20
22
|
})(nodeInterop);
|
|
21
23
|
}
|
|
22
|
-
function
|
|
24
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
23
25
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
24
26
|
return obj;
|
|
25
27
|
}
|
|
@@ -32,7 +34,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
32
34
|
if (cache && cache.has(obj)) {
|
|
33
35
|
return cache.get(obj);
|
|
34
36
|
}
|
|
35
|
-
var newObj = {
|
|
37
|
+
var newObj = {
|
|
38
|
+
__proto__: null
|
|
39
|
+
};
|
|
36
40
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
37
41
|
for(var key in obj){
|
|
38
42
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -51,11 +55,11 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
51
55
|
return newObj;
|
|
52
56
|
}
|
|
53
57
|
function NativeWidgetView(param) {
|
|
54
|
-
let { widget
|
|
55
|
-
const { siblingsRef
|
|
58
|
+
let { widget, getPos } = param;
|
|
59
|
+
const { siblingsRef, parentRef } = (0, _react.useContext)(_ChildDescriptionsContext.ChildDescriptionsContext);
|
|
56
60
|
const viewDescRef = (0, _react.useRef)(null);
|
|
57
61
|
const rootDomRef = (0, _react.useRef)(null);
|
|
58
|
-
(0,
|
|
62
|
+
(0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
|
|
59
63
|
const siblings = siblingsRef.current;
|
|
60
64
|
return ()=>{
|
|
61
65
|
if (!viewDescRef.current) return;
|
|
@@ -67,7 +71,7 @@ function NativeWidgetView(param) {
|
|
|
67
71
|
}, [
|
|
68
72
|
siblingsRef
|
|
69
73
|
]);
|
|
70
|
-
(0,
|
|
74
|
+
(0, _useEditorEffect.useEditorEffect)((view)=>{
|
|
71
75
|
if (!rootDomRef.current) return;
|
|
72
76
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
77
|
const toDOM = widget.type.toDOM;
|
|
@@ -85,10 +89,10 @@ function NativeWidgetView(param) {
|
|
|
85
89
|
if (rootDomRef.current.firstElementChild === dom) return;
|
|
86
90
|
rootDomRef.current.replaceChildren(dom);
|
|
87
91
|
});
|
|
88
|
-
(0,
|
|
92
|
+
(0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
|
|
89
93
|
if (!rootDomRef.current) return;
|
|
90
94
|
if (!viewDescRef.current) {
|
|
91
|
-
viewDescRef.current = new
|
|
95
|
+
viewDescRef.current = new _viewdesc.WidgetViewDesc(parentRef.current, getPos, widget, rootDomRef.current);
|
|
92
96
|
} else {
|
|
93
97
|
viewDescRef.current.parent = parentRef.current;
|
|
94
98
|
viewDescRef.current.widget = widget;
|
|
@@ -97,7 +101,7 @@ function NativeWidgetView(param) {
|
|
|
97
101
|
if (!siblingsRef.current.includes(viewDescRef.current)) {
|
|
98
102
|
siblingsRef.current.push(viewDescRef.current);
|
|
99
103
|
}
|
|
100
|
-
siblingsRef.current.sort(
|
|
104
|
+
siblingsRef.current.sort(_viewdesc.sortViewDescs);
|
|
101
105
|
});
|
|
102
106
|
return /*#__PURE__*/ _react.default.createElement("span", {
|
|
103
107
|
ref: rootDomRef
|
|
@@ -4,11 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "OutputSpec", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return ForwardedOutputSpec;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _react = /*#__PURE__*/
|
|
10
|
-
const
|
|
11
|
-
const
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
+
const _props = require("../props.js");
|
|
13
|
+
const _refs = require("../refs.js");
|
|
12
14
|
function _getRequireWildcardCache(nodeInterop) {
|
|
13
15
|
if (typeof WeakMap !== "function") return null;
|
|
14
16
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -17,7 +19,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
17
19
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
18
20
|
})(nodeInterop);
|
|
19
21
|
}
|
|
20
|
-
function
|
|
22
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
21
23
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
22
24
|
return obj;
|
|
23
25
|
}
|
|
@@ -30,7 +32,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
30
32
|
if (cache && cache.has(obj)) {
|
|
31
33
|
return cache.get(obj);
|
|
32
34
|
}
|
|
33
|
-
var newObj = {
|
|
35
|
+
var newObj = {
|
|
36
|
+
__proto__: null
|
|
37
|
+
};
|
|
34
38
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
35
39
|
for(var key in obj){
|
|
36
40
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -69,8 +73,8 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
69
73
|
return false;
|
|
70
74
|
}
|
|
71
75
|
const ForwardedOutputSpec = /*#__PURE__*/ (0, _react.memo)(/*#__PURE__*/ (0, _react.forwardRef)(function OutputSpec(param, ref) {
|
|
72
|
-
let { outputSpec
|
|
73
|
-
const mergedRef = (0,
|
|
76
|
+
let { outputSpec, isMark, contentDOMRef, children, ...propOverrides } = param;
|
|
77
|
+
const mergedRef = (0, _refs.useMergedDOMRefs)(ref, contentDOMRef);
|
|
74
78
|
if (typeof outputSpec === "string") {
|
|
75
79
|
return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, outputSpec);
|
|
76
80
|
}
|
|
@@ -87,7 +91,7 @@ const ForwardedOutputSpec = /*#__PURE__*/ (0, _react.memo)(/*#__PURE__*/ (0, _re
|
|
|
87
91
|
let start = 1;
|
|
88
92
|
if (attrs && typeof attrs === "object" && attrs.nodeType == null && !Array.isArray(attrs)) {
|
|
89
93
|
start = 2;
|
|
90
|
-
props = (0,
|
|
94
|
+
props = (0, _props.mergeReactProps)((0, _props.htmlAttrsToReactProps)(attrs), props);
|
|
91
95
|
}
|
|
92
96
|
const content = [];
|
|
93
97
|
for(let i = start; i < outputSpec.length; i++){
|
|
@@ -4,32 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "ProseMirror", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return ProseMirror;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _react = /*#__PURE__*/
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
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
|
-
}
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
+
const _ChildDescriptionsContext = require("../contexts/ChildDescriptionsContext.js");
|
|
13
|
+
const _EditorContext = require("../contexts/EditorContext.js");
|
|
14
|
+
const _EditorStateContext = require("../contexts/EditorStateContext.js");
|
|
15
|
+
const _NodeViewContext = require("../contexts/NodeViewContext.js");
|
|
16
|
+
const _computeDocDeco = require("../decorations/computeDocDeco.js");
|
|
17
|
+
const _viewDecorations = require("../decorations/viewDecorations.js");
|
|
18
|
+
const _useEditor = require("../hooks/useEditor.js");
|
|
19
|
+
const _LayoutGroup = require("./LayoutGroup.js");
|
|
20
|
+
const _ProseMirrorDoc = require("./ProseMirrorDoc.js");
|
|
33
21
|
function _getRequireWildcardCache(nodeInterop) {
|
|
34
22
|
if (typeof WeakMap !== "function") return null;
|
|
35
23
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -38,7 +26,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
38
26
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
39
27
|
})(nodeInterop);
|
|
40
28
|
}
|
|
41
|
-
function
|
|
29
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
42
30
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
43
31
|
return obj;
|
|
44
32
|
}
|
|
@@ -51,7 +39,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
51
39
|
if (cache && cache.has(obj)) {
|
|
52
40
|
return cache.get(obj);
|
|
53
41
|
}
|
|
54
|
-
var newObj = {
|
|
42
|
+
var newObj = {
|
|
43
|
+
__proto__: null
|
|
44
|
+
};
|
|
55
45
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
56
46
|
for(var key in obj){
|
|
57
47
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -81,9 +71,9 @@ const rootChildDescriptionsContextValue = {
|
|
|
81
71
|
}
|
|
82
72
|
};
|
|
83
73
|
function ProseMirrorInner(param) {
|
|
84
|
-
let { children
|
|
74
|
+
let { children, nodeViewComponents, markViewComponents, ...props } = param;
|
|
85
75
|
const [mount, setMount] = (0, _react.useState)(null);
|
|
86
|
-
const { editor
|
|
76
|
+
const { editor, state } = (0, _useEditor.useEditor)(mount, props);
|
|
87
77
|
const nodeViewConstructors = editor.view.nodeViews;
|
|
88
78
|
const nodeViewContextValue = (0, _react.useMemo)(()=>{
|
|
89
79
|
return {
|
|
@@ -99,8 +89,8 @@ function ProseMirrorInner(param) {
|
|
|
99
89
|
nodeViewConstructors
|
|
100
90
|
]);
|
|
101
91
|
const node = state.doc;
|
|
102
|
-
const decorations = (0,
|
|
103
|
-
const innerDecorations = (0,
|
|
92
|
+
const decorations = (0, _computeDocDeco.computeDocDeco)(editor.view);
|
|
93
|
+
const innerDecorations = (0, _viewDecorations.viewDecorations)(editor.view, editor.cursorWrapper);
|
|
104
94
|
const docNodeViewContextValue = (0, _react.useMemo)(()=>({
|
|
105
95
|
setMount,
|
|
106
96
|
node,
|
|
@@ -112,18 +102,18 @@ function ProseMirrorInner(param) {
|
|
|
112
102
|
decorations,
|
|
113
103
|
innerDecorations
|
|
114
104
|
]);
|
|
115
|
-
return /*#__PURE__*/ _react.default.createElement(
|
|
105
|
+
return /*#__PURE__*/ _react.default.createElement(_EditorContext.EditorContext.Provider, {
|
|
116
106
|
value: editor
|
|
117
|
-
}, /*#__PURE__*/ _react.default.createElement(
|
|
107
|
+
}, /*#__PURE__*/ _react.default.createElement(_EditorStateContext.EditorStateContext.Provider, {
|
|
118
108
|
value: state
|
|
119
|
-
}, /*#__PURE__*/ _react.default.createElement(
|
|
109
|
+
}, /*#__PURE__*/ _react.default.createElement(_NodeViewContext.NodeViewContext.Provider, {
|
|
120
110
|
value: nodeViewContextValue
|
|
121
|
-
}, /*#__PURE__*/ _react.default.createElement(
|
|
111
|
+
}, /*#__PURE__*/ _react.default.createElement(_ChildDescriptionsContext.ChildDescriptionsContext.Provider, {
|
|
122
112
|
value: rootChildDescriptionsContextValue
|
|
123
|
-
}, /*#__PURE__*/ _react.default.createElement(
|
|
113
|
+
}, /*#__PURE__*/ _react.default.createElement(_ProseMirrorDoc.DocNodeViewContext.Provider, {
|
|
124
114
|
value: docNodeViewContextValue
|
|
125
115
|
}, children)))));
|
|
126
116
|
}
|
|
127
117
|
function ProseMirror(props) {
|
|
128
|
-
return /*#__PURE__*/ _react.default.createElement(
|
|
118
|
+
return /*#__PURE__*/ _react.default.createElement(_LayoutGroup.LayoutGroup, null, /*#__PURE__*/ _react.default.createElement(ProseMirrorInner, props));
|
|
129
119
|
}
|
|
@@ -9,25 +9,15 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
DocNodeViewContext: ()
|
|
13
|
-
|
|
12
|
+
DocNodeViewContext: function() {
|
|
13
|
+
return DocNodeViewContext;
|
|
14
|
+
},
|
|
15
|
+
ProseMirrorDoc: function() {
|
|
16
|
+
return ProseMirrorDoc;
|
|
17
|
+
}
|
|
14
18
|
});
|
|
15
|
-
const _react = /*#__PURE__*/
|
|
16
|
-
const
|
|
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
|
-
}
|
|
19
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
20
|
+
const _DocNodeView = require("./nodes/DocNodeView.js");
|
|
31
21
|
function _getRequireWildcardCache(nodeInterop) {
|
|
32
22
|
if (typeof WeakMap !== "function") return null;
|
|
33
23
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -36,7 +26,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
36
26
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
37
27
|
})(nodeInterop);
|
|
38
28
|
}
|
|
39
|
-
function
|
|
29
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
40
30
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
41
31
|
return obj;
|
|
42
32
|
}
|
|
@@ -49,7 +39,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
49
39
|
if (cache && cache.has(obj)) {
|
|
50
40
|
return cache.get(obj);
|
|
51
41
|
}
|
|
52
|
-
var newObj = {
|
|
42
|
+
var newObj = {
|
|
43
|
+
__proto__: null
|
|
44
|
+
};
|
|
53
45
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
54
46
|
for(var key in obj){
|
|
55
47
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -69,11 +61,12 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
69
61
|
}
|
|
70
62
|
const DocNodeViewContext = /*#__PURE__*/ (0, _react.createContext)(null);
|
|
71
63
|
const ProseMirrorDoc = /*#__PURE__*/ (0, _react.forwardRef)(function ProseMirrorDoc(param, ref) {
|
|
72
|
-
let { as
|
|
64
|
+
let { as, ...props } = param;
|
|
73
65
|
const docProps = (0, _react.useContext)(DocNodeViewContext);
|
|
74
|
-
return /*#__PURE__*/ _react.default.createElement(
|
|
75
|
-
ref: ref
|
|
76
|
-
|
|
66
|
+
return /*#__PURE__*/ _react.default.createElement(_DocNodeView.DocNodeView, {
|
|
67
|
+
ref: ref,
|
|
68
|
+
...props,
|
|
69
|
+
...docProps,
|
|
77
70
|
as: as
|
|
78
|
-
})
|
|
71
|
+
});
|
|
79
72
|
});
|
|
@@ -4,13 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "SeparatorHackView", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return SeparatorHackView;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const _react = /*#__PURE__*/
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
+
const _browser = require("../browser.js");
|
|
13
|
+
const _ChildDescriptionsContext = require("../contexts/ChildDescriptionsContext.js");
|
|
14
|
+
const _useClientLayoutEffect = require("../hooks/useClientLayoutEffect.js");
|
|
15
|
+
const _viewdesc = require("../viewdesc.js");
|
|
14
16
|
function _getRequireWildcardCache(nodeInterop) {
|
|
15
17
|
if (typeof WeakMap !== "function") return null;
|
|
16
18
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -19,7 +21,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
19
21
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
20
22
|
})(nodeInterop);
|
|
21
23
|
}
|
|
22
|
-
function
|
|
24
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
23
25
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
24
26
|
return obj;
|
|
25
27
|
}
|
|
@@ -32,7 +34,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
32
34
|
if (cache && cache.has(obj)) {
|
|
33
35
|
return cache.get(obj);
|
|
34
36
|
}
|
|
35
|
-
var newObj = {
|
|
37
|
+
var newObj = {
|
|
38
|
+
__proto__: null
|
|
39
|
+
};
|
|
36
40
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
37
41
|
for(var key in obj){
|
|
38
42
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -51,12 +55,12 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
51
55
|
return newObj;
|
|
52
56
|
}
|
|
53
57
|
function SeparatorHackView(param) {
|
|
54
|
-
let { getPos
|
|
55
|
-
const { siblingsRef
|
|
58
|
+
let { getPos } = param;
|
|
59
|
+
const { siblingsRef, parentRef } = (0, _react.useContext)(_ChildDescriptionsContext.ChildDescriptionsContext);
|
|
56
60
|
const viewDescRef = (0, _react.useRef)(null);
|
|
57
61
|
const ref = (0, _react.useRef)(null);
|
|
58
62
|
const [shouldRender, setShouldRender] = (0, _react.useState)(false);
|
|
59
|
-
(0,
|
|
63
|
+
(0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
|
|
60
64
|
const siblings = siblingsRef.current;
|
|
61
65
|
return ()=>{
|
|
62
66
|
if (!viewDescRef.current) return;
|
|
@@ -71,17 +75,16 @@ function SeparatorHackView(param) {
|
|
|
71
75
|
// There's no risk of an infinite loop here, because
|
|
72
76
|
// we call setShouldRender conditionally
|
|
73
77
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
74
|
-
(0,
|
|
75
|
-
|
|
76
|
-
const nonHackSiblings = siblingsRef.current.filter((viewdesc)=>!(viewdesc instanceof _viewdescJs.TrailingHackViewDesc));
|
|
78
|
+
(0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
|
|
79
|
+
const nonHackSiblings = siblingsRef.current.filter((viewdesc)=>!(viewdesc instanceof _viewdesc.TrailingHackViewDesc));
|
|
77
80
|
const lastSibling = nonHackSiblings[nonHackSiblings.length - 1];
|
|
78
|
-
if ((
|
|
81
|
+
if ((_browser.browser.safari || _browser.browser.chrome) && lastSibling?.dom?.contentEditable == "false") {
|
|
79
82
|
setShouldRender(true);
|
|
80
83
|
return;
|
|
81
84
|
}
|
|
82
85
|
if (!ref.current) return;
|
|
83
86
|
if (!viewDescRef.current) {
|
|
84
|
-
viewDescRef.current = new
|
|
87
|
+
viewDescRef.current = new _viewdesc.TrailingHackViewDesc(parentRef.current, [], getPos, ref.current, null);
|
|
85
88
|
} else {
|
|
86
89
|
viewDescRef.current.parent = parentRef.current;
|
|
87
90
|
viewDescRef.current.dom = ref.current;
|
|
@@ -89,7 +92,7 @@ function SeparatorHackView(param) {
|
|
|
89
92
|
if (!siblingsRef.current.includes(viewDescRef.current)) {
|
|
90
93
|
siblingsRef.current.push(viewDescRef.current);
|
|
91
94
|
}
|
|
92
|
-
siblingsRef.current.sort(
|
|
95
|
+
siblingsRef.current.sort(_viewdesc.sortViewDescs);
|
|
93
96
|
});
|
|
94
97
|
return shouldRender ? /*#__PURE__*/ _react.default.createElement("img", {
|
|
95
98
|
ref: ref,
|