@apollohg/react-native-rich-text-editor 2.0.0 → 2.0.2
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 +8 -116
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/android/build.gradle +3 -0
- package/android/src/main/java/com/apollohg/editor/EditorEditTextImages.kt +25 -0
- package/android/src/main/java/com/apollohg/editor/EditorV2RenderValidation.kt +1 -0
- package/android/src/main/java/com/apollohg/editor/ImageResizeOverlayView.kt +101 -33
- package/android/src/main/java/com/apollohg/editor/RenderMediaSpans.kt +15 -3
- package/android/src/main/java/com/apollohg/editor/RichTextEditorView.kt +14 -0
- package/android/src/main/java/com/apollohg/editor/viewer/AndroidProseLayoutEngine.kt +1 -1
- package/app.plugin.js +42 -39
- package/dist/AtomHost.js +18 -11
- package/dist/EditorAddon.js +4 -2
- package/dist/EditorAddonNormalization.js +17 -9
- package/dist/EditorMentionThemeNormalization.js +6 -3
- package/dist/EditorMentionThemeValidation.js +28 -11
- package/dist/EditorStyleSheetNormalization.js +85 -38
- package/dist/EditorStyleSheetTypes.d.ts +1 -1
- package/dist/EditorTheme.d.ts +4 -0
- package/dist/EditorTheme.js +5 -3
- package/dist/EditorToolbarComponent.d.ts +1 -1
- package/dist/EditorToolbarComponent.js +1 -1
- package/dist/EditorToolbarRegistry.js +5 -5
- package/dist/EditorToolbarTypes.d.ts +12 -12
- package/dist/EditorToolbarVisuals.js +1 -1
- package/dist/ExternalTextComposition.js +89 -43
- package/dist/ImageLoadingPolicy.d.ts +1 -1
- package/dist/NativeEditorBoundaryError.d.ts +7 -7
- package/dist/NativeEditorBoundaryError.js +9 -5
- package/dist/NativeEditorCollaborationTransport.d.ts +7 -7
- package/dist/NativeEditorCollaborationTransport.js +28 -15
- package/dist/NativeEditorCreateConfig.js +11 -6
- package/dist/NativeEditorCreateJson.js +51 -25
- package/dist/NativeEditorCreateValidation.js +11 -6
- package/dist/NativeEditorDocumentBridge.d.ts +1 -1
- package/dist/NativeEditorDocumentBridge.js +32 -18
- package/dist/NativeEditorDocumentHandle.d.ts +4 -4
- package/dist/NativeEditorDocumentHandle.js +1 -1
- package/dist/NativeEditorLocalAwareness.js +25 -13
- package/dist/NativeEditorNativeModule.d.ts +8 -1
- package/dist/NativeEditorNativeModule.js +7 -5
- package/dist/NativeEditorRenderNormalization.js +66 -25
- package/dist/NativeEditorResultNormalization.js +53 -29
- package/dist/NativeEditorTypes.d.ts +10 -10
- package/dist/NativeEditorV2Decimal.js +6 -3
- package/dist/NativeProseViewer.js +11 -3
- package/dist/ResourceLimits.d.ts +2 -2
- package/dist/ResourceLimits.js +7 -2
- package/dist/RichTextEditor.js +1 -1
- package/dist/RichTextEditorNativeTypes.d.ts +1 -1
- package/dist/RichTextEditorNativeView.d.ts +1 -3
- package/dist/RichTextEditorSerialization.js +24 -14
- package/dist/RichTextEditorTypes.d.ts +1 -1
- package/dist/YjsCollaboration.d.ts +7 -7
- package/dist/YjsCollaboration.js +42 -26
- package/dist/addons.d.ts +4 -4
- package/dist/addons.js +3 -3
- package/dist/atomInstances.js +6 -3
- package/dist/atomUpdates.js +7 -4
- package/dist/atoms.js +20 -12
- package/dist/attributeValidation.js +55 -24
- package/dist/contentExpression.js +80 -42
- package/dist/listMarkers.d.ts +1 -1
- package/dist/listMarkers.js +1 -1
- package/dist/schemaDefinition.d.ts +1 -1
- package/dist/schemaDefinition.js +23 -14
- package/dist/schemaDocument.js +1 -1
- package/dist/schemaDocumentConstruction.js +25 -14
- package/dist/schemaNormalization.js +51 -29
- package/dist/schemaPresets.d.ts +1 -1
- package/dist/schemaPresets.js +9 -4
- package/dist/schemaResolution.js +46 -25
- package/dist/specs/PreparedProseViewerNativeComponent.d.ts +4 -0
- package/dist/useEditorToolbarInteractions.d.ts +2 -2
- package/dist/useEditorToolbarInteractions.js +45 -23
- package/dist/useEditorToolbarItems.d.ts +1 -1
- package/dist/useEditorToolbarItems.js +4 -3
- package/dist/useEditorToolbarPresentation.d.ts +3 -3
- package/dist/useEditorToolbarPresentation.js +4 -4
- package/dist/useEditorToolbarState.d.ts +1 -1
- package/dist/useEditorToolbarState.js +1 -1
- package/dist/useFocusPreservingFrames.js +11 -8
- package/dist/useNativeEditor.d.ts +1 -1
- package/dist/useNativeEditor.js +21 -11
- package/dist/useRichTextEditorCommands.d.ts +2 -2
- package/dist/useRichTextEditorCommands.js +59 -29
- package/dist/useRichTextEditorEvents.d.ts +3 -3
- package/dist/useRichTextEditorEvents.js +75 -32
- package/dist/useRichTextEditorMentions.d.ts +4 -4
- package/dist/useRichTextEditorMentions.js +48 -29
- package/dist/useRichTextEditorPresentation.d.ts +4 -4
- package/dist/useRichTextEditorPresentation.js +25 -23
- package/dist/useRichTextEditorState.d.ts +3 -3
- package/dist/useRichTextEditorState.js +20 -15
- package/dist/useRichTextEditorUpdates.d.ts +1 -1
- package/dist/useRichTextEditorUpdates.js +99 -41
- package/dist/useViewerAtoms.js +63 -36
- package/ios/EditorCore.xcframework/ios-arm64/libeditor_core.a +0 -0
- package/ios/EditorCore.xcframework/ios-arm64_x86_64-simulator/libeditor_core.a +0 -0
- package/ios/EditorInteractionOverlays.swift +114 -122
- package/ios/EditorLayoutManager.swift +13 -3
- package/ios/EditorStyleSheet.swift +12 -1
- package/ios/EditorTextView+Images.swift +32 -10
- package/ios/EditorTextView.swift +1 -1
- package/ios/EditorV2Adapter+RenderValidation.swift +2 -2
- package/ios/NativeToolbar+ButtonStyle.swift +17 -5
- package/ios/NativeToolbar+Diagnostics.swift +15 -0
- package/ios/RenderBridge+Atoms.swift +0 -1
- package/ios/RenderBridge+Attachments.swift +0 -29
- package/ios/RichTextEditorView.swift +4 -12
- package/ios/Viewer/CoreTextProseLayoutEngine+AttributedText.swift +3 -2
- package/package.json +11 -3
- package/react-native.config.js +1 -1
- package/rust/android/arm64-v8a/libeditor_core.so +0 -0
- package/rust/android/armeabi-v7a/libeditor_core.so +0 -0
- package/rust/android/x86/libeditor_core.so +0 -0
- package/rust/android/x86_64/libeditor_core.so +0 -0
- package/src/AtomHost.tsx +58 -28
- package/src/EditorAddon.ts +18 -8
- package/src/EditorAddonNormalization.ts +40 -11
- package/src/EditorMentionThemeNormalization.ts +15 -4
- package/src/EditorMentionThemeValidation.ts +51 -14
- package/src/EditorStyleSheet.ts +1 -0
- package/src/EditorStyleSheetNormalization.ts +195 -64
- package/src/EditorStyleSheetTypes.ts +1 -1
- package/src/EditorTheme.ts +13 -5
- package/src/EditorToolbarComponent.tsx +2 -1
- package/src/EditorToolbarRegistry.tsx +23 -13
- package/src/EditorToolbarTypes.tsx +12 -12
- package/src/EditorToolbarVisuals.tsx +6 -3
- package/src/EditorUpdateRevision.ts +1 -0
- package/src/ExternalTextComposition.ts +259 -49
- package/src/ImageLoadingPolicy.ts +3 -1
- package/src/NativeEditorBoundaryError.ts +38 -11
- package/src/NativeEditorCollaborationTransport.ts +108 -27
- package/src/NativeEditorCreateConfig.ts +92 -19
- package/src/NativeEditorCreateJson.ts +163 -26
- package/src/NativeEditorCreateValidation.ts +33 -12
- package/src/NativeEditorDocumentBridge.ts +111 -19
- package/src/NativeEditorDocumentHandle.ts +9 -4
- package/src/NativeEditorLocalAwareness.ts +70 -15
- package/src/NativeEditorNativeModule.ts +13 -9
- package/src/NativeEditorRenderNormalization.ts +128 -29
- package/src/NativeEditorResultNormalization.ts +143 -32
- package/src/NativeEditorTypes.ts +12 -11
- package/src/NativeEditorV2Decimal.ts +12 -3
- package/src/NativeProseViewer.tsx +46 -16
- package/src/ResourceLimits.ts +15 -8
- package/src/RichTextEditor.tsx +3 -1
- package/src/RichTextEditorNativeTypes.tsx +1 -1
- package/src/RichTextEditorNativeView.tsx +2 -8
- package/src/RichTextEditorSerialization.tsx +70 -24
- package/src/RichTextEditorTypes.tsx +1 -1
- package/src/YjsCollaboration.ts +143 -47
- package/src/addons.ts +12 -8
- package/src/atomInstances.ts +25 -5
- package/src/atomUpdates.ts +23 -6
- package/src/atoms.ts +85 -18
- package/src/attributeValidation.ts +97 -33
- package/src/contentExpression.ts +218 -63
- package/src/listMarkers.ts +1 -1
- package/src/schemaDefinition.ts +82 -20
- package/src/schemaDocument.ts +15 -1
- package/src/schemaDocumentConstruction.ts +80 -16
- package/src/schemaNormalization.ts +155 -41
- package/src/schemaPresets.ts +37 -31
- package/src/schemaResolution.ts +126 -27
- package/src/specs/PreparedProseViewerNativeComponent.ts +4 -2
- package/src/useEditorToolbarInteractions.tsx +85 -36
- package/src/useEditorToolbarItems.tsx +50 -22
- package/src/useEditorToolbarPresentation.tsx +81 -58
- package/src/useEditorToolbarState.tsx +8 -6
- package/src/useFocusPreservingFrames.ts +43 -15
- package/src/useNativeEditor.ts +111 -51
- package/src/useRichTextEditorCommands.tsx +127 -54
- package/src/useRichTextEditorEvents.tsx +144 -42
- package/src/useRichTextEditorMentions.tsx +118 -37
- package/src/useRichTextEditorPresentation.tsx +128 -114
- package/src/useRichTextEditorState.tsx +76 -40
- package/src/useRichTextEditorUpdates.tsx +207 -56
- package/src/useViewerAtoms.tsx +162 -66
|
@@ -16,8 +16,9 @@ exports.normalizeNativeEditorV2CreateValue = normalizeNativeEditorV2CreateValue;
|
|
|
16
16
|
const NativeEditorResultNormalization_1 = require("./NativeEditorResultNormalization");
|
|
17
17
|
const EditorMentionThemeValidation_1 = require("./EditorMentionThemeValidation");
|
|
18
18
|
function validListContext(value) {
|
|
19
|
-
if (!(0, NativeEditorResultNormalization_1.isPlainRecord)(value))
|
|
19
|
+
if (!(0, NativeEditorResultNormalization_1.isPlainRecord)(value)) {
|
|
20
20
|
return false;
|
|
21
|
+
}
|
|
21
22
|
return ((0, NativeEditorResultNormalization_1.hasOnlyOwnKeys)(value, [
|
|
22
23
|
'ordered',
|
|
23
24
|
'index',
|
|
@@ -48,7 +49,11 @@ function validRenderElement(value) {
|
|
|
48
49
|
Array.isArray(value.marks) &&
|
|
49
50
|
value.marks.every(NativeEditorResultNormalization_1.validRenderMark));
|
|
50
51
|
case 'blockStart':
|
|
51
|
-
return ((0, NativeEditorResultNormalization_1.hasOnlyOwnKeys)(value, ['type',
|
|
52
|
+
return ((0, NativeEditorResultNormalization_1.hasOnlyOwnKeys)(value, ['type',
|
|
53
|
+
'nodeType',
|
|
54
|
+
'depth',
|
|
55
|
+
'listContext',
|
|
56
|
+
'language']) &&
|
|
52
57
|
typeof value.nodeType === 'string' &&
|
|
53
58
|
(0, NativeEditorResultNormalization_1.nativeEditorV2U32)(value.depth) != null &&
|
|
54
59
|
(value.language === undefined || typeof value.language === 'string') &&
|
|
@@ -61,7 +66,11 @@ function validRenderElement(value) {
|
|
|
61
66
|
(0, NativeEditorResultNormalization_1.nativeEditorV2U32)(value.docPos) != null &&
|
|
62
67
|
(value.attrs === undefined || (0, NativeEditorResultNormalization_1.isPlainRecord)(value.attrs)));
|
|
63
68
|
case 'voidBlock':
|
|
64
|
-
return ((0, NativeEditorResultNormalization_1.hasOnlyOwnKeys)(value, ['type',
|
|
69
|
+
return ((0, NativeEditorResultNormalization_1.hasOnlyOwnKeys)(value, ['type',
|
|
70
|
+
'nodeType',
|
|
71
|
+
'docPos',
|
|
72
|
+
'attrs',
|
|
73
|
+
'atomId']) &&
|
|
65
74
|
typeof value.nodeType === 'string' &&
|
|
66
75
|
(0, NativeEditorResultNormalization_1.nativeEditorV2U32)(value.docPos) != null &&
|
|
67
76
|
(value.attrs === undefined || (0, NativeEditorResultNormalization_1.isPlainRecord)(value.attrs)) &&
|
|
@@ -81,7 +90,11 @@ function validRenderElement(value) {
|
|
|
81
90
|
(value.attrs === undefined || (0, NativeEditorResultNormalization_1.isPlainRecord)(value.attrs)) &&
|
|
82
91
|
(value.mentionTheme === undefined || (0, EditorMentionThemeValidation_1.validEditorMentionTheme)(value.mentionTheme)));
|
|
83
92
|
case 'opaqueBlockAtom':
|
|
84
|
-
return ((0, NativeEditorResultNormalization_1.hasOnlyOwnKeys)(value, ['type',
|
|
93
|
+
return ((0, NativeEditorResultNormalization_1.hasOnlyOwnKeys)(value, ['type',
|
|
94
|
+
'nodeType',
|
|
95
|
+
'label',
|
|
96
|
+
'docPos',
|
|
97
|
+
'attrs']) &&
|
|
85
98
|
typeof value.nodeType === 'string' &&
|
|
86
99
|
typeof value.label === 'string' &&
|
|
87
100
|
(0, NativeEditorResultNormalization_1.nativeEditorV2U32)(value.docPos) != null &&
|
|
@@ -90,15 +103,17 @@ function validRenderElement(value) {
|
|
|
90
103
|
return false;
|
|
91
104
|
}
|
|
92
105
|
function normalizeRenderBlocks(value) {
|
|
93
|
-
if (!Array.isArray(value))
|
|
106
|
+
if (!Array.isArray(value)) {
|
|
94
107
|
return null;
|
|
95
|
-
|
|
96
|
-
|
|
108
|
+
}
|
|
109
|
+
return value.every(block => Array.isArray(block) && block.every(element => validRenderElement(element)))
|
|
110
|
+
? (value)
|
|
97
111
|
: null;
|
|
98
112
|
}
|
|
99
113
|
function normalizeRenderPatch(value) {
|
|
100
|
-
if (value === null)
|
|
114
|
+
if (value === null) {
|
|
101
115
|
return null;
|
|
116
|
+
}
|
|
102
117
|
if (!(0, NativeEditorResultNormalization_1.isPlainRecord)(value) ||
|
|
103
118
|
!(0, NativeEditorResultNormalization_1.hasExactOwnKeys)(value, [
|
|
104
119
|
'baseDocumentVersion',
|
|
@@ -121,36 +136,48 @@ function normalizeRenderPatch(value) {
|
|
|
121
136
|
return { baseDocumentVersion, startIndex, deleteCount, renderBlocks };
|
|
122
137
|
}
|
|
123
138
|
function normalizeRenderSelection(value) {
|
|
124
|
-
if (!(0, NativeEditorResultNormalization_1.isPlainRecord)(value))
|
|
139
|
+
if (!(0, NativeEditorResultNormalization_1.isPlainRecord)(value)) {
|
|
125
140
|
return null;
|
|
126
|
-
|
|
141
|
+
}
|
|
142
|
+
if (value.type === 'all') {
|
|
127
143
|
return (0, NativeEditorResultNormalization_1.hasExactOwnKeys)(value, ['type']) ? { type: 'all' } : null;
|
|
144
|
+
}
|
|
128
145
|
if (value.type === 'text') {
|
|
129
|
-
if (!(0, NativeEditorResultNormalization_1.hasExactOwnKeys)(value, ['type',
|
|
146
|
+
if (!(0, NativeEditorResultNormalization_1.hasExactOwnKeys)(value, ['type',
|
|
147
|
+
'anchor',
|
|
148
|
+
'head',
|
|
149
|
+
'anchorScalar',
|
|
150
|
+
'headScalar'])) {
|
|
130
151
|
return null;
|
|
131
152
|
}
|
|
132
153
|
const anchor = (0, NativeEditorResultNormalization_1.nativeEditorV2U32)(value.anchor);
|
|
133
154
|
const head = (0, NativeEditorResultNormalization_1.nativeEditorV2U32)(value.head);
|
|
134
155
|
const anchorScalar = (0, NativeEditorResultNormalization_1.nativeEditorV2U32)(value.anchorScalar);
|
|
135
156
|
const headScalar = (0, NativeEditorResultNormalization_1.nativeEditorV2U32)(value.headScalar);
|
|
136
|
-
if (anchor == null || head == null || anchorScalar == null || headScalar == null)
|
|
157
|
+
if (anchor == null || head == null || anchorScalar == null || headScalar == null) {
|
|
137
158
|
return null;
|
|
138
|
-
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
type: 'text', anchor, head, anchorScalar, headScalar,
|
|
162
|
+
};
|
|
139
163
|
}
|
|
140
164
|
if (value.type === 'node') {
|
|
141
|
-
if (!(0, NativeEditorResultNormalization_1.hasExactOwnKeys)(value, ['type', 'pos', 'posScalar']))
|
|
165
|
+
if (!(0, NativeEditorResultNormalization_1.hasExactOwnKeys)(value, ['type', 'pos', 'posScalar'])) {
|
|
142
166
|
return null;
|
|
167
|
+
}
|
|
143
168
|
const pos = (0, NativeEditorResultNormalization_1.nativeEditorV2U32)(value.pos);
|
|
144
169
|
const posScalar = (0, NativeEditorResultNormalization_1.nativeEditorV2U32)(value.posScalar);
|
|
145
|
-
if (pos == null || posScalar == null)
|
|
170
|
+
if (pos == null || posScalar == null) {
|
|
146
171
|
return null;
|
|
172
|
+
}
|
|
147
173
|
return { type: 'node', pos, posScalar };
|
|
148
174
|
}
|
|
149
175
|
return null;
|
|
150
176
|
}
|
|
151
177
|
function normalizeRenderActiveState(value) {
|
|
152
|
-
if (!(0, NativeEditorResultNormalization_1.isPlainRecord)(value))
|
|
178
|
+
if (!(0, NativeEditorResultNormalization_1.isPlainRecord)(value)) {
|
|
153
179
|
return null;
|
|
180
|
+
}
|
|
154
181
|
if (!(0, NativeEditorResultNormalization_1.hasExactOwnKeys)(value, [
|
|
155
182
|
'marks',
|
|
156
183
|
'markAttrs',
|
|
@@ -168,11 +195,19 @@ function normalizeRenderActiveState(value) {
|
|
|
168
195
|
!(0, NativeEditorResultNormalization_1.stringArray)(value.insertableNodes)) {
|
|
169
196
|
return null;
|
|
170
197
|
}
|
|
171
|
-
return
|
|
198
|
+
return {
|
|
199
|
+
marks: value.marks,
|
|
200
|
+
markAttrs: value.markAttrs,
|
|
201
|
+
nodes: value.nodes,
|
|
202
|
+
commands: value.commands,
|
|
203
|
+
allowedMarks: value.allowedMarks,
|
|
204
|
+
insertableNodes: value.insertableNodes,
|
|
205
|
+
};
|
|
172
206
|
}
|
|
173
207
|
function normalizeRenderHistoryState(value) {
|
|
174
|
-
if (!(0, NativeEditorResultNormalization_1.isPlainRecord)(value) || !(0, NativeEditorResultNormalization_1.hasExactOwnKeys)(value, ['canUndo', 'canRedo']))
|
|
208
|
+
if (!(0, NativeEditorResultNormalization_1.isPlainRecord)(value) || !(0, NativeEditorResultNormalization_1.hasExactOwnKeys)(value, ['canUndo', 'canRedo'])) {
|
|
175
209
|
return null;
|
|
210
|
+
}
|
|
176
211
|
const canUndo = (0, NativeEditorResultNormalization_1.optionalBoolean)(value.canUndo);
|
|
177
212
|
const canRedo = (0, NativeEditorResultNormalization_1.optionalBoolean)(value.canRedo);
|
|
178
213
|
return canUndo == null || canRedo == null ? null : { canUndo, canRedo };
|
|
@@ -189,8 +224,9 @@ function deepFreezeV2Value(value) {
|
|
|
189
224
|
/** Validate and freeze the one complete render/state snapshot. */
|
|
190
225
|
function normalizeNativeEditorV2RenderUpdateValue(value) {
|
|
191
226
|
const parsed = (0, NativeEditorResultNormalization_1.parseNativeEditorV2JsonValue)(value);
|
|
192
|
-
if (!(0, NativeEditorResultNormalization_1.isPlainRecord)(parsed))
|
|
227
|
+
if (!(0, NativeEditorResultNormalization_1.isPlainRecord)(parsed)) {
|
|
193
228
|
return null;
|
|
229
|
+
}
|
|
194
230
|
if (!(0, NativeEditorResultNormalization_1.hasExactOwnKeys)(parsed, [
|
|
195
231
|
'renderBlocks',
|
|
196
232
|
'renderPatch',
|
|
@@ -225,13 +261,15 @@ function normalizeNativeEditorV2RenderUpdateValue(value) {
|
|
|
225
261
|
}
|
|
226
262
|
let renderPayload;
|
|
227
263
|
if (renderBlocks == null) {
|
|
228
|
-
if (parsed.renderBlocks !== null || renderPatch == null)
|
|
264
|
+
if (parsed.renderBlocks !== null || renderPatch == null) {
|
|
229
265
|
return null;
|
|
266
|
+
}
|
|
230
267
|
renderPayload = { renderBlocks: null, renderPatch };
|
|
231
268
|
}
|
|
232
269
|
else {
|
|
233
|
-
if (renderPatch !== null)
|
|
270
|
+
if (renderPatch !== null) {
|
|
234
271
|
return null;
|
|
272
|
+
}
|
|
235
273
|
renderPayload = { renderBlocks, renderPatch: null };
|
|
236
274
|
}
|
|
237
275
|
return deepFreezeV2Value({
|
|
@@ -247,7 +285,7 @@ function normalizeNativeEditorV2RenderUpdateValue(value) {
|
|
|
247
285
|
}
|
|
248
286
|
function normalizeNativeEditorV2DocumentJsonValue(value) {
|
|
249
287
|
const parsed = (0, NativeEditorResultNormalization_1.parseNativeEditorV2JsonValue)(value);
|
|
250
|
-
return (0, NativeEditorResultNormalization_1.isPlainRecord)(parsed) ? parsed : null;
|
|
288
|
+
return (0, NativeEditorResultNormalization_1.isPlainRecord)(parsed) ? (parsed) : null;
|
|
251
289
|
}
|
|
252
290
|
function normalizeNativeEditorV2ContentSnapshotValue(value) {
|
|
253
291
|
const parsed = (0, NativeEditorResultNormalization_1.parseNativeEditorV2JsonValue)(value);
|
|
@@ -258,17 +296,20 @@ function normalizeNativeEditorV2ContentSnapshotValue(value) {
|
|
|
258
296
|
}
|
|
259
297
|
/** The snapshot export record arrives as direct fields (JSON + bytes), not a JSON string. */
|
|
260
298
|
function normalizeNativeEditorV2SnapshotExportValue(value) {
|
|
261
|
-
if (!(0, NativeEditorResultNormalization_1.isPlainRecord)(value) || typeof value.metadataJson !== 'string')
|
|
299
|
+
if (!(0, NativeEditorResultNormalization_1.isPlainRecord)(value) || typeof value.metadataJson !== 'string') {
|
|
262
300
|
return null;
|
|
301
|
+
}
|
|
263
302
|
const encodedState = (0, NativeEditorResultNormalization_1.normalizeNativeEditorV2Bytes)(value.encodedState);
|
|
264
|
-
if (encodedState == null)
|
|
303
|
+
if (encodedState == null) {
|
|
265
304
|
return null;
|
|
305
|
+
}
|
|
266
306
|
return { metadataJson: value.metadataJson, encodedState };
|
|
267
307
|
}
|
|
268
308
|
function normalizeNativeEditorV2CreateValue(value) {
|
|
269
309
|
const parsed = (0, NativeEditorResultNormalization_1.parseNativeEditorV2JsonValue)(value);
|
|
270
|
-
if (!(0, NativeEditorResultNormalization_1.isPlainRecord)(parsed))
|
|
310
|
+
if (!(0, NativeEditorResultNormalization_1.isPlainRecord)(parsed)) {
|
|
271
311
|
return null;
|
|
312
|
+
}
|
|
272
313
|
const editorId = (0, NativeEditorResultNormalization_1.normalizeNativeEditorV2DecimalId)(parsed.editorId);
|
|
273
314
|
return editorId == null ? null : { editorId };
|
|
274
315
|
}
|
|
@@ -44,12 +44,14 @@ function isPlainRecord(value) {
|
|
|
44
44
|
* turns that into the non-retryable FFI_RESULT_INVALID error.
|
|
45
45
|
*/
|
|
46
46
|
function normalizeNativeEditorV2Result(raw, normalizeValue) {
|
|
47
|
-
if (!isPlainRecord(raw))
|
|
47
|
+
if (!isPlainRecord(raw)) {
|
|
48
48
|
return null;
|
|
49
|
+
}
|
|
49
50
|
const hasValue = raw.value !== null && raw.value !== undefined;
|
|
50
51
|
const hasError = raw.error !== null && raw.error !== undefined;
|
|
51
|
-
if (hasValue === hasError)
|
|
52
|
+
if (hasValue === hasError) {
|
|
52
53
|
return null;
|
|
54
|
+
}
|
|
53
55
|
if (hasError) {
|
|
54
56
|
const error = (0, NativeEditorBoundaryError_1.normalizeNativeEditorV2Error)({ error: raw.error });
|
|
55
57
|
return error == null ? null : { ok: false, error };
|
|
@@ -59,8 +61,9 @@ function normalizeNativeEditorV2Result(raw, normalizeValue) {
|
|
|
59
61
|
}
|
|
60
62
|
/** Parse a JSON-string result value; anything else is a contract violation. */
|
|
61
63
|
function parseNativeEditorV2JsonValue(value) {
|
|
62
|
-
if (typeof value !== 'string' || value === '')
|
|
64
|
+
if (typeof value !== 'string' || value === '') {
|
|
63
65
|
return null;
|
|
66
|
+
}
|
|
64
67
|
try {
|
|
65
68
|
return JSON.parse(value);
|
|
66
69
|
}
|
|
@@ -73,13 +76,15 @@ function parseNativeEditorV2JsonValue(value) {
|
|
|
73
76
|
* purpose: the frozen v2 contract moves bytes as bytes.
|
|
74
77
|
*/
|
|
75
78
|
function normalizeNativeEditorV2Bytes(value) {
|
|
76
|
-
if (value instanceof Uint8Array)
|
|
79
|
+
if (value instanceof Uint8Array) {
|
|
77
80
|
return value;
|
|
81
|
+
}
|
|
78
82
|
if (ArrayBuffer.isView(value)) {
|
|
79
83
|
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
80
84
|
}
|
|
81
|
-
if (value instanceof ArrayBuffer)
|
|
85
|
+
if (value instanceof ArrayBuffer) {
|
|
82
86
|
return new Uint8Array(value);
|
|
87
|
+
}
|
|
83
88
|
return null;
|
|
84
89
|
}
|
|
85
90
|
/** FfiUnitResult successes are exactly `true`; anything else is invalid. */
|
|
@@ -144,8 +149,9 @@ function whitelisted(value, allowed) {
|
|
|
144
149
|
}
|
|
145
150
|
function normalizeNativeEditorV2StateValue(value) {
|
|
146
151
|
const parsed = typeof value === 'string' ? parseNativeEditorV2JsonValue(value) : value;
|
|
147
|
-
if (!isPlainRecord(parsed))
|
|
152
|
+
if (!isPlainRecord(parsed)) {
|
|
148
153
|
return null;
|
|
154
|
+
}
|
|
149
155
|
const documentState = whitelisted(parsed.documentState, exports.V2_DOCUMENT_STATES);
|
|
150
156
|
const transportState = whitelisted(parsed.transportState, exports.V2_TRANSPORT_STATES);
|
|
151
157
|
const renderState = whitelisted(parsed.renderState, exports.V2_RENDER_STATES);
|
|
@@ -177,16 +183,18 @@ function normalizeNativeEditorV2StateValue(value) {
|
|
|
177
183
|
}
|
|
178
184
|
function normalizeNativeEditorV2MutationOutcomeValue(value) {
|
|
179
185
|
const parsed = parseNativeEditorV2JsonValue(value);
|
|
180
|
-
if (!isPlainRecord(parsed))
|
|
186
|
+
if (!isPlainRecord(parsed)) {
|
|
181
187
|
return null;
|
|
188
|
+
}
|
|
182
189
|
if (parsed.type === 'notApplicable') {
|
|
183
190
|
return { type: 'notApplicable' };
|
|
184
191
|
}
|
|
185
192
|
if (parsed.type === 'replacement') {
|
|
186
193
|
const changed = optionalBoolean(parsed.changed);
|
|
187
194
|
const documentRevision = normalizeRevisionField(parsed, 'documentRevision');
|
|
188
|
-
if (changed == null || documentRevision == null)
|
|
195
|
+
if (changed == null || documentRevision == null) {
|
|
189
196
|
return null;
|
|
197
|
+
}
|
|
190
198
|
return { type: 'replacement', changed, documentRevision };
|
|
191
199
|
}
|
|
192
200
|
if (parsed.type === 'transaction') {
|
|
@@ -215,24 +223,28 @@ function normalizeNativeEditorV2MutationOutcomeValue(value) {
|
|
|
215
223
|
}
|
|
216
224
|
function normalizeNativeEditorV2CommitValue(value) {
|
|
217
225
|
const parsed = parseNativeEditorV2JsonValue(value);
|
|
218
|
-
if (!isPlainRecord(parsed))
|
|
226
|
+
if (!isPlainRecord(parsed)) {
|
|
219
227
|
return null;
|
|
228
|
+
}
|
|
220
229
|
const changed = optionalBoolean(parsed.changed);
|
|
221
230
|
const documentRevision = normalizeRevisionField(parsed, 'documentRevision');
|
|
222
|
-
if (changed == null || documentRevision == null)
|
|
231
|
+
if (changed == null || documentRevision == null) {
|
|
223
232
|
return null;
|
|
233
|
+
}
|
|
224
234
|
return { changed, documentRevision };
|
|
225
235
|
}
|
|
226
236
|
function normalizeNativeEditorV2ChangedValue(value) {
|
|
227
237
|
const parsed = parseNativeEditorV2JsonValue(value);
|
|
228
|
-
if (!isPlainRecord(parsed))
|
|
238
|
+
if (!isPlainRecord(parsed)) {
|
|
229
239
|
return null;
|
|
240
|
+
}
|
|
230
241
|
return optionalBoolean(parsed.changed);
|
|
231
242
|
}
|
|
232
243
|
function normalizeNativeEditorV2HtmlValue(value) {
|
|
233
244
|
const parsed = parseNativeEditorV2JsonValue(value);
|
|
234
|
-
if (!isPlainRecord(parsed) || typeof parsed.html !== 'string')
|
|
245
|
+
if (!isPlainRecord(parsed) || typeof parsed.html !== 'string') {
|
|
235
246
|
return null;
|
|
247
|
+
}
|
|
236
248
|
return parsed.html;
|
|
237
249
|
}
|
|
238
250
|
exports.RENDER_ELEMENT_TYPES = new Set([
|
|
@@ -252,23 +264,27 @@ function hasExactOwnKeys(record, expected) {
|
|
|
252
264
|
}
|
|
253
265
|
function hasOnlyOwnKeys(record, allowed) {
|
|
254
266
|
const allowedKeys = new Set(allowed);
|
|
255
|
-
return Object.keys(record).every(
|
|
267
|
+
return Object.keys(record).every(key => allowedKeys.has(key));
|
|
256
268
|
}
|
|
257
269
|
function booleanRecord(value) {
|
|
258
|
-
return (isPlainRecord(value) && Object.values(value).every(
|
|
270
|
+
return (isPlainRecord(value) && Object.values(value).every(entry => typeof entry === 'boolean'));
|
|
259
271
|
}
|
|
260
272
|
function stringArray(value) {
|
|
261
|
-
return Array.isArray(value) && value.every(
|
|
273
|
+
return Array.isArray(value) && value.every(entry => typeof entry === 'string');
|
|
262
274
|
}
|
|
263
275
|
function validJsonValue(value) {
|
|
264
|
-
if (value === null)
|
|
276
|
+
if (value === null) {
|
|
265
277
|
return true;
|
|
266
|
-
|
|
278
|
+
}
|
|
279
|
+
if (typeof value === 'string' || typeof value === 'boolean') {
|
|
267
280
|
return true;
|
|
268
|
-
|
|
281
|
+
}
|
|
282
|
+
if (typeof value === 'number') {
|
|
269
283
|
return Number.isFinite(value);
|
|
270
|
-
|
|
284
|
+
}
|
|
285
|
+
if (Array.isArray(value)) {
|
|
271
286
|
return value.every(validJsonValue);
|
|
287
|
+
}
|
|
272
288
|
return isPlainRecord(value) && Object.values(value).every(validJsonValue);
|
|
273
289
|
}
|
|
274
290
|
function validRenderMark(value) {
|
|
@@ -279,34 +295,40 @@ function validRenderMark(value) {
|
|
|
279
295
|
}
|
|
280
296
|
function normalizeNativeEditorV2PeersValue(value) {
|
|
281
297
|
const parsed = typeof value === 'string' ? parseNativeEditorV2JsonValue(value) : value;
|
|
282
|
-
if (!isPlainRecord(parsed) || !Array.isArray(parsed.peers))
|
|
298
|
+
if (!isPlainRecord(parsed) || !Array.isArray(parsed.peers)) {
|
|
283
299
|
return null;
|
|
300
|
+
}
|
|
284
301
|
const peers = [];
|
|
285
302
|
for (const rawPeer of parsed.peers) {
|
|
286
|
-
if (!isPlainRecord(rawPeer))
|
|
303
|
+
if (!isPlainRecord(rawPeer)) {
|
|
287
304
|
return null;
|
|
305
|
+
}
|
|
288
306
|
const clientId = normalizeNativeEditorV2DecimalId(rawPeer.clientId);
|
|
289
307
|
const clock = nativeEditorV2U32(rawPeer.clock);
|
|
290
308
|
const isLocal = optionalBoolean(rawPeer.isLocal);
|
|
291
|
-
if (clientId == null || clock == null || isLocal == null)
|
|
309
|
+
if (clientId == null || clock == null || isLocal == null) {
|
|
292
310
|
return null;
|
|
293
|
-
|
|
311
|
+
}
|
|
312
|
+
if (rawPeer.state !== null && !isPlainRecord(rawPeer.state)) {
|
|
294
313
|
return null;
|
|
314
|
+
}
|
|
295
315
|
let cursor = null;
|
|
296
316
|
if (rawPeer.cursor !== null && rawPeer.cursor !== undefined) {
|
|
297
|
-
if (!isPlainRecord(rawPeer.cursor))
|
|
317
|
+
if (!isPlainRecord(rawPeer.cursor)) {
|
|
298
318
|
return null;
|
|
319
|
+
}
|
|
299
320
|
const anchor = nativeEditorV2U32(rawPeer.cursor.anchor);
|
|
300
321
|
const head = nativeEditorV2U32(rawPeer.cursor.head);
|
|
301
|
-
if (anchor == null || head == null)
|
|
322
|
+
if (anchor == null || head == null) {
|
|
302
323
|
return null;
|
|
324
|
+
}
|
|
303
325
|
cursor = { anchor, head };
|
|
304
326
|
}
|
|
305
327
|
peers.push({
|
|
306
328
|
clientId,
|
|
307
329
|
clock,
|
|
308
330
|
isLocal,
|
|
309
|
-
state: rawPeer.state ?? null,
|
|
331
|
+
state: (rawPeer.state) ?? null,
|
|
310
332
|
cursor,
|
|
311
333
|
});
|
|
312
334
|
}
|
|
@@ -322,8 +344,9 @@ function describeRejectedV2Record(raw) {
|
|
|
322
344
|
catch {
|
|
323
345
|
return `<unserializable ${typeof raw}>`;
|
|
324
346
|
}
|
|
325
|
-
if (serialized === undefined)
|
|
347
|
+
if (serialized === undefined) {
|
|
326
348
|
return `<${typeof raw}>`;
|
|
349
|
+
}
|
|
327
350
|
return serialized.length > exports.REJECTED_V2_RECORD_PREVIEW_CHARS
|
|
328
351
|
? `${serialized.slice(0, exports.REJECTED_V2_RECORD_PREVIEW_CHARS)}… (${serialized.length} chars)`
|
|
329
352
|
: serialized;
|
|
@@ -374,14 +397,15 @@ function unwrapNativeEditorV2Result(raw, normalizeValue) {
|
|
|
374
397
|
const result = normalizeNativeEditorV2Result(raw, normalizeValue);
|
|
375
398
|
if (result == null) {
|
|
376
399
|
// The thrown error cannot carry the payload, so name the rejected
|
|
377
|
-
// record here
|
|
400
|
+
// record here : otherwise the failure is unattributable in the app.
|
|
378
401
|
if (__DEV__) {
|
|
379
402
|
console.error('NativeEditorBridge: native module returned a record this boundary rejected', describeRejectedV2Record(raw));
|
|
380
403
|
}
|
|
381
404
|
throw invalidV2ResultError();
|
|
382
405
|
}
|
|
383
|
-
if (!result.ok)
|
|
406
|
+
if (!result.ok) {
|
|
384
407
|
throw (0, NativeEditorBoundaryError_1.nativeEditorV2ErrorToException)(result.error);
|
|
408
|
+
}
|
|
385
409
|
return result.value;
|
|
386
410
|
}
|
|
387
411
|
function requireV2DecimalId(value, field) {
|
|
@@ -48,11 +48,11 @@ export interface NativeEditorLocalAwarenessIntent {
|
|
|
48
48
|
* How this intent treats the local cursor. Rust owns it as a sticky
|
|
49
49
|
* index, so the three cases are deliberately distinct:
|
|
50
50
|
*
|
|
51
|
-
* - **omitted**
|
|
51
|
+
* - **omitted** : retain the cursor already published. Use this for
|
|
52
52
|
* focus-only or state-only updates: restating a document position
|
|
53
53
|
* that the document has since invalidated would be refused.
|
|
54
|
-
* - **`null`**
|
|
55
|
-
* - **a factory selection**
|
|
54
|
+
* - **`null`** : publish presence with no cursor at all.
|
|
55
|
+
* - **a factory selection** : set the cursor to these positions, which
|
|
56
56
|
* must resolve against the current document.
|
|
57
57
|
*/
|
|
58
58
|
selection?: NativeEditorLocalAwarenessSelection | null;
|
|
@@ -65,7 +65,7 @@ export interface ListContext {
|
|
|
65
65
|
index: number;
|
|
66
66
|
/** Number of sibling items in the enclosing list. */
|
|
67
67
|
total: number;
|
|
68
|
-
/** The list's `start` attribute
|
|
68
|
+
/** The list's `start` attribute : the number the first item takes. */
|
|
69
69
|
start: number;
|
|
70
70
|
isFirst: boolean;
|
|
71
71
|
isLast: boolean;
|
|
@@ -107,7 +107,7 @@ export interface RenderBlocksPatch {
|
|
|
107
107
|
deleteCount: number;
|
|
108
108
|
renderBlocks: RenderElement[][];
|
|
109
109
|
}
|
|
110
|
-
/** What the current selection can do
|
|
110
|
+
/** What the current selection can do : the state a toolbar renders from. */
|
|
111
111
|
export interface ActiveState {
|
|
112
112
|
/** Marks active at the selection, keyed by mark name. */
|
|
113
113
|
marks: Record<string, boolean>;
|
|
@@ -213,12 +213,12 @@ export interface NativeEditorRoomSnapshot {
|
|
|
213
213
|
encodedState: Uint8Array;
|
|
214
214
|
}
|
|
215
215
|
/**
|
|
216
|
-
* How a document handle's content starts out. Fixed at creation
|
|
216
|
+
* How a document handle's content starts out. Fixed at creation : there is no
|
|
217
217
|
* prop equivalent.
|
|
218
218
|
*
|
|
219
|
-
* - `localEmpty`
|
|
220
|
-
* - `localJson` / `localHtml`
|
|
221
|
-
* - `room`
|
|
219
|
+
* - `localEmpty` : the schema's empty document.
|
|
220
|
+
* - `localJson` / `localHtml` : seeded from the given content.
|
|
221
|
+
* - `room` : a collaborative document. It renders nothing until the server's
|
|
222
222
|
* document arrives, unless a `snapshot` seeds it offline.
|
|
223
223
|
*/
|
|
224
224
|
export type NativeEditorInitialization = {
|
|
@@ -286,7 +286,7 @@ export type NativeEditorOffsetKind = 'scalar' | 'utf16';
|
|
|
286
286
|
export type NativeEditorPositionAffinity = 'before' | 'after';
|
|
287
287
|
/**
|
|
288
288
|
* Mirrors the Rust `PositionEnvelope`. `offset` is measured in the currency
|
|
289
|
-
* named by `kind`
|
|
289
|
+
* named by `kind` : scalar offsets are Unicode scalars, not document positions.
|
|
290
290
|
*/
|
|
291
291
|
export interface NativeEditorPositionEnvelope {
|
|
292
292
|
offset: number;
|
|
@@ -8,11 +8,14 @@ const V2_U64_MAX = '18446744073709551615';
|
|
|
8
8
|
* lexical after syntax validation, so JavaScript never coerces the value.
|
|
9
9
|
*/
|
|
10
10
|
function normalizeNativeEditorV2U64(value) {
|
|
11
|
-
if (typeof value !== 'string' || !CANONICAL_V2_U64.test(value))
|
|
11
|
+
if (typeof value !== 'string' || !CANONICAL_V2_U64.test(value)) {
|
|
12
12
|
return null;
|
|
13
|
-
|
|
13
|
+
}
|
|
14
|
+
if (value.length < V2_U64_MAX.length) {
|
|
14
15
|
return value;
|
|
15
|
-
|
|
16
|
+
}
|
|
17
|
+
if (value.length > V2_U64_MAX.length || value > V2_U64_MAX) {
|
|
16
18
|
return null;
|
|
19
|
+
}
|
|
17
20
|
return value;
|
|
18
21
|
}
|
|
@@ -65,7 +65,12 @@ function RichTextViewer(props) {
|
|
|
65
65
|
const { contentJSON, contentHTML, schema, atoms, readOnly = true, atomsInteractive = true, atomViewport, onUpdateAtomAttrs, theme, allowBase64Images = false, imageLoadingPolicy, resourceLimits, collapseTrailingEmptyParagraphs = true, enableLinkTaps = true, renderImages = true, fontEnvironmentRevision = 0, addons, onPressLink, onError, ...viewProps } = props;
|
|
66
66
|
const { mentions, codeHighlighting } = (0, react_1.useMemo)(() => (0, addons_1.normalizeEditorAddons)(addons), [addons]);
|
|
67
67
|
const resolvedResourceLimits = (0, react_1.useMemo)(() => (resourceLimits ? (0, ResourceLimits_1.resolveEditorResourceLimits)(resourceLimits) : undefined), [resourceLimits]);
|
|
68
|
-
const configJson = (0, react_1.useMemo)(() => (0, ViewerConfiguration_1.serializePreparedProseViewerConfiguration)(resolveViewerConfiguration(schema, allowBase64Images, resolvedResourceLimits, mentions, atoms, codeHighlighting)), [allowBase64Images,
|
|
68
|
+
const configJson = (0, react_1.useMemo)(() => (0, ViewerConfiguration_1.serializePreparedProseViewerConfiguration)(resolveViewerConfiguration(schema, allowBase64Images, resolvedResourceLimits, mentions, atoms, codeHighlighting)), [allowBase64Images,
|
|
69
|
+
mentions,
|
|
70
|
+
resolvedResourceLimits,
|
|
71
|
+
schema,
|
|
72
|
+
atoms,
|
|
73
|
+
codeHighlighting]);
|
|
69
74
|
const themeJson = (0, react_1.useMemo)(() => (0, EditorTheme_1.serializeEditorTheme)(theme, mentions?.theme), [mentions?.theme, theme]);
|
|
70
75
|
const imagePolicyJson = (0, react_1.useMemo)(() => (0, ImageLoadingPolicy_1.serializeEditorImageLoadingPolicy)(imageLoadingPolicy), [imageLoadingPolicy]);
|
|
71
76
|
const sourceKind = contentJSON === undefined ? 'html' : 'json';
|
|
@@ -75,7 +80,9 @@ function RichTextViewer(props) {
|
|
|
75
80
|
}
|
|
76
81
|
return typeof contentJSON === 'string' ? contentJSON : stringifyCachedJson(contentJSON);
|
|
77
82
|
}, [contentHTML, contentJSON]);
|
|
78
|
-
const atomIdentity = (0, react_1.useMemo)(() => ({
|
|
83
|
+
const atomIdentity = (0, react_1.useMemo)(() => ({
|
|
84
|
+
sourceKind, source, configJson, themeJson, imagePolicyJson, renderImages, collapseTrailingEmptyParagraphs, fontEnvironmentRevision,
|
|
85
|
+
}), [
|
|
79
86
|
sourceKind,
|
|
80
87
|
source,
|
|
81
88
|
configJson,
|
|
@@ -122,8 +129,9 @@ function RichTextViewer(props) {
|
|
|
122
129
|
onError?.(event.nativeEvent);
|
|
123
130
|
}, [onError]);
|
|
124
131
|
const nativeViewer = ((0, jsx_runtime_1.jsx)(PreparedProseViewerNativeComponent_1.default, { ...(viewerAtoms.enabled ? { style: { alignSelf: 'stretch' } } : viewProps), sourceKind: sourceKind, source: source, configJson: configJson, themeJson: viewerAtoms.themeJson, onAtomLayout: viewerAtoms.enabled ? viewerAtoms.onAtomLayout : undefined, imagePolicyJson: imagePolicyJson, imagesEnabled: renderImages, collapsesWhenEmpty: collapseTrailingEmptyParagraphs, enableLinkTaps: enableLinkTaps && onPressLink != null, mentionInteractionsEnabled: mentions?.onPress != null, fontEnvironmentRevision: fontEnvironmentRevision, onPressLink: onPressLink ? handlePressLink : undefined, onPressMention: mentions?.onPress ? handlePressMention : undefined, onError: onError ? handleError : undefined }));
|
|
125
|
-
if (!viewerAtoms.enabled)
|
|
132
|
+
if (!viewerAtoms.enabled) {
|
|
126
133
|
return nativeViewer;
|
|
134
|
+
}
|
|
127
135
|
return ((0, jsx_runtime_1.jsx)(react_native_1.View, { ...viewProps, children: (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: { alignSelf: 'stretch' }, onLayout: viewerAtoms.onContainerLayout, children: [nativeViewer, viewerAtoms.children] }) }));
|
|
128
136
|
}
|
|
129
137
|
/** @deprecated Use RichTextViewer instead. */
|
package/dist/ResourceLimits.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Every field is optional; an omitted one uses
|
|
7
7
|
* {@link DEFAULT_EDITOR_RESOURCE_LIMITS}. Each value must be a positive
|
|
8
8
|
* integer no greater than the matching {@link HARD_EDITOR_RESOURCE_LIMITS}
|
|
9
|
-
* ceiling
|
|
9
|
+
* ceiling : anything else throws `NativeEditorBoundaryError`
|
|
10
10
|
* (`INVALID_RESOURCE_LIMIT`). Exceeding a limit at runtime raises
|
|
11
11
|
* `INPUT_LIMIT_EXCEEDED`, `DOCUMENT_LIMIT_EXCEEDED`, or `SCHEMA_INVALID`.
|
|
12
12
|
*/
|
|
@@ -23,7 +23,7 @@ export interface EditorResourceLimits {
|
|
|
23
23
|
maxSchemaExpressionBytes?: number;
|
|
24
24
|
/** Byte ceiling for one inbound collaboration message. */
|
|
25
25
|
maxCollaborationMessageBytes?: number;
|
|
26
|
-
/** Byte ceiling for an encoded Yjs state
|
|
26
|
+
/** Byte ceiling for an encoded Yjs state : imported room snapshots and exported ones. */
|
|
27
27
|
maxEncodedStateBytes?: number;
|
|
28
28
|
}
|
|
29
29
|
/**
|
package/dist/ResourceLimits.js
CHANGED
|
@@ -53,8 +53,9 @@ function resolveLimit(name, value) {
|
|
|
53
53
|
return resolved;
|
|
54
54
|
}
|
|
55
55
|
function validateOverrides(limits, ceilings) {
|
|
56
|
-
if (limits === undefined)
|
|
56
|
+
if (limits === undefined) {
|
|
57
57
|
return;
|
|
58
|
+
}
|
|
58
59
|
for (const name of Object.keys(ceilings)) {
|
|
59
60
|
const value = limits[name];
|
|
60
61
|
if (value !== undefined) {
|
|
@@ -76,5 +77,9 @@ function validateEditorCreateLimits(limits) {
|
|
|
76
77
|
* not a positive integer within its ceiling.
|
|
77
78
|
*/
|
|
78
79
|
function resolveEditorResourceLimits(limits = {}) {
|
|
79
|
-
|
|
80
|
+
const resolved = { ...exports.DEFAULT_EDITOR_RESOURCE_LIMITS };
|
|
81
|
+
for (const name of Object.keys(resolved)) {
|
|
82
|
+
resolved[name] = resolveLimit(name, limits[name]);
|
|
83
|
+
}
|
|
84
|
+
return resolved;
|
|
80
85
|
}
|
package/dist/RichTextEditor.js
CHANGED
|
@@ -8,7 +8,7 @@ const useRichTextEditorCommands_1 = require("./useRichTextEditorCommands");
|
|
|
8
8
|
const useRichTextEditorEvents_1 = require("./useRichTextEditorEvents");
|
|
9
9
|
const useRichTextEditorMentions_1 = require("./useRichTextEditorMentions");
|
|
10
10
|
const useRichTextEditorPresentation_1 = require("./useRichTextEditorPresentation");
|
|
11
|
-
exports.RichTextEditor = (0, react_1.forwardRef)(
|
|
11
|
+
exports.RichTextEditor = (0, react_1.forwardRef)((props, ref) => {
|
|
12
12
|
const state = (0, useRichTextEditorState_1.useRichTextEditorState)(props, ref);
|
|
13
13
|
const updates = (0, useRichTextEditorUpdates_1.useRichTextEditorUpdates)(state);
|
|
14
14
|
const commands = (0, useRichTextEditorCommands_1.useRichTextEditorCommands)({ ...state, ...updates });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExternalTextCompositionManager, type NativeExternalTextCompositionHandle } from './ExternalTextComposition';
|
|
1
|
+
import { type ExternalTextCompositionManager, type NativeExternalTextCompositionHandle } from './ExternalTextComposition';
|
|
2
2
|
import { type ReactNode } from 'react';
|
|
3
3
|
import { type NativeSyntheticEvent, type StyleProp, type ViewStyle } from 'react-native';
|
|
4
4
|
import { type DocumentJSON, type NativeEditorDocumentHandle } from './NativeEditorBridge';
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { type NativeEditorViewProps, type NativeEditorViewHandle } from './RichTextEditorNativeTypes';
|
|
3
|
-
export declare const NativeEditorView: React.ComponentType<NativeEditorViewProps & React.RefAttributes<NativeEditorViewHandle>>;
|
|
1
|
+
export declare const NativeEditorView: import("react").ComponentType<any>;
|
|
4
2
|
export declare const styles: {
|
|
5
3
|
container: {
|
|
6
4
|
position: "relative";
|