@uniformdev/canvas-react 19.134.3-alpha.28 → 19.135.1-alpha.10
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/dist/index.d.mts +39 -18
- package/dist/index.d.ts +39 -18
- package/dist/index.esm.js +20 -6
- package/dist/index.js +19 -5
- package/dist/index.mjs +20 -6
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React$1, { Key, ReactNode, PropsWithChildren } from 'react';
|
|
2
|
-
import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, getParameterAttributes as getParameterAttributes$1, SubscribeToCompositionOptions } from '@uniformdev/canvas';
|
|
2
|
+
import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, getParameterAttributes as getParameterAttributes$1, SubscribeToCompositionOptions, UpdateContextualEditingStateInternalMessage } from '@uniformdev/canvas';
|
|
3
3
|
export { GetParameterAttributesProps, createUniformApiEnhancer } from '@uniformdev/canvas';
|
|
4
4
|
import { P as PureUniformTextProps } from './PureUniformText-B3GAm6Dc.mjs';
|
|
5
5
|
import { RichTextNode } from '@uniformdev/richtext';
|
|
@@ -110,6 +110,9 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
110
110
|
connectedData?: {
|
|
111
111
|
pointer: string;
|
|
112
112
|
syntax: "jptr";
|
|
113
|
+
failureAction?: "a" | "p" | "t" | "c" | undefined;
|
|
114
|
+
failureLogLevel?: "i" | "e" | "w" | undefined;
|
|
115
|
+
failureDefault?: string | undefined;
|
|
113
116
|
} | undefined;
|
|
114
117
|
locales?: {
|
|
115
118
|
[key: string]: unknown;
|
|
@@ -125,7 +128,7 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
125
128
|
isSearchHit?: boolean | undefined;
|
|
126
129
|
queryStrings?: {
|
|
127
130
|
name: string;
|
|
128
|
-
value
|
|
131
|
+
value?: string | undefined;
|
|
129
132
|
helpText?: string | undefined;
|
|
130
133
|
}[] | undefined;
|
|
131
134
|
previewValue?: string | undefined;
|
|
@@ -147,6 +150,9 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
147
150
|
connectedData?: {
|
|
148
151
|
pointer: string;
|
|
149
152
|
syntax: "jptr";
|
|
153
|
+
failureAction?: "a" | "p" | "t" | "c" | undefined;
|
|
154
|
+
failureLogLevel?: "i" | "e" | "w" | undefined;
|
|
155
|
+
failureDefault?: string | undefined;
|
|
150
156
|
} | undefined;
|
|
151
157
|
locales?: {
|
|
152
158
|
[key: string]: unknown;
|
|
@@ -189,6 +195,9 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
189
195
|
connectedData?: {
|
|
190
196
|
pointer: string;
|
|
191
197
|
syntax: "jptr";
|
|
198
|
+
failureAction?: "a" | "p" | "t" | "c" | undefined;
|
|
199
|
+
failureLogLevel?: "i" | "e" | "w" | undefined;
|
|
200
|
+
failureDefault?: string | undefined;
|
|
192
201
|
} | undefined;
|
|
193
202
|
locales?: {
|
|
194
203
|
[key: string]: unknown;
|
|
@@ -214,6 +223,10 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
214
223
|
_id: string;
|
|
215
224
|
_slug?: string | null | undefined;
|
|
216
225
|
_name: string;
|
|
226
|
+
_author?: string | undefined;
|
|
227
|
+
_authorSubject?: string | undefined;
|
|
228
|
+
_creator?: string | undefined;
|
|
229
|
+
_creatorSubject?: string | undefined;
|
|
217
230
|
_pattern?: string | undefined;
|
|
218
231
|
_patternDataResources?: {
|
|
219
232
|
[key: string]: {
|
|
@@ -245,6 +258,9 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
245
258
|
connectedData?: {
|
|
246
259
|
pointer: string;
|
|
247
260
|
syntax: "jptr";
|
|
261
|
+
failureAction?: "a" | "p" | "t" | "c" | undefined;
|
|
262
|
+
failureLogLevel?: "i" | "e" | "w" | undefined;
|
|
263
|
+
failureDefault?: string | undefined;
|
|
248
264
|
} | undefined;
|
|
249
265
|
locales?: {
|
|
250
266
|
[key: string]: unknown;
|
|
@@ -430,26 +446,31 @@ type UseUniformContextualEditingStateProps = {
|
|
|
430
446
|
**/
|
|
431
447
|
global?: boolean;
|
|
432
448
|
};
|
|
449
|
+
type UseUniformContextualEditingStateReturnType = {
|
|
450
|
+
/**
|
|
451
|
+
* Returns `true` when the app is rendered inside Canvas editor. Regardless of which preview mode is currently selected ("editor" or "preview").
|
|
452
|
+
*/
|
|
453
|
+
isContextualEditing: boolean;
|
|
454
|
+
/**
|
|
455
|
+
* A reference to the currently selected component in Canvas editor.
|
|
456
|
+
* Returns `undefined` if the selected component is not part of the current React component.
|
|
457
|
+
* Set the `global` option to `true` to get a reference of the selected component anywhere in the composition tree.
|
|
458
|
+
*/
|
|
459
|
+
selectedComponentReference: UpdateContextualEditingStateInternalMessage['state']['selectedComponentReference'];
|
|
460
|
+
/**
|
|
461
|
+
* Returns the current preview mode in Canvas editor ("editor" or "preview").
|
|
462
|
+
* Returns `undefined` when the app is not rendered inside Canvas editor.
|
|
463
|
+
* Learn more about the preview modes: https://docs.uniform.app/docs/guides/composition/visual-editing#editing-and-preview-mode
|
|
464
|
+
* @deprecated this is an experimental property, it might receive breaking changes in minor releases ⚠️
|
|
465
|
+
*/
|
|
466
|
+
previewMode: UpdateContextualEditingStateInternalMessage['state']['previewMode'] | undefined;
|
|
467
|
+
};
|
|
433
468
|
/**
|
|
434
469
|
* Returns the state of contextual editing, when the app is open inside Canvas Editor.
|
|
435
470
|
* This hook can be used to improve the editing experience of your team.
|
|
436
471
|
* For example: You can use `selectedComponentReference` to control which element to show inside a carousel or an accordion.
|
|
437
472
|
*/
|
|
438
|
-
declare const useUniformContextualEditingState: ({ global, }?: UseUniformContextualEditingStateProps) =>
|
|
439
|
-
isContextualEditing: boolean;
|
|
440
|
-
selectedComponentReference: {
|
|
441
|
-
id: string;
|
|
442
|
-
slotName?: string | undefined;
|
|
443
|
-
componentIndex?: number | undefined;
|
|
444
|
-
totalComponents?: number | undefined;
|
|
445
|
-
componentName?: string | undefined;
|
|
446
|
-
componentTitle?: string | undefined;
|
|
447
|
-
parentId?: string | undefined;
|
|
448
|
-
parentType?: string | undefined;
|
|
449
|
-
isLocalized?: boolean | undefined;
|
|
450
|
-
isReadOnly?: boolean | undefined;
|
|
451
|
-
} | undefined;
|
|
452
|
-
};
|
|
473
|
+
declare const useUniformContextualEditingState: ({ global, }?: UseUniformContextualEditingStateProps) => UseUniformContextualEditingStateReturnType;
|
|
453
474
|
|
|
454
475
|
declare const componentStore: ComponentStore;
|
|
455
476
|
declare const registerUniformComponent: ({ type, variantId, component, }: {
|
|
@@ -467,4 +488,4 @@ declare const createComponentStoreResolver: (options: {
|
|
|
467
488
|
defaultComponent?: React$1.ComponentType<ComponentProps<any>>;
|
|
468
489
|
}) => RenderComponentResolver;
|
|
469
490
|
|
|
470
|
-
export { type ComponentProps, type ComponentStore, type CustomSlotChildRenderFunc, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, type RenderComponentResolver, type RenderRichTextComponentResolver, type RichTextComponentProps, type RichTextRendererComponent, type SystemRenderConfig, type SystemRenderFunction, UniformComponent, type UniformComponentContextValue, type UniformComponentProps, UniformComposition, UniformCompositionContext, type UniformCompositionProps, UniformPlayground, type UniformPlaygroundDecorator, type UniformPlaygroundProps, UniformRichText, UniformRichTextNode, type UniformRichTextNodeProps, type UniformRichTextProps, UniformSlot, type UniformSlotProps, type UniformSlotWrapperComponentProps, UniformText, type UniformTextProps, type UseCompositionEventEffectOptions, type UseUniformContextualEditingProps, type UseUniformContextualEditingStateProps, componentStore, componentStoreResolver, convertComponentToProps, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
|
|
491
|
+
export { type ComponentProps, type ComponentStore, type CustomSlotChildRenderFunc, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, type RenderComponentResolver, type RenderRichTextComponentResolver, type RichTextComponentProps, type RichTextRendererComponent, type SystemRenderConfig, type SystemRenderFunction, UniformComponent, type UniformComponentContextValue, type UniformComponentProps, UniformComposition, UniformCompositionContext, type UniformCompositionProps, UniformPlayground, type UniformPlaygroundDecorator, type UniformPlaygroundProps, UniformRichText, UniformRichTextNode, type UniformRichTextNodeProps, type UniformRichTextProps, UniformSlot, type UniformSlotProps, type UniformSlotWrapperComponentProps, UniformText, type UniformTextProps, type UseCompositionEventEffectOptions, type UseUniformContextualEditingProps, type UseUniformContextualEditingStateProps, type UseUniformContextualEditingStateReturnType, componentStore, componentStoreResolver, convertComponentToProps, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React$1, { Key, ReactNode, PropsWithChildren } from 'react';
|
|
2
|
-
import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, getParameterAttributes as getParameterAttributes$1, SubscribeToCompositionOptions } from '@uniformdev/canvas';
|
|
2
|
+
import { ComponentInstance, RootComponentInstance, UpdateCompositionMessage, getParameterAttributes as getParameterAttributes$1, SubscribeToCompositionOptions, UpdateContextualEditingStateInternalMessage } from '@uniformdev/canvas';
|
|
3
3
|
export { GetParameterAttributesProps, createUniformApiEnhancer } from '@uniformdev/canvas';
|
|
4
4
|
import { P as PureUniformTextProps } from './PureUniformText-B3GAm6Dc.js';
|
|
5
5
|
import { RichTextNode } from '@uniformdev/richtext';
|
|
@@ -110,6 +110,9 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
110
110
|
connectedData?: {
|
|
111
111
|
pointer: string;
|
|
112
112
|
syntax: "jptr";
|
|
113
|
+
failureAction?: "a" | "p" | "t" | "c" | undefined;
|
|
114
|
+
failureLogLevel?: "i" | "e" | "w" | undefined;
|
|
115
|
+
failureDefault?: string | undefined;
|
|
113
116
|
} | undefined;
|
|
114
117
|
locales?: {
|
|
115
118
|
[key: string]: unknown;
|
|
@@ -125,7 +128,7 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
125
128
|
isSearchHit?: boolean | undefined;
|
|
126
129
|
queryStrings?: {
|
|
127
130
|
name: string;
|
|
128
|
-
value
|
|
131
|
+
value?: string | undefined;
|
|
129
132
|
helpText?: string | undefined;
|
|
130
133
|
}[] | undefined;
|
|
131
134
|
previewValue?: string | undefined;
|
|
@@ -147,6 +150,9 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
147
150
|
connectedData?: {
|
|
148
151
|
pointer: string;
|
|
149
152
|
syntax: "jptr";
|
|
153
|
+
failureAction?: "a" | "p" | "t" | "c" | undefined;
|
|
154
|
+
failureLogLevel?: "i" | "e" | "w" | undefined;
|
|
155
|
+
failureDefault?: string | undefined;
|
|
150
156
|
} | undefined;
|
|
151
157
|
locales?: {
|
|
152
158
|
[key: string]: unknown;
|
|
@@ -189,6 +195,9 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
189
195
|
connectedData?: {
|
|
190
196
|
pointer: string;
|
|
191
197
|
syntax: "jptr";
|
|
198
|
+
failureAction?: "a" | "p" | "t" | "c" | undefined;
|
|
199
|
+
failureLogLevel?: "i" | "e" | "w" | undefined;
|
|
200
|
+
failureDefault?: string | undefined;
|
|
192
201
|
} | undefined;
|
|
193
202
|
locales?: {
|
|
194
203
|
[key: string]: unknown;
|
|
@@ -214,6 +223,10 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
214
223
|
_id: string;
|
|
215
224
|
_slug?: string | null | undefined;
|
|
216
225
|
_name: string;
|
|
226
|
+
_author?: string | undefined;
|
|
227
|
+
_authorSubject?: string | undefined;
|
|
228
|
+
_creator?: string | undefined;
|
|
229
|
+
_creatorSubject?: string | undefined;
|
|
217
230
|
_pattern?: string | undefined;
|
|
218
231
|
_patternDataResources?: {
|
|
219
232
|
[key: string]: {
|
|
@@ -245,6 +258,9 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
245
258
|
connectedData?: {
|
|
246
259
|
pointer: string;
|
|
247
260
|
syntax: "jptr";
|
|
261
|
+
failureAction?: "a" | "p" | "t" | "c" | undefined;
|
|
262
|
+
failureLogLevel?: "i" | "e" | "w" | undefined;
|
|
263
|
+
failureDefault?: string | undefined;
|
|
248
264
|
} | undefined;
|
|
249
265
|
locales?: {
|
|
250
266
|
[key: string]: unknown;
|
|
@@ -430,26 +446,31 @@ type UseUniformContextualEditingStateProps = {
|
|
|
430
446
|
**/
|
|
431
447
|
global?: boolean;
|
|
432
448
|
};
|
|
449
|
+
type UseUniformContextualEditingStateReturnType = {
|
|
450
|
+
/**
|
|
451
|
+
* Returns `true` when the app is rendered inside Canvas editor. Regardless of which preview mode is currently selected ("editor" or "preview").
|
|
452
|
+
*/
|
|
453
|
+
isContextualEditing: boolean;
|
|
454
|
+
/**
|
|
455
|
+
* A reference to the currently selected component in Canvas editor.
|
|
456
|
+
* Returns `undefined` if the selected component is not part of the current React component.
|
|
457
|
+
* Set the `global` option to `true` to get a reference of the selected component anywhere in the composition tree.
|
|
458
|
+
*/
|
|
459
|
+
selectedComponentReference: UpdateContextualEditingStateInternalMessage['state']['selectedComponentReference'];
|
|
460
|
+
/**
|
|
461
|
+
* Returns the current preview mode in Canvas editor ("editor" or "preview").
|
|
462
|
+
* Returns `undefined` when the app is not rendered inside Canvas editor.
|
|
463
|
+
* Learn more about the preview modes: https://docs.uniform.app/docs/guides/composition/visual-editing#editing-and-preview-mode
|
|
464
|
+
* @deprecated this is an experimental property, it might receive breaking changes in minor releases ⚠️
|
|
465
|
+
*/
|
|
466
|
+
previewMode: UpdateContextualEditingStateInternalMessage['state']['previewMode'] | undefined;
|
|
467
|
+
};
|
|
433
468
|
/**
|
|
434
469
|
* Returns the state of contextual editing, when the app is open inside Canvas Editor.
|
|
435
470
|
* This hook can be used to improve the editing experience of your team.
|
|
436
471
|
* For example: You can use `selectedComponentReference` to control which element to show inside a carousel or an accordion.
|
|
437
472
|
*/
|
|
438
|
-
declare const useUniformContextualEditingState: ({ global, }?: UseUniformContextualEditingStateProps) =>
|
|
439
|
-
isContextualEditing: boolean;
|
|
440
|
-
selectedComponentReference: {
|
|
441
|
-
id: string;
|
|
442
|
-
slotName?: string | undefined;
|
|
443
|
-
componentIndex?: number | undefined;
|
|
444
|
-
totalComponents?: number | undefined;
|
|
445
|
-
componentName?: string | undefined;
|
|
446
|
-
componentTitle?: string | undefined;
|
|
447
|
-
parentId?: string | undefined;
|
|
448
|
-
parentType?: string | undefined;
|
|
449
|
-
isLocalized?: boolean | undefined;
|
|
450
|
-
isReadOnly?: boolean | undefined;
|
|
451
|
-
} | undefined;
|
|
452
|
-
};
|
|
473
|
+
declare const useUniformContextualEditingState: ({ global, }?: UseUniformContextualEditingStateProps) => UseUniformContextualEditingStateReturnType;
|
|
453
474
|
|
|
454
475
|
declare const componentStore: ComponentStore;
|
|
455
476
|
declare const registerUniformComponent: ({ type, variantId, component, }: {
|
|
@@ -467,4 +488,4 @@ declare const createComponentStoreResolver: (options: {
|
|
|
467
488
|
defaultComponent?: React$1.ComponentType<ComponentProps<any>>;
|
|
468
489
|
}) => RenderComponentResolver;
|
|
469
490
|
|
|
470
|
-
export { type ComponentProps, type ComponentStore, type CustomSlotChildRenderFunc, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, type RenderComponentResolver, type RenderRichTextComponentResolver, type RichTextComponentProps, type RichTextRendererComponent, type SystemRenderConfig, type SystemRenderFunction, UniformComponent, type UniformComponentContextValue, type UniformComponentProps, UniformComposition, UniformCompositionContext, type UniformCompositionProps, UniformPlayground, type UniformPlaygroundDecorator, type UniformPlaygroundProps, UniformRichText, UniformRichTextNode, type UniformRichTextNodeProps, type UniformRichTextProps, UniformSlot, type UniformSlotProps, type UniformSlotWrapperComponentProps, UniformText, type UniformTextProps, type UseCompositionEventEffectOptions, type UseUniformContextualEditingProps, type UseUniformContextualEditingStateProps, componentStore, componentStoreResolver, convertComponentToProps, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
|
|
491
|
+
export { type ComponentProps, type ComponentStore, type CustomSlotChildRenderFunc, DefaultNotImplementedComponent, NOT_IMPLEMENTED_COMPONENT, type RenderComponentResolver, type RenderRichTextComponentResolver, type RichTextComponentProps, type RichTextRendererComponent, type SystemRenderConfig, type SystemRenderFunction, UniformComponent, type UniformComponentContextValue, type UniformComponentProps, UniformComposition, UniformCompositionContext, type UniformCompositionProps, UniformPlayground, type UniformPlaygroundDecorator, type UniformPlaygroundProps, UniformRichText, UniformRichTextNode, type UniformRichTextNodeProps, type UniformRichTextProps, UniformSlot, type UniformSlotProps, type UniformSlotWrapperComponentProps, UniformText, type UniformTextProps, type UseCompositionEventEffectOptions, type UseUniformContextualEditingProps, type UseUniformContextualEditingStateProps, type UseUniformContextualEditingStateReturnType, componentStore, componentStoreResolver, convertComponentToProps, createComponentStore, createComponentStoreResolver, getParameterAttributes, registerUniformComponent, useCompositionEventEffect, useUniformContextualEditing, useUniformContextualEditingState, useUniformCurrentComponent, useUniformCurrentComposition };
|
package/dist/index.esm.js
CHANGED
|
@@ -243,13 +243,14 @@ import {
|
|
|
243
243
|
isAllowedReferrer,
|
|
244
244
|
isUpdateCompositionInternalMessage
|
|
245
245
|
} from "@uniformdev/canvas";
|
|
246
|
-
import { useEffect, useMemo, useState } from "react";
|
|
246
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
247
247
|
var registeredCompositionIds = /* @__PURE__ */ new Set();
|
|
248
248
|
var useUniformContextualEditing = ({
|
|
249
249
|
initialCompositionValue,
|
|
250
250
|
enhance = (message) => message.composition
|
|
251
251
|
}) => {
|
|
252
252
|
const [contextualComposition, setContextualComposition] = useState();
|
|
253
|
+
const latestEventTimeStamp = useRef();
|
|
253
254
|
const channel = useMemo(() => {
|
|
254
255
|
var _a;
|
|
255
256
|
if (!isInContextEditingMode()) {
|
|
@@ -273,8 +274,12 @@ var useUniformContextualEditing = ({
|
|
|
273
274
|
if (!isUpdateCompositionInternalMessage(message)) {
|
|
274
275
|
return;
|
|
275
276
|
}
|
|
277
|
+
if (latestEventTimeStamp.current && message.eventTimestamp && message.eventTimestamp <= latestEventTimeStamp.current) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
276
280
|
const enhancedComposition = await enhance(message);
|
|
277
281
|
setContextualComposition(enhancedComposition);
|
|
282
|
+
latestEventTimeStamp.current = message.eventTimestamp;
|
|
278
283
|
});
|
|
279
284
|
registeredCompositionIds.add(initialCompositionValue == null ? void 0 : initialCompositionValue._id);
|
|
280
285
|
return () => {
|
|
@@ -940,6 +945,9 @@ var useUniformContextualEditingState = ({
|
|
|
940
945
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
941
946
|
const { data: componentData } = useUniformCurrentComponent();
|
|
942
947
|
const [selectedComponentReference, setSelectedComponentReference] = useState3();
|
|
948
|
+
const [previewMode, setPreviewMode] = useState3(
|
|
949
|
+
isContextualEditing ? "editor" : void 0
|
|
950
|
+
);
|
|
943
951
|
const channel = useMemo4(() => {
|
|
944
952
|
if (!isContextualEditing) {
|
|
945
953
|
return;
|
|
@@ -951,15 +959,20 @@ var useUniformContextualEditingState = ({
|
|
|
951
959
|
return channel2;
|
|
952
960
|
}, [isContextualEditing]);
|
|
953
961
|
useEffect3(() => {
|
|
962
|
+
var _a, _b;
|
|
954
963
|
if (!channel) {
|
|
955
964
|
return;
|
|
956
965
|
}
|
|
966
|
+
if (typeof window !== "undefined") {
|
|
967
|
+
setPreviewMode((_b = (_a = window.__UNIFORM_CONTEXTUAL_EDITING__) == null ? void 0 : _a.state) == null ? void 0 : _b.previewMode);
|
|
968
|
+
}
|
|
957
969
|
const unsubscribe = channel.on("update-contextual-editing-state-internal", async (message) => {
|
|
958
|
-
var
|
|
970
|
+
var _a2;
|
|
959
971
|
if (!isUpdateContextualEditingStateInternalMessage(message)) {
|
|
960
972
|
return;
|
|
961
973
|
}
|
|
962
|
-
|
|
974
|
+
setPreviewMode(message.state.previewMode);
|
|
975
|
+
if (!global && (componentData == null ? void 0 : componentData._id) !== ((_a2 = message.state.selectedComponentReference) == null ? void 0 : _a2.parentId)) {
|
|
963
976
|
setSelectedComponentReference(void 0);
|
|
964
977
|
return;
|
|
965
978
|
}
|
|
@@ -968,13 +981,14 @@ var useUniformContextualEditingState = ({
|
|
|
968
981
|
return () => {
|
|
969
982
|
unsubscribe();
|
|
970
983
|
};
|
|
971
|
-
}, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference]);
|
|
984
|
+
}, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference, setPreviewMode]);
|
|
972
985
|
return useMemo4(
|
|
973
986
|
() => ({
|
|
974
987
|
isContextualEditing,
|
|
975
|
-
selectedComponentReference
|
|
988
|
+
selectedComponentReference,
|
|
989
|
+
previewMode
|
|
976
990
|
}),
|
|
977
|
-
[isContextualEditing, selectedComponentReference]
|
|
991
|
+
[isContextualEditing, selectedComponentReference, previewMode]
|
|
978
992
|
);
|
|
979
993
|
};
|
|
980
994
|
export {
|
package/dist/index.js
CHANGED
|
@@ -282,6 +282,7 @@ var useUniformContextualEditing = ({
|
|
|
282
282
|
enhance = (message) => message.composition
|
|
283
283
|
}) => {
|
|
284
284
|
const [contextualComposition, setContextualComposition] = (0, import_react3.useState)();
|
|
285
|
+
const latestEventTimeStamp = (0, import_react3.useRef)();
|
|
285
286
|
const channel = (0, import_react3.useMemo)(() => {
|
|
286
287
|
var _a;
|
|
287
288
|
if (!isInContextEditingMode()) {
|
|
@@ -305,8 +306,12 @@ var useUniformContextualEditing = ({
|
|
|
305
306
|
if (!(0, import_canvas4.isUpdateCompositionInternalMessage)(message)) {
|
|
306
307
|
return;
|
|
307
308
|
}
|
|
309
|
+
if (latestEventTimeStamp.current && message.eventTimestamp && message.eventTimestamp <= latestEventTimeStamp.current) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
308
312
|
const enhancedComposition = await enhance(message);
|
|
309
313
|
setContextualComposition(enhancedComposition);
|
|
314
|
+
latestEventTimeStamp.current = message.eventTimestamp;
|
|
310
315
|
});
|
|
311
316
|
registeredCompositionIds.add(initialCompositionValue == null ? void 0 : initialCompositionValue._id);
|
|
312
317
|
return () => {
|
|
@@ -956,6 +961,9 @@ var useUniformContextualEditingState = ({
|
|
|
956
961
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
957
962
|
const { data: componentData } = useUniformCurrentComponent();
|
|
958
963
|
const [selectedComponentReference, setSelectedComponentReference] = (0, import_react22.useState)();
|
|
964
|
+
const [previewMode, setPreviewMode] = (0, import_react22.useState)(
|
|
965
|
+
isContextualEditing ? "editor" : void 0
|
|
966
|
+
);
|
|
959
967
|
const channel = (0, import_react22.useMemo)(() => {
|
|
960
968
|
if (!isContextualEditing) {
|
|
961
969
|
return;
|
|
@@ -967,15 +975,20 @@ var useUniformContextualEditingState = ({
|
|
|
967
975
|
return channel2;
|
|
968
976
|
}, [isContextualEditing]);
|
|
969
977
|
(0, import_react22.useEffect)(() => {
|
|
978
|
+
var _a, _b;
|
|
970
979
|
if (!channel) {
|
|
971
980
|
return;
|
|
972
981
|
}
|
|
982
|
+
if (typeof window !== "undefined") {
|
|
983
|
+
setPreviewMode((_b = (_a = window.__UNIFORM_CONTEXTUAL_EDITING__) == null ? void 0 : _a.state) == null ? void 0 : _b.previewMode);
|
|
984
|
+
}
|
|
973
985
|
const unsubscribe = channel.on("update-contextual-editing-state-internal", async (message) => {
|
|
974
|
-
var
|
|
986
|
+
var _a2;
|
|
975
987
|
if (!(0, import_canvas12.isUpdateContextualEditingStateInternalMessage)(message)) {
|
|
976
988
|
return;
|
|
977
989
|
}
|
|
978
|
-
|
|
990
|
+
setPreviewMode(message.state.previewMode);
|
|
991
|
+
if (!global && (componentData == null ? void 0 : componentData._id) !== ((_a2 = message.state.selectedComponentReference) == null ? void 0 : _a2.parentId)) {
|
|
979
992
|
setSelectedComponentReference(void 0);
|
|
980
993
|
return;
|
|
981
994
|
}
|
|
@@ -984,13 +997,14 @@ var useUniformContextualEditingState = ({
|
|
|
984
997
|
return () => {
|
|
985
998
|
unsubscribe();
|
|
986
999
|
};
|
|
987
|
-
}, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference]);
|
|
1000
|
+
}, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference, setPreviewMode]);
|
|
988
1001
|
return (0, import_react22.useMemo)(
|
|
989
1002
|
() => ({
|
|
990
1003
|
isContextualEditing,
|
|
991
|
-
selectedComponentReference
|
|
1004
|
+
selectedComponentReference,
|
|
1005
|
+
previewMode
|
|
992
1006
|
}),
|
|
993
|
-
[isContextualEditing, selectedComponentReference]
|
|
1007
|
+
[isContextualEditing, selectedComponentReference, previewMode]
|
|
994
1008
|
);
|
|
995
1009
|
};
|
|
996
1010
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -243,13 +243,14 @@ import {
|
|
|
243
243
|
isAllowedReferrer,
|
|
244
244
|
isUpdateCompositionInternalMessage
|
|
245
245
|
} from "@uniformdev/canvas";
|
|
246
|
-
import { useEffect, useMemo, useState } from "react";
|
|
246
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
247
247
|
var registeredCompositionIds = /* @__PURE__ */ new Set();
|
|
248
248
|
var useUniformContextualEditing = ({
|
|
249
249
|
initialCompositionValue,
|
|
250
250
|
enhance = (message) => message.composition
|
|
251
251
|
}) => {
|
|
252
252
|
const [contextualComposition, setContextualComposition] = useState();
|
|
253
|
+
const latestEventTimeStamp = useRef();
|
|
253
254
|
const channel = useMemo(() => {
|
|
254
255
|
var _a;
|
|
255
256
|
if (!isInContextEditingMode()) {
|
|
@@ -273,8 +274,12 @@ var useUniformContextualEditing = ({
|
|
|
273
274
|
if (!isUpdateCompositionInternalMessage(message)) {
|
|
274
275
|
return;
|
|
275
276
|
}
|
|
277
|
+
if (latestEventTimeStamp.current && message.eventTimestamp && message.eventTimestamp <= latestEventTimeStamp.current) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
276
280
|
const enhancedComposition = await enhance(message);
|
|
277
281
|
setContextualComposition(enhancedComposition);
|
|
282
|
+
latestEventTimeStamp.current = message.eventTimestamp;
|
|
278
283
|
});
|
|
279
284
|
registeredCompositionIds.add(initialCompositionValue == null ? void 0 : initialCompositionValue._id);
|
|
280
285
|
return () => {
|
|
@@ -940,6 +945,9 @@ var useUniformContextualEditingState = ({
|
|
|
940
945
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
941
946
|
const { data: componentData } = useUniformCurrentComponent();
|
|
942
947
|
const [selectedComponentReference, setSelectedComponentReference] = useState3();
|
|
948
|
+
const [previewMode, setPreviewMode] = useState3(
|
|
949
|
+
isContextualEditing ? "editor" : void 0
|
|
950
|
+
);
|
|
943
951
|
const channel = useMemo4(() => {
|
|
944
952
|
if (!isContextualEditing) {
|
|
945
953
|
return;
|
|
@@ -951,15 +959,20 @@ var useUniformContextualEditingState = ({
|
|
|
951
959
|
return channel2;
|
|
952
960
|
}, [isContextualEditing]);
|
|
953
961
|
useEffect3(() => {
|
|
962
|
+
var _a, _b;
|
|
954
963
|
if (!channel) {
|
|
955
964
|
return;
|
|
956
965
|
}
|
|
966
|
+
if (typeof window !== "undefined") {
|
|
967
|
+
setPreviewMode((_b = (_a = window.__UNIFORM_CONTEXTUAL_EDITING__) == null ? void 0 : _a.state) == null ? void 0 : _b.previewMode);
|
|
968
|
+
}
|
|
957
969
|
const unsubscribe = channel.on("update-contextual-editing-state-internal", async (message) => {
|
|
958
|
-
var
|
|
970
|
+
var _a2;
|
|
959
971
|
if (!isUpdateContextualEditingStateInternalMessage(message)) {
|
|
960
972
|
return;
|
|
961
973
|
}
|
|
962
|
-
|
|
974
|
+
setPreviewMode(message.state.previewMode);
|
|
975
|
+
if (!global && (componentData == null ? void 0 : componentData._id) !== ((_a2 = message.state.selectedComponentReference) == null ? void 0 : _a2.parentId)) {
|
|
963
976
|
setSelectedComponentReference(void 0);
|
|
964
977
|
return;
|
|
965
978
|
}
|
|
@@ -968,13 +981,14 @@ var useUniformContextualEditingState = ({
|
|
|
968
981
|
return () => {
|
|
969
982
|
unsubscribe();
|
|
970
983
|
};
|
|
971
|
-
}, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference]);
|
|
984
|
+
}, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference, setPreviewMode]);
|
|
972
985
|
return useMemo4(
|
|
973
986
|
() => ({
|
|
974
987
|
isContextualEditing,
|
|
975
|
-
selectedComponentReference
|
|
988
|
+
selectedComponentReference,
|
|
989
|
+
previewMode
|
|
976
990
|
}),
|
|
977
|
-
[isContextualEditing, selectedComponentReference]
|
|
991
|
+
[isContextualEditing, selectedComponentReference, previewMode]
|
|
978
992
|
);
|
|
979
993
|
};
|
|
980
994
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-react",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.135.1-alpha.10+261b728b6b",
|
|
4
4
|
"description": "React SDK for Uniform Canvas",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"document": "api-extractor run --local"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@uniformdev/canvas": "19.
|
|
49
|
-
"@uniformdev/context": "19.
|
|
50
|
-
"@uniformdev/context-react": "19.
|
|
51
|
-
"@uniformdev/richtext": "19.
|
|
48
|
+
"@uniformdev/canvas": "19.135.1-alpha.10+261b728b6b",
|
|
49
|
+
"@uniformdev/context": "19.135.1-alpha.10+261b728b6b",
|
|
50
|
+
"@uniformdev/context-react": "19.135.1-alpha.10+261b728b6b",
|
|
51
|
+
"@uniformdev/richtext": "19.135.1-alpha.10+261b728b6b"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"react": ">= 16 || 17 || 18",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "261b728b6bc036ca8260861715632078b3eb27ca"
|
|
69
69
|
}
|