@orion-studios/payload-studio 0.6.0-beta.45 → 0.6.0-beta.46
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/builder-v2/client.d.mts +5 -0
- package/dist/builder-v2/client.d.ts +5 -0
- package/dist/builder-v2/client.js +373 -24
- package/dist/builder-v2/client.mjs +373 -24
- package/dist/builder-v2/index.d.mts +81 -1
- package/dist/builder-v2/index.d.ts +81 -1
- package/dist/builder-v2/index.js +280 -7
- package/dist/builder-v2/index.mjs +275 -6
- package/dist/builder-v2/styles.css +206 -3
- package/package.json +1 -1
|
@@ -15,18 +15,76 @@ type BuilderV2ValidationIssue = {
|
|
|
15
15
|
path: string;
|
|
16
16
|
severity: 'error' | 'warning';
|
|
17
17
|
};
|
|
18
|
+
type BuilderV2Role = 'admin' | 'client' | 'developer' | 'editor';
|
|
19
|
+
type BuilderV2PermissionSet = {
|
|
20
|
+
canEditCustomCode?: boolean;
|
|
21
|
+
canManageGlobalStyles?: boolean;
|
|
22
|
+
canManageReusableSections?: boolean;
|
|
23
|
+
canPublish?: boolean;
|
|
24
|
+
canUseEmbeds?: boolean;
|
|
25
|
+
role?: BuilderV2Role;
|
|
26
|
+
};
|
|
18
27
|
type BuilderV2CompiledOutput = {
|
|
19
28
|
css: string;
|
|
20
29
|
dynamicComponents: BuilderV2DynamicComponentInstance[];
|
|
21
30
|
html: string;
|
|
31
|
+
validationIssues?: BuilderV2ValidationIssue[];
|
|
22
32
|
};
|
|
23
33
|
type BuilderV2ProjectData = Record<string, unknown>;
|
|
34
|
+
type BuilderV2ThemeTokens = {
|
|
35
|
+
buttons?: Record<string, unknown>;
|
|
36
|
+
colors?: Record<string, string>;
|
|
37
|
+
fonts?: Record<string, string>;
|
|
38
|
+
radii?: Record<string, string>;
|
|
39
|
+
shadows?: Record<string, string>;
|
|
40
|
+
spacing?: Record<string, string>;
|
|
41
|
+
typography?: Record<string, unknown>;
|
|
42
|
+
};
|
|
43
|
+
type BuilderV2PageTreeNode = {
|
|
44
|
+
children?: BuilderV2PageTreeNode[];
|
|
45
|
+
id: number | string;
|
|
46
|
+
parentId?: number | string | null;
|
|
47
|
+
path: string;
|
|
48
|
+
slug: string;
|
|
49
|
+
status?: 'draft' | 'published';
|
|
50
|
+
title: string;
|
|
51
|
+
};
|
|
52
|
+
type BuilderV2VersionSnapshot = {
|
|
53
|
+
compiledCss?: string;
|
|
54
|
+
compiledHtml?: string;
|
|
55
|
+
createdAt: string;
|
|
56
|
+
id: string;
|
|
57
|
+
label: string;
|
|
58
|
+
projectData?: BuilderV2ProjectData | null;
|
|
59
|
+
published?: boolean;
|
|
60
|
+
};
|
|
61
|
+
type BuilderV2ReusableSection = {
|
|
62
|
+
category?: string;
|
|
63
|
+
id: string;
|
|
64
|
+
name: string;
|
|
65
|
+
projectData: BuilderV2ProjectData;
|
|
66
|
+
thumbnail?: string;
|
|
67
|
+
};
|
|
68
|
+
type BuilderV2EditorMeta = {
|
|
69
|
+
pageTree?: BuilderV2PageTreeNode[];
|
|
70
|
+
permissions?: BuilderV2PermissionSet;
|
|
71
|
+
themeTokens?: BuilderV2ThemeTokens;
|
|
72
|
+
};
|
|
24
73
|
type BuilderV2PageData = {
|
|
74
|
+
builderAutosaveProjectData?: BuilderV2ProjectData | null;
|
|
25
75
|
builderDynamicComponents?: BuilderV2DynamicComponentInstance[];
|
|
76
|
+
builderLastPublishedAt?: string;
|
|
77
|
+
builderLastSavedAt?: string;
|
|
78
|
+
builderLockedAreas?: string[];
|
|
26
79
|
builderMode?: string;
|
|
27
80
|
builderProjectData?: BuilderV2ProjectData | null;
|
|
28
81
|
builderPublishedProjectData?: BuilderV2ProjectData | null;
|
|
82
|
+
builderPublishedSnapshot?: BuilderV2VersionSnapshot | null;
|
|
83
|
+
builderReusableSections?: BuilderV2ReusableSection[];
|
|
84
|
+
builderSeo?: Record<string, unknown> | null;
|
|
85
|
+
builderThemeTokens?: BuilderV2ThemeTokens | null;
|
|
29
86
|
builderValidationIssues?: BuilderV2ValidationIssue[];
|
|
87
|
+
builderVersions?: BuilderV2VersionSnapshot[];
|
|
30
88
|
compiledCss?: string;
|
|
31
89
|
compiledHtml?: string;
|
|
32
90
|
id?: number | string;
|
|
@@ -70,11 +128,13 @@ type BuilderV2TraitDefinition = {
|
|
|
70
128
|
type BuilderV2ProjectAdapter = {
|
|
71
129
|
components?: Record<string, BuilderV2ProjectComponentDefinition | BuilderV2RuntimeComponent>;
|
|
72
130
|
dataProviders?: Record<string, unknown>;
|
|
131
|
+
defaultThemeTokens?: BuilderV2ThemeTokens;
|
|
73
132
|
id: string;
|
|
74
133
|
label?: string;
|
|
75
134
|
themeTokens?: Record<string, unknown>;
|
|
76
135
|
};
|
|
77
136
|
type BuilderV2EditorInitialData = {
|
|
137
|
+
meta?: BuilderV2EditorMeta;
|
|
78
138
|
projectData?: BuilderV2ProjectData | null;
|
|
79
139
|
title?: string;
|
|
80
140
|
};
|
|
@@ -145,6 +205,19 @@ declare const createBuilderV2PageService: ({ collectionSlug, payload, user, }: C
|
|
|
145
205
|
declare const createEmptyBuilderV2ProjectData: (title?: string) => BuilderV2ProjectData;
|
|
146
206
|
declare const normalizeBuilderV2ProjectData: (value: unknown, fallbackTitle?: string) => BuilderV2ProjectData;
|
|
147
207
|
|
|
208
|
+
type PageLike = {
|
|
209
|
+
id: number | string;
|
|
210
|
+
parent?: number | string | {
|
|
211
|
+
id?: number | string;
|
|
212
|
+
} | null;
|
|
213
|
+
parentId?: number | string | null;
|
|
214
|
+
path?: string | null;
|
|
215
|
+
slug?: string | null;
|
|
216
|
+
title?: string | null;
|
|
217
|
+
_status?: 'draft' | 'published';
|
|
218
|
+
};
|
|
219
|
+
declare const buildBuilderV2PageTree: (pages: PageLike[]) => BuilderV2PageTreeNode[];
|
|
220
|
+
|
|
148
221
|
declare function BuilderPageRuntime({ adapter, className, page }: BuilderV2RuntimeProps): react_jsx_runtime.JSX.Element;
|
|
149
222
|
|
|
150
223
|
declare const parseBuilderV2DynamicComponents: (html: string) => BuilderV2DynamicComponentInstance[];
|
|
@@ -152,5 +225,12 @@ declare const splitBuilderV2HtmlIntoChunks: (html: string) => BuilderV2Renderabl
|
|
|
152
225
|
|
|
153
226
|
declare const sanitizeBuilderHtml: (value: unknown) => string;
|
|
154
227
|
declare const sanitizeBuilderCss: (value: unknown) => string;
|
|
228
|
+
declare const scopeBuilderCss: (value: unknown, scope?: string) => string;
|
|
229
|
+
|
|
230
|
+
declare const validateBuilderV2Output: (input: {
|
|
231
|
+
css?: unknown;
|
|
232
|
+
html?: unknown;
|
|
233
|
+
}) => BuilderV2ValidationIssue[];
|
|
234
|
+
declare const hasBlockingBuilderV2Issues: (issues: BuilderV2ValidationIssue[]) => boolean;
|
|
155
235
|
|
|
156
|
-
export { BuilderPageRuntime, type BuilderV2Asset, type BuilderV2CompiledOutput, type BuilderV2DynamicComponentInstance, type BuilderV2EditorInitialData, type BuilderV2FieldOptions, type BuilderV2Mode, type BuilderV2PageData, type BuilderV2PagePayloadDoc, type BuilderV2ProjectAdapter, type BuilderV2ProjectComponentDefinition, type BuilderV2ProjectData, type BuilderV2RenderResult, type BuilderV2RenderableChunk, type BuilderV2RuntimeComponent, type BuilderV2RuntimeComponentProps, type BuilderV2RuntimeProps, type BuilderV2TraitDefinition, type BuilderV2ValidationIssue, type CreateBuilderV2PageServiceArgs, type SaveBuilderV2PageInput, appendBuilderV2PageFields, compileBuilderV2Output, createBuilderV2PageFields, createBuilderV2PageService, createEmptyBuilderV2ProjectData, normalizeBuilderV2ProjectData, parseBuilderV2DynamicComponents, sanitizeBuilderCss, sanitizeBuilderHtml, splitBuilderV2HtmlIntoChunks, toBuilderV2EditorInitialData };
|
|
236
|
+
export { BuilderPageRuntime, type BuilderV2Asset, type BuilderV2CompiledOutput, type BuilderV2DynamicComponentInstance, type BuilderV2EditorInitialData, type BuilderV2FieldOptions, type BuilderV2Mode, type BuilderV2PageData, type BuilderV2PagePayloadDoc, type BuilderV2PageTreeNode, type BuilderV2PermissionSet, type BuilderV2ProjectAdapter, type BuilderV2ProjectComponentDefinition, type BuilderV2ProjectData, type BuilderV2RenderResult, type BuilderV2RenderableChunk, type BuilderV2RuntimeComponent, type BuilderV2RuntimeComponentProps, type BuilderV2RuntimeProps, type BuilderV2ThemeTokens, type BuilderV2TraitDefinition, type BuilderV2ValidationIssue, type BuilderV2VersionSnapshot, type CreateBuilderV2PageServiceArgs, type SaveBuilderV2PageInput, appendBuilderV2PageFields, buildBuilderV2PageTree, compileBuilderV2Output, createBuilderV2PageFields, createBuilderV2PageService, createEmptyBuilderV2ProjectData, hasBlockingBuilderV2Issues, normalizeBuilderV2ProjectData, parseBuilderV2DynamicComponents, sanitizeBuilderCss, sanitizeBuilderHtml, scopeBuilderCss, splitBuilderV2HtmlIntoChunks, toBuilderV2EditorInitialData, validateBuilderV2Output };
|
package/dist/builder-v2/index.js
CHANGED
|
@@ -32,16 +32,20 @@ var builder_v2_exports = {};
|
|
|
32
32
|
__export(builder_v2_exports, {
|
|
33
33
|
BuilderPageRuntime: () => BuilderPageRuntime,
|
|
34
34
|
appendBuilderV2PageFields: () => appendBuilderV2PageFields,
|
|
35
|
+
buildBuilderV2PageTree: () => buildBuilderV2PageTree,
|
|
35
36
|
compileBuilderV2Output: () => compileBuilderV2Output,
|
|
36
37
|
createBuilderV2PageFields: () => createBuilderV2PageFields,
|
|
37
38
|
createBuilderV2PageService: () => createBuilderV2PageService,
|
|
38
39
|
createEmptyBuilderV2ProjectData: () => createEmptyBuilderV2ProjectData,
|
|
40
|
+
hasBlockingBuilderV2Issues: () => hasBlockingBuilderV2Issues,
|
|
39
41
|
normalizeBuilderV2ProjectData: () => normalizeBuilderV2ProjectData,
|
|
40
42
|
parseBuilderV2DynamicComponents: () => parseBuilderV2DynamicComponents,
|
|
41
43
|
sanitizeBuilderCss: () => sanitizeBuilderCss,
|
|
42
44
|
sanitizeBuilderHtml: () => sanitizeBuilderHtml,
|
|
45
|
+
scopeBuilderCss: () => scopeBuilderCss,
|
|
43
46
|
splitBuilderV2HtmlIntoChunks: () => splitBuilderV2HtmlIntoChunks,
|
|
44
|
-
toBuilderV2EditorInitialData: () => toBuilderV2EditorInitialData
|
|
47
|
+
toBuilderV2EditorInitialData: () => toBuilderV2EditorInitialData,
|
|
48
|
+
validateBuilderV2Output: () => validateBuilderV2Output
|
|
45
49
|
});
|
|
46
50
|
module.exports = __toCommonJS(builder_v2_exports);
|
|
47
51
|
|
|
@@ -75,6 +79,13 @@ var createBuilderV2PageFields = (options = {}) => {
|
|
|
75
79
|
},
|
|
76
80
|
hidden
|
|
77
81
|
),
|
|
82
|
+
withHiddenAdmin(
|
|
83
|
+
{
|
|
84
|
+
name: "builderAutosaveProjectData",
|
|
85
|
+
type: "json"
|
|
86
|
+
},
|
|
87
|
+
hidden
|
|
88
|
+
),
|
|
78
89
|
withHiddenAdmin(
|
|
79
90
|
{
|
|
80
91
|
name: "builderPublishedProjectData",
|
|
@@ -109,6 +120,62 @@ var createBuilderV2PageFields = (options = {}) => {
|
|
|
109
120
|
type: "json"
|
|
110
121
|
},
|
|
111
122
|
hidden
|
|
123
|
+
),
|
|
124
|
+
withHiddenAdmin(
|
|
125
|
+
{
|
|
126
|
+
name: "builderVersions",
|
|
127
|
+
type: "json"
|
|
128
|
+
},
|
|
129
|
+
hidden
|
|
130
|
+
),
|
|
131
|
+
withHiddenAdmin(
|
|
132
|
+
{
|
|
133
|
+
name: "builderPublishedSnapshot",
|
|
134
|
+
type: "json"
|
|
135
|
+
},
|
|
136
|
+
hidden
|
|
137
|
+
),
|
|
138
|
+
withHiddenAdmin(
|
|
139
|
+
{
|
|
140
|
+
name: "builderReusableSections",
|
|
141
|
+
type: "json"
|
|
142
|
+
},
|
|
143
|
+
hidden
|
|
144
|
+
),
|
|
145
|
+
withHiddenAdmin(
|
|
146
|
+
{
|
|
147
|
+
name: "builderThemeTokens",
|
|
148
|
+
type: "json"
|
|
149
|
+
},
|
|
150
|
+
hidden
|
|
151
|
+
),
|
|
152
|
+
withHiddenAdmin(
|
|
153
|
+
{
|
|
154
|
+
name: "builderLockedAreas",
|
|
155
|
+
type: "json"
|
|
156
|
+
},
|
|
157
|
+
hidden
|
|
158
|
+
),
|
|
159
|
+
withHiddenAdmin(
|
|
160
|
+
{
|
|
161
|
+
name: "builderSeo",
|
|
162
|
+
type: "json"
|
|
163
|
+
},
|
|
164
|
+
hidden
|
|
165
|
+
),
|
|
166
|
+
withHiddenAdmin(
|
|
167
|
+
{
|
|
168
|
+
name: "builderLastSavedAt",
|
|
169
|
+
type: "date"
|
|
170
|
+
},
|
|
171
|
+
hidden
|
|
172
|
+
),
|
|
173
|
+
withHiddenAdmin(
|
|
174
|
+
{
|
|
175
|
+
name: "builderLastPublishedAt",
|
|
176
|
+
type: "date"
|
|
177
|
+
},
|
|
178
|
+
hidden
|
|
112
179
|
)
|
|
113
180
|
];
|
|
114
181
|
};
|
|
@@ -253,15 +320,119 @@ var sanitizeBuilderCss = (value) => {
|
|
|
253
320
|
}
|
|
254
321
|
return value.replace(/@import\s+[^;]+;/gi, "").replace(/expression\s*\(/gi, "").replace(/javascript\s*:/gi, "");
|
|
255
322
|
};
|
|
323
|
+
var scopeSelector = (selector, scope) => selector.split(",").map((part) => {
|
|
324
|
+
const trimmed = part.trim();
|
|
325
|
+
if (!trimmed || trimmed.startsWith(scope) || trimmed.startsWith("@")) {
|
|
326
|
+
return trimmed;
|
|
327
|
+
}
|
|
328
|
+
if (/^(html|body|:root)\b/i.test(trimmed)) {
|
|
329
|
+
return trimmed.replace(/^(html|body|:root)\b/i, scope);
|
|
330
|
+
}
|
|
331
|
+
return `${scope} ${trimmed}`;
|
|
332
|
+
}).filter(Boolean).join(", ");
|
|
333
|
+
var scopeBuilderCss = (value, scope = ".orion-builder-v2-runtime") => {
|
|
334
|
+
const css = sanitizeBuilderCss(value);
|
|
335
|
+
if (!css) {
|
|
336
|
+
return "";
|
|
337
|
+
}
|
|
338
|
+
let output = "";
|
|
339
|
+
let cursor = 0;
|
|
340
|
+
const rulePattern = /([^{}]+)\{/g;
|
|
341
|
+
let match;
|
|
342
|
+
while ((match = rulePattern.exec(css)) !== null) {
|
|
343
|
+
const selectorStart = match.index;
|
|
344
|
+
const selector = match[1];
|
|
345
|
+
output += css.slice(cursor, selectorStart);
|
|
346
|
+
const trimmedSelector = selector.trim();
|
|
347
|
+
if (trimmedSelector.startsWith("@keyframes") || trimmedSelector.startsWith("@font-face") || trimmedSelector.startsWith("@page")) {
|
|
348
|
+
output += `${selector}{`;
|
|
349
|
+
} else if (trimmedSelector.startsWith("@media") || trimmedSelector.startsWith("@supports")) {
|
|
350
|
+
output += `${selector}{`;
|
|
351
|
+
} else {
|
|
352
|
+
output += `${scopeSelector(selector, scope)} {`;
|
|
353
|
+
}
|
|
354
|
+
cursor = rulePattern.lastIndex;
|
|
355
|
+
}
|
|
356
|
+
output += css.slice(cursor);
|
|
357
|
+
return output;
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
// src/builder-v2/validation.ts
|
|
361
|
+
var hasMatch = (value, pattern) => pattern.test(value);
|
|
362
|
+
var validateBuilderV2Output = (input) => {
|
|
363
|
+
const html = typeof input.html === "string" ? input.html : "";
|
|
364
|
+
const css = typeof input.css === "string" ? input.css : "";
|
|
365
|
+
const issues = [];
|
|
366
|
+
if (!html.trim()) {
|
|
367
|
+
issues.push({
|
|
368
|
+
code: "empty-page",
|
|
369
|
+
message: "This page has no rendered content.",
|
|
370
|
+
path: "compiledHtml",
|
|
371
|
+
severity: "error"
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
if (!hasMatch(html, /<h1\b/i)) {
|
|
375
|
+
issues.push({
|
|
376
|
+
code: "missing-h1",
|
|
377
|
+
message: "Add one H1 so the published page has a clear primary heading.",
|
|
378
|
+
path: "compiledHtml",
|
|
379
|
+
severity: "warning"
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
if (hasMatch(html, /\son[a-z]+\s*=/i)) {
|
|
383
|
+
issues.push({
|
|
384
|
+
code: "inline-event-handler",
|
|
385
|
+
message: "Inline event handlers are not allowed in published builder HTML.",
|
|
386
|
+
path: "compiledHtml",
|
|
387
|
+
severity: "error"
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
if (hasMatch(html, /<(script|object|embed)\b/i)) {
|
|
391
|
+
issues.push({
|
|
392
|
+
code: "unsafe-element",
|
|
393
|
+
message: "Script, object, and embed tags are not allowed in builder content.",
|
|
394
|
+
path: "compiledHtml",
|
|
395
|
+
severity: "error"
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
if (hasMatch(html, /\b(?:href|src)=["']\s*javascript:/i)) {
|
|
399
|
+
issues.push({
|
|
400
|
+
code: "unsafe-url",
|
|
401
|
+
message: "Links and media cannot use javascript URLs.",
|
|
402
|
+
path: "compiledHtml",
|
|
403
|
+
severity: "error"
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
if (hasMatch(css, /@import\s/i)) {
|
|
407
|
+
issues.push({
|
|
408
|
+
code: "css-import",
|
|
409
|
+
message: "CSS imports are removed at publish time. Use the site font and theme managers instead.",
|
|
410
|
+
path: "compiledCss",
|
|
411
|
+
severity: "warning"
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
if (hasMatch(css, /position\s*:\s*fixed/i)) {
|
|
415
|
+
issues.push({
|
|
416
|
+
code: "fixed-position",
|
|
417
|
+
message: "Fixed positioning can cover site navigation or dialogs. Review this before publishing.",
|
|
418
|
+
path: "compiledCss",
|
|
419
|
+
severity: "warning"
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
return issues;
|
|
423
|
+
};
|
|
424
|
+
var hasBlockingBuilderV2Issues = (issues) => issues.some((issue) => issue.severity === "error");
|
|
256
425
|
|
|
257
426
|
// src/builder-v2/payload/compile.ts
|
|
258
427
|
var compileBuilderV2Output = (input) => {
|
|
259
428
|
const html = sanitizeBuilderHtml(input.html);
|
|
260
|
-
const css =
|
|
429
|
+
const css = scopeBuilderCss(input.css);
|
|
430
|
+
const validationIssues = validateBuilderV2Output({ css: input.css, html: input.html });
|
|
261
431
|
return {
|
|
262
432
|
css,
|
|
263
433
|
dynamicComponents: parseBuilderV2DynamicComponents(html),
|
|
264
|
-
html
|
|
434
|
+
html,
|
|
435
|
+
validationIssues
|
|
265
436
|
};
|
|
266
437
|
};
|
|
267
438
|
|
|
@@ -309,6 +480,25 @@ var normalizeBuilderV2ProjectData = (value, fallbackTitle = "Untitled Page") =>
|
|
|
309
480
|
|
|
310
481
|
// src/builder-v2/payload/pageService.ts
|
|
311
482
|
var pageTitle = (page) => typeof page.title === "string" && page.title.trim().length > 0 ? page.title : "Untitled Page";
|
|
483
|
+
var normalizeVersions = (value) => Array.isArray(value) ? value.filter((item) => Boolean(item && typeof item === "object")) : [];
|
|
484
|
+
var createVersionSnapshot = ({
|
|
485
|
+
compiled,
|
|
486
|
+
label,
|
|
487
|
+
projectData,
|
|
488
|
+
published = false
|
|
489
|
+
}) => {
|
|
490
|
+
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
491
|
+
return {
|
|
492
|
+
compiledCss: compiled.css,
|
|
493
|
+
compiledHtml: compiled.html,
|
|
494
|
+
createdAt,
|
|
495
|
+
id: `builder-v2-${createdAt.replace(/[^0-9]/g, "")}`,
|
|
496
|
+
label,
|
|
497
|
+
projectData,
|
|
498
|
+
published
|
|
499
|
+
};
|
|
500
|
+
};
|
|
501
|
+
var appendVersionSnapshot = (current, snapshot) => [snapshot, ...normalizeVersions(current)].slice(0, 50);
|
|
312
502
|
var toBuilderV2EditorInitialData = (page) => ({
|
|
313
503
|
projectData: normalizeBuilderV2ProjectData(
|
|
314
504
|
page.builderProjectData || page.builderPublishedProjectData,
|
|
@@ -338,14 +528,33 @@ var createBuilderV2PageService = ({
|
|
|
338
528
|
},
|
|
339
529
|
saveDraft: async (pageID, input) => {
|
|
340
530
|
const compiled = compileBuilderV2Output(input.compiled);
|
|
531
|
+
const existing = await payload.findByID({
|
|
532
|
+
collection: collectionSlug,
|
|
533
|
+
depth: 0,
|
|
534
|
+
draft: true,
|
|
535
|
+
id: pageID,
|
|
536
|
+
overrideAccess: false,
|
|
537
|
+
user
|
|
538
|
+
});
|
|
539
|
+
const validationIssues = input.validationIssues || compiled.validationIssues || [];
|
|
341
540
|
await payload.update({
|
|
342
541
|
collection: collectionSlug,
|
|
343
542
|
data: {
|
|
344
543
|
_status: "draft",
|
|
544
|
+
builderAutosaveProjectData: null,
|
|
345
545
|
builderDynamicComponents: compiled.dynamicComponents,
|
|
546
|
+
builderLastSavedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
346
547
|
builderMode: "grapes-v2",
|
|
347
548
|
builderProjectData: input.projectData,
|
|
348
|
-
builderValidationIssues:
|
|
549
|
+
builderValidationIssues: validationIssues,
|
|
550
|
+
builderVersions: appendVersionSnapshot(
|
|
551
|
+
existing.builderVersions,
|
|
552
|
+
createVersionSnapshot({
|
|
553
|
+
compiled,
|
|
554
|
+
label: "Draft saved",
|
|
555
|
+
projectData: input.projectData
|
|
556
|
+
})
|
|
557
|
+
),
|
|
349
558
|
compiledCss: compiled.css,
|
|
350
559
|
compiledHtml: compiled.html,
|
|
351
560
|
...input.title ? { title: input.title } : {}
|
|
@@ -362,15 +571,35 @@ var createBuilderV2PageService = ({
|
|
|
362
571
|
},
|
|
363
572
|
publish: async (pageID, input) => {
|
|
364
573
|
const compiled = compileBuilderV2Output(input.compiled);
|
|
574
|
+
const existing = await payload.findByID({
|
|
575
|
+
collection: collectionSlug,
|
|
576
|
+
depth: 0,
|
|
577
|
+
draft: true,
|
|
578
|
+
id: pageID,
|
|
579
|
+
overrideAccess: false,
|
|
580
|
+
user
|
|
581
|
+
});
|
|
582
|
+
const validationIssues = input.validationIssues || compiled.validationIssues || [];
|
|
583
|
+
const snapshot = createVersionSnapshot({
|
|
584
|
+
compiled,
|
|
585
|
+
label: "Published",
|
|
586
|
+
projectData: input.projectData,
|
|
587
|
+
published: true
|
|
588
|
+
});
|
|
365
589
|
await payload.update({
|
|
366
590
|
collection: collectionSlug,
|
|
367
591
|
data: {
|
|
368
592
|
_status: "published",
|
|
593
|
+
builderAutosaveProjectData: null,
|
|
369
594
|
builderDynamicComponents: compiled.dynamicComponents,
|
|
595
|
+
builderLastPublishedAt: snapshot.createdAt,
|
|
596
|
+
builderLastSavedAt: snapshot.createdAt,
|
|
370
597
|
builderMode: "grapes-v2",
|
|
371
598
|
builderProjectData: input.projectData,
|
|
372
599
|
builderPublishedProjectData: input.projectData,
|
|
373
|
-
|
|
600
|
+
builderPublishedSnapshot: snapshot,
|
|
601
|
+
builderValidationIssues: validationIssues,
|
|
602
|
+
builderVersions: appendVersionSnapshot(existing.builderVersions, snapshot),
|
|
374
603
|
compiledCss: compiled.css,
|
|
375
604
|
compiledHtml: compiled.html,
|
|
376
605
|
...input.title ? { title: input.title } : {}
|
|
@@ -387,6 +616,46 @@ var createBuilderV2PageService = ({
|
|
|
387
616
|
}
|
|
388
617
|
});
|
|
389
618
|
|
|
619
|
+
// src/builder-v2/pageTree.ts
|
|
620
|
+
var relationId = (value) => {
|
|
621
|
+
if (typeof value === "number" || typeof value === "string") {
|
|
622
|
+
return value;
|
|
623
|
+
}
|
|
624
|
+
if (value && typeof value === "object") {
|
|
625
|
+
const id = value.id;
|
|
626
|
+
return typeof id === "number" || typeof id === "string" ? id : null;
|
|
627
|
+
}
|
|
628
|
+
return null;
|
|
629
|
+
};
|
|
630
|
+
var buildBuilderV2PageTree = (pages) => {
|
|
631
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
632
|
+
const roots = [];
|
|
633
|
+
pages.forEach((page) => {
|
|
634
|
+
nodes.set(page.id, {
|
|
635
|
+
children: [],
|
|
636
|
+
id: page.id,
|
|
637
|
+
parentId: page.parentId ?? relationId(page.parent),
|
|
638
|
+
path: page.path || (page.slug ? `/${page.slug}` : "/"),
|
|
639
|
+
slug: page.slug || "",
|
|
640
|
+
status: page._status,
|
|
641
|
+
title: page.title || "Untitled page"
|
|
642
|
+
});
|
|
643
|
+
});
|
|
644
|
+
nodes.forEach((node) => {
|
|
645
|
+
if (node.parentId && nodes.has(node.parentId)) {
|
|
646
|
+
nodes.get(node.parentId)?.children?.push(node);
|
|
647
|
+
} else {
|
|
648
|
+
roots.push(node);
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
const sortNodes = (items) => {
|
|
652
|
+
items.sort((a, b) => a.path.localeCompare(b.path));
|
|
653
|
+
items.forEach((item) => sortNodes(item.children || []));
|
|
654
|
+
};
|
|
655
|
+
sortNodes(roots);
|
|
656
|
+
return roots;
|
|
657
|
+
};
|
|
658
|
+
|
|
390
659
|
// src/builder-v2/runtime/BuilderPageRuntime.tsx
|
|
391
660
|
var import_react = require("react");
|
|
392
661
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -402,7 +671,7 @@ var resolveRuntimeComponent = (adapter, type) => {
|
|
|
402
671
|
};
|
|
403
672
|
function BuilderPageRuntime({ adapter, className, page }) {
|
|
404
673
|
const html = sanitizeBuilderHtml(page.compiledHtml);
|
|
405
|
-
const css =
|
|
674
|
+
const css = scopeBuilderCss(page.compiledCss);
|
|
406
675
|
const chunks = splitBuilderV2HtmlIntoChunks(html);
|
|
407
676
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: ["orion-builder-v2-runtime", className].filter(Boolean).join(" "), children: [
|
|
408
677
|
css ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { dangerouslySetInnerHTML: { __html: css } }) : null,
|
|
@@ -436,14 +705,18 @@ function BuilderPageRuntime({ adapter, className, page }) {
|
|
|
436
705
|
0 && (module.exports = {
|
|
437
706
|
BuilderPageRuntime,
|
|
438
707
|
appendBuilderV2PageFields,
|
|
708
|
+
buildBuilderV2PageTree,
|
|
439
709
|
compileBuilderV2Output,
|
|
440
710
|
createBuilderV2PageFields,
|
|
441
711
|
createBuilderV2PageService,
|
|
442
712
|
createEmptyBuilderV2ProjectData,
|
|
713
|
+
hasBlockingBuilderV2Issues,
|
|
443
714
|
normalizeBuilderV2ProjectData,
|
|
444
715
|
parseBuilderV2DynamicComponents,
|
|
445
716
|
sanitizeBuilderCss,
|
|
446
717
|
sanitizeBuilderHtml,
|
|
718
|
+
scopeBuilderCss,
|
|
447
719
|
splitBuilderV2HtmlIntoChunks,
|
|
448
|
-
toBuilderV2EditorInitialData
|
|
720
|
+
toBuilderV2EditorInitialData,
|
|
721
|
+
validateBuilderV2Output
|
|
449
722
|
});
|