@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,418 @@
|
|
|
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
|
+
ChildNodeViews: function() {
|
|
13
|
+
return ChildNodeViews;
|
|
14
|
+
},
|
|
15
|
+
wrapInDeco: function() {
|
|
16
|
+
return wrapInDeco;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
20
|
+
const _ChildDescriptionsContext = require("../contexts/ChildDescriptionsContext.js");
|
|
21
|
+
const _EditorContext = require("../contexts/EditorContext.js");
|
|
22
|
+
const _iterDeco = require("../decorations/iterDeco.js");
|
|
23
|
+
const _reactKeys = require("../plugins/reactKeys.js");
|
|
24
|
+
const _props = require("../props.js");
|
|
25
|
+
const _viewdesc = require("../viewdesc.js");
|
|
26
|
+
const _NativeWidgetView = require("./NativeWidgetView.js");
|
|
27
|
+
const _SeparatorHackView = require("./SeparatorHackView.js");
|
|
28
|
+
const _TextNodeView = require("./TextNodeView.js");
|
|
29
|
+
const _TrailingHackView = require("./TrailingHackView.js");
|
|
30
|
+
const _WidgetView = require("./WidgetView.js");
|
|
31
|
+
const _MarkView = require("./marks/MarkView.js");
|
|
32
|
+
const _NodeView = require("./nodes/NodeView.js");
|
|
33
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
34
|
+
if (typeof WeakMap !== "function") return null;
|
|
35
|
+
var cacheBabelInterop = new WeakMap();
|
|
36
|
+
var cacheNodeInterop = new WeakMap();
|
|
37
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
38
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
39
|
+
})(nodeInterop);
|
|
40
|
+
}
|
|
41
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
42
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
43
|
+
return obj;
|
|
44
|
+
}
|
|
45
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
46
|
+
return {
|
|
47
|
+
default: obj
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
51
|
+
if (cache && cache.has(obj)) {
|
|
52
|
+
return cache.get(obj);
|
|
53
|
+
}
|
|
54
|
+
var newObj = {
|
|
55
|
+
__proto__: null
|
|
56
|
+
};
|
|
57
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
58
|
+
for(var key in obj){
|
|
59
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
60
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
61
|
+
if (desc && (desc.get || desc.set)) {
|
|
62
|
+
Object.defineProperty(newObj, key, desc);
|
|
63
|
+
} else {
|
|
64
|
+
newObj[key] = obj[key];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
newObj.default = obj;
|
|
69
|
+
if (cache) {
|
|
70
|
+
cache.set(obj, newObj);
|
|
71
|
+
}
|
|
72
|
+
return newObj;
|
|
73
|
+
}
|
|
74
|
+
function wrapInDeco(reactNode, deco) {
|
|
75
|
+
const { nodeName, ...attrs } = deco.type.attrs;
|
|
76
|
+
const props = (0, _props.htmlAttrsToReactProps)(attrs);
|
|
77
|
+
// We auto-wrap text nodes in spans so that we can apply attributes
|
|
78
|
+
// and styles, but we want to avoid double-wrapping the same
|
|
79
|
+
// text node
|
|
80
|
+
if (nodeName || typeof reactNode === "string") {
|
|
81
|
+
return /*#__PURE__*/ (0, _react.createElement)(nodeName ?? "span", props, reactNode);
|
|
82
|
+
}
|
|
83
|
+
return /*#__PURE__*/ (0, _react.cloneElement)(reactNode, (0, _props.mergeReactProps)(reactNode.props, props));
|
|
84
|
+
}
|
|
85
|
+
function areChildrenEqual(a, b) {
|
|
86
|
+
return a.type === b.type && a.marks.every((mark)=>mark.isInSet(b.marks)) && b.marks.every((mark)=>mark.isInSet(a.marks)) && a.key === b.key && (a.type !== "node" || b.type !== "node" || a.node.eq(b.node) && (0, _viewdesc.sameOuterDeco)(a.outerDeco, b.outerDeco) && a.innerDeco.eq(b.innerDeco)) && a.widget === b.widget;
|
|
87
|
+
}
|
|
88
|
+
const ChildView = /*#__PURE__*/ (0, _react.memo)(function ChildView(param) {
|
|
89
|
+
let { child, getInnerPos } = param;
|
|
90
|
+
const { view } = (0, _react.useContext)(_EditorContext.EditorContext);
|
|
91
|
+
const childRef = (0, _react.useRef)(child);
|
|
92
|
+
childRef.current = child;
|
|
93
|
+
const getPos = (0, _react.useCallback)(()=>{
|
|
94
|
+
return getInnerPos() + childRef.current.offset;
|
|
95
|
+
}, [
|
|
96
|
+
getInnerPos
|
|
97
|
+
]);
|
|
98
|
+
return child.type === "widget" ? /*#__PURE__*/ _react.default.createElement(_WidgetView.WidgetView, {
|
|
99
|
+
key: child.key,
|
|
100
|
+
widget: child.widget,
|
|
101
|
+
getPos: getPos
|
|
102
|
+
}) : child.type === "native-widget" ? /*#__PURE__*/ _react.default.createElement(_NativeWidgetView.NativeWidgetView, {
|
|
103
|
+
key: child.key,
|
|
104
|
+
widget: child.widget,
|
|
105
|
+
getPos: getPos
|
|
106
|
+
}) : child.type === "hack" ? /*#__PURE__*/ _react.default.createElement(child.component, {
|
|
107
|
+
key: child.key,
|
|
108
|
+
getPos: getPos
|
|
109
|
+
}) : child.node.isText ? /*#__PURE__*/ _react.default.createElement(_ChildDescriptionsContext.ChildDescriptionsContext.Consumer, {
|
|
110
|
+
key: child.key
|
|
111
|
+
}, (param)=>{
|
|
112
|
+
let { siblingsRef, parentRef } = param;
|
|
113
|
+
return /*#__PURE__*/ _react.default.createElement(_TextNodeView.TextNodeView, {
|
|
114
|
+
view: view,
|
|
115
|
+
node: child.node,
|
|
116
|
+
getPos: getPos,
|
|
117
|
+
siblingsRef: siblingsRef,
|
|
118
|
+
parentRef: parentRef,
|
|
119
|
+
decorations: child.outerDeco
|
|
120
|
+
});
|
|
121
|
+
}) : /*#__PURE__*/ _react.default.createElement(_NodeView.RemountableNodeView, {
|
|
122
|
+
key: child.key,
|
|
123
|
+
node: child.node,
|
|
124
|
+
getPos: getPos,
|
|
125
|
+
outerDeco: child.outerDeco,
|
|
126
|
+
innerDeco: child.innerDeco
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
const InlinePartition = /*#__PURE__*/ (0, _react.memo)(function InlinePartition(param) {
|
|
130
|
+
let { childViews, getInnerPos } = param;
|
|
131
|
+
const firstChild = childViews[0];
|
|
132
|
+
const firstChildRef = (0, _react.useRef)(firstChild);
|
|
133
|
+
firstChildRef.current = firstChild;
|
|
134
|
+
const getPos = (0, _react.useCallback)(()=>{
|
|
135
|
+
return getInnerPos() + firstChildRef.current.offset;
|
|
136
|
+
}, [
|
|
137
|
+
getInnerPos
|
|
138
|
+
]);
|
|
139
|
+
const firstMark = firstChild.marks[0];
|
|
140
|
+
if (!firstMark) {
|
|
141
|
+
return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, childViews.map((child)=>{
|
|
142
|
+
return /*#__PURE__*/ _react.default.createElement(ChildView, {
|
|
143
|
+
key: child.key,
|
|
144
|
+
child: child,
|
|
145
|
+
getInnerPos: getInnerPos
|
|
146
|
+
});
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
return /*#__PURE__*/ _react.default.createElement(_MarkView.MarkView, {
|
|
150
|
+
key: firstChild.key,
|
|
151
|
+
mark: firstMark,
|
|
152
|
+
getPos: getPos,
|
|
153
|
+
inline: true
|
|
154
|
+
}, /*#__PURE__*/ _react.default.createElement(InlineView, {
|
|
155
|
+
key: firstChild.key,
|
|
156
|
+
getInnerPos: getInnerPos,
|
|
157
|
+
childViews: childViews.map((child)=>({
|
|
158
|
+
...child,
|
|
159
|
+
marks: child.marks.slice(1)
|
|
160
|
+
}))
|
|
161
|
+
}));
|
|
162
|
+
});
|
|
163
|
+
const InlineView = /*#__PURE__*/ (0, _react.memo)(function InlineView(param) {
|
|
164
|
+
let { getInnerPos, childViews } = param;
|
|
165
|
+
// const editorState = useEditorState();
|
|
166
|
+
const partitioned = childViews.reduce((acc, child)=>{
|
|
167
|
+
const lastPartition = acc[acc.length - 1];
|
|
168
|
+
if (!lastPartition) {
|
|
169
|
+
return [
|
|
170
|
+
[
|
|
171
|
+
child
|
|
172
|
+
]
|
|
173
|
+
];
|
|
174
|
+
}
|
|
175
|
+
const lastChild = lastPartition[lastPartition.length - 1];
|
|
176
|
+
if (!lastChild) {
|
|
177
|
+
return [
|
|
178
|
+
...acc.slice(0, acc.length),
|
|
179
|
+
[
|
|
180
|
+
child
|
|
181
|
+
]
|
|
182
|
+
];
|
|
183
|
+
}
|
|
184
|
+
if (!child.marks.length && !lastChild.marks.length || child.marks.length && lastChild.marks.length && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
185
|
+
child.marks[0]?.eq(lastChild.marks[0])) {
|
|
186
|
+
return [
|
|
187
|
+
...acc.slice(0, acc.length - 1),
|
|
188
|
+
[
|
|
189
|
+
...lastPartition.slice(0, lastPartition.length),
|
|
190
|
+
child
|
|
191
|
+
]
|
|
192
|
+
];
|
|
193
|
+
}
|
|
194
|
+
return [
|
|
195
|
+
...acc,
|
|
196
|
+
[
|
|
197
|
+
child
|
|
198
|
+
]
|
|
199
|
+
];
|
|
200
|
+
}, []);
|
|
201
|
+
return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, partitioned.map((childViews)=>{
|
|
202
|
+
const firstChild = childViews[0];
|
|
203
|
+
if (!firstChild) return null;
|
|
204
|
+
return /*#__PURE__*/ _react.default.createElement(InlinePartition, {
|
|
205
|
+
key: firstChild.key,
|
|
206
|
+
childViews: childViews,
|
|
207
|
+
getInnerPos: getInnerPos
|
|
208
|
+
});
|
|
209
|
+
}));
|
|
210
|
+
});
|
|
211
|
+
function createKey(innerPos, offset, index, type, posToKey, widget) {
|
|
212
|
+
const pos = innerPos + offset;
|
|
213
|
+
const key = posToKey?.get(pos);
|
|
214
|
+
if (type === "widget" || type === "native-widget") {
|
|
215
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
216
|
+
if (widget.type.spec.key) // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
217
|
+
return widget.type.spec.key;
|
|
218
|
+
if (type === "widget") {
|
|
219
|
+
// eslint-disable-next-line no-console
|
|
220
|
+
console.warn(`Widget at position ${pos} doesn't have a key specified. React ProseMirror will generate a key partially based on this widget’s index into its parent’s children. This can cause issues if there are multiple adjacent widgets.`);
|
|
221
|
+
}
|
|
222
|
+
return `${key}-${index}`;
|
|
223
|
+
}
|
|
224
|
+
if (key) return key;
|
|
225
|
+
// if (!doc) return pos;
|
|
226
|
+
const parentPos = innerPos - 1;
|
|
227
|
+
const parentKey = posToKey?.get(parentPos);
|
|
228
|
+
if (parentKey) return `${parentKey}-${offset}`;
|
|
229
|
+
return pos;
|
|
230
|
+
}
|
|
231
|
+
function adjustWidgetMarksForward(lastNodeChild, widgetChild) {
|
|
232
|
+
if (!widgetChild || // Using internal Decoration property, "type"
|
|
233
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
234
|
+
widgetChild.widget.type.side >= 0) return;
|
|
235
|
+
if (!lastNodeChild || !lastNodeChild.node.isInline) return;
|
|
236
|
+
const marksToSpread = lastNodeChild.marks;
|
|
237
|
+
widgetChild.marks = widgetChild.marks.reduce((acc, mark)=>mark.addToSet(acc), marksToSpread);
|
|
238
|
+
}
|
|
239
|
+
function adjustWidgetMarksBack(widgetChildren, nodeChild) {
|
|
240
|
+
if (!nodeChild.node.isInline) return;
|
|
241
|
+
const marksToSpread = nodeChild.marks;
|
|
242
|
+
for(let i = widgetChildren.length - 1; i >= 0; i--){
|
|
243
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
244
|
+
const child = widgetChildren[i];
|
|
245
|
+
if (// Using internal Decoration property, "type"
|
|
246
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
247
|
+
child.widget.type.side < 0 || // Using internal Decoration property, "type"
|
|
248
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
249
|
+
child.widget.type.spec.marks) {
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
child.marks = child.marks.reduce((acc, mark)=>mark.addToSet(acc), marksToSpread);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const ChildElement = /*#__PURE__*/ (0, _react.memo)(function ChildElement(param) {
|
|
256
|
+
let { child, getInnerPos } = param;
|
|
257
|
+
const childRef = (0, _react.useRef)(child);
|
|
258
|
+
childRef.current = child;
|
|
259
|
+
const getPos = (0, _react.useCallback)(()=>{
|
|
260
|
+
return getInnerPos() + childRef.current.offset;
|
|
261
|
+
}, [
|
|
262
|
+
getInnerPos
|
|
263
|
+
]);
|
|
264
|
+
if (child.type === "node") {
|
|
265
|
+
return child.marks.reduce((element, mark)=>/*#__PURE__*/ _react.default.createElement(_MarkView.MarkView, {
|
|
266
|
+
mark: mark,
|
|
267
|
+
getPos: getPos,
|
|
268
|
+
inline: false
|
|
269
|
+
}, element), /*#__PURE__*/ _react.default.createElement(_NodeView.RemountableNodeView, {
|
|
270
|
+
key: child.key,
|
|
271
|
+
outerDeco: child.outerDeco,
|
|
272
|
+
node: child.node,
|
|
273
|
+
innerDeco: child.innerDeco,
|
|
274
|
+
getPos: getPos
|
|
275
|
+
}));
|
|
276
|
+
} else {
|
|
277
|
+
return /*#__PURE__*/ _react.default.createElement(InlineView, {
|
|
278
|
+
key: child.key,
|
|
279
|
+
childViews: [
|
|
280
|
+
child
|
|
281
|
+
],
|
|
282
|
+
getInnerPos: getInnerPos
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
function createChildElements(children, getInnerPos) {
|
|
287
|
+
if (!children.length) return [];
|
|
288
|
+
if (children.every((child)=>child.type !== "node" || child.node.isInline)) {
|
|
289
|
+
return [
|
|
290
|
+
/*#__PURE__*/ _react.default.createElement(InlineView, {
|
|
291
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
292
|
+
key: children[0].key,
|
|
293
|
+
childViews: children,
|
|
294
|
+
getInnerPos: getInnerPos
|
|
295
|
+
})
|
|
296
|
+
];
|
|
297
|
+
}
|
|
298
|
+
return children.map((child)=>{
|
|
299
|
+
return /*#__PURE__*/ _react.default.createElement(ChildElement, {
|
|
300
|
+
key: child.key,
|
|
301
|
+
child: child,
|
|
302
|
+
getInnerPos: getInnerPos
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
const ChildNodeViews = /*#__PURE__*/ (0, _react.memo)(function ChildNodeViews(param) {
|
|
307
|
+
let { getPos, node, innerDecorations } = param;
|
|
308
|
+
const { view } = (0, _react.useContext)(_EditorContext.EditorContext);
|
|
309
|
+
const getInnerPos = (0, _react.useCallback)(()=>getPos() + 1, [
|
|
310
|
+
getPos
|
|
311
|
+
]);
|
|
312
|
+
const childMap = (0, _react.useRef)(new Map()).current;
|
|
313
|
+
if (!node) return null;
|
|
314
|
+
const keysSeen = new Map();
|
|
315
|
+
let widgetChildren = [];
|
|
316
|
+
let lastNodeChild = null;
|
|
317
|
+
(0, _iterDeco.iterDeco)(node, innerDecorations, (widget, isNative, offset, index)=>{
|
|
318
|
+
const posToKey = _reactKeys.reactKeysPluginKey.getState(view.state)?.posToKey;
|
|
319
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
320
|
+
const widgetMarks = widget.type.spec.marks ?? [];
|
|
321
|
+
let key;
|
|
322
|
+
if (isNative) {
|
|
323
|
+
key = createKey(getInnerPos(), offset, index, "native-widget", posToKey, widget);
|
|
324
|
+
const child = {
|
|
325
|
+
type: "native-widget",
|
|
326
|
+
widget,
|
|
327
|
+
marks: widgetMarks,
|
|
328
|
+
offset,
|
|
329
|
+
index,
|
|
330
|
+
key
|
|
331
|
+
};
|
|
332
|
+
const prevChild = childMap.get(key);
|
|
333
|
+
if (prevChild && areChildrenEqual(prevChild, child)) {
|
|
334
|
+
prevChild.offset = offset;
|
|
335
|
+
} else {
|
|
336
|
+
childMap.set(key, child);
|
|
337
|
+
}
|
|
338
|
+
keysSeen.set(key, keysSeen.size);
|
|
339
|
+
} else {
|
|
340
|
+
key = createKey(getInnerPos(), offset, index, "widget", posToKey, widget);
|
|
341
|
+
const child = {
|
|
342
|
+
type: "widget",
|
|
343
|
+
widget: widget,
|
|
344
|
+
marks: widgetMarks,
|
|
345
|
+
offset,
|
|
346
|
+
index,
|
|
347
|
+
key
|
|
348
|
+
};
|
|
349
|
+
const prevChild = childMap.get(key);
|
|
350
|
+
if (prevChild && areChildrenEqual(prevChild, child)) {
|
|
351
|
+
prevChild.offset = offset;
|
|
352
|
+
} else {
|
|
353
|
+
childMap.set(key, child);
|
|
354
|
+
}
|
|
355
|
+
keysSeen.set(key, keysSeen.size);
|
|
356
|
+
}
|
|
357
|
+
const child = childMap.get(key);
|
|
358
|
+
widgetChildren.push(child);
|
|
359
|
+
adjustWidgetMarksForward(lastNodeChild, childMap.get(key));
|
|
360
|
+
}, (childNode, outerDeco, innerDeco, offset, index)=>{
|
|
361
|
+
const posToKey = _reactKeys.reactKeysPluginKey.getState(view.state)?.posToKey;
|
|
362
|
+
const key = createKey(getInnerPos(), offset, index, "node", posToKey);
|
|
363
|
+
const child = {
|
|
364
|
+
type: "node",
|
|
365
|
+
node: childNode,
|
|
366
|
+
marks: childNode.marks,
|
|
367
|
+
innerDeco,
|
|
368
|
+
outerDeco,
|
|
369
|
+
offset,
|
|
370
|
+
index,
|
|
371
|
+
key
|
|
372
|
+
};
|
|
373
|
+
const prevChild = childMap.get(key);
|
|
374
|
+
if (prevChild && areChildrenEqual(prevChild, child)) {
|
|
375
|
+
prevChild.offset = offset;
|
|
376
|
+
lastNodeChild = prevChild;
|
|
377
|
+
} else {
|
|
378
|
+
childMap.set(key, child);
|
|
379
|
+
lastNodeChild = child;
|
|
380
|
+
}
|
|
381
|
+
keysSeen.set(key, keysSeen.size);
|
|
382
|
+
adjustWidgetMarksBack(widgetChildren, lastNodeChild);
|
|
383
|
+
widgetChildren = [];
|
|
384
|
+
});
|
|
385
|
+
for (const key of childMap.keys()){
|
|
386
|
+
if (!keysSeen.has(key)) {
|
|
387
|
+
childMap.delete(key);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
const children = Array.from(childMap.values()).sort(// We already ensured that these existed in keysSeen in the previous
|
|
391
|
+
// step
|
|
392
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
393
|
+
(a, b)=>keysSeen.get(a.key) - keysSeen.get(b.key));
|
|
394
|
+
if (node.isTextblock) {
|
|
395
|
+
const lastChild = children[children.length - 1];
|
|
396
|
+
if (!lastChild || lastChild.type !== "node" || lastChild.node.isInline && !lastChild.node.isText || // RegExp.test actually handles undefined just fine
|
|
397
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
398
|
+
/\n$/.test(lastChild.node.text)) {
|
|
399
|
+
children.push({
|
|
400
|
+
type: "hack",
|
|
401
|
+
component: _SeparatorHackView.SeparatorHackView,
|
|
402
|
+
marks: [],
|
|
403
|
+
offset: lastChild?.offset ?? 0,
|
|
404
|
+
index: (lastChild?.index ?? 0) + 1,
|
|
405
|
+
key: "trailing-hack-img"
|
|
406
|
+
}, {
|
|
407
|
+
type: "hack",
|
|
408
|
+
component: _TrailingHackView.TrailingHackView,
|
|
409
|
+
marks: [],
|
|
410
|
+
offset: lastChild?.offset ?? 0,
|
|
411
|
+
index: (lastChild?.index ?? 0) + 2,
|
|
412
|
+
key: "trailing-hack-br"
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
const childElements = createChildElements(children, getInnerPos);
|
|
417
|
+
return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, childElements);
|
|
418
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "CursorWrapper", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return CursorWrapper;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
+
const _ReactEditorView = require("../ReactEditorView.js");
|
|
13
|
+
const _dom = require("../dom.js");
|
|
14
|
+
const _useEditorEffect = require("../hooks/useEditorEffect.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 CursorWrapper = /*#__PURE__*/ (0, _react.forwardRef)(function CursorWrapper(param, ref) {
|
|
57
|
+
let { widget, getPos, ...props } = param;
|
|
58
|
+
const innerRef = (0, _react.useRef)(null);
|
|
59
|
+
(0, _react.useImperativeHandle)(ref, ()=>{
|
|
60
|
+
return innerRef.current;
|
|
61
|
+
}, []);
|
|
62
|
+
(0, _useEditorEffect.useEditorEffect)((view)=>{
|
|
63
|
+
if (!(view instanceof _ReactEditorView.ReactEditorView) || !innerRef.current) return;
|
|
64
|
+
view.domObserver.disconnectSelection();
|
|
65
|
+
const domSel = view.domSelection();
|
|
66
|
+
if (!domSel.isCollapsed) return;
|
|
67
|
+
const node = innerRef.current;
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
69
|
+
domSel.collapse(node.parentNode, (0, _dom.domIndex)(node) + 1);
|
|
70
|
+
view.cursorWrapped = true;
|
|
71
|
+
view.domObserver.connectSelection();
|
|
72
|
+
return ()=>{
|
|
73
|
+
view.cursorWrapped = false;
|
|
74
|
+
};
|
|
75
|
+
}, []);
|
|
76
|
+
return /*#__PURE__*/ _react.default.createElement("img", {
|
|
77
|
+
ref: innerRef,
|
|
78
|
+
className: "ProseMirror-separator",
|
|
79
|
+
// eslint-disable-next-line react/no-unknown-property
|
|
80
|
+
"mark-placeholder": "true",
|
|
81
|
+
alt: "",
|
|
82
|
+
...props
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
EditorStateSelectorsProvider: function() {
|
|
13
|
+
return EditorStateSelectorsProvider;
|
|
14
|
+
},
|
|
15
|
+
EditorStateSelectorsRegistrar: function() {
|
|
16
|
+
return EditorStateSelectorsRegistrar;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
20
|
+
const _EditorStateStoreContext = require("../contexts/EditorStateStoreContext.js");
|
|
21
|
+
const _useEditorState = require("../hooks/useEditorState.js");
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
23
|
+
if (typeof WeakMap !== "function") return null;
|
|
24
|
+
var cacheBabelInterop = new WeakMap();
|
|
25
|
+
var cacheNodeInterop = new WeakMap();
|
|
26
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
27
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
28
|
+
})(nodeInterop);
|
|
29
|
+
}
|
|
30
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
31
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
32
|
+
return obj;
|
|
33
|
+
}
|
|
34
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
35
|
+
return {
|
|
36
|
+
default: obj
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
40
|
+
if (cache && cache.has(obj)) {
|
|
41
|
+
return cache.get(obj);
|
|
42
|
+
}
|
|
43
|
+
var newObj = {
|
|
44
|
+
__proto__: null
|
|
45
|
+
};
|
|
46
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
47
|
+
for(var key in obj){
|
|
48
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
49
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
50
|
+
if (desc && (desc.get || desc.set)) {
|
|
51
|
+
Object.defineProperty(newObj, key, desc);
|
|
52
|
+
} else {
|
|
53
|
+
newObj[key] = obj[key];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
newObj.default = obj;
|
|
58
|
+
if (cache) {
|
|
59
|
+
cache.set(obj, newObj);
|
|
60
|
+
}
|
|
61
|
+
return newObj;
|
|
62
|
+
}
|
|
63
|
+
function EditorStateSelectorsRegistrar(param) {
|
|
64
|
+
let { children } = param;
|
|
65
|
+
const store = (0, _react.useMemo)(()=>(0, _EditorStateStoreContext.createEditorStateStore)(), []);
|
|
66
|
+
return /*#__PURE__*/ _react.default.createElement(_EditorStateStoreContext.EditorStateStoreContext.Provider, {
|
|
67
|
+
value: store
|
|
68
|
+
}, children);
|
|
69
|
+
}
|
|
70
|
+
function EditorStateSelectorsProvider(param) {
|
|
71
|
+
let { children } = param;
|
|
72
|
+
const editorState = (0, _useEditorState.useEditorState)();
|
|
73
|
+
const store = (0, _react.useContext)(_EditorStateStoreContext.EditorStateStoreContext);
|
|
74
|
+
// This _must_ be set during render so that child components
|
|
75
|
+
// get the latest values from their selectors during render,
|
|
76
|
+
// if they happen to render before store.notifyListeners()
|
|
77
|
+
// is called
|
|
78
|
+
store.setState(editorState);
|
|
79
|
+
// This means that we get a double-render whenever the selectors update,
|
|
80
|
+
// but everything is consistent during both renders.
|
|
81
|
+
// Only components with new selector values will render on
|
|
82
|
+
// the second render cycle
|
|
83
|
+
(0, _react.useLayoutEffect)(()=>{
|
|
84
|
+
store.notifyListeners();
|
|
85
|
+
}, [
|
|
86
|
+
editorState,
|
|
87
|
+
store
|
|
88
|
+
]);
|
|
89
|
+
return children;
|
|
90
|
+
}
|