@measured/puck 0.21.0-canary.3aa27d1d → 0.21.0-canary.41d0882b
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/Editor-IQP25PUX.css +404 -0
- package/dist/Editor-L3JAAT2X.mjs +204 -0
- package/dist/Render-3OV4N4MT.css +102 -0
- package/dist/Render-FXZX6NFH.mjs +55 -0
- package/dist/{walk-tree-16XYcbNo.d.mts → actions-tsxxcX1z.d.mts} +29 -40
- package/dist/{walk-tree-16XYcbNo.d.ts → actions-tsxxcX1z.d.ts} +29 -40
- package/dist/chunk-23IZFPL7.mjs +528 -0
- package/dist/chunk-3SDLQIUZ.mjs +429 -0
- package/dist/chunk-45I5SDOI.mjs +134 -0
- package/dist/chunk-5ZZVX2Z3.mjs +63 -0
- package/dist/chunk-AOEDIUVK.mjs +11 -0
- package/dist/chunk-B7REOAA7.mjs +435 -0
- package/dist/chunk-BXQQARCR.mjs +708 -0
- package/dist/{chunk-GFIVKP2H.mjs → chunk-CQUAWHOK.mjs} +6092 -8451
- package/dist/chunk-D2SRL6YA.mjs +1807 -0
- package/dist/chunk-LJEGWHDD.mjs +53 -0
- package/dist/chunk-M6W7YEVX.mjs +95 -0
- package/dist/chunk-PBAAIKXA.mjs +111 -0
- package/dist/chunk-U4VSQKO3.mjs +33 -0
- package/dist/chunk-V5I7CVLT.mjs +103 -0
- package/dist/chunk-Y2EFNT5P.mjs +108 -0
- package/dist/full-2GJTAAZE.css +301 -0
- package/dist/full-L7DWVNTZ.mjs +93 -0
- package/dist/index-Ca6V6NQD.d.ts +118 -0
- package/dist/index-mQvUCH3C.d.mts +118 -0
- package/dist/index.css +858 -459
- package/dist/index.d.mts +32 -129
- package/dist/index.d.ts +32 -129
- package/dist/index.js +9406 -6857
- package/dist/index.mjs +32 -14
- package/dist/internal.d.mts +27 -0
- package/dist/internal.d.ts +27 -0
- package/dist/internal.js +927 -0
- package/dist/internal.mjs +13 -0
- package/dist/loaded-2HLHDP2G.mjs +57 -0
- package/dist/loaded-LZUXYAGW.mjs +60 -0
- package/dist/loaded-RVWBFK7L.css +87 -0
- package/dist/loaded-UHVTB6OD.mjs +57 -0
- package/dist/no-external.css +990 -587
- package/dist/no-external.d.mts +4 -2
- package/dist/no-external.d.ts +4 -2
- package/dist/no-external.js +9407 -6855
- package/dist/no-external.mjs +34 -11
- package/dist/rsc.css +35 -26
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +300 -215
- package/dist/rsc.mjs +18 -9
- package/dist/walk-tree-Bh85NMeo.d.ts +29 -0
- package/dist/walk-tree-CDA3K5S3.d.mts +29 -0
- package/package.json +9 -4
- package/dist/chunk-SRDLYODX.mjs +0 -1245
package/dist/rsc.js
CHANGED
|
@@ -153,6 +153,205 @@ var require_classnames = __commonJS({
|
|
|
153
153
|
}
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
+
// lib/get-class-name-factory.ts
|
|
157
|
+
var import_classnames, getClassNameFactory, get_class_name_factory_default;
|
|
158
|
+
var init_get_class_name_factory = __esm({
|
|
159
|
+
"lib/get-class-name-factory.ts"() {
|
|
160
|
+
"use strict";
|
|
161
|
+
init_react_import();
|
|
162
|
+
import_classnames = __toESM(require_classnames());
|
|
163
|
+
getClassNameFactory = (rootClass, styles, config = { baseClass: "" }) => (options = {}) => {
|
|
164
|
+
if (typeof options === "string") {
|
|
165
|
+
const descendant = options;
|
|
166
|
+
const style = styles[`${rootClass}-${descendant}`];
|
|
167
|
+
if (style) {
|
|
168
|
+
return config.baseClass + styles[`${rootClass}-${descendant}`] || "";
|
|
169
|
+
}
|
|
170
|
+
return "";
|
|
171
|
+
} else if (typeof options === "object") {
|
|
172
|
+
const modifiers = options;
|
|
173
|
+
const prefixedModifiers = {};
|
|
174
|
+
for (let modifier in modifiers) {
|
|
175
|
+
prefixedModifiers[styles[`${rootClass}--${modifier}`]] = modifiers[modifier];
|
|
176
|
+
}
|
|
177
|
+
const c = styles[rootClass];
|
|
178
|
+
return config.baseClass + (0, import_classnames.default)(__spreadValues({
|
|
179
|
+
[c]: !!c
|
|
180
|
+
}, prefixedModifiers));
|
|
181
|
+
} else {
|
|
182
|
+
return config.baseClass + styles[rootClass] || "";
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
get_class_name_factory_default = getClassNameFactory;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/RichTextEditor/styles.module.css/#css-module-data
|
|
190
|
+
var init_css_module_data = __esm({
|
|
191
|
+
"css-module:/home/runner/work/puck/puck/packages/core/components/RichTextEditor/styles.module.css/#css-module-data"() {
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/RichTextEditor/styles.module.css#css-module
|
|
196
|
+
var styles_module_default;
|
|
197
|
+
var init_styles_module = __esm({
|
|
198
|
+
"css-module:/home/runner/work/puck/puck/packages/core/components/RichTextEditor/styles.module.css#css-module"() {
|
|
199
|
+
"use strict";
|
|
200
|
+
init_react_import();
|
|
201
|
+
init_css_module_data();
|
|
202
|
+
styles_module_default = { "RichTextEditor": "_RichTextEditor_z25h4_1", "RichTextEditor--editor": "_RichTextEditor--editor_z25h4_50", "RichTextEditor--disabled": "_RichTextEditor--disabled_z25h4_107", "RichTextEditor--isActive": "_RichTextEditor--isActive_z25h4_111", "RichTextEditor-menu": "_RichTextEditor-menu_z25h4_117" };
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// components/RichTextEditor/extension.ts
|
|
207
|
+
var import_core, import_extension_blockquote, import_extension_bold, import_extension_code, import_extension_code_block, import_extension_document, import_extension_hard_break, import_extension_heading, import_extension_horizontal_rule, import_extension_italic, import_extension_link, import_extension_list, import_extension_paragraph, import_extension_strike, import_extension_text, import_extension_text_align, import_extension_underline, defaultPuckRichTextOptions, PuckRichText;
|
|
208
|
+
var init_extension = __esm({
|
|
209
|
+
"components/RichTextEditor/extension.ts"() {
|
|
210
|
+
"use strict";
|
|
211
|
+
init_react_import();
|
|
212
|
+
import_core = require("@tiptap/core");
|
|
213
|
+
import_extension_blockquote = require("@tiptap/extension-blockquote");
|
|
214
|
+
import_extension_bold = require("@tiptap/extension-bold");
|
|
215
|
+
import_extension_code = require("@tiptap/extension-code");
|
|
216
|
+
import_extension_code_block = require("@tiptap/extension-code-block");
|
|
217
|
+
import_extension_document = require("@tiptap/extension-document");
|
|
218
|
+
import_extension_hard_break = require("@tiptap/extension-hard-break");
|
|
219
|
+
import_extension_heading = require("@tiptap/extension-heading");
|
|
220
|
+
import_extension_horizontal_rule = require("@tiptap/extension-horizontal-rule");
|
|
221
|
+
import_extension_italic = require("@tiptap/extension-italic");
|
|
222
|
+
import_extension_link = require("@tiptap/extension-link");
|
|
223
|
+
import_extension_list = require("@tiptap/extension-list");
|
|
224
|
+
import_extension_paragraph = require("@tiptap/extension-paragraph");
|
|
225
|
+
import_extension_strike = require("@tiptap/extension-strike");
|
|
226
|
+
import_extension_text = require("@tiptap/extension-text");
|
|
227
|
+
import_extension_text_align = __toESM(require("@tiptap/extension-text-align"));
|
|
228
|
+
import_extension_underline = require("@tiptap/extension-underline");
|
|
229
|
+
defaultPuckRichTextOptions = {
|
|
230
|
+
textAlign: {
|
|
231
|
+
types: ["heading", "paragraph"]
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
PuckRichText = import_core.Extension.create({
|
|
235
|
+
name: "puckRichText",
|
|
236
|
+
addExtensions() {
|
|
237
|
+
const extensions = [];
|
|
238
|
+
const options = __spreadValues(__spreadValues({}, this.options), defaultPuckRichTextOptions);
|
|
239
|
+
if (options.bold !== false) {
|
|
240
|
+
extensions.push(import_extension_bold.Bold.configure(options.bold));
|
|
241
|
+
}
|
|
242
|
+
if (options.blockquote !== false) {
|
|
243
|
+
extensions.push(import_extension_blockquote.Blockquote.configure(options.blockquote));
|
|
244
|
+
}
|
|
245
|
+
if (options.bulletList !== false) {
|
|
246
|
+
extensions.push(import_extension_list.BulletList.configure(options.bulletList));
|
|
247
|
+
}
|
|
248
|
+
if (options.code !== false) {
|
|
249
|
+
extensions.push(import_extension_code.Code.configure(options.code));
|
|
250
|
+
}
|
|
251
|
+
if (options.codeBlock !== false) {
|
|
252
|
+
extensions.push(import_extension_code_block.CodeBlock.configure(options.codeBlock));
|
|
253
|
+
}
|
|
254
|
+
if (options.document !== false) {
|
|
255
|
+
extensions.push(import_extension_document.Document.configure(options.document));
|
|
256
|
+
}
|
|
257
|
+
if (options.hardBreak !== false) {
|
|
258
|
+
extensions.push(import_extension_hard_break.HardBreak.configure(options.hardBreak));
|
|
259
|
+
}
|
|
260
|
+
if (options.heading !== false) {
|
|
261
|
+
extensions.push(import_extension_heading.Heading.configure(options.heading));
|
|
262
|
+
}
|
|
263
|
+
if (options.horizontalRule !== false) {
|
|
264
|
+
extensions.push(import_extension_horizontal_rule.HorizontalRule.configure(options.horizontalRule));
|
|
265
|
+
}
|
|
266
|
+
if (options.italic !== false) {
|
|
267
|
+
extensions.push(import_extension_italic.Italic.configure(options.italic));
|
|
268
|
+
}
|
|
269
|
+
if (options.listItem !== false) {
|
|
270
|
+
extensions.push(import_extension_list.ListItem.configure(options.listItem));
|
|
271
|
+
}
|
|
272
|
+
if (options.listKeymap !== false) {
|
|
273
|
+
extensions.push(import_extension_list.ListKeymap.configure(options == null ? void 0 : options.listKeymap));
|
|
274
|
+
}
|
|
275
|
+
if (options.link !== false) {
|
|
276
|
+
extensions.push(import_extension_link.Link.configure(options == null ? void 0 : options.link));
|
|
277
|
+
}
|
|
278
|
+
if (options.orderedList !== false) {
|
|
279
|
+
extensions.push(import_extension_list.OrderedList.configure(options.orderedList));
|
|
280
|
+
}
|
|
281
|
+
if (options.paragraph !== false) {
|
|
282
|
+
extensions.push(import_extension_paragraph.Paragraph.configure(options.paragraph));
|
|
283
|
+
}
|
|
284
|
+
if (options.strike !== false) {
|
|
285
|
+
extensions.push(import_extension_strike.Strike.configure(options.strike));
|
|
286
|
+
}
|
|
287
|
+
if (options.text !== false) {
|
|
288
|
+
extensions.push(import_extension_text.Text.configure(options.text));
|
|
289
|
+
}
|
|
290
|
+
if (options.textAlign !== false) {
|
|
291
|
+
extensions.push(import_extension_text_align.default.configure(options.textAlign));
|
|
292
|
+
}
|
|
293
|
+
if (options.underline !== false) {
|
|
294
|
+
extensions.push(import_extension_underline.Underline.configure(options == null ? void 0 : options.underline));
|
|
295
|
+
}
|
|
296
|
+
return extensions;
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
// components/RichTextEditor/components/Render.tsx
|
|
303
|
+
var Render_exports = {};
|
|
304
|
+
__export(Render_exports, {
|
|
305
|
+
RichTextRender: () => RichTextRender
|
|
306
|
+
});
|
|
307
|
+
function RichTextRender({
|
|
308
|
+
content,
|
|
309
|
+
field
|
|
310
|
+
}) {
|
|
311
|
+
const { tiptap = {}, options } = field;
|
|
312
|
+
const { extensions = [] } = tiptap;
|
|
313
|
+
const loadedExtensions = (0, import_react3.useMemo)(
|
|
314
|
+
() => [PuckRichText.configure(options), ...extensions],
|
|
315
|
+
[field, extensions]
|
|
316
|
+
);
|
|
317
|
+
const normalized = (0, import_react3.useMemo)(() => {
|
|
318
|
+
if (typeof content === "object" && (content == null ? void 0 : content.type) === "doc") {
|
|
319
|
+
return content;
|
|
320
|
+
}
|
|
321
|
+
if (typeof content === "string") {
|
|
322
|
+
const isHtml = /<\/?[a-z][\s\S]*>/i.test(content);
|
|
323
|
+
if (isHtml) {
|
|
324
|
+
return (0, import_html.generateJSON)(content, loadedExtensions);
|
|
325
|
+
}
|
|
326
|
+
return {
|
|
327
|
+
type: "doc",
|
|
328
|
+
content: [
|
|
329
|
+
{ type: "paragraph", content: [{ type: "text", text: content }] }
|
|
330
|
+
]
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
return { type: "doc", content: [] };
|
|
334
|
+
}, [content, loadedExtensions]);
|
|
335
|
+
const html = (0, import_react3.useMemo)(() => {
|
|
336
|
+
return (0, import_html.generateHTML)(normalized, loadedExtensions);
|
|
337
|
+
}, [normalized, loadedExtensions]);
|
|
338
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: getClassName2(), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "rich-text", dangerouslySetInnerHTML: { __html: html } }) });
|
|
339
|
+
}
|
|
340
|
+
var import_html, import_react3, import_jsx_runtime2, getClassName2;
|
|
341
|
+
var init_Render = __esm({
|
|
342
|
+
"components/RichTextEditor/components/Render.tsx"() {
|
|
343
|
+
"use strict";
|
|
344
|
+
init_react_import();
|
|
345
|
+
import_html = require("@tiptap/html");
|
|
346
|
+
import_react3 = require("react");
|
|
347
|
+
init_get_class_name_factory();
|
|
348
|
+
init_styles_module();
|
|
349
|
+
init_extension();
|
|
350
|
+
import_jsx_runtime2 = require("react/jsx-runtime");
|
|
351
|
+
getClassName2 = get_class_name_factory_default("RichTextEditor", styles_module_default);
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
|
|
156
355
|
// bundle/rsc.tsx
|
|
157
356
|
var rsc_exports = {};
|
|
158
357
|
__export(rsc_exports, {
|
|
@@ -330,12 +529,12 @@ var walkObject = ({
|
|
|
330
529
|
}
|
|
331
530
|
return flatten(newProps);
|
|
332
531
|
};
|
|
333
|
-
function mapFields(item, mappers, config, recurseSlots = false) {
|
|
532
|
+
function mapFields(item, mappers, config, recurseSlots = false, shouldDefaultSlots = true) {
|
|
334
533
|
var _a, _b, _c, _d, _e;
|
|
335
534
|
const itemType = "type" in item ? item.type : "root";
|
|
336
535
|
const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
|
|
337
536
|
const newProps = walkObject({
|
|
338
|
-
value: defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}),
|
|
537
|
+
value: shouldDefaultSlots ? defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}) : item.props,
|
|
339
538
|
fields: (_d = componentConfig == null ? void 0 : componentConfig.fields) != null ? _d : {},
|
|
340
539
|
mappers,
|
|
341
540
|
id: item.props ? (_e = item.props.id) != null ? _e : "root" : "root",
|
|
@@ -353,32 +552,38 @@ function mapFields(item, mappers, config, recurseSlots = false) {
|
|
|
353
552
|
});
|
|
354
553
|
}
|
|
355
554
|
|
|
555
|
+
// lib/field-transforms/build-mappers.ts
|
|
556
|
+
init_react_import();
|
|
557
|
+
function buildMappers(transforms, readOnly, forceReadOnly) {
|
|
558
|
+
return Object.keys(transforms).reduce((acc, _fieldType) => {
|
|
559
|
+
const fieldType = _fieldType;
|
|
560
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
561
|
+
[fieldType]: (_a) => {
|
|
562
|
+
var _b = _a, {
|
|
563
|
+
parentId
|
|
564
|
+
} = _b, params = __objRest(_b, [
|
|
565
|
+
"parentId"
|
|
566
|
+
]);
|
|
567
|
+
const wildcardPath = params.propPath.replace(/\[\d+\]/g, "[*]");
|
|
568
|
+
const isReadOnly = (readOnly == null ? void 0 : readOnly[params.propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly || false;
|
|
569
|
+
const fn = transforms[fieldType];
|
|
570
|
+
return fn == null ? void 0 : fn(__spreadProps(__spreadValues({}, params), {
|
|
571
|
+
isReadOnly,
|
|
572
|
+
componentId: parentId
|
|
573
|
+
}));
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
}, {});
|
|
577
|
+
}
|
|
578
|
+
|
|
356
579
|
// lib/field-transforms/use-field-transforms.tsx
|
|
357
580
|
function useFieldTransforms(config, item, transforms, readOnly, forceReadOnly) {
|
|
358
|
-
const mappers = (0, import_react2.useMemo)(
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
[fieldType]: (_a) => {
|
|
363
|
-
var _b = _a, {
|
|
364
|
-
parentId
|
|
365
|
-
} = _b, params = __objRest(_b, [
|
|
366
|
-
"parentId"
|
|
367
|
-
]);
|
|
368
|
-
const wildcardPath = params.propPath.replace(/\[\d+\]/g, "[*]");
|
|
369
|
-
const isReadOnly = (readOnly == null ? void 0 : readOnly[params.propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly || false;
|
|
370
|
-
const fn = transforms[fieldType];
|
|
371
|
-
return fn == null ? void 0 : fn(__spreadProps(__spreadValues({}, params), {
|
|
372
|
-
isReadOnly,
|
|
373
|
-
componentId: parentId
|
|
374
|
-
}));
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
}, {});
|
|
378
|
-
}, [transforms, readOnly, forceReadOnly]);
|
|
581
|
+
const mappers = (0, import_react2.useMemo)(
|
|
582
|
+
() => buildMappers(transforms, readOnly, forceReadOnly),
|
|
583
|
+
[transforms, readOnly, forceReadOnly]
|
|
584
|
+
);
|
|
379
585
|
const transformedProps = (0, import_react2.useMemo)(() => {
|
|
380
|
-
|
|
381
|
-
return mapped;
|
|
586
|
+
return mapFields(item, mappers, config).props;
|
|
382
587
|
}, [config, item, mappers]);
|
|
383
588
|
const mergedProps = (0, import_react2.useMemo)(
|
|
384
589
|
() => __spreadValues(__spreadValues({}, item.props), transformedProps),
|
|
@@ -418,176 +623,29 @@ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdi
|
|
|
418
623
|
init_react_import();
|
|
419
624
|
var import_react5 = require("react");
|
|
420
625
|
|
|
421
|
-
// components/RichTextEditor/lib/use-richtext-
|
|
626
|
+
// components/RichTextEditor/lib/use-richtext-props.tsx
|
|
422
627
|
init_react_import();
|
|
423
628
|
var import_react4 = require("react");
|
|
424
629
|
|
|
425
|
-
// components/RichTextEditor/
|
|
426
|
-
init_react_import();
|
|
427
|
-
var import_html = require("@tiptap/html");
|
|
428
|
-
var import_react3 = require("react");
|
|
429
|
-
|
|
430
|
-
// lib/get-class-name-factory.ts
|
|
630
|
+
// components/RichTextEditor/components/RenderFallback.tsx
|
|
431
631
|
init_react_import();
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
if (typeof options === "string") {
|
|
435
|
-
const descendant = options;
|
|
436
|
-
const style = styles[`${rootClass}-${descendant}`];
|
|
437
|
-
if (style) {
|
|
438
|
-
return config.baseClass + styles[`${rootClass}-${descendant}`] || "";
|
|
439
|
-
}
|
|
440
|
-
return "";
|
|
441
|
-
} else if (typeof options === "object") {
|
|
442
|
-
const modifiers = options;
|
|
443
|
-
const prefixedModifiers = {};
|
|
444
|
-
for (let modifier in modifiers) {
|
|
445
|
-
prefixedModifiers[styles[`${rootClass}--${modifier}`]] = modifiers[modifier];
|
|
446
|
-
}
|
|
447
|
-
const c = styles[rootClass];
|
|
448
|
-
return config.baseClass + (0, import_classnames.default)(__spreadValues({
|
|
449
|
-
[c]: !!c
|
|
450
|
-
}, prefixedModifiers));
|
|
451
|
-
} else {
|
|
452
|
-
return config.baseClass + styles[rootClass] || "";
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
var get_class_name_factory_default = getClassNameFactory;
|
|
456
|
-
|
|
457
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/RichTextEditor/styles.module.css#css-module
|
|
458
|
-
init_react_import();
|
|
459
|
-
var styles_module_default = { "RichTextEditor": "_RichTextEditor_1819a_1", "RichTextEditor--editor": "_RichTextEditor--editor_1819a_46", "RichTextEditor--disabled": "_RichTextEditor--disabled_1819a_95", "RichTextEditor--isActive": "_RichTextEditor--isActive_1819a_99", "RichTextEditor-menu": "_RichTextEditor-menu_1819a_105" };
|
|
460
|
-
|
|
461
|
-
// components/RichTextEditor/extensions.ts
|
|
462
|
-
init_react_import();
|
|
463
|
-
var import_core = require("@tiptap/core");
|
|
464
|
-
var import_extension_blockquote = require("@tiptap/extension-blockquote");
|
|
465
|
-
var import_extension_bold = require("@tiptap/extension-bold");
|
|
466
|
-
var import_extension_code = require("@tiptap/extension-code");
|
|
467
|
-
var import_extension_code_block = require("@tiptap/extension-code-block");
|
|
468
|
-
var import_extension_document = require("@tiptap/extension-document");
|
|
469
|
-
var import_extension_hard_break = require("@tiptap/extension-hard-break");
|
|
470
|
-
var import_extension_heading = require("@tiptap/extension-heading");
|
|
471
|
-
var import_extension_horizontal_rule = require("@tiptap/extension-horizontal-rule");
|
|
472
|
-
var import_extension_italic = require("@tiptap/extension-italic");
|
|
473
|
-
var import_extension_link = require("@tiptap/extension-link");
|
|
474
|
-
var import_extension_list = require("@tiptap/extension-list");
|
|
475
|
-
var import_extension_paragraph = require("@tiptap/extension-paragraph");
|
|
476
|
-
var import_extension_strike = require("@tiptap/extension-strike");
|
|
477
|
-
var import_extension_text = require("@tiptap/extension-text");
|
|
478
|
-
var import_extension_text_align = __toESM(require("@tiptap/extension-text-align"));
|
|
479
|
-
var import_extension_underline = require("@tiptap/extension-underline");
|
|
480
|
-
var defaultPuckRichTextOptions = {
|
|
481
|
-
textAlign: {
|
|
482
|
-
types: ["heading", "paragraph"]
|
|
483
|
-
}
|
|
484
|
-
};
|
|
485
|
-
var PuckRichText = import_core.Extension.create({
|
|
486
|
-
name: "puckRichText",
|
|
487
|
-
addExtensions() {
|
|
488
|
-
const extensions = [];
|
|
489
|
-
const options = __spreadValues(__spreadValues({}, this.options), defaultPuckRichTextOptions);
|
|
490
|
-
if (options.bold !== false) {
|
|
491
|
-
extensions.push(import_extension_bold.Bold.configure(options.bold));
|
|
492
|
-
}
|
|
493
|
-
if (options.blockquote !== false) {
|
|
494
|
-
extensions.push(import_extension_blockquote.Blockquote.configure(options.blockquote));
|
|
495
|
-
}
|
|
496
|
-
if (options.bulletList !== false) {
|
|
497
|
-
extensions.push(import_extension_list.BulletList.configure(options.bulletList));
|
|
498
|
-
}
|
|
499
|
-
if (options.code !== false) {
|
|
500
|
-
extensions.push(import_extension_code.Code.configure(options.code));
|
|
501
|
-
}
|
|
502
|
-
if (options.codeBlock !== false) {
|
|
503
|
-
extensions.push(import_extension_code_block.CodeBlock.configure(options.codeBlock));
|
|
504
|
-
}
|
|
505
|
-
if (options.document !== false) {
|
|
506
|
-
extensions.push(import_extension_document.Document.configure(options.document));
|
|
507
|
-
}
|
|
508
|
-
if (options.hardBreak !== false) {
|
|
509
|
-
extensions.push(import_extension_hard_break.HardBreak.configure(options.hardBreak));
|
|
510
|
-
}
|
|
511
|
-
if (options.heading !== false) {
|
|
512
|
-
extensions.push(import_extension_heading.Heading.configure(options.heading));
|
|
513
|
-
}
|
|
514
|
-
if (options.horizontalRule !== false) {
|
|
515
|
-
extensions.push(import_extension_horizontal_rule.HorizontalRule.configure(options.horizontalRule));
|
|
516
|
-
}
|
|
517
|
-
if (options.italic !== false) {
|
|
518
|
-
extensions.push(import_extension_italic.Italic.configure(options.italic));
|
|
519
|
-
}
|
|
520
|
-
if (options.listItem !== false) {
|
|
521
|
-
extensions.push(import_extension_list.ListItem.configure(options.listItem));
|
|
522
|
-
}
|
|
523
|
-
if (options.listKeymap !== false) {
|
|
524
|
-
extensions.push(import_extension_list.ListKeymap.configure(options == null ? void 0 : options.listKeymap));
|
|
525
|
-
}
|
|
526
|
-
if (options.link !== false) {
|
|
527
|
-
extensions.push(import_extension_link.Link.configure(options == null ? void 0 : options.link));
|
|
528
|
-
}
|
|
529
|
-
if (options.orderedList !== false) {
|
|
530
|
-
extensions.push(import_extension_list.OrderedList.configure(options.orderedList));
|
|
531
|
-
}
|
|
532
|
-
if (options.paragraph !== false) {
|
|
533
|
-
extensions.push(import_extension_paragraph.Paragraph.configure(options.paragraph));
|
|
534
|
-
}
|
|
535
|
-
if (options.strike !== false) {
|
|
536
|
-
extensions.push(import_extension_strike.Strike.configure(options.strike));
|
|
537
|
-
}
|
|
538
|
-
if (options.text !== false) {
|
|
539
|
-
extensions.push(import_extension_text.Text.configure(options.text));
|
|
540
|
-
}
|
|
541
|
-
if (options.textAlign !== false) {
|
|
542
|
-
extensions.push(import_extension_text_align.default.configure(options.textAlign));
|
|
543
|
-
}
|
|
544
|
-
if (options.underline !== false) {
|
|
545
|
-
extensions.push(import_extension_underline.Underline.configure(options == null ? void 0 : options.underline));
|
|
546
|
-
}
|
|
547
|
-
return extensions;
|
|
548
|
-
}
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
// components/RichTextEditor/Render.tsx
|
|
632
|
+
init_get_class_name_factory();
|
|
633
|
+
init_styles_module();
|
|
552
634
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
553
635
|
var getClassName = get_class_name_factory_default("RichTextEditor", styles_module_default);
|
|
554
|
-
function
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
const loadedExtensions = (0, import_react3.useMemo)(
|
|
561
|
-
() => [PuckRichText.configure(options), ...extensions],
|
|
562
|
-
[field, extensions]
|
|
563
|
-
);
|
|
564
|
-
const normalized = (0, import_react3.useMemo)(() => {
|
|
565
|
-
if (typeof content === "object" && (content == null ? void 0 : content.type) === "doc") {
|
|
566
|
-
return content;
|
|
567
|
-
}
|
|
568
|
-
if (typeof content === "string") {
|
|
569
|
-
const isHtml = /<\/?[a-z][\s\S]*>/i.test(content);
|
|
570
|
-
if (isHtml) {
|
|
571
|
-
return (0, import_html.generateJSON)(content, loadedExtensions);
|
|
572
|
-
}
|
|
573
|
-
return {
|
|
574
|
-
type: "doc",
|
|
575
|
-
content: [
|
|
576
|
-
{ type: "paragraph", content: [{ type: "text", text: content }] }
|
|
577
|
-
]
|
|
578
|
-
};
|
|
636
|
+
function RichTextRenderFallback({ content }) {
|
|
637
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: getClassName(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
638
|
+
"div",
|
|
639
|
+
{
|
|
640
|
+
className: "rich-text",
|
|
641
|
+
dangerouslySetInnerHTML: { __html: content }
|
|
579
642
|
}
|
|
580
|
-
|
|
581
|
-
}, [content, loadedExtensions]);
|
|
582
|
-
const html = (0, import_react3.useMemo)(() => {
|
|
583
|
-
return (0, import_html.generateHTML)(normalized, loadedExtensions);
|
|
584
|
-
}, [normalized, loadedExtensions]);
|
|
585
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: getClassName(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "rich-text", dangerouslySetInnerHTML: { __html: html } }) });
|
|
643
|
+
) });
|
|
586
644
|
}
|
|
587
645
|
|
|
588
|
-
// components/RichTextEditor/lib/use-richtext-
|
|
589
|
-
var
|
|
590
|
-
function
|
|
646
|
+
// components/RichTextEditor/lib/use-richtext-props.tsx
|
|
647
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
648
|
+
function useRichtextProps(fields, props) {
|
|
591
649
|
const findAllRichtextKeys = (fields2) => {
|
|
592
650
|
if (!fields2) return [];
|
|
593
651
|
const result = [];
|
|
@@ -599,36 +657,41 @@ function useRichtextRenderer(fields, props) {
|
|
|
599
657
|
return result;
|
|
600
658
|
};
|
|
601
659
|
const richtextKeys = (0, import_react4.useMemo)(() => findAllRichtextKeys(fields), [fields]);
|
|
602
|
-
const
|
|
603
|
-
if (!richtextKeys) return {};
|
|
660
|
+
const richtextProps = (0, import_react4.useMemo)(() => {
|
|
661
|
+
if (!(richtextKeys == null ? void 0 : richtextKeys.length)) return {};
|
|
662
|
+
const RichTextRender2 = (0, import_react4.lazy)(
|
|
663
|
+
() => Promise.resolve().then(() => (init_Render(), Render_exports)).then((m) => ({
|
|
664
|
+
default: m.RichTextRender
|
|
665
|
+
}))
|
|
666
|
+
);
|
|
604
667
|
return richtextKeys.reduce((acc, key) => {
|
|
605
|
-
acc[key] = /* @__PURE__ */ (0,
|
|
606
|
-
|
|
668
|
+
acc[key] = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react4.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(RichTextRenderFallback, { content: props[key] }), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
669
|
+
RichTextRender2,
|
|
607
670
|
{
|
|
608
671
|
content: props[key],
|
|
609
672
|
field: fields[key]
|
|
610
673
|
}
|
|
611
|
-
);
|
|
674
|
+
) });
|
|
612
675
|
return acc;
|
|
613
676
|
}, {});
|
|
614
|
-
}, [richtextKeys, props]);
|
|
615
|
-
return
|
|
677
|
+
}, [richtextKeys, props, fields]);
|
|
678
|
+
return richtextProps;
|
|
616
679
|
}
|
|
617
680
|
|
|
618
681
|
// components/SlotRender/server.tsx
|
|
619
|
-
var
|
|
620
|
-
var SlotRenderPure = (props) => /* @__PURE__ */ (0,
|
|
682
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
683
|
+
var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SlotRender, __spreadValues({}, props));
|
|
621
684
|
var Item = ({
|
|
622
685
|
config,
|
|
623
686
|
item,
|
|
624
687
|
metadata
|
|
625
688
|
}) => {
|
|
626
689
|
const Component = config.components[item.type];
|
|
627
|
-
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0,
|
|
628
|
-
const
|
|
629
|
-
return /* @__PURE__ */ (0,
|
|
690
|
+
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
691
|
+
const richtextProps = useRichtextProps(Component.fields, props);
|
|
692
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
630
693
|
Component.render,
|
|
631
|
-
__spreadProps(__spreadValues(__spreadValues({}, props),
|
|
694
|
+
__spreadProps(__spreadValues(__spreadValues({}, props), richtextProps), {
|
|
632
695
|
puck: __spreadProps(__spreadValues({}, props.puck), {
|
|
633
696
|
metadata: metadata || {}
|
|
634
697
|
})
|
|
@@ -638,11 +701,11 @@ var Item = ({
|
|
|
638
701
|
var SlotRender = (0, import_react5.forwardRef)(
|
|
639
702
|
function SlotRenderInternal({ className, style, content, config, metadata, as }, ref) {
|
|
640
703
|
const El = as != null ? as : "div";
|
|
641
|
-
return /* @__PURE__ */ (0,
|
|
704
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(El, { className, style, ref, children: content.map((item) => {
|
|
642
705
|
if (!config.components[item.type]) {
|
|
643
706
|
return null;
|
|
644
707
|
}
|
|
645
|
-
return /* @__PURE__ */ (0,
|
|
708
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
646
709
|
Item,
|
|
647
710
|
{
|
|
648
711
|
config,
|
|
@@ -656,7 +719,7 @@ var SlotRender = (0, import_react5.forwardRef)(
|
|
|
656
719
|
);
|
|
657
720
|
|
|
658
721
|
// components/ServerRender/index.tsx
|
|
659
|
-
var
|
|
722
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
660
723
|
function DropZoneRender({
|
|
661
724
|
zone,
|
|
662
725
|
data,
|
|
@@ -673,11 +736,11 @@ function DropZoneRender({
|
|
|
673
736
|
zoneCompound = `${areaId}:${zone}`;
|
|
674
737
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
|
675
738
|
}
|
|
676
|
-
return /* @__PURE__ */ (0,
|
|
739
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: content.map((item) => {
|
|
677
740
|
const Component = config.components[item.type];
|
|
678
741
|
const props = __spreadProps(__spreadValues({}, item.props), {
|
|
679
742
|
puck: {
|
|
680
|
-
renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0,
|
|
743
|
+
renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
681
744
|
DropZoneRender,
|
|
682
745
|
{
|
|
683
746
|
zone: zone2,
|
|
@@ -693,9 +756,9 @@ function DropZoneRender({
|
|
|
693
756
|
}
|
|
694
757
|
});
|
|
695
758
|
const renderItem = __spreadProps(__spreadValues({}, item), { props });
|
|
696
|
-
const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ (0,
|
|
759
|
+
const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
|
|
697
760
|
if (Component) {
|
|
698
|
-
return /* @__PURE__ */ (0,
|
|
761
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Component.render, __spreadValues({}, propsWithSlots), renderItem.props.id);
|
|
699
762
|
}
|
|
700
763
|
return null;
|
|
701
764
|
}) });
|
|
@@ -705,12 +768,12 @@ function Render({
|
|
|
705
768
|
data,
|
|
706
769
|
metadata = {}
|
|
707
770
|
}) {
|
|
708
|
-
var _a;
|
|
771
|
+
var _a, _b;
|
|
709
772
|
const rootProps = "props" in data.root ? data.root.props : data.root;
|
|
710
773
|
const title = rootProps.title || "";
|
|
711
774
|
const props = __spreadProps(__spreadValues({}, rootProps), {
|
|
712
775
|
puck: {
|
|
713
|
-
renderDropZone: ({ zone }) => /* @__PURE__ */ (0,
|
|
776
|
+
renderDropZone: ({ zone }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
714
777
|
DropZoneRender,
|
|
715
778
|
{
|
|
716
779
|
zone,
|
|
@@ -727,9 +790,10 @@ function Render({
|
|
|
727
790
|
editMode: false,
|
|
728
791
|
id: "puck-root"
|
|
729
792
|
});
|
|
730
|
-
const propsWithSlots = useSlots(config, { type: "root", props }, (props2) => /* @__PURE__ */ (0,
|
|
731
|
-
|
|
732
|
-
|
|
793
|
+
const propsWithSlots = useSlots(config, { type: "root", props }, (props2) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
|
|
794
|
+
const richtextProps = useRichtextProps((_a = config.root) == null ? void 0 : _a.fields, props);
|
|
795
|
+
if ((_b = config.root) == null ? void 0 : _b.render) {
|
|
796
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(config.root.render, __spreadProps(__spreadValues(__spreadValues({}, propsWithSlots), richtextProps), { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
733
797
|
DropZoneRender,
|
|
734
798
|
{
|
|
735
799
|
config,
|
|
@@ -739,7 +803,7 @@ function Render({
|
|
|
739
803
|
}
|
|
740
804
|
) }));
|
|
741
805
|
}
|
|
742
|
-
return /* @__PURE__ */ (0,
|
|
806
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
743
807
|
DropZoneRender,
|
|
744
808
|
{
|
|
745
809
|
config,
|
|
@@ -982,7 +1046,8 @@ init_react_import();
|
|
|
982
1046
|
var defaultViewports = [
|
|
983
1047
|
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
|
984
1048
|
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
|
985
|
-
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
|
1049
|
+
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" },
|
|
1050
|
+
{ width: "100%", height: "auto", icon: "FullWidth", label: "Full-width" }
|
|
986
1051
|
];
|
|
987
1052
|
|
|
988
1053
|
// store/default-app-state.ts
|
|
@@ -1004,7 +1069,8 @@ var defaultAppState = {
|
|
|
1004
1069
|
options: [],
|
|
1005
1070
|
controlsVisible: true
|
|
1006
1071
|
},
|
|
1007
|
-
field: { focus: null }
|
|
1072
|
+
field: { focus: null },
|
|
1073
|
+
plugin: { current: null }
|
|
1008
1074
|
},
|
|
1009
1075
|
indexes: {
|
|
1010
1076
|
nodes: {},
|
|
@@ -1052,9 +1118,28 @@ var stripSlots = (data, config) => {
|
|
|
1052
1118
|
|
|
1053
1119
|
// lib/data/flatten-node.ts
|
|
1054
1120
|
var { flatten: flatten2, unflatten } = import_flat.default;
|
|
1121
|
+
function isEmptyArrayOrObject(val) {
|
|
1122
|
+
if (Array.isArray(val)) {
|
|
1123
|
+
return val.length === 0;
|
|
1124
|
+
}
|
|
1125
|
+
if (val != null && Object.prototype.toString.call(val) === "[object Object]") {
|
|
1126
|
+
return Object.keys(val).length === 0;
|
|
1127
|
+
}
|
|
1128
|
+
return false;
|
|
1129
|
+
}
|
|
1130
|
+
function stripEmptyObjects(props) {
|
|
1131
|
+
const result = {};
|
|
1132
|
+
for (const key in props) {
|
|
1133
|
+
if (!Object.prototype.hasOwnProperty.call(props, key)) continue;
|
|
1134
|
+
const val = props[key];
|
|
1135
|
+
if (isEmptyArrayOrObject(val)) continue;
|
|
1136
|
+
result[key] = val;
|
|
1137
|
+
}
|
|
1138
|
+
return result;
|
|
1139
|
+
}
|
|
1055
1140
|
var flattenNode = (node, config) => {
|
|
1056
1141
|
return __spreadProps(__spreadValues({}, node), {
|
|
1057
|
-
props: flatten2(stripSlots(node, config).props)
|
|
1142
|
+
props: stripEmptyObjects(flatten2(stripSlots(node, config).props))
|
|
1058
1143
|
});
|
|
1059
1144
|
};
|
|
1060
1145
|
|