@handlewithcare/react-prosemirror 3.1.0-tiptap.36 → 3.1.0-tiptap.38
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/dist/cjs/tiptap/tiptapNodeView.js +10 -9
- package/dist/esm/tiptap/tiptapNodeView.js +10 -9
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/constants.d.ts +1 -1
- package/dist/types/props.d.ts +26 -26
- package/dist/types/tiptap/tiptapNodeView.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/components/CustomNodeView.js +0 -132
- package/dist/cjs/components/DefaultNodeView.js +0 -67
- package/dist/cjs/components/DocNodeView.js +0 -96
- package/dist/cjs/components/MarkView.js +0 -119
- package/dist/cjs/components/NodeView.js +0 -86
- package/dist/cjs/components/NodeViewComponentProps.js +0 -4
- package/dist/cjs/components/ReactNodeView.js +0 -174
- package/dist/cjs/components/marks/CustomMarkView.js +0 -110
- package/dist/cjs/components/marks/OldMarkView.js +0 -120
- package/dist/cjs/components/nodes/CustomNodeView.js +0 -135
- package/dist/cjs/contexts/ChildDescriptorsContext.js +0 -19
- package/dist/cjs/hooks/useNodeViewDescriptor.js +0 -156
- package/dist/cjs/tiptap/TiptapNodeView.js +0 -26
- package/dist/esm/components/CustomNodeView.js +0 -81
- package/dist/esm/components/DefaultNodeView.js +0 -16
- package/dist/esm/components/DocNodeView.js +0 -45
- package/dist/esm/components/MarkView.js +0 -68
- package/dist/esm/components/NodeView.js +0 -35
- package/dist/esm/components/NodeViewComponentProps.js +0 -1
- package/dist/esm/components/ReactNodeView.js +0 -123
- package/dist/esm/components/marks/CustomMarkView.js +0 -59
- package/dist/esm/components/marks/OldMarkView.js +0 -69
- package/dist/esm/components/nodes/CustomNodeView.js +0 -84
- package/dist/esm/contexts/ChildDescriptorsContext.js +0 -9
- package/dist/esm/hooks/useNodeViewDescriptor.js +0 -146
- package/dist/esm/tiptap/TiptapNodeView.js +0 -22
- package/dist/types/components/CustomNodeView.d.ts +0 -12
- package/dist/types/components/DefaultNodeView.d.ts +0 -3
- package/dist/types/components/DocNodeView.d.ts +0 -12
- package/dist/types/components/MarkView.d.ts +0 -9
- package/dist/types/components/NodeView.d.ts +0 -11
- package/dist/types/components/NodeViewComponentProps.d.ts +0 -12
- package/dist/types/components/ReactNodeView.d.ts +0 -13
- package/dist/types/components/marks/CustomMarkView.d.ts +0 -12
- package/dist/types/components/marks/OldMarkView.d.ts +0 -10
- package/dist/types/components/nodes/CustomNodeView.d.ts +0 -12
- package/dist/types/contexts/ChildDescriptorsContext.d.ts +0 -6
- package/dist/types/hooks/useNodeViewDescriptor.d.ts +0 -20
- package/dist/types/tiptap/TiptapNodeView.d.ts +0 -15
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Schema } from "prosemirror-model";
|
|
2
2
|
import { EditorState } from "prosemirror-state";
|
|
3
|
-
export declare const EMPTY_SCHEMA: Schema<"
|
|
3
|
+
export declare const EMPTY_SCHEMA: Schema<"doc" | "text", any>;
|
|
4
4
|
export declare const EMPTY_STATE: EditorState;
|
package/dist/types/props.d.ts
CHANGED
|
@@ -904,19 +904,19 @@ export declare function mergeReactProps(a: HTMLProps<HTMLElement>, b: HTMLProps<
|
|
|
904
904
|
suppressContentEditableWarning?: boolean | undefined;
|
|
905
905
|
suppressHydrationWarning?: boolean | undefined;
|
|
906
906
|
accessKey?: string | undefined;
|
|
907
|
-
autoCapitalize?: "
|
|
907
|
+
autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | (string & {}) | undefined;
|
|
908
908
|
autoFocus?: boolean | undefined;
|
|
909
|
-
contentEditable?: (boolean | "
|
|
909
|
+
contentEditable?: (boolean | "false" | "true") | "inherit" | "plaintext-only" | undefined;
|
|
910
910
|
contextMenu?: string | undefined;
|
|
911
911
|
dir?: string | undefined;
|
|
912
|
-
draggable?: (boolean | "
|
|
913
|
-
enterKeyHint?: "
|
|
912
|
+
draggable?: (boolean | "false" | "true") | undefined;
|
|
913
|
+
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
|
|
914
914
|
hidden?: boolean | undefined;
|
|
915
915
|
id?: string | undefined;
|
|
916
916
|
lang?: string | undefined;
|
|
917
917
|
nonce?: string | undefined;
|
|
918
918
|
slot?: string | undefined;
|
|
919
|
-
spellCheck?: (boolean | "
|
|
919
|
+
spellCheck?: (boolean | "false" | "true") | undefined;
|
|
920
920
|
tabIndex?: number | undefined;
|
|
921
921
|
title?: string | undefined;
|
|
922
922
|
translate?: "yes" | "no" | undefined;
|
|
@@ -944,57 +944,57 @@ export declare function mergeReactProps(a: HTMLProps<HTMLElement>, b: HTMLProps<
|
|
|
944
944
|
results?: number | undefined;
|
|
945
945
|
security?: string | undefined;
|
|
946
946
|
unselectable?: "off" | "on" | undefined;
|
|
947
|
-
inputMode?: "
|
|
947
|
+
inputMode?: "text" | "none" | "search" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined;
|
|
948
948
|
is?: string | undefined;
|
|
949
949
|
exportparts?: string | undefined;
|
|
950
950
|
part?: string | undefined;
|
|
951
951
|
"aria-activedescendant"?: string | undefined;
|
|
952
|
-
"aria-atomic"?: (boolean | "
|
|
953
|
-
"aria-autocomplete"?: "
|
|
952
|
+
"aria-atomic"?: (boolean | "false" | "true") | undefined;
|
|
953
|
+
"aria-autocomplete"?: "none" | "list" | "inline" | "both" | undefined;
|
|
954
954
|
"aria-braillelabel"?: string | undefined;
|
|
955
955
|
"aria-brailleroledescription"?: string | undefined;
|
|
956
|
-
"aria-busy"?: (boolean | "
|
|
957
|
-
"aria-checked"?: boolean | "
|
|
956
|
+
"aria-busy"?: (boolean | "false" | "true") | undefined;
|
|
957
|
+
"aria-checked"?: boolean | "false" | "true" | "mixed" | undefined;
|
|
958
958
|
"aria-colcount"?: number | undefined;
|
|
959
959
|
"aria-colindex"?: number | undefined;
|
|
960
960
|
"aria-colindextext"?: string | undefined;
|
|
961
961
|
"aria-colspan"?: number | undefined;
|
|
962
962
|
"aria-controls"?: string | undefined;
|
|
963
|
-
"aria-current"?: boolean | "
|
|
963
|
+
"aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined;
|
|
964
964
|
"aria-describedby"?: string | undefined;
|
|
965
965
|
"aria-description"?: string | undefined;
|
|
966
966
|
"aria-details"?: string | undefined;
|
|
967
|
-
"aria-disabled"?: (boolean | "
|
|
968
|
-
"aria-dropeffect"?: "
|
|
967
|
+
"aria-disabled"?: (boolean | "false" | "true") | undefined;
|
|
968
|
+
"aria-dropeffect"?: "none" | "link" | "copy" | "execute" | "move" | "popup" | undefined;
|
|
969
969
|
"aria-errormessage"?: string | undefined;
|
|
970
|
-
"aria-expanded"?: (boolean | "
|
|
970
|
+
"aria-expanded"?: (boolean | "false" | "true") | undefined;
|
|
971
971
|
"aria-flowto"?: string | undefined;
|
|
972
|
-
"aria-grabbed"?: (boolean | "
|
|
973
|
-
"aria-haspopup"?: boolean | "
|
|
974
|
-
"aria-hidden"?: (boolean | "
|
|
975
|
-
"aria-invalid"?: boolean | "
|
|
972
|
+
"aria-grabbed"?: (boolean | "false" | "true") | undefined;
|
|
973
|
+
"aria-haspopup"?: boolean | "false" | "true" | "dialog" | "grid" | "listbox" | "menu" | "tree" | undefined;
|
|
974
|
+
"aria-hidden"?: (boolean | "false" | "true") | undefined;
|
|
975
|
+
"aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
|
|
976
976
|
"aria-keyshortcuts"?: string | undefined;
|
|
977
977
|
"aria-label"?: string | undefined;
|
|
978
978
|
"aria-labelledby"?: string | undefined;
|
|
979
979
|
"aria-level"?: number | undefined;
|
|
980
980
|
"aria-live"?: "off" | "assertive" | "polite" | undefined;
|
|
981
|
-
"aria-modal"?: (boolean | "
|
|
982
|
-
"aria-multiline"?: (boolean | "
|
|
983
|
-
"aria-multiselectable"?: (boolean | "
|
|
981
|
+
"aria-modal"?: (boolean | "false" | "true") | undefined;
|
|
982
|
+
"aria-multiline"?: (boolean | "false" | "true") | undefined;
|
|
983
|
+
"aria-multiselectable"?: (boolean | "false" | "true") | undefined;
|
|
984
984
|
"aria-orientation"?: "horizontal" | "vertical" | undefined;
|
|
985
985
|
"aria-owns"?: string | undefined;
|
|
986
986
|
"aria-placeholder"?: string | undefined;
|
|
987
987
|
"aria-posinset"?: number | undefined;
|
|
988
|
-
"aria-pressed"?: boolean | "
|
|
989
|
-
"aria-readonly"?: (boolean | "
|
|
990
|
-
"aria-relevant"?: "text" | "
|
|
991
|
-
"aria-required"?: (boolean | "
|
|
988
|
+
"aria-pressed"?: boolean | "false" | "true" | "mixed" | undefined;
|
|
989
|
+
"aria-readonly"?: (boolean | "false" | "true") | undefined;
|
|
990
|
+
"aria-relevant"?: "text" | "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals" | undefined;
|
|
991
|
+
"aria-required"?: (boolean | "false" | "true") | undefined;
|
|
992
992
|
"aria-roledescription"?: string | undefined;
|
|
993
993
|
"aria-rowcount"?: number | undefined;
|
|
994
994
|
"aria-rowindex"?: number | undefined;
|
|
995
995
|
"aria-rowindextext"?: string | undefined;
|
|
996
996
|
"aria-rowspan"?: number | undefined;
|
|
997
|
-
"aria-selected"?: (boolean | "
|
|
997
|
+
"aria-selected"?: (boolean | "false" | "true") | undefined;
|
|
998
998
|
"aria-setsize"?: number | undefined;
|
|
999
999
|
"aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
|
|
1000
1000
|
"aria-valuemax"?: number | undefined;
|
package/package.json
CHANGED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "CustomNodeView", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return CustomNodeView;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _prosemirrormodel = require("prosemirror-model");
|
|
12
|
-
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
13
|
-
const _reactdom = require("react-dom");
|
|
14
|
-
const _ChildDescriptorsContext = require("../contexts/ChildDescriptorsContext.js");
|
|
15
|
-
const _useNodeViewDescriptor = require("../hooks/useNodeViewDescriptor.js");
|
|
16
|
-
const _ChildNodeViews = require("./ChildNodeViews.js");
|
|
17
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
18
|
-
if (typeof WeakMap !== "function") return null;
|
|
19
|
-
var cacheBabelInterop = new WeakMap();
|
|
20
|
-
var cacheNodeInterop = new WeakMap();
|
|
21
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
22
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
23
|
-
})(nodeInterop);
|
|
24
|
-
}
|
|
25
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
26
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
27
|
-
return obj;
|
|
28
|
-
}
|
|
29
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
30
|
-
return {
|
|
31
|
-
default: obj
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
35
|
-
if (cache && cache.has(obj)) {
|
|
36
|
-
return cache.get(obj);
|
|
37
|
-
}
|
|
38
|
-
var newObj = {
|
|
39
|
-
__proto__: null
|
|
40
|
-
};
|
|
41
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
42
|
-
for(var key in obj){
|
|
43
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
44
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
45
|
-
if (desc && (desc.get || desc.set)) {
|
|
46
|
-
Object.defineProperty(newObj, key, desc);
|
|
47
|
-
} else {
|
|
48
|
-
newObj[key] = obj[key];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
newObj.default = obj;
|
|
53
|
-
if (cache) {
|
|
54
|
-
cache.set(obj, newObj);
|
|
55
|
-
}
|
|
56
|
-
return newObj;
|
|
57
|
-
}
|
|
58
|
-
const CustomNodeView = /*#__PURE__*/ (0, _react.memo)(function CustomNodeView(param) {
|
|
59
|
-
let { constructor, node, getPos, innerDeco, outerDeco } = param;
|
|
60
|
-
const ref = (0, _react.useRef)(null);
|
|
61
|
-
const innerRef = (0, _react.useRef)(null);
|
|
62
|
-
const nodeProps = (0, _react.useMemo)(()=>({
|
|
63
|
-
node,
|
|
64
|
-
getPos,
|
|
65
|
-
decorations: outerDeco,
|
|
66
|
-
innerDecorations: innerDeco
|
|
67
|
-
}), [
|
|
68
|
-
node,
|
|
69
|
-
getPos,
|
|
70
|
-
outerDeco,
|
|
71
|
-
innerDeco
|
|
72
|
-
]);
|
|
73
|
-
const createNodeView = function() {
|
|
74
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
75
|
-
args[_key] = arguments[_key];
|
|
76
|
-
}
|
|
77
|
-
const nodeView = constructor(...args);
|
|
78
|
-
if (!nodeView || !nodeView.dom) {
|
|
79
|
-
const spec = node.type.spec.toDOM?.(node);
|
|
80
|
-
if (!spec) {
|
|
81
|
-
throw new Error(`Node spec for ${node.type.name} is missing toDOM`);
|
|
82
|
-
}
|
|
83
|
-
return _prosemirrormodel.DOMSerializer.renderSpec(document, spec, null);
|
|
84
|
-
}
|
|
85
|
-
return nodeView;
|
|
86
|
-
};
|
|
87
|
-
const { childContextValue, contentDOM } = (0, _useNodeViewDescriptor.useNodeViewDescriptor)(ref, function() {
|
|
88
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
89
|
-
args[_key] = arguments[_key];
|
|
90
|
-
}
|
|
91
|
-
const nodeView = createNodeView(...args);
|
|
92
|
-
const contentDOM = nodeView.contentDOM;
|
|
93
|
-
const nodeDOM = nodeView.dom;
|
|
94
|
-
const wrapperDOM = innerRef.current ?? ref.current;
|
|
95
|
-
wrapperDOM.appendChild(nodeDOM);
|
|
96
|
-
if (!contentDOM && nodeDOM instanceof HTMLElement && nodeDOM.tagName !== "BR") {
|
|
97
|
-
if (!nodeDOM.hasAttribute("contenteditable")) {
|
|
98
|
-
nodeDOM.contentEditable = "false";
|
|
99
|
-
}
|
|
100
|
-
if (node.type.spec.draggable) {
|
|
101
|
-
nodeDOM.draggable = true;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return {
|
|
105
|
-
...nodeView,
|
|
106
|
-
destroy () {
|
|
107
|
-
if (nodeView.destroy) {
|
|
108
|
-
nodeView.destroy();
|
|
109
|
-
}
|
|
110
|
-
wrapperDOM.removeChild(nodeDOM);
|
|
111
|
-
},
|
|
112
|
-
selectNode: nodeView.selectNode?.bind(nodeView),
|
|
113
|
-
deselectNode: nodeView.deselectNode?.bind(nodeView),
|
|
114
|
-
stopEvent: nodeView.stopEvent?.bind(nodeView),
|
|
115
|
-
ignoreMutation: nodeView.ignoreMutation?.bind(nodeView)
|
|
116
|
-
};
|
|
117
|
-
}, nodeProps);
|
|
118
|
-
const Component = node.isInline ? "span" : "div";
|
|
119
|
-
const props = {
|
|
120
|
-
ref: innerRef
|
|
121
|
-
};
|
|
122
|
-
const children = !node.isLeaf && contentDOM ? /*#__PURE__*/ (0, _reactdom.createPortal)(/*#__PURE__*/ _react.default.createElement(_ChildDescriptorsContext.ChildDescriptorsContext.Provider, {
|
|
123
|
-
value: childContextValue
|
|
124
|
-
}, /*#__PURE__*/ _react.default.createElement(_ChildNodeViews.ChildNodeViews, {
|
|
125
|
-
getPos: getPos,
|
|
126
|
-
node: node,
|
|
127
|
-
innerDecorations: innerDeco
|
|
128
|
-
})), contentDOM) : null;
|
|
129
|
-
return /*#__PURE__*/ (0, _react.cloneElement)(outerDeco.reduce(_ChildNodeViews.wrapInDeco, /*#__PURE__*/ _react.default.createElement(Component, props, children)), {
|
|
130
|
-
ref
|
|
131
|
-
});
|
|
132
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "DefaultNodeView", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return DefaultNodeView;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
-
const _OutputSpec = require("./OutputSpec.js");
|
|
13
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
14
|
-
if (typeof WeakMap !== "function") return null;
|
|
15
|
-
var cacheBabelInterop = new WeakMap();
|
|
16
|
-
var cacheNodeInterop = new WeakMap();
|
|
17
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
18
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
19
|
-
})(nodeInterop);
|
|
20
|
-
}
|
|
21
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
22
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
23
|
-
return obj;
|
|
24
|
-
}
|
|
25
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
26
|
-
return {
|
|
27
|
-
default: obj
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
31
|
-
if (cache && cache.has(obj)) {
|
|
32
|
-
return cache.get(obj);
|
|
33
|
-
}
|
|
34
|
-
var newObj = {
|
|
35
|
-
__proto__: null
|
|
36
|
-
};
|
|
37
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
38
|
-
for(var key in obj){
|
|
39
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
40
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
41
|
-
if (desc && (desc.get || desc.set)) {
|
|
42
|
-
Object.defineProperty(newObj, key, desc);
|
|
43
|
-
} else {
|
|
44
|
-
newObj[key] = obj[key];
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
newObj.default = obj;
|
|
49
|
-
if (cache) {
|
|
50
|
-
cache.set(obj, newObj);
|
|
51
|
-
}
|
|
52
|
-
return newObj;
|
|
53
|
-
}
|
|
54
|
-
const DefaultNodeView = /*#__PURE__*/ (0, _react.forwardRef)(function DefaultNodeView(param, ref) {
|
|
55
|
-
let { nodeProps: { node }, children, ...props } = param;
|
|
56
|
-
const spec = (0, _react.useMemo)(()=>node.type.spec.toDOM?.(node), [
|
|
57
|
-
node
|
|
58
|
-
]);
|
|
59
|
-
if (!spec) {
|
|
60
|
-
throw new Error(`Node spec for ${node.type.name} is missing toDOM`);
|
|
61
|
-
}
|
|
62
|
-
return /*#__PURE__*/ _react.default.createElement(_OutputSpec.OutputSpec, {
|
|
63
|
-
...props,
|
|
64
|
-
outputSpec: spec,
|
|
65
|
-
ref: ref
|
|
66
|
-
}, children);
|
|
67
|
-
});
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "DocNodeView", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return DocNodeView;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
-
const _ChildDescriptorsContext = require("../contexts/ChildDescriptorsContext.js");
|
|
13
|
-
const _useNodeViewDescriptor = require("../hooks/useNodeViewDescriptor.js");
|
|
14
|
-
const _ChildNodeViews = require("./ChildNodeViews.js");
|
|
15
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
16
|
-
if (typeof WeakMap !== "function") return null;
|
|
17
|
-
var cacheBabelInterop = new WeakMap();
|
|
18
|
-
var cacheNodeInterop = new WeakMap();
|
|
19
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
20
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
21
|
-
})(nodeInterop);
|
|
22
|
-
}
|
|
23
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
24
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
25
|
-
return obj;
|
|
26
|
-
}
|
|
27
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
28
|
-
return {
|
|
29
|
-
default: obj
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
33
|
-
if (cache && cache.has(obj)) {
|
|
34
|
-
return cache.get(obj);
|
|
35
|
-
}
|
|
36
|
-
var newObj = {
|
|
37
|
-
__proto__: null
|
|
38
|
-
};
|
|
39
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
40
|
-
for(var key in obj){
|
|
41
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
42
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
43
|
-
if (desc && (desc.get || desc.set)) {
|
|
44
|
-
Object.defineProperty(newObj, key, desc);
|
|
45
|
-
} else {
|
|
46
|
-
newObj[key] = obj[key];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
newObj.default = obj;
|
|
51
|
-
if (cache) {
|
|
52
|
-
cache.set(obj, newObj);
|
|
53
|
-
}
|
|
54
|
-
return newObj;
|
|
55
|
-
}
|
|
56
|
-
const DocNodeView = /*#__PURE__*/ (0, _react.memo)(/*#__PURE__*/ (0, _react.forwardRef)(function DocNodeView(param, ref) {
|
|
57
|
-
let { as, node, getPos, decorations, innerDecorations, setMount, ...elementProps } = param;
|
|
58
|
-
const innerRef = (0, _react.useRef)(null);
|
|
59
|
-
(0, _react.useImperativeHandle)(ref, ()=>innerRef.current);
|
|
60
|
-
(0, _react.useImperativeHandle)(setMount, ()=>innerRef.current);
|
|
61
|
-
const nodeProps = (0, _react.useMemo)(()=>({
|
|
62
|
-
node,
|
|
63
|
-
getPos,
|
|
64
|
-
decorations,
|
|
65
|
-
innerDecorations
|
|
66
|
-
}), [
|
|
67
|
-
node,
|
|
68
|
-
getPos,
|
|
69
|
-
decorations,
|
|
70
|
-
innerDecorations
|
|
71
|
-
]);
|
|
72
|
-
const { childContextValue } = (0, _useNodeViewDescriptor.useNodeViewDescriptor)(innerRef, ()=>{
|
|
73
|
-
const dom = innerRef.current;
|
|
74
|
-
return {
|
|
75
|
-
dom,
|
|
76
|
-
contentDOM: dom,
|
|
77
|
-
update () {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}, nodeProps);
|
|
82
|
-
const children = /*#__PURE__*/ _react.default.createElement(_ChildDescriptorsContext.ChildDescriptorsContext.Provider, {
|
|
83
|
-
value: childContextValue
|
|
84
|
-
}, /*#__PURE__*/ _react.default.createElement(_ChildNodeViews.ChildNodeViews, {
|
|
85
|
-
getPos: getPos,
|
|
86
|
-
node: node,
|
|
87
|
-
innerDecorations: innerDecorations
|
|
88
|
-
}));
|
|
89
|
-
const props = {
|
|
90
|
-
...elementProps,
|
|
91
|
-
suppressContentEditableWarning: true,
|
|
92
|
-
ref: innerRef
|
|
93
|
-
};
|
|
94
|
-
const element = as ? /*#__PURE__*/ (0, _react.cloneElement)(as, props, children) : /*#__PURE__*/ (0, _react.createElement)("div", props, children);
|
|
95
|
-
return nodeProps.decorations.reduce(_ChildNodeViews.wrapInDeco, element);
|
|
96
|
-
}));
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "MarkView", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return MarkView;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
-
const _ChildDescriptorsContext = require("../contexts/ChildDescriptorsContext.js");
|
|
13
|
-
const _useClientLayoutEffect = require("../hooks/useClientLayoutEffect.js");
|
|
14
|
-
const _viewdesc = require("../viewdesc.js");
|
|
15
|
-
const _OutputSpec = require("./OutputSpec.js");
|
|
16
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
17
|
-
if (typeof WeakMap !== "function") return null;
|
|
18
|
-
var cacheBabelInterop = new WeakMap();
|
|
19
|
-
var cacheNodeInterop = new WeakMap();
|
|
20
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
21
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
22
|
-
})(nodeInterop);
|
|
23
|
-
}
|
|
24
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
25
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
26
|
-
return obj;
|
|
27
|
-
}
|
|
28
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
29
|
-
return {
|
|
30
|
-
default: obj
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
34
|
-
if (cache && cache.has(obj)) {
|
|
35
|
-
return cache.get(obj);
|
|
36
|
-
}
|
|
37
|
-
var newObj = {
|
|
38
|
-
__proto__: null
|
|
39
|
-
};
|
|
40
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
41
|
-
for(var key in obj){
|
|
42
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
43
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
44
|
-
if (desc && (desc.get || desc.set)) {
|
|
45
|
-
Object.defineProperty(newObj, key, desc);
|
|
46
|
-
} else {
|
|
47
|
-
newObj[key] = obj[key];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
newObj.default = obj;
|
|
52
|
-
if (cache) {
|
|
53
|
-
cache.set(obj, newObj);
|
|
54
|
-
}
|
|
55
|
-
return newObj;
|
|
56
|
-
}
|
|
57
|
-
const MarkView = /*#__PURE__*/ (0, _react.memo)(/*#__PURE__*/ (0, _react.forwardRef)(function MarkView(param, ref) {
|
|
58
|
-
let { mark, getPos, children } = param;
|
|
59
|
-
const { siblingsRef, parentRef } = (0, _react.useContext)(_ChildDescriptorsContext.ChildDescriptorsContext);
|
|
60
|
-
const viewDescRef = (0, _react.useRef)(undefined);
|
|
61
|
-
const childDescriptors = (0, _react.useRef)([]);
|
|
62
|
-
const domRef = (0, _react.useRef)(null);
|
|
63
|
-
(0, _react.useImperativeHandle)(ref, ()=>{
|
|
64
|
-
return domRef.current;
|
|
65
|
-
}, []);
|
|
66
|
-
const outputSpec = (0, _react.useMemo)(()=>mark.type.spec.toDOM?.(mark, true), [
|
|
67
|
-
mark
|
|
68
|
-
]);
|
|
69
|
-
if (!outputSpec) throw new Error(`Mark spec for ${mark.type.name} is missing toDOM`);
|
|
70
|
-
(0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
|
|
71
|
-
const siblings = siblingsRef.current;
|
|
72
|
-
return ()=>{
|
|
73
|
-
if (!viewDescRef.current) return;
|
|
74
|
-
if (siblings.includes(viewDescRef.current)) {
|
|
75
|
-
const index = siblings.indexOf(viewDescRef.current);
|
|
76
|
-
siblings.splice(index, 1);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
}, [
|
|
80
|
-
siblingsRef
|
|
81
|
-
]);
|
|
82
|
-
(0, _useClientLayoutEffect.useClientLayoutEffect)(()=>{
|
|
83
|
-
if (!domRef.current) return;
|
|
84
|
-
const firstChildDesc = childDescriptors.current[0];
|
|
85
|
-
if (!viewDescRef.current) {
|
|
86
|
-
viewDescRef.current = new _viewdesc.MarkViewDesc(parentRef.current, childDescriptors.current, getPos, mark, domRef.current, firstChildDesc?.dom.parentElement ?? domRef.current, {
|
|
87
|
-
dom: domRef.current,
|
|
88
|
-
contentDOM: firstChildDesc?.dom.parentElement ?? domRef.current
|
|
89
|
-
});
|
|
90
|
-
} else {
|
|
91
|
-
viewDescRef.current.parent = parentRef.current;
|
|
92
|
-
viewDescRef.current.spec.dom = viewDescRef.current.dom = domRef.current;
|
|
93
|
-
viewDescRef.current.children = childDescriptors.current;
|
|
94
|
-
viewDescRef.current.spec.contentDOM = viewDescRef.current.contentDOM = firstChildDesc?.dom.parentElement ?? domRef.current;
|
|
95
|
-
viewDescRef.current.mark = mark;
|
|
96
|
-
}
|
|
97
|
-
if (!siblingsRef.current.includes(viewDescRef.current)) {
|
|
98
|
-
siblingsRef.current.push(viewDescRef.current);
|
|
99
|
-
}
|
|
100
|
-
siblingsRef.current.sort(_viewdesc.sortViewDescs);
|
|
101
|
-
for (const childDesc of childDescriptors.current){
|
|
102
|
-
childDesc.parent = viewDescRef.current;
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
const childContextValue = (0, _react.useMemo)(()=>({
|
|
106
|
-
parentRef: viewDescRef,
|
|
107
|
-
siblingsRef: childDescriptors
|
|
108
|
-
}), [
|
|
109
|
-
childDescriptors,
|
|
110
|
-
viewDescRef
|
|
111
|
-
]);
|
|
112
|
-
return /*#__PURE__*/ _react.default.createElement(_OutputSpec.OutputSpec, {
|
|
113
|
-
ref: domRef,
|
|
114
|
-
outputSpec: outputSpec,
|
|
115
|
-
isMark: true
|
|
116
|
-
}, /*#__PURE__*/ _react.default.createElement(_ChildDescriptorsContext.ChildDescriptorsContext.Provider, {
|
|
117
|
-
value: childContextValue
|
|
118
|
-
}, children));
|
|
119
|
-
}));
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "NodeView", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return NodeView;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
-
const _NodeViewContext = require("../contexts/NodeViewContext.js");
|
|
13
|
-
const _CustomNodeView = require("./CustomNodeView.js");
|
|
14
|
-
const _DefaultNodeView = require("./DefaultNodeView.js");
|
|
15
|
-
const _ReactNodeView = require("./ReactNodeView.js");
|
|
16
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
17
|
-
if (typeof WeakMap !== "function") return null;
|
|
18
|
-
var cacheBabelInterop = new WeakMap();
|
|
19
|
-
var cacheNodeInterop = new WeakMap();
|
|
20
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
21
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
22
|
-
})(nodeInterop);
|
|
23
|
-
}
|
|
24
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
25
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
26
|
-
return obj;
|
|
27
|
-
}
|
|
28
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
29
|
-
return {
|
|
30
|
-
default: obj
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
34
|
-
if (cache && cache.has(obj)) {
|
|
35
|
-
return cache.get(obj);
|
|
36
|
-
}
|
|
37
|
-
var newObj = {
|
|
38
|
-
__proto__: null
|
|
39
|
-
};
|
|
40
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
41
|
-
for(var key in obj){
|
|
42
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
43
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
44
|
-
if (desc && (desc.get || desc.set)) {
|
|
45
|
-
Object.defineProperty(newObj, key, desc);
|
|
46
|
-
} else {
|
|
47
|
-
newObj[key] = obj[key];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
newObj.default = obj;
|
|
52
|
-
if (cache) {
|
|
53
|
-
cache.set(obj, newObj);
|
|
54
|
-
}
|
|
55
|
-
return newObj;
|
|
56
|
-
}
|
|
57
|
-
const NodeView = /*#__PURE__*/ (0, _react.memo)(function NodeView(props) {
|
|
58
|
-
const { components, constructors } = (0, _react.useContext)(_NodeViewContext.NodeViewContext);
|
|
59
|
-
const component = components[props.node.type.name] ?? _DefaultNodeView.DefaultNodeView;
|
|
60
|
-
const constructor = constructors[props.node.type.name];
|
|
61
|
-
// Construct a wrapper component so that the node view remounts when either
|
|
62
|
-
// its component or constructor changes. A React node view would remount if
|
|
63
|
-
// its underlying component changed without this wrapper, but a custom node
|
|
64
|
-
// view otherwise uses the same React components for all custom node views.
|
|
65
|
-
const Component = (0, _react.useMemo)(()=>{
|
|
66
|
-
if (constructor) {
|
|
67
|
-
return function NodeView(props) {
|
|
68
|
-
return /*#__PURE__*/ _react.default.createElement(_CustomNodeView.CustomNodeView, {
|
|
69
|
-
constructor: constructor,
|
|
70
|
-
...props
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
} else {
|
|
74
|
-
return function NodeView(props) {
|
|
75
|
-
return /*#__PURE__*/ _react.default.createElement(_ReactNodeView.ReactNodeView, {
|
|
76
|
-
component: component,
|
|
77
|
-
...props
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}, [
|
|
82
|
-
constructor,
|
|
83
|
-
component
|
|
84
|
-
]);
|
|
85
|
-
return /*#__PURE__*/ _react.default.createElement(Component, props);
|
|
86
|
-
});
|