@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,94 @@
|
|
|
1
|
+
import { DOMSerializer } from "prosemirror-model";
|
|
2
|
+
import React, { cloneElement, memo, useMemo, useRef } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import { ChildDescriptionsContext } from "../../contexts/ChildDescriptionsContext.js";
|
|
5
|
+
import { useForceUpdate } from "../../hooks/useForceUpdate.js";
|
|
6
|
+
import { useNodeViewDescription } from "../../hooks/useNodeViewDescription.js";
|
|
7
|
+
import { ChildNodeViews, wrapInDeco } from "../ChildNodeViews.js";
|
|
8
|
+
export const NodeViewConstructorView = /*#__PURE__*/ memo(function NodeViewConstructorView(param) {
|
|
9
|
+
let { constructor, node, getPos, innerDeco, outerDeco } = param;
|
|
10
|
+
const ref = useRef(null);
|
|
11
|
+
const innerRef = useRef(null);
|
|
12
|
+
const forceUpdate = useForceUpdate();
|
|
13
|
+
const nodeProps = useMemo(()=>({
|
|
14
|
+
node,
|
|
15
|
+
getPos,
|
|
16
|
+
decorations: outerDeco,
|
|
17
|
+
innerDecorations: innerDeco,
|
|
18
|
+
contentDOMRef: {
|
|
19
|
+
current: null
|
|
20
|
+
}
|
|
21
|
+
}), [
|
|
22
|
+
node,
|
|
23
|
+
getPos,
|
|
24
|
+
outerDeco,
|
|
25
|
+
innerDeco
|
|
26
|
+
]);
|
|
27
|
+
const createNodeView = function() {
|
|
28
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
29
|
+
args[_key] = arguments[_key];
|
|
30
|
+
}
|
|
31
|
+
const nodeView = constructor(...args);
|
|
32
|
+
if (!nodeView || !nodeView.dom) {
|
|
33
|
+
const spec = node.type.spec.toDOM?.(node);
|
|
34
|
+
if (!spec) {
|
|
35
|
+
throw new Error(`Node spec for ${node.type.name} is missing toDOM`);
|
|
36
|
+
}
|
|
37
|
+
return DOMSerializer.renderSpec(document, spec, null);
|
|
38
|
+
}
|
|
39
|
+
return nodeView;
|
|
40
|
+
};
|
|
41
|
+
const { childContextValue, contentDOM } = useNodeViewDescription(()=>ref.current, (source)=>source?.contentDOM ?? null, function() {
|
|
42
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
43
|
+
args[_key] = arguments[_key];
|
|
44
|
+
}
|
|
45
|
+
const nodeView = createNodeView(...args);
|
|
46
|
+
const contentDOM = nodeView.contentDOM;
|
|
47
|
+
const nodeDOM = nodeView.dom;
|
|
48
|
+
const wrapperDOM = innerRef.current ?? ref.current;
|
|
49
|
+
wrapperDOM.appendChild(nodeDOM);
|
|
50
|
+
if (!contentDOM && nodeDOM instanceof HTMLElement && nodeDOM.tagName !== "BR") {
|
|
51
|
+
if (!nodeDOM.hasAttribute("contenteditable")) {
|
|
52
|
+
nodeDOM.contentEditable = "false";
|
|
53
|
+
}
|
|
54
|
+
if (node.type.spec.draggable) {
|
|
55
|
+
nodeDOM.draggable = true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (contentDOM) {
|
|
59
|
+
// Force a re-render if we have a contentDOM,
|
|
60
|
+
// so that we properly create a portal into it
|
|
61
|
+
forceUpdate();
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
destroy () {
|
|
65
|
+
if (nodeView.destroy) {
|
|
66
|
+
nodeView.destroy();
|
|
67
|
+
}
|
|
68
|
+
wrapperDOM.removeChild(nodeDOM);
|
|
69
|
+
},
|
|
70
|
+
dom: nodeView.dom,
|
|
71
|
+
contentDOM: nodeView.contentDOM,
|
|
72
|
+
multiType: nodeView.multiType,
|
|
73
|
+
update: nodeView.update?.bind(nodeView),
|
|
74
|
+
selectNode: nodeView.selectNode?.bind(nodeView),
|
|
75
|
+
deselectNode: nodeView.deselectNode?.bind(nodeView),
|
|
76
|
+
stopEvent: nodeView.stopEvent?.bind(nodeView),
|
|
77
|
+
ignoreMutation: nodeView.ignoreMutation?.bind(nodeView)
|
|
78
|
+
};
|
|
79
|
+
}, nodeProps);
|
|
80
|
+
const Component = node.isInline ? "span" : "div";
|
|
81
|
+
const props = {
|
|
82
|
+
ref: innerRef
|
|
83
|
+
};
|
|
84
|
+
const children = !node.isLeaf && contentDOM ? /*#__PURE__*/ createPortal(/*#__PURE__*/ React.createElement(ChildDescriptionsContext.Provider, {
|
|
85
|
+
value: childContextValue
|
|
86
|
+
}, /*#__PURE__*/ React.createElement(ChildNodeViews, {
|
|
87
|
+
getPos: getPos,
|
|
88
|
+
node: node,
|
|
89
|
+
innerDecorations: innerDeco
|
|
90
|
+
})), contentDOM) : null;
|
|
91
|
+
return /*#__PURE__*/ cloneElement(outerDeco.reduce(wrapInDeco, /*#__PURE__*/ React.createElement(Component, props, children)), {
|
|
92
|
+
ref
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import React, { cloneElement, memo, useCallback, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { ChildDescriptionsContext } from "../../contexts/ChildDescriptionsContext.js";
|
|
3
|
+
import { IgnoreMutationContext } from "../../contexts/IgnoreMutationContext.js";
|
|
4
|
+
import { SelectNodeContext } from "../../contexts/SelectNodeContext.js";
|
|
5
|
+
import { StopEventContext } from "../../contexts/StopEventContext.js";
|
|
6
|
+
import { useForceUpdate } from "../../hooks/useForceUpdate.js";
|
|
7
|
+
import { useNodeViewDescription } from "../../hooks/useNodeViewDescription.js";
|
|
8
|
+
import { useSetDom } from "../../hooks/useSetDom.js";
|
|
9
|
+
import { ChildNodeViews, wrapInDeco } from "../ChildNodeViews.js";
|
|
10
|
+
export const ReactNodeView = /*#__PURE__*/ memo(function ReactNodeView(param) {
|
|
11
|
+
let { component: Component, outerDeco, getPos, node, innerDeco } = param;
|
|
12
|
+
const [hasCustomSelectNode, setHasCustomSelectNode] = useState(false);
|
|
13
|
+
const [selected, setSelected] = useState(false);
|
|
14
|
+
const forceUpdate = useForceUpdate();
|
|
15
|
+
const domRef = useRef(null);
|
|
16
|
+
const nodeDOMRef = useRef(null);
|
|
17
|
+
const contentDOMRef = useRef(null);
|
|
18
|
+
const selectNodeRef = useRef(null);
|
|
19
|
+
const deselectNodeRef = useRef(null);
|
|
20
|
+
const stopEventRef = useRef(null);
|
|
21
|
+
const ignoreMutationRef = useRef(null);
|
|
22
|
+
const setSelectNode = useCallback((selectHandler, deselectHandler)=>{
|
|
23
|
+
selectNodeRef.current = selectHandler;
|
|
24
|
+
deselectNodeRef.current = deselectHandler;
|
|
25
|
+
setHasCustomSelectNode(true);
|
|
26
|
+
return ()=>{
|
|
27
|
+
selectNodeRef.current = null;
|
|
28
|
+
deselectNodeRef.current = null;
|
|
29
|
+
setHasCustomSelectNode(false);
|
|
30
|
+
};
|
|
31
|
+
}, []);
|
|
32
|
+
const setStopEvent = useCallback((handler)=>{
|
|
33
|
+
stopEventRef.current = handler;
|
|
34
|
+
return ()=>{
|
|
35
|
+
stopEventRef.current = null;
|
|
36
|
+
};
|
|
37
|
+
}, []);
|
|
38
|
+
const setIgnoreMutation = useCallback((handler)=>{
|
|
39
|
+
ignoreMutationRef.current = handler;
|
|
40
|
+
return ()=>{
|
|
41
|
+
ignoreMutationRef.current = null;
|
|
42
|
+
return ()=>{
|
|
43
|
+
ignoreMutationRef.current = null;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
}, []);
|
|
47
|
+
const nodeViewDescProps = useMemo(()=>({
|
|
48
|
+
node: node,
|
|
49
|
+
getPos: getPos,
|
|
50
|
+
decorations: outerDeco,
|
|
51
|
+
innerDecorations: innerDeco
|
|
52
|
+
}), [
|
|
53
|
+
getPos,
|
|
54
|
+
innerDeco,
|
|
55
|
+
node,
|
|
56
|
+
outerDeco
|
|
57
|
+
]);
|
|
58
|
+
const { childContextValue, refUpdated, isMounted } = useNodeViewDescription(()=>domRef.current, ()=>contentDOMRef.current, ()=>{
|
|
59
|
+
setSelected(false);
|
|
60
|
+
return {
|
|
61
|
+
dom: nodeDOMRef.current ?? domRef.current,
|
|
62
|
+
contentDOM: contentDOMRef.current,
|
|
63
|
+
update () {
|
|
64
|
+
return true;
|
|
65
|
+
},
|
|
66
|
+
multiType: true,
|
|
67
|
+
selectNode () {
|
|
68
|
+
const selectNode = selectNodeRef.current;
|
|
69
|
+
if (selectNode) {
|
|
70
|
+
selectNode.call(this);
|
|
71
|
+
}
|
|
72
|
+
setSelected(true);
|
|
73
|
+
},
|
|
74
|
+
deselectNode () {
|
|
75
|
+
const deselectNode = deselectNodeRef.current;
|
|
76
|
+
if (deselectNode) {
|
|
77
|
+
deselectNode.call(this);
|
|
78
|
+
}
|
|
79
|
+
setSelected(false);
|
|
80
|
+
},
|
|
81
|
+
stopEvent (event) {
|
|
82
|
+
const stopEvent = stopEventRef.current;
|
|
83
|
+
if (stopEvent) {
|
|
84
|
+
return stopEvent.call(this, event);
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
},
|
|
88
|
+
ignoreMutation (mutation) {
|
|
89
|
+
const ignoreMutation = ignoreMutationRef.current;
|
|
90
|
+
if (ignoreMutation) {
|
|
91
|
+
return ignoreMutation.call(this, mutation);
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}, nodeViewDescProps);
|
|
97
|
+
const setDOM = useSetDom(domRef, refUpdated, isMounted, forceUpdate);
|
|
98
|
+
const setNodeDOM = useSetDom(nodeDOMRef, refUpdated, isMounted, forceUpdate);
|
|
99
|
+
const setContentDOM = useSetDom(contentDOMRef, refUpdated, isMounted, forceUpdate);
|
|
100
|
+
const nodeProps = useMemo(()=>({
|
|
101
|
+
...nodeViewDescProps,
|
|
102
|
+
contentDOMRef: setContentDOM
|
|
103
|
+
}), [
|
|
104
|
+
nodeViewDescProps,
|
|
105
|
+
setContentDOM
|
|
106
|
+
]);
|
|
107
|
+
const props = {
|
|
108
|
+
nodeProps,
|
|
109
|
+
...!contentDOMRef.current && !nodeProps.node.isText && nodeDOMRef.current?.nodeName !== "BR" ? {
|
|
110
|
+
contentEditable: false,
|
|
111
|
+
suppressContentEditableWarning: true
|
|
112
|
+
} : null,
|
|
113
|
+
...!hasCustomSelectNode && selected ? {
|
|
114
|
+
className: "ProseMirror-selectednode"
|
|
115
|
+
} : null,
|
|
116
|
+
...!hasCustomSelectNode && selected || !contentDOMRef.current && !nodeProps.node.isText && domRef.current?.nodeName !== "BR" && node.type.spec.draggable ? {
|
|
117
|
+
draggable: true
|
|
118
|
+
} : null,
|
|
119
|
+
ref: setNodeDOM
|
|
120
|
+
};
|
|
121
|
+
const children = !node.isLeaf ? /*#__PURE__*/ React.createElement(ChildNodeViews, {
|
|
122
|
+
getPos: getPos,
|
|
123
|
+
node: node,
|
|
124
|
+
innerDecorations: innerDeco
|
|
125
|
+
}) : null;
|
|
126
|
+
const element = /*#__PURE__*/ cloneElement(outerDeco.reduce(wrapInDeco, /*#__PURE__*/ React.createElement(Component, props, children)), {
|
|
127
|
+
ref: setDOM
|
|
128
|
+
});
|
|
129
|
+
return /*#__PURE__*/ React.createElement(SelectNodeContext.Provider, {
|
|
130
|
+
value: setSelectNode
|
|
131
|
+
}, /*#__PURE__*/ React.createElement(StopEventContext.Provider, {
|
|
132
|
+
value: setStopEvent
|
|
133
|
+
}, /*#__PURE__*/ React.createElement(IgnoreMutationContext.Provider, {
|
|
134
|
+
value: setIgnoreMutation
|
|
135
|
+
}, /*#__PURE__*/ React.createElement(ChildDescriptionsContext.Provider, {
|
|
136
|
+
value: childContextValue
|
|
137
|
+
}, element))));
|
|
138
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Schema } from "prosemirror-model";
|
|
2
|
+
import { EditorState } from "prosemirror-state";
|
|
3
|
+
export const EMPTY_SCHEMA = new Schema({
|
|
4
|
+
nodes: {
|
|
5
|
+
doc: {
|
|
6
|
+
content: "text*"
|
|
7
|
+
},
|
|
8
|
+
text: {
|
|
9
|
+
inline: true
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
export const EMPTY_STATE = EditorState.create({
|
|
14
|
+
schema: EMPTY_SCHEMA
|
|
15
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/* Copyright (c) The New York Times Company */ import { createContext } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Provides the EditorView, as well as the current
|
|
4
|
+
* EditorState. Should not be consumed directly; instead
|
|
5
|
+
* see `useEditorState`, `useEditorViewEvent`, and
|
|
6
|
+
* `useEditorViewLayoutEffect`.
|
|
7
|
+
*/ export const EditorContext = createContext(null);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
export function createEditorStateStore() {
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
+
let state = null;
|
|
5
|
+
let pendingNotify = false;
|
|
6
|
+
const listeners = new Set();
|
|
7
|
+
return {
|
|
8
|
+
getState: ()=>state,
|
|
9
|
+
subscribe: (listener)=>{
|
|
10
|
+
listeners.add(listener);
|
|
11
|
+
return ()=>listeners.delete(listener);
|
|
12
|
+
},
|
|
13
|
+
setState: (newState)=>{
|
|
14
|
+
if (state !== newState) {
|
|
15
|
+
state = newState;
|
|
16
|
+
pendingNotify = true;
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
notifyListeners: ()=>{
|
|
20
|
+
if (pendingNotify) {
|
|
21
|
+
pendingNotify = false;
|
|
22
|
+
listeners.forEach((l)=>l());
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export const EditorStateStoreContext = createContext(null);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createContext, useContext, useSyncExternalStore } from "react";
|
|
2
|
+
export const createRenderStore = ()=>{
|
|
3
|
+
const listeners = new Set();
|
|
4
|
+
let version = 0;
|
|
5
|
+
const store = {
|
|
6
|
+
state: null,
|
|
7
|
+
doc: null,
|
|
8
|
+
announced: false,
|
|
9
|
+
getVersion: ()=>version,
|
|
10
|
+
subscribe: (listener)=>{
|
|
11
|
+
listeners.add(listener);
|
|
12
|
+
return ()=>{
|
|
13
|
+
listeners.delete(listener);
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
announce: ()=>{
|
|
17
|
+
// Nobody to re-render through the store: let the contexts change.
|
|
18
|
+
if (!listeners.size) return;
|
|
19
|
+
store.announced = true;
|
|
20
|
+
version++;
|
|
21
|
+
listeners.forEach((listener)=>listener());
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
return store;
|
|
25
|
+
};
|
|
26
|
+
export const RenderStoreContext = createContext(null);
|
|
27
|
+
const inertStore = createRenderStore();
|
|
28
|
+
/** Subscribes to announced transactions; null when `stableContexts` is off. */ export const useRenderStore = ()=>{
|
|
29
|
+
const store = useContext(RenderStoreContext);
|
|
30
|
+
const subscribed = store ?? inertStore;
|
|
31
|
+
useSyncExternalStore(subscribed.subscribe, subscribed.getVersion, subscribed.getVersion);
|
|
32
|
+
return store;
|
|
33
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Decoration } from "prosemirror-view";
|
|
2
|
+
function compareObjs(a, b) {
|
|
3
|
+
if (a == b) return true;
|
|
4
|
+
for(const p in a)if (a[p] !== b[p]) return false;
|
|
5
|
+
for(const p in b)if (!(p in a)) return false;
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
const noSpec = {
|
|
9
|
+
side: 0
|
|
10
|
+
};
|
|
11
|
+
export class ReactWidgetType {
|
|
12
|
+
Component;
|
|
13
|
+
side;
|
|
14
|
+
spec;
|
|
15
|
+
constructor(Component, spec){
|
|
16
|
+
this.Component = Component;
|
|
17
|
+
this.spec = spec ?? noSpec;
|
|
18
|
+
this.side = this.spec.side ?? 0;
|
|
19
|
+
}
|
|
20
|
+
map(mapping, span, offset, oldOffset) {
|
|
21
|
+
const { pos, deleted } = mapping.mapResult(span.from + oldOffset, this.side < 0 ? -1 : 1);
|
|
22
|
+
// @ts-expect-error The Decoration constructor is private/internal, but
|
|
23
|
+
// we need to use it for our custom widget implementation here.
|
|
24
|
+
return deleted ? null : new Decoration(pos - offset, pos - offset, this);
|
|
25
|
+
}
|
|
26
|
+
valid() {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
eq(other) {
|
|
30
|
+
return this == other || other instanceof ReactWidgetType && (this.spec.key && this.spec.key == other.spec.key || this.Component == other.Component && compareObjs(this.spec, other.spec));
|
|
31
|
+
}
|
|
32
|
+
destroy() {
|
|
33
|
+
// Can be implemented with React effect hooks
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function widget(pos, component, spec) {
|
|
37
|
+
// @ts-expect-error The Decoration constructor is private/internal, but
|
|
38
|
+
// we need to use it for our custom widget implementation here.
|
|
39
|
+
return new Decoration(pos, pos, new ReactWidgetType(component, spec));
|
|
40
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Decoration } from "prosemirror-view";
|
|
2
|
+
const DocDecorationsCache = new WeakMap();
|
|
3
|
+
/**
|
|
4
|
+
* Produces the outer decorations for the doc node, based
|
|
5
|
+
* on the attributes editor prop.
|
|
6
|
+
*
|
|
7
|
+
* The return value of this function is memoized; if it is to
|
|
8
|
+
* return an equivalent value to the last time it was called for
|
|
9
|
+
* a given EditorView, it will return exactly that previous value.
|
|
10
|
+
*
|
|
11
|
+
* This makes it safe to call in a React render function, even
|
|
12
|
+
* if its result is used in a dependencies array for a hook.
|
|
13
|
+
*/ export function computeDocDeco(view) {
|
|
14
|
+
const attrs = Object.create(null);
|
|
15
|
+
attrs.class = "ProseMirror";
|
|
16
|
+
attrs.contenteditable = String(view.editable);
|
|
17
|
+
view.someProp("attributes", (value)=>{
|
|
18
|
+
if (typeof value == "function") value = value(view.state);
|
|
19
|
+
if (value) for(const attr in value){
|
|
20
|
+
if (attr == "class") attrs.class += " " + value[attr];
|
|
21
|
+
else if (attr == "style") attrs.style = (attrs.style ? attrs.style + ";" : "") + value[attr];
|
|
22
|
+
else if (!attrs[attr] && attr != "contenteditable" && attr != "nodeName") attrs[attr] = String(value[attr]);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
if (!attrs.translate) attrs.translate = "no";
|
|
26
|
+
const next = [
|
|
27
|
+
Decoration.node(0, view.state.doc.content.size, attrs)
|
|
28
|
+
];
|
|
29
|
+
const previous = DocDecorationsCache.get(view);
|
|
30
|
+
if (!previous) {
|
|
31
|
+
DocDecorationsCache.set(view, next);
|
|
32
|
+
return next;
|
|
33
|
+
}
|
|
34
|
+
if (previous[0].to !== view.state.doc.content.size) {
|
|
35
|
+
DocDecorationsCache.set(view, next);
|
|
36
|
+
return next;
|
|
37
|
+
}
|
|
38
|
+
// @ts-expect-error Internal property (Decoration.type)
|
|
39
|
+
if (!previous[0].type.eq(next[0].type)) {
|
|
40
|
+
DocDecorationsCache.set(view, next);
|
|
41
|
+
return next;
|
|
42
|
+
}
|
|
43
|
+
return previous;
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */ import { ReactWidgetType } from "./ReactWidgetType.js";
|
|
2
|
+
function compareSide(a, b) {
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
+
return a.type.side - b.type.side;
|
|
5
|
+
}
|
|
6
|
+
// This function abstracts iterating over the nodes and decorations in
|
|
7
|
+
// a fragment. Calls `onNode` for each node, with its local and child
|
|
8
|
+
// decorations. Splits text nodes when there is a decoration starting
|
|
9
|
+
// or ending inside of them. Calls `onWidget` for each widget.
|
|
10
|
+
export function iterDeco(parent, deco, // Callbacks have been slightly modified to pass
|
|
11
|
+
// the offset, so that we can pass the position as
|
|
12
|
+
// a prop to components
|
|
13
|
+
onWidget, onNode) {
|
|
14
|
+
const locals = deco.locals(parent);
|
|
15
|
+
let offset = 0;
|
|
16
|
+
// Simple, cheap variant for when there are no local decorations
|
|
17
|
+
if (locals.length == 0) {
|
|
18
|
+
for(let i = 0; i < parent.childCount; i++){
|
|
19
|
+
const child = parent.child(i);
|
|
20
|
+
onNode(child, locals, deco.forChild(offset, child), offset, i);
|
|
21
|
+
offset += child.nodeSize;
|
|
22
|
+
}
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
let decoIndex = 0;
|
|
26
|
+
const active = [];
|
|
27
|
+
let restNode = null;
|
|
28
|
+
for(let parentIndex = 0;;){
|
|
29
|
+
if (decoIndex < locals.length && locals[decoIndex].to == offset) {
|
|
30
|
+
let widget;
|
|
31
|
+
let widgets;
|
|
32
|
+
while(decoIndex < locals.length && locals[decoIndex].to == offset){
|
|
33
|
+
const next = locals[decoIndex++];
|
|
34
|
+
if (next.widget || // FORK: Our custom widget type can't report itself as a widget,
|
|
35
|
+
// so we have to explicitly check
|
|
36
|
+
next.type instanceof ReactWidgetType) {
|
|
37
|
+
if (!widget) widget = next;
|
|
38
|
+
else (widgets || (widgets = [
|
|
39
|
+
widget
|
|
40
|
+
])).push(next);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (widget) {
|
|
44
|
+
if (widgets) {
|
|
45
|
+
widgets.sort(compareSide);
|
|
46
|
+
for(let i = 0; i < widgets.length; i++)onWidget(widgets[i], // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
!(widgets[i].type instanceof ReactWidgetType), offset, parentIndex + i, !!restNode);
|
|
48
|
+
} else {
|
|
49
|
+
onWidget(widget, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
!(widget.type instanceof ReactWidgetType), offset, parentIndex, !!restNode);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
let child, index;
|
|
55
|
+
if (restNode) {
|
|
56
|
+
index = -1;
|
|
57
|
+
child = restNode;
|
|
58
|
+
restNode = null;
|
|
59
|
+
} else if (parentIndex < parent.childCount) {
|
|
60
|
+
index = parentIndex;
|
|
61
|
+
child = parent.child(parentIndex++);
|
|
62
|
+
} else {
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
for(let i = 0; i < active.length; i++)if (active[i].to <= offset) active.splice(i--, 1);
|
|
66
|
+
while(decoIndex < locals.length && locals[decoIndex].from <= offset && locals[decoIndex].to > offset)active.push(locals[decoIndex++]);
|
|
67
|
+
let end = offset + child.nodeSize;
|
|
68
|
+
if (child.isText) {
|
|
69
|
+
let cutAt = end;
|
|
70
|
+
if (decoIndex < locals.length && locals[decoIndex].from < cutAt) cutAt = locals[decoIndex].from;
|
|
71
|
+
for(let i = 0; i < active.length; i++)if (active[i].to < cutAt) cutAt = active[i].to;
|
|
72
|
+
if (cutAt < end) {
|
|
73
|
+
restNode = child.cut(cutAt - offset);
|
|
74
|
+
child = child.cut(0, cutAt - offset);
|
|
75
|
+
end = cutAt;
|
|
76
|
+
index = -1;
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
while(decoIndex < locals.length && locals[decoIndex].to < end)decoIndex++;
|
|
80
|
+
}
|
|
81
|
+
const outerDeco = child.isInline && !child.isLeaf ? active.filter((d)=>!d.inline) : active.slice();
|
|
82
|
+
onNode(child, outerDeco, deco.forChild(offset, child), offset, index);
|
|
83
|
+
offset = end;
|
|
84
|
+
}
|
|
85
|
+
}
|