@uniformdev/canvas-react 19.55.1-alpha.8 → 19.55.2-alpha.17
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/PureUniformText-37defdc5.d.ts +41 -0
- package/dist/core.d.mts +12 -38
- package/dist/core.d.ts +12 -38
- package/dist/core.js +41 -5
- package/dist/core.mjs +43 -3
- package/dist/index.d.mts +22 -4
- package/dist/index.d.ts +22 -4
- package/dist/index.esm.js +140 -82
- package/dist/index.js +184 -132
- package/dist/index.mjs +140 -82
- package/package.json +6 -6
package/dist/index.esm.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
// src/components/DefaultNotImplementedComponent.tsx
|
|
2
4
|
import { CANVAS_LOCALIZATION_TYPE } from "@uniformdev/canvas";
|
|
3
5
|
import React from "react";
|
|
@@ -73,9 +75,9 @@ import {
|
|
|
73
75
|
CANVAS_ENRICHMENT_TAG_PARAM
|
|
74
76
|
} from "@uniformdev/canvas";
|
|
75
77
|
import { Track, TrackFragment, useUniformContext } from "@uniformdev/context-react";
|
|
76
|
-
import
|
|
78
|
+
import React7, { createContext as createContext2, useContext as useContext2 } from "react";
|
|
77
79
|
|
|
78
|
-
// src/convertComponentToProps.ts
|
|
80
|
+
// src/helpers/convertComponentToProps.ts
|
|
79
81
|
function convertComponentToProps(component) {
|
|
80
82
|
var _a;
|
|
81
83
|
const parameters = (_a = component.parameters) != null ? _a : {};
|
|
@@ -138,7 +140,7 @@ import {
|
|
|
138
140
|
CANVAS_TEST_TYPE,
|
|
139
141
|
EMPTY_COMPOSITION as EMPTY_COMPOSITION2
|
|
140
142
|
} from "@uniformdev/canvas";
|
|
141
|
-
import
|
|
143
|
+
import React6 from "react";
|
|
142
144
|
|
|
143
145
|
// src/defaultSystemComponentResolver.tsx
|
|
144
146
|
import {
|
|
@@ -182,16 +184,50 @@ var defaultSystemComponentResolver = {
|
|
|
182
184
|
};
|
|
183
185
|
|
|
184
186
|
// src/components/ContextualEditingComponentWrapper.tsx
|
|
187
|
+
import {
|
|
188
|
+
isComponentPlaceholderId
|
|
189
|
+
} from "@uniformdev/canvas";
|
|
190
|
+
import React5 from "react";
|
|
191
|
+
|
|
192
|
+
// src/components/PureContextualEditingComponentWrapper.tsx
|
|
185
193
|
import {
|
|
186
194
|
CANVAS_LOCALE_TAG_PARAM,
|
|
187
195
|
IN_CONTEXT_EDITOR_COMPONENT_END_ROLE,
|
|
188
|
-
IN_CONTEXT_EDITOR_COMPONENT_START_ROLE
|
|
189
|
-
isComponentPlaceholderId
|
|
196
|
+
IN_CONTEXT_EDITOR_COMPONENT_START_ROLE
|
|
190
197
|
} from "@uniformdev/canvas";
|
|
191
|
-
import
|
|
198
|
+
import React3 from "react";
|
|
199
|
+
var PureContextualEditingComponentWrapper = ({
|
|
200
|
+
children,
|
|
201
|
+
isPlaceholder,
|
|
202
|
+
parentComponent,
|
|
203
|
+
component,
|
|
204
|
+
slotName,
|
|
205
|
+
indexInSlot,
|
|
206
|
+
slotChildrenCount,
|
|
207
|
+
isReadOnly
|
|
208
|
+
}) => {
|
|
209
|
+
var _a, _b, _c, _d;
|
|
210
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
|
|
211
|
+
"script",
|
|
212
|
+
{
|
|
213
|
+
"data-role": IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,
|
|
214
|
+
"data-parent-id": parentComponent == null ? void 0 : parentComponent._id,
|
|
215
|
+
"data-parent-type": parentComponent == null ? void 0 : parentComponent.type,
|
|
216
|
+
"data-component-id": component == null ? void 0 : component._id,
|
|
217
|
+
"data-slot-name": slotName != null ? slotName : "",
|
|
218
|
+
"data-component-index": indexInSlot != null ? indexInSlot : "",
|
|
219
|
+
"data-total-components": slotChildrenCount != null ? slotChildrenCount : "",
|
|
220
|
+
"data-component-name": component == null ? void 0 : component.type,
|
|
221
|
+
"data-is-placeholder": isPlaceholder ? "true" : void 0,
|
|
222
|
+
"data-is-localized": ((_a = component == null ? void 0 : component.parameters) == null ? void 0 : _a[CANVAS_LOCALE_TAG_PARAM]) ? "true" : void 0,
|
|
223
|
+
"data-component-title": (_d = (_c = (_b = component == null ? void 0 : component.parameters) == null ? void 0 : _b.title) == null ? void 0 : _c.value) != null ? _d : "",
|
|
224
|
+
"data-is-readonly": isReadOnly
|
|
225
|
+
}
|
|
226
|
+
), children, /* @__PURE__ */ React3.createElement("script", { "data-role": IN_CONTEXT_EDITOR_COMPONENT_END_ROLE }));
|
|
227
|
+
};
|
|
192
228
|
|
|
193
229
|
// src/components/UniformComposition.tsx
|
|
194
|
-
import
|
|
230
|
+
import React4, { createContext, useContext } from "react";
|
|
195
231
|
|
|
196
232
|
// src/hooks/useUniformContextualEditing.ts
|
|
197
233
|
import {
|
|
@@ -200,6 +236,7 @@ import {
|
|
|
200
236
|
EMPTY_COMPOSITION,
|
|
201
237
|
IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID,
|
|
202
238
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
|
|
239
|
+
isAllowedReferrer,
|
|
203
240
|
isUpdateCompositionInternalMessage
|
|
204
241
|
} from "@uniformdev/canvas";
|
|
205
242
|
import { useEffect, useMemo, useState } from "react";
|
|
@@ -252,7 +289,7 @@ var useUniformContextualEditing = ({
|
|
|
252
289
|
window.__UNIFORM_CONTEXTUAL_EDITING__ = {
|
|
253
290
|
framework: "React",
|
|
254
291
|
// Make sure to also update the value in canvas-vue
|
|
255
|
-
version:
|
|
292
|
+
version: 2
|
|
256
293
|
};
|
|
257
294
|
const script = document.createElement("script");
|
|
258
295
|
script.id = IN_CONTEXT_EDITOR_EMBED_SCRIPT_ID;
|
|
@@ -261,7 +298,7 @@ var useUniformContextualEditing = ({
|
|
|
261
298
|
document.head.appendChild(script);
|
|
262
299
|
}, [initialCompositionValue == null ? void 0 : initialCompositionValue._id]);
|
|
263
300
|
return {
|
|
264
|
-
composition: contextualComposition
|
|
301
|
+
composition: contextualComposition ? contextualComposition : initialCompositionValue,
|
|
265
302
|
isContextualEditing: Boolean(contextualComposition)
|
|
266
303
|
};
|
|
267
304
|
};
|
|
@@ -276,10 +313,7 @@ function isInContextEditingMode() {
|
|
|
276
313
|
const isOpenedByInContextEditor = new URLSearchParams(window.location.search).has(
|
|
277
314
|
IN_CONTEXT_EDITOR_QUERY_STRING_PARAM
|
|
278
315
|
);
|
|
279
|
-
|
|
280
|
-
window.document.referrer.match(/(^https:\/\/|\.)(uniform.app|uniform.wtf|localhost:\d{4})\//)
|
|
281
|
-
);
|
|
282
|
-
return isOpenedByInContextEditor && isAllowlistedReferrer;
|
|
316
|
+
return isOpenedByInContextEditor && isAllowedReferrer(window.document.referrer);
|
|
283
317
|
}
|
|
284
318
|
|
|
285
319
|
// src/components/UniformComposition.tsx
|
|
@@ -302,12 +336,12 @@ function UniformComposition({
|
|
|
302
336
|
initialCompositionValue: data,
|
|
303
337
|
enhance: contextualEditingEnhancer
|
|
304
338
|
});
|
|
305
|
-
return /* @__PURE__ */
|
|
339
|
+
return /* @__PURE__ */ React4.createElement(
|
|
306
340
|
UniformCompositionContext.Provider,
|
|
307
341
|
{
|
|
308
342
|
value: { data: composition, behaviorTracking, resolveRenderer, isContextualEditing }
|
|
309
343
|
},
|
|
310
|
-
/* @__PURE__ */
|
|
344
|
+
/* @__PURE__ */ React4.createElement(ContextualEditingComponentWrapper, { component: composition }, /* @__PURE__ */ React4.createElement(
|
|
311
345
|
UniformComponent,
|
|
312
346
|
{
|
|
313
347
|
data: composition,
|
|
@@ -330,27 +364,30 @@ function ContextualEditingComponentWrapper({
|
|
|
330
364
|
emptyPlaceholder,
|
|
331
365
|
children
|
|
332
366
|
}) {
|
|
333
|
-
var _a
|
|
367
|
+
var _a;
|
|
334
368
|
const isPlaceholder = isComponentPlaceholderId(component == null ? void 0 : component._id);
|
|
335
369
|
const { isContextualEditing } = useUniformCurrentComposition();
|
|
336
370
|
const isReadOnly = ((_a = component == null ? void 0 : component._contextualEditing) == null ? void 0 : _a.isEditable) ? void 0 : "true";
|
|
337
|
-
|
|
338
|
-
|
|
371
|
+
if (!isContextualEditing) {
|
|
372
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, children);
|
|
373
|
+
}
|
|
374
|
+
if (isPlaceholder && emptyPlaceholder === null) {
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
return /* @__PURE__ */ React5.createElement(
|
|
378
|
+
PureContextualEditingComponentWrapper,
|
|
339
379
|
{
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
"data-is-readonly": isReadOnly
|
|
352
|
-
}
|
|
353
|
-
), isPlaceholder && emptyPlaceholder !== void 0 ? emptyPlaceholder : children, /* @__PURE__ */ React4.createElement("script", { "data-role": IN_CONTEXT_EDITOR_COMPONENT_END_ROLE }));
|
|
380
|
+
isPlaceholder,
|
|
381
|
+
parentComponent,
|
|
382
|
+
component,
|
|
383
|
+
slotName,
|
|
384
|
+
indexInSlot,
|
|
385
|
+
slotChildrenCount,
|
|
386
|
+
isReadOnly
|
|
387
|
+
},
|
|
388
|
+
isContextualEditing && /* @__PURE__ */ React5.createElement(React5.Fragment, null),
|
|
389
|
+
isPlaceholder && emptyPlaceholder !== void 0 ? emptyPlaceholder : children
|
|
390
|
+
);
|
|
354
391
|
}
|
|
355
392
|
|
|
356
393
|
// src/components/UniformSlot.tsx
|
|
@@ -389,13 +426,13 @@ function UniformSlot({
|
|
|
389
426
|
emptyPlaceholder
|
|
390
427
|
});
|
|
391
428
|
const elements = children ? children({ child, component, key: `wrapped-inner-${index}` }) : child;
|
|
392
|
-
return
|
|
429
|
+
return React6.createElement(React6.Fragment, { key: index }, elements);
|
|
393
430
|
});
|
|
394
431
|
if (!wrapperComponent) {
|
|
395
|
-
return
|
|
432
|
+
return React6.createElement(React6.Fragment, void 0, finalChildren);
|
|
396
433
|
}
|
|
397
434
|
const Wrapper = wrapperComponent;
|
|
398
|
-
return /* @__PURE__ */
|
|
435
|
+
return /* @__PURE__ */ React6.createElement(Wrapper, { items: finalChildren, slotName: name });
|
|
399
436
|
}
|
|
400
437
|
function renderComponent({
|
|
401
438
|
component,
|
|
@@ -427,7 +464,7 @@ function renderComponent({
|
|
|
427
464
|
});
|
|
428
465
|
}
|
|
429
466
|
);
|
|
430
|
-
return /* @__PURE__ */
|
|
467
|
+
return /* @__PURE__ */ React6.createElement(
|
|
431
468
|
ContextualEditingComponentWrapper,
|
|
432
469
|
{
|
|
433
470
|
component,
|
|
@@ -458,7 +495,7 @@ function renderComponent({
|
|
|
458
495
|
});
|
|
459
496
|
}
|
|
460
497
|
);
|
|
461
|
-
return /* @__PURE__ */
|
|
498
|
+
return /* @__PURE__ */ React6.createElement(
|
|
462
499
|
ContextualEditingComponentWrapper,
|
|
463
500
|
{
|
|
464
501
|
component,
|
|
@@ -472,7 +509,7 @@ function renderComponent({
|
|
|
472
509
|
);
|
|
473
510
|
} else if (RenderComponent) {
|
|
474
511
|
const props = convertComponentToProps(component);
|
|
475
|
-
return /* @__PURE__ */
|
|
512
|
+
return /* @__PURE__ */ React6.createElement(UniformComponent, { key, data: component, resolveRenderer }, /* @__PURE__ */ React6.createElement(
|
|
476
513
|
ContextualEditingComponentWrapper,
|
|
477
514
|
{
|
|
478
515
|
component,
|
|
@@ -482,7 +519,7 @@ function renderComponent({
|
|
|
482
519
|
slotChildrenCount,
|
|
483
520
|
emptyPlaceholder
|
|
484
521
|
},
|
|
485
|
-
/* @__PURE__ */
|
|
522
|
+
/* @__PURE__ */ React6.createElement(RenderComponent, { ...props })
|
|
486
523
|
));
|
|
487
524
|
} else if (process.env.NODE_ENV !== "production") {
|
|
488
525
|
console.warn(
|
|
@@ -529,9 +566,9 @@ function UniformComponent({
|
|
|
529
566
|
hasParentLayout: Boolean(parentData.data),
|
|
530
567
|
resolveRenderer: contextValue.resolveRenderer
|
|
531
568
|
});
|
|
532
|
-
return /* @__PURE__ */
|
|
569
|
+
return /* @__PURE__ */ React7.createElement(UniformComponentContext.Provider, { value: contextValue }, contextContextProviderPresent ? (
|
|
533
570
|
/* auto-track behavior signals when in a Canvas context */
|
|
534
|
-
/* @__PURE__ */
|
|
571
|
+
/* @__PURE__ */ React7.createElement(TrackComponent, { behavior: enrichmentTags }, resolvedChildren)
|
|
535
572
|
) : resolvedChildren);
|
|
536
573
|
}
|
|
537
574
|
function resolveChildren({
|
|
@@ -544,14 +581,14 @@ function resolveChildren({
|
|
|
544
581
|
if (!children && !hasParentLayout) {
|
|
545
582
|
const topLevelComponent = resolveRenderer({ type: data.type });
|
|
546
583
|
if (topLevelComponent) {
|
|
547
|
-
children =
|
|
584
|
+
children = React7.createElement(topLevelComponent, convertComponentToProps(data));
|
|
548
585
|
} else {
|
|
549
586
|
if (Object.keys((_a = data.slots) != null ? _a : {}).length > 1 && process.env.NODE_ENV === "development") {
|
|
550
587
|
console.warn(
|
|
551
588
|
`[canvas-dev] All the slots in component '${data.type}' are rendered in no particular order. Use '<UniformSlot name={slotName} />' to reliably render the slots.`
|
|
552
589
|
);
|
|
553
590
|
}
|
|
554
|
-
children = Object.keys(data.slots || {}).map((slotName) => /* @__PURE__ */
|
|
591
|
+
children = Object.keys(data.slots || {}).map((slotName) => /* @__PURE__ */ React7.createElement(UniformSlot, { key: slotName, name: slotName }));
|
|
555
592
|
}
|
|
556
593
|
}
|
|
557
594
|
const renderChildren = typeof children === "function" ? children(convertComponentToProps(data)) : children;
|
|
@@ -560,7 +597,7 @@ function resolveChildren({
|
|
|
560
597
|
|
|
561
598
|
// src/components/UniformPlayground.tsx
|
|
562
599
|
import { EMPTY_COMPOSITION as EMPTY_COMPOSITION3 } from "@uniformdev/canvas";
|
|
563
|
-
import
|
|
600
|
+
import React8, { useMemo as useMemo2 } from "react";
|
|
564
601
|
var UniformPlayground = ({
|
|
565
602
|
resolveRenderer,
|
|
566
603
|
decorators = [],
|
|
@@ -577,7 +614,7 @@ var UniformPlayground = ({
|
|
|
577
614
|
if (!composition) {
|
|
578
615
|
return null;
|
|
579
616
|
}
|
|
580
|
-
let component = /* @__PURE__ */
|
|
617
|
+
let component = /* @__PURE__ */ React8.createElement(ContextualEditingComponentWrapper, { component: composition }, /* @__PURE__ */ React8.createElement(
|
|
581
618
|
UniformComponent,
|
|
582
619
|
{
|
|
583
620
|
data: composition,
|
|
@@ -588,7 +625,7 @@ var UniformPlayground = ({
|
|
|
588
625
|
children
|
|
589
626
|
));
|
|
590
627
|
decorators.forEach((Decorator) => {
|
|
591
|
-
component = /* @__PURE__ */
|
|
628
|
+
component = /* @__PURE__ */ React8.createElement(Decorator, { data: composition }, component);
|
|
592
629
|
});
|
|
593
630
|
return component;
|
|
594
631
|
}, [
|
|
@@ -599,7 +636,7 @@ var UniformPlayground = ({
|
|
|
599
636
|
behaviorTracking,
|
|
600
637
|
contextualEditingDefaultPlaceholder
|
|
601
638
|
]);
|
|
602
|
-
return /* @__PURE__ */
|
|
639
|
+
return /* @__PURE__ */ React8.createElement(
|
|
603
640
|
UniformCompositionContext.Provider,
|
|
604
641
|
{
|
|
605
642
|
value: { data: composition, behaviorTracking, resolveRenderer, isContextualEditing }
|
|
@@ -609,59 +646,64 @@ var UniformPlayground = ({
|
|
|
609
646
|
};
|
|
610
647
|
|
|
611
648
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
649
|
+
import {
|
|
650
|
+
ATTRIBUTE_COMPONENT_ID,
|
|
651
|
+
ATTRIBUTE_PARAMETER_ID,
|
|
652
|
+
ATTRIBUTE_PARAMETER_TYPE
|
|
653
|
+
} from "@uniformdev/canvas";
|
|
612
654
|
import {
|
|
613
655
|
isRichTextValue,
|
|
614
656
|
isRichTextValueConsideredEmpty
|
|
615
657
|
} from "@uniformdev/richtext";
|
|
616
|
-
import
|
|
658
|
+
import React18, { useMemo as useMemo3 } from "react";
|
|
617
659
|
|
|
618
660
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
619
661
|
import { isRichTextNode } from "@uniformdev/richtext";
|
|
620
|
-
import
|
|
662
|
+
import React17 from "react";
|
|
621
663
|
|
|
622
664
|
// src/components/UniformRichText/nodes/HeadingRichTextNode.tsx
|
|
623
|
-
import
|
|
665
|
+
import React9 from "react";
|
|
624
666
|
var HeadingRichTextNode = ({ children, node }) => {
|
|
625
667
|
const { tag } = node;
|
|
626
668
|
const HTag = tag != null ? tag : "h1";
|
|
627
|
-
return /* @__PURE__ */
|
|
669
|
+
return /* @__PURE__ */ React9.createElement(HTag, null, children);
|
|
628
670
|
};
|
|
629
671
|
|
|
630
672
|
// src/components/UniformRichText/nodes/LinebreakRichTextNode.tsx
|
|
631
|
-
import
|
|
673
|
+
import React10 from "react";
|
|
632
674
|
var LinebreakRichTextNode = () => {
|
|
633
|
-
return /* @__PURE__ */
|
|
675
|
+
return /* @__PURE__ */ React10.createElement("br", null);
|
|
634
676
|
};
|
|
635
677
|
|
|
636
678
|
// src/components/UniformRichText/nodes/LinkRichTextNode.tsx
|
|
637
679
|
import { linkParamValueToHref } from "@uniformdev/richtext";
|
|
638
|
-
import
|
|
680
|
+
import React11 from "react";
|
|
639
681
|
var LinkRichTextNode = ({ children, node }) => {
|
|
640
682
|
const { link } = node;
|
|
641
|
-
return /* @__PURE__ */
|
|
683
|
+
return /* @__PURE__ */ React11.createElement("a", { href: linkParamValueToHref(link) }, children);
|
|
642
684
|
};
|
|
643
685
|
|
|
644
686
|
// src/components/UniformRichText/nodes/ListItemRichTextNode.tsx
|
|
645
|
-
import
|
|
687
|
+
import React12 from "react";
|
|
646
688
|
var ListItemRichTextNode = ({ children, node }) => {
|
|
647
689
|
const { value } = node;
|
|
648
|
-
return /* @__PURE__ */
|
|
690
|
+
return /* @__PURE__ */ React12.createElement("li", { value: Number.isFinite(value) && value > 0 ? value : void 0 }, children);
|
|
649
691
|
};
|
|
650
692
|
|
|
651
693
|
// src/components/UniformRichText/nodes/ListRichTextNode.tsx
|
|
652
|
-
import
|
|
694
|
+
import React13 from "react";
|
|
653
695
|
var ListRichTextNode = ({ children, node }) => {
|
|
654
696
|
const { tag, start } = node;
|
|
655
697
|
const ListTag = tag != null ? tag : "ul";
|
|
656
|
-
return /* @__PURE__ */
|
|
698
|
+
return /* @__PURE__ */ React13.createElement(ListTag, { start: Number.isFinite(start) && start > 0 ? start : void 0 }, children);
|
|
657
699
|
};
|
|
658
700
|
|
|
659
701
|
// src/components/UniformRichText/nodes/ParagraphRichTextNode.tsx
|
|
660
702
|
import { isPureDirection, isPureTextAlign } from "@uniformdev/richtext";
|
|
661
|
-
import
|
|
703
|
+
import React14 from "react";
|
|
662
704
|
var ParagraphRichTextNode = ({ children, node }) => {
|
|
663
705
|
const { format, direction } = node;
|
|
664
|
-
return /* @__PURE__ */
|
|
706
|
+
return /* @__PURE__ */ React14.createElement(
|
|
665
707
|
"p",
|
|
666
708
|
{
|
|
667
709
|
dir: isPureDirection(direction) ? direction : void 0,
|
|
@@ -672,18 +714,18 @@ var ParagraphRichTextNode = ({ children, node }) => {
|
|
|
672
714
|
};
|
|
673
715
|
|
|
674
716
|
// src/components/UniformRichText/nodes/TabRichTextNode.tsx
|
|
675
|
-
import
|
|
717
|
+
import React15 from "react";
|
|
676
718
|
var TabRichTextNode = () => {
|
|
677
|
-
return /* @__PURE__ */
|
|
719
|
+
return /* @__PURE__ */ React15.createElement(React15.Fragment, null, " ");
|
|
678
720
|
};
|
|
679
721
|
|
|
680
722
|
// src/components/UniformRichText/nodes/TextRichTextNode.tsx
|
|
681
723
|
import { getRichTextTagsFromTextFormat } from "@uniformdev/richtext";
|
|
682
|
-
import
|
|
724
|
+
import React16 from "react";
|
|
683
725
|
var TextRichTextNode = ({ node }) => {
|
|
684
726
|
const { text, format } = node;
|
|
685
727
|
const tags = getRichTextTagsFromTextFormat(format);
|
|
686
|
-
return /* @__PURE__ */
|
|
728
|
+
return /* @__PURE__ */ React16.createElement(React16.Fragment, null, tags.length > 0 ? tags.reduceRight((children, Tag) => /* @__PURE__ */ React16.createElement(Tag, null, children), text) : text);
|
|
687
729
|
};
|
|
688
730
|
|
|
689
731
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
@@ -698,8 +740,8 @@ function UniformRichTextNode({ node, ...props }) {
|
|
|
698
740
|
if (!NodeRenderer) {
|
|
699
741
|
return null;
|
|
700
742
|
}
|
|
701
|
-
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */
|
|
702
|
-
return /* @__PURE__ */
|
|
743
|
+
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */ React17.createElement(UniformRichTextNode, { ...props, key: i, node: childNode })) : null;
|
|
744
|
+
return /* @__PURE__ */ React17.createElement(NodeRenderer, { node }, children);
|
|
703
745
|
}
|
|
704
746
|
var rendererMap = /* @__PURE__ */ new Map([
|
|
705
747
|
["heading", HeadingRichTextNode],
|
|
@@ -708,12 +750,12 @@ var rendererMap = /* @__PURE__ */ new Map([
|
|
|
708
750
|
["list", ListRichTextNode],
|
|
709
751
|
["listitem", ListItemRichTextNode],
|
|
710
752
|
["paragraph", ParagraphRichTextNode],
|
|
711
|
-
["quote", ({ children }) => /* @__PURE__ */
|
|
753
|
+
["quote", ({ children }) => /* @__PURE__ */ React17.createElement("blockquote", null, children)],
|
|
712
754
|
[
|
|
713
755
|
"code",
|
|
714
|
-
({ children }) => /* @__PURE__ */
|
|
756
|
+
({ children }) => /* @__PURE__ */ React17.createElement("pre", null, /* @__PURE__ */ React17.createElement("code", null, children))
|
|
715
757
|
],
|
|
716
|
-
["root", ({ children }) => /* @__PURE__ */
|
|
758
|
+
["root", ({ children }) => /* @__PURE__ */ React17.createElement(React17.Fragment, null, children)],
|
|
717
759
|
["text", TextRichTextNode],
|
|
718
760
|
["tab", TabRichTextNode]
|
|
719
761
|
]);
|
|
@@ -722,7 +764,7 @@ var resolveRichTextDefaultRenderer = (node) => {
|
|
|
722
764
|
};
|
|
723
765
|
|
|
724
766
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
725
|
-
var UniformRichText =
|
|
767
|
+
var UniformRichText = React18.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", ...props }, ref) {
|
|
726
768
|
const { data: componentData } = useUniformCurrentComponent();
|
|
727
769
|
const parameter = useMemo3(() => {
|
|
728
770
|
var _a;
|
|
@@ -731,14 +773,26 @@ var UniformRichText = React17.forwardRef(function UniformRichText2({ parameterId
|
|
|
731
773
|
const value = useMemo3(() => parameter == null ? void 0 : parameter.value, [parameter]);
|
|
732
774
|
if (!value || !isRichTextValue(value) || isRichTextValueConsideredEmpty(value))
|
|
733
775
|
return null;
|
|
734
|
-
return Tag === null ? /* @__PURE__ */
|
|
776
|
+
return Tag === null ? /* @__PURE__ */ React18.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ React18.createElement(
|
|
777
|
+
Tag,
|
|
778
|
+
{
|
|
779
|
+
ref,
|
|
780
|
+
...props,
|
|
781
|
+
...{
|
|
782
|
+
[ATTRIBUTE_COMPONENT_ID]: componentData == null ? void 0 : componentData._id,
|
|
783
|
+
[ATTRIBUTE_PARAMETER_ID]: parameterId,
|
|
784
|
+
[ATTRIBUTE_PARAMETER_TYPE]: "richText"
|
|
785
|
+
}
|
|
786
|
+
},
|
|
787
|
+
/* @__PURE__ */ React18.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer })
|
|
788
|
+
);
|
|
735
789
|
});
|
|
736
790
|
|
|
737
791
|
// src/components/UniformText.tsx
|
|
738
|
-
import
|
|
792
|
+
import React20, { useState as useState2 } from "react";
|
|
739
793
|
|
|
740
794
|
// src/components/PureUniformText.tsx
|
|
741
|
-
import
|
|
795
|
+
import React19 from "react";
|
|
742
796
|
var PureUniformText = ({
|
|
743
797
|
as: Tag = "span",
|
|
744
798
|
parameterId,
|
|
@@ -757,10 +811,10 @@ var PureUniformText = ({
|
|
|
757
811
|
return null;
|
|
758
812
|
}
|
|
759
813
|
if (!isContextualEditing) {
|
|
760
|
-
return /* @__PURE__ */
|
|
814
|
+
return /* @__PURE__ */ React19.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
|
|
761
815
|
}
|
|
762
816
|
const computedPlaceholder = typeof placeholder === "function" ? placeholder({ id: parameterId }) : placeholder;
|
|
763
|
-
return /* @__PURE__ */
|
|
817
|
+
return /* @__PURE__ */ React19.createElement(
|
|
764
818
|
Tag,
|
|
765
819
|
{
|
|
766
820
|
...props,
|
|
@@ -798,7 +852,7 @@ var UniformText = ({
|
|
|
798
852
|
}
|
|
799
853
|
const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
|
|
800
854
|
const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
|
|
801
|
-
return /* @__PURE__ */
|
|
855
|
+
return /* @__PURE__ */ React20.createElement(
|
|
802
856
|
PureUniformText,
|
|
803
857
|
{
|
|
804
858
|
...props,
|
|
@@ -911,11 +965,14 @@ var useUniformContextualEditingState = ({
|
|
|
911
965
|
return () => {
|
|
912
966
|
unsubscribe();
|
|
913
967
|
};
|
|
914
|
-
}, [global, channel, componentData == null ? void 0 : componentData._id]);
|
|
915
|
-
return
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
968
|
+
}, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference]);
|
|
969
|
+
return useMemo4(
|
|
970
|
+
() => ({
|
|
971
|
+
isContextualEditing,
|
|
972
|
+
selectedComponentReference
|
|
973
|
+
}),
|
|
974
|
+
[isContextualEditing, selectedComponentReference]
|
|
975
|
+
);
|
|
919
976
|
};
|
|
920
977
|
export {
|
|
921
978
|
DefaultNotImplementedComponent,
|
|
@@ -930,6 +987,7 @@ export {
|
|
|
930
987
|
UniformText,
|
|
931
988
|
componentStore,
|
|
932
989
|
componentStoreResolver,
|
|
990
|
+
convertComponentToProps,
|
|
933
991
|
createComponentStore,
|
|
934
992
|
createComponentStoreResolver,
|
|
935
993
|
createUniformApiEnhancer,
|