@handlewithcare/react-prosemirror 3.1.0-tiptap.42 → 3.1.0-tiptap.44
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/README.md +26 -0
- package/dist/cjs/ReactEditorView.js +74 -70
- package/dist/cjs/StaticEditorView.js +21 -18
- package/dist/cjs/browser.js +3 -1
- package/dist/cjs/commands/reorderSiblings.js +13 -9
- package/dist/cjs/components/ChildNodeViews.js +74 -69
- package/dist/cjs/components/CursorWrapper.js +20 -34
- package/dist/cjs/components/LayoutGroup.js +16 -12
- package/dist/cjs/components/NativeWidgetView.js +19 -15
- package/dist/cjs/components/OutputSpec.js +13 -9
- package/dist/cjs/components/ProseMirror.js +27 -37
- package/dist/cjs/components/ProseMirrorDoc.js +18 -25
- package/dist/cjs/components/SeparatorHackView.js +20 -17
- package/dist/cjs/components/TextNodeView.js +20 -22
- package/dist/cjs/components/TrailingHackView.js +17 -13
- package/dist/cjs/components/WidgetView.js +18 -14
- package/dist/cjs/components/marks/DefaultMarkView.js +15 -27
- package/dist/cjs/components/marks/MarkView.js +23 -32
- package/dist/cjs/components/marks/MarkViewConstructorView.js +22 -38
- package/dist/cjs/components/marks/ReactMarkView.js +16 -27
- package/dist/cjs/components/nodes/DefaultNodeView.js +15 -27
- package/dist/cjs/components/nodes/DocNodeView.js +16 -12
- package/dist/cjs/components/nodes/NodeView.js +26 -33
- package/dist/cjs/components/nodes/NodeViewConstructorView.js +29 -45
- package/dist/cjs/components/nodes/ReactNodeView.js +27 -39
- package/dist/cjs/constants.js +10 -6
- package/dist/cjs/contexts/ChildDescriptionsContext.js +3 -1
- package/dist/cjs/contexts/EditorContext.js +3 -1
- package/dist/cjs/contexts/EditorStateContext.js +3 -1
- package/dist/cjs/contexts/IgnoreMutationContext.js +3 -1
- package/dist/cjs/contexts/LayoutGroupContext.js +3 -1
- package/dist/cjs/contexts/NodeViewContext.js +3 -1
- package/dist/cjs/contexts/SelectNodeContext.js +3 -1
- package/dist/cjs/contexts/StopEventContext.js +3 -1
- package/dist/cjs/decorations/ReactWidgetType.js +19 -13
- package/dist/cjs/decorations/computeDocDeco.js +5 -3
- package/dist/cjs/decorations/iterDeco.js +19 -17
- package/dist/cjs/decorations/viewDecorations.js +15 -12
- package/dist/cjs/dom.js +34 -13
- package/dist/cjs/findDOMNode.js +9 -5
- package/dist/cjs/hooks/useClientLayoutEffect.js +3 -1
- package/dist/cjs/hooks/useComponentEventListeners.js +7 -6
- package/dist/cjs/hooks/useEditor.js +29 -32
- package/dist/cjs/hooks/useEditorEffect.js +9 -7
- package/dist/cjs/hooks/useEditorEventCallback.js +9 -7
- package/dist/cjs/hooks/useEditorEventListener.js +8 -6
- package/dist/cjs/hooks/useEditorState.js +5 -3
- package/dist/cjs/hooks/useEffectEvent.js +3 -1
- package/dist/cjs/hooks/useForceUpdate.js +3 -1
- package/dist/cjs/hooks/useIgnoreMutation.js +9 -7
- package/dist/cjs/hooks/useIsEditorStatic.js +5 -5
- package/dist/cjs/hooks/useIsNodeSelected.js +5 -3
- package/dist/cjs/hooks/useLayoutGroupEffect.js +7 -5
- package/dist/cjs/hooks/useMarkViewDescription.js +31 -25
- package/dist/cjs/hooks/useNodePos.js +7 -5
- package/dist/cjs/hooks/useNodeViewDescription.js +32 -28
- package/dist/cjs/hooks/useReactKeys.js +7 -5
- package/dist/cjs/hooks/useSelectNode.js +10 -8
- package/dist/cjs/hooks/useStopEvent.js +9 -7
- package/dist/cjs/index.js +66 -34
- package/dist/cjs/plugins/beforeInputPlugin.js +51 -24
- package/dist/cjs/plugins/componentEventListeners.js +8 -6
- package/dist/cjs/plugins/componentEventListenersPlugin.js +8 -6
- package/dist/cjs/plugins/reactKeys.js +15 -10
- package/dist/cjs/props.js +23 -19
- package/dist/cjs/refs.js +3 -1
- package/dist/cjs/testing/editorViewTestHelpers.js +40 -47
- package/dist/cjs/testing/setupProseMirrorView.js +7 -4
- package/dist/cjs/tiptap/ReactProseMirrorNodeView.js +10 -6
- package/dist/cjs/tiptap/TiptapEditor.js +15 -14
- package/dist/cjs/tiptap/TiptapEditorContent.js +18 -28
- package/dist/cjs/tiptap/TiptapEditorView.js +23 -34
- package/dist/cjs/tiptap/contexts/TiptapEditorContext.js +3 -1
- package/dist/cjs/tiptap/extensions/ReactProseMirror.js +8 -6
- package/dist/cjs/tiptap/extensions/ReactProseMirrorCommands.js +5 -3
- package/dist/cjs/tiptap/extensions/commands/updateAttributes.js +4 -2
- package/dist/cjs/tiptap/hooks/useIsInReactProseMirror.js +5 -3
- package/dist/cjs/tiptap/hooks/useTiptapEditor.js +12 -14
- package/dist/cjs/tiptap/hooks/useTiptapEditorEffect.js +12 -10
- package/dist/cjs/tiptap/hooks/useTiptapEditorEventCallback.js +6 -4
- package/dist/cjs/tiptap/index.js +36 -18
- package/dist/cjs/tiptap/tiptapNodeView.js +48 -62
- package/dist/cjs/viewdesc.js +119 -89
- package/dist/esm/ReactEditorView.js +68 -66
- package/dist/esm/StaticEditorView.js +18 -17
- package/dist/esm/commands/reorderSiblings.js +5 -5
- package/dist/esm/components/ChildNodeViews.js +36 -37
- package/dist/esm/components/CursorWrapper.js +10 -28
- package/dist/esm/components/LayoutGroup.js +1 -1
- package/dist/esm/components/NativeWidgetView.js +2 -2
- package/dist/esm/components/OutputSpec.js +1 -1
- package/dist/esm/components/ProseMirror.js +4 -18
- package/dist/esm/components/ProseMirrorDoc.js +6 -19
- package/dist/esm/components/SeparatorHackView.js +3 -4
- package/dist/esm/components/TextNodeView.js +6 -10
- package/dist/esm/components/TrailingHackView.js +2 -2
- package/dist/esm/components/WidgetView.js +3 -3
- package/dist/esm/components/marks/DefaultMarkView.js +6 -22
- package/dist/esm/components/marks/MarkView.js +11 -24
- package/dist/esm/components/marks/MarkViewConstructorView.js +7 -27
- package/dist/esm/components/marks/ReactMarkView.js +3 -18
- package/dist/esm/components/nodes/DefaultNodeView.js +6 -22
- package/dist/esm/components/nodes/DocNodeView.js +2 -2
- package/dist/esm/components/nodes/NodeView.js +11 -24
- package/dist/esm/components/nodes/NodeViewConstructorView.js +11 -31
- package/dist/esm/components/nodes/ReactNodeView.js +6 -22
- package/dist/esm/decorations/ReactWidgetType.js +10 -8
- package/dist/esm/decorations/iterDeco.js +13 -13
- package/dist/esm/decorations/viewDecorations.js +7 -6
- package/dist/esm/dom.js +1 -2
- package/dist/esm/findDOMNode.js +1 -1
- package/dist/esm/hooks/useComponentEventListeners.js +2 -3
- package/dist/esm/hooks/useEditor.js +6 -11
- package/dist/esm/hooks/useEditorEffect.js +1 -1
- package/dist/esm/hooks/useEditorEventCallback.js +1 -1
- package/dist/esm/hooks/useEditorEventListener.js +1 -1
- package/dist/esm/hooks/useIsEditorStatic.js +1 -3
- package/dist/esm/hooks/useMarkViewDescription.js +14 -10
- package/dist/esm/hooks/useNodeViewDescription.js +10 -8
- package/dist/esm/hooks/useReactKeys.js +1 -1
- package/dist/esm/plugins/beforeInputPlugin.js +44 -19
- package/dist/esm/plugins/reactKeys.js +3 -4
- package/dist/esm/props.js +15 -15
- package/dist/esm/testing/editorViewTestHelpers.js +20 -31
- package/dist/esm/testing/setupProseMirrorView.js +1 -2
- package/dist/esm/tiptap/ReactProseMirrorNodeView.js +7 -5
- package/dist/esm/tiptap/TiptapEditor.js +9 -10
- package/dist/esm/tiptap/TiptapEditorContent.js +4 -18
- package/dist/esm/tiptap/TiptapEditorView.js +8 -23
- package/dist/esm/tiptap/extensions/ReactProseMirror.js +1 -1
- package/dist/esm/tiptap/extensions/commands/updateAttributes.js +1 -1
- package/dist/esm/tiptap/hooks/useTiptapEditor.js +4 -8
- package/dist/esm/tiptap/hooks/useTiptapEditorEffect.js +4 -4
- package/dist/esm/tiptap/hooks/useTiptapEditorEventCallback.js +1 -1
- package/dist/esm/tiptap/tiptapNodeView.js +20 -38
- package/dist/esm/viewdesc.js +74 -66
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/constants.d.ts +1 -1
- package/dist/types/contexts/EditorContext.d.ts +1 -2
- package/dist/types/hooks/useEditor.d.ts +1 -1
- package/dist/types/props.d.ts +8 -8
- package/dist/types/testing/editorViewTestHelpers.d.ts +1 -0
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -95,6 +95,7 @@ import "prosemirror-view/style/prosemirror.css";
|
|
|
95
95
|
- [When should I use this?](#when-should-i-use-this)
|
|
96
96
|
- [Migrations](#migrations)
|
|
97
97
|
- [Looking for someone to collaborate with?](#looking-for-someone-to-collaborate-with)
|
|
98
|
+
- [Sponsors](#sponsors)
|
|
98
99
|
|
|
99
100
|
<!-- tocstop -->
|
|
100
101
|
|
|
@@ -818,3 +819,28 @@ Reach out to [Handle with Care](https://handlewithcare.dev/#get-in-touch)! We're
|
|
|
818
819
|
a product development collective with years of experience bringing excellent
|
|
819
820
|
ideas to life. We love React and ProseMirror, and we're always looking for new
|
|
820
821
|
folks to work with!
|
|
822
|
+
|
|
823
|
+
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
|
824
|
+
<!--sponsorsstart-->
|
|
825
|
+
|
|
826
|
+
## Sponsors
|
|
827
|
+
|
|
828
|
+
The following companies, organizations, and individuals support Pitter Patter's
|
|
829
|
+
ongoing development.
|
|
830
|
+
|
|
831
|
+
Sponsors receive regular updates about development progress, including previews
|
|
832
|
+
of upcoming features, priority getting issues addressed as we release features,
|
|
833
|
+
and a direct line of communication to us for support. Funders above a certain
|
|
834
|
+
threshold join our steering committee — a lightweight governance model where
|
|
835
|
+
significant contributors help shape our roadmap priorities.
|
|
836
|
+
|
|
837
|
+
[Become a Sponsor](https://handlewithcare.dev/pitter-patter/#become-a-sponsor)
|
|
838
|
+
|
|
839
|
+
<h3>Sponsors</h3>
|
|
840
|
+
<p>
|
|
841
|
+
<a href="https://www.moment.dev/"><img src="https://media.githubusercontent.com/media/handlewithcarecollective/pitter-patter-sponsors/main/logos/Moment.png" alt="Moment" height="128"></a>
|
|
842
|
+
<a href="https://www.lingco.io/"><img src="https://media.githubusercontent.com/media/handlewithcarecollective/pitter-patter-sponsors/main/logos/Lingco.png" alt="Lingco" height="128"></a>
|
|
843
|
+
<a href="https://dskrpt.de/"><img src="https://media.githubusercontent.com/media/handlewithcarecollective/pitter-patter-sponsors/main/logos/Dskrpt.png" alt="Dskrpt" height="128"></a>
|
|
844
|
+
<a href="https://github.com/fastrepl/"><img src="https://media.githubusercontent.com/media/handlewithcarecollective/pitter-patter-sponsors/main/logos/Fastrepl.png" alt="Fastrepl" height="128"></a>
|
|
845
|
+
</p>
|
|
846
|
+
<!--sponsorsend-->
|
|
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "ReactEditorView", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return ReactEditorView;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
+
const _prosemirrorview = require("prosemirror-view");
|
|
12
|
+
const _constants = require("./constants.js");
|
|
11
13
|
function buildNodeViews(view) {
|
|
12
14
|
const result = Object.create(null);
|
|
13
15
|
function add(obj) {
|
|
@@ -27,7 +29,63 @@ function changedNodeViews(a, b) {
|
|
|
27
29
|
for(const _ in b)nB++;
|
|
28
30
|
return nA != nB;
|
|
29
31
|
}
|
|
30
|
-
let ReactEditorView = class ReactEditorView extends
|
|
32
|
+
let ReactEditorView = class ReactEditorView extends _prosemirrorview.EditorView {
|
|
33
|
+
nextProps;
|
|
34
|
+
prevState;
|
|
35
|
+
_destroyed;
|
|
36
|
+
constructor(place, props){
|
|
37
|
+
// Prevent the base class from destroying the React-managed nodes.
|
|
38
|
+
// Restore them below after invoking the base class constructor.
|
|
39
|
+
const reactContent = [
|
|
40
|
+
...place.mount.childNodes
|
|
41
|
+
];
|
|
42
|
+
// Prevent the base class from mutating the React-managed attributes.
|
|
43
|
+
// Restore them below after invoking the base class constructor.
|
|
44
|
+
const reactAttrs = [
|
|
45
|
+
...place.mount.attributes
|
|
46
|
+
];
|
|
47
|
+
for (const attr of reactAttrs){
|
|
48
|
+
place.mount.removeAttributeNode(attr);
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
// Call the superclass constructor with only a state and no plugins.
|
|
52
|
+
// We'll set everything else ourselves and apply props during layout.
|
|
53
|
+
super(place, {
|
|
54
|
+
state: _constants.EMPTY_STATE
|
|
55
|
+
});
|
|
56
|
+
this.domObserver.stop();
|
|
57
|
+
this.domObserver.observer = null;
|
|
58
|
+
this.domObserver.queue = [];
|
|
59
|
+
const originalOnSelectionChange = this.domObserver.onSelectionChange;
|
|
60
|
+
this.domObserver.onSelectionChange = ()=>{
|
|
61
|
+
// During a composition, we completely pause React-driven
|
|
62
|
+
// selection and DOM updates. Compositions are "fragile";
|
|
63
|
+
// in Safari, even updating the selection to the same
|
|
64
|
+
// position it's already set to will end the current
|
|
65
|
+
// composition.
|
|
66
|
+
if (this.composing) return;
|
|
67
|
+
originalOnSelectionChange();
|
|
68
|
+
};
|
|
69
|
+
} finally{
|
|
70
|
+
place.mount.replaceChildren(...reactContent);
|
|
71
|
+
for (const attr of place.mount.attributes){
|
|
72
|
+
place.mount.removeAttributeNode(attr);
|
|
73
|
+
}
|
|
74
|
+
for (const attr of reactAttrs){
|
|
75
|
+
place.mount.setAttributeNode(attr);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
this.prevState = _constants.EMPTY_STATE;
|
|
79
|
+
this.nextProps = props;
|
|
80
|
+
this.state = props.state;
|
|
81
|
+
this.nodeViews = buildNodeViews(this);
|
|
82
|
+
// Destroy the document view description that the base class makes.
|
|
83
|
+
// A React document view will assign itself to this attribute later.
|
|
84
|
+
this.docView.destroy();
|
|
85
|
+
// @ts-expect-error this violates the typing but class does it, too.
|
|
86
|
+
this.docView = null;
|
|
87
|
+
this._destroyed = false;
|
|
88
|
+
}
|
|
31
89
|
get props() {
|
|
32
90
|
return this.nextProps;
|
|
33
91
|
}
|
|
@@ -77,22 +135,21 @@ let ReactEditorView = class ReactEditorView extends _prosemirrorView.EditorView
|
|
|
77
135
|
return result;
|
|
78
136
|
}
|
|
79
137
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return result1;
|
|
138
|
+
for (const plugin of this.props.plugins ?? []){
|
|
139
|
+
const prop = plugin.props[propName];
|
|
140
|
+
if (prop != null) {
|
|
141
|
+
const result = f ? f(prop) : prop;
|
|
142
|
+
if (result) {
|
|
143
|
+
return result;
|
|
87
144
|
}
|
|
88
145
|
}
|
|
89
146
|
}
|
|
90
|
-
for (const
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
95
|
-
return
|
|
147
|
+
for (const plugin of this.state.plugins){
|
|
148
|
+
const prop = plugin.props[propName];
|
|
149
|
+
if (prop != null) {
|
|
150
|
+
const result = f ? f(prop) : prop;
|
|
151
|
+
if (result) {
|
|
152
|
+
return result;
|
|
96
153
|
}
|
|
97
154
|
}
|
|
98
155
|
}
|
|
@@ -132,57 +189,4 @@ let ReactEditorView = class ReactEditorView extends _prosemirrorView.EditorView
|
|
|
132
189
|
// Store the new previous state.
|
|
133
190
|
this.prevState = this.state;
|
|
134
191
|
}
|
|
135
|
-
constructor(place, props){
|
|
136
|
-
// Prevent the base class from destroying the React-managed nodes.
|
|
137
|
-
// Restore them below after invoking the base class constructor.
|
|
138
|
-
const reactContent = [
|
|
139
|
-
...place.mount.childNodes
|
|
140
|
-
];
|
|
141
|
-
// Prevent the base class from mutating the React-managed attributes.
|
|
142
|
-
// Restore them below after invoking the base class constructor.
|
|
143
|
-
const reactAttrs = [
|
|
144
|
-
...place.mount.attributes
|
|
145
|
-
];
|
|
146
|
-
for (const attr of reactAttrs){
|
|
147
|
-
place.mount.removeAttributeNode(attr);
|
|
148
|
-
}
|
|
149
|
-
try {
|
|
150
|
-
// Call the superclass constructor with only a state and no plugins.
|
|
151
|
-
// We'll set everything else ourselves and apply props during layout.
|
|
152
|
-
super(place, {
|
|
153
|
-
state: _constantsJs.EMPTY_STATE
|
|
154
|
-
});
|
|
155
|
-
this.domObserver.stop();
|
|
156
|
-
this.domObserver.observer = null;
|
|
157
|
-
this.domObserver.queue = [];
|
|
158
|
-
const originalOnSelectionChange = this.domObserver.onSelectionChange;
|
|
159
|
-
this.domObserver.onSelectionChange = ()=>{
|
|
160
|
-
// During a composition, we completely pause React-driven
|
|
161
|
-
// selection and DOM updates. Compositions are "fragile";
|
|
162
|
-
// in Safari, even updating the selection to the same
|
|
163
|
-
// position it's already set to will end the current
|
|
164
|
-
// composition.
|
|
165
|
-
if (this.composing) return;
|
|
166
|
-
originalOnSelectionChange();
|
|
167
|
-
};
|
|
168
|
-
} finally{
|
|
169
|
-
place.mount.replaceChildren(...reactContent);
|
|
170
|
-
for (const attr1 of place.mount.attributes){
|
|
171
|
-
place.mount.removeAttributeNode(attr1);
|
|
172
|
-
}
|
|
173
|
-
for (const attr2 of reactAttrs){
|
|
174
|
-
place.mount.setAttributeNode(attr2);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
this.prevState = _constantsJs.EMPTY_STATE;
|
|
178
|
-
this.nextProps = props;
|
|
179
|
-
this.state = props.state;
|
|
180
|
-
this.nodeViews = buildNodeViews(this);
|
|
181
|
-
// Destroy the document view description that the base class makes.
|
|
182
|
-
// A React document view will assign itself to this attribute later.
|
|
183
|
-
this.docView.destroy();
|
|
184
|
-
// @ts-expect-error this violates the typing but class does it, too.
|
|
185
|
-
this.docView = null;
|
|
186
|
-
this._destroyed = false;
|
|
187
|
-
}
|
|
188
192
|
};
|
|
@@ -4,9 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "StaticEditorView", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return StaticEditorView;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
let StaticEditorView = class StaticEditorView {
|
|
12
|
+
props;
|
|
13
|
+
nodeViews;
|
|
14
|
+
constructor(props){
|
|
15
|
+
this.props = props;
|
|
16
|
+
this.nodeViews = {};
|
|
17
|
+
}
|
|
10
18
|
get composing() {
|
|
11
19
|
return false;
|
|
12
20
|
}
|
|
@@ -44,22 +52,21 @@ let StaticEditorView = class StaticEditorView {
|
|
|
44
52
|
return result;
|
|
45
53
|
}
|
|
46
54
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return result1;
|
|
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;
|
|
54
61
|
}
|
|
55
62
|
}
|
|
56
63
|
}
|
|
57
|
-
for (const
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
return
|
|
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;
|
|
63
70
|
}
|
|
64
71
|
}
|
|
65
72
|
}
|
|
@@ -79,8 +86,4 @@ let StaticEditorView = class StaticEditorView {
|
|
|
79
86
|
domSelection() {
|
|
80
87
|
return null;
|
|
81
88
|
}
|
|
82
|
-
constructor(props){
|
|
83
|
-
this.props = props;
|
|
84
|
-
this.nodeViews = {};
|
|
85
|
-
}
|
|
86
89
|
};
|
package/dist/cjs/browser.js
CHANGED
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "browser", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return browser;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const nav = typeof navigator != "undefined" ? navigator : null;
|
|
10
12
|
const doc = typeof document != "undefined" ? document : null;
|
|
@@ -9,10 +9,14 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
reorderSiblings: ()
|
|
13
|
-
|
|
12
|
+
reorderSiblings: function() {
|
|
13
|
+
return reorderSiblings;
|
|
14
|
+
},
|
|
15
|
+
reorderSiblingsOnTransaction: function() {
|
|
16
|
+
return reorderSiblingsOnTransaction;
|
|
17
|
+
}
|
|
14
18
|
});
|
|
15
|
-
const
|
|
19
|
+
const _reactKeys = require("../plugins/reactKeys.js");
|
|
16
20
|
function reorderSiblings(pos, order) {
|
|
17
21
|
return function reorderSiblingsCommand(state, dispatch) {
|
|
18
22
|
const tr = state.tr;
|
|
@@ -53,16 +57,16 @@ function reorderSiblingsOnTransaction(pos, order, tr, state, dispatch) {
|
|
|
53
57
|
start = pos;
|
|
54
58
|
const newPositions = [];
|
|
55
59
|
for(let i = 0; i < reordered.length; i++){
|
|
56
|
-
const
|
|
60
|
+
const node = reordered[i];
|
|
57
61
|
newPositions[order[i]] = start;
|
|
58
|
-
start +=
|
|
62
|
+
start += node.nodeSize;
|
|
59
63
|
}
|
|
60
|
-
for(let
|
|
61
|
-
const oldPosition = oldPositions[
|
|
62
|
-
const newPosition = newPositions[
|
|
64
|
+
for(let i = 0; i < oldPositions.length; i++){
|
|
65
|
+
const oldPosition = oldPositions[i];
|
|
66
|
+
const newPosition = newPositions[i];
|
|
63
67
|
meta.overrides[oldPosition] = newPosition;
|
|
64
68
|
}
|
|
65
|
-
tr.setMeta(
|
|
69
|
+
tr.setMeta(_reactKeys.reactKeysPluginKey, meta);
|
|
66
70
|
dispatch(tr);
|
|
67
71
|
return true;
|
|
68
72
|
}
|
|
@@ -9,23 +9,27 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
ChildNodeViews: function() {
|
|
13
|
+
return ChildNodeViews;
|
|
14
|
+
},
|
|
15
|
+
wrapInDeco: function() {
|
|
16
|
+
return wrapInDeco;
|
|
17
|
+
}
|
|
14
18
|
});
|
|
15
|
-
const _react = /*#__PURE__*/
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
19
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
20
|
+
const _ChildDescriptionsContext = require("../contexts/ChildDescriptionsContext.js");
|
|
21
|
+
const _EditorContext = require("../contexts/EditorContext.js");
|
|
22
|
+
const _iterDeco = require("../decorations/iterDeco.js");
|
|
23
|
+
const _useReactKeys = require("../hooks/useReactKeys.js");
|
|
24
|
+
const _props = require("../props.js");
|
|
25
|
+
const _viewdesc = require("../viewdesc.js");
|
|
26
|
+
const _NativeWidgetView = require("./NativeWidgetView.js");
|
|
27
|
+
const _SeparatorHackView = require("./SeparatorHackView.js");
|
|
28
|
+
const _TextNodeView = require("./TextNodeView.js");
|
|
29
|
+
const _TrailingHackView = require("./TrailingHackView.js");
|
|
30
|
+
const _WidgetView = require("./WidgetView.js");
|
|
31
|
+
const _MarkView = require("./marks/MarkView.js");
|
|
32
|
+
const _NodeView = require("./nodes/NodeView.js");
|
|
29
33
|
function _getRequireWildcardCache(nodeInterop) {
|
|
30
34
|
if (typeof WeakMap !== "function") return null;
|
|
31
35
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -34,7 +38,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
34
38
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
35
39
|
})(nodeInterop);
|
|
36
40
|
}
|
|
37
|
-
function
|
|
41
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
38
42
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
39
43
|
return obj;
|
|
40
44
|
}
|
|
@@ -47,7 +51,9 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
47
51
|
if (cache && cache.has(obj)) {
|
|
48
52
|
return cache.get(obj);
|
|
49
53
|
}
|
|
50
|
-
var newObj = {
|
|
54
|
+
var newObj = {
|
|
55
|
+
__proto__: null
|
|
56
|
+
};
|
|
51
57
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
52
58
|
for(var key in obj){
|
|
53
59
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -66,22 +72,22 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
66
72
|
return newObj;
|
|
67
73
|
}
|
|
68
74
|
function wrapInDeco(reactNode, deco) {
|
|
69
|
-
const { nodeName
|
|
70
|
-
const props = (0,
|
|
75
|
+
const { nodeName, ...attrs } = deco.type.attrs;
|
|
76
|
+
const props = (0, _props.htmlAttrsToReactProps)(attrs);
|
|
71
77
|
// We auto-wrap text nodes in spans so that we can apply attributes
|
|
72
78
|
// and styles, but we want to avoid double-wrapping the same
|
|
73
79
|
// text node
|
|
74
80
|
if (nodeName || typeof reactNode === "string") {
|
|
75
|
-
return /*#__PURE__*/ (0, _react.createElement)(nodeName
|
|
81
|
+
return /*#__PURE__*/ (0, _react.createElement)(nodeName ?? "span", props, reactNode);
|
|
76
82
|
}
|
|
77
|
-
return /*#__PURE__*/ (0, _react.cloneElement)(reactNode, (0,
|
|
83
|
+
return /*#__PURE__*/ (0, _react.cloneElement)(reactNode, (0, _props.mergeReactProps)(reactNode.props, props));
|
|
78
84
|
}
|
|
79
85
|
function areChildrenEqual(a, b) {
|
|
80
|
-
return a.type === b.type && a.marks.every((mark)=>mark.isInSet(b.marks)) && b.marks.every((mark)=>mark.isInSet(a.marks)) && a.key === b.key && (a.type !== "node" || b.type !== "node" || a.node.eq(b.node) && (0,
|
|
86
|
+
return a.type === b.type && a.marks.every((mark)=>mark.isInSet(b.marks)) && b.marks.every((mark)=>mark.isInSet(a.marks)) && a.key === b.key && (a.type !== "node" || b.type !== "node" || a.node.eq(b.node) && (0, _viewdesc.sameOuterDeco)(a.outerDeco, b.outerDeco) && a.innerDeco.eq(b.innerDeco)) && a.widget === b.widget;
|
|
81
87
|
}
|
|
82
88
|
const ChildView = /*#__PURE__*/ (0, _react.memo)(function ChildView(param) {
|
|
83
|
-
let { child
|
|
84
|
-
const { view
|
|
89
|
+
let { child, getInnerPos } = param;
|
|
90
|
+
const { view } = (0, _react.useContext)(_EditorContext.EditorContext);
|
|
85
91
|
const childRef = (0, _react.useRef)(child);
|
|
86
92
|
childRef.current = child;
|
|
87
93
|
const getPos = (0, _react.useCallback)(()=>{
|
|
@@ -89,22 +95,22 @@ const ChildView = /*#__PURE__*/ (0, _react.memo)(function ChildView(param) {
|
|
|
89
95
|
}, [
|
|
90
96
|
getInnerPos
|
|
91
97
|
]);
|
|
92
|
-
return child.type === "widget" ? /*#__PURE__*/ _react.default.createElement(
|
|
98
|
+
return child.type === "widget" ? /*#__PURE__*/ _react.default.createElement(_WidgetView.WidgetView, {
|
|
93
99
|
key: child.key,
|
|
94
100
|
widget: child.widget,
|
|
95
101
|
getPos: getPos
|
|
96
|
-
}) : child.type === "native-widget" ? /*#__PURE__*/ _react.default.createElement(
|
|
102
|
+
}) : child.type === "native-widget" ? /*#__PURE__*/ _react.default.createElement(_NativeWidgetView.NativeWidgetView, {
|
|
97
103
|
key: child.key,
|
|
98
104
|
widget: child.widget,
|
|
99
105
|
getPos: getPos
|
|
100
106
|
}) : child.type === "hack" ? /*#__PURE__*/ _react.default.createElement(child.component, {
|
|
101
107
|
key: child.key,
|
|
102
108
|
getPos: getPos
|
|
103
|
-
}) : child.node.isText ? /*#__PURE__*/ _react.default.createElement(
|
|
109
|
+
}) : child.node.isText ? /*#__PURE__*/ _react.default.createElement(_ChildDescriptionsContext.ChildDescriptionsContext.Consumer, {
|
|
104
110
|
key: child.key
|
|
105
|
-
}, (param)
|
|
106
|
-
let { siblingsRef
|
|
107
|
-
return _react.default.createElement(
|
|
111
|
+
}, (param)=>{
|
|
112
|
+
let { siblingsRef, parentRef } = param;
|
|
113
|
+
return /*#__PURE__*/ _react.default.createElement(_TextNodeView.TextNodeView, {
|
|
108
114
|
view: view,
|
|
109
115
|
node: child.node,
|
|
110
116
|
getPos: getPos,
|
|
@@ -112,7 +118,7 @@ const ChildView = /*#__PURE__*/ (0, _react.memo)(function ChildView(param) {
|
|
|
112
118
|
parentRef: parentRef,
|
|
113
119
|
decorations: child.outerDeco
|
|
114
120
|
});
|
|
115
|
-
}) : /*#__PURE__*/ _react.default.createElement(
|
|
121
|
+
}) : /*#__PURE__*/ _react.default.createElement(_NodeView.NodeView, {
|
|
116
122
|
key: child.key,
|
|
117
123
|
node: child.node,
|
|
118
124
|
getPos: getPos,
|
|
@@ -121,7 +127,7 @@ const ChildView = /*#__PURE__*/ (0, _react.memo)(function ChildView(param) {
|
|
|
121
127
|
});
|
|
122
128
|
});
|
|
123
129
|
const InlinePartition = /*#__PURE__*/ (0, _react.memo)(function InlinePartition(param) {
|
|
124
|
-
let { childViews
|
|
130
|
+
let { childViews, getInnerPos } = param;
|
|
125
131
|
const firstChild = childViews[0];
|
|
126
132
|
const firstChildRef = (0, _react.useRef)(firstChild);
|
|
127
133
|
firstChildRef.current = firstChild;
|
|
@@ -140,7 +146,7 @@ const InlinePartition = /*#__PURE__*/ (0, _react.memo)(function InlinePartition(
|
|
|
140
146
|
});
|
|
141
147
|
}));
|
|
142
148
|
}
|
|
143
|
-
return /*#__PURE__*/ _react.default.createElement(
|
|
149
|
+
return /*#__PURE__*/ _react.default.createElement(_MarkView.MarkView, {
|
|
144
150
|
key: firstChild.key,
|
|
145
151
|
mark: firstMark,
|
|
146
152
|
getPos: getPos,
|
|
@@ -155,11 +161,9 @@ const InlinePartition = /*#__PURE__*/ (0, _react.memo)(function InlinePartition(
|
|
|
155
161
|
}));
|
|
156
162
|
});
|
|
157
163
|
const InlineView = /*#__PURE__*/ (0, _react.memo)(function InlineView(param) {
|
|
158
|
-
let { getInnerPos
|
|
164
|
+
let { getInnerPos, childViews } = param;
|
|
159
165
|
// const editorState = useEditorState();
|
|
160
166
|
const partitioned = childViews.reduce((acc, child)=>{
|
|
161
|
-
var // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
162
|
-
ref;
|
|
163
167
|
const lastPartition = acc[acc.length - 1];
|
|
164
168
|
if (!lastPartition) {
|
|
165
169
|
return [
|
|
@@ -177,7 +181,8 @@ const InlineView = /*#__PURE__*/ (0, _react.memo)(function InlineView(param) {
|
|
|
177
181
|
]
|
|
178
182
|
];
|
|
179
183
|
}
|
|
180
|
-
if (!child.marks.length && !lastChild.marks.length || child.marks.length && lastChild.marks.length &&
|
|
184
|
+
if (!child.marks.length && !lastChild.marks.length || child.marks.length && lastChild.marks.length && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
185
|
+
child.marks[0]?.eq(lastChild.marks[0])) {
|
|
181
186
|
return [
|
|
182
187
|
...acc.slice(0, acc.length - 1),
|
|
183
188
|
[
|
|
@@ -205,22 +210,22 @@ const InlineView = /*#__PURE__*/ (0, _react.memo)(function InlineView(param) {
|
|
|
205
210
|
});
|
|
206
211
|
function createKey(innerPos, offset, index, type, posToKey, widget) {
|
|
207
212
|
const pos = innerPos + offset;
|
|
208
|
-
const key = posToKey
|
|
213
|
+
const key = posToKey?.get(pos);
|
|
209
214
|
if (type === "widget" || type === "native-widget") {
|
|
210
215
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
211
216
|
if (widget.type.spec.key) // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
212
217
|
return widget.type.spec.key;
|
|
213
218
|
if (type === "widget") {
|
|
214
219
|
// eslint-disable-next-line no-console
|
|
215
|
-
console.warn(
|
|
220
|
+
console.warn(`Widget at position ${pos} doesn't have a key specified. React ProseMirror will generate a key partially based on this widget’s index into its parent’s children. This can cause issues if there are multiple adjacent widgets.`);
|
|
216
221
|
}
|
|
217
|
-
return
|
|
222
|
+
return `${key}-${index}`;
|
|
218
223
|
}
|
|
219
224
|
if (key) return key;
|
|
220
225
|
// if (!doc) return pos;
|
|
221
226
|
const parentPos = innerPos - 1;
|
|
222
|
-
const parentKey = posToKey
|
|
223
|
-
if (parentKey) return
|
|
227
|
+
const parentKey = posToKey?.get(parentPos);
|
|
228
|
+
if (parentKey) return `${parentKey}-${offset}`;
|
|
224
229
|
return pos;
|
|
225
230
|
}
|
|
226
231
|
function adjustWidgetMarksForward(lastNodeChild, widgetChild) {
|
|
@@ -239,14 +244,16 @@ function adjustWidgetMarksBack(widgetChildren, nodeChild) {
|
|
|
239
244
|
const child = widgetChildren[i];
|
|
240
245
|
if (// Using internal Decoration property, "type"
|
|
241
246
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
242
|
-
child.widget.type.side < 0
|
|
247
|
+
child.widget.type.side < 0 || // Using internal Decoration property, "type"
|
|
248
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
249
|
+
child.widget.type.spec.marks) {
|
|
243
250
|
continue;
|
|
244
251
|
}
|
|
245
252
|
child.marks = child.marks.reduce((acc, mark)=>mark.addToSet(acc), marksToSpread);
|
|
246
253
|
}
|
|
247
254
|
}
|
|
248
255
|
const ChildElement = /*#__PURE__*/ (0, _react.memo)(function ChildElement(param) {
|
|
249
|
-
let { child
|
|
256
|
+
let { child, getInnerPos } = param;
|
|
250
257
|
const childRef = (0, _react.useRef)(child);
|
|
251
258
|
childRef.current = child;
|
|
252
259
|
const getPos = (0, _react.useCallback)(()=>{
|
|
@@ -255,11 +262,11 @@ const ChildElement = /*#__PURE__*/ (0, _react.memo)(function ChildElement(param)
|
|
|
255
262
|
getInnerPos
|
|
256
263
|
]);
|
|
257
264
|
if (child.type === "node") {
|
|
258
|
-
return child.marks.reduce((element, mark)=>/*#__PURE__*/ _react.default.createElement(
|
|
265
|
+
return child.marks.reduce((element, mark)=>/*#__PURE__*/ _react.default.createElement(_MarkView.MarkView, {
|
|
259
266
|
mark: mark,
|
|
260
267
|
getPos: getPos,
|
|
261
268
|
inline: false
|
|
262
|
-
}, element), /*#__PURE__*/ _react.default.createElement(
|
|
269
|
+
}, element), /*#__PURE__*/ _react.default.createElement(_NodeView.NodeView, {
|
|
263
270
|
key: child.key,
|
|
264
271
|
outerDeco: child.outerDeco,
|
|
265
272
|
node: child.node,
|
|
@@ -297,8 +304,8 @@ function createChildElements(children, getInnerPos) {
|
|
|
297
304
|
});
|
|
298
305
|
}
|
|
299
306
|
const ChildNodeViews = /*#__PURE__*/ (0, _react.memo)(function ChildNodeViews(param) {
|
|
300
|
-
let { getPos
|
|
301
|
-
const reactKeys = (0,
|
|
307
|
+
let { getPos, node, innerDecorations } = param;
|
|
308
|
+
const reactKeys = (0, _useReactKeys.useReactKeys)();
|
|
302
309
|
const getInnerPos = (0, _react.useCallback)(()=>getPos() + 1, [
|
|
303
310
|
getPos
|
|
304
311
|
]);
|
|
@@ -307,13 +314,12 @@ const ChildNodeViews = /*#__PURE__*/ (0, _react.memo)(function ChildNodeViews(pa
|
|
|
307
314
|
const keysSeen = new Map();
|
|
308
315
|
let widgetChildren = [];
|
|
309
316
|
let lastNodeChild = null;
|
|
310
|
-
(0,
|
|
311
|
-
var _marks;
|
|
317
|
+
(0, _iterDeco.iterDeco)(node, innerDecorations, (widget, isNative, offset, index)=>{
|
|
312
318
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
313
|
-
const widgetMarks =
|
|
319
|
+
const widgetMarks = widget.type.spec.marks ?? [];
|
|
314
320
|
let key;
|
|
315
321
|
if (isNative) {
|
|
316
|
-
key = createKey(getInnerPos(), offset, index, "native-widget", reactKeys
|
|
322
|
+
key = createKey(getInnerPos(), offset, index, "native-widget", reactKeys?.posToKey, widget);
|
|
317
323
|
const child = {
|
|
318
324
|
type: "native-widget",
|
|
319
325
|
widget,
|
|
@@ -330,8 +336,8 @@ const ChildNodeViews = /*#__PURE__*/ (0, _react.memo)(function ChildNodeViews(pa
|
|
|
330
336
|
}
|
|
331
337
|
keysSeen.set(key, keysSeen.size);
|
|
332
338
|
} else {
|
|
333
|
-
key = createKey(getInnerPos(), offset, index, "widget", reactKeys
|
|
334
|
-
const
|
|
339
|
+
key = createKey(getInnerPos(), offset, index, "widget", reactKeys?.posToKey, widget);
|
|
340
|
+
const child = {
|
|
335
341
|
type: "widget",
|
|
336
342
|
widget: widget,
|
|
337
343
|
marks: widgetMarks,
|
|
@@ -339,19 +345,19 @@ const ChildNodeViews = /*#__PURE__*/ (0, _react.memo)(function ChildNodeViews(pa
|
|
|
339
345
|
index,
|
|
340
346
|
key
|
|
341
347
|
};
|
|
342
|
-
const
|
|
343
|
-
if (
|
|
344
|
-
|
|
348
|
+
const prevChild = childMap.get(key);
|
|
349
|
+
if (prevChild && areChildrenEqual(prevChild, child)) {
|
|
350
|
+
prevChild.offset = offset;
|
|
345
351
|
} else {
|
|
346
|
-
childMap.set(key,
|
|
352
|
+
childMap.set(key, child);
|
|
347
353
|
}
|
|
348
354
|
keysSeen.set(key, keysSeen.size);
|
|
349
355
|
}
|
|
350
|
-
const
|
|
351
|
-
widgetChildren.push(
|
|
356
|
+
const child = childMap.get(key);
|
|
357
|
+
widgetChildren.push(child);
|
|
352
358
|
adjustWidgetMarksForward(lastNodeChild, childMap.get(key));
|
|
353
359
|
}, (childNode, outerDeco, innerDeco, offset, index)=>{
|
|
354
|
-
const key = createKey(getInnerPos(), offset, index, "node", reactKeys
|
|
360
|
+
const key = createKey(getInnerPos(), offset, index, "node", reactKeys?.posToKey);
|
|
355
361
|
const child = {
|
|
356
362
|
type: "node",
|
|
357
363
|
node: childNode,
|
|
@@ -388,20 +394,19 @@ const ChildNodeViews = /*#__PURE__*/ (0, _react.memo)(function ChildNodeViews(pa
|
|
|
388
394
|
if (!lastChild || lastChild.type !== "node" || lastChild.node.isInline && !lastChild.node.isText || // RegExp.test actually handles undefined just fine
|
|
389
395
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
390
396
|
/\n$/.test(lastChild.node.text)) {
|
|
391
|
-
var ref, ref1, ref2, ref3;
|
|
392
397
|
children.push({
|
|
393
398
|
type: "hack",
|
|
394
|
-
component:
|
|
399
|
+
component: _SeparatorHackView.SeparatorHackView,
|
|
395
400
|
marks: [],
|
|
396
|
-
offset:
|
|
397
|
-
index: (
|
|
401
|
+
offset: lastChild?.offset ?? 0,
|
|
402
|
+
index: (lastChild?.index ?? 0) + 2,
|
|
398
403
|
key: "trailing-hack-img"
|
|
399
404
|
}, {
|
|
400
405
|
type: "hack",
|
|
401
|
-
component:
|
|
406
|
+
component: _TrailingHackView.TrailingHackView,
|
|
402
407
|
marks: [],
|
|
403
|
-
offset:
|
|
404
|
-
index: (
|
|
408
|
+
offset: lastChild?.offset ?? 0,
|
|
409
|
+
index: (lastChild?.index ?? 0) + 1,
|
|
405
410
|
key: "trailing-hack-br"
|
|
406
411
|
});
|
|
407
412
|
}
|