@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,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "TiptapEditorContent", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return TiptapEditorContent;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
+
const _reactdom = require("react-dom");
|
|
13
|
+
const _ProseMirrorDoc = require("../components/ProseMirrorDoc.js");
|
|
14
|
+
const _useEditorEffect = require("../hooks/useEditorEffect.js");
|
|
15
|
+
const _TiptapEditorContext = require("./contexts/TiptapEditorContext.js");
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
17
|
+
if (typeof WeakMap !== "function") return null;
|
|
18
|
+
var cacheBabelInterop = new WeakMap();
|
|
19
|
+
var cacheNodeInterop = new WeakMap();
|
|
20
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
21
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
22
|
+
})(nodeInterop);
|
|
23
|
+
}
|
|
24
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
25
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
26
|
+
return obj;
|
|
27
|
+
}
|
|
28
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
29
|
+
return {
|
|
30
|
+
default: obj
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
34
|
+
if (cache && cache.has(obj)) {
|
|
35
|
+
return cache.get(obj);
|
|
36
|
+
}
|
|
37
|
+
var newObj = {
|
|
38
|
+
__proto__: null
|
|
39
|
+
};
|
|
40
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
41
|
+
for(var key in obj){
|
|
42
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
43
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
44
|
+
if (desc && (desc.get || desc.set)) {
|
|
45
|
+
Object.defineProperty(newObj, key, desc);
|
|
46
|
+
} else {
|
|
47
|
+
newObj[key] = obj[key];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
newObj.default = obj;
|
|
52
|
+
if (cache) {
|
|
53
|
+
cache.set(obj, newObj);
|
|
54
|
+
}
|
|
55
|
+
return newObj;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* This component renders all of the editor's registered "React renderers".
|
|
59
|
+
*/ const Portals = (param)=>{
|
|
60
|
+
let { contentComponent } = param;
|
|
61
|
+
const renderers = (0, _react.useSyncExternalStore)(contentComponent.subscribe, contentComponent.getSnapshot, contentComponent.getServerSnapshot);
|
|
62
|
+
return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, Object.values(renderers));
|
|
63
|
+
};
|
|
64
|
+
function getInstance() {
|
|
65
|
+
const subscribers = new Set();
|
|
66
|
+
let renderers = {};
|
|
67
|
+
return {
|
|
68
|
+
/**
|
|
69
|
+
* Subscribe to the editor instance's changes.
|
|
70
|
+
*/ subscribe (callback) {
|
|
71
|
+
subscribers.add(callback);
|
|
72
|
+
return ()=>{
|
|
73
|
+
subscribers.delete(callback);
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
getSnapshot () {
|
|
77
|
+
return renderers;
|
|
78
|
+
},
|
|
79
|
+
getServerSnapshot () {
|
|
80
|
+
return renderers;
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
* Adds a new React Renderer to the editor.
|
|
84
|
+
*/ setRenderer (id, renderer) {
|
|
85
|
+
renderers = {
|
|
86
|
+
...renderers,
|
|
87
|
+
[id]: /*#__PURE__*/ (0, _reactdom.createPortal)(renderer.reactElement, renderer.element, id)
|
|
88
|
+
};
|
|
89
|
+
subscribers.forEach((subscriber)=>subscriber());
|
|
90
|
+
},
|
|
91
|
+
/**
|
|
92
|
+
* Removes a React Renderer from the editor.
|
|
93
|
+
*/ removeRenderer (id) {
|
|
94
|
+
const nextRenderers = {
|
|
95
|
+
...renderers
|
|
96
|
+
};
|
|
97
|
+
delete nextRenderers[id];
|
|
98
|
+
renderers = nextRenderers;
|
|
99
|
+
subscribers.forEach((subscriber)=>subscriber());
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function TiptapEditorContent(param) {
|
|
104
|
+
let { editor: editorProp, ...props } = param;
|
|
105
|
+
const editor = editorProp;
|
|
106
|
+
const { onEditorInitialize, onEditorDeinitialize } = (0, _react.useContext)(_TiptapEditorContext.TiptapEditorContext);
|
|
107
|
+
(0, _useEditorEffect.useEditorEffect)((view)=>{
|
|
108
|
+
if (editor.view === view) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
// @ts-expect-error private property
|
|
112
|
+
editor.editorView = view;
|
|
113
|
+
editor.contentComponent = getInstance();
|
|
114
|
+
// @ts-expect-error private method
|
|
115
|
+
editor.injectCSS();
|
|
116
|
+
const dom = view.dom;
|
|
117
|
+
dom.editor = editor;
|
|
118
|
+
setTimeout(()=>{
|
|
119
|
+
if (editor.isDestroyed) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
editor.commands.focus(editor.options.autofocus);
|
|
123
|
+
editor.emit("create", {
|
|
124
|
+
editor
|
|
125
|
+
});
|
|
126
|
+
editor.isInitialized = true;
|
|
127
|
+
onEditorInitialize();
|
|
128
|
+
});
|
|
129
|
+
return ()=>{
|
|
130
|
+
editor.isInitialized = false;
|
|
131
|
+
editor.contentComponent = null;
|
|
132
|
+
editor.destroy();
|
|
133
|
+
onEditorDeinitialize();
|
|
134
|
+
};
|
|
135
|
+
}, [
|
|
136
|
+
editor,
|
|
137
|
+
onEditorDeinitialize,
|
|
138
|
+
onEditorInitialize
|
|
139
|
+
]);
|
|
140
|
+
return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/ _react.default.createElement(_ProseMirrorDoc.ProseMirrorDoc, props), editor?.contentComponent && /*#__PURE__*/ _react.default.createElement(Portals, {
|
|
141
|
+
contentComponent: editor.contentComponent
|
|
142
|
+
}));
|
|
143
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "TiptapEditorView", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return TiptapEditorView;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _react = require("@tiptap/react");
|
|
12
|
+
const _classnames = /*#__PURE__*/ _interop_require_default(require("classnames"));
|
|
13
|
+
const _react1 = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
14
|
+
const _ProseMirror = require("../components/ProseMirror.js");
|
|
15
|
+
const _useForceUpdate = require("../hooks/useForceUpdate.js");
|
|
16
|
+
const _TiptapEditorContext = require("./contexts/TiptapEditorContext.js");
|
|
17
|
+
function _interop_require_default(obj) {
|
|
18
|
+
return obj && obj.__esModule ? obj : {
|
|
19
|
+
default: obj
|
|
20
|
+
};
|
|
21
|
+
}
|
|
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 TiptapEditorView(param) {
|
|
64
|
+
let { editor, nodeViewComponents, markViewComponents, children, static: isStatic = false } = param;
|
|
65
|
+
const [isEditorInitialized, setIsEditorInitialized] = (0, _react1.useState)(editor.isInitialized);
|
|
66
|
+
const attributesProp = editor.options.editorProps?.attributes;
|
|
67
|
+
const [attributes, setAttributes] = (0, _react1.useState)(typeof attributesProp === "function" ? attributesProp(editor.state) : attributesProp);
|
|
68
|
+
const forceUpdate = (0, _useForceUpdate.useForceUpdate)();
|
|
69
|
+
const dispatchTransaction = (0, _react1.useCallback)((tr)=>{
|
|
70
|
+
// @ts-expect-error calling private method
|
|
71
|
+
editor.dispatchTransaction(tr);
|
|
72
|
+
if (typeof attributesProp === "function") {
|
|
73
|
+
setAttributes(attributesProp(editor.state));
|
|
74
|
+
}
|
|
75
|
+
// Tiptap's dispatchTransaction doesn't trigger
|
|
76
|
+
// a re-render, so we need to manually force
|
|
77
|
+
// one to ensure that React stays in sync.
|
|
78
|
+
forceUpdate();
|
|
79
|
+
}, [
|
|
80
|
+
attributesProp,
|
|
81
|
+
editor,
|
|
82
|
+
forceUpdate
|
|
83
|
+
]);
|
|
84
|
+
const editorProps = {
|
|
85
|
+
...editor.options.editorProps,
|
|
86
|
+
attributes: {
|
|
87
|
+
role: "textbox",
|
|
88
|
+
...attributes,
|
|
89
|
+
class: (0, _classnames.default)(attributes?.class, "tiptap")
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const { nodeViews, markViews } = editor.isDestroyed ? {
|
|
93
|
+
nodeViews: undefined,
|
|
94
|
+
markViews: undefined
|
|
95
|
+
} : editor.view.props;
|
|
96
|
+
const contextValue = (0, _react1.useMemo)(()=>({
|
|
97
|
+
editor
|
|
98
|
+
}), [
|
|
99
|
+
editor
|
|
100
|
+
]);
|
|
101
|
+
const onEditorInitialize = (0, _react1.useCallback)(()=>{
|
|
102
|
+
setIsEditorInitialized(true);
|
|
103
|
+
}, []);
|
|
104
|
+
const onEditorDeinitialize = (0, _react1.useCallback)(()=>{
|
|
105
|
+
setIsEditorInitialized(false);
|
|
106
|
+
}, []);
|
|
107
|
+
const tiptapEditorContextValue = (0, _react1.useMemo)(()=>({
|
|
108
|
+
isEditorInitialized,
|
|
109
|
+
onEditorInitialize,
|
|
110
|
+
onEditorDeinitialize
|
|
111
|
+
}), [
|
|
112
|
+
isEditorInitialized,
|
|
113
|
+
onEditorDeinitialize,
|
|
114
|
+
onEditorInitialize
|
|
115
|
+
]);
|
|
116
|
+
return /*#__PURE__*/ _react1.default.createElement(_ProseMirror.ProseMirror, {
|
|
117
|
+
static: isStatic,
|
|
118
|
+
...editorProps,
|
|
119
|
+
markViewComponents: markViewComponents,
|
|
120
|
+
markViews: markViews,
|
|
121
|
+
nodeViewComponents: nodeViewComponents,
|
|
122
|
+
nodeViews: nodeViews,
|
|
123
|
+
state: editor.state,
|
|
124
|
+
dispatchTransaction: dispatchTransaction
|
|
125
|
+
}, /*#__PURE__*/ _react1.default.createElement(_react.EditorContext.Provider, {
|
|
126
|
+
value: contextValue
|
|
127
|
+
}, /*#__PURE__*/ _react1.default.createElement(_TiptapEditorContext.TiptapEditorContext.Provider, {
|
|
128
|
+
value: tiptapEditorContextValue
|
|
129
|
+
}, children)));
|
|
130
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "TiptapEditorContext", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return TiptapEditorContext;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _react = require("react");
|
|
12
|
+
const TiptapEditorContext = (0, _react.createContext)(null);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "ReactProseMirror", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return ReactProseMirror;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _core = require("@tiptap/core");
|
|
12
|
+
const _reorderSiblings = require("../../commands/reorderSiblings.js");
|
|
13
|
+
const _reactKeys = require("../../plugins/reactKeys.js");
|
|
14
|
+
const ReactProseMirror = _core.Extension.create({
|
|
15
|
+
name: "@handlewithcare/react-prosemirror/reactKeys",
|
|
16
|
+
addProseMirrorPlugins () {
|
|
17
|
+
return [
|
|
18
|
+
(0, _reactKeys.reactKeys)()
|
|
19
|
+
];
|
|
20
|
+
},
|
|
21
|
+
addCommands () {
|
|
22
|
+
return {
|
|
23
|
+
/**
|
|
24
|
+
* Command that reorders the adjacent nodes starting
|
|
25
|
+
* at the provided position.
|
|
26
|
+
*
|
|
27
|
+
* @param pos - The `start` position of the parent of the nodes being reordered
|
|
28
|
+
* @param order - The new order for the nodes, expressed as an array of indices. For
|
|
29
|
+
* example, to swap the first two nodes in a set of three, `order`
|
|
30
|
+
* would be set to `[1, 0, 2]`. To move the first node to the end,
|
|
31
|
+
* and keep the other two in relative order, set `order` to `[1, 2, 0]`.
|
|
32
|
+
*/ reorderSiblings (initialPos, order) {
|
|
33
|
+
return function reorderSiblingsCommand(param) {
|
|
34
|
+
let { tr, state, dispatch } = param;
|
|
35
|
+
return (0, _reorderSiblings.reorderSiblingsOnTransaction)(initialPos, order, tr, state, dispatch);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "ReactProseMirrorCommands", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return ReactProseMirrorCommands;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _core = require("@tiptap/core");
|
|
12
|
+
const _updateAttributes = require("./commands/updateAttributes.js");
|
|
13
|
+
const ReactProseMirrorCommands = _core.Extension.create({
|
|
14
|
+
name: "reactProseMirrorCommands",
|
|
15
|
+
addCommands () {
|
|
16
|
+
return {
|
|
17
|
+
..._core.commands,
|
|
18
|
+
updateAttributes: _updateAttributes.updateAttributes
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "updateAttributes", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return updateAttributes;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _core = require("@tiptap/core");
|
|
12
|
+
const updateAttributes = function(typeOrName) {
|
|
13
|
+
let attributes = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
14
|
+
return (param)=>{
|
|
15
|
+
let { tr, state, dispatch } = param;
|
|
16
|
+
let nodeType = null;
|
|
17
|
+
let markType = null;
|
|
18
|
+
const schemaType = (0, _core.getSchemaTypeNameByName)(typeof typeOrName === "string" ? typeOrName : typeOrName.name, state.schema);
|
|
19
|
+
if (!schemaType) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (schemaType === "node") {
|
|
23
|
+
nodeType = (0, _core.getNodeType)(typeOrName, state.schema);
|
|
24
|
+
}
|
|
25
|
+
if (schemaType === "mark") {
|
|
26
|
+
markType = (0, _core.getMarkType)(typeOrName, state.schema);
|
|
27
|
+
}
|
|
28
|
+
let canUpdate = false;
|
|
29
|
+
tr.selection.ranges.forEach((range)=>{
|
|
30
|
+
const from = range.$from.pos;
|
|
31
|
+
const to = range.$to.pos;
|
|
32
|
+
let lastPos;
|
|
33
|
+
let lastNode;
|
|
34
|
+
let trimmedFrom;
|
|
35
|
+
let trimmedTo;
|
|
36
|
+
if (tr.selection.empty) {
|
|
37
|
+
state.doc.nodesBetween(from, to, (node, pos)=>{
|
|
38
|
+
if (nodeType && nodeType === node.type) {
|
|
39
|
+
canUpdate = true;
|
|
40
|
+
trimmedFrom = Math.max(pos, from);
|
|
41
|
+
trimmedTo = Math.min(pos + node.nodeSize, to);
|
|
42
|
+
lastPos = pos;
|
|
43
|
+
lastNode = node;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
} else {
|
|
47
|
+
state.doc.nodesBetween(from, to, (node, pos)=>{
|
|
48
|
+
if (pos < from && nodeType && nodeType === node.type) {
|
|
49
|
+
canUpdate = true;
|
|
50
|
+
trimmedFrom = Math.max(pos, from);
|
|
51
|
+
trimmedTo = Math.min(pos + node.nodeSize, to);
|
|
52
|
+
lastPos = pos;
|
|
53
|
+
lastNode = node;
|
|
54
|
+
}
|
|
55
|
+
if (pos >= from && pos <= to) {
|
|
56
|
+
if (nodeType && nodeType === node.type) {
|
|
57
|
+
canUpdate = true;
|
|
58
|
+
if (dispatch) {
|
|
59
|
+
Object.entries(attributes).forEach((param)=>{
|
|
60
|
+
let [key, value] = param;
|
|
61
|
+
tr.setNodeAttribute(pos, key, value);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (markType && node.marks.length) {
|
|
66
|
+
node.marks.forEach((mark)=>{
|
|
67
|
+
if (markType === mark.type) {
|
|
68
|
+
canUpdate = true;
|
|
69
|
+
if (dispatch) {
|
|
70
|
+
const trimmedFrom2 = Math.max(pos, from);
|
|
71
|
+
const trimmedTo2 = Math.min(pos + node.nodeSize, to);
|
|
72
|
+
tr.addMark(trimmedFrom2, trimmedTo2, markType.create({
|
|
73
|
+
...mark.attrs,
|
|
74
|
+
...attributes
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (lastNode) {
|
|
84
|
+
if (dispatch) {
|
|
85
|
+
Object.entries(attributes).forEach((param)=>{
|
|
86
|
+
let [key, value] = param;
|
|
87
|
+
if (lastPos !== undefined) tr.setNodeAttribute(lastPos, key, value);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (markType && lastNode.marks.length) {
|
|
91
|
+
lastNode.marks.forEach((mark)=>{
|
|
92
|
+
if (markType === mark.type && dispatch) {
|
|
93
|
+
tr.addMark(trimmedFrom, trimmedTo, markType.create({
|
|
94
|
+
...mark.attrs,
|
|
95
|
+
...attributes
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
return canUpdate;
|
|
103
|
+
};
|
|
104
|
+
};
|