@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,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "ReactEditorView", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return ReactEditorView;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _prosemirrorview = require("prosemirror-view");
|
|
12
|
+
const _constants = require("./constants.js");
|
|
13
|
+
function buildNodeViews(view) {
|
|
14
|
+
const result = Object.create(null);
|
|
15
|
+
function add(obj) {
|
|
16
|
+
for(const prop in obj)if (!Object.prototype.hasOwnProperty.call(result, prop)) // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
17
|
+
result[prop] = obj[prop];
|
|
18
|
+
}
|
|
19
|
+
view.someProp("nodeViews", add);
|
|
20
|
+
view.someProp("markViews", add);
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
function changedNodeViews(a, b) {
|
|
24
|
+
let nA = 0, nB = 0;
|
|
25
|
+
for(const prop in a){
|
|
26
|
+
if (a[prop] != b[prop]) return true;
|
|
27
|
+
nA++;
|
|
28
|
+
}
|
|
29
|
+
for(const _ in b)nB++;
|
|
30
|
+
return nA != nB;
|
|
31
|
+
}
|
|
32
|
+
let ReactEditorView = class ReactEditorView extends _prosemirrorview.EditorView {
|
|
33
|
+
nextProps;
|
|
34
|
+
prevState;
|
|
35
|
+
_destroyed;
|
|
36
|
+
cursorWrapped;
|
|
37
|
+
constructor(place, props){
|
|
38
|
+
// Prevent the base class from destroying the React-managed nodes.
|
|
39
|
+
// Restore them below after invoking the base class constructor.
|
|
40
|
+
const reactContent = [
|
|
41
|
+
...place.mount.childNodes
|
|
42
|
+
];
|
|
43
|
+
// Prevent the base class from mutating the React-managed attributes.
|
|
44
|
+
// Restore them below after invoking the base class constructor.
|
|
45
|
+
const reactAttrs = [
|
|
46
|
+
...place.mount.attributes
|
|
47
|
+
];
|
|
48
|
+
for (const attr of reactAttrs){
|
|
49
|
+
place.mount.removeAttributeNode(attr);
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
// Call the superclass constructor with only a state and no plugins.
|
|
53
|
+
// We'll set everything else ourselves and apply props during layout.
|
|
54
|
+
super(place, {
|
|
55
|
+
state: _constants.EMPTY_STATE
|
|
56
|
+
});
|
|
57
|
+
this.domObserver.stop();
|
|
58
|
+
this.domObserver.observer = null;
|
|
59
|
+
this.domObserver.queue = [];
|
|
60
|
+
const originalOnSelectionChange = this.domObserver.onSelectionChange;
|
|
61
|
+
this.domObserver.onSelectionChange = ()=>{
|
|
62
|
+
// During a composition, we completely pause React-driven
|
|
63
|
+
// selection and DOM updates. Compositions are "fragile";
|
|
64
|
+
// in Safari, even updating the selection to the same
|
|
65
|
+
// position it's already set to will end the current
|
|
66
|
+
// composition.
|
|
67
|
+
if (this.composing) return;
|
|
68
|
+
originalOnSelectionChange();
|
|
69
|
+
};
|
|
70
|
+
} finally{
|
|
71
|
+
place.mount.replaceChildren(...reactContent);
|
|
72
|
+
for (const attr of place.mount.attributes){
|
|
73
|
+
place.mount.removeAttributeNode(attr);
|
|
74
|
+
}
|
|
75
|
+
for (const attr of reactAttrs){
|
|
76
|
+
place.mount.setAttributeNode(attr);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
this.prevState = _constants.EMPTY_STATE;
|
|
80
|
+
this.nextProps = props;
|
|
81
|
+
this.state = props.state;
|
|
82
|
+
this.nodeViews = buildNodeViews(this);
|
|
83
|
+
// Destroy the document view description that the base class makes.
|
|
84
|
+
// A React document view will assign itself to this attribute later.
|
|
85
|
+
this.docView.destroy();
|
|
86
|
+
// @ts-expect-error this violates the typing but class does it, too.
|
|
87
|
+
this.docView = null;
|
|
88
|
+
this._destroyed = false;
|
|
89
|
+
this.cursorWrapped = false;
|
|
90
|
+
}
|
|
91
|
+
get props() {
|
|
92
|
+
return this.nextProps;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @privateremarks
|
|
96
|
+
*
|
|
97
|
+
* We override this getter because the base implementation
|
|
98
|
+
* relies on checking `docView === null`, but we unconditionally
|
|
99
|
+
* set view.docView in a layout effect in the DocNodeView.
|
|
100
|
+
* This has the effect of "un-destroying" the EditorView,
|
|
101
|
+
* making it impossible to determine whether it's been destroyed.
|
|
102
|
+
*/ get isDestroyed() {
|
|
103
|
+
return this._destroyed;
|
|
104
|
+
}
|
|
105
|
+
setProps(props) {
|
|
106
|
+
this.update({
|
|
107
|
+
...this.props,
|
|
108
|
+
...props
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
update(props) {
|
|
112
|
+
const prevProps = this.nextProps;
|
|
113
|
+
this.nextProps = props;
|
|
114
|
+
this.state = props.state;
|
|
115
|
+
if (prevProps.state.plugins !== props.state.plugins || prevProps.plugins !== props.plugins || prevProps.nodeViews !== props.nodeViews) {
|
|
116
|
+
const nodeViews = buildNodeViews(this);
|
|
117
|
+
if (changedNodeViews(this.nodeViews, nodeViews)) {
|
|
118
|
+
this.nodeViews = nodeViews;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
this.editable = !this.someProp("editable", (value)=>value(this.state) === false);
|
|
122
|
+
}
|
|
123
|
+
updateState(state) {
|
|
124
|
+
this.setProps({
|
|
125
|
+
state
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
someProp(propName, f) {
|
|
129
|
+
if (!this.props) {
|
|
130
|
+
// The base class constructor calls this method before props are set.
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
const prop = this.props[propName];
|
|
134
|
+
if (prop != null) {
|
|
135
|
+
const result = f ? f(prop) : prop;
|
|
136
|
+
if (result) {
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
for (const plugin of this.props.plugins ?? []){
|
|
141
|
+
const prop = plugin.props[propName];
|
|
142
|
+
if (prop != null) {
|
|
143
|
+
const result = f ? f(prop) : prop;
|
|
144
|
+
if (result) {
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
for (const plugin of this.state.plugins){
|
|
150
|
+
const prop = plugin.props[propName];
|
|
151
|
+
if (prop != null) {
|
|
152
|
+
const result = f ? f(prop) : prop;
|
|
153
|
+
if (result) {
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
destroy() {
|
|
161
|
+
// Prevent the base class from destroying the React-managed nodes.
|
|
162
|
+
// Restore them below after invoking the base class method.
|
|
163
|
+
const reactContent = [
|
|
164
|
+
...this.dom.childNodes
|
|
165
|
+
];
|
|
166
|
+
try {
|
|
167
|
+
super.destroy();
|
|
168
|
+
} finally{
|
|
169
|
+
this.dom.replaceChildren(...reactContent);
|
|
170
|
+
this._destroyed = true;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Commit effects by appling the pending props and state.
|
|
175
|
+
*
|
|
176
|
+
* Ensures the DOM selection is correct and updates plugin views.
|
|
177
|
+
*
|
|
178
|
+
* @privateRemarks
|
|
179
|
+
*
|
|
180
|
+
* The correctness of this depends on the pure update function ensuring that
|
|
181
|
+
* the node view set is up to date so that it does not try to redraw.
|
|
182
|
+
*/ commitPendingEffects() {
|
|
183
|
+
// This class tracks state eagerly but the base class does it lazily.
|
|
184
|
+
// Temporarily roll it back so the base class can handle the updates.
|
|
185
|
+
this.state = this.prevState;
|
|
186
|
+
// Force the base class to try to update the document. React updated it, but
|
|
187
|
+
// this ensures that the base class validates the DOM selection and invokes
|
|
188
|
+
// node view selection callbacks.
|
|
189
|
+
this.docView.markDirty(-1, -1);
|
|
190
|
+
super.update(this.nextProps);
|
|
191
|
+
// Store the new previous state.
|
|
192
|
+
this.prevState = this.state;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "StaticEditorView", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return StaticEditorView;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
let StaticEditorView = class StaticEditorView {
|
|
12
|
+
props;
|
|
13
|
+
nodeViews;
|
|
14
|
+
constructor(props){
|
|
15
|
+
this.props = props;
|
|
16
|
+
this.nodeViews = {};
|
|
17
|
+
}
|
|
18
|
+
get composing() {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
get dom() {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
get editable() {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
get state() {
|
|
28
|
+
return this.props.state;
|
|
29
|
+
}
|
|
30
|
+
get isDestroyed() {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
setProps(props) {
|
|
34
|
+
return this.update({
|
|
35
|
+
...this.props,
|
|
36
|
+
...props
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
update(props) {
|
|
40
|
+
this.props = props;
|
|
41
|
+
}
|
|
42
|
+
updateState(state) {
|
|
43
|
+
this.setProps({
|
|
44
|
+
state
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
someProp(propName, f) {
|
|
48
|
+
const prop = this.props[propName];
|
|
49
|
+
if (prop != null) {
|
|
50
|
+
const result = f ? f(prop) : prop;
|
|
51
|
+
if (result) {
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
for (const plugin of this.props.plugins ?? []){
|
|
56
|
+
const prop = plugin.props[propName];
|
|
57
|
+
if (prop != null) {
|
|
58
|
+
const result = f ? f(prop) : prop;
|
|
59
|
+
if (result) {
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
for (const plugin of this.state.plugins){
|
|
65
|
+
const prop = plugin.props[propName];
|
|
66
|
+
if (prop != null) {
|
|
67
|
+
const result = f ? f(prop) : prop;
|
|
68
|
+
if (result) {
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
destroy() {
|
|
76
|
+
// pass
|
|
77
|
+
}
|
|
78
|
+
domSelectionRange() {
|
|
79
|
+
return {
|
|
80
|
+
anchorNode: null,
|
|
81
|
+
anchorOffset: 0,
|
|
82
|
+
focusNode: null,
|
|
83
|
+
focusOffset: 0
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
domSelection() {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "browser", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return browser;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const nav = typeof navigator != "undefined" ? navigator : null;
|
|
12
|
+
const doc = typeof document != "undefined" ? document : null;
|
|
13
|
+
const agent = nav && nav.userAgent || "";
|
|
14
|
+
const ie_edge = /Edge\/(\d+)/.exec(agent);
|
|
15
|
+
const ie_upto10 = /MSIE \d/.exec(agent);
|
|
16
|
+
const ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(agent);
|
|
17
|
+
const ie = !!(ie_upto10 || ie_11up || ie_edge);
|
|
18
|
+
const ie_version = ie_upto10 ? document.documentMode : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : 0;
|
|
19
|
+
const gecko = !ie && /gecko\/(\d+)/i.test(agent);
|
|
20
|
+
const gecko_version = gecko && +(/Firefox\/(\d+)/.exec(agent) || [
|
|
21
|
+
0,
|
|
22
|
+
0
|
|
23
|
+
])[1];
|
|
24
|
+
const _chrome = !ie && /Chrome\/(\d+)/.exec(agent);
|
|
25
|
+
const chrome = !!_chrome;
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
27
|
+
const chrome_version = _chrome ? +_chrome[1] : 0;
|
|
28
|
+
const safari = !ie && !!nav && /Apple Computer/.test(nav.vendor);
|
|
29
|
+
// Is true for both iOS and iPadOS for convenience
|
|
30
|
+
const ios = safari && (/Mobile\/\w+/.test(agent) || !!nav && nav.maxTouchPoints > 2);
|
|
31
|
+
const mac = ios || (nav ? /Mac/.test(nav.platform) : false);
|
|
32
|
+
const windows = nav ? /Win/.test(nav.platform) : false;
|
|
33
|
+
const android = /Android \d/.test(agent);
|
|
34
|
+
const webkit = !!doc && "webkitFontSmoothing" in doc.documentElement.style;
|
|
35
|
+
const webkit_version = webkit ? +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [
|
|
36
|
+
0,
|
|
37
|
+
0
|
|
38
|
+
])[1] : 0;
|
|
39
|
+
const browser = {
|
|
40
|
+
ie,
|
|
41
|
+
ie_version,
|
|
42
|
+
gecko,
|
|
43
|
+
gecko_version,
|
|
44
|
+
chrome,
|
|
45
|
+
chrome_version,
|
|
46
|
+
safari,
|
|
47
|
+
ios,
|
|
48
|
+
mac,
|
|
49
|
+
windows,
|
|
50
|
+
android,
|
|
51
|
+
webkit,
|
|
52
|
+
webkit_version
|
|
53
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */ "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
|
+
reorderSiblings: function() {
|
|
13
|
+
return reorderSiblings;
|
|
14
|
+
},
|
|
15
|
+
reorderSiblingsOnTransaction: function() {
|
|
16
|
+
return reorderSiblingsOnTransaction;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _reactKeys = require("../plugins/reactKeys.js");
|
|
20
|
+
function reorderSiblings(pos, order) {
|
|
21
|
+
return function reorderSiblingsCommand(state, dispatch) {
|
|
22
|
+
const tr = state.tr;
|
|
23
|
+
return reorderSiblingsOnTransaction(pos, order, tr, state, dispatch);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function reorderSiblingsOnTransaction(pos, order, tr, state, dispatch) {
|
|
27
|
+
const orderLookup = order.reduce((acc, oldIndex, newIndex)=>{
|
|
28
|
+
acc[oldIndex] = newIndex;
|
|
29
|
+
return acc;
|
|
30
|
+
}, []);
|
|
31
|
+
const $pos = state.doc.resolve(pos);
|
|
32
|
+
if ($pos.start() !== pos) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (!dispatch) return true;
|
|
36
|
+
const nodes = $pos.parent.children;
|
|
37
|
+
const reordered = nodes.map((node, i)=>[
|
|
38
|
+
node,
|
|
39
|
+
i
|
|
40
|
+
]).sort((param, param1)=>{
|
|
41
|
+
let [, a] = param, [, b] = param1;
|
|
42
|
+
return orderLookup[a] - orderLookup[b];
|
|
43
|
+
}).map((param)=>{
|
|
44
|
+
let [node] = param;
|
|
45
|
+
return node;
|
|
46
|
+
});
|
|
47
|
+
tr.replaceWith(pos, $pos.parent.content.size + pos, reordered);
|
|
48
|
+
const meta = {
|
|
49
|
+
overrides: {}
|
|
50
|
+
};
|
|
51
|
+
const oldPositions = [];
|
|
52
|
+
let start = pos;
|
|
53
|
+
for (const node of nodes){
|
|
54
|
+
oldPositions.push(start);
|
|
55
|
+
start += node.nodeSize;
|
|
56
|
+
}
|
|
57
|
+
start = pos;
|
|
58
|
+
const newPositions = [];
|
|
59
|
+
for(let i = 0; i < reordered.length; i++){
|
|
60
|
+
const node = reordered[i];
|
|
61
|
+
newPositions[order[i]] = start;
|
|
62
|
+
start += node.nodeSize;
|
|
63
|
+
}
|
|
64
|
+
for(let i = 0; i < oldPositions.length; i++){
|
|
65
|
+
const oldPosition = oldPositions[i];
|
|
66
|
+
const newPosition = newPositions[i];
|
|
67
|
+
meta.overrides[oldPosition] = newPosition;
|
|
68
|
+
}
|
|
69
|
+
tr.setMeta(_reactKeys.reactKeysPluginKey, meta);
|
|
70
|
+
dispatch(tr);
|
|
71
|
+
return true;
|
|
72
|
+
}
|