@uniformdev/canvas-react 19.173.1-alpha.17 → 19.173.2-alpha.210
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 +145 -125
- package/dist/index.d.ts +145 -125
- package/dist/index.esm.js +53 -36
- package/dist/index.js +63 -43
- package/dist/index.mjs +53 -36
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -110,64 +110,64 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
110
110
|
connectedData?: {
|
|
111
111
|
pointer: string;
|
|
112
112
|
syntax: "jptr";
|
|
113
|
-
failureAction?: "
|
|
114
|
-
failureLogLevel?: "
|
|
115
|
-
failureDefault?: string
|
|
116
|
-
}
|
|
113
|
+
failureAction?: "t" | "p" | "c" | "a";
|
|
114
|
+
failureLogLevel?: "e" | "w" | "i";
|
|
115
|
+
failureDefault?: string;
|
|
116
|
+
};
|
|
117
117
|
locales?: {
|
|
118
118
|
[key: string]: unknown;
|
|
119
|
-
}
|
|
119
|
+
};
|
|
120
120
|
conditions?: {
|
|
121
121
|
when: {
|
|
122
|
-
op?: "&" | "|"
|
|
123
|
-
clauses: (
|
|
122
|
+
op?: "&" | "|";
|
|
123
|
+
clauses: ({
|
|
124
124
|
rule: string;
|
|
125
|
-
source?: string
|
|
125
|
+
source?: string;
|
|
126
126
|
op: string;
|
|
127
127
|
value: string | string[];
|
|
128
|
-
})[];
|
|
128
|
+
} | any)[];
|
|
129
129
|
};
|
|
130
130
|
value: unknown;
|
|
131
131
|
id: number;
|
|
132
|
-
}[]
|
|
132
|
+
}[];
|
|
133
133
|
localesConditions?: {
|
|
134
134
|
[key: string]: {
|
|
135
135
|
when: {
|
|
136
|
-
op?: "&" | "|"
|
|
137
|
-
clauses: (
|
|
136
|
+
op?: "&" | "|";
|
|
137
|
+
clauses: ({
|
|
138
138
|
rule: string;
|
|
139
|
-
source?: string
|
|
139
|
+
source?: string;
|
|
140
140
|
op: string;
|
|
141
141
|
value: string | string[];
|
|
142
|
-
})[];
|
|
142
|
+
} | any)[];
|
|
143
143
|
};
|
|
144
144
|
value: unknown;
|
|
145
145
|
id: number;
|
|
146
146
|
}[];
|
|
147
|
-
}
|
|
147
|
+
};
|
|
148
148
|
};
|
|
149
|
-
}
|
|
150
|
-
variant?: string
|
|
149
|
+
};
|
|
150
|
+
variant?: string;
|
|
151
151
|
projectMapNodes?: {
|
|
152
152
|
id: string;
|
|
153
153
|
path: string;
|
|
154
154
|
projectMapId: string;
|
|
155
155
|
data?: {
|
|
156
|
-
isSearchHit?: boolean
|
|
156
|
+
isSearchHit?: boolean;
|
|
157
157
|
queryStrings?: {
|
|
158
158
|
name: string;
|
|
159
|
-
value?: string
|
|
160
|
-
helpText?: string
|
|
161
|
-
}[]
|
|
162
|
-
previewValue?: string
|
|
163
|
-
}
|
|
159
|
+
value?: string;
|
|
160
|
+
helpText?: string;
|
|
161
|
+
}[];
|
|
162
|
+
previewValue?: string;
|
|
163
|
+
};
|
|
164
164
|
locales?: {
|
|
165
165
|
[key: string]: {
|
|
166
166
|
path: string;
|
|
167
167
|
inherited: boolean;
|
|
168
168
|
};
|
|
169
|
-
}
|
|
170
|
-
}[]
|
|
169
|
+
};
|
|
170
|
+
}[];
|
|
171
171
|
slots?: {
|
|
172
172
|
[key: string]: {
|
|
173
173
|
type: string;
|
|
@@ -178,72 +178,74 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
178
178
|
connectedData?: {
|
|
179
179
|
pointer: string;
|
|
180
180
|
syntax: "jptr";
|
|
181
|
-
failureAction?: "
|
|
182
|
-
failureLogLevel?: "
|
|
183
|
-
failureDefault?: string
|
|
184
|
-
}
|
|
181
|
+
failureAction?: "t" | "p" | "c" | "a";
|
|
182
|
+
failureLogLevel?: "e" | "w" | "i";
|
|
183
|
+
failureDefault?: string;
|
|
184
|
+
};
|
|
185
185
|
locales?: {
|
|
186
186
|
[key: string]: unknown;
|
|
187
|
-
}
|
|
187
|
+
};
|
|
188
188
|
conditions?: {
|
|
189
189
|
when: {
|
|
190
|
-
op?: "&" | "|"
|
|
191
|
-
clauses: (
|
|
190
|
+
op?: "&" | "|";
|
|
191
|
+
clauses: ({
|
|
192
192
|
rule: string;
|
|
193
|
-
source?: string
|
|
193
|
+
source?: string;
|
|
194
194
|
op: string;
|
|
195
195
|
value: string | string[];
|
|
196
|
-
})[];
|
|
196
|
+
} | any)[];
|
|
197
197
|
};
|
|
198
198
|
value: unknown;
|
|
199
199
|
id: number;
|
|
200
|
-
}[]
|
|
200
|
+
}[];
|
|
201
201
|
localesConditions?: {
|
|
202
202
|
[key: string]: {
|
|
203
203
|
when: {
|
|
204
|
-
op?: "&" | "|"
|
|
205
|
-
clauses: (
|
|
204
|
+
op?: "&" | "|";
|
|
205
|
+
clauses: ({
|
|
206
206
|
rule: string;
|
|
207
|
-
source?: string
|
|
207
|
+
source?: string;
|
|
208
208
|
op: string;
|
|
209
209
|
value: string | string[];
|
|
210
|
-
})[];
|
|
210
|
+
} | any)[];
|
|
211
211
|
};
|
|
212
212
|
value: unknown;
|
|
213
213
|
id: number;
|
|
214
214
|
}[];
|
|
215
|
-
}
|
|
215
|
+
};
|
|
216
216
|
};
|
|
217
|
-
}
|
|
218
|
-
variant?: string
|
|
217
|
+
};
|
|
218
|
+
variant?: string;
|
|
219
219
|
slots?: {
|
|
220
220
|
[key: string]: any[];
|
|
221
|
-
}
|
|
222
|
-
_id?: string
|
|
223
|
-
_pattern?: string
|
|
221
|
+
};
|
|
222
|
+
_id?: string;
|
|
223
|
+
_pattern?: string;
|
|
224
224
|
_dataResources?: {
|
|
225
225
|
[key: string]: {
|
|
226
226
|
type: string;
|
|
227
|
-
isPatternParameter?: boolean
|
|
228
|
-
ignorePatternParameterDefault?: boolean
|
|
229
|
-
optionalPatternParameter?: boolean
|
|
227
|
+
isPatternParameter?: boolean;
|
|
228
|
+
ignorePatternParameterDefault?: boolean;
|
|
229
|
+
optionalPatternParameter?: boolean;
|
|
230
|
+
dataSourceVariant?: "unpublished";
|
|
230
231
|
variables?: {
|
|
231
232
|
[key: string]: string;
|
|
232
|
-
}
|
|
233
|
+
};
|
|
233
234
|
};
|
|
234
|
-
}
|
|
235
|
+
};
|
|
235
236
|
_patternDataResources?: {
|
|
236
237
|
[key: string]: {
|
|
237
238
|
type: string;
|
|
238
|
-
isPatternParameter?: boolean
|
|
239
|
-
ignorePatternParameterDefault?: boolean
|
|
240
|
-
optionalPatternParameter?: boolean
|
|
239
|
+
isPatternParameter?: boolean;
|
|
240
|
+
ignorePatternParameterDefault?: boolean;
|
|
241
|
+
optionalPatternParameter?: boolean;
|
|
242
|
+
dataSourceVariant?: "unpublished";
|
|
241
243
|
variables?: {
|
|
242
244
|
[key: string]: string;
|
|
243
|
-
}
|
|
245
|
+
};
|
|
244
246
|
};
|
|
245
|
-
}
|
|
246
|
-
_patternError?: "NOTFOUND" | "CYCLIC"
|
|
247
|
+
};
|
|
248
|
+
_patternError?: "NOTFOUND" | "CYCLIC";
|
|
247
249
|
_overrides?: {
|
|
248
250
|
[key: string]: {
|
|
249
251
|
parameters?: {
|
|
@@ -253,90 +255,92 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
253
255
|
connectedData?: {
|
|
254
256
|
pointer: string;
|
|
255
257
|
syntax: "jptr";
|
|
256
|
-
failureAction?: "
|
|
257
|
-
failureLogLevel?: "
|
|
258
|
-
failureDefault?: string
|
|
259
|
-
}
|
|
258
|
+
failureAction?: "t" | "p" | "c" | "a";
|
|
259
|
+
failureLogLevel?: "e" | "w" | "i";
|
|
260
|
+
failureDefault?: string;
|
|
261
|
+
};
|
|
260
262
|
locales?: {
|
|
261
263
|
[key: string]: unknown;
|
|
262
|
-
}
|
|
264
|
+
};
|
|
263
265
|
conditions?: {
|
|
264
266
|
when: {
|
|
265
|
-
op?: "&" | "|"
|
|
266
|
-
clauses: (
|
|
267
|
+
op?: "&" | "|";
|
|
268
|
+
clauses: ({
|
|
267
269
|
rule: string;
|
|
268
|
-
source?: string
|
|
270
|
+
source?: string;
|
|
269
271
|
op: string;
|
|
270
272
|
value: string | string[];
|
|
271
|
-
})[];
|
|
273
|
+
} | any)[];
|
|
272
274
|
};
|
|
273
275
|
value: unknown;
|
|
274
276
|
id: number;
|
|
275
|
-
}[]
|
|
277
|
+
}[];
|
|
276
278
|
localesConditions?: {
|
|
277
279
|
[key: string]: {
|
|
278
280
|
when: {
|
|
279
|
-
op?: "&" | "|"
|
|
280
|
-
clauses: (
|
|
281
|
+
op?: "&" | "|";
|
|
282
|
+
clauses: ({
|
|
281
283
|
rule: string;
|
|
282
|
-
source?: string
|
|
284
|
+
source?: string;
|
|
283
285
|
op: string;
|
|
284
286
|
value: string | string[];
|
|
285
|
-
})[];
|
|
287
|
+
} | any)[];
|
|
286
288
|
};
|
|
287
289
|
value: unknown;
|
|
288
290
|
id: number;
|
|
289
291
|
}[];
|
|
290
|
-
}
|
|
292
|
+
};
|
|
291
293
|
};
|
|
292
|
-
}
|
|
294
|
+
};
|
|
293
295
|
slots?: {
|
|
294
296
|
[key: string]: any[];
|
|
295
|
-
}
|
|
296
|
-
variant?: string
|
|
297
|
+
};
|
|
298
|
+
variant?: string;
|
|
297
299
|
};
|
|
298
|
-
}
|
|
300
|
+
};
|
|
299
301
|
_overridability?: {
|
|
300
302
|
parameters?: {
|
|
301
303
|
[key: string]: "yes" | "no";
|
|
302
|
-
}
|
|
303
|
-
variants?: boolean
|
|
304
|
-
hideLockedParameters?: boolean
|
|
305
|
-
}
|
|
306
|
-
_locales?: string[]
|
|
304
|
+
};
|
|
305
|
+
variants?: boolean;
|
|
306
|
+
hideLockedParameters?: boolean;
|
|
307
|
+
};
|
|
308
|
+
_locales?: string[];
|
|
307
309
|
}[];
|
|
308
|
-
}
|
|
310
|
+
};
|
|
309
311
|
_id: string;
|
|
310
|
-
_slug?: string | null
|
|
312
|
+
_slug?: string | null;
|
|
311
313
|
_name: string;
|
|
312
|
-
_author?: string
|
|
313
|
-
_authorSubject?: string
|
|
314
|
-
_creator?: string
|
|
315
|
-
_creatorSubject?: string
|
|
316
|
-
_pattern?: string
|
|
314
|
+
_author?: string;
|
|
315
|
+
_authorSubject?: string;
|
|
316
|
+
_creator?: string;
|
|
317
|
+
_creatorSubject?: string;
|
|
318
|
+
_pattern?: string;
|
|
317
319
|
_patternDataResources?: {
|
|
318
320
|
[key: string]: {
|
|
319
321
|
type: string;
|
|
320
|
-
isPatternParameter?: boolean
|
|
321
|
-
ignorePatternParameterDefault?: boolean
|
|
322
|
-
optionalPatternParameter?: boolean
|
|
322
|
+
isPatternParameter?: boolean;
|
|
323
|
+
ignorePatternParameterDefault?: boolean;
|
|
324
|
+
optionalPatternParameter?: boolean;
|
|
325
|
+
dataSourceVariant?: "unpublished";
|
|
323
326
|
variables?: {
|
|
324
327
|
[key: string]: string;
|
|
325
|
-
}
|
|
328
|
+
};
|
|
326
329
|
};
|
|
327
|
-
}
|
|
330
|
+
};
|
|
328
331
|
_dataResources?: {
|
|
329
332
|
[key: string]: {
|
|
330
333
|
type: string;
|
|
331
|
-
isPatternParameter?: boolean
|
|
332
|
-
ignorePatternParameterDefault?: boolean
|
|
333
|
-
optionalPatternParameter?: boolean
|
|
334
|
+
isPatternParameter?: boolean;
|
|
335
|
+
ignorePatternParameterDefault?: boolean;
|
|
336
|
+
optionalPatternParameter?: boolean;
|
|
337
|
+
dataSourceVariant?: "unpublished";
|
|
334
338
|
variables?: {
|
|
335
339
|
[key: string]: string;
|
|
336
|
-
}
|
|
340
|
+
};
|
|
337
341
|
};
|
|
338
|
-
}
|
|
339
|
-
_patternError?: "NOTFOUND" | "CYCLIC"
|
|
342
|
+
};
|
|
343
|
+
_patternError?: "NOTFOUND" | "CYCLIC";
|
|
340
344
|
_overrides?: {
|
|
341
345
|
[key: string]: {
|
|
342
346
|
parameters?: {
|
|
@@ -346,57 +350,57 @@ declare const useUniformContextualEditing: ({ initialCompositionValue, enhance,
|
|
|
346
350
|
connectedData?: {
|
|
347
351
|
pointer: string;
|
|
348
352
|
syntax: "jptr";
|
|
349
|
-
failureAction?: "
|
|
350
|
-
failureLogLevel?: "
|
|
351
|
-
failureDefault?: string
|
|
352
|
-
}
|
|
353
|
+
failureAction?: "t" | "p" | "c" | "a";
|
|
354
|
+
failureLogLevel?: "e" | "w" | "i";
|
|
355
|
+
failureDefault?: string;
|
|
356
|
+
};
|
|
353
357
|
locales?: {
|
|
354
358
|
[key: string]: unknown;
|
|
355
|
-
}
|
|
359
|
+
};
|
|
356
360
|
conditions?: {
|
|
357
361
|
when: {
|
|
358
|
-
op?: "&" | "|"
|
|
359
|
-
clauses: (
|
|
362
|
+
op?: "&" | "|";
|
|
363
|
+
clauses: ({
|
|
360
364
|
rule: string;
|
|
361
|
-
source?: string
|
|
365
|
+
source?: string;
|
|
362
366
|
op: string;
|
|
363
367
|
value: string | string[];
|
|
364
|
-
})[];
|
|
368
|
+
} | any)[];
|
|
365
369
|
};
|
|
366
370
|
value: unknown;
|
|
367
371
|
id: number;
|
|
368
|
-
}[]
|
|
372
|
+
}[];
|
|
369
373
|
localesConditions?: {
|
|
370
374
|
[key: string]: {
|
|
371
375
|
when: {
|
|
372
|
-
op?: "&" | "|"
|
|
373
|
-
clauses: (
|
|
376
|
+
op?: "&" | "|";
|
|
377
|
+
clauses: ({
|
|
374
378
|
rule: string;
|
|
375
|
-
source?: string
|
|
379
|
+
source?: string;
|
|
376
380
|
op: string;
|
|
377
381
|
value: string | string[];
|
|
378
|
-
})[];
|
|
382
|
+
} | any)[];
|
|
379
383
|
};
|
|
380
384
|
value: unknown;
|
|
381
385
|
id: number;
|
|
382
386
|
}[];
|
|
383
|
-
}
|
|
387
|
+
};
|
|
384
388
|
};
|
|
385
|
-
}
|
|
389
|
+
};
|
|
386
390
|
slots?: {
|
|
387
391
|
[key: string]: any[];
|
|
388
|
-
}
|
|
389
|
-
variant?: string
|
|
392
|
+
};
|
|
393
|
+
variant?: string;
|
|
390
394
|
};
|
|
391
|
-
}
|
|
395
|
+
};
|
|
392
396
|
_overridability?: {
|
|
393
397
|
parameters?: {
|
|
394
398
|
[key: string]: "yes" | "no";
|
|
395
|
-
}
|
|
396
|
-
variants?: boolean
|
|
397
|
-
hideLockedParameters?: boolean
|
|
398
|
-
}
|
|
399
|
-
_locales?: string[]
|
|
399
|
+
};
|
|
400
|
+
variants?: boolean;
|
|
401
|
+
hideLockedParameters?: boolean;
|
|
402
|
+
};
|
|
403
|
+
_locales?: string[];
|
|
400
404
|
} | undefined;
|
|
401
405
|
isContextualEditing: boolean;
|
|
402
406
|
};
|
|
@@ -469,6 +473,14 @@ type UniformRichTextProps = {
|
|
|
469
473
|
* for rendering a rich text node
|
|
470
474
|
*/
|
|
471
475
|
resolveRichTextRenderer?: RenderRichTextComponentResolver;
|
|
476
|
+
/**
|
|
477
|
+
* Sets the value to show in Canvas editor when the parameter value is empty.
|
|
478
|
+
* Can be a static string, or a function to generate the placeholder out of parameter info.
|
|
479
|
+
* @default undefined
|
|
480
|
+
*/
|
|
481
|
+
placeholder?: string | ((parameter: {
|
|
482
|
+
id: string;
|
|
483
|
+
}) => string | undefined);
|
|
472
484
|
} & Omit<React$1.HTMLAttributes<HTMLDivElement>, 'children'>;
|
|
473
485
|
/**
|
|
474
486
|
* Adds rendering support for Uniform Rich Text parameters
|
|
@@ -478,14 +490,22 @@ declare const UniformRichText: React$1.ForwardRefExoticComponent<{
|
|
|
478
490
|
* The name of the HTML tag to render.
|
|
479
491
|
* @default "div"
|
|
480
492
|
*/
|
|
481
|
-
as?: React$1.ElementType
|
|
493
|
+
as?: React$1.ElementType;
|
|
482
494
|
/** The ID of the parameter. */
|
|
483
495
|
parameterId: string;
|
|
484
496
|
/**
|
|
485
497
|
* A function which can provide a custom react component
|
|
486
498
|
* for rendering a rich text node
|
|
487
499
|
*/
|
|
488
|
-
resolveRichTextRenderer?: RenderRichTextComponentResolver
|
|
500
|
+
resolveRichTextRenderer?: RenderRichTextComponentResolver;
|
|
501
|
+
/**
|
|
502
|
+
* Sets the value to show in Canvas editor when the parameter value is empty.
|
|
503
|
+
* Can be a static string, or a function to generate the placeholder out of parameter info.
|
|
504
|
+
* @default undefined
|
|
505
|
+
*/
|
|
506
|
+
placeholder?: string | ((parameter: {
|
|
507
|
+
id: string;
|
|
508
|
+
}) => string | undefined);
|
|
489
509
|
} & Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & React$1.RefAttributes<unknown>>;
|
|
490
510
|
|
|
491
511
|
type UniformRichTextNodeProps = {
|
|
@@ -593,7 +613,7 @@ declare const useUniformContextualEditingState: ({ global, }?: UseUniformContext
|
|
|
593
613
|
declare const componentStore: ComponentStore;
|
|
594
614
|
declare const registerUniformComponent: ({ type, variantId, component, }: {
|
|
595
615
|
type: string;
|
|
596
|
-
variantId?: string
|
|
616
|
+
variantId?: string;
|
|
597
617
|
component: React.ComponentType<ComponentProps<any>>;
|
|
598
618
|
}) => void;
|
|
599
619
|
declare const componentStoreResolver: RenderComponentResolver;
|
package/dist/index.esm.js
CHANGED
|
@@ -695,15 +695,12 @@ import {
|
|
|
695
695
|
ATTRIBUTE_PARAMETER_ID,
|
|
696
696
|
ATTRIBUTE_PARAMETER_TYPE
|
|
697
697
|
} from "@uniformdev/canvas";
|
|
698
|
-
import {
|
|
699
|
-
|
|
700
|
-
isRichTextValueConsideredEmpty
|
|
701
|
-
} from "@uniformdev/richtext";
|
|
702
|
-
import React18, { useMemo as useMemo5 } from "react";
|
|
698
|
+
import { isRichTextValue, isRichTextValueConsideredEmpty } from "@uniformdev/richtext";
|
|
699
|
+
import React19 from "react";
|
|
703
700
|
|
|
704
701
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
705
702
|
import { isRichTextNode } from "@uniformdev/richtext";
|
|
706
|
-
import
|
|
703
|
+
import React18 from "react";
|
|
707
704
|
|
|
708
705
|
// src/components/UniformRichText/nodes/HeadingRichTextNode.tsx
|
|
709
706
|
import React9 from "react";
|
|
@@ -757,19 +754,28 @@ var ParagraphRichTextNode = ({ children, node }) => {
|
|
|
757
754
|
);
|
|
758
755
|
};
|
|
759
756
|
|
|
760
|
-
// src/components/UniformRichText/nodes/
|
|
757
|
+
// src/components/UniformRichText/nodes/TableCellRichTextNode.tsx
|
|
758
|
+
import { getRichTextTagFromTableCellHeaderState } from "@uniformdev/richtext";
|
|
761
759
|
import React15 from "react";
|
|
760
|
+
var TableCellRichTextNode = ({ children, node }) => {
|
|
761
|
+
const { headerState } = node;
|
|
762
|
+
const TableCellTag = getRichTextTagFromTableCellHeaderState(headerState);
|
|
763
|
+
return /* @__PURE__ */ React15.createElement(TableCellTag, null, children);
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
// src/components/UniformRichText/nodes/TabRichTextNode.tsx
|
|
767
|
+
import React16 from "react";
|
|
762
768
|
var TabRichTextNode = () => {
|
|
763
|
-
return /* @__PURE__ */
|
|
769
|
+
return /* @__PURE__ */ React16.createElement(React16.Fragment, null, " ");
|
|
764
770
|
};
|
|
765
771
|
|
|
766
772
|
// src/components/UniformRichText/nodes/TextRichTextNode.tsx
|
|
767
773
|
import { getRichTextTagsFromTextFormat } from "@uniformdev/richtext";
|
|
768
|
-
import
|
|
774
|
+
import React17 from "react";
|
|
769
775
|
var TextRichTextNode = ({ node }) => {
|
|
770
776
|
const { text, format } = node;
|
|
771
777
|
const tags = getRichTextTagsFromTextFormat(format);
|
|
772
|
-
return /* @__PURE__ */
|
|
778
|
+
return /* @__PURE__ */ React17.createElement(React17.Fragment, null, tags.length > 0 ? tags.reduceRight((children, Tag) => /* @__PURE__ */ React17.createElement(Tag, null, children), text) : text);
|
|
773
779
|
};
|
|
774
780
|
|
|
775
781
|
// src/components/UniformRichText/UniformRichTextNode.tsx
|
|
@@ -783,8 +789,8 @@ function UniformRichTextNode({ node, ...props }) {
|
|
|
783
789
|
if (!NodeRenderer) {
|
|
784
790
|
return null;
|
|
785
791
|
}
|
|
786
|
-
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */
|
|
787
|
-
return /* @__PURE__ */
|
|
792
|
+
const children = node.children ? node.children.map((childNode, i) => /* @__PURE__ */ React18.createElement(UniformRichTextNode, { ...props, key: i, node: childNode })) : null;
|
|
793
|
+
return /* @__PURE__ */ React18.createElement(NodeRenderer, { node }, children);
|
|
788
794
|
}
|
|
789
795
|
var rendererMap = /* @__PURE__ */ new Map([
|
|
790
796
|
["heading", HeadingRichTextNode],
|
|
@@ -793,48 +799,59 @@ var rendererMap = /* @__PURE__ */ new Map([
|
|
|
793
799
|
["list", ListRichTextNode],
|
|
794
800
|
["listitem", ListItemRichTextNode],
|
|
795
801
|
["paragraph", ParagraphRichTextNode],
|
|
796
|
-
["quote", ({ children }) => /* @__PURE__ */
|
|
802
|
+
["quote", ({ children }) => /* @__PURE__ */ React18.createElement("blockquote", null, children)],
|
|
797
803
|
[
|
|
798
804
|
"code",
|
|
799
|
-
({ children }) => /* @__PURE__ */
|
|
805
|
+
({ children }) => /* @__PURE__ */ React18.createElement("pre", null, /* @__PURE__ */ React18.createElement("code", null, children))
|
|
800
806
|
],
|
|
801
|
-
["root", ({ children }) => /* @__PURE__ */
|
|
807
|
+
["root", ({ children }) => /* @__PURE__ */ React18.createElement(React18.Fragment, null, children)],
|
|
802
808
|
["text", TextRichTextNode],
|
|
803
|
-
["tab", TabRichTextNode]
|
|
809
|
+
["tab", TabRichTextNode],
|
|
810
|
+
[
|
|
811
|
+
"table",
|
|
812
|
+
({ children }) => /* @__PURE__ */ React18.createElement("table", null, /* @__PURE__ */ React18.createElement("tbody", null, children))
|
|
813
|
+
],
|
|
814
|
+
["tablerow", ({ children }) => /* @__PURE__ */ React18.createElement("tr", null, children)],
|
|
815
|
+
["tablecell", TableCellRichTextNode]
|
|
804
816
|
]);
|
|
805
817
|
var resolveRichTextDefaultRenderer = (node) => {
|
|
806
818
|
return rendererMap.get(node.type);
|
|
807
819
|
};
|
|
808
820
|
|
|
809
821
|
// src/components/UniformRichText/UniformRichText.tsx
|
|
810
|
-
var UniformRichText =
|
|
811
|
-
|
|
812
|
-
const
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
822
|
+
var UniformRichText = React19.forwardRef(function UniformRichText2({ parameterId, resolveRichTextRenderer, as: Tag = "div", placeholder, ...props }, ref) {
|
|
823
|
+
var _a;
|
|
824
|
+
const { data: componentData, contextualEditingDefaultPlaceholder } = useUniformCurrentComponent();
|
|
825
|
+
const { isContextualEditing } = useUniformCurrentComposition();
|
|
826
|
+
const parameter = (_a = componentData == null ? void 0 : componentData.parameters) == null ? void 0 : _a[parameterId];
|
|
827
|
+
if (!parameter) {
|
|
828
|
+
return null;
|
|
829
|
+
}
|
|
830
|
+
const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
|
|
831
|
+
const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
|
|
832
|
+
const value = parameter.value;
|
|
833
|
+
if (!value || !isRichTextValue(value)) return null;
|
|
834
|
+
if (!isContextualEditing && isRichTextValueConsideredEmpty(value)) return null;
|
|
835
|
+
return Tag === null ? /* @__PURE__ */ React19.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer }) : /* @__PURE__ */ React19.createElement(
|
|
819
836
|
Tag,
|
|
820
837
|
{
|
|
821
838
|
ref,
|
|
822
839
|
...props,
|
|
823
|
-
...{
|
|
840
|
+
...isContextualEditing ? {
|
|
824
841
|
[ATTRIBUTE_COMPONENT_ID]: componentData == null ? void 0 : componentData._id,
|
|
825
842
|
[ATTRIBUTE_PARAMETER_ID]: parameterId,
|
|
826
843
|
[ATTRIBUTE_PARAMETER_TYPE]: "richText"
|
|
827
|
-
}
|
|
844
|
+
} : {}
|
|
828
845
|
},
|
|
829
|
-
/* @__PURE__ */
|
|
846
|
+
isRichTextValueConsideredEmpty(value) ? /* @__PURE__ */ React19.createElement("p", null, /* @__PURE__ */ React19.createElement("i", null, computedPlaceholder)) : /* @__PURE__ */ React19.createElement(UniformRichTextNode, { node: value.root, resolveRichTextRenderer })
|
|
830
847
|
);
|
|
831
848
|
});
|
|
832
849
|
|
|
833
850
|
// src/components/UniformText.tsx
|
|
834
|
-
import
|
|
851
|
+
import React21, { useState as useState2 } from "react";
|
|
835
852
|
|
|
836
853
|
// src/components/PureUniformText.tsx
|
|
837
|
-
import
|
|
854
|
+
import React20 from "react";
|
|
838
855
|
var PureUniformText = ({
|
|
839
856
|
as: Tag = "span",
|
|
840
857
|
parameterId,
|
|
@@ -853,10 +870,10 @@ var PureUniformText = ({
|
|
|
853
870
|
return null;
|
|
854
871
|
}
|
|
855
872
|
if (!isContextualEditing) {
|
|
856
|
-
return /* @__PURE__ */
|
|
873
|
+
return /* @__PURE__ */ React20.createElement(Tag, { style: isMultiline ? { whiteSpace: "pre-wrap" } : {}, ...props }, render(value));
|
|
857
874
|
}
|
|
858
875
|
const computedPlaceholder = typeof placeholder === "function" ? placeholder({ id: parameterId }) : placeholder;
|
|
859
|
-
return /* @__PURE__ */
|
|
876
|
+
return /* @__PURE__ */ React20.createElement(
|
|
860
877
|
Tag,
|
|
861
878
|
{
|
|
862
879
|
...props,
|
|
@@ -894,7 +911,7 @@ var UniformText = ({
|
|
|
894
911
|
}
|
|
895
912
|
const placeholderProp = placeholder != null ? placeholder : contextualEditingDefaultPlaceholder;
|
|
896
913
|
const computedPlaceholder = typeof placeholderProp === "function" ? placeholderProp({ id: parameterId }) : placeholderProp;
|
|
897
|
-
return /* @__PURE__ */
|
|
914
|
+
return /* @__PURE__ */ React21.createElement(
|
|
898
915
|
PureUniformText,
|
|
899
916
|
{
|
|
900
917
|
...props,
|
|
@@ -972,7 +989,7 @@ import {
|
|
|
972
989
|
createCanvasChannel as createCanvasChannel2,
|
|
973
990
|
isUpdateContextualEditingStateInternalMessage
|
|
974
991
|
} from "@uniformdev/canvas";
|
|
975
|
-
import { useEffect as useEffect3, useMemo as
|
|
992
|
+
import { useEffect as useEffect3, useMemo as useMemo5, useState as useState3 } from "react";
|
|
976
993
|
var useUniformContextualEditingState = ({
|
|
977
994
|
global = false
|
|
978
995
|
} = {}) => {
|
|
@@ -982,7 +999,7 @@ var useUniformContextualEditingState = ({
|
|
|
982
999
|
const [previewMode, setPreviewMode] = useState3(
|
|
983
1000
|
isContextualEditing ? "editor" : void 0
|
|
984
1001
|
);
|
|
985
|
-
const channel =
|
|
1002
|
+
const channel = useMemo5(() => {
|
|
986
1003
|
if (!isContextualEditing) {
|
|
987
1004
|
return;
|
|
988
1005
|
}
|
|
@@ -1016,7 +1033,7 @@ var useUniformContextualEditingState = ({
|
|
|
1016
1033
|
unsubscribe();
|
|
1017
1034
|
};
|
|
1018
1035
|
}, [global, channel, componentData == null ? void 0 : componentData._id, setSelectedComponentReference, setPreviewMode]);
|
|
1019
|
-
return
|
|
1036
|
+
return useMemo5(
|
|
1020
1037
|
() => ({
|
|
1021
1038
|
isContextualEditing,
|
|
1022
1039
|
selectedComponentReference,
|