@puckeditor/core 0.23.0 → 0.24.0-canary.03e660bb
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/LICENSE +21 -0
- package/dist/{Editor-44C53YAG.mjs → Editor-7KNCA6HK.mjs} +9 -9
- package/dist/{Render-DQXAYUBI.mjs → Render-H3USS5FU.mjs} +2 -2
- package/dist/{actions-DA1J5F56.d.mts → actions-BEt6vA0O.d.mts} +78 -20
- package/dist/{actions-DA1J5F56.d.ts → actions-BEt6vA0O.d.ts} +78 -20
- package/dist/{chunk-YQWFSBOU.mjs → chunk-3GJJSXCL.mjs} +138 -50
- package/dist/{chunk-55V3NZVF.mjs → chunk-DQGTW26I.mjs} +1678 -1064
- package/dist/{chunk-NJTGWYYH.mjs → chunk-EPCBCOJF.mjs} +1 -1
- package/dist/{chunk-4P4VZS4P.mjs → chunk-I4C7LRQ7.mjs} +1 -1
- package/dist/{chunk-GNR2HNTB.mjs → chunk-J6CJWYPQ.mjs} +8 -8
- package/dist/{chunk-WF6I3XOL.mjs → chunk-NZHU34KT.mjs} +4 -4
- package/dist/{chunk-Y2EFNT5P.mjs → chunk-OT7NKYY4.mjs} +2 -2
- package/dist/{chunk-K2LNXU54.mjs → chunk-SBDTCWI2.mjs} +109 -76
- package/dist/{chunk-67Y7M4OJ.mjs → chunk-VCJQYLHO.mjs} +1 -1
- package/dist/{chunk-ZRAERXB4.mjs → chunk-XMN55NON.mjs} +3 -2
- package/dist/{chunk-2CNEFIQP.mjs → chunk-ZOLLDKZQ.mjs} +4 -1
- package/dist/{full-7ZJV44EE.mjs → full-FCIISNOL.mjs} +7 -7
- package/dist/{index-DIZKfHDN.d.ts → index-BjizoAHc.d.ts} +1 -1
- package/dist/{index-n9eR_SWx.d.mts → index-Cw7CQGG8.d.mts} +1 -1
- package/dist/index.css +217 -51
- package/dist/index.d.mts +50 -9
- package/dist/index.d.ts +50 -9
- package/dist/index.js +2227 -1485
- package/dist/index.mjs +16 -10
- package/dist/internal.d.mts +2 -2
- package/dist/internal.d.ts +2 -2
- package/dist/{loaded-36WRJPBT.mjs → loaded-6K36DBBN.mjs} +4 -4
- package/dist/{loaded-SMPR6KZF.mjs → loaded-GZTG57BI.mjs} +4 -4
- package/dist/{loaded-JKA25A3T.mjs → loaded-SBKSTOMK.mjs} +4 -4
- package/dist/no-external.css +217 -51
- package/dist/no-external.d.mts +4 -4
- package/dist/no-external.d.ts +4 -4
- package/dist/no-external.js +2227 -1485
- package/dist/no-external.mjs +16 -10
- package/dist/rsc.d.mts +4 -3
- package/dist/rsc.d.ts +4 -3
- package/dist/rsc.js +194 -71
- package/dist/rsc.mjs +51 -21
- package/dist/{walk-tree-DbY5zG2K.d.ts → walk-tree-COvy_ERJ.d.ts} +1 -1
- package/dist/{walk-tree-DHP1pWEM.d.mts → walk-tree-CrM-tWuf.d.mts} +1 -1
- package/package.json +34 -33
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
defaultAppState,
|
|
6
6
|
resolveComponentData
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-XMN55NON.mjs";
|
|
8
8
|
import {
|
|
9
9
|
get_class_name_factory_default
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-OT7NKYY4.mjs";
|
|
11
11
|
import {
|
|
12
12
|
getZoneId,
|
|
13
13
|
mapFields,
|
|
@@ -225,16 +225,12 @@ function resolveAllData(_0, _1) {
|
|
|
225
225
|
"force",
|
|
226
226
|
parent,
|
|
227
227
|
root,
|
|
228
|
-
cacheStore
|
|
228
|
+
cacheStore,
|
|
229
|
+
// Slot children resolve through resolveNode, not a second walk of
|
|
230
|
+
// the resolved tree, so each resolveData runs once.
|
|
231
|
+
(child, resolvedParent) => resolveNode(child, resolvedParent, root)
|
|
229
232
|
)).node;
|
|
230
233
|
const resolvedAsComponent = toComponent(resolved);
|
|
231
|
-
const resolvedDeepPromise = mapFields(
|
|
232
|
-
resolved,
|
|
233
|
-
{
|
|
234
|
-
slot: ({ value }) => processContent(value, resolvedAsComponent, root)
|
|
235
|
-
},
|
|
236
|
-
config
|
|
237
|
-
);
|
|
238
234
|
let resolveZonePromises = [];
|
|
239
235
|
if (zonesByComponent[resolvedAsComponent.props.id]) {
|
|
240
236
|
resolveZonePromises = zonesByComponent[resolvedAsComponent.props.id].map(
|
|
@@ -247,10 +243,9 @@ function resolveAllData(_0, _1) {
|
|
|
247
243
|
})
|
|
248
244
|
);
|
|
249
245
|
}
|
|
250
|
-
const resolvedDeep = yield resolvedDeepPromise;
|
|
251
246
|
yield Promise.all(resolveZonePromises);
|
|
252
|
-
onResolveEnd == null ? void 0 : onResolveEnd(
|
|
253
|
-
return
|
|
247
|
+
onResolveEnd == null ? void 0 : onResolveEnd(resolvedAsComponent);
|
|
248
|
+
return resolved;
|
|
254
249
|
});
|
|
255
250
|
const processContent = (content, parent, root) => __async(null, null, function* () {
|
|
256
251
|
return Promise.all(content.map((item) => resolveNode(item, parent, root)));
|
|
@@ -267,23 +262,58 @@ function resolveAllData(_0, _1) {
|
|
|
267
262
|
});
|
|
268
263
|
}
|
|
269
264
|
|
|
270
|
-
// lib/
|
|
265
|
+
// lib/props/shared/get-drop-zone-props.ts
|
|
271
266
|
init_react_import();
|
|
272
|
-
var
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
267
|
+
var CONSUMED_PROP_KEYS = {
|
|
268
|
+
zone: true,
|
|
269
|
+
allow: true,
|
|
270
|
+
disallow: true,
|
|
271
|
+
style: true,
|
|
272
|
+
minEmptyHeight: true,
|
|
273
|
+
className: true,
|
|
274
|
+
collisionAxis: true,
|
|
275
|
+
ref: true,
|
|
276
|
+
as: true,
|
|
277
|
+
content: true,
|
|
278
|
+
config: true,
|
|
279
|
+
metadata: true,
|
|
280
|
+
fieldTransforms: true
|
|
281
|
+
};
|
|
282
|
+
var NON_FORWARDABLE_PROP_KEYS = {
|
|
283
|
+
children: true,
|
|
284
|
+
dangerouslySetInnerHTML: true
|
|
285
|
+
};
|
|
286
|
+
var CONSUMED_KEY_SET = new Set(
|
|
287
|
+
Object.keys(CONSUMED_PROP_KEYS)
|
|
288
|
+
);
|
|
289
|
+
var NON_FORWARDABLE_KEY_SET = new Set(
|
|
290
|
+
Object.keys(NON_FORWARDABLE_PROP_KEYS)
|
|
291
|
+
);
|
|
292
|
+
var getDropZoneProps = (allProps) => {
|
|
293
|
+
const props = /* @__PURE__ */ Object.create(null);
|
|
294
|
+
const forwardableProps = /* @__PURE__ */ Object.create(null);
|
|
295
|
+
const nonForwardableProps = /* @__PURE__ */ Object.create(null);
|
|
296
|
+
for (const key of Object.keys(allProps)) {
|
|
297
|
+
if (NON_FORWARDABLE_KEY_SET.has(key)) {
|
|
298
|
+
console.warn(
|
|
299
|
+
"The following prop is not supported by Puck DropZones or slots and will not be forwarded to the `as` element:",
|
|
300
|
+
key
|
|
301
|
+
);
|
|
302
|
+
nonForwardableProps[key] = allProps[key];
|
|
303
|
+
} else if (CONSUMED_KEY_SET.has(key)) {
|
|
304
|
+
props[key] = allProps[key];
|
|
305
|
+
} else {
|
|
306
|
+
forwardableProps[key] = allProps[key];
|
|
307
|
+
}
|
|
283
308
|
}
|
|
284
|
-
|
|
309
|
+
return {
|
|
310
|
+
props,
|
|
311
|
+
forwardableProps,
|
|
312
|
+
nonForwardableProps
|
|
313
|
+
};
|
|
314
|
+
};
|
|
285
315
|
|
|
286
|
-
// lib/use-
|
|
316
|
+
// lib/props/render/use-render-props.tsx
|
|
287
317
|
init_react_import();
|
|
288
318
|
|
|
289
319
|
// lib/field-transforms/use-field-transforms.tsx
|
|
@@ -327,16 +357,21 @@ function useFieldTransforms(config, item, transforms, readOnly, forceReadOnly) {
|
|
|
327
357
|
return mergedProps;
|
|
328
358
|
}
|
|
329
359
|
|
|
330
|
-
// lib/
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
360
|
+
// lib/field-transforms/default-transforms/slot-transform.tsx
|
|
361
|
+
init_react_import();
|
|
362
|
+
var getSlotTransform = (renderSlotEdit, renderSlotRender = renderSlotEdit) => ({
|
|
363
|
+
slot: ({ value: content, propName, field, isReadOnly }) => {
|
|
364
|
+
const render = isReadOnly ? renderSlotRender : renderSlotEdit;
|
|
365
|
+
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
|
366
|
+
allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
|
|
367
|
+
disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
|
|
368
|
+
}, dzProps), {
|
|
369
|
+
zone: propName,
|
|
370
|
+
content
|
|
371
|
+
}));
|
|
372
|
+
return Slot;
|
|
373
|
+
}
|
|
374
|
+
});
|
|
340
375
|
|
|
341
376
|
// components/RichTextEditor/lib/use-richtext-props.tsx
|
|
342
377
|
init_react_import();
|
|
@@ -377,15 +412,18 @@ var mapDeep = (source, path, render) => {
|
|
|
377
412
|
// components/RichTextEditor/lib/use-richtext-props.tsx
|
|
378
413
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
379
414
|
var RichTextRender = lazy(
|
|
380
|
-
() => import("./Render-
|
|
415
|
+
() => import("./Render-H3USS5FU.mjs").then((m) => ({
|
|
381
416
|
default: m.RichTextRender
|
|
382
417
|
}))
|
|
383
418
|
);
|
|
384
|
-
function useRichtextProps(fields, props) {
|
|
419
|
+
function useRichtextProps(fields, props, fieldTransforms) {
|
|
385
420
|
const findAllRichtextKeys = (fields2, path = []) => {
|
|
386
421
|
if (!fields2) return [];
|
|
387
422
|
const result = [];
|
|
388
423
|
for (const [key, field] of Object.entries(fields2)) {
|
|
424
|
+
if (fieldTransforms == null ? void 0 : fieldTransforms[field.type]) {
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
389
427
|
const currentPath = [...path, key];
|
|
390
428
|
if (field.type === "richtext") {
|
|
391
429
|
result.push({
|
|
@@ -402,7 +440,10 @@ function useRichtextProps(fields, props) {
|
|
|
402
440
|
}
|
|
403
441
|
return result;
|
|
404
442
|
};
|
|
405
|
-
const richtextKeys = useMemo2(
|
|
443
|
+
const richtextKeys = useMemo2(
|
|
444
|
+
() => findAllRichtextKeys(fields),
|
|
445
|
+
[fields, fieldTransforms]
|
|
446
|
+
);
|
|
406
447
|
const richtextProps = useMemo2(() => {
|
|
407
448
|
if (!(richtextKeys == null ? void 0 : richtextKeys.length)) return {};
|
|
408
449
|
let result = __spreadValues({}, props);
|
|
@@ -421,6 +462,28 @@ function useRichtextProps(fields, props) {
|
|
|
421
462
|
return richtextProps;
|
|
422
463
|
}
|
|
423
464
|
|
|
465
|
+
// lib/props/render/use-render-props.tsx
|
|
466
|
+
var EMPTY_FIELD_CONFIG = {};
|
|
467
|
+
function useRenderProps(config, component, renderSlot, fieldTransforms) {
|
|
468
|
+
var _a, _b;
|
|
469
|
+
const transformedProps = useFieldTransforms(
|
|
470
|
+
config,
|
|
471
|
+
component,
|
|
472
|
+
__spreadValues(__spreadValues({}, getSlotTransform(renderSlot)), fieldTransforms),
|
|
473
|
+
void 0,
|
|
474
|
+
true
|
|
475
|
+
);
|
|
476
|
+
const isRoot = !("type" in component) || component.type === "root";
|
|
477
|
+
const componentFields = isRoot ? (_a = config.root) == null ? void 0 : _a.fields : ((_b = config.components[component.type]) == null ? void 0 : _b.fields) || EMPTY_FIELD_CONFIG;
|
|
478
|
+
const richtextProps = useRichtextProps(
|
|
479
|
+
componentFields,
|
|
480
|
+
transformedProps,
|
|
481
|
+
fieldTransforms
|
|
482
|
+
);
|
|
483
|
+
return __spreadValues(__spreadValues({}, transformedProps), richtextProps);
|
|
484
|
+
}
|
|
485
|
+
var use_render_props_default = useRenderProps;
|
|
486
|
+
|
|
424
487
|
// components/SlotRender/server.tsx
|
|
425
488
|
init_react_import();
|
|
426
489
|
import { forwardRef } from "react";
|
|
@@ -429,14 +492,26 @@ var SlotRenderPure = (props) => /* @__PURE__ */ jsx3(SlotRender, __spreadValues(
|
|
|
429
492
|
var Item = ({
|
|
430
493
|
config,
|
|
431
494
|
item,
|
|
432
|
-
metadata
|
|
495
|
+
metadata,
|
|
496
|
+
fieldTransforms
|
|
433
497
|
}) => {
|
|
434
498
|
const Component = config.components[item.type];
|
|
435
|
-
const props =
|
|
436
|
-
|
|
499
|
+
const props = use_render_props_default(
|
|
500
|
+
config,
|
|
501
|
+
item,
|
|
502
|
+
(slotProps) => /* @__PURE__ */ jsx3(
|
|
503
|
+
SlotRenderPure,
|
|
504
|
+
__spreadProps(__spreadValues({}, slotProps), {
|
|
505
|
+
config,
|
|
506
|
+
metadata,
|
|
507
|
+
fieldTransforms
|
|
508
|
+
})
|
|
509
|
+
),
|
|
510
|
+
fieldTransforms
|
|
511
|
+
);
|
|
437
512
|
return /* @__PURE__ */ jsx3(
|
|
438
513
|
Component.render,
|
|
439
|
-
__spreadProps(__spreadValues(
|
|
514
|
+
__spreadProps(__spreadValues({}, props), {
|
|
440
515
|
puck: __spreadProps(__spreadValues({}, props.puck), {
|
|
441
516
|
metadata: metadata || {}
|
|
442
517
|
})
|
|
@@ -444,9 +519,21 @@ var Item = ({
|
|
|
444
519
|
);
|
|
445
520
|
};
|
|
446
521
|
var SlotRender = forwardRef(
|
|
447
|
-
function SlotRenderInternal(
|
|
522
|
+
function SlotRenderInternal(allProps, ref) {
|
|
523
|
+
const {
|
|
524
|
+
props: {
|
|
525
|
+
className,
|
|
526
|
+
style,
|
|
527
|
+
content,
|
|
528
|
+
config,
|
|
529
|
+
metadata,
|
|
530
|
+
as,
|
|
531
|
+
fieldTransforms
|
|
532
|
+
},
|
|
533
|
+
forwardableProps
|
|
534
|
+
} = getDropZoneProps(allProps);
|
|
448
535
|
const El = as != null ? as : "div";
|
|
449
|
-
return /* @__PURE__ */ jsx3(El, { className, style, ref, children: content.map((item) => {
|
|
536
|
+
return /* @__PURE__ */ jsx3(El, __spreadProps(__spreadValues({}, forwardableProps), { className, style, ref, children: content.map((item) => {
|
|
450
537
|
if (!config.components[item.type]) {
|
|
451
538
|
return null;
|
|
452
539
|
}
|
|
@@ -455,20 +542,21 @@ var SlotRender = forwardRef(
|
|
|
455
542
|
{
|
|
456
543
|
config,
|
|
457
544
|
item,
|
|
458
|
-
metadata
|
|
545
|
+
metadata,
|
|
546
|
+
fieldTransforms
|
|
459
547
|
},
|
|
460
548
|
item.props.id
|
|
461
549
|
);
|
|
462
|
-
}) });
|
|
550
|
+
}) }));
|
|
463
551
|
}
|
|
464
552
|
);
|
|
465
553
|
|
|
466
554
|
export {
|
|
555
|
+
getDropZoneProps,
|
|
467
556
|
buildMappers,
|
|
468
557
|
getSlotTransform,
|
|
469
|
-
useSlots,
|
|
470
558
|
RichTextRenderFallback,
|
|
471
|
-
|
|
559
|
+
use_render_props_default,
|
|
472
560
|
SlotRenderPure,
|
|
473
561
|
SlotRender,
|
|
474
562
|
migrate,
|