@stesura/react-prosemirror 3.2.11-stesura.1
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/LICENSE.txt +21 -0
- package/README.md +939 -0
- package/dist/cjs/AbstractEditorView.js +4 -0
- package/dist/cjs/ReactEditorView.js +194 -0
- package/dist/cjs/StaticEditorView.js +89 -0
- package/dist/cjs/browser.js +53 -0
- package/dist/cjs/commands/reorderSiblings.js +72 -0
- package/dist/cjs/components/ChildNodeViews.js +418 -0
- package/dist/cjs/components/CursorWrapper.js +84 -0
- package/dist/cjs/components/EditorStateSelectorsProvider.js +90 -0
- package/dist/cjs/components/LayoutGroup.js +112 -0
- package/dist/cjs/components/NativeWidgetView.js +108 -0
- package/dist/cjs/components/OutputSpec.js +121 -0
- package/dist/cjs/components/ProseMirror.js +146 -0
- package/dist/cjs/components/ProseMirrorDoc.js +74 -0
- package/dist/cjs/components/SeparatorHackView.js +99 -0
- package/dist/cjs/components/TextNodeView.js +113 -0
- package/dist/cjs/components/TrailingHackView.js +87 -0
- package/dist/cjs/components/WidgetView.js +94 -0
- package/dist/cjs/components/WidgetViewComponentProps.js +4 -0
- package/dist/cjs/components/marks/DefaultMarkView.js +70 -0
- package/dist/cjs/components/marks/MarkView.js +85 -0
- package/dist/cjs/components/marks/MarkViewComponentProps.js +4 -0
- package/dist/cjs/components/marks/MarkViewConstructorView.js +116 -0
- package/dist/cjs/components/marks/ReactMarkView.js +109 -0
- package/dist/cjs/components/nodes/DefaultNodeView.js +68 -0
- package/dist/cjs/components/nodes/DocNodeView.js +97 -0
- package/dist/cjs/components/nodes/NodeView.js +129 -0
- package/dist/cjs/components/nodes/NodeViewComponentProps.js +4 -0
- package/dist/cjs/components/nodes/NodeViewConstructorView.js +145 -0
- package/dist/cjs/components/nodes/ReactNodeView.js +189 -0
- package/dist/cjs/constants.js +33 -0
- package/dist/cjs/contexts/ChildDescriptionsContext.js +19 -0
- package/dist/cjs/contexts/EditorContext.js +12 -0
- package/dist/cjs/contexts/EditorStateContext.js +12 -0
- package/dist/cjs/contexts/EditorStateStoreContext.js +45 -0
- package/dist/cjs/contexts/IgnoreMutationContext.js +12 -0
- package/dist/cjs/contexts/LayoutGroupContext.js +12 -0
- package/dist/cjs/contexts/NodeViewContext.js +12 -0
- package/dist/cjs/contexts/RenderStoreContext.js +54 -0
- package/dist/cjs/contexts/SelectNodeContext.js +12 -0
- package/dist/cjs/contexts/StopEventContext.js +12 -0
- package/dist/cjs/decorations/ReactWidgetType.js +58 -0
- package/dist/cjs/decorations/computeDocDeco.js +44 -0
- package/dist/cjs/decorations/internalTypes.js +4 -0
- package/dist/cjs/decorations/iterDeco.js +91 -0
- package/dist/cjs/decorations/viewDecorations.js +155 -0
- package/dist/cjs/dom.js +147 -0
- package/dist/cjs/findDOMNode.js +46 -0
- package/dist/cjs/hooks/useClientLayoutEffect.js +19 -0
- package/dist/cjs/hooks/useComponentEventListeners.js +72 -0
- package/dist/cjs/hooks/useEditor.js +130 -0
- package/dist/cjs/hooks/useEditorEffect.js +39 -0
- package/dist/cjs/hooks/useEditorEventCallback.js +38 -0
- package/dist/cjs/hooks/useEditorEventListener.js +34 -0
- package/dist/cjs/hooks/useEditorState.js +18 -0
- package/dist/cjs/hooks/useEditorStateSelector.js +17 -0
- package/dist/cjs/hooks/useEffectEvent.js +34 -0
- package/dist/cjs/hooks/useForceUpdate.js +15 -0
- package/dist/cjs/hooks/useIgnoreMutation.js +24 -0
- package/dist/cjs/hooks/useIsComposingIn.js +25 -0
- package/dist/cjs/hooks/useIsEditorStatic.js +15 -0
- package/dist/cjs/hooks/useIsNodeSelected.js +21 -0
- package/dist/cjs/hooks/useLayoutGroupEffect.js +20 -0
- package/dist/cjs/hooks/useMarkViewDescription.js +134 -0
- package/dist/cjs/hooks/useNodePos.js +18 -0
- package/dist/cjs/hooks/useNodeViewDescription.js +154 -0
- package/dist/cjs/hooks/useReactKeys.js +17 -0
- package/dist/cjs/hooks/useSelectNode.js +30 -0
- package/dist/cjs/hooks/useSetDom.js +57 -0
- package/dist/cjs/hooks/useStopEvent.js +24 -0
- package/dist/cjs/index.js +85 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/plugins/beforeInputPlugin.js +356 -0
- package/dist/cjs/plugins/reactKeys.js +121 -0
- package/dist/cjs/props.js +283 -0
- package/dist/cjs/refs.js +28 -0
- package/dist/cjs/testing/editorViewTestHelpers.js +109 -0
- package/dist/cjs/testing/setupProseMirrorView.js +94 -0
- package/dist/cjs/tiptap/ReactProseMirrorNodeView.js +26 -0
- package/dist/cjs/tiptap/TiptapEditor.js +34 -0
- package/dist/cjs/tiptap/TiptapEditorContent.js +143 -0
- package/dist/cjs/tiptap/TiptapEditorView.js +130 -0
- package/dist/cjs/tiptap/contexts/TiptapEditorContext.js +12 -0
- package/dist/cjs/tiptap/extensions/ReactProseMirror.js +40 -0
- package/dist/cjs/tiptap/extensions/ReactProseMirrorCommands.js +21 -0
- package/dist/cjs/tiptap/extensions/commands/updateAttributes.js +104 -0
- package/dist/cjs/tiptap/hooks/useEditor.js +318 -0
- package/dist/cjs/tiptap/hooks/useIsInReactProseMirror.js +15 -0
- package/dist/cjs/tiptap/hooks/useTiptapEditor.js +35 -0
- package/dist/cjs/tiptap/hooks/useTiptapEditorEffect.js +35 -0
- package/dist/cjs/tiptap/hooks/useTiptapEditorEventCallback.js +35 -0
- package/dist/cjs/tiptap/index.js +48 -0
- package/dist/cjs/tiptap/tiptapNodeView.js +245 -0
- package/dist/cjs/viewdesc.js +862 -0
- package/dist/esm/AbstractEditorView.js +1 -0
- package/dist/esm/ReactEditorView.js +194 -0
- package/dist/esm/StaticEditorView.js +79 -0
- package/dist/esm/browser.js +43 -0
- package/dist/esm/commands/reorderSiblings.js +63 -0
- package/dist/esm/components/ChildNodeViews.js +359 -0
- package/dist/esm/components/CursorWrapper.js +33 -0
- package/dist/esm/components/EditorStateSelectorsProvider.js +31 -0
- package/dist/esm/components/LayoutGroup.js +67 -0
- package/dist/esm/components/NativeWidgetView.js +57 -0
- package/dist/esm/components/OutputSpec.js +71 -0
- package/dist/esm/components/ProseMirror.js +95 -0
- package/dist/esm/components/ProseMirrorDoc.js +15 -0
- package/dist/esm/components/SeparatorHackView.js +48 -0
- package/dist/esm/components/TextNodeView.js +103 -0
- package/dist/esm/components/TrailingHackView.js +36 -0
- package/dist/esm/components/WidgetView.js +43 -0
- package/dist/esm/components/WidgetViewComponentProps.js +1 -0
- package/dist/esm/components/marks/DefaultMarkView.js +19 -0
- package/dist/esm/components/marks/MarkView.js +34 -0
- package/dist/esm/components/marks/MarkViewComponentProps.js +1 -0
- package/dist/esm/components/marks/MarkViewConstructorView.js +65 -0
- package/dist/esm/components/marks/ReactMarkView.js +58 -0
- package/dist/esm/components/nodes/DefaultNodeView.js +17 -0
- package/dist/esm/components/nodes/DocNodeView.js +46 -0
- package/dist/esm/components/nodes/NodeView.js +67 -0
- package/dist/esm/components/nodes/NodeViewComponentProps.js +1 -0
- package/dist/esm/components/nodes/NodeViewConstructorView.js +94 -0
- package/dist/esm/components/nodes/ReactNodeView.js +138 -0
- package/dist/esm/constants.js +15 -0
- package/dist/esm/contexts/ChildDescriptionsContext.js +9 -0
- package/dist/esm/contexts/EditorContext.js +7 -0
- package/dist/esm/contexts/EditorStateContext.js +2 -0
- package/dist/esm/contexts/EditorStateStoreContext.js +27 -0
- package/dist/esm/contexts/IgnoreMutationContext.js +2 -0
- package/dist/esm/contexts/LayoutGroupContext.js +2 -0
- package/dist/esm/contexts/NodeViewContext.js +2 -0
- package/dist/esm/contexts/RenderStoreContext.js +33 -0
- package/dist/esm/contexts/SelectNodeContext.js +2 -0
- package/dist/esm/contexts/StopEventContext.js +2 -0
- package/dist/esm/decorations/ReactWidgetType.js +40 -0
- package/dist/esm/decorations/computeDocDeco.js +44 -0
- package/dist/esm/decorations/internalTypes.js +1 -0
- package/dist/esm/decorations/iterDeco.js +85 -0
- package/dist/esm/decorations/viewDecorations.js +155 -0
- package/dist/esm/dom.js +110 -0
- package/dist/esm/findDOMNode.js +31 -0
- package/dist/esm/hooks/useClientLayoutEffect.js +9 -0
- package/dist/esm/hooks/useComponentEventListeners.js +87 -0
- package/dist/esm/hooks/useEditor.js +128 -0
- package/dist/esm/hooks/useEditorEffect.js +46 -0
- package/dist/esm/hooks/useEditorEventCallback.js +38 -0
- package/dist/esm/hooks/useEditorEventListener.js +28 -0
- package/dist/esm/hooks/useEditorState.js +10 -0
- package/dist/esm/hooks/useEditorStateSelector.js +14 -0
- package/dist/esm/hooks/useEffectEvent.js +24 -0
- package/dist/esm/hooks/useForceUpdate.js +8 -0
- package/dist/esm/hooks/useIgnoreMutation.js +14 -0
- package/dist/esm/hooks/useIsComposingIn.js +17 -0
- package/dist/esm/hooks/useIsEditorStatic.js +8 -0
- package/dist/esm/hooks/useIsNodeSelected.js +11 -0
- package/dist/esm/hooks/useLayoutGroupEffect.js +10 -0
- package/dist/esm/hooks/useMarkViewDescription.js +124 -0
- package/dist/esm/hooks/useNodePos.js +15 -0
- package/dist/esm/hooks/useNodeViewDescription.js +144 -0
- package/dist/esm/hooks/useReactKeys.js +7 -0
- package/dist/esm/hooks/useSelectNode.js +20 -0
- package/dist/esm/hooks/useSetDom.js +47 -0
- package/dist/esm/hooks/useStopEvent.js +14 -0
- package/dist/esm/index.js +19 -0
- package/dist/esm/plugins/beforeInputPlugin.js +346 -0
- package/dist/esm/plugins/reactKeys.js +106 -0
- package/dist/esm/props.js +267 -0
- package/dist/esm/refs.js +18 -0
- package/dist/esm/testing/editorViewTestHelpers.js +86 -0
- package/dist/esm/testing/setupProseMirrorView.js +76 -0
- package/dist/esm/tiptap/ReactProseMirrorNodeView.js +22 -0
- package/dist/esm/tiptap/TiptapEditor.js +24 -0
- package/dist/esm/tiptap/TiptapEditorContent.js +99 -0
- package/dist/esm/tiptap/TiptapEditorView.js +76 -0
- package/dist/esm/tiptap/contexts/TiptapEditorContext.js +2 -0
- package/dist/esm/tiptap/extensions/ReactProseMirror.js +30 -0
- package/dist/esm/tiptap/extensions/ReactProseMirrorCommands.js +11 -0
- package/dist/esm/tiptap/extensions/commands/updateAttributes.js +96 -0
- package/dist/esm/tiptap/hooks/useEditor.js +308 -0
- package/dist/esm/tiptap/hooks/useIsInReactProseMirror.js +9 -0
- package/dist/esm/tiptap/hooks/useTiptapEditor.js +31 -0
- package/dist/esm/tiptap/hooks/useTiptapEditorEffect.js +42 -0
- package/dist/esm/tiptap/hooks/useTiptapEditorEventCallback.js +35 -0
- package/dist/esm/tiptap/index.js +9 -0
- package/dist/esm/tiptap/tiptapNodeView.js +211 -0
- package/dist/esm/viewdesc.js +844 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/AbstractEditorView.d.ts +28 -0
- package/dist/types/ReactEditorView.d.ts +102 -0
- package/dist/types/StaticEditorView.d.ts +26 -0
- package/dist/types/__tests__/viewdesc.test.d.ts +1 -0
- package/dist/types/browser.d.ts +15 -0
- package/dist/types/commands/__tests__/reorderSiblings.test.d.ts +1 -0
- package/dist/types/commands/reorderSiblings.d.ts +14 -0
- package/dist/types/components/ChildNodeViews.d.ts +9 -0
- package/dist/types/components/CursorWrapper.d.ts +3 -0
- package/dist/types/components/EditorStateSelectorsProvider.d.ts +10 -0
- package/dist/types/components/LayoutGroup.d.ts +12 -0
- package/dist/types/components/NativeWidgetView.d.ts +8 -0
- package/dist/types/components/OutputSpec.d.ts +10 -0
- package/dist/types/components/ProseMirror.d.ts +14 -0
- package/dist/types/components/ProseMirrorDoc.d.ts +16 -0
- package/dist/types/components/SeparatorHackView.d.ts +6 -0
- package/dist/types/components/TextNodeView.d.ts +27 -0
- package/dist/types/components/TrailingHackView.d.ts +6 -0
- package/dist/types/components/WidgetView.d.ts +8 -0
- package/dist/types/components/WidgetViewComponentProps.d.ts +7 -0
- package/dist/types/components/__tests__/ProseMirror.composition.test.d.ts +17 -0
- package/dist/types/components/__tests__/ProseMirror.domchange.test.d.ts +1 -0
- package/dist/types/components/__tests__/ProseMirror.draw-decoration.test.d.ts +1 -0
- package/dist/types/components/__tests__/ProseMirror.draw.test.d.ts +1 -0
- package/dist/types/components/__tests__/ProseMirror.memory-leak.test.d.ts +6 -0
- package/dist/types/components/__tests__/ProseMirror.mobile.test.d.ts +1 -0
- package/dist/types/components/__tests__/ProseMirror.node-view.test.d.ts +1 -0
- package/dist/types/components/__tests__/ProseMirror.selection.test.d.ts +1 -0
- package/dist/types/components/__tests__/ProseMirror.test.d.ts +1 -0
- package/dist/types/components/__tests__/stableContexts.test.d.ts +10 -0
- package/dist/types/components/marks/DefaultMarkView.d.ts +3 -0
- package/dist/types/components/marks/MarkView.d.ts +10 -0
- package/dist/types/components/marks/MarkViewComponentProps.d.ts +11 -0
- package/dist/types/components/marks/MarkViewConstructorView.d.ts +12 -0
- package/dist/types/components/marks/ReactMarkView.d.ts +12 -0
- package/dist/types/components/nodes/DefaultNodeView.d.ts +3 -0
- package/dist/types/components/nodes/DocNodeView.d.ts +12 -0
- package/dist/types/components/nodes/NodeView.d.ts +14 -0
- package/dist/types/components/nodes/NodeViewComponentProps.d.ts +13 -0
- package/dist/types/components/nodes/NodeViewConstructorView.d.ts +12 -0
- package/dist/types/components/nodes/ReactNodeView.d.ts +13 -0
- package/dist/types/constants.d.ts +4 -0
- package/dist/types/contexts/ChildDescriptionsContext.d.ts +7 -0
- package/dist/types/contexts/EditorContext.d.ts +18 -0
- package/dist/types/contexts/EditorStateContext.d.ts +2 -0
- package/dist/types/contexts/EditorStateStoreContext.d.ts +9 -0
- package/dist/types/contexts/IgnoreMutationContext.d.ts +5 -0
- package/dist/types/contexts/LayoutGroupContext.d.ts +5 -0
- package/dist/types/contexts/NodeViewContext.d.ts +9 -0
- package/dist/types/contexts/RenderStoreContext.d.ts +24 -0
- package/dist/types/contexts/SelectNodeContext.d.ts +5 -0
- package/dist/types/contexts/StopEventContext.d.ts +5 -0
- package/dist/types/contexts/__tests__/DeferredLayoutEffects.test.d.ts +1 -0
- package/dist/types/decorations/ReactWidgetType.d.ts +40 -0
- package/dist/types/decorations/computeDocDeco.d.ts +14 -0
- package/dist/types/decorations/internalTypes.d.ts +20 -0
- package/dist/types/decorations/iterDeco.d.ts +3 -0
- package/dist/types/decorations/viewDecorations.d.ts +14 -0
- package/dist/types/dom.d.ts +22 -0
- package/dist/types/findDOMNode.d.ts +3 -0
- package/dist/types/hooks/__tests__/useEditorEffect.test.d.ts +1 -0
- package/dist/types/hooks/useClientLayoutEffect.d.ts +2 -0
- package/dist/types/hooks/useComponentEventListeners.d.ts +34 -0
- package/dist/types/hooks/useEditor.d.ts +37 -0
- package/dist/types/hooks/useEditorEffect.d.ts +21 -0
- package/dist/types/hooks/useEditorEventCallback.d.ts +13 -0
- package/dist/types/hooks/useEditorEventListener.d.ts +8 -0
- package/dist/types/hooks/useEditorState.d.ts +5 -0
- package/dist/types/hooks/useEditorStateSelector.d.ts +10 -0
- package/dist/types/hooks/useEffectEvent.d.ts +1 -0
- package/dist/types/hooks/useForceUpdate.d.ts +5 -0
- package/dist/types/hooks/useIgnoreMutation.d.ts +2 -0
- package/dist/types/hooks/useIsComposingIn.d.ts +4 -0
- package/dist/types/hooks/useIsEditorStatic.d.ts +5 -0
- package/dist/types/hooks/useIsNodeSelected.d.ts +1 -0
- package/dist/types/hooks/useLayoutGroupEffect.d.ts +3 -0
- package/dist/types/hooks/useMarkViewDescription.d.ts +15 -0
- package/dist/types/hooks/useNodePos.d.ts +9 -0
- package/dist/types/hooks/useNodeViewDescription.d.ts +16 -0
- package/dist/types/hooks/useReactKeys.d.ts +2 -0
- package/dist/types/hooks/useSelectNode.d.ts +2 -0
- package/dist/types/hooks/useSetDom.d.ts +2 -0
- package/dist/types/hooks/useStopEvent.d.ts +2 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/plugins/__tests__/reactKeys.test.d.ts +1 -0
- package/dist/types/plugins/beforeInputPlugin.d.ts +2 -0
- package/dist/types/plugins/reactKeys.d.ts +23 -0
- package/dist/types/props.d.ts +1173 -0
- package/dist/types/refs.d.ts +2 -0
- package/dist/types/testing/editorViewTestHelpers.d.ts +24 -0
- package/dist/types/testing/setupProseMirrorView.d.ts +2 -0
- package/dist/types/tiptap/ReactProseMirrorNodeView.d.ts +15 -0
- package/dist/types/tiptap/TiptapEditor.d.ts +6 -0
- package/dist/types/tiptap/TiptapEditorContent.d.ts +28 -0
- package/dist/types/tiptap/TiptapEditorView.d.ts +16 -0
- package/dist/types/tiptap/contexts/TiptapEditorContext.d.ts +6 -0
- package/dist/types/tiptap/extensions/ReactProseMirror.d.ts +9 -0
- package/dist/types/tiptap/extensions/ReactProseMirrorCommands.d.ts +2 -0
- package/dist/types/tiptap/extensions/commands/updateAttributes.d.ts +24 -0
- package/dist/types/tiptap/hooks/useEditor.d.ts +38 -0
- package/dist/types/tiptap/hooks/useIsInReactProseMirror.d.ts +6 -0
- package/dist/types/tiptap/hooks/useTiptapEditor.d.ts +11 -0
- package/dist/types/tiptap/hooks/useTiptapEditorEffect.d.ts +21 -0
- package/dist/types/tiptap/hooks/useTiptapEditorEventCallback.d.ts +13 -0
- package/dist/types/tiptap/index.d.ts +9 -0
- package/dist/types/tiptap/tiptapNodeView.d.ts +50 -0
- package/dist/types/viewdesc.d.ts +179 -0
- package/package.json +167 -0
|
@@ -0,0 +1,68 @@
|
|
|
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, contentDOMRef }, 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
|
+
contentDOMRef: contentDOMRef
|
|
67
|
+
}, children);
|
|
68
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
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 _ChildDescriptionsContext = require("../../contexts/ChildDescriptionsContext.js");
|
|
13
|
+
const _useNodeViewDescription = require("../../hooks/useNodeViewDescription.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
|
+
contentDOMRef: innerRef
|
|
67
|
+
}), [
|
|
68
|
+
node,
|
|
69
|
+
getPos,
|
|
70
|
+
decorations,
|
|
71
|
+
innerDecorations
|
|
72
|
+
]);
|
|
73
|
+
const { childContextValue } = (0, _useNodeViewDescription.useNodeViewDescription)(()=>innerRef.current, ()=>innerRef.current, ()=>{
|
|
74
|
+
const dom = innerRef.current;
|
|
75
|
+
return {
|
|
76
|
+
dom,
|
|
77
|
+
contentDOM: dom,
|
|
78
|
+
update () {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}, nodeProps);
|
|
83
|
+
const children = /*#__PURE__*/ _react.default.createElement(_ChildDescriptionsContext.ChildDescriptionsContext.Provider, {
|
|
84
|
+
value: childContextValue
|
|
85
|
+
}, /*#__PURE__*/ _react.default.createElement(_ChildNodeViews.ChildNodeViews, {
|
|
86
|
+
getPos: getPos,
|
|
87
|
+
node: node,
|
|
88
|
+
innerDecorations: innerDecorations
|
|
89
|
+
}));
|
|
90
|
+
const props = {
|
|
91
|
+
...elementProps,
|
|
92
|
+
suppressContentEditableWarning: true,
|
|
93
|
+
ref: innerRef
|
|
94
|
+
};
|
|
95
|
+
const element = as ? /*#__PURE__*/ (0, _react.createElement)(as, props, children) : /*#__PURE__*/ (0, _react.createElement)("div", props, children);
|
|
96
|
+
return nodeProps.decorations.reduce(_ChildNodeViews.wrapInDeco, element);
|
|
97
|
+
}));
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
GetPosContext: function() {
|
|
13
|
+
return GetPosContext;
|
|
14
|
+
},
|
|
15
|
+
NodeView: function() {
|
|
16
|
+
return NodeView;
|
|
17
|
+
},
|
|
18
|
+
RemountableNodeView: function() {
|
|
19
|
+
return RemountableNodeView;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
23
|
+
const _NodeViewContext = require("../../contexts/NodeViewContext.js");
|
|
24
|
+
const _useEditorStateSelector = require("../../hooks/useEditorStateSelector.js");
|
|
25
|
+
const _reactKeys = require("../../plugins/reactKeys.js");
|
|
26
|
+
const _DefaultNodeView = require("./DefaultNodeView.js");
|
|
27
|
+
const _NodeViewConstructorView = require("./NodeViewConstructorView.js");
|
|
28
|
+
const _ReactNodeView = require("./ReactNodeView.js");
|
|
29
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
30
|
+
if (typeof WeakMap !== "function") return null;
|
|
31
|
+
var cacheBabelInterop = new WeakMap();
|
|
32
|
+
var cacheNodeInterop = new WeakMap();
|
|
33
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
34
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
35
|
+
})(nodeInterop);
|
|
36
|
+
}
|
|
37
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
38
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
39
|
+
return obj;
|
|
40
|
+
}
|
|
41
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
42
|
+
return {
|
|
43
|
+
default: obj
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
47
|
+
if (cache && cache.has(obj)) {
|
|
48
|
+
return cache.get(obj);
|
|
49
|
+
}
|
|
50
|
+
var newObj = {
|
|
51
|
+
__proto__: null
|
|
52
|
+
};
|
|
53
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
54
|
+
for(var key in obj){
|
|
55
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
56
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
57
|
+
if (desc && (desc.get || desc.set)) {
|
|
58
|
+
Object.defineProperty(newObj, key, desc);
|
|
59
|
+
} else {
|
|
60
|
+
newObj[key] = obj[key];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
newObj.default = obj;
|
|
65
|
+
if (cache) {
|
|
66
|
+
cache.set(obj, newObj);
|
|
67
|
+
}
|
|
68
|
+
return newObj;
|
|
69
|
+
}
|
|
70
|
+
const NodeView = /*#__PURE__*/ (0, _react.memo)(function NodeView(param) {
|
|
71
|
+
let { forceRemount, ...props } = param;
|
|
72
|
+
const renderRef = (0, _react.useRef)(null);
|
|
73
|
+
const frozen = (0, _useEditorStateSelector.useEditorStateSelector)((state)=>_reactKeys.reactKeysPluginKey.getState(state)?.freezeFrom === props.getPos());
|
|
74
|
+
const { components, constructors } = (0, _react.useContext)(_NodeViewContext.NodeViewContext);
|
|
75
|
+
const committedFrozenRef = (0, _react.useRef)(false);
|
|
76
|
+
const component = components[props.node.type.name] ?? _DefaultNodeView.DefaultNodeView;
|
|
77
|
+
const constructor = constructors[props.node.type.name];
|
|
78
|
+
// Construct a wrapper component so that the node view remounts when either
|
|
79
|
+
// its component or constructor changes. A React node view would remount if
|
|
80
|
+
// its underlying component changed without this wrapper, but a custom node
|
|
81
|
+
// view otherwise uses the same React components for all custom node views.
|
|
82
|
+
const Component = (0, _react.useMemo)(()=>{
|
|
83
|
+
if (constructor) {
|
|
84
|
+
return function NodeView(props) {
|
|
85
|
+
return /*#__PURE__*/ _react.default.createElement(_NodeViewConstructorView.NodeViewConstructorView, {
|
|
86
|
+
constructor: constructor,
|
|
87
|
+
...props
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
} else {
|
|
91
|
+
return function NodeView(props) {
|
|
92
|
+
return /*#__PURE__*/ _react.default.createElement(_ReactNodeView.ReactNodeView, {
|
|
93
|
+
component: component,
|
|
94
|
+
...props
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}, [
|
|
99
|
+
constructor,
|
|
100
|
+
component
|
|
101
|
+
]);
|
|
102
|
+
// Protect content while frozen, and also through the single render where we
|
|
103
|
+
// leave the frozen state: `committedFrozenRef` still reflects the previous
|
|
104
|
+
// commit, so we keep returning the exact same cached element reference.
|
|
105
|
+
const protecting = (frozen || committedFrozenRef.current) && renderRef.current != null;
|
|
106
|
+
if (!protecting) {
|
|
107
|
+
renderRef.current = /*#__PURE__*/ _react.default.createElement(GetPosContext.Provider, {
|
|
108
|
+
value: props.getPos
|
|
109
|
+
}, /*#__PURE__*/ _react.default.createElement(Component, props));
|
|
110
|
+
}
|
|
111
|
+
(0, _react.useLayoutEffect)(()=>{
|
|
112
|
+
const wasFrozen = committedFrozenRef.current;
|
|
113
|
+
committedFrozenRef.current = frozen;
|
|
114
|
+
if (wasFrozen && !frozen) forceRemount();
|
|
115
|
+
}, [
|
|
116
|
+
frozen,
|
|
117
|
+
forceRemount
|
|
118
|
+
]);
|
|
119
|
+
return renderRef.current;
|
|
120
|
+
});
|
|
121
|
+
const GetPosContext = /*#__PURE__*/ (0, _react.createContext)(null);
|
|
122
|
+
function RemountableNodeView(props) {
|
|
123
|
+
const [key, forceRemount] = (0, _react.useReducer)((x)=>x + 1, 0);
|
|
124
|
+
return /*#__PURE__*/ _react.default.createElement(NodeView, {
|
|
125
|
+
key: key.toString(),
|
|
126
|
+
...props,
|
|
127
|
+
forceRemount: forceRemount
|
|
128
|
+
});
|
|
129
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "NodeViewConstructorView", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return NodeViewConstructorView;
|
|
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 _ChildDescriptionsContext = require("../../contexts/ChildDescriptionsContext.js");
|
|
15
|
+
const _useForceUpdate = require("../../hooks/useForceUpdate.js");
|
|
16
|
+
const _useNodeViewDescription = require("../../hooks/useNodeViewDescription.js");
|
|
17
|
+
const _ChildNodeViews = require("../ChildNodeViews.js");
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
19
|
+
if (typeof WeakMap !== "function") return null;
|
|
20
|
+
var cacheBabelInterop = new WeakMap();
|
|
21
|
+
var cacheNodeInterop = new WeakMap();
|
|
22
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
23
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
24
|
+
})(nodeInterop);
|
|
25
|
+
}
|
|
26
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
27
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
28
|
+
return obj;
|
|
29
|
+
}
|
|
30
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
31
|
+
return {
|
|
32
|
+
default: obj
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
36
|
+
if (cache && cache.has(obj)) {
|
|
37
|
+
return cache.get(obj);
|
|
38
|
+
}
|
|
39
|
+
var newObj = {
|
|
40
|
+
__proto__: null
|
|
41
|
+
};
|
|
42
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
43
|
+
for(var key in obj){
|
|
44
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
45
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
46
|
+
if (desc && (desc.get || desc.set)) {
|
|
47
|
+
Object.defineProperty(newObj, key, desc);
|
|
48
|
+
} else {
|
|
49
|
+
newObj[key] = obj[key];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
newObj.default = obj;
|
|
54
|
+
if (cache) {
|
|
55
|
+
cache.set(obj, newObj);
|
|
56
|
+
}
|
|
57
|
+
return newObj;
|
|
58
|
+
}
|
|
59
|
+
const NodeViewConstructorView = /*#__PURE__*/ (0, _react.memo)(function NodeViewConstructorView(param) {
|
|
60
|
+
let { constructor, node, getPos, innerDeco, outerDeco } = param;
|
|
61
|
+
const ref = (0, _react.useRef)(null);
|
|
62
|
+
const innerRef = (0, _react.useRef)(null);
|
|
63
|
+
const forceUpdate = (0, _useForceUpdate.useForceUpdate)();
|
|
64
|
+
const nodeProps = (0, _react.useMemo)(()=>({
|
|
65
|
+
node,
|
|
66
|
+
getPos,
|
|
67
|
+
decorations: outerDeco,
|
|
68
|
+
innerDecorations: innerDeco,
|
|
69
|
+
contentDOMRef: {
|
|
70
|
+
current: null
|
|
71
|
+
}
|
|
72
|
+
}), [
|
|
73
|
+
node,
|
|
74
|
+
getPos,
|
|
75
|
+
outerDeco,
|
|
76
|
+
innerDeco
|
|
77
|
+
]);
|
|
78
|
+
const createNodeView = function() {
|
|
79
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
80
|
+
args[_key] = arguments[_key];
|
|
81
|
+
}
|
|
82
|
+
const nodeView = constructor(...args);
|
|
83
|
+
if (!nodeView || !nodeView.dom) {
|
|
84
|
+
const spec = node.type.spec.toDOM?.(node);
|
|
85
|
+
if (!spec) {
|
|
86
|
+
throw new Error(`Node spec for ${node.type.name} is missing toDOM`);
|
|
87
|
+
}
|
|
88
|
+
return _prosemirrormodel.DOMSerializer.renderSpec(document, spec, null);
|
|
89
|
+
}
|
|
90
|
+
return nodeView;
|
|
91
|
+
};
|
|
92
|
+
const { childContextValue, contentDOM } = (0, _useNodeViewDescription.useNodeViewDescription)(()=>ref.current, (source)=>source?.contentDOM ?? null, function() {
|
|
93
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
94
|
+
args[_key] = arguments[_key];
|
|
95
|
+
}
|
|
96
|
+
const nodeView = createNodeView(...args);
|
|
97
|
+
const contentDOM = nodeView.contentDOM;
|
|
98
|
+
const nodeDOM = nodeView.dom;
|
|
99
|
+
const wrapperDOM = innerRef.current ?? ref.current;
|
|
100
|
+
wrapperDOM.appendChild(nodeDOM);
|
|
101
|
+
if (!contentDOM && nodeDOM instanceof HTMLElement && nodeDOM.tagName !== "BR") {
|
|
102
|
+
if (!nodeDOM.hasAttribute("contenteditable")) {
|
|
103
|
+
nodeDOM.contentEditable = "false";
|
|
104
|
+
}
|
|
105
|
+
if (node.type.spec.draggable) {
|
|
106
|
+
nodeDOM.draggable = true;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (contentDOM) {
|
|
110
|
+
// Force a re-render if we have a contentDOM,
|
|
111
|
+
// so that we properly create a portal into it
|
|
112
|
+
forceUpdate();
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
destroy () {
|
|
116
|
+
if (nodeView.destroy) {
|
|
117
|
+
nodeView.destroy();
|
|
118
|
+
}
|
|
119
|
+
wrapperDOM.removeChild(nodeDOM);
|
|
120
|
+
},
|
|
121
|
+
dom: nodeView.dom,
|
|
122
|
+
contentDOM: nodeView.contentDOM,
|
|
123
|
+
multiType: nodeView.multiType,
|
|
124
|
+
update: nodeView.update?.bind(nodeView),
|
|
125
|
+
selectNode: nodeView.selectNode?.bind(nodeView),
|
|
126
|
+
deselectNode: nodeView.deselectNode?.bind(nodeView),
|
|
127
|
+
stopEvent: nodeView.stopEvent?.bind(nodeView),
|
|
128
|
+
ignoreMutation: nodeView.ignoreMutation?.bind(nodeView)
|
|
129
|
+
};
|
|
130
|
+
}, nodeProps);
|
|
131
|
+
const Component = node.isInline ? "span" : "div";
|
|
132
|
+
const props = {
|
|
133
|
+
ref: innerRef
|
|
134
|
+
};
|
|
135
|
+
const children = !node.isLeaf && contentDOM ? /*#__PURE__*/ (0, _reactdom.createPortal)(/*#__PURE__*/ _react.default.createElement(_ChildDescriptionsContext.ChildDescriptionsContext.Provider, {
|
|
136
|
+
value: childContextValue
|
|
137
|
+
}, /*#__PURE__*/ _react.default.createElement(_ChildNodeViews.ChildNodeViews, {
|
|
138
|
+
getPos: getPos,
|
|
139
|
+
node: node,
|
|
140
|
+
innerDecorations: innerDeco
|
|
141
|
+
})), contentDOM) : null;
|
|
142
|
+
return /*#__PURE__*/ (0, _react.cloneElement)(outerDeco.reduce(_ChildNodeViews.wrapInDeco, /*#__PURE__*/ _react.default.createElement(Component, props, children)), {
|
|
143
|
+
ref
|
|
144
|
+
});
|
|
145
|
+
});
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "ReactNodeView", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return ReactNodeView;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
+
const _ChildDescriptionsContext = require("../../contexts/ChildDescriptionsContext.js");
|
|
13
|
+
const _IgnoreMutationContext = require("../../contexts/IgnoreMutationContext.js");
|
|
14
|
+
const _SelectNodeContext = require("../../contexts/SelectNodeContext.js");
|
|
15
|
+
const _StopEventContext = require("../../contexts/StopEventContext.js");
|
|
16
|
+
const _useForceUpdate = require("../../hooks/useForceUpdate.js");
|
|
17
|
+
const _useNodeViewDescription = require("../../hooks/useNodeViewDescription.js");
|
|
18
|
+
const _useSetDom = require("../../hooks/useSetDom.js");
|
|
19
|
+
const _ChildNodeViews = require("../ChildNodeViews.js");
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
21
|
+
if (typeof WeakMap !== "function") return null;
|
|
22
|
+
var cacheBabelInterop = new WeakMap();
|
|
23
|
+
var cacheNodeInterop = new WeakMap();
|
|
24
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
25
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
26
|
+
})(nodeInterop);
|
|
27
|
+
}
|
|
28
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
29
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
30
|
+
return obj;
|
|
31
|
+
}
|
|
32
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
33
|
+
return {
|
|
34
|
+
default: obj
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
38
|
+
if (cache && cache.has(obj)) {
|
|
39
|
+
return cache.get(obj);
|
|
40
|
+
}
|
|
41
|
+
var newObj = {
|
|
42
|
+
__proto__: null
|
|
43
|
+
};
|
|
44
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
45
|
+
for(var key in obj){
|
|
46
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
47
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
48
|
+
if (desc && (desc.get || desc.set)) {
|
|
49
|
+
Object.defineProperty(newObj, key, desc);
|
|
50
|
+
} else {
|
|
51
|
+
newObj[key] = obj[key];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
newObj.default = obj;
|
|
56
|
+
if (cache) {
|
|
57
|
+
cache.set(obj, newObj);
|
|
58
|
+
}
|
|
59
|
+
return newObj;
|
|
60
|
+
}
|
|
61
|
+
const ReactNodeView = /*#__PURE__*/ (0, _react.memo)(function ReactNodeView(param) {
|
|
62
|
+
let { component: Component, outerDeco, getPos, node, innerDeco } = param;
|
|
63
|
+
const [hasCustomSelectNode, setHasCustomSelectNode] = (0, _react.useState)(false);
|
|
64
|
+
const [selected, setSelected] = (0, _react.useState)(false);
|
|
65
|
+
const forceUpdate = (0, _useForceUpdate.useForceUpdate)();
|
|
66
|
+
const domRef = (0, _react.useRef)(null);
|
|
67
|
+
const nodeDOMRef = (0, _react.useRef)(null);
|
|
68
|
+
const contentDOMRef = (0, _react.useRef)(null);
|
|
69
|
+
const selectNodeRef = (0, _react.useRef)(null);
|
|
70
|
+
const deselectNodeRef = (0, _react.useRef)(null);
|
|
71
|
+
const stopEventRef = (0, _react.useRef)(null);
|
|
72
|
+
const ignoreMutationRef = (0, _react.useRef)(null);
|
|
73
|
+
const setSelectNode = (0, _react.useCallback)((selectHandler, deselectHandler)=>{
|
|
74
|
+
selectNodeRef.current = selectHandler;
|
|
75
|
+
deselectNodeRef.current = deselectHandler;
|
|
76
|
+
setHasCustomSelectNode(true);
|
|
77
|
+
return ()=>{
|
|
78
|
+
selectNodeRef.current = null;
|
|
79
|
+
deselectNodeRef.current = null;
|
|
80
|
+
setHasCustomSelectNode(false);
|
|
81
|
+
};
|
|
82
|
+
}, []);
|
|
83
|
+
const setStopEvent = (0, _react.useCallback)((handler)=>{
|
|
84
|
+
stopEventRef.current = handler;
|
|
85
|
+
return ()=>{
|
|
86
|
+
stopEventRef.current = null;
|
|
87
|
+
};
|
|
88
|
+
}, []);
|
|
89
|
+
const setIgnoreMutation = (0, _react.useCallback)((handler)=>{
|
|
90
|
+
ignoreMutationRef.current = handler;
|
|
91
|
+
return ()=>{
|
|
92
|
+
ignoreMutationRef.current = null;
|
|
93
|
+
return ()=>{
|
|
94
|
+
ignoreMutationRef.current = null;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
}, []);
|
|
98
|
+
const nodeViewDescProps = (0, _react.useMemo)(()=>({
|
|
99
|
+
node: node,
|
|
100
|
+
getPos: getPos,
|
|
101
|
+
decorations: outerDeco,
|
|
102
|
+
innerDecorations: innerDeco
|
|
103
|
+
}), [
|
|
104
|
+
getPos,
|
|
105
|
+
innerDeco,
|
|
106
|
+
node,
|
|
107
|
+
outerDeco
|
|
108
|
+
]);
|
|
109
|
+
const { childContextValue, refUpdated, isMounted } = (0, _useNodeViewDescription.useNodeViewDescription)(()=>domRef.current, ()=>contentDOMRef.current, ()=>{
|
|
110
|
+
setSelected(false);
|
|
111
|
+
return {
|
|
112
|
+
dom: nodeDOMRef.current ?? domRef.current,
|
|
113
|
+
contentDOM: contentDOMRef.current,
|
|
114
|
+
update () {
|
|
115
|
+
return true;
|
|
116
|
+
},
|
|
117
|
+
multiType: true,
|
|
118
|
+
selectNode () {
|
|
119
|
+
const selectNode = selectNodeRef.current;
|
|
120
|
+
if (selectNode) {
|
|
121
|
+
selectNode.call(this);
|
|
122
|
+
}
|
|
123
|
+
setSelected(true);
|
|
124
|
+
},
|
|
125
|
+
deselectNode () {
|
|
126
|
+
const deselectNode = deselectNodeRef.current;
|
|
127
|
+
if (deselectNode) {
|
|
128
|
+
deselectNode.call(this);
|
|
129
|
+
}
|
|
130
|
+
setSelected(false);
|
|
131
|
+
},
|
|
132
|
+
stopEvent (event) {
|
|
133
|
+
const stopEvent = stopEventRef.current;
|
|
134
|
+
if (stopEvent) {
|
|
135
|
+
return stopEvent.call(this, event);
|
|
136
|
+
}
|
|
137
|
+
return false;
|
|
138
|
+
},
|
|
139
|
+
ignoreMutation (mutation) {
|
|
140
|
+
const ignoreMutation = ignoreMutationRef.current;
|
|
141
|
+
if (ignoreMutation) {
|
|
142
|
+
return ignoreMutation.call(this, mutation);
|
|
143
|
+
}
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}, nodeViewDescProps);
|
|
148
|
+
const setDOM = (0, _useSetDom.useSetDom)(domRef, refUpdated, isMounted, forceUpdate);
|
|
149
|
+
const setNodeDOM = (0, _useSetDom.useSetDom)(nodeDOMRef, refUpdated, isMounted, forceUpdate);
|
|
150
|
+
const setContentDOM = (0, _useSetDom.useSetDom)(contentDOMRef, refUpdated, isMounted, forceUpdate);
|
|
151
|
+
const nodeProps = (0, _react.useMemo)(()=>({
|
|
152
|
+
...nodeViewDescProps,
|
|
153
|
+
contentDOMRef: setContentDOM
|
|
154
|
+
}), [
|
|
155
|
+
nodeViewDescProps,
|
|
156
|
+
setContentDOM
|
|
157
|
+
]);
|
|
158
|
+
const props = {
|
|
159
|
+
nodeProps,
|
|
160
|
+
...!contentDOMRef.current && !nodeProps.node.isText && nodeDOMRef.current?.nodeName !== "BR" ? {
|
|
161
|
+
contentEditable: false,
|
|
162
|
+
suppressContentEditableWarning: true
|
|
163
|
+
} : null,
|
|
164
|
+
...!hasCustomSelectNode && selected ? {
|
|
165
|
+
className: "ProseMirror-selectednode"
|
|
166
|
+
} : null,
|
|
167
|
+
...!hasCustomSelectNode && selected || !contentDOMRef.current && !nodeProps.node.isText && domRef.current?.nodeName !== "BR" && node.type.spec.draggable ? {
|
|
168
|
+
draggable: true
|
|
169
|
+
} : null,
|
|
170
|
+
ref: setNodeDOM
|
|
171
|
+
};
|
|
172
|
+
const children = !node.isLeaf ? /*#__PURE__*/ _react.default.createElement(_ChildNodeViews.ChildNodeViews, {
|
|
173
|
+
getPos: getPos,
|
|
174
|
+
node: node,
|
|
175
|
+
innerDecorations: innerDeco
|
|
176
|
+
}) : null;
|
|
177
|
+
const element = /*#__PURE__*/ (0, _react.cloneElement)(outerDeco.reduce(_ChildNodeViews.wrapInDeco, /*#__PURE__*/ _react.default.createElement(Component, props, children)), {
|
|
178
|
+
ref: setDOM
|
|
179
|
+
});
|
|
180
|
+
return /*#__PURE__*/ _react.default.createElement(_SelectNodeContext.SelectNodeContext.Provider, {
|
|
181
|
+
value: setSelectNode
|
|
182
|
+
}, /*#__PURE__*/ _react.default.createElement(_StopEventContext.StopEventContext.Provider, {
|
|
183
|
+
value: setStopEvent
|
|
184
|
+
}, /*#__PURE__*/ _react.default.createElement(_IgnoreMutationContext.IgnoreMutationContext.Provider, {
|
|
185
|
+
value: setIgnoreMutation
|
|
186
|
+
}, /*#__PURE__*/ _react.default.createElement(_ChildDescriptionsContext.ChildDescriptionsContext.Provider, {
|
|
187
|
+
value: childContextValue
|
|
188
|
+
}, element))));
|
|
189
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
EMPTY_SCHEMA: function() {
|
|
13
|
+
return EMPTY_SCHEMA;
|
|
14
|
+
},
|
|
15
|
+
EMPTY_STATE: function() {
|
|
16
|
+
return EMPTY_STATE;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _prosemirrormodel = require("prosemirror-model");
|
|
20
|
+
const _prosemirrorstate = require("prosemirror-state");
|
|
21
|
+
const EMPTY_SCHEMA = new _prosemirrormodel.Schema({
|
|
22
|
+
nodes: {
|
|
23
|
+
doc: {
|
|
24
|
+
content: "text*"
|
|
25
|
+
},
|
|
26
|
+
text: {
|
|
27
|
+
inline: true
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const EMPTY_STATE = _prosemirrorstate.EditorState.create({
|
|
32
|
+
schema: EMPTY_SCHEMA
|
|
33
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "ChildDescriptionsContext", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return ChildDescriptionsContext;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _react = require("react");
|
|
12
|
+
const ChildDescriptionsContext = (0, _react.createContext)({
|
|
13
|
+
parentRef: {
|
|
14
|
+
current: undefined
|
|
15
|
+
},
|
|
16
|
+
siblingsRef: {
|
|
17
|
+
current: []
|
|
18
|
+
}
|
|
19
|
+
});
|