@orion-studios/payload-studio 0.6.0-beta.10 → 0.6.0-beta.103
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/admin/client.js +2073 -610
- package/dist/admin/client.mjs +2048 -587
- package/dist/admin/index.d.mts +2 -2
- package/dist/admin/index.d.ts +2 -2
- package/dist/admin/index.js +129 -16
- package/dist/admin/index.mjs +1 -1
- package/dist/admin-app/client.js +2 -4
- package/dist/admin-app/client.mjs +1 -1
- package/dist/admin-app/index.d.mts +2 -2
- package/dist/admin-app/index.d.ts +2 -2
- package/dist/admin-app/styles.css +316 -3
- package/dist/admin.css +98 -2
- package/dist/builder-v2/client.d.mts +18 -0
- package/dist/builder-v2/client.d.ts +18 -0
- package/dist/builder-v2/client.js +3298 -0
- package/dist/builder-v2/client.mjs +3173 -0
- package/dist/builder-v2/index.d.mts +242 -0
- package/dist/builder-v2/index.d.ts +242 -0
- package/dist/builder-v2/index.js +805 -0
- package/dist/builder-v2/index.mjs +755 -0
- package/dist/builder-v2/styles.css +2365 -0
- package/dist/{chunk-KPIX7OSV.mjs → chunk-3ZKXHSG5.mjs} +2 -4
- package/dist/{chunk-PF3EBZXF.mjs → chunk-7ZMXZRBP.mjs} +39 -3
- package/dist/{chunk-WLOPFFN2.mjs → chunk-JC3UV74N.mjs} +129 -16
- package/dist/{chunk-XKUTZ7IU.mjs → chunk-NGLIA2OE.mjs} +53 -2
- package/dist/{chunk-OTHERBGX.mjs → chunk-ZADL33R6.mjs} +1 -1
- package/dist/{index-CkT_eyhK.d.ts → index-BV0vEGl6.d.ts} +3 -2
- package/dist/{index-Cv-6qnrw.d.mts → index-D5zrOdyv.d.mts} +3 -1
- package/dist/{index-52HdVLQq.d.ts → index-DAdN56fM.d.ts} +1 -1
- package/dist/{index-Bm2SaC3r.d.mts → index-DLfPOqYA.d.mts} +3 -2
- package/dist/{index-Crx_MtPw.d.ts → index-Dv-Alx4h.d.ts} +3 -1
- package/dist/{index-DEQC3Dwj.d.mts → index-G_uTNffQ.d.mts} +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +220 -20
- package/dist/index.mjs +4 -4
- package/dist/nextjs/index.js +39 -3
- package/dist/nextjs/index.mjs +2 -2
- package/dist/{sitePreviewTypes-BkHCWxNW.d.mts → sitePreviewTypes-BrJwGzJj.d.mts} +1 -1
- package/dist/{sitePreviewTypes-BkHCWxNW.d.ts → sitePreviewTypes-BrJwGzJj.d.ts} +1 -1
- package/dist/studio-pages/builder.css +66 -5
- package/dist/studio-pages/client.js +618 -73
- package/dist/studio-pages/client.mjs +641 -96
- package/dist/studio-pages/index.d.mts +1 -1
- package/dist/studio-pages/index.d.ts +1 -1
- package/dist/studio-pages/index.js +91 -4
- package/dist/studio-pages/index.mjs +2 -2
- package/package.json +23 -3
|
@@ -0,0 +1,3298 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
"use client";
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
+
|
|
32
|
+
// src/builder-v2/client.ts
|
|
33
|
+
var client_exports = {};
|
|
34
|
+
__export(client_exports, {
|
|
35
|
+
GrapesPageEditor: () => GrapesPageEditor
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(client_exports);
|
|
38
|
+
|
|
39
|
+
// src/builder-v2/editor/GrapesPageEditor.tsx
|
|
40
|
+
var import_react = require("react");
|
|
41
|
+
|
|
42
|
+
// src/shared/clientImageUploadOptimization.ts
|
|
43
|
+
var MAX_DIRECT_UPLOAD_BYTES = 4e6;
|
|
44
|
+
var extensionForMimeType = (mimeType) => {
|
|
45
|
+
switch (mimeType) {
|
|
46
|
+
case "image/webp":
|
|
47
|
+
return ".webp";
|
|
48
|
+
case "image/png":
|
|
49
|
+
return ".png";
|
|
50
|
+
default:
|
|
51
|
+
return ".jpg";
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var detectCanvasTransparency = (context, width, height) => {
|
|
55
|
+
try {
|
|
56
|
+
const { data } = context.getImageData(0, 0, width, height);
|
|
57
|
+
for (let index = 3; index < data.length; index += 4) {
|
|
58
|
+
if (data[index] < 255) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
} catch {
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
};
|
|
66
|
+
var resolveOutputMimeTypes = (sourceMime, hasTransparency) => {
|
|
67
|
+
const candidates = [];
|
|
68
|
+
if (hasTransparency) {
|
|
69
|
+
candidates.push("image/webp", "image/png");
|
|
70
|
+
} else if (sourceMime === "image/webp") {
|
|
71
|
+
candidates.push("image/webp", "image/jpeg");
|
|
72
|
+
} else if (sourceMime === "image/png") {
|
|
73
|
+
candidates.push("image/webp", "image/jpeg", "image/png");
|
|
74
|
+
} else {
|
|
75
|
+
candidates.push("image/jpeg", "image/webp");
|
|
76
|
+
}
|
|
77
|
+
return [...new Set(candidates)];
|
|
78
|
+
};
|
|
79
|
+
async function optimizeImageForUpload(file) {
|
|
80
|
+
if (!file.type.startsWith("image/")) {
|
|
81
|
+
return file;
|
|
82
|
+
}
|
|
83
|
+
const objectURL = URL.createObjectURL(file);
|
|
84
|
+
try {
|
|
85
|
+
const image = await new Promise((resolve, reject) => {
|
|
86
|
+
const nextImage = new Image();
|
|
87
|
+
nextImage.onload = () => resolve(nextImage);
|
|
88
|
+
nextImage.onerror = () => reject(new Error("Could not read image for upload optimization."));
|
|
89
|
+
nextImage.src = objectURL;
|
|
90
|
+
});
|
|
91
|
+
const canvas = document.createElement("canvas");
|
|
92
|
+
canvas.width = Math.max(1, image.width);
|
|
93
|
+
canvas.height = Math.max(1, image.height);
|
|
94
|
+
const context = canvas.getContext("2d");
|
|
95
|
+
if (!context) {
|
|
96
|
+
return file;
|
|
97
|
+
}
|
|
98
|
+
context.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
99
|
+
const sourceMime = file.type.toLowerCase();
|
|
100
|
+
const hasTransparency = detectCanvasTransparency(context, canvas.width, canvas.height);
|
|
101
|
+
const outputMimes = resolveOutputMimeTypes(sourceMime, hasTransparency);
|
|
102
|
+
const qualityPasses = [0.82, 0.74, 0.66, 0.58, 0.5, 0.42, 0.36, 0.3, 0.26];
|
|
103
|
+
let bestFile = null;
|
|
104
|
+
for (const outputMime of outputMimes) {
|
|
105
|
+
const passes = outputMime === "image/png" ? [void 0] : qualityPasses;
|
|
106
|
+
for (const quality of passes) {
|
|
107
|
+
const blob = await new Promise((resolve) => {
|
|
108
|
+
canvas.toBlob((value) => resolve(value), outputMime, quality);
|
|
109
|
+
});
|
|
110
|
+
if (!blob) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
const optimizedName = file.name.replace(/\.[^/.]+$/, extensionForMimeType(outputMime));
|
|
114
|
+
const optimized = new File([blob], optimizedName, {
|
|
115
|
+
lastModified: Date.now(),
|
|
116
|
+
type: outputMime
|
|
117
|
+
});
|
|
118
|
+
if (!bestFile || optimized.size < bestFile.size) {
|
|
119
|
+
bestFile = optimized;
|
|
120
|
+
}
|
|
121
|
+
if (optimized.size <= MAX_DIRECT_UPLOAD_BYTES) {
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (!bestFile) {
|
|
127
|
+
return file;
|
|
128
|
+
}
|
|
129
|
+
return bestFile.size < file.size ? bestFile : file;
|
|
130
|
+
} finally {
|
|
131
|
+
URL.revokeObjectURL(objectURL);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// src/builder-v2/projectData.ts
|
|
136
|
+
var isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
137
|
+
var createEmptyBuilderV2ProjectData = (title = "Untitled Page") => ({
|
|
138
|
+
assets: [],
|
|
139
|
+
pages: [
|
|
140
|
+
{
|
|
141
|
+
component: {
|
|
142
|
+
components: [
|
|
143
|
+
{
|
|
144
|
+
attributes: {
|
|
145
|
+
class: "orion-builder-v2-section"
|
|
146
|
+
},
|
|
147
|
+
components: [
|
|
148
|
+
{
|
|
149
|
+
content: title,
|
|
150
|
+
tagName: "h1",
|
|
151
|
+
type: "text"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
content: "Start building this page by dragging blocks from the panel.",
|
|
155
|
+
tagName: "p",
|
|
156
|
+
type: "text"
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
tagName: "section"
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
type: "wrapper"
|
|
163
|
+
},
|
|
164
|
+
id: "page",
|
|
165
|
+
name: title
|
|
166
|
+
}
|
|
167
|
+
],
|
|
168
|
+
styles: []
|
|
169
|
+
});
|
|
170
|
+
var normalizeBuilderV2ProjectData = (value, fallbackTitle = "Untitled Page") => {
|
|
171
|
+
if (!isRecord(value)) {
|
|
172
|
+
return createEmptyBuilderV2ProjectData(fallbackTitle);
|
|
173
|
+
}
|
|
174
|
+
return value;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// src/builder-v2/runtime/placeholders.ts
|
|
178
|
+
var placeholderPattern = /<(?<tag>[a-zA-Z][a-zA-Z0-9-]*)\b(?<attrs>[^>]*)data-orion-component=["'](?<component>[^"']+)["'](?<rest>[^>]*)>/gis;
|
|
179
|
+
var attrPattern = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)=(?:"([^"]*)"|'([^']*)')/g;
|
|
180
|
+
var decodeHtmlAttribute = (value) => value.replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
181
|
+
var parseAttributes = (value) => {
|
|
182
|
+
const props = {};
|
|
183
|
+
let match;
|
|
184
|
+
while ((match = attrPattern.exec(value)) !== null) {
|
|
185
|
+
const name = match[1];
|
|
186
|
+
const rawValue = match[2] ?? match[3] ?? "";
|
|
187
|
+
if (!name.startsWith("data-")) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (name === "data-orion-component" || name === "data-orion-id") {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
if (name === "data-orion-props") {
|
|
194
|
+
const decoded = decodeHtmlAttribute(rawValue);
|
|
195
|
+
try {
|
|
196
|
+
const parsed = JSON.parse(decoded);
|
|
197
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
198
|
+
Object.assign(props, parsed);
|
|
199
|
+
}
|
|
200
|
+
} catch {
|
|
201
|
+
props.propsJson = decoded;
|
|
202
|
+
}
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
const propName = name.replace(/^data-orion-/, "").replace(/^data-/, "").replace(/-([a-z])/g, (_, char) => char.toUpperCase());
|
|
206
|
+
props[propName] = decodeHtmlAttribute(rawValue);
|
|
207
|
+
}
|
|
208
|
+
return props;
|
|
209
|
+
};
|
|
210
|
+
var extractAttribute = (attrs, name) => {
|
|
211
|
+
attrPattern.lastIndex = 0;
|
|
212
|
+
let match;
|
|
213
|
+
while ((match = attrPattern.exec(attrs)) !== null) {
|
|
214
|
+
if (match[1] === name) {
|
|
215
|
+
return decodeHtmlAttribute(match[2] ?? match[3] ?? "");
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return null;
|
|
219
|
+
};
|
|
220
|
+
var extractWrapperAttributes = (attrs) => {
|
|
221
|
+
const id = extractAttribute(attrs, "id") || void 0;
|
|
222
|
+
const className = extractAttribute(attrs, "class") || void 0;
|
|
223
|
+
const style = extractAttribute(attrs, "style") || void 0;
|
|
224
|
+
return id || className || style ? { className, id, style } : void 0;
|
|
225
|
+
};
|
|
226
|
+
var parseBuilderV2DynamicComponents = (html) => {
|
|
227
|
+
const instances = [];
|
|
228
|
+
let match;
|
|
229
|
+
while ((match = placeholderPattern.exec(html)) !== null) {
|
|
230
|
+
const attrs = `${match.groups?.attrs ?? ""} ${match.groups?.rest ?? ""}`;
|
|
231
|
+
const component = match.groups?.component ?? "";
|
|
232
|
+
if (!component) {
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
instances.push({
|
|
236
|
+
component,
|
|
237
|
+
id: extractAttribute(attrs, "data-orion-id") || `component-${instances.length + 1}`,
|
|
238
|
+
props: parseAttributes(attrs),
|
|
239
|
+
wrapperAttributes: extractWrapperAttributes(attrs)
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
return instances;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// src/builder-v2/sanitize.ts
|
|
246
|
+
var import_sanitize_html = __toESM(require("sanitize-html"));
|
|
247
|
+
var allowedTags = import_sanitize_html.default.defaults.allowedTags.concat([
|
|
248
|
+
"article",
|
|
249
|
+
"aside",
|
|
250
|
+
"button",
|
|
251
|
+
"figure",
|
|
252
|
+
"figcaption",
|
|
253
|
+
"footer",
|
|
254
|
+
"header",
|
|
255
|
+
"main",
|
|
256
|
+
"nav",
|
|
257
|
+
"section",
|
|
258
|
+
"source",
|
|
259
|
+
"video"
|
|
260
|
+
]);
|
|
261
|
+
var allowedAttributes = {
|
|
262
|
+
...import_sanitize_html.default.defaults.allowedAttributes,
|
|
263
|
+
"*": [
|
|
264
|
+
"aria-*",
|
|
265
|
+
"class",
|
|
266
|
+
"data-*",
|
|
267
|
+
"id",
|
|
268
|
+
"role",
|
|
269
|
+
"style",
|
|
270
|
+
"title"
|
|
271
|
+
],
|
|
272
|
+
a: ["aria-*", "class", "data-*", "href", "id", "name", "rel", "style", "target", "title"],
|
|
273
|
+
button: ["aria-*", "class", "data-*", "disabled", "id", "style", "title", "type"],
|
|
274
|
+
iframe: ["allow", "allowfullscreen", "class", "data-*", "height", "loading", "src", "style", "title", "width"],
|
|
275
|
+
img: ["alt", "class", "data-*", "height", "id", "loading", "sizes", "src", "srcset", "style", "title", "width"],
|
|
276
|
+
source: ["media", "src", "srcset", "type"],
|
|
277
|
+
video: ["autoplay", "class", "controls", "height", "loop", "muted", "playsinline", "poster", "preload", "src", "style", "width"]
|
|
278
|
+
};
|
|
279
|
+
var allowedIframeHosts = [
|
|
280
|
+
"calendar.google.com",
|
|
281
|
+
"calendly.com",
|
|
282
|
+
"player.vimeo.com",
|
|
283
|
+
"www.google.com",
|
|
284
|
+
"www.youtube.com",
|
|
285
|
+
"youtube.com"
|
|
286
|
+
];
|
|
287
|
+
var sanitizeBuilderHtml = (value) => {
|
|
288
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
289
|
+
return "";
|
|
290
|
+
}
|
|
291
|
+
return (0, import_sanitize_html.default)(value, {
|
|
292
|
+
allowedAttributes,
|
|
293
|
+
allowedIframeHostnames: allowedIframeHosts,
|
|
294
|
+
allowedSchemes: ["http", "https", "mailto", "tel"],
|
|
295
|
+
allowedSchemesByTag: {
|
|
296
|
+
img: ["http", "https", "data"]
|
|
297
|
+
},
|
|
298
|
+
allowedTags,
|
|
299
|
+
allowProtocolRelative: false,
|
|
300
|
+
parseStyleAttributes: false
|
|
301
|
+
});
|
|
302
|
+
};
|
|
303
|
+
var sanitizeBuilderCss = (value) => {
|
|
304
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
305
|
+
return "";
|
|
306
|
+
}
|
|
307
|
+
return value.replace(/@import\s+[^;]+;/gi, "").replace(/expression\s*\(/gi, "").replace(/javascript\s*:/gi, "");
|
|
308
|
+
};
|
|
309
|
+
var scopeSelector = (selector, scope) => selector.split(",").map((part) => {
|
|
310
|
+
const trimmed = part.trim();
|
|
311
|
+
if (!trimmed || trimmed.startsWith(scope) || trimmed.startsWith("@")) {
|
|
312
|
+
return trimmed;
|
|
313
|
+
}
|
|
314
|
+
if (/^(html|body|:root)\b/i.test(trimmed)) {
|
|
315
|
+
return trimmed.replace(/^(html|body|:root)\b/i, scope);
|
|
316
|
+
}
|
|
317
|
+
return `${scope} ${trimmed}`;
|
|
318
|
+
}).filter(Boolean).join(", ");
|
|
319
|
+
var scopeBuilderCss = (value, scope = ".orion-builder-v2-runtime") => {
|
|
320
|
+
const css = sanitizeBuilderCss(value);
|
|
321
|
+
if (!css) {
|
|
322
|
+
return "";
|
|
323
|
+
}
|
|
324
|
+
let output = "";
|
|
325
|
+
let cursor = 0;
|
|
326
|
+
const rulePattern = /([^{}]+)\{/g;
|
|
327
|
+
let match;
|
|
328
|
+
while ((match = rulePattern.exec(css)) !== null) {
|
|
329
|
+
const selectorStart = match.index;
|
|
330
|
+
const selector = match[1];
|
|
331
|
+
output += css.slice(cursor, selectorStart);
|
|
332
|
+
const trimmedSelector = selector.trim();
|
|
333
|
+
if (trimmedSelector.startsWith("@keyframes") || trimmedSelector.startsWith("@font-face") || trimmedSelector.startsWith("@page")) {
|
|
334
|
+
output += `${selector}{`;
|
|
335
|
+
} else if (trimmedSelector.startsWith("@media") || trimmedSelector.startsWith("@supports")) {
|
|
336
|
+
output += `${selector}{`;
|
|
337
|
+
} else {
|
|
338
|
+
output += `${scopeSelector(selector, scope)} {`;
|
|
339
|
+
}
|
|
340
|
+
cursor = rulePattern.lastIndex;
|
|
341
|
+
}
|
|
342
|
+
output += css.slice(cursor);
|
|
343
|
+
return output;
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
// src/builder-v2/validation.ts
|
|
347
|
+
var hasMatch = (value, pattern) => pattern.test(value);
|
|
348
|
+
var validateBuilderV2Output = (input) => {
|
|
349
|
+
const html = typeof input.html === "string" ? input.html : "";
|
|
350
|
+
const css = typeof input.css === "string" ? input.css : "";
|
|
351
|
+
const issues = [];
|
|
352
|
+
if (!html.trim()) {
|
|
353
|
+
issues.push({
|
|
354
|
+
code: "empty-page",
|
|
355
|
+
message: "This page has no rendered content.",
|
|
356
|
+
path: "compiledHtml",
|
|
357
|
+
severity: "error"
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
if (!hasMatch(html, /<h1\b/i)) {
|
|
361
|
+
issues.push({
|
|
362
|
+
code: "missing-h1",
|
|
363
|
+
message: "Add one H1 so the published page has a clear primary heading.",
|
|
364
|
+
path: "compiledHtml",
|
|
365
|
+
severity: "warning"
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
if (hasMatch(html, /\son[a-z]+\s*=/i)) {
|
|
369
|
+
issues.push({
|
|
370
|
+
code: "inline-event-handler",
|
|
371
|
+
message: "Inline event handlers are not allowed in published builder HTML.",
|
|
372
|
+
path: "compiledHtml",
|
|
373
|
+
severity: "error"
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
if (hasMatch(html, /<(script|object|embed)\b/i)) {
|
|
377
|
+
issues.push({
|
|
378
|
+
code: "unsafe-element",
|
|
379
|
+
message: "Script, object, and embed tags are not allowed in builder content.",
|
|
380
|
+
path: "compiledHtml",
|
|
381
|
+
severity: "error"
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
if (hasMatch(html, /\b(?:href|src)=["']\s*javascript:/i)) {
|
|
385
|
+
issues.push({
|
|
386
|
+
code: "unsafe-url",
|
|
387
|
+
message: "Links and media cannot use javascript URLs.",
|
|
388
|
+
path: "compiledHtml",
|
|
389
|
+
severity: "error"
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
if (hasMatch(css, /@import\s/i)) {
|
|
393
|
+
issues.push({
|
|
394
|
+
code: "css-import",
|
|
395
|
+
message: "CSS imports are removed at publish time. Use the site font and theme managers instead.",
|
|
396
|
+
path: "compiledCss",
|
|
397
|
+
severity: "warning"
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
if (hasMatch(css, /position\s*:\s*fixed/i)) {
|
|
401
|
+
issues.push({
|
|
402
|
+
code: "fixed-position",
|
|
403
|
+
message: "Fixed positioning can cover site navigation or dialogs. Review this before publishing.",
|
|
404
|
+
path: "compiledCss",
|
|
405
|
+
severity: "warning"
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
return issues;
|
|
409
|
+
};
|
|
410
|
+
var hasBlockingBuilderV2Issues = (issues) => issues.some((issue) => issue.severity === "error");
|
|
411
|
+
|
|
412
|
+
// src/builder-v2/editor/defaultBlocks.ts
|
|
413
|
+
var blockPreview = (variant) => `
|
|
414
|
+
<div class="orion-builder-v2-block-preview is-${variant}" aria-hidden="true">
|
|
415
|
+
<span class="wire wire-kicker"></span>
|
|
416
|
+
<span class="wire wire-title"></span>
|
|
417
|
+
<span class="wire wire-copy"></span>
|
|
418
|
+
<span class="wire wire-copy is-short"></span>
|
|
419
|
+
<span class="wire wire-button"></span>
|
|
420
|
+
<span class="wire wire-image"></span>
|
|
421
|
+
<span class="wire wire-card"></span>
|
|
422
|
+
<span class="wire wire-card"></span>
|
|
423
|
+
<span class="wire wire-card"></span>
|
|
424
|
+
</div>
|
|
425
|
+
`;
|
|
426
|
+
var registerOrionBuilderV2Blocks = (editor) => {
|
|
427
|
+
const blocks = editor.Blocks;
|
|
428
|
+
blocks.add("orion-section", {
|
|
429
|
+
category: "Layout",
|
|
430
|
+
content: `
|
|
431
|
+
<section class="orion-builder-v2-section">
|
|
432
|
+
<div class="orion-builder-v2-container">
|
|
433
|
+
<h2>Section Heading</h2>
|
|
434
|
+
<p>Add supporting content here.</p>
|
|
435
|
+
</div>
|
|
436
|
+
</section>
|
|
437
|
+
`,
|
|
438
|
+
label: "Section",
|
|
439
|
+
media: blockPreview("section")
|
|
440
|
+
});
|
|
441
|
+
blocks.add("orion-hero", {
|
|
442
|
+
category: "Sections",
|
|
443
|
+
content: `
|
|
444
|
+
<section class="orion-builder-v2-hero">
|
|
445
|
+
<div class="orion-builder-v2-container">
|
|
446
|
+
<p class="orion-builder-v2-kicker">Optional kicker</p>
|
|
447
|
+
<h1>Build a stronger website</h1>
|
|
448
|
+
<p>Use this area for a clear value proposition and call to action.</p>
|
|
449
|
+
<a class="orion-builder-v2-button" href="/contact">Get started</a>
|
|
450
|
+
</div>
|
|
451
|
+
</section>
|
|
452
|
+
`,
|
|
453
|
+
label: "Hero",
|
|
454
|
+
media: blockPreview("hero")
|
|
455
|
+
});
|
|
456
|
+
blocks.add("orion-columns", {
|
|
457
|
+
category: "Layout",
|
|
458
|
+
content: `
|
|
459
|
+
<section class="orion-builder-v2-section">
|
|
460
|
+
<div class="orion-builder-v2-container orion-builder-v2-grid is-3">
|
|
461
|
+
<article class="orion-builder-v2-card"><h3>Column One</h3><p>Add content.</p></article>
|
|
462
|
+
<article class="orion-builder-v2-card"><h3>Column Two</h3><p>Add content.</p></article>
|
|
463
|
+
<article class="orion-builder-v2-card"><h3>Column Three</h3><p>Add content.</p></article>
|
|
464
|
+
</div>
|
|
465
|
+
</section>
|
|
466
|
+
`,
|
|
467
|
+
label: "Columns",
|
|
468
|
+
media: blockPreview("columns")
|
|
469
|
+
});
|
|
470
|
+
blocks.add("orion-card-grid", {
|
|
471
|
+
category: "Sections",
|
|
472
|
+
content: `
|
|
473
|
+
<section class="orion-builder-v2-section">
|
|
474
|
+
<div class="orion-builder-v2-container">
|
|
475
|
+
<p class="orion-builder-v2-kicker">Featured</p>
|
|
476
|
+
<h2>Cards that explain the offer</h2>
|
|
477
|
+
<div class="orion-builder-v2-grid is-3">
|
|
478
|
+
<article class="orion-builder-v2-card"><h3>Service One</h3><p>Describe the outcome clients care about.</p><a href="/contact">Learn more</a></article>
|
|
479
|
+
<article class="orion-builder-v2-card"><h3>Service Two</h3><p>Keep the card concise and scannable.</p><a href="/contact">Learn more</a></article>
|
|
480
|
+
<article class="orion-builder-v2-card"><h3>Service Three</h3><p>Use the same structure for visual rhythm.</p><a href="/contact">Learn more</a></article>
|
|
481
|
+
</div>
|
|
482
|
+
</div>
|
|
483
|
+
</section>
|
|
484
|
+
`,
|
|
485
|
+
label: "Card grid",
|
|
486
|
+
media: blockPreview("card-grid")
|
|
487
|
+
});
|
|
488
|
+
blocks.add("orion-gallery", {
|
|
489
|
+
category: "Media",
|
|
490
|
+
content: `
|
|
491
|
+
<section class="orion-builder-v2-section">
|
|
492
|
+
<div class="orion-builder-v2-container">
|
|
493
|
+
<h2>Gallery</h2>
|
|
494
|
+
<div class="orion-builder-v2-gallery">
|
|
495
|
+
<img alt="Gallery item" src="https://placehold.co/900x700" />
|
|
496
|
+
<img alt="Gallery item" src="https://placehold.co/900x700" />
|
|
497
|
+
<img alt="Gallery item" src="https://placehold.co/900x700" />
|
|
498
|
+
<img alt="Gallery item" src="https://placehold.co/900x700" />
|
|
499
|
+
</div>
|
|
500
|
+
</div>
|
|
501
|
+
</section>
|
|
502
|
+
`,
|
|
503
|
+
label: "Gallery",
|
|
504
|
+
media: blockPreview("gallery")
|
|
505
|
+
});
|
|
506
|
+
blocks.add("orion-testimonials", {
|
|
507
|
+
category: "Sections",
|
|
508
|
+
content: `
|
|
509
|
+
<section class="orion-builder-v2-section is-muted">
|
|
510
|
+
<div class="orion-builder-v2-container">
|
|
511
|
+
<p class="orion-builder-v2-kicker">Testimonials</p>
|
|
512
|
+
<h2>What clients say</h2>
|
|
513
|
+
<div class="orion-builder-v2-grid is-3">
|
|
514
|
+
<blockquote class="orion-builder-v2-card"><p>"A clear, warm experience from start to finish."</p><cite>Client Name</cite></blockquote>
|
|
515
|
+
<blockquote class="orion-builder-v2-card"><p>"Exactly what we needed, without friction."</p><cite>Client Name</cite></blockquote>
|
|
516
|
+
<blockquote class="orion-builder-v2-card"><p>"The site made every next step obvious."</p><cite>Client Name</cite></blockquote>
|
|
517
|
+
</div>
|
|
518
|
+
</div>
|
|
519
|
+
</section>
|
|
520
|
+
`,
|
|
521
|
+
label: "Testimonials",
|
|
522
|
+
media: blockPreview("testimonials")
|
|
523
|
+
});
|
|
524
|
+
blocks.add("orion-faq", {
|
|
525
|
+
category: "Sections",
|
|
526
|
+
content: `
|
|
527
|
+
<section class="orion-builder-v2-section">
|
|
528
|
+
<div class="orion-builder-v2-container is-narrow">
|
|
529
|
+
<p class="orion-builder-v2-kicker">FAQ</p>
|
|
530
|
+
<h2>Questions answered</h2>
|
|
531
|
+
<details open><summary>What should visitors know first?</summary><p>Give a short, useful answer that removes hesitation.</p></details>
|
|
532
|
+
<details><summary>How does the process work?</summary><p>Explain the next step clearly.</p></details>
|
|
533
|
+
<details><summary>How do we get started?</summary><p>Point people to the strongest call to action.</p></details>
|
|
534
|
+
</div>
|
|
535
|
+
</section>
|
|
536
|
+
`,
|
|
537
|
+
label: "FAQ",
|
|
538
|
+
media: blockPreview("faq")
|
|
539
|
+
});
|
|
540
|
+
blocks.add("orion-pricing", {
|
|
541
|
+
category: "Commerce",
|
|
542
|
+
content: `
|
|
543
|
+
<section class="orion-builder-v2-section">
|
|
544
|
+
<div class="orion-builder-v2-container">
|
|
545
|
+
<p class="orion-builder-v2-kicker">Pricing</p>
|
|
546
|
+
<h2>Simple package options</h2>
|
|
547
|
+
<div class="orion-builder-v2-grid is-3">
|
|
548
|
+
<article class="orion-builder-v2-card"><h3>Starter</h3><p class="orion-builder-v2-price">$500</p><p>Best for focused launches.</p><a class="orion-builder-v2-button" href="/contact">Choose Starter</a></article>
|
|
549
|
+
<article class="orion-builder-v2-card is-featured"><h3>Growth</h3><p class="orion-builder-v2-price">$1,500</p><p>Best for expanding teams.</p><a class="orion-builder-v2-button" href="/contact">Choose Growth</a></article>
|
|
550
|
+
<article class="orion-builder-v2-card"><h3>Custom</h3><p class="orion-builder-v2-price">Quote</p><p>Best for complex builds.</p><a class="orion-builder-v2-button" href="/contact">Talk with us</a></article>
|
|
551
|
+
</div>
|
|
552
|
+
</div>
|
|
553
|
+
</section>
|
|
554
|
+
`,
|
|
555
|
+
label: "Pricing",
|
|
556
|
+
media: blockPreview("pricing")
|
|
557
|
+
});
|
|
558
|
+
blocks.add("orion-button", {
|
|
559
|
+
category: "Basic",
|
|
560
|
+
content: '<a class="orion-builder-v2-button" href="/contact">Button</a>',
|
|
561
|
+
label: "Button",
|
|
562
|
+
media: blockPreview("button")
|
|
563
|
+
});
|
|
564
|
+
blocks.add("orion-image", {
|
|
565
|
+
category: "Basic",
|
|
566
|
+
content: '<img alt="Image" class="orion-builder-v2-image" src="https://placehold.co/1200x700" />',
|
|
567
|
+
label: "Image",
|
|
568
|
+
media: blockPreview("image")
|
|
569
|
+
});
|
|
570
|
+
blocks.add("orion-form-embed", {
|
|
571
|
+
category: "Dynamic",
|
|
572
|
+
content: `
|
|
573
|
+
<div
|
|
574
|
+
class="orion-builder-v2-dynamic-placeholder"
|
|
575
|
+
data-orion-component="formEmbed"
|
|
576
|
+
data-orion-form-slug="contact"
|
|
577
|
+
>
|
|
578
|
+
<strong>Form Embed</strong>
|
|
579
|
+
<span>contact</span>
|
|
580
|
+
</div>
|
|
581
|
+
`,
|
|
582
|
+
label: "Form",
|
|
583
|
+
media: blockPreview("form")
|
|
584
|
+
});
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
// src/builder-v2/editor/projectComponents.ts
|
|
588
|
+
var normalizeDefinition = (type, value) => {
|
|
589
|
+
if (!value || typeof value === "function") {
|
|
590
|
+
return null;
|
|
591
|
+
}
|
|
592
|
+
return {
|
|
593
|
+
...value,
|
|
594
|
+
type: value.type || type
|
|
595
|
+
};
|
|
596
|
+
};
|
|
597
|
+
var decodeHtmlAttribute2 = (value) => {
|
|
598
|
+
if (typeof value !== "string") {
|
|
599
|
+
return "";
|
|
600
|
+
}
|
|
601
|
+
let decoded = value;
|
|
602
|
+
for (let index = 0; index < 3; index += 1) {
|
|
603
|
+
const next = decoded.replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
604
|
+
if (next === decoded) {
|
|
605
|
+
break;
|
|
606
|
+
}
|
|
607
|
+
decoded = next;
|
|
608
|
+
}
|
|
609
|
+
return decoded;
|
|
610
|
+
};
|
|
611
|
+
var attrToPropName = (name) => name.replace(/^data-orion-/, "").replace(/^data-/, "").replace(/-([a-z])/g, (_, char) => char.toUpperCase());
|
|
612
|
+
var propToAttrName = (name) => `data-orion-${name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`)}`;
|
|
613
|
+
var headingFieldNames = /* @__PURE__ */ new Set(["headline", "label", "question", "title", "value"]);
|
|
614
|
+
var textKindForField = (field, element) => /^h[1-6]$/i.test(element.tagName) || headingFieldNames.has(field) ? "heading" : "body";
|
|
615
|
+
var markActiveEditableField = (model, field, element) => {
|
|
616
|
+
const computed = window.getComputedStyle(element);
|
|
617
|
+
model.addAttributes?.({
|
|
618
|
+
"data-orion-active-edit-field": field,
|
|
619
|
+
"data-orion-active-text-kind": textKindForField(field, element),
|
|
620
|
+
"data-orion-active-font-family": computed.fontFamily,
|
|
621
|
+
"data-orion-active-font-size": computed.fontSize,
|
|
622
|
+
"data-orion-active-font-weight": computed.fontWeight,
|
|
623
|
+
"data-orion-active-line-height": computed.lineHeight,
|
|
624
|
+
"data-orion-active-letter-spacing": computed.letterSpacing,
|
|
625
|
+
"data-orion-active-color": computed.color,
|
|
626
|
+
"data-orion-active-text-align": computed.textAlign
|
|
627
|
+
});
|
|
628
|
+
};
|
|
629
|
+
var propsFromAttributes = (attributes = {}) => {
|
|
630
|
+
const props = {};
|
|
631
|
+
Object.keys(attributes).forEach((name) => {
|
|
632
|
+
if (!name.startsWith("data-") || name === "data-orion-component" || name === "data-orion-id") {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
const value = decodeHtmlAttribute2(attributes[name]);
|
|
636
|
+
if (name === "data-orion-props") {
|
|
637
|
+
try {
|
|
638
|
+
const parsed = JSON.parse(value);
|
|
639
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
640
|
+
Object.assign(props, parsed);
|
|
641
|
+
}
|
|
642
|
+
} catch {
|
|
643
|
+
props.propsJson = value;
|
|
644
|
+
}
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
props[attrToPropName(name)] = value;
|
|
648
|
+
});
|
|
649
|
+
return props;
|
|
650
|
+
};
|
|
651
|
+
var parseJsonRecord = (value) => {
|
|
652
|
+
const decoded = decodeHtmlAttribute2(value);
|
|
653
|
+
if (!decoded) {
|
|
654
|
+
return {};
|
|
655
|
+
}
|
|
656
|
+
try {
|
|
657
|
+
const parsed = JSON.parse(decoded);
|
|
658
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
659
|
+
} catch {
|
|
660
|
+
return {};
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
var serializeJsonRecord = (value) => JSON.stringify(value);
|
|
664
|
+
var normalizeCssColor = (value) => typeof value === "string" && value.trim() && value.trim() !== "none" ? value.trim() : "";
|
|
665
|
+
var defaultBackgroundForComponent = (type, props) => {
|
|
666
|
+
const block = parseJsonRecord(props.block);
|
|
667
|
+
const explicit = normalizeCssColor(block.backgroundColor) || normalizeCssColor(props.backgroundColor);
|
|
668
|
+
if (explicit) {
|
|
669
|
+
return explicit;
|
|
670
|
+
}
|
|
671
|
+
if (type === "xoCta") {
|
|
672
|
+
return typeof block.style === "string" && block.style.toLowerCase() === "dark" ? "#243654" : "#304b70";
|
|
673
|
+
}
|
|
674
|
+
if (type === "xoFeatureGrid" || type === "xoRichText") {
|
|
675
|
+
return "#fbfaf7";
|
|
676
|
+
}
|
|
677
|
+
if (type === "xoHero" && !props.backgroundImageURL && !props.imageURL) {
|
|
678
|
+
return "#fbfaf7";
|
|
679
|
+
}
|
|
680
|
+
return "";
|
|
681
|
+
};
|
|
682
|
+
var syncModelBackgroundToBlock = (model) => {
|
|
683
|
+
const attrs = model.getAttributes?.() || {};
|
|
684
|
+
const block = parseJsonRecord(attrs["data-orion-block"]);
|
|
685
|
+
const style = model.getStyle?.() || {};
|
|
686
|
+
const backgroundColor = normalizeCssColor(style["background-color"] || style.backgroundColor);
|
|
687
|
+
if (!backgroundColor || Object.keys(block).length === 0) {
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
model.addAttributes?.({
|
|
691
|
+
"data-orion-background-color": backgroundColor,
|
|
692
|
+
"data-orion-block": serializeJsonRecord({
|
|
693
|
+
...block,
|
|
694
|
+
backgroundColor
|
|
695
|
+
})
|
|
696
|
+
});
|
|
697
|
+
};
|
|
698
|
+
var previewForDefinition = (definition, props) => definition.editorPreview?.(props) || `<div class="orion-builder-v2-dynamic-placeholder"><strong>${definition.label}</strong></div>`;
|
|
699
|
+
var blockPreviewForDefinition = (type) => {
|
|
700
|
+
const normalizedType = type.replace(/[^a-z0-9-]/gi, "-");
|
|
701
|
+
return `
|
|
702
|
+
<div class="orion-builder-v2-block-preview is-project is-${normalizedType}" aria-hidden="true">
|
|
703
|
+
<span class="wire wire-kicker"></span>
|
|
704
|
+
<span class="wire wire-title"></span>
|
|
705
|
+
<span class="wire wire-copy"></span>
|
|
706
|
+
<span class="wire wire-image"></span>
|
|
707
|
+
<span class="wire wire-card"></span>
|
|
708
|
+
<span class="wire wire-card"></span>
|
|
709
|
+
<span class="wire wire-card"></span>
|
|
710
|
+
</div>
|
|
711
|
+
`;
|
|
712
|
+
};
|
|
713
|
+
var lockPreviewChildren = (component) => {
|
|
714
|
+
const children = typeof component.components === "function" ? component.components() : null;
|
|
715
|
+
const childList = children && typeof children === "object" && "forEach" in children ? children : null;
|
|
716
|
+
childList?.forEach((child) => {
|
|
717
|
+
if (typeof child.set === "function") {
|
|
718
|
+
child.set({
|
|
719
|
+
copyable: false,
|
|
720
|
+
draggable: false,
|
|
721
|
+
droppable: false,
|
|
722
|
+
editable: false,
|
|
723
|
+
highlightable: false,
|
|
724
|
+
hoverable: false,
|
|
725
|
+
removable: false,
|
|
726
|
+
selectable: false
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
lockPreviewChildren(child);
|
|
730
|
+
});
|
|
731
|
+
};
|
|
732
|
+
var parseJsonArray = (value) => {
|
|
733
|
+
const decoded = decodeHtmlAttribute2(value);
|
|
734
|
+
if (!decoded) {
|
|
735
|
+
return [];
|
|
736
|
+
}
|
|
737
|
+
try {
|
|
738
|
+
const parsed = JSON.parse(decoded);
|
|
739
|
+
return Array.isArray(parsed) ? parsed.filter((item) => Boolean(item && typeof item === "object" && !Array.isArray(item))) : [];
|
|
740
|
+
} catch {
|
|
741
|
+
return [];
|
|
742
|
+
}
|
|
743
|
+
};
|
|
744
|
+
var updateJsonListAttribute = ({
|
|
745
|
+
field,
|
|
746
|
+
index,
|
|
747
|
+
listAttr,
|
|
748
|
+
model,
|
|
749
|
+
value
|
|
750
|
+
}) => {
|
|
751
|
+
const attrs = model.getAttributes?.() || {};
|
|
752
|
+
const list = parseJsonArray(attrs[listAttr]);
|
|
753
|
+
if (!list[index]) {
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
list[index] = {
|
|
757
|
+
...list[index],
|
|
758
|
+
[field]: value
|
|
759
|
+
};
|
|
760
|
+
model.addAttributes?.({
|
|
761
|
+
[listAttr]: JSON.stringify(list)
|
|
762
|
+
});
|
|
763
|
+
};
|
|
764
|
+
var addJsonListItem = ({
|
|
765
|
+
listAttr,
|
|
766
|
+
model,
|
|
767
|
+
template
|
|
768
|
+
}) => {
|
|
769
|
+
const attrs = model.getAttributes?.() || {};
|
|
770
|
+
const list = parseJsonArray(attrs[listAttr]);
|
|
771
|
+
list.push(template);
|
|
772
|
+
model.addAttributes?.({
|
|
773
|
+
[listAttr]: JSON.stringify(list)
|
|
774
|
+
});
|
|
775
|
+
};
|
|
776
|
+
var duplicateJsonListItem = ({
|
|
777
|
+
index,
|
|
778
|
+
listAttr,
|
|
779
|
+
model
|
|
780
|
+
}) => {
|
|
781
|
+
const attrs = model.getAttributes?.() || {};
|
|
782
|
+
const list = parseJsonArray(attrs[listAttr]);
|
|
783
|
+
const item = list[index];
|
|
784
|
+
if (!item) {
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
list.splice(index + 1, 0, {
|
|
788
|
+
...item,
|
|
789
|
+
title: typeof item.title === "string" ? `${item.title} copy` : item.title
|
|
790
|
+
});
|
|
791
|
+
model.addAttributes?.({
|
|
792
|
+
[listAttr]: JSON.stringify(list)
|
|
793
|
+
});
|
|
794
|
+
};
|
|
795
|
+
var removeJsonListItem = ({
|
|
796
|
+
index,
|
|
797
|
+
listAttr,
|
|
798
|
+
model
|
|
799
|
+
}) => {
|
|
800
|
+
const attrs = model.getAttributes?.() || {};
|
|
801
|
+
const list = parseJsonArray(attrs[listAttr]);
|
|
802
|
+
if (!list[index]) {
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
list.splice(index, 1);
|
|
806
|
+
model.addAttributes?.({
|
|
807
|
+
[listAttr]: JSON.stringify(list)
|
|
808
|
+
});
|
|
809
|
+
};
|
|
810
|
+
var parseTemplateAttribute = (value) => {
|
|
811
|
+
const decoded = decodeHtmlAttribute2(value);
|
|
812
|
+
if (!decoded) {
|
|
813
|
+
return {
|
|
814
|
+
description: "Describe this item.",
|
|
815
|
+
imageURL: "",
|
|
816
|
+
title: "New item"
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
try {
|
|
820
|
+
const parsed = JSON.parse(decoded);
|
|
821
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {
|
|
822
|
+
description: "Describe this item.",
|
|
823
|
+
imageURL: "",
|
|
824
|
+
title: "New item"
|
|
825
|
+
};
|
|
826
|
+
} catch {
|
|
827
|
+
return {
|
|
828
|
+
description: "Describe this item.",
|
|
829
|
+
imageURL: "",
|
|
830
|
+
title: "New item"
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
var chooseAsset = (editor, currentSrc, callback) => {
|
|
835
|
+
const assetManager = editor?.AssetManager;
|
|
836
|
+
if (!assetManager?.open) {
|
|
837
|
+
const src = window.prompt("Image URL");
|
|
838
|
+
if (src) {
|
|
839
|
+
callback(src);
|
|
840
|
+
}
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
if (currentSrc) {
|
|
844
|
+
assetManager.add?.({
|
|
845
|
+
name: `Current image - ${currentSrc.split("/").pop() || currentSrc}`,
|
|
846
|
+
src: currentSrc,
|
|
847
|
+
type: "image"
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
assetManager.open({
|
|
851
|
+
select(asset) {
|
|
852
|
+
const src = typeof asset === "string" ? asset : asset && typeof asset === "object" && "get" in asset && typeof asset.get === "function" ? String(asset.get("src") || "") : asset && typeof asset === "object" && "src" in asset ? String(asset.src || "") : "";
|
|
853
|
+
if (src) {
|
|
854
|
+
callback(src);
|
|
855
|
+
}
|
|
856
|
+
assetManager.close?.();
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
};
|
|
860
|
+
var bindEditablePreview = (view, editor) => {
|
|
861
|
+
const root = view.el;
|
|
862
|
+
if (!root) {
|
|
863
|
+
return;
|
|
864
|
+
}
|
|
865
|
+
root.querySelectorAll("[data-orion-action]").forEach((element) => {
|
|
866
|
+
const action = element.dataset.orionAction || "";
|
|
867
|
+
const listName = element.dataset.orionEditList || "";
|
|
868
|
+
const listIndex = Number(element.dataset.orionEditIndex);
|
|
869
|
+
const listAttr = listName ? propToAttrName(listName) : "";
|
|
870
|
+
element.setAttribute("title", element.getAttribute("aria-label") || element.textContent?.trim() || "Section action");
|
|
871
|
+
const runAction = (event) => {
|
|
872
|
+
event.preventDefault();
|
|
873
|
+
event.stopPropagation();
|
|
874
|
+
if (typeof event.stopImmediatePropagation === "function") {
|
|
875
|
+
event.stopImmediatePropagation();
|
|
876
|
+
}
|
|
877
|
+
editor.select?.(view.model);
|
|
878
|
+
if (!listAttr) {
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
if (action === "add-list-item") {
|
|
882
|
+
addJsonListItem({
|
|
883
|
+
listAttr,
|
|
884
|
+
model: view.model,
|
|
885
|
+
template: parseTemplateAttribute(element.dataset.orionItemTemplate)
|
|
886
|
+
});
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
if (!Number.isInteger(listIndex)) {
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
if (action === "duplicate-list-item") {
|
|
893
|
+
duplicateJsonListItem({
|
|
894
|
+
index: listIndex,
|
|
895
|
+
listAttr,
|
|
896
|
+
model: view.model
|
|
897
|
+
});
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
if (action === "remove-list-item") {
|
|
901
|
+
removeJsonListItem({
|
|
902
|
+
index: listIndex,
|
|
903
|
+
listAttr,
|
|
904
|
+
model: view.model
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
element.addEventListener("pointerdown", runAction, true);
|
|
909
|
+
element.addEventListener("keydown", (event) => {
|
|
910
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
911
|
+
runAction(event);
|
|
912
|
+
}
|
|
913
|
+
});
|
|
914
|
+
});
|
|
915
|
+
root.querySelectorAll("[data-orion-edit-field]").forEach((element) => {
|
|
916
|
+
const field = element.dataset.orionEditField || "";
|
|
917
|
+
const listName = element.dataset.orionEditList || "";
|
|
918
|
+
const listIndex = Number(element.dataset.orionEditIndex);
|
|
919
|
+
const attrName = listName ? propToAttrName(listName) : propToAttrName(field);
|
|
920
|
+
const isImage = element.dataset.orionEditKind === "image" || element instanceof HTMLImageElement;
|
|
921
|
+
const placeholder = element.dataset.orionPlaceholder || "";
|
|
922
|
+
element.setAttribute("title", isImage ? "Click to replace image" : "Click and type to edit");
|
|
923
|
+
element.style.cursor = "text";
|
|
924
|
+
element.addEventListener("pointerdown", (event) => {
|
|
925
|
+
event.stopPropagation();
|
|
926
|
+
if (typeof event.stopImmediatePropagation === "function") {
|
|
927
|
+
event.stopImmediatePropagation();
|
|
928
|
+
}
|
|
929
|
+
if (!isImage) {
|
|
930
|
+
markActiveEditableField(view.model, field, element);
|
|
931
|
+
}
|
|
932
|
+
editor.select?.(view.model);
|
|
933
|
+
}, true);
|
|
934
|
+
element.addEventListener("click", (event) => {
|
|
935
|
+
event.stopPropagation();
|
|
936
|
+
if (!isImage) {
|
|
937
|
+
markActiveEditableField(view.model, field, element);
|
|
938
|
+
}
|
|
939
|
+
editor.select?.(view.model);
|
|
940
|
+
if (!isImage) {
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
element.style.cursor = "pointer";
|
|
944
|
+
const currentSrc = element instanceof HTMLImageElement ? element.currentSrc || element.src || "" : element.style.backgroundImage.replace(/^url\(["']?/, "").replace(/["']?\)$/, "");
|
|
945
|
+
chooseAsset(editor, currentSrc, (src) => {
|
|
946
|
+
if (listName && Number.isInteger(listIndex)) {
|
|
947
|
+
updateJsonListAttribute({
|
|
948
|
+
field,
|
|
949
|
+
index: listIndex,
|
|
950
|
+
listAttr: attrName,
|
|
951
|
+
model: view.model,
|
|
952
|
+
value: src
|
|
953
|
+
});
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
view.model.addAttributes?.({
|
|
957
|
+
[attrName]: src
|
|
958
|
+
});
|
|
959
|
+
});
|
|
960
|
+
});
|
|
961
|
+
if (isImage) {
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
964
|
+
element.setAttribute("contenteditable", "true");
|
|
965
|
+
element.setAttribute("spellcheck", "true");
|
|
966
|
+
const commit = () => {
|
|
967
|
+
const typedValue = element.innerText.trim();
|
|
968
|
+
const value = placeholder && typedValue === placeholder ? "" : typedValue;
|
|
969
|
+
if (listName && Number.isInteger(listIndex)) {
|
|
970
|
+
updateJsonListAttribute({
|
|
971
|
+
field,
|
|
972
|
+
index: listIndex,
|
|
973
|
+
listAttr: attrName,
|
|
974
|
+
model: view.model,
|
|
975
|
+
value
|
|
976
|
+
});
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
view.model.addAttributes?.({
|
|
980
|
+
[attrName]: value
|
|
981
|
+
});
|
|
982
|
+
};
|
|
983
|
+
element.addEventListener("blur", commit);
|
|
984
|
+
element.addEventListener("keydown", (event) => {
|
|
985
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
986
|
+
event.preventDefault();
|
|
987
|
+
element.blur();
|
|
988
|
+
}
|
|
989
|
+
});
|
|
990
|
+
});
|
|
991
|
+
};
|
|
992
|
+
var registerProjectDynamicComponents = (editor, adapter) => {
|
|
993
|
+
const components = adapter?.components || {};
|
|
994
|
+
Object.keys(components).forEach((type) => {
|
|
995
|
+
const definition = normalizeDefinition(type, components[type]);
|
|
996
|
+
if (!definition) {
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
999
|
+
editor.DomComponents.addType(`orion-${type}`, {
|
|
1000
|
+
model: {
|
|
1001
|
+
defaults: {
|
|
1002
|
+
attributes: {
|
|
1003
|
+
"data-orion-component": type,
|
|
1004
|
+
"data-orion-id": `${type}-${Date.now()}`
|
|
1005
|
+
},
|
|
1006
|
+
components: "",
|
|
1007
|
+
droppable: false,
|
|
1008
|
+
tagName: "div",
|
|
1009
|
+
traits: [
|
|
1010
|
+
...(definition.traits || []).map((trait) => ({
|
|
1011
|
+
label: trait.label,
|
|
1012
|
+
name: `data-orion-${trait.name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`)}`,
|
|
1013
|
+
options: trait.options,
|
|
1014
|
+
placeholder: trait.placeholder,
|
|
1015
|
+
type: trait.type
|
|
1016
|
+
}))
|
|
1017
|
+
]
|
|
1018
|
+
}
|
|
1019
|
+
},
|
|
1020
|
+
view: {
|
|
1021
|
+
init() {
|
|
1022
|
+
this.listenTo(this.model, "change:attributes", this.renderPreview);
|
|
1023
|
+
this.listenTo(this.model, "change:style", () => syncModelBackgroundToBlock(this.model));
|
|
1024
|
+
this.renderPreview();
|
|
1025
|
+
},
|
|
1026
|
+
renderPreview() {
|
|
1027
|
+
const attributes = this.model.getAttributes?.() || {};
|
|
1028
|
+
const props = propsFromAttributes(attributes);
|
|
1029
|
+
const backgroundColor = defaultBackgroundForComponent(type, props);
|
|
1030
|
+
if (backgroundColor && !normalizeCssColor(this.model.getStyle?.()?.["background-color"])) {
|
|
1031
|
+
this.model.addStyle?.({ "background-color": backgroundColor });
|
|
1032
|
+
this.model.addAttributes?.({ "data-orion-background-color": backgroundColor });
|
|
1033
|
+
}
|
|
1034
|
+
this.model.components(previewForDefinition(definition, props));
|
|
1035
|
+
lockPreviewChildren(this.model);
|
|
1036
|
+
queueMicrotask(() => bindEditablePreview(this, editor));
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1040
|
+
editor.Blocks.add(`orion-dynamic-${type}`, {
|
|
1041
|
+
category: "Project",
|
|
1042
|
+
content: {
|
|
1043
|
+
type: `orion-${type}`
|
|
1044
|
+
},
|
|
1045
|
+
label: definition.label,
|
|
1046
|
+
media: blockPreviewForDefinition(type)
|
|
1047
|
+
});
|
|
1048
|
+
});
|
|
1049
|
+
};
|
|
1050
|
+
|
|
1051
|
+
// src/builder-v2/editor/GrapesPageEditor.tsx
|
|
1052
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1053
|
+
var quickLayoutOptions = [
|
|
1054
|
+
{ description: "Normal page section flow.", label: "Natural", value: "natural" },
|
|
1055
|
+
{ description: "Stack children vertically.", label: "Stacked", value: "stacked" },
|
|
1056
|
+
{ description: "Place children in one flexible row.", label: "Row", value: "row" },
|
|
1057
|
+
{ description: "Split content into two columns.", label: "Two column", value: "two-column" },
|
|
1058
|
+
{ description: "Use a three-column card/grid layout.", label: "Three column", value: "three-column" },
|
|
1059
|
+
{ description: "Center content in the section.", label: "Centered", value: "centered" },
|
|
1060
|
+
{ description: "Prepare the section for layered content.", label: "Overlay", value: "overlay" }
|
|
1061
|
+
];
|
|
1062
|
+
var quickSpacingOptions = [
|
|
1063
|
+
{ label: "Compact", value: "compact" },
|
|
1064
|
+
{ label: "Medium", value: "medium" },
|
|
1065
|
+
{ label: "Spacious", value: "spacious" }
|
|
1066
|
+
];
|
|
1067
|
+
var horizontalAlignOptions = [
|
|
1068
|
+
{ label: "Left", value: "left" },
|
|
1069
|
+
{ label: "Center", value: "center" },
|
|
1070
|
+
{ label: "Right", value: "right" }
|
|
1071
|
+
];
|
|
1072
|
+
var verticalAlignOptions = [
|
|
1073
|
+
{ label: "Top", value: "top" },
|
|
1074
|
+
{ label: "Middle", value: "middle" },
|
|
1075
|
+
{ label: "Bottom", value: "bottom" }
|
|
1076
|
+
];
|
|
1077
|
+
var builderSettingHelp = {
|
|
1078
|
+
"align items": "Controls how flex children align across the section, such as top, center, bottom, or stretch.",
|
|
1079
|
+
background: "Sets the full background style for the selected element. Use carefully when combining images, colors, or gradients.",
|
|
1080
|
+
"background color": "Sets the background color behind the selected element content.",
|
|
1081
|
+
"background image url": "The image shown behind this section. Use a media URL from the site media library or uploaded asset.",
|
|
1082
|
+
border: "Controls the selected element border width, style, and color.",
|
|
1083
|
+
"border radius": "Rounds the corners of the selected element.",
|
|
1084
|
+
bottom: "Offsets positioned elements from the bottom. This only applies when Position is relative, absolute, or fixed.",
|
|
1085
|
+
"box shadow": "Adds depth behind the selected element.",
|
|
1086
|
+
color: "Sets the text color for the selected element.",
|
|
1087
|
+
description: "Supporting body copy for this section.",
|
|
1088
|
+
display: "Controls how the element participates in layout. Flex unlocks child alignment and gap controls; none hides the element.",
|
|
1089
|
+
eyebrow: "Small label text shown above the main title or headline.",
|
|
1090
|
+
"flex direction": "Controls whether flex children flow in a row or column. Only applies when Display is flex.",
|
|
1091
|
+
"flex wrap": "Controls whether flex children can wrap onto another row. Only applies when Display is flex.",
|
|
1092
|
+
"font family": "Controls the typeface used by the selected text.",
|
|
1093
|
+
"font size": "Controls how large the selected text appears.",
|
|
1094
|
+
"font weight": "Controls the thickness of the selected text.",
|
|
1095
|
+
"form type": "Chooses which site form this section should render.",
|
|
1096
|
+
gap: "Adds space between child elements. This is most useful when Display is flex or grid.",
|
|
1097
|
+
headline: "Main heading text for this section.",
|
|
1098
|
+
height: "Sets an exact element height. Use sparingly because fixed heights can clip content on smaller screens.",
|
|
1099
|
+
kicker: "Small label text shown above the main hero headline.",
|
|
1100
|
+
left: "Offsets positioned elements from the left. This only applies when Position is relative, absolute, or fixed.",
|
|
1101
|
+
"letter spacing": "Adjusts the space between letters.",
|
|
1102
|
+
"line height": "Controls vertical spacing between lines of text.",
|
|
1103
|
+
margin: "Adds space outside the selected element.",
|
|
1104
|
+
"min height": "Sets the minimum height while still allowing content to grow. Usually better than fixed Height for sections.",
|
|
1105
|
+
opacity: "Controls transparency. Lower values make the selected element more see-through.",
|
|
1106
|
+
padding: "Adds space inside the selected element between its border and content.",
|
|
1107
|
+
position: "Controls whether the element stays in normal flow or can be offset/pinned.",
|
|
1108
|
+
"primary label": "Text for the primary call-to-action button.",
|
|
1109
|
+
"primary link": "Destination URL for the primary call-to-action button.",
|
|
1110
|
+
right: "Offsets positioned elements from the right. This only applies when Position is relative, absolute, or fixed.",
|
|
1111
|
+
"secondary label": "Text for the secondary call-to-action button.",
|
|
1112
|
+
"secondary link": "Destination URL for the secondary call-to-action button.",
|
|
1113
|
+
style: "Selects the visual variant for this component.",
|
|
1114
|
+
subheadline: "Supporting text below the main hero headline.",
|
|
1115
|
+
subtitle: "Supporting text below the section title.",
|
|
1116
|
+
text: "Editable rich text or body content for this section.",
|
|
1117
|
+
"text align": "Controls horizontal text alignment.",
|
|
1118
|
+
title: "Main title text for this section.",
|
|
1119
|
+
top: "Offsets positioned elements from the top. This only applies when Position is relative, absolute, or fixed.",
|
|
1120
|
+
variant: "Selects the layout or visual variant for this component.",
|
|
1121
|
+
width: "Sets the element width. Applies to block, inline-block, flex, grid, absolute, and fixed elements."
|
|
1122
|
+
};
|
|
1123
|
+
var normalizeHelpKey = (value) => value.replace(/\s+/g, " ").trim().toLowerCase();
|
|
1124
|
+
var readDetailedLayoutControlState = (component) => {
|
|
1125
|
+
const style = component?.getStyle?.() || {};
|
|
1126
|
+
return {
|
|
1127
|
+
display: getStyleString(style, "display") || "block",
|
|
1128
|
+
position: getStyleString(style, "position") || "static"
|
|
1129
|
+
};
|
|
1130
|
+
};
|
|
1131
|
+
var decorateBuilderSettingHelp = (root = document) => {
|
|
1132
|
+
const elements = root.querySelectorAll(
|
|
1133
|
+
[
|
|
1134
|
+
".orion-builder-v2-choice",
|
|
1135
|
+
".orion-builder-v2-segmented button",
|
|
1136
|
+
".orion-builder-v2-toggle",
|
|
1137
|
+
".gjs-sm-label",
|
|
1138
|
+
".gjs-label",
|
|
1139
|
+
".gjs-trt-trait__label",
|
|
1140
|
+
".gjs-sm-radio-item-label",
|
|
1141
|
+
".gjs-sm-sector-title"
|
|
1142
|
+
].join(",")
|
|
1143
|
+
);
|
|
1144
|
+
elements.forEach((element) => {
|
|
1145
|
+
const text = normalizeHelpKey(element.textContent || element.getAttribute("aria-label") || "");
|
|
1146
|
+
const help = builderSettingHelp[text];
|
|
1147
|
+
if (!help) {
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
element.setAttribute("aria-description", help);
|
|
1151
|
+
element.dataset.builderSettingHelp = help;
|
|
1152
|
+
if (!element.querySelector(":scope > .orion-builder-v2-help-trigger")) {
|
|
1153
|
+
const trigger = document.createElement("span");
|
|
1154
|
+
trigger.setAttribute("aria-label", `Show help: ${element.textContent?.trim() || "setting"}`);
|
|
1155
|
+
trigger.className = "orion-builder-v2-help-trigger";
|
|
1156
|
+
trigger.dataset.builderHelpText = help;
|
|
1157
|
+
trigger.role = "button";
|
|
1158
|
+
trigger.tabIndex = 0;
|
|
1159
|
+
trigger.textContent = "?";
|
|
1160
|
+
element.appendChild(trigger);
|
|
1161
|
+
}
|
|
1162
|
+
});
|
|
1163
|
+
};
|
|
1164
|
+
var findColorInputForControl = (element) => {
|
|
1165
|
+
const field = element.closest(".gjs-field-color") || element.closest(".gjs-sm-property") || element.closest("label");
|
|
1166
|
+
return field?.querySelector(
|
|
1167
|
+
'input:not([type="hidden"]):not([disabled]), input[type="color"]:not([disabled])'
|
|
1168
|
+
) || null;
|
|
1169
|
+
};
|
|
1170
|
+
var applyColorValueToInput = (input, color) => {
|
|
1171
|
+
input.value = color;
|
|
1172
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
1173
|
+
input.dispatchEvent(new Event("change", { bubbles: true }));
|
|
1174
|
+
};
|
|
1175
|
+
var openScreenColorPickerForInput = async (input) => {
|
|
1176
|
+
const EyeDropper = window.EyeDropper;
|
|
1177
|
+
if (!EyeDropper) {
|
|
1178
|
+
return false;
|
|
1179
|
+
}
|
|
1180
|
+
const result = await new EyeDropper().open();
|
|
1181
|
+
applyColorValueToInput(input, result.sRGBHex);
|
|
1182
|
+
return true;
|
|
1183
|
+
};
|
|
1184
|
+
var decorateBuilderColorEyeDroppers = (root = document) => {
|
|
1185
|
+
const supportsEyeDropper = Boolean(window.EyeDropper);
|
|
1186
|
+
const colorFields = root.querySelectorAll(".gjs-field-color");
|
|
1187
|
+
colorFields.forEach((field) => {
|
|
1188
|
+
const input = findColorInputForControl(field);
|
|
1189
|
+
const swatch = field.querySelector(".gjs-field-colorp");
|
|
1190
|
+
if (!supportsEyeDropper || !input || !swatch || field.querySelector(":scope > .orion-builder-v2-eyedropper")) {
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1193
|
+
field.classList.add("has-orion-eyedropper");
|
|
1194
|
+
const button = document.createElement("button");
|
|
1195
|
+
button.type = "button";
|
|
1196
|
+
button.className = "orion-builder-v2-eyedropper";
|
|
1197
|
+
button.dataset.orionColorEyedropper = "true";
|
|
1198
|
+
button.setAttribute("aria-label", "Pick color from screen");
|
|
1199
|
+
button.setAttribute("title", "Pick color from screen");
|
|
1200
|
+
button.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M14.7 4.3a2.4 2.4 0 0 1 3.4 0l1.6 1.6a2.4 2.4 0 0 1 0 3.4l-1.2 1.2 1 1a1 1 0 1 1-1.4 1.4l-1-1-8.9 8.9H4v-4.2l8.9-8.9-1-1a1 1 0 0 1 1.4-1.4l1 1 1.4-1.4Zm-.4 4.8-8.3 8.3V19h1.6l8.3-8.3-1.6-1.6Z" fill="currentColor"/></svg>';
|
|
1201
|
+
swatch.insertAdjacentElement("afterend", button);
|
|
1202
|
+
});
|
|
1203
|
+
};
|
|
1204
|
+
var closeBuilderHelpPopovers = (except) => {
|
|
1205
|
+
document.querySelectorAll(".is-builder-help-open").forEach((element) => {
|
|
1206
|
+
if (element !== except) {
|
|
1207
|
+
element.classList.remove("is-builder-help-open");
|
|
1208
|
+
element.classList.remove("is-builder-help-left", "is-builder-help-center", "is-builder-help-right");
|
|
1209
|
+
}
|
|
1210
|
+
});
|
|
1211
|
+
};
|
|
1212
|
+
var openBuilderHelpPopover = (trigger, wrapper, isOpen) => {
|
|
1213
|
+
if (!wrapper) {
|
|
1214
|
+
return;
|
|
1215
|
+
}
|
|
1216
|
+
wrapper.classList.remove("is-builder-help-left", "is-builder-help-center", "is-builder-help-right");
|
|
1217
|
+
if (!isOpen) {
|
|
1218
|
+
wrapper.classList.remove("is-builder-help-open");
|
|
1219
|
+
return;
|
|
1220
|
+
}
|
|
1221
|
+
const triggerRect = trigger.getBoundingClientRect();
|
|
1222
|
+
const viewportWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
1223
|
+
const tooltipHalfWidth = 140;
|
|
1224
|
+
const viewportGutter = 18;
|
|
1225
|
+
const triggerCenter = triggerRect.left + triggerRect.width / 2;
|
|
1226
|
+
if (triggerCenter - tooltipHalfWidth < viewportGutter) {
|
|
1227
|
+
wrapper.classList.add("is-builder-help-left");
|
|
1228
|
+
} else if (triggerCenter + tooltipHalfWidth > viewportWidth - viewportGutter) {
|
|
1229
|
+
wrapper.classList.add("is-builder-help-right");
|
|
1230
|
+
} else {
|
|
1231
|
+
wrapper.classList.add("is-builder-help-center");
|
|
1232
|
+
}
|
|
1233
|
+
wrapper.classList.add("is-builder-help-open");
|
|
1234
|
+
};
|
|
1235
|
+
var positionColorPickerFromAnchor = (anchor) => {
|
|
1236
|
+
if (!anchor) {
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
window.requestAnimationFrame(() => {
|
|
1240
|
+
const picker = document.querySelector(".sp-container.gjs-editor-sp:not(.sp-hidden)");
|
|
1241
|
+
if (!picker) {
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
1244
|
+
const anchorRect = anchor.getBoundingClientRect();
|
|
1245
|
+
const pickerRect = picker.getBoundingClientRect();
|
|
1246
|
+
const viewportPadding = 12;
|
|
1247
|
+
const left = Math.min(
|
|
1248
|
+
Math.max(viewportPadding, anchorRect.right - pickerRect.width),
|
|
1249
|
+
Math.max(viewportPadding, window.innerWidth - pickerRect.width - viewportPadding)
|
|
1250
|
+
);
|
|
1251
|
+
const top = Math.min(anchorRect.bottom + 8, Math.max(viewportPadding, window.innerHeight - pickerRect.height - viewportPadding));
|
|
1252
|
+
picker.style.left = `${left}px`;
|
|
1253
|
+
picker.style.right = "auto";
|
|
1254
|
+
picker.style.top = `${top}px`;
|
|
1255
|
+
});
|
|
1256
|
+
};
|
|
1257
|
+
var detailedLayoutClassNames = ({ display, position }) => {
|
|
1258
|
+
const normalizedDisplay = normalizeHelpKey(display || "block");
|
|
1259
|
+
const normalizedPosition = normalizeHelpKey(position || "static");
|
|
1260
|
+
const supportsGap = normalizedDisplay === "flex" || normalizedDisplay === "grid";
|
|
1261
|
+
const supportsFlexControls = normalizedDisplay === "flex";
|
|
1262
|
+
const supportsSize = normalizedDisplay === "block" || normalizedDisplay === "inline-block" || normalizedDisplay === "flex" || normalizedDisplay === "grid" || normalizedPosition === "absolute" || normalizedPosition === "fixed";
|
|
1263
|
+
const supportsOffsets = normalizedPosition === "relative" || normalizedPosition === "absolute" || normalizedPosition === "fixed";
|
|
1264
|
+
return [
|
|
1265
|
+
supportsGap ? "can-use-gap" : "cannot-use-gap",
|
|
1266
|
+
supportsFlexControls ? "can-use-flex-controls" : "cannot-use-flex-controls",
|
|
1267
|
+
supportsOffsets ? "can-use-position-offsets" : "cannot-use-position-offsets",
|
|
1268
|
+
supportsSize ? "can-use-sizing-controls" : "cannot-use-sizing-controls"
|
|
1269
|
+
].join(" ");
|
|
1270
|
+
};
|
|
1271
|
+
var HelpTrigger = ({ help, label }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1272
|
+
"span",
|
|
1273
|
+
{
|
|
1274
|
+
"aria-label": `Show help: ${label}`,
|
|
1275
|
+
className: "orion-builder-v2-help-trigger",
|
|
1276
|
+
"data-builder-help-text": help,
|
|
1277
|
+
role: "button",
|
|
1278
|
+
tabIndex: 0,
|
|
1279
|
+
children: "?"
|
|
1280
|
+
}
|
|
1281
|
+
);
|
|
1282
|
+
var layoutStyleReset = {
|
|
1283
|
+
"align-items": "",
|
|
1284
|
+
"display": "",
|
|
1285
|
+
"flex-direction": "",
|
|
1286
|
+
"flex-wrap": "",
|
|
1287
|
+
"gap": "",
|
|
1288
|
+
"grid-template-columns": "",
|
|
1289
|
+
"justify-content": "",
|
|
1290
|
+
"margin-left": "",
|
|
1291
|
+
"margin-right": "",
|
|
1292
|
+
"min-height": "",
|
|
1293
|
+
"place-items": "",
|
|
1294
|
+
"position": "",
|
|
1295
|
+
"text-align": ""
|
|
1296
|
+
};
|
|
1297
|
+
var quickLayoutStyles = {
|
|
1298
|
+
centered: {
|
|
1299
|
+
...layoutStyleReset,
|
|
1300
|
+
display: "block",
|
|
1301
|
+
"margin-left": "auto",
|
|
1302
|
+
"margin-right": "auto",
|
|
1303
|
+
"text-align": "center"
|
|
1304
|
+
},
|
|
1305
|
+
natural: layoutStyleReset,
|
|
1306
|
+
overlay: {
|
|
1307
|
+
...layoutStyleReset,
|
|
1308
|
+
display: "grid",
|
|
1309
|
+
"min-height": "420px",
|
|
1310
|
+
"place-items": "center",
|
|
1311
|
+
position: "relative",
|
|
1312
|
+
"text-align": "center"
|
|
1313
|
+
},
|
|
1314
|
+
row: {
|
|
1315
|
+
...layoutStyleReset,
|
|
1316
|
+
display: "flex",
|
|
1317
|
+
"flex-direction": "row",
|
|
1318
|
+
"flex-wrap": "wrap",
|
|
1319
|
+
gap: "24px"
|
|
1320
|
+
},
|
|
1321
|
+
stacked: {
|
|
1322
|
+
...layoutStyleReset,
|
|
1323
|
+
display: "block"
|
|
1324
|
+
},
|
|
1325
|
+
"three-column": {
|
|
1326
|
+
...layoutStyleReset,
|
|
1327
|
+
display: "grid",
|
|
1328
|
+
gap: "24px",
|
|
1329
|
+
"grid-template-columns": "repeat(3, minmax(0, 1fr))"
|
|
1330
|
+
},
|
|
1331
|
+
"two-column": {
|
|
1332
|
+
...layoutStyleReset,
|
|
1333
|
+
display: "grid",
|
|
1334
|
+
gap: "24px",
|
|
1335
|
+
"grid-template-columns": "repeat(2, minmax(0, 1fr))"
|
|
1336
|
+
}
|
|
1337
|
+
};
|
|
1338
|
+
var quickSpacingStyles = {
|
|
1339
|
+
compact: "32px 24px",
|
|
1340
|
+
medium: "64px 24px",
|
|
1341
|
+
spacious: "96px 24px"
|
|
1342
|
+
};
|
|
1343
|
+
var quickHorizontalAlignStyles = {
|
|
1344
|
+
center: { "justify-content": "center", "text-align": "center" },
|
|
1345
|
+
left: { "justify-content": "flex-start", "text-align": "left" },
|
|
1346
|
+
right: { "justify-content": "flex-end", "text-align": "right" }
|
|
1347
|
+
};
|
|
1348
|
+
var quickVerticalAlignStyles = {
|
|
1349
|
+
bottom: "flex-end",
|
|
1350
|
+
middle: "center",
|
|
1351
|
+
top: "flex-start"
|
|
1352
|
+
};
|
|
1353
|
+
var canvasSelectionCss = `
|
|
1354
|
+
.gjs-selected,
|
|
1355
|
+
[data-gjs-highlightable].gjs-selected {
|
|
1356
|
+
outline-color: #c7643d !important;
|
|
1357
|
+
outline-width: 2px !important;
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
.gjs-hovered,
|
|
1361
|
+
[data-gjs-highlightable].gjs-hovered {
|
|
1362
|
+
outline-color: #c7643d !important;
|
|
1363
|
+
}
|
|
1364
|
+
`;
|
|
1365
|
+
var isQuickHorizontalAlign = (value) => value === "center" || value === "left" || value === "right";
|
|
1366
|
+
var isQuickVerticalAlign = (value) => value === "bottom" || value === "middle" || value === "top";
|
|
1367
|
+
var getStyleString = (style, property) => {
|
|
1368
|
+
const value = style[property];
|
|
1369
|
+
return typeof value === "string" ? value : "";
|
|
1370
|
+
};
|
|
1371
|
+
var parseOrionBlockAttribute = (value) => {
|
|
1372
|
+
const decoded = decodeHtmlAttribute3(value);
|
|
1373
|
+
if (!decoded) {
|
|
1374
|
+
return {};
|
|
1375
|
+
}
|
|
1376
|
+
try {
|
|
1377
|
+
const parsed = JSON.parse(decoded);
|
|
1378
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
1379
|
+
} catch {
|
|
1380
|
+
return {};
|
|
1381
|
+
}
|
|
1382
|
+
};
|
|
1383
|
+
var serializeOrionBlockAttribute = (block) => JSON.stringify(block);
|
|
1384
|
+
var readNestedRecord = (value, key) => {
|
|
1385
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
1386
|
+
return {};
|
|
1387
|
+
}
|
|
1388
|
+
const nested = value[key];
|
|
1389
|
+
return nested && typeof nested === "object" && !Array.isArray(nested) ? nested : {};
|
|
1390
|
+
};
|
|
1391
|
+
var firstString = (...values) => {
|
|
1392
|
+
for (const value of values) {
|
|
1393
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
1394
|
+
return value.trim();
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
return "";
|
|
1398
|
+
};
|
|
1399
|
+
var normalizeCssSizeValue = (value) => {
|
|
1400
|
+
if (typeof value !== "string") {
|
|
1401
|
+
return "";
|
|
1402
|
+
}
|
|
1403
|
+
const trimmed = value.trim();
|
|
1404
|
+
return /^-?\d*\.?\d+(px|pt|rem|em|%)?$/.test(trimmed) || trimmed === "normal" ? trimmed : "";
|
|
1405
|
+
};
|
|
1406
|
+
var normalizeCssColorValue = (value) => {
|
|
1407
|
+
if (typeof value !== "string") {
|
|
1408
|
+
return "";
|
|
1409
|
+
}
|
|
1410
|
+
const trimmed = value.trim();
|
|
1411
|
+
return trimmed && trimmed !== "none" ? trimmed : "";
|
|
1412
|
+
};
|
|
1413
|
+
var getStyleColorValue = (style, property) => normalizeCssColorValue(
|
|
1414
|
+
style[property] || style[property.replace(/-([a-z])/g, (_, char) => char.toUpperCase())]
|
|
1415
|
+
);
|
|
1416
|
+
var normalizeFontFamilyValue = (value) => {
|
|
1417
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
1418
|
+
return "";
|
|
1419
|
+
}
|
|
1420
|
+
const trimmed = value.trim();
|
|
1421
|
+
const normalized = trimmed.replace(/["']/g, "").toLowerCase();
|
|
1422
|
+
if (normalized === "inherit") {
|
|
1423
|
+
return "inherit";
|
|
1424
|
+
}
|
|
1425
|
+
if (normalized.includes("caveat") || normalized.includes("brush script")) {
|
|
1426
|
+
return '"Caveat", "Brush Script MT", cursive';
|
|
1427
|
+
}
|
|
1428
|
+
if (normalized.includes("georgia")) {
|
|
1429
|
+
return 'Georgia, "Times New Roman", serif';
|
|
1430
|
+
}
|
|
1431
|
+
if (normalized.includes("times new roman") && !normalized.includes("georgia")) {
|
|
1432
|
+
return '"Times New Roman", Times, serif';
|
|
1433
|
+
}
|
|
1434
|
+
if (normalized.includes("arial") || normalized.includes("helvetica")) {
|
|
1435
|
+
return "Arial, Helvetica, sans-serif";
|
|
1436
|
+
}
|
|
1437
|
+
if (normalized.includes("inter") || normalized.includes("segoe ui") || normalized.includes("system-ui")) {
|
|
1438
|
+
return 'Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif';
|
|
1439
|
+
}
|
|
1440
|
+
return trimmed;
|
|
1441
|
+
};
|
|
1442
|
+
var normalizeFontWeightValue = (value) => {
|
|
1443
|
+
if (typeof value !== "string" && typeof value !== "number") {
|
|
1444
|
+
return "";
|
|
1445
|
+
}
|
|
1446
|
+
const trimmed = String(value).trim();
|
|
1447
|
+
return /^(normal|bold|bolder|lighter|[1-9]00)$/.test(trimmed) ? trimmed : "";
|
|
1448
|
+
};
|
|
1449
|
+
var normalizeStyleTextAlignment = (value) => value === "center" || value === "left" || value === "right" ? value : "";
|
|
1450
|
+
var typographyKey = (kind, property) => `${kind}${property}`;
|
|
1451
|
+
var readStylePanelValue = (property) => {
|
|
1452
|
+
const panel = document.getElementById("orion-builder-v2-styles");
|
|
1453
|
+
const control = panel?.querySelector(`.gjs-sm-property__${CSS.escape(property)}`);
|
|
1454
|
+
return control || null;
|
|
1455
|
+
};
|
|
1456
|
+
var readStylePanelLength = (property) => {
|
|
1457
|
+
const control = readStylePanelValue(property);
|
|
1458
|
+
const value = control?.querySelector("input")?.value.trim() || "";
|
|
1459
|
+
const unit = control?.querySelector("select")?.value.trim() || "";
|
|
1460
|
+
if (!value) {
|
|
1461
|
+
return "";
|
|
1462
|
+
}
|
|
1463
|
+
if (value === "normal") {
|
|
1464
|
+
return value;
|
|
1465
|
+
}
|
|
1466
|
+
return `${value}${unit}`;
|
|
1467
|
+
};
|
|
1468
|
+
var readStylePanelSelect = (property) => (readStylePanelValue(property)?.querySelector("select")?.value || "").trim();
|
|
1469
|
+
var readStylePanelInput = (property) => (readStylePanelValue(property)?.querySelector("input")?.value || "").trim();
|
|
1470
|
+
var readStylePanelColor = (property) => {
|
|
1471
|
+
const control = readStylePanelValue(property);
|
|
1472
|
+
const inputValue = (control?.querySelector("input")?.value || "").trim();
|
|
1473
|
+
if (inputValue && inputValue !== "none") {
|
|
1474
|
+
return inputValue;
|
|
1475
|
+
}
|
|
1476
|
+
const swatchColor = (control?.querySelector(".gjs-field-color-picker")?.style.backgroundColor || "").trim();
|
|
1477
|
+
return swatchColor;
|
|
1478
|
+
};
|
|
1479
|
+
var readStylePanelRadio = (property) => (readStylePanelValue(property)?.querySelector("input:checked")?.value || "").trim();
|
|
1480
|
+
var hasExplicitHorizontalAlign = (block) => {
|
|
1481
|
+
const settings = readNestedRecord(block, "settings");
|
|
1482
|
+
const typography = readNestedRecord(settings, "typography");
|
|
1483
|
+
return Boolean(
|
|
1484
|
+
firstString(
|
|
1485
|
+
block.horizontalAlign,
|
|
1486
|
+
block.textHeadingAlign,
|
|
1487
|
+
block.textBodyAlign,
|
|
1488
|
+
typography.headingAlign,
|
|
1489
|
+
typography.bodyAlign
|
|
1490
|
+
)
|
|
1491
|
+
);
|
|
1492
|
+
};
|
|
1493
|
+
var hasExplicitVerticalAlign = (block) => Boolean(firstString(block.verticalAlign));
|
|
1494
|
+
var inferComponentHorizontalAlign = (attributes, block) => {
|
|
1495
|
+
const componentType = String(attributes["data-orion-component"] || "");
|
|
1496
|
+
const settings = readNestedRecord(block, "settings");
|
|
1497
|
+
const typography = readNestedRecord(settings, "typography");
|
|
1498
|
+
const blockType = firstString(block.blockType, componentType);
|
|
1499
|
+
const variant = firstString(block.variant, attributes["data-orion-variant"]);
|
|
1500
|
+
const inferred = firstString(
|
|
1501
|
+
block.horizontalAlign,
|
|
1502
|
+
block.textHeadingAlign,
|
|
1503
|
+
block.textBodyAlign,
|
|
1504
|
+
attributes["data-orion-horizontal-align"],
|
|
1505
|
+
variant === "quoteBanner" ? "" : typography.headingAlign,
|
|
1506
|
+
variant === "quoteBanner" ? "" : typography.bodyAlign
|
|
1507
|
+
);
|
|
1508
|
+
if (isQuickHorizontalAlign(inferred)) {
|
|
1509
|
+
return inferred;
|
|
1510
|
+
}
|
|
1511
|
+
if (componentType === "xoHero" || componentType === "xoCta" || componentType === "xoRichText" || blockType === "cta" || blockType === "richText" || variant === "centered" || variant === "quoteBanner") {
|
|
1512
|
+
return "center";
|
|
1513
|
+
}
|
|
1514
|
+
return "left";
|
|
1515
|
+
};
|
|
1516
|
+
var inferComponentVerticalAlign = (attributes, block) => {
|
|
1517
|
+
const componentType = String(attributes["data-orion-component"] || "");
|
|
1518
|
+
const blockType = firstString(block.blockType, componentType);
|
|
1519
|
+
const variant = firstString(block.variant, attributes["data-orion-variant"]);
|
|
1520
|
+
const inferred = firstString(block.verticalAlign, attributes["data-orion-vertical-align"]);
|
|
1521
|
+
if (isQuickVerticalAlign(inferred)) {
|
|
1522
|
+
return inferred;
|
|
1523
|
+
}
|
|
1524
|
+
if (componentType === "xoHero" || componentType === "xoCta" || componentType === "xoRichText" || blockType === "cta" || blockType === "richText" || variant === "quoteBanner") {
|
|
1525
|
+
return "middle";
|
|
1526
|
+
}
|
|
1527
|
+
return "top";
|
|
1528
|
+
};
|
|
1529
|
+
var readQuickLayoutState = (component) => {
|
|
1530
|
+
const style = component?.getStyle?.() || {};
|
|
1531
|
+
const attributes = component?.getAttributes?.() || {};
|
|
1532
|
+
const orionBlock = parseOrionBlockAttribute(attributes["data-orion-block"]);
|
|
1533
|
+
const display = getStyleString(style, "display");
|
|
1534
|
+
const gridColumns = getStyleString(style, "grid-template-columns");
|
|
1535
|
+
const flexDirection = getStyleString(style, "flex-direction");
|
|
1536
|
+
const textAlign = getStyleString(style, "text-align");
|
|
1537
|
+
const placeItems = getStyleString(style, "place-items");
|
|
1538
|
+
const padding = getStyleString(style, "padding");
|
|
1539
|
+
const position = getStyleString(style, "position");
|
|
1540
|
+
const justifyContent = getStyleString(style, "justify-content");
|
|
1541
|
+
const alignItems = getStyleString(style, "align-items");
|
|
1542
|
+
const layout = display === "none" ? "natural" : gridColumns.includes("repeat(3") ? "three-column" : gridColumns.includes("repeat(2") ? "two-column" : display === "flex" && flexDirection !== "column" ? "row" : placeItems === "center" || position === "relative" ? "overlay" : textAlign === "center" ? "centered" : display === "block" ? "stacked" : "natural";
|
|
1543
|
+
const spacing = padding.includes("96px") ? "spacious" : padding.includes("32px") ? "compact" : "medium";
|
|
1544
|
+
const storedHorizontalAlign = attributes["data-orion-horizontal-align"];
|
|
1545
|
+
const storedVerticalAlign = attributes["data-orion-vertical-align"];
|
|
1546
|
+
const inferredHorizontalAlign = inferComponentHorizontalAlign(attributes, orionBlock);
|
|
1547
|
+
const inferredVerticalAlign = inferComponentVerticalAlign(attributes, orionBlock);
|
|
1548
|
+
const horizontalAlign = isQuickHorizontalAlign(storedHorizontalAlign) && hasExplicitHorizontalAlign(orionBlock) ? storedHorizontalAlign : textAlign === "right" || justifyContent === "flex-end" ? "right" : textAlign === "center" || justifyContent === "center" ? "center" : inferredHorizontalAlign;
|
|
1549
|
+
const verticalAlign = isQuickVerticalAlign(storedVerticalAlign) && hasExplicitVerticalAlign(orionBlock) ? storedVerticalAlign : alignItems === "flex-end" ? "bottom" : alignItems === "center" || placeItems === "center" ? "middle" : inferredVerticalAlign;
|
|
1550
|
+
return {
|
|
1551
|
+
hidden: display === "none",
|
|
1552
|
+
horizontalAlign,
|
|
1553
|
+
layout,
|
|
1554
|
+
spacing,
|
|
1555
|
+
sticky: position === "sticky" || position === "fixed",
|
|
1556
|
+
verticalAlign
|
|
1557
|
+
};
|
|
1558
|
+
};
|
|
1559
|
+
var decodeHtmlAttribute3 = (value) => {
|
|
1560
|
+
if (typeof value !== "string") {
|
|
1561
|
+
return "";
|
|
1562
|
+
}
|
|
1563
|
+
return value.replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
1564
|
+
};
|
|
1565
|
+
var parseItemsJson = (value) => {
|
|
1566
|
+
const decoded = decodeHtmlAttribute3(value);
|
|
1567
|
+
if (!decoded) {
|
|
1568
|
+
return [];
|
|
1569
|
+
}
|
|
1570
|
+
try {
|
|
1571
|
+
const parsed = JSON.parse(decoded);
|
|
1572
|
+
return Array.isArray(parsed) ? parsed.filter((item) => Boolean(item && typeof item === "object" && !Array.isArray(item))) : [];
|
|
1573
|
+
} catch {
|
|
1574
|
+
return [];
|
|
1575
|
+
}
|
|
1576
|
+
};
|
|
1577
|
+
var postToParent = (payload) => {
|
|
1578
|
+
window.parent?.postMessage(
|
|
1579
|
+
{
|
|
1580
|
+
source: "payload-visual-builder-child",
|
|
1581
|
+
...payload
|
|
1582
|
+
},
|
|
1583
|
+
"*"
|
|
1584
|
+
);
|
|
1585
|
+
};
|
|
1586
|
+
var buildSavePayload = (editor, status, projectData) => ({
|
|
1587
|
+
builderMode: "grapes-v2",
|
|
1588
|
+
compiledCss: scopeBuilderCss(editor.getCss()),
|
|
1589
|
+
compiledHtml: sanitizeBuilderHtml(editor.getHtml()),
|
|
1590
|
+
projectData,
|
|
1591
|
+
status
|
|
1592
|
+
});
|
|
1593
|
+
var parsePayloadErrorMessage = async (response, fallback) => {
|
|
1594
|
+
try {
|
|
1595
|
+
const json = await response.json();
|
|
1596
|
+
return json.errors?.[0]?.message || json.message || fallback;
|
|
1597
|
+
} catch {
|
|
1598
|
+
const raw = await response.text();
|
|
1599
|
+
return raw.trim() || fallback;
|
|
1600
|
+
}
|
|
1601
|
+
};
|
|
1602
|
+
var getRelationID = (value) => {
|
|
1603
|
+
if (typeof value === "number" || typeof value === "string") {
|
|
1604
|
+
return value;
|
|
1605
|
+
}
|
|
1606
|
+
if (!value || typeof value !== "object") {
|
|
1607
|
+
return null;
|
|
1608
|
+
}
|
|
1609
|
+
const id = value.id;
|
|
1610
|
+
return typeof id === "number" || typeof id === "string" ? id : null;
|
|
1611
|
+
};
|
|
1612
|
+
var normalizeAssetSrc = (value) => {
|
|
1613
|
+
const trimmed = value.trim();
|
|
1614
|
+
if (!trimmed) {
|
|
1615
|
+
return "";
|
|
1616
|
+
}
|
|
1617
|
+
if (/^(https?:)?\/\//i.test(trimmed) || trimmed.startsWith("/")) {
|
|
1618
|
+
return trimmed;
|
|
1619
|
+
}
|
|
1620
|
+
return `/${trimmed}`;
|
|
1621
|
+
};
|
|
1622
|
+
var mediaDocImageCandidates = (doc) => {
|
|
1623
|
+
const candidates = [];
|
|
1624
|
+
if (doc.sizes && typeof doc.sizes === "object") {
|
|
1625
|
+
Object.values(doc.sizes).forEach((size) => {
|
|
1626
|
+
if (size?.url) {
|
|
1627
|
+
candidates.push({ src: normalizeAssetSrc(size.url), width: size.width });
|
|
1628
|
+
} else if (size?.filename) {
|
|
1629
|
+
candidates.push({ src: `/api/media/file/${encodeURIComponent(size.filename)}`, width: size.width });
|
|
1630
|
+
}
|
|
1631
|
+
});
|
|
1632
|
+
}
|
|
1633
|
+
if (typeof doc.thumbnailURL === "string" && doc.thumbnailURL.length > 0) {
|
|
1634
|
+
candidates.push({ src: normalizeAssetSrc(doc.thumbnailURL), width: 360 });
|
|
1635
|
+
}
|
|
1636
|
+
if (typeof doc.url === "string" && doc.url.length > 0) {
|
|
1637
|
+
candidates.push({ src: normalizeAssetSrc(doc.url), width: doc.width });
|
|
1638
|
+
}
|
|
1639
|
+
if (typeof doc.filename === "string" && doc.filename.length > 0) {
|
|
1640
|
+
candidates.push({ src: `/api/media/file/${encodeURIComponent(doc.filename)}`, width: doc.width });
|
|
1641
|
+
}
|
|
1642
|
+
return candidates.filter((candidate, index, all) => candidate.src && all.findIndex((item) => item.src === candidate.src) === index);
|
|
1643
|
+
};
|
|
1644
|
+
var pickMediaAssetSrc = (doc) => {
|
|
1645
|
+
const candidates = mediaDocImageCandidates(doc);
|
|
1646
|
+
if (candidates.length === 0) {
|
|
1647
|
+
return "";
|
|
1648
|
+
}
|
|
1649
|
+
const absolute = candidates.find((candidate) => /^(https?:)?\/\//i.test(candidate.src));
|
|
1650
|
+
if (absolute) {
|
|
1651
|
+
return absolute.src;
|
|
1652
|
+
}
|
|
1653
|
+
const fullSize = candidates.find((candidate) => candidate.src === doc.url);
|
|
1654
|
+
if (fullSize) {
|
|
1655
|
+
return fullSize.src;
|
|
1656
|
+
}
|
|
1657
|
+
const widest = [...candidates].sort((left, right) => (right.width || 0) - (left.width || 0))[0];
|
|
1658
|
+
return widest?.src || candidates[0]?.src || "";
|
|
1659
|
+
};
|
|
1660
|
+
var mediaDocToAsset = (doc) => {
|
|
1661
|
+
const id = getRelationID(doc);
|
|
1662
|
+
const filename = typeof doc.filename === "string" ? doc.filename : "";
|
|
1663
|
+
const src = pickMediaAssetSrc(doc);
|
|
1664
|
+
if (id === null || !src) {
|
|
1665
|
+
return null;
|
|
1666
|
+
}
|
|
1667
|
+
return {
|
|
1668
|
+
alt: typeof doc.alt === "string" ? doc.alt : "",
|
|
1669
|
+
id,
|
|
1670
|
+
name: filename || String(id),
|
|
1671
|
+
src,
|
|
1672
|
+
type: "image"
|
|
1673
|
+
};
|
|
1674
|
+
};
|
|
1675
|
+
var imageCanLoad = (src) => new Promise((resolve) => {
|
|
1676
|
+
if (!src) {
|
|
1677
|
+
resolve(false);
|
|
1678
|
+
return;
|
|
1679
|
+
}
|
|
1680
|
+
const image = new Image();
|
|
1681
|
+
image.onload = () => resolve(true);
|
|
1682
|
+
image.onerror = () => resolve(false);
|
|
1683
|
+
image.src = src;
|
|
1684
|
+
});
|
|
1685
|
+
var pruneBrokenImageAssets = async (editor) => {
|
|
1686
|
+
const assetManager = editor.AssetManager;
|
|
1687
|
+
const existingAssets = assetManager.getAll?.() || [];
|
|
1688
|
+
for (const asset of existingAssets) {
|
|
1689
|
+
const src = typeof asset.get === "function" ? String(asset.get("src") || "") : "";
|
|
1690
|
+
if (src && !await imageCanLoad(src)) {
|
|
1691
|
+
assetManager.remove?.(asset);
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
};
|
|
1695
|
+
var extractUploadedMedia = (value) => {
|
|
1696
|
+
const candidate = value && typeof value === "object" && "doc" in value ? value.doc : value;
|
|
1697
|
+
if (!candidate || typeof candidate !== "object") {
|
|
1698
|
+
return null;
|
|
1699
|
+
}
|
|
1700
|
+
const id = getRelationID(candidate);
|
|
1701
|
+
if (id === null) {
|
|
1702
|
+
return null;
|
|
1703
|
+
}
|
|
1704
|
+
const typed = candidate;
|
|
1705
|
+
return {
|
|
1706
|
+
alt: typeof typed.alt === "string" ? typed.alt : "",
|
|
1707
|
+
filename: typeof typed.filename === "string" ? typed.filename : "",
|
|
1708
|
+
id,
|
|
1709
|
+
sizes: typed.sizes && typeof typed.sizes === "object" ? typed.sizes : void 0,
|
|
1710
|
+
thumbnailURL: typeof typed.thumbnailURL === "string" ? typed.thumbnailURL : "",
|
|
1711
|
+
url: typeof typed.url === "string" ? typed.url : "",
|
|
1712
|
+
width: typeof typed.width === "number" ? typed.width : void 0
|
|
1713
|
+
};
|
|
1714
|
+
};
|
|
1715
|
+
var loadPayloadMediaAssets = async (editor) => {
|
|
1716
|
+
const response = await fetch(`/api/media?depth=1&limit=100&sort=-updatedAt&_=${Date.now()}`, {
|
|
1717
|
+
cache: "no-store",
|
|
1718
|
+
credentials: "include"
|
|
1719
|
+
});
|
|
1720
|
+
if (!response.ok) {
|
|
1721
|
+
return;
|
|
1722
|
+
}
|
|
1723
|
+
const json = await response.json();
|
|
1724
|
+
const candidateAssets = (Array.isArray(json.docs) ? json.docs : []).map((doc) => mediaDocToAsset(doc)).filter((asset) => asset !== null);
|
|
1725
|
+
const assets = [];
|
|
1726
|
+
for (const asset of candidateAssets) {
|
|
1727
|
+
if (await imageCanLoad(asset.src)) {
|
|
1728
|
+
assets.push(asset);
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
if (assets.length > 0) {
|
|
1732
|
+
editor.AssetManager.add(assets);
|
|
1733
|
+
}
|
|
1734
|
+
await pruneBrokenImageAssets(editor);
|
|
1735
|
+
};
|
|
1736
|
+
var uploadPayloadMediaAssets = async (editor, files) => {
|
|
1737
|
+
const fileArray = Array.from(files);
|
|
1738
|
+
const uploadedAssets = [];
|
|
1739
|
+
for (const file of fileArray) {
|
|
1740
|
+
const optimizedFile = await optimizeImageForUpload(file);
|
|
1741
|
+
if (optimizedFile.size > MAX_DIRECT_UPLOAD_BYTES) {
|
|
1742
|
+
throw new Error("Image is too large. Use an image under 4MB or lower-resolution export.");
|
|
1743
|
+
}
|
|
1744
|
+
const fallbackAlt = file.name.replace(/\.[^/.]+$/, "").trim();
|
|
1745
|
+
const formData = new FormData();
|
|
1746
|
+
formData.set("_payload", JSON.stringify({ alt: fallbackAlt || "Uploaded image" }));
|
|
1747
|
+
formData.set("alt", fallbackAlt || "Uploaded image");
|
|
1748
|
+
formData.set("file", optimizedFile);
|
|
1749
|
+
const response = await fetch("/api/media", {
|
|
1750
|
+
body: formData,
|
|
1751
|
+
credentials: "include",
|
|
1752
|
+
method: "POST"
|
|
1753
|
+
});
|
|
1754
|
+
if (!response.ok) {
|
|
1755
|
+
throw new Error(await parsePayloadErrorMessage(response, "Could not upload image."));
|
|
1756
|
+
}
|
|
1757
|
+
const uploaded = extractUploadedMedia(await response.json());
|
|
1758
|
+
const asset = uploaded ? mediaDocToAsset(uploaded) : null;
|
|
1759
|
+
if (asset) {
|
|
1760
|
+
uploadedAssets.push(asset);
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
if (uploadedAssets.length > 0) {
|
|
1764
|
+
editor.AssetManager.add(uploadedAssets);
|
|
1765
|
+
}
|
|
1766
|
+
};
|
|
1767
|
+
function GrapesPageEditor({
|
|
1768
|
+
adapter,
|
|
1769
|
+
autosaveIntervalMs = 3e4,
|
|
1770
|
+
initialData,
|
|
1771
|
+
pageID
|
|
1772
|
+
}) {
|
|
1773
|
+
const containerRef = (0, import_react.useRef)(null);
|
|
1774
|
+
const editorRef = (0, import_react.useRef)(null);
|
|
1775
|
+
const autosaveTimerRef = (0, import_react.useRef)(null);
|
|
1776
|
+
const saveRef = (0, import_react.useRef)(async () => void 0);
|
|
1777
|
+
const selectedComponentRef = (0, import_react.useRef)(null);
|
|
1778
|
+
const lastSelectedComponentRef = (0, import_react.useRef)(null);
|
|
1779
|
+
const colorPickerAnchorRef = (0, import_react.useRef)(null);
|
|
1780
|
+
const sidebarPointerActiveRef = (0, import_react.useRef)(false);
|
|
1781
|
+
const stylePanelEditActiveRef = (0, import_react.useRef)(false);
|
|
1782
|
+
const historyRestoreActiveRef = (0, import_react.useRef)(false);
|
|
1783
|
+
const stylePanelHistoryBeforeRef = (0, import_react.useRef)(null);
|
|
1784
|
+
const lastComponentSnapshotRef = (0, import_react.useRef)(/* @__PURE__ */ new WeakMap());
|
|
1785
|
+
const customUndoStackRef = (0, import_react.useRef)([]);
|
|
1786
|
+
const customRedoStackRef = (0, import_react.useRef)([]);
|
|
1787
|
+
const syncingOrionBlockStylesRef = (0, import_react.useRef)(false);
|
|
1788
|
+
const [error, setError] = (0, import_react.useState)("");
|
|
1789
|
+
const [historyState, setHistoryState] = (0, import_react.useState)({ canRedo: false, canUndo: false });
|
|
1790
|
+
const [isDirty, setIsDirty] = (0, import_react.useState)(false);
|
|
1791
|
+
const [lastSavedAt, setLastSavedAt] = (0, import_react.useState)("");
|
|
1792
|
+
const [loading, setLoading] = (0, import_react.useState)(true);
|
|
1793
|
+
const [publicationState, setPublicationState] = (0, import_react.useState)("live");
|
|
1794
|
+
const [quickLayoutState, setQuickLayoutState] = (0, import_react.useState)(() => readQuickLayoutState(null));
|
|
1795
|
+
const [selectedDevice, setSelectedDevice] = (0, import_react.useState)("desktop");
|
|
1796
|
+
const [detailedLayoutControlState, setDetailedLayoutControlState] = (0, import_react.useState)(
|
|
1797
|
+
() => readDetailedLayoutControlState(null)
|
|
1798
|
+
);
|
|
1799
|
+
const [saving, setSaving] = (0, import_react.useState)(null);
|
|
1800
|
+
const [saveMessage, setSaveMessage] = (0, import_react.useState)("");
|
|
1801
|
+
const [selectionSummary, setSelectionSummary] = (0, import_react.useState)(null);
|
|
1802
|
+
const [openInspectorPanels, setOpenInspectorPanels] = (0, import_react.useState)({});
|
|
1803
|
+
const [openSidebarPanels, setOpenSidebarPanels] = (0, import_react.useState)({});
|
|
1804
|
+
const [validationIssues, setValidationIssues] = (0, import_react.useState)([]);
|
|
1805
|
+
const editorPageBasePath = initialData?.meta?.editorPageBasePath || "/admin/pages";
|
|
1806
|
+
const pageTree = initialData?.meta?.pageTree || [];
|
|
1807
|
+
const role = initialData?.meta?.permissions?.role || "client";
|
|
1808
|
+
const canUseDeveloperControls = role === "developer";
|
|
1809
|
+
const summarizeSelectedComponent = (component) => {
|
|
1810
|
+
if (!component) {
|
|
1811
|
+
return null;
|
|
1812
|
+
}
|
|
1813
|
+
const attrs = component.getAttributes?.() || {};
|
|
1814
|
+
const componentType = String(attrs["data-orion-component"] || component.get?.("type") || "Section");
|
|
1815
|
+
const rawName = String(component.get?.("name") || componentType || "Section");
|
|
1816
|
+
const label = rawName.replace(/^orion-/, "").replace(/^xo/, "XO ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/-/g, " ").trim();
|
|
1817
|
+
const items = parseItemsJson(attrs["data-orion-items-json"]).map((item, index) => ({
|
|
1818
|
+
index,
|
|
1819
|
+
title: typeof item.title === "string" && item.title.trim() ? item.title.trim() : `Item ${index + 1}`
|
|
1820
|
+
}));
|
|
1821
|
+
return {
|
|
1822
|
+
items: items.length > 0 ? items : void 0,
|
|
1823
|
+
label: label || "Section",
|
|
1824
|
+
type: componentType
|
|
1825
|
+
};
|
|
1826
|
+
};
|
|
1827
|
+
const getCurrentStyleTarget = () => selectedComponentRef.current || lastSelectedComponentRef.current || (editorRef.current?.getSelected?.() || null);
|
|
1828
|
+
const findOrionBlockByElement = (element) => {
|
|
1829
|
+
const target = element?.closest("[data-orion-block]");
|
|
1830
|
+
const targetID = target?.id || "";
|
|
1831
|
+
if (!targetID) {
|
|
1832
|
+
return null;
|
|
1833
|
+
}
|
|
1834
|
+
const editor = editorRef.current;
|
|
1835
|
+
const wrapper = editor?.DomComponents?.getWrapper?.() || null;
|
|
1836
|
+
const component = wrapper?.find?.(`#${CSS.escape(targetID)}`)?.[0] || null;
|
|
1837
|
+
return Object.keys(parseOrionBlockAttribute(component?.getAttributes?.()?.["data-orion-block"])).length > 0 ? component : null;
|
|
1838
|
+
};
|
|
1839
|
+
const findOrionBlockAncestor = (component) => {
|
|
1840
|
+
let current = component;
|
|
1841
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1842
|
+
while (current && !visited.has(current)) {
|
|
1843
|
+
visited.add(current);
|
|
1844
|
+
if (Object.keys(parseOrionBlockAttribute(current.getAttributes?.()?.["data-orion-block"])).length > 0) {
|
|
1845
|
+
return current;
|
|
1846
|
+
}
|
|
1847
|
+
current = current.parent?.() || null;
|
|
1848
|
+
}
|
|
1849
|
+
return null;
|
|
1850
|
+
};
|
|
1851
|
+
const findSelectedCanvasOrionBlock = () => {
|
|
1852
|
+
const editor = editorRef.current;
|
|
1853
|
+
const wrapper = editor?.DomComponents?.getWrapper?.() || null;
|
|
1854
|
+
const candidates = wrapper?.find?.("[data-orion-block]") || [];
|
|
1855
|
+
return candidates.find((candidate) => {
|
|
1856
|
+
const element = candidate.getEl?.();
|
|
1857
|
+
return Boolean(
|
|
1858
|
+
element?.classList.contains("gjs-selected") || element?.matches("[data-gjs-highlightable].gjs-selected, .gjs-selected")
|
|
1859
|
+
);
|
|
1860
|
+
}) || null;
|
|
1861
|
+
};
|
|
1862
|
+
const getCurrentOrionBlockTarget = (component = getCurrentStyleTarget()) => {
|
|
1863
|
+
const ancestor = findOrionBlockAncestor(component);
|
|
1864
|
+
if (ancestor) {
|
|
1865
|
+
return ancestor;
|
|
1866
|
+
}
|
|
1867
|
+
const canvasSelected = findSelectedCanvasOrionBlock();
|
|
1868
|
+
if (canvasSelected) {
|
|
1869
|
+
return canvasSelected;
|
|
1870
|
+
}
|
|
1871
|
+
const editor = editorRef.current;
|
|
1872
|
+
const selected = editor?.getSelected?.() || null;
|
|
1873
|
+
const selectedAncestor = findOrionBlockAncestor(selected);
|
|
1874
|
+
if (selectedAncestor) {
|
|
1875
|
+
return selectedAncestor;
|
|
1876
|
+
}
|
|
1877
|
+
const selectedID = firstString(selected?.getAttributes?.()?.id, component?.getAttributes?.()?.id);
|
|
1878
|
+
const wrapper = editor?.DomComponents?.getWrapper?.() || null;
|
|
1879
|
+
if (!wrapper) {
|
|
1880
|
+
return component || selected || null;
|
|
1881
|
+
}
|
|
1882
|
+
const candidates = [
|
|
1883
|
+
...selectedID ? wrapper.find?.(`#${selectedID}`) || [] : [],
|
|
1884
|
+
...wrapper.find?.("[data-orion-block]") || []
|
|
1885
|
+
];
|
|
1886
|
+
return candidates.find(
|
|
1887
|
+
(candidate) => Object.keys(parseOrionBlockAttribute(candidate.getAttributes?.()?.["data-orion-block"])).length > 0
|
|
1888
|
+
) || component || selected || null;
|
|
1889
|
+
};
|
|
1890
|
+
const selectStyleManagerTarget = (component) => {
|
|
1891
|
+
if (!component) {
|
|
1892
|
+
return;
|
|
1893
|
+
}
|
|
1894
|
+
const editor = editorRef.current;
|
|
1895
|
+
editor?.StyleManager?.select?.(component);
|
|
1896
|
+
};
|
|
1897
|
+
const updateSelectedItems = (updater) => {
|
|
1898
|
+
const component = getCurrentOrionBlockTarget();
|
|
1899
|
+
if (!component) {
|
|
1900
|
+
return;
|
|
1901
|
+
}
|
|
1902
|
+
const attrs = component.getAttributes?.() || {};
|
|
1903
|
+
const currentItems = parseItemsJson(attrs["data-orion-items-json"]);
|
|
1904
|
+
const nextItems = updater(currentItems);
|
|
1905
|
+
const block = parseOrionBlockAttribute(attrs["data-orion-block"]);
|
|
1906
|
+
component.addAttributes?.({
|
|
1907
|
+
"data-orion-items-json": JSON.stringify(nextItems),
|
|
1908
|
+
...Object.keys(block).length > 0 ? {
|
|
1909
|
+
"data-orion-block": serializeOrionBlockAttribute({
|
|
1910
|
+
...block,
|
|
1911
|
+
items: nextItems
|
|
1912
|
+
})
|
|
1913
|
+
} : {}
|
|
1914
|
+
});
|
|
1915
|
+
rememberComponentSnapshot(component);
|
|
1916
|
+
setSelectionSummary(summarizeSelectedComponent(component));
|
|
1917
|
+
};
|
|
1918
|
+
const refreshSelectedState = (component) => {
|
|
1919
|
+
setSelectionSummary(summarizeSelectedComponent(component));
|
|
1920
|
+
setQuickLayoutState(readQuickLayoutState(component));
|
|
1921
|
+
setDetailedLayoutControlState(readDetailedLayoutControlState(component));
|
|
1922
|
+
window.requestAnimationFrame(() => decorateBuilderSettingHelp());
|
|
1923
|
+
};
|
|
1924
|
+
const applySelectedStyle = (style) => {
|
|
1925
|
+
const component = selectedComponentRef.current;
|
|
1926
|
+
if (!component) {
|
|
1927
|
+
return;
|
|
1928
|
+
}
|
|
1929
|
+
component.addStyle?.(style);
|
|
1930
|
+
rememberComponentSnapshot(component);
|
|
1931
|
+
refreshSelectedState(component);
|
|
1932
|
+
};
|
|
1933
|
+
const applySelectedStyleAndAttributes = (style, attributes) => {
|
|
1934
|
+
const component = selectedComponentRef.current;
|
|
1935
|
+
if (!component) {
|
|
1936
|
+
return;
|
|
1937
|
+
}
|
|
1938
|
+
component.addStyle?.(style);
|
|
1939
|
+
component.addAttributes?.(attributes);
|
|
1940
|
+
rememberComponentSnapshot(component);
|
|
1941
|
+
refreshSelectedState(component);
|
|
1942
|
+
};
|
|
1943
|
+
const updateSelectedOrionBlock = (updates) => {
|
|
1944
|
+
const component = selectedComponentRef.current;
|
|
1945
|
+
if (!component) {
|
|
1946
|
+
return;
|
|
1947
|
+
}
|
|
1948
|
+
const attrs = component.getAttributes?.() || {};
|
|
1949
|
+
const block = parseOrionBlockAttribute(attrs["data-orion-block"]);
|
|
1950
|
+
if (Object.keys(block).length === 0) {
|
|
1951
|
+
return;
|
|
1952
|
+
}
|
|
1953
|
+
component.addAttributes?.({
|
|
1954
|
+
"data-orion-block": serializeOrionBlockAttribute({
|
|
1955
|
+
...block,
|
|
1956
|
+
...updates
|
|
1957
|
+
})
|
|
1958
|
+
});
|
|
1959
|
+
rememberComponentSnapshot(component);
|
|
1960
|
+
};
|
|
1961
|
+
const syncSelectedTypographyStyleToOrionBlock = (component = selectedComponentRef.current) => {
|
|
1962
|
+
if (!component) {
|
|
1963
|
+
return;
|
|
1964
|
+
}
|
|
1965
|
+
const attrs = component.getAttributes?.() || {};
|
|
1966
|
+
const block = parseOrionBlockAttribute(attrs["data-orion-block"]);
|
|
1967
|
+
if (Object.keys(block).length === 0) {
|
|
1968
|
+
return;
|
|
1969
|
+
}
|
|
1970
|
+
const kind = attrs["data-orion-active-text-kind"] === "heading" ? "heading" : "body";
|
|
1971
|
+
const style = component.getStyle?.() || {};
|
|
1972
|
+
const settings = readNestedRecord(block, "settings");
|
|
1973
|
+
const typography = readNestedRecord(settings, "typography");
|
|
1974
|
+
const nextTypography = { ...typography };
|
|
1975
|
+
const fontFamily = normalizeFontFamilyValue(style["font-family"]);
|
|
1976
|
+
const fontSize = normalizeCssSizeValue(style["font-size"]);
|
|
1977
|
+
const fontWeight = normalizeFontWeightValue(style["font-weight"]);
|
|
1978
|
+
const lineHeight = normalizeCssSizeValue(style["line-height"]);
|
|
1979
|
+
const letterSpacing = normalizeCssSizeValue(style["letter-spacing"]);
|
|
1980
|
+
const color = normalizeCssColorValue(style.color);
|
|
1981
|
+
const textAlign = normalizeStyleTextAlignment(style["text-align"]);
|
|
1982
|
+
if (fontFamily) {
|
|
1983
|
+
nextTypography[typographyKey(kind, "FontFamily")] = fontFamily;
|
|
1984
|
+
}
|
|
1985
|
+
if (fontSize) {
|
|
1986
|
+
nextTypography[typographyKey(kind, "FontSize")] = fontSize;
|
|
1987
|
+
}
|
|
1988
|
+
if (fontWeight) {
|
|
1989
|
+
nextTypography[typographyKey(kind, "FontWeight")] = fontWeight;
|
|
1990
|
+
}
|
|
1991
|
+
if (lineHeight) {
|
|
1992
|
+
nextTypography[typographyKey(kind, "LineHeight")] = lineHeight;
|
|
1993
|
+
}
|
|
1994
|
+
if (letterSpacing) {
|
|
1995
|
+
nextTypography[typographyKey(kind, "LetterSpacing")] = letterSpacing;
|
|
1996
|
+
}
|
|
1997
|
+
if (color) {
|
|
1998
|
+
nextTypography[typographyKey(kind, "Color")] = color;
|
|
1999
|
+
}
|
|
2000
|
+
if (textAlign) {
|
|
2001
|
+
nextTypography[typographyKey(kind, "Align")] = textAlign;
|
|
2002
|
+
if (kind === "heading") {
|
|
2003
|
+
block.textHeadingAlign = textAlign;
|
|
2004
|
+
} else {
|
|
2005
|
+
block.textBodyAlign = textAlign;
|
|
2006
|
+
}
|
|
2007
|
+
block.horizontalAlign = textAlign;
|
|
2008
|
+
}
|
|
2009
|
+
component.addAttributes?.({
|
|
2010
|
+
"data-orion-block": serializeOrionBlockAttribute({
|
|
2011
|
+
...block,
|
|
2012
|
+
settings: {
|
|
2013
|
+
...settings,
|
|
2014
|
+
typography: nextTypography
|
|
2015
|
+
}
|
|
2016
|
+
})
|
|
2017
|
+
});
|
|
2018
|
+
};
|
|
2019
|
+
const syncSelectedDecorationStyleToOrionBlock = (component = selectedComponentRef.current) => {
|
|
2020
|
+
const target = getCurrentOrionBlockTarget(component);
|
|
2021
|
+
if (!target) {
|
|
2022
|
+
return;
|
|
2023
|
+
}
|
|
2024
|
+
const attrs = target.getAttributes?.() || {};
|
|
2025
|
+
const block = parseOrionBlockAttribute(attrs["data-orion-block"]);
|
|
2026
|
+
if (Object.keys(block).length === 0) {
|
|
2027
|
+
return;
|
|
2028
|
+
}
|
|
2029
|
+
const backgroundColor = getStyleColorValue(component?.getStyle?.() || target.getStyle?.() || {}, "background-color");
|
|
2030
|
+
if (!backgroundColor) {
|
|
2031
|
+
return;
|
|
2032
|
+
}
|
|
2033
|
+
target.addAttributes?.({
|
|
2034
|
+
"data-orion-background-color": backgroundColor,
|
|
2035
|
+
"data-orion-block": serializeOrionBlockAttribute({
|
|
2036
|
+
...block,
|
|
2037
|
+
backgroundColor
|
|
2038
|
+
})
|
|
2039
|
+
});
|
|
2040
|
+
};
|
|
2041
|
+
const syncSelectedTypographyControlsToOrionBlock = (component = selectedComponentRef.current) => {
|
|
2042
|
+
if (!component) {
|
|
2043
|
+
return;
|
|
2044
|
+
}
|
|
2045
|
+
const attrs = component.getAttributes?.() || {};
|
|
2046
|
+
const block = parseOrionBlockAttribute(attrs["data-orion-block"]);
|
|
2047
|
+
if (Object.keys(block).length === 0) {
|
|
2048
|
+
return;
|
|
2049
|
+
}
|
|
2050
|
+
const kind = attrs["data-orion-active-text-kind"] === "heading" ? "heading" : "body";
|
|
2051
|
+
const settings = readNestedRecord(block, "settings");
|
|
2052
|
+
const typography = readNestedRecord(settings, "typography");
|
|
2053
|
+
const nextTypography = { ...typography };
|
|
2054
|
+
const nextStyle = {};
|
|
2055
|
+
const fontFamilyControl = readStylePanelValue("font-family");
|
|
2056
|
+
const fontFamily = normalizeFontFamilyValue(readStylePanelSelect("font-family"));
|
|
2057
|
+
const fontSize = normalizeCssSizeValue(readStylePanelLength("font-size"));
|
|
2058
|
+
const fontWeight = normalizeFontWeightValue(readStylePanelSelect("font-weight"));
|
|
2059
|
+
const lineHeight = normalizeCssSizeValue(readStylePanelLength("line-height"));
|
|
2060
|
+
const letterSpacing = normalizeCssSizeValue(readStylePanelLength("letter-spacing"));
|
|
2061
|
+
const color = normalizeCssColorValue(readStylePanelInput("color"));
|
|
2062
|
+
const textAlign = normalizeStyleTextAlignment(readStylePanelRadio("text-align"));
|
|
2063
|
+
if (fontFamilyControl) {
|
|
2064
|
+
if (fontFamily) {
|
|
2065
|
+
nextTypography[typographyKey(kind, "FontFamily")] = fontFamily;
|
|
2066
|
+
nextStyle["font-family"] = fontFamily;
|
|
2067
|
+
} else {
|
|
2068
|
+
delete nextTypography[typographyKey(kind, "FontFamily")];
|
|
2069
|
+
nextStyle["font-family"] = "";
|
|
2070
|
+
component.removeStyle?.("font-family");
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
if (fontSize) {
|
|
2074
|
+
nextTypography[typographyKey(kind, "FontSize")] = fontSize;
|
|
2075
|
+
nextStyle["font-size"] = fontSize;
|
|
2076
|
+
}
|
|
2077
|
+
if (fontWeight) {
|
|
2078
|
+
nextTypography[typographyKey(kind, "FontWeight")] = fontWeight;
|
|
2079
|
+
nextStyle["font-weight"] = fontWeight;
|
|
2080
|
+
}
|
|
2081
|
+
if (lineHeight) {
|
|
2082
|
+
nextTypography[typographyKey(kind, "LineHeight")] = lineHeight;
|
|
2083
|
+
nextStyle["line-height"] = lineHeight;
|
|
2084
|
+
}
|
|
2085
|
+
if (letterSpacing) {
|
|
2086
|
+
nextTypography[typographyKey(kind, "LetterSpacing")] = letterSpacing;
|
|
2087
|
+
nextStyle["letter-spacing"] = letterSpacing;
|
|
2088
|
+
}
|
|
2089
|
+
if (color) {
|
|
2090
|
+
nextTypography[typographyKey(kind, "Color")] = color;
|
|
2091
|
+
nextStyle.color = color;
|
|
2092
|
+
}
|
|
2093
|
+
if (textAlign) {
|
|
2094
|
+
nextTypography[typographyKey(kind, "Align")] = textAlign;
|
|
2095
|
+
nextStyle["text-align"] = textAlign;
|
|
2096
|
+
if (kind === "heading") {
|
|
2097
|
+
block.textHeadingAlign = textAlign;
|
|
2098
|
+
} else {
|
|
2099
|
+
block.textBodyAlign = textAlign;
|
|
2100
|
+
}
|
|
2101
|
+
block.horizontalAlign = textAlign;
|
|
2102
|
+
}
|
|
2103
|
+
if (Object.keys(nextStyle).length > 0) {
|
|
2104
|
+
component.addStyle?.(nextStyle);
|
|
2105
|
+
}
|
|
2106
|
+
component.addAttributes?.({
|
|
2107
|
+
"data-orion-block": serializeOrionBlockAttribute({
|
|
2108
|
+
...block,
|
|
2109
|
+
settings: {
|
|
2110
|
+
...settings,
|
|
2111
|
+
typography: nextTypography
|
|
2112
|
+
}
|
|
2113
|
+
})
|
|
2114
|
+
});
|
|
2115
|
+
};
|
|
2116
|
+
const syncSelectedDecorationControlsToOrionBlock = (component = selectedComponentRef.current) => {
|
|
2117
|
+
if (historyRestoreActiveRef.current) {
|
|
2118
|
+
return;
|
|
2119
|
+
}
|
|
2120
|
+
const target = getCurrentOrionBlockTarget(component);
|
|
2121
|
+
if (!target) {
|
|
2122
|
+
return;
|
|
2123
|
+
}
|
|
2124
|
+
const attrs = target.getAttributes?.() || {};
|
|
2125
|
+
const block = parseOrionBlockAttribute(attrs["data-orion-block"]);
|
|
2126
|
+
if (Object.keys(block).length === 0) {
|
|
2127
|
+
return;
|
|
2128
|
+
}
|
|
2129
|
+
const panelBackgroundColor = normalizeCssColorValue(readStylePanelColor("background-color"));
|
|
2130
|
+
const styleBackgroundColor = getStyleColorValue(component?.getStyle?.() || target.getStyle?.() || {}, "background-color");
|
|
2131
|
+
const backgroundColor = normalizeCssColorValue(panelBackgroundColor === "none" ? "" : panelBackgroundColor) || styleBackgroundColor;
|
|
2132
|
+
if (!backgroundColor) {
|
|
2133
|
+
return;
|
|
2134
|
+
}
|
|
2135
|
+
if (getStyleColorValue(target.getStyle?.() || {}, "background-color") !== backgroundColor) {
|
|
2136
|
+
target.addStyle?.({ "background-color": backgroundColor });
|
|
2137
|
+
}
|
|
2138
|
+
if (component && component !== target && getStyleColorValue(component.getStyle?.() || {}, "background-color") !== backgroundColor) {
|
|
2139
|
+
component.addStyle?.({ "background-color": backgroundColor });
|
|
2140
|
+
}
|
|
2141
|
+
target.addAttributes?.({
|
|
2142
|
+
"data-orion-background-color": backgroundColor,
|
|
2143
|
+
"data-orion-block": serializeOrionBlockAttribute({
|
|
2144
|
+
...block,
|
|
2145
|
+
backgroundColor
|
|
2146
|
+
})
|
|
2147
|
+
});
|
|
2148
|
+
};
|
|
2149
|
+
const syncAllOrionBlockStylesToAttributes = () => {
|
|
2150
|
+
if (syncingOrionBlockStylesRef.current) {
|
|
2151
|
+
return;
|
|
2152
|
+
}
|
|
2153
|
+
const editor = editorRef.current;
|
|
2154
|
+
const wrapper = editor?.DomComponents?.getWrapper?.() || null;
|
|
2155
|
+
const blocks = wrapper?.find?.("[data-orion-block]") || [];
|
|
2156
|
+
syncingOrionBlockStylesRef.current = true;
|
|
2157
|
+
try {
|
|
2158
|
+
blocks.forEach((component) => {
|
|
2159
|
+
const attrs = component.getAttributes?.() || {};
|
|
2160
|
+
const block = parseOrionBlockAttribute(attrs["data-orion-block"]);
|
|
2161
|
+
if (Object.keys(block).length === 0) {
|
|
2162
|
+
return;
|
|
2163
|
+
}
|
|
2164
|
+
const backgroundColor = getStyleColorValue(component.getStyle?.() || {}, "background-color");
|
|
2165
|
+
if (!backgroundColor || normalizeCssColorValue(block.backgroundColor) === backgroundColor && normalizeCssColorValue(attrs["data-orion-background-color"]) === backgroundColor) {
|
|
2166
|
+
return;
|
|
2167
|
+
}
|
|
2168
|
+
component.addAttributes?.({
|
|
2169
|
+
"data-orion-background-color": backgroundColor,
|
|
2170
|
+
"data-orion-block": serializeOrionBlockAttribute({
|
|
2171
|
+
...block,
|
|
2172
|
+
backgroundColor
|
|
2173
|
+
})
|
|
2174
|
+
});
|
|
2175
|
+
});
|
|
2176
|
+
} finally {
|
|
2177
|
+
syncingOrionBlockStylesRef.current = false;
|
|
2178
|
+
}
|
|
2179
|
+
};
|
|
2180
|
+
const hydrateSelectedTypographyStyleFromOrionBlock = (component) => {
|
|
2181
|
+
if (!component) {
|
|
2182
|
+
return;
|
|
2183
|
+
}
|
|
2184
|
+
const attrs = component.getAttributes?.() || {};
|
|
2185
|
+
const block = parseOrionBlockAttribute(attrs["data-orion-block"]);
|
|
2186
|
+
if (Object.keys(block).length === 0) {
|
|
2187
|
+
return;
|
|
2188
|
+
}
|
|
2189
|
+
const kind = attrs["data-orion-active-text-kind"] === "heading" ? "heading" : "body";
|
|
2190
|
+
const settings = readNestedRecord(block, "settings");
|
|
2191
|
+
const typography = readNestedRecord(settings, "typography");
|
|
2192
|
+
const nextStyle = {};
|
|
2193
|
+
const currentStyle = component.getStyle?.() || {};
|
|
2194
|
+
const fontFamily = normalizeFontFamilyValue(firstString(typography[typographyKey(kind, "FontFamily")], attrs["data-orion-active-font-family"]));
|
|
2195
|
+
const fontSize = firstString(typography[typographyKey(kind, "FontSize")], attrs["data-orion-active-font-size"]);
|
|
2196
|
+
const fontWeight = normalizeFontWeightValue(firstString(typography[typographyKey(kind, "FontWeight")], attrs["data-orion-active-font-weight"]));
|
|
2197
|
+
const lineHeight = firstString(typography[typographyKey(kind, "LineHeight")], attrs["data-orion-active-line-height"]);
|
|
2198
|
+
const letterSpacing = firstString(typography[typographyKey(kind, "LetterSpacing")], attrs["data-orion-active-letter-spacing"]);
|
|
2199
|
+
const color = firstString(typography[typographyKey(kind, "Color")], attrs["data-orion-active-color"]);
|
|
2200
|
+
const textAlign = firstString(typography[typographyKey(kind, "Align")], kind === "heading" ? block.textHeadingAlign : block.textBodyAlign, attrs["data-orion-active-text-align"]);
|
|
2201
|
+
if (fontFamily && !currentStyle["font-family"]) {
|
|
2202
|
+
nextStyle["font-family"] = fontFamily;
|
|
2203
|
+
}
|
|
2204
|
+
if (fontSize && !currentStyle["font-size"]) {
|
|
2205
|
+
nextStyle["font-size"] = fontSize;
|
|
2206
|
+
}
|
|
2207
|
+
if (fontWeight && !currentStyle["font-weight"]) {
|
|
2208
|
+
nextStyle["font-weight"] = fontWeight;
|
|
2209
|
+
}
|
|
2210
|
+
if (lineHeight && !currentStyle["line-height"]) {
|
|
2211
|
+
nextStyle["line-height"] = lineHeight;
|
|
2212
|
+
}
|
|
2213
|
+
if (letterSpacing && letterSpacing !== "normal" && !currentStyle["letter-spacing"]) {
|
|
2214
|
+
nextStyle["letter-spacing"] = letterSpacing;
|
|
2215
|
+
}
|
|
2216
|
+
if (color && !currentStyle.color) {
|
|
2217
|
+
nextStyle.color = color;
|
|
2218
|
+
}
|
|
2219
|
+
if (textAlign && !currentStyle["text-align"]) {
|
|
2220
|
+
nextStyle["text-align"] = textAlign;
|
|
2221
|
+
}
|
|
2222
|
+
if (Object.keys(nextStyle).length > 0) {
|
|
2223
|
+
component.addStyle?.(nextStyle);
|
|
2224
|
+
}
|
|
2225
|
+
};
|
|
2226
|
+
const rehydrateSelectedComponentControls = (component) => {
|
|
2227
|
+
if (!component || component !== selectedComponentRef.current) {
|
|
2228
|
+
return;
|
|
2229
|
+
}
|
|
2230
|
+
hydrateSelectedTypographyStyleFromOrionBlock(component);
|
|
2231
|
+
rememberComponentSnapshot(component);
|
|
2232
|
+
refreshSelectedState(component);
|
|
2233
|
+
};
|
|
2234
|
+
const applyQuickLayout = (layout) => {
|
|
2235
|
+
const nextStyle = quickLayoutStyles[layout];
|
|
2236
|
+
applySelectedStyle({
|
|
2237
|
+
...nextStyle,
|
|
2238
|
+
...quickLayoutState.spacing ? { padding: quickSpacingStyles[quickLayoutState.spacing] } : {},
|
|
2239
|
+
...quickLayoutState.hidden ? { display: "none" } : {},
|
|
2240
|
+
...quickLayoutState.sticky ? { position: "sticky", top: "0px", "z-index": "10" } : {}
|
|
2241
|
+
});
|
|
2242
|
+
};
|
|
2243
|
+
const applyQuickSpacing = (spacing) => {
|
|
2244
|
+
applySelectedStyle({ padding: quickSpacingStyles[spacing] });
|
|
2245
|
+
};
|
|
2246
|
+
const applyQuickHorizontalAlign = (alignment) => {
|
|
2247
|
+
updateSelectedOrionBlock({
|
|
2248
|
+
horizontalAlign: alignment,
|
|
2249
|
+
textBodyAlign: alignment,
|
|
2250
|
+
textHeadingAlign: alignment
|
|
2251
|
+
});
|
|
2252
|
+
applySelectedStyleAndAttributes(quickHorizontalAlignStyles[alignment], {
|
|
2253
|
+
"data-orion-horizontal-align": alignment
|
|
2254
|
+
});
|
|
2255
|
+
};
|
|
2256
|
+
const applyQuickVerticalAlign = (alignment) => {
|
|
2257
|
+
updateSelectedOrionBlock({
|
|
2258
|
+
verticalAlign: alignment
|
|
2259
|
+
});
|
|
2260
|
+
applySelectedStyleAndAttributes(
|
|
2261
|
+
{
|
|
2262
|
+
"align-items": quickVerticalAlignStyles[alignment],
|
|
2263
|
+
"place-items": "",
|
|
2264
|
+
width: "100%"
|
|
2265
|
+
},
|
|
2266
|
+
{
|
|
2267
|
+
"data-orion-vertical-align": alignment
|
|
2268
|
+
}
|
|
2269
|
+
);
|
|
2270
|
+
};
|
|
2271
|
+
const toggleSticky = () => {
|
|
2272
|
+
applySelectedStyle(
|
|
2273
|
+
quickLayoutState.sticky ? { position: "", top: "", "z-index": "" } : { position: "sticky", top: "0px", "z-index": "10" }
|
|
2274
|
+
);
|
|
2275
|
+
};
|
|
2276
|
+
const toggleHidden = () => {
|
|
2277
|
+
applySelectedStyle(
|
|
2278
|
+
quickLayoutState.hidden ? { display: quickLayoutStyles[quickLayoutState.layout].display || "" } : { display: "none" }
|
|
2279
|
+
);
|
|
2280
|
+
};
|
|
2281
|
+
const toggleInspectorPanel = (panel) => {
|
|
2282
|
+
setOpenInspectorPanels((current) => ({
|
|
2283
|
+
...current,
|
|
2284
|
+
[panel]: !current[panel]
|
|
2285
|
+
}));
|
|
2286
|
+
};
|
|
2287
|
+
const toggleSidebarPanel = (panel) => {
|
|
2288
|
+
setOpenSidebarPanels((current) => ({
|
|
2289
|
+
...current,
|
|
2290
|
+
[panel]: !current[panel]
|
|
2291
|
+
}));
|
|
2292
|
+
};
|
|
2293
|
+
const updateHistoryState = (editor) => {
|
|
2294
|
+
const next = {
|
|
2295
|
+
canRedo: customRedoStackRef.current.length > 0 || editor.UndoManager.hasRedo(),
|
|
2296
|
+
canUndo: customUndoStackRef.current.length > 0 || editor.UndoManager.hasUndo()
|
|
2297
|
+
};
|
|
2298
|
+
setHistoryState(next);
|
|
2299
|
+
postToParent({
|
|
2300
|
+
...next,
|
|
2301
|
+
type: "history-state"
|
|
2302
|
+
});
|
|
2303
|
+
};
|
|
2304
|
+
const snapshotComponent = (component) => {
|
|
2305
|
+
if (!component) {
|
|
2306
|
+
return null;
|
|
2307
|
+
}
|
|
2308
|
+
return {
|
|
2309
|
+
attributes: { ...component.getAttributes?.() || {} },
|
|
2310
|
+
component,
|
|
2311
|
+
style: { ...component.getStyle?.() || {} }
|
|
2312
|
+
};
|
|
2313
|
+
};
|
|
2314
|
+
const rememberComponentSnapshot = (component) => {
|
|
2315
|
+
const snapshot = snapshotComponent(component);
|
|
2316
|
+
if (snapshot) {
|
|
2317
|
+
lastComponentSnapshotRef.current.set(snapshot.component, snapshot);
|
|
2318
|
+
}
|
|
2319
|
+
return snapshot;
|
|
2320
|
+
};
|
|
2321
|
+
const getPreviousComponentSnapshot = (component) => component ? lastComponentSnapshotRef.current.get(component) || snapshotComponent(component) : null;
|
|
2322
|
+
const restoreComponentSnapshot = (snapshot) => {
|
|
2323
|
+
const currentStyle = snapshot.component.getStyle?.() || {};
|
|
2324
|
+
snapshot.component.addStyle?.({
|
|
2325
|
+
...Object.fromEntries(Object.keys(currentStyle).map((key) => [key, ""])),
|
|
2326
|
+
...Object.fromEntries(Object.entries(snapshot.style).map(([key, value]) => [key, String(value)]))
|
|
2327
|
+
});
|
|
2328
|
+
snapshot.component.addAttributes?.({ ...snapshot.attributes });
|
|
2329
|
+
selectedComponentRef.current = snapshot.component;
|
|
2330
|
+
lastSelectedComponentRef.current = snapshot.component;
|
|
2331
|
+
editorRef.current?.select?.(snapshot.component);
|
|
2332
|
+
selectStyleManagerTarget(snapshot.component);
|
|
2333
|
+
lastComponentSnapshotRef.current.set(snapshot.component, snapshot);
|
|
2334
|
+
refreshSelectedState(snapshot.component);
|
|
2335
|
+
};
|
|
2336
|
+
const pushCustomHistoryEntry = (before, after) => {
|
|
2337
|
+
if (!before || !after || before.component !== after.component) {
|
|
2338
|
+
return;
|
|
2339
|
+
}
|
|
2340
|
+
if (JSON.stringify(before.style) === JSON.stringify(after.style) && JSON.stringify(before.attributes) === JSON.stringify(after.attributes)) {
|
|
2341
|
+
return;
|
|
2342
|
+
}
|
|
2343
|
+
customUndoStackRef.current.push({ after, before });
|
|
2344
|
+
customRedoStackRef.current = [];
|
|
2345
|
+
lastComponentSnapshotRef.current.set(after.component, after);
|
|
2346
|
+
if (customUndoStackRef.current.length > 100) {
|
|
2347
|
+
customUndoStackRef.current.shift();
|
|
2348
|
+
}
|
|
2349
|
+
if (editorRef.current) {
|
|
2350
|
+
updateHistoryState(editorRef.current);
|
|
2351
|
+
}
|
|
2352
|
+
};
|
|
2353
|
+
const completeHistoryRestore = (editor) => {
|
|
2354
|
+
window.requestAnimationFrame(() => {
|
|
2355
|
+
window.setTimeout(() => {
|
|
2356
|
+
syncAllOrionBlockStylesToAttributes();
|
|
2357
|
+
const selected = getCurrentOrionBlockTarget(getCurrentStyleTarget()) || selectedComponentRef.current;
|
|
2358
|
+
if (selected) {
|
|
2359
|
+
selectedComponentRef.current = selected;
|
|
2360
|
+
lastSelectedComponentRef.current = selected;
|
|
2361
|
+
selectStyleManagerTarget(selected);
|
|
2362
|
+
refreshSelectedState(selected);
|
|
2363
|
+
}
|
|
2364
|
+
updateHistoryState(editor);
|
|
2365
|
+
historyRestoreActiveRef.current = false;
|
|
2366
|
+
}, 120);
|
|
2367
|
+
});
|
|
2368
|
+
};
|
|
2369
|
+
const runHistoryAction = (action) => {
|
|
2370
|
+
const editor = editorRef.current;
|
|
2371
|
+
if (!editor) {
|
|
2372
|
+
return;
|
|
2373
|
+
}
|
|
2374
|
+
const customEntry = action === "undo" ? customUndoStackRef.current.pop() : customRedoStackRef.current.pop();
|
|
2375
|
+
if (customEntry) {
|
|
2376
|
+
historyRestoreActiveRef.current = true;
|
|
2377
|
+
restoreComponentSnapshot(action === "undo" ? customEntry.before : customEntry.after);
|
|
2378
|
+
if (action === "undo") {
|
|
2379
|
+
customRedoStackRef.current.push(customEntry);
|
|
2380
|
+
} else {
|
|
2381
|
+
customUndoStackRef.current.push(customEntry);
|
|
2382
|
+
}
|
|
2383
|
+
completeHistoryRestore(editor);
|
|
2384
|
+
return;
|
|
2385
|
+
}
|
|
2386
|
+
historyRestoreActiveRef.current = true;
|
|
2387
|
+
if (action === "undo") {
|
|
2388
|
+
editor.UndoManager.undo();
|
|
2389
|
+
} else {
|
|
2390
|
+
editor.UndoManager.redo();
|
|
2391
|
+
}
|
|
2392
|
+
completeHistoryRestore(editor);
|
|
2393
|
+
};
|
|
2394
|
+
const runValidation = (editor) => {
|
|
2395
|
+
const issues = validateBuilderV2Output({
|
|
2396
|
+
css: editor.getCss(),
|
|
2397
|
+
html: editor.getHtml()
|
|
2398
|
+
});
|
|
2399
|
+
setValidationIssues(issues);
|
|
2400
|
+
postToParent({ issues, type: "validation-state" });
|
|
2401
|
+
return issues;
|
|
2402
|
+
};
|
|
2403
|
+
const setDevice = (device) => {
|
|
2404
|
+
const editor = editorRef.current;
|
|
2405
|
+
if (!editor) {
|
|
2406
|
+
return;
|
|
2407
|
+
}
|
|
2408
|
+
editor.setDevice(device);
|
|
2409
|
+
setSelectedDevice(device);
|
|
2410
|
+
};
|
|
2411
|
+
const syncStylePanelInput = (event) => {
|
|
2412
|
+
const target = event.target;
|
|
2413
|
+
if (!target?.closest("#orion-builder-v2-styles")) {
|
|
2414
|
+
return;
|
|
2415
|
+
}
|
|
2416
|
+
const activeElement = document.activeElement;
|
|
2417
|
+
if (!sidebarPointerActiveRef.current && !activeElement?.closest("#orion-builder-v2-styles")) {
|
|
2418
|
+
return;
|
|
2419
|
+
}
|
|
2420
|
+
stylePanelEditActiveRef.current = true;
|
|
2421
|
+
if (!stylePanelHistoryBeforeRef.current) {
|
|
2422
|
+
stylePanelHistoryBeforeRef.current = snapshotComponent(getCurrentOrionBlockTarget(getCurrentStyleTarget()));
|
|
2423
|
+
}
|
|
2424
|
+
window.setTimeout(() => {
|
|
2425
|
+
const selected = getCurrentOrionBlockTarget(getCurrentStyleTarget());
|
|
2426
|
+
if (selected) {
|
|
2427
|
+
selectedComponentRef.current = selected;
|
|
2428
|
+
lastSelectedComponentRef.current = selected;
|
|
2429
|
+
}
|
|
2430
|
+
syncSelectedTypographyControlsToOrionBlock(selected);
|
|
2431
|
+
syncSelectedDecorationControlsToOrionBlock(selected);
|
|
2432
|
+
syncAllOrionBlockStylesToAttributes();
|
|
2433
|
+
if (selected) {
|
|
2434
|
+
editorRef.current?.select?.(selected);
|
|
2435
|
+
}
|
|
2436
|
+
refreshSelectedState(getCurrentStyleTarget());
|
|
2437
|
+
pushCustomHistoryEntry(stylePanelHistoryBeforeRef.current, snapshotComponent(selected));
|
|
2438
|
+
stylePanelHistoryBeforeRef.current = null;
|
|
2439
|
+
window.setTimeout(() => {
|
|
2440
|
+
stylePanelEditActiveRef.current = false;
|
|
2441
|
+
}, 120);
|
|
2442
|
+
}, 80);
|
|
2443
|
+
};
|
|
2444
|
+
const syncStylePanelChange = () => {
|
|
2445
|
+
stylePanelEditActiveRef.current = true;
|
|
2446
|
+
if (!stylePanelHistoryBeforeRef.current) {
|
|
2447
|
+
stylePanelHistoryBeforeRef.current = snapshotComponent(getCurrentOrionBlockTarget(getCurrentStyleTarget()));
|
|
2448
|
+
}
|
|
2449
|
+
window.setTimeout(() => {
|
|
2450
|
+
const selected = getCurrentOrionBlockTarget(getCurrentStyleTarget());
|
|
2451
|
+
if (selected) {
|
|
2452
|
+
selectedComponentRef.current = selected;
|
|
2453
|
+
lastSelectedComponentRef.current = selected;
|
|
2454
|
+
}
|
|
2455
|
+
syncSelectedTypographyControlsToOrionBlock(selected);
|
|
2456
|
+
syncSelectedDecorationControlsToOrionBlock(selected);
|
|
2457
|
+
syncAllOrionBlockStylesToAttributes();
|
|
2458
|
+
if (selected) {
|
|
2459
|
+
editorRef.current?.select?.(selected);
|
|
2460
|
+
}
|
|
2461
|
+
refreshSelectedState(getCurrentStyleTarget());
|
|
2462
|
+
pushCustomHistoryEntry(stylePanelHistoryBeforeRef.current, snapshotComponent(selected));
|
|
2463
|
+
stylePanelHistoryBeforeRef.current = null;
|
|
2464
|
+
window.setTimeout(() => {
|
|
2465
|
+
stylePanelEditActiveRef.current = false;
|
|
2466
|
+
}, 120);
|
|
2467
|
+
}, 80);
|
|
2468
|
+
};
|
|
2469
|
+
(0, import_react.useEffect)(() => {
|
|
2470
|
+
let active = true;
|
|
2471
|
+
const init = async () => {
|
|
2472
|
+
if (!containerRef.current || editorRef.current) {
|
|
2473
|
+
return;
|
|
2474
|
+
}
|
|
2475
|
+
try {
|
|
2476
|
+
const grapesjs = (await import("grapesjs")).default;
|
|
2477
|
+
if (!active || !containerRef.current) {
|
|
2478
|
+
return;
|
|
2479
|
+
}
|
|
2480
|
+
const projectData = normalizeBuilderV2ProjectData(initialData?.projectData, initialData?.title);
|
|
2481
|
+
const editor = grapesjs.init({
|
|
2482
|
+
assetManager: {
|
|
2483
|
+
uploadFile: async (event) => {
|
|
2484
|
+
const target = event.target;
|
|
2485
|
+
const dataTransfer = "dataTransfer" in event ? event.dataTransfer : null;
|
|
2486
|
+
const files = dataTransfer?.files || target?.files;
|
|
2487
|
+
if (!files || files.length === 0) {
|
|
2488
|
+
return void 0;
|
|
2489
|
+
}
|
|
2490
|
+
await uploadPayloadMediaAssets(editorRef.current || editor, files).catch((uploadError) => {
|
|
2491
|
+
setError(uploadError instanceof Error ? uploadError.message : "Could not upload image.");
|
|
2492
|
+
});
|
|
2493
|
+
}
|
|
2494
|
+
},
|
|
2495
|
+
blockManager: {
|
|
2496
|
+
appendTo: "#orion-builder-v2-blocks"
|
|
2497
|
+
},
|
|
2498
|
+
canvasCss: canvasSelectionCss,
|
|
2499
|
+
container: containerRef.current,
|
|
2500
|
+
deviceManager: {
|
|
2501
|
+
devices: [
|
|
2502
|
+
{ id: "desktop", name: "Desktop", width: "" },
|
|
2503
|
+
{ id: "tablet", name: "Tablet", width: "768px" },
|
|
2504
|
+
{ id: "mobile", name: "Mobile", width: "390px" }
|
|
2505
|
+
]
|
|
2506
|
+
},
|
|
2507
|
+
fromElement: false,
|
|
2508
|
+
height: "100%",
|
|
2509
|
+
panels: {
|
|
2510
|
+
defaults: []
|
|
2511
|
+
},
|
|
2512
|
+
selectorManager: {
|
|
2513
|
+
componentFirst: true
|
|
2514
|
+
},
|
|
2515
|
+
storageManager: false,
|
|
2516
|
+
styleManager: {
|
|
2517
|
+
appendTo: "#orion-builder-v2-styles",
|
|
2518
|
+
sectors: [
|
|
2519
|
+
{
|
|
2520
|
+
name: "Detailed layout",
|
|
2521
|
+
open: false,
|
|
2522
|
+
properties: [
|
|
2523
|
+
"display",
|
|
2524
|
+
"position",
|
|
2525
|
+
"top",
|
|
2526
|
+
"right",
|
|
2527
|
+
"bottom",
|
|
2528
|
+
"left",
|
|
2529
|
+
"width",
|
|
2530
|
+
"height",
|
|
2531
|
+
"min-height",
|
|
2532
|
+
"margin",
|
|
2533
|
+
"padding",
|
|
2534
|
+
"flex-direction",
|
|
2535
|
+
"justify-content",
|
|
2536
|
+
"align-items",
|
|
2537
|
+
"gap",
|
|
2538
|
+
"flex-wrap"
|
|
2539
|
+
]
|
|
2540
|
+
},
|
|
2541
|
+
{
|
|
2542
|
+
name: "Typography",
|
|
2543
|
+
open: false,
|
|
2544
|
+
properties: [
|
|
2545
|
+
{
|
|
2546
|
+
name: "Font family",
|
|
2547
|
+
property: "font-family",
|
|
2548
|
+
type: "select",
|
|
2549
|
+
options: [
|
|
2550
|
+
{ id: "inherit", label: "Inherit" },
|
|
2551
|
+
{ id: "Arial, Helvetica, sans-serif", label: "Arial" },
|
|
2552
|
+
{ id: 'Georgia, "Times New Roman", serif', label: "Georgia" },
|
|
2553
|
+
{ id: '"Times New Roman", Times, serif', label: "Times New Roman" },
|
|
2554
|
+
{ id: 'Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif', label: "Inter/System" },
|
|
2555
|
+
{ id: '"Caveat", "Brush Script MT", cursive', label: "Script" }
|
|
2556
|
+
]
|
|
2557
|
+
},
|
|
2558
|
+
{
|
|
2559
|
+
name: "Font size",
|
|
2560
|
+
property: "font-size",
|
|
2561
|
+
type: "number",
|
|
2562
|
+
units: ["pt", "px", "rem", "em", "%"]
|
|
2563
|
+
},
|
|
2564
|
+
"font-weight",
|
|
2565
|
+
{
|
|
2566
|
+
name: "Line height",
|
|
2567
|
+
property: "line-height",
|
|
2568
|
+
type: "number",
|
|
2569
|
+
units: ["pt", "px", "rem", "em", "%", ""]
|
|
2570
|
+
},
|
|
2571
|
+
{
|
|
2572
|
+
name: "Letter spacing",
|
|
2573
|
+
property: "letter-spacing",
|
|
2574
|
+
type: "number",
|
|
2575
|
+
units: ["pt", "px", "em", "rem"]
|
|
2576
|
+
},
|
|
2577
|
+
"color",
|
|
2578
|
+
"text-align"
|
|
2579
|
+
]
|
|
2580
|
+
},
|
|
2581
|
+
{
|
|
2582
|
+
name: "Decoration",
|
|
2583
|
+
open: false,
|
|
2584
|
+
properties: ["background-color", "background", "border", "border-radius", "box-shadow", "opacity"]
|
|
2585
|
+
}
|
|
2586
|
+
]
|
|
2587
|
+
},
|
|
2588
|
+
traitManager: {
|
|
2589
|
+
appendTo: "#orion-builder-v2-traits"
|
|
2590
|
+
},
|
|
2591
|
+
width: "auto"
|
|
2592
|
+
});
|
|
2593
|
+
editorRef.current = editor;
|
|
2594
|
+
registerOrionBuilderV2Blocks(editor);
|
|
2595
|
+
registerProjectDynamicComponents(editor, adapter);
|
|
2596
|
+
editor.loadProjectData(projectData);
|
|
2597
|
+
void loadPayloadMediaAssets(editor);
|
|
2598
|
+
editor.on("update", () => {
|
|
2599
|
+
const hasDirtyChanges = editor.getDirtyCount() > 0;
|
|
2600
|
+
refreshSelectedState(selectedComponentRef.current);
|
|
2601
|
+
setIsDirty(hasDirtyChanges);
|
|
2602
|
+
postToParent({ dirty: hasDirtyChanges, type: "dirty-state" });
|
|
2603
|
+
updateHistoryState(editor);
|
|
2604
|
+
runValidation(editor);
|
|
2605
|
+
setSaveMessage("Unsaved changes");
|
|
2606
|
+
if (autosaveTimerRef.current) {
|
|
2607
|
+
window.clearTimeout(autosaveTimerRef.current);
|
|
2608
|
+
}
|
|
2609
|
+
autosaveTimerRef.current = window.setTimeout(() => {
|
|
2610
|
+
if (editor.getDirtyCount() > 0) {
|
|
2611
|
+
void saveRef.current("draft", { autosave: true });
|
|
2612
|
+
}
|
|
2613
|
+
}, autosaveIntervalMs);
|
|
2614
|
+
});
|
|
2615
|
+
editor.on("component:selected", (component) => {
|
|
2616
|
+
const typed = component;
|
|
2617
|
+
const target = getCurrentOrionBlockTarget(typed) || typed;
|
|
2618
|
+
selectedComponentRef.current = target;
|
|
2619
|
+
lastSelectedComponentRef.current = target;
|
|
2620
|
+
if (target !== typed) {
|
|
2621
|
+
editor.select?.(target);
|
|
2622
|
+
}
|
|
2623
|
+
selectStyleManagerTarget(target);
|
|
2624
|
+
rehydrateSelectedComponentControls(target);
|
|
2625
|
+
window.setTimeout(() => {
|
|
2626
|
+
selectStyleManagerTarget(target);
|
|
2627
|
+
rehydrateSelectedComponentControls(target);
|
|
2628
|
+
}, 120);
|
|
2629
|
+
});
|
|
2630
|
+
editor.on("component:update:attributes", (component) => {
|
|
2631
|
+
if (historyRestoreActiveRef.current) {
|
|
2632
|
+
return;
|
|
2633
|
+
}
|
|
2634
|
+
rehydrateSelectedComponentControls(component);
|
|
2635
|
+
});
|
|
2636
|
+
editor.on("component:deselected", () => {
|
|
2637
|
+
const activeElement = document.activeElement;
|
|
2638
|
+
if (sidebarPointerActiveRef.current || activeElement?.closest("#orion-builder-v2-styles, #orion-builder-v2-traits, .orion-builder-v2-sidebar")) {
|
|
2639
|
+
window.requestAnimationFrame(() => {
|
|
2640
|
+
const selected = selectedComponentRef.current;
|
|
2641
|
+
if (selected) {
|
|
2642
|
+
editor.select?.(selected);
|
|
2643
|
+
}
|
|
2644
|
+
refreshSelectedState(selected);
|
|
2645
|
+
});
|
|
2646
|
+
return;
|
|
2647
|
+
}
|
|
2648
|
+
selectedComponentRef.current = null;
|
|
2649
|
+
refreshSelectedState(null);
|
|
2650
|
+
});
|
|
2651
|
+
const bindCanvasSelectionTracking = () => {
|
|
2652
|
+
const canvasDocument = editor.Canvas?.getDocument?.();
|
|
2653
|
+
if (!canvasDocument) {
|
|
2654
|
+
return;
|
|
2655
|
+
}
|
|
2656
|
+
const trackCanvasSelection = (event) => {
|
|
2657
|
+
const target = findOrionBlockByElement(event.target);
|
|
2658
|
+
if (!target) {
|
|
2659
|
+
return;
|
|
2660
|
+
}
|
|
2661
|
+
selectedComponentRef.current = target;
|
|
2662
|
+
lastSelectedComponentRef.current = target;
|
|
2663
|
+
rememberComponentSnapshot(target);
|
|
2664
|
+
refreshSelectedState(target);
|
|
2665
|
+
};
|
|
2666
|
+
canvasDocument.addEventListener("pointerdown", trackCanvasSelection, true);
|
|
2667
|
+
canvasDocument.addEventListener("click", trackCanvasSelection, true);
|
|
2668
|
+
};
|
|
2669
|
+
bindCanvasSelectionTracking();
|
|
2670
|
+
editor.on("canvas:frame:load", bindCanvasSelectionTracking);
|
|
2671
|
+
editor.on("style:property:update", () => {
|
|
2672
|
+
const selected = getCurrentStyleTarget();
|
|
2673
|
+
if (historyRestoreActiveRef.current) {
|
|
2674
|
+
refreshSelectedState(selected);
|
|
2675
|
+
return;
|
|
2676
|
+
}
|
|
2677
|
+
const historyTarget = getCurrentOrionBlockTarget(selected);
|
|
2678
|
+
const before = getPreviousComponentSnapshot(historyTarget);
|
|
2679
|
+
syncSelectedTypographyStyleToOrionBlock(selected);
|
|
2680
|
+
syncSelectedDecorationStyleToOrionBlock(selected);
|
|
2681
|
+
if (stylePanelEditActiveRef.current) {
|
|
2682
|
+
syncSelectedDecorationControlsToOrionBlock(selected);
|
|
2683
|
+
}
|
|
2684
|
+
window.setTimeout(() => {
|
|
2685
|
+
syncAllOrionBlockStylesToAttributes();
|
|
2686
|
+
pushCustomHistoryEntry(before, snapshotComponent(historyTarget));
|
|
2687
|
+
}, 80);
|
|
2688
|
+
refreshSelectedState(selected);
|
|
2689
|
+
});
|
|
2690
|
+
editor.on("component:styleUpdate:background-color", () => {
|
|
2691
|
+
window.setTimeout(() => {
|
|
2692
|
+
if (historyRestoreActiveRef.current) {
|
|
2693
|
+
return;
|
|
2694
|
+
}
|
|
2695
|
+
syncAllOrionBlockStylesToAttributes();
|
|
2696
|
+
}, 160);
|
|
2697
|
+
});
|
|
2698
|
+
editor.on("style:target", () => {
|
|
2699
|
+
const selected = getCurrentOrionBlockTarget(getCurrentStyleTarget());
|
|
2700
|
+
if (selected) {
|
|
2701
|
+
selectedComponentRef.current = selected;
|
|
2702
|
+
lastSelectedComponentRef.current = selected;
|
|
2703
|
+
window.setTimeout(() => {
|
|
2704
|
+
if (historyRestoreActiveRef.current) {
|
|
2705
|
+
return;
|
|
2706
|
+
}
|
|
2707
|
+
selectStyleManagerTarget(selected);
|
|
2708
|
+
refreshSelectedState(selected);
|
|
2709
|
+
}, 160);
|
|
2710
|
+
}
|
|
2711
|
+
});
|
|
2712
|
+
setSelectedDevice(editor.getDevice() || "desktop");
|
|
2713
|
+
runValidation(editor);
|
|
2714
|
+
updateHistoryState(editor);
|
|
2715
|
+
decorateBuilderSettingHelp();
|
|
2716
|
+
setLoading(false);
|
|
2717
|
+
} catch (initError) {
|
|
2718
|
+
setError(initError instanceof Error ? initError.message : "Could not load the website builder.");
|
|
2719
|
+
setLoading(false);
|
|
2720
|
+
}
|
|
2721
|
+
};
|
|
2722
|
+
void init();
|
|
2723
|
+
return () => {
|
|
2724
|
+
active = false;
|
|
2725
|
+
if (autosaveTimerRef.current) {
|
|
2726
|
+
window.clearTimeout(autosaveTimerRef.current);
|
|
2727
|
+
}
|
|
2728
|
+
editorRef.current?.destroy();
|
|
2729
|
+
editorRef.current = null;
|
|
2730
|
+
};
|
|
2731
|
+
}, [adapter, autosaveIntervalMs, initialData?.projectData, initialData?.title]);
|
|
2732
|
+
const save = async (status, options = {}) => {
|
|
2733
|
+
const editor = editorRef.current;
|
|
2734
|
+
if (!editor || saving) {
|
|
2735
|
+
return;
|
|
2736
|
+
}
|
|
2737
|
+
const issues = runValidation(editor);
|
|
2738
|
+
if (status === "published" && hasBlockingBuilderV2Issues(issues)) {
|
|
2739
|
+
const message = "Resolve blocking validation errors before publishing.";
|
|
2740
|
+
setSaveMessage(message);
|
|
2741
|
+
postToParent({
|
|
2742
|
+
message,
|
|
2743
|
+
ok: false,
|
|
2744
|
+
status,
|
|
2745
|
+
type: "save-result"
|
|
2746
|
+
});
|
|
2747
|
+
return;
|
|
2748
|
+
}
|
|
2749
|
+
setSaving(status);
|
|
2750
|
+
try {
|
|
2751
|
+
syncAllOrionBlockStylesToAttributes();
|
|
2752
|
+
const projectData = editor.getProjectData();
|
|
2753
|
+
const payload = buildSavePayload(editor, status, projectData);
|
|
2754
|
+
const dynamicComponents = parseBuilderV2DynamicComponents(String(payload.compiledHtml || ""));
|
|
2755
|
+
const endpoint = status === "draft" ? `/api/pages/${pageID}?draft=true` : `/api/pages/${pageID}`;
|
|
2756
|
+
const response = await fetch(endpoint, {
|
|
2757
|
+
body: JSON.stringify(
|
|
2758
|
+
status === "published" ? {
|
|
2759
|
+
_status: "published",
|
|
2760
|
+
builderDynamicComponents: dynamicComponents,
|
|
2761
|
+
builderMode: "grapes-v2",
|
|
2762
|
+
builderProjectData: projectData,
|
|
2763
|
+
builderPublishedProjectData: projectData,
|
|
2764
|
+
builderLastPublishedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2765
|
+
builderLastSavedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2766
|
+
builderValidationIssues: issues,
|
|
2767
|
+
compiledCss: payload.compiledCss,
|
|
2768
|
+
compiledHtml: payload.compiledHtml
|
|
2769
|
+
} : {
|
|
2770
|
+
_status: "draft",
|
|
2771
|
+
builderAutosaveProjectData: options.autosave ? projectData : null,
|
|
2772
|
+
builderDynamicComponents: dynamicComponents,
|
|
2773
|
+
builderMode: "grapes-v2",
|
|
2774
|
+
builderProjectData: projectData,
|
|
2775
|
+
builderLastSavedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2776
|
+
builderValidationIssues: issues,
|
|
2777
|
+
compiledCss: payload.compiledCss,
|
|
2778
|
+
compiledHtml: payload.compiledHtml
|
|
2779
|
+
}
|
|
2780
|
+
),
|
|
2781
|
+
credentials: "include",
|
|
2782
|
+
headers: {
|
|
2783
|
+
"Content-Type": "application/json"
|
|
2784
|
+
},
|
|
2785
|
+
method: "PATCH"
|
|
2786
|
+
});
|
|
2787
|
+
if (!response.ok) {
|
|
2788
|
+
if (response.status === 401 || response.status === 403) {
|
|
2789
|
+
postToParent({ type: "session-expired" });
|
|
2790
|
+
}
|
|
2791
|
+
throw new Error(await parsePayloadErrorMessage(response, "Could not save this page."));
|
|
2792
|
+
}
|
|
2793
|
+
editor.clearDirtyCount();
|
|
2794
|
+
setIsDirty(false);
|
|
2795
|
+
setPublicationState(status === "published" ? "live" : "draft");
|
|
2796
|
+
postToParent({
|
|
2797
|
+
dirty: false,
|
|
2798
|
+
type: "dirty-state"
|
|
2799
|
+
});
|
|
2800
|
+
postToParent({
|
|
2801
|
+
message: status === "published" ? "Published." : options.autosave ? "Autosaved." : "Draft saved.",
|
|
2802
|
+
ok: true,
|
|
2803
|
+
status,
|
|
2804
|
+
type: "save-result"
|
|
2805
|
+
});
|
|
2806
|
+
setLastSavedAt((/* @__PURE__ */ new Date()).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }));
|
|
2807
|
+
setSaveMessage(status === "published" ? "Published" : options.autosave ? "Autosaved" : "Draft saved");
|
|
2808
|
+
} catch (saveError) {
|
|
2809
|
+
const message = saveError instanceof Error ? saveError.message : "Could not save.";
|
|
2810
|
+
setSaveMessage(message);
|
|
2811
|
+
postToParent({
|
|
2812
|
+
message,
|
|
2813
|
+
ok: false,
|
|
2814
|
+
status,
|
|
2815
|
+
type: "save-result"
|
|
2816
|
+
});
|
|
2817
|
+
} finally {
|
|
2818
|
+
setSaving(null);
|
|
2819
|
+
}
|
|
2820
|
+
};
|
|
2821
|
+
(0, import_react.useEffect)(() => {
|
|
2822
|
+
saveRef.current = save;
|
|
2823
|
+
}, [saving]);
|
|
2824
|
+
(0, import_react.useEffect)(() => {
|
|
2825
|
+
decorateBuilderSettingHelp();
|
|
2826
|
+
decorateBuilderColorEyeDroppers();
|
|
2827
|
+
const refreshControls = () => refreshSelectedState(selectedComponentRef.current);
|
|
2828
|
+
const onStylePanelInput = (event) => {
|
|
2829
|
+
const target = event.target;
|
|
2830
|
+
if (target?.closest("#orion-builder-v2-styles")) {
|
|
2831
|
+
const activeElement = document.activeElement;
|
|
2832
|
+
if (!sidebarPointerActiveRef.current && !activeElement?.closest("#orion-builder-v2-styles")) {
|
|
2833
|
+
return;
|
|
2834
|
+
}
|
|
2835
|
+
syncStylePanelChange();
|
|
2836
|
+
}
|
|
2837
|
+
};
|
|
2838
|
+
const onDocumentClick = async (event) => {
|
|
2839
|
+
const target = event.target;
|
|
2840
|
+
const helpTrigger = target?.closest(".orion-builder-v2-help-trigger");
|
|
2841
|
+
if (helpTrigger) {
|
|
2842
|
+
event.preventDefault();
|
|
2843
|
+
event.stopPropagation();
|
|
2844
|
+
const wrapper = helpTrigger.parentElement;
|
|
2845
|
+
const willOpen = !wrapper?.classList.contains("is-builder-help-open");
|
|
2846
|
+
closeBuilderHelpPopovers(wrapper);
|
|
2847
|
+
openBuilderHelpPopover(helpTrigger, wrapper, willOpen);
|
|
2848
|
+
return;
|
|
2849
|
+
}
|
|
2850
|
+
const eyeDropperButton = target?.closest('[data-orion-color-eyedropper="true"]');
|
|
2851
|
+
if (eyeDropperButton) {
|
|
2852
|
+
event.preventDefault();
|
|
2853
|
+
event.stopPropagation();
|
|
2854
|
+
const input = findColorInputForControl(eyeDropperButton);
|
|
2855
|
+
if (input) {
|
|
2856
|
+
try {
|
|
2857
|
+
await openScreenColorPickerForInput(input);
|
|
2858
|
+
refreshControls();
|
|
2859
|
+
} catch {
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
return;
|
|
2863
|
+
}
|
|
2864
|
+
closeBuilderHelpPopovers();
|
|
2865
|
+
const colorAnchor = target?.closest(".gjs-field-colorp, .gjs-field-colorp-c, .gjs-field-color-picker");
|
|
2866
|
+
if (colorAnchor) {
|
|
2867
|
+
colorPickerAnchorRef.current = colorAnchor.closest(".gjs-field-colorp") || colorAnchor;
|
|
2868
|
+
positionColorPickerFromAnchor(colorPickerAnchorRef.current);
|
|
2869
|
+
window.setTimeout(() => positionColorPickerFromAnchor(colorPickerAnchorRef.current), 80);
|
|
2870
|
+
}
|
|
2871
|
+
};
|
|
2872
|
+
const onDocumentKeydown = (event) => {
|
|
2873
|
+
const target = event.target;
|
|
2874
|
+
const helpTrigger = target?.closest(".orion-builder-v2-help-trigger");
|
|
2875
|
+
if (!helpTrigger || event.key !== "Enter" && event.key !== " ") {
|
|
2876
|
+
return;
|
|
2877
|
+
}
|
|
2878
|
+
event.preventDefault();
|
|
2879
|
+
const wrapper = helpTrigger.parentElement;
|
|
2880
|
+
const willOpen = !wrapper?.classList.contains("is-builder-help-open");
|
|
2881
|
+
closeBuilderHelpPopovers(wrapper);
|
|
2882
|
+
openBuilderHelpPopover(helpTrigger, wrapper, willOpen);
|
|
2883
|
+
};
|
|
2884
|
+
const observer = new MutationObserver(() => {
|
|
2885
|
+
decorateBuilderSettingHelp();
|
|
2886
|
+
decorateBuilderColorEyeDroppers();
|
|
2887
|
+
});
|
|
2888
|
+
observer.observe(document.body, {
|
|
2889
|
+
childList: true,
|
|
2890
|
+
subtree: true
|
|
2891
|
+
});
|
|
2892
|
+
document.addEventListener("change", refreshControls);
|
|
2893
|
+
document.addEventListener("change", onStylePanelInput, true);
|
|
2894
|
+
document.addEventListener("click", onDocumentClick, true);
|
|
2895
|
+
document.addEventListener("input", refreshControls);
|
|
2896
|
+
document.addEventListener("input", onStylePanelInput, true);
|
|
2897
|
+
document.addEventListener("keydown", onDocumentKeydown, true);
|
|
2898
|
+
return () => {
|
|
2899
|
+
observer.disconnect();
|
|
2900
|
+
document.removeEventListener("change", refreshControls);
|
|
2901
|
+
document.removeEventListener("change", onStylePanelInput, true);
|
|
2902
|
+
document.removeEventListener("click", onDocumentClick, true);
|
|
2903
|
+
document.removeEventListener("input", refreshControls);
|
|
2904
|
+
document.removeEventListener("input", onStylePanelInput, true);
|
|
2905
|
+
document.removeEventListener("keydown", onDocumentKeydown, true);
|
|
2906
|
+
};
|
|
2907
|
+
}, []);
|
|
2908
|
+
(0, import_react.useEffect)(() => {
|
|
2909
|
+
const onMessage = (event) => {
|
|
2910
|
+
const data = event.data;
|
|
2911
|
+
const editor = editorRef.current;
|
|
2912
|
+
if (!data || data.source !== "payload-visual-builder-parent" || !editor) {
|
|
2913
|
+
return;
|
|
2914
|
+
}
|
|
2915
|
+
if (data.type === "dirty-check-request") {
|
|
2916
|
+
postToParent({ dirty: editor.getDirtyCount() > 0, type: "dirty-state" });
|
|
2917
|
+
updateHistoryState(editor);
|
|
2918
|
+
return;
|
|
2919
|
+
}
|
|
2920
|
+
if (data.type === "history-check-request") {
|
|
2921
|
+
updateHistoryState(editor);
|
|
2922
|
+
return;
|
|
2923
|
+
}
|
|
2924
|
+
if (data.type === "undo") {
|
|
2925
|
+
runHistoryAction("undo");
|
|
2926
|
+
return;
|
|
2927
|
+
}
|
|
2928
|
+
if (data.type === "redo") {
|
|
2929
|
+
runHistoryAction("redo");
|
|
2930
|
+
return;
|
|
2931
|
+
}
|
|
2932
|
+
if (data.type === "save" && (data.status === "draft" || data.status === "published")) {
|
|
2933
|
+
void save(data.status);
|
|
2934
|
+
}
|
|
2935
|
+
};
|
|
2936
|
+
window.addEventListener("message", onMessage);
|
|
2937
|
+
return () => window.removeEventListener("message", onMessage);
|
|
2938
|
+
}, [saving]);
|
|
2939
|
+
const statusLabel = saving ? saving === "published" ? "Publishing..." : "Saving draft..." : isDirty ? "Unsaved changes" : saveMessage && saveMessage !== "Unsaved changes" ? saveMessage : "All changes saved";
|
|
2940
|
+
const statusMeta = lastSavedAt ? `Last saved ${lastSavedAt}` : "Ready";
|
|
2941
|
+
const liveStatusLabel = isDirty ? "Save draft to update" : publicationState === "draft" ? "Unpublished draft changes" : "Live is up to date";
|
|
2942
|
+
const renderInspectorPanel = (panel, title, children) => {
|
|
2943
|
+
const isOpen = Boolean(openInspectorPanels[panel]);
|
|
2944
|
+
const panelContentID = `orion-builder-v2-inspector-panel-${panel}`;
|
|
2945
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `orion-builder-v2-panel orion-builder-v2-collapsible-panel ${isOpen ? "is-open" : "is-collapsed"}`, children: [
|
|
2946
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
2947
|
+
"button",
|
|
2948
|
+
{
|
|
2949
|
+
"aria-controls": panelContentID,
|
|
2950
|
+
"aria-expanded": isOpen,
|
|
2951
|
+
className: "orion-builder-v2-panel-toggle",
|
|
2952
|
+
onClick: () => toggleInspectorPanel(panel),
|
|
2953
|
+
type: "button",
|
|
2954
|
+
children: [
|
|
2955
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: title }),
|
|
2956
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "orion-builder-v2-panel-toggle-icon", "aria-hidden": "true", children: isOpen ? "\u2212" : "+" })
|
|
2957
|
+
]
|
|
2958
|
+
}
|
|
2959
|
+
),
|
|
2960
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "orion-builder-v2-panel-body", hidden: !isOpen, id: panelContentID, children })
|
|
2961
|
+
] });
|
|
2962
|
+
};
|
|
2963
|
+
const renderSidebarPanel = (panel, title, children) => {
|
|
2964
|
+
const isOpen = Boolean(openSidebarPanels[panel]);
|
|
2965
|
+
const panelContentID = `orion-builder-v2-sidebar-panel-${panel}`;
|
|
2966
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `orion-builder-v2-panel orion-builder-v2-collapsible-panel ${isOpen ? "is-open" : "is-collapsed"}`, children: [
|
|
2967
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
2968
|
+
"button",
|
|
2969
|
+
{
|
|
2970
|
+
"aria-controls": panelContentID,
|
|
2971
|
+
"aria-expanded": isOpen,
|
|
2972
|
+
className: "orion-builder-v2-panel-toggle",
|
|
2973
|
+
onClick: () => toggleSidebarPanel(panel),
|
|
2974
|
+
type: "button",
|
|
2975
|
+
children: [
|
|
2976
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: title }),
|
|
2977
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "orion-builder-v2-panel-toggle-icon", "aria-hidden": "true", children: isOpen ? "\u2212" : "+" })
|
|
2978
|
+
]
|
|
2979
|
+
}
|
|
2980
|
+
),
|
|
2981
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "orion-builder-v2-panel-body", hidden: !isOpen, id: panelContentID, children })
|
|
2982
|
+
] });
|
|
2983
|
+
};
|
|
2984
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
2985
|
+
"div",
|
|
2986
|
+
{
|
|
2987
|
+
className: `orion-builder-v2-editor ${detailedLayoutClassNames(detailedLayoutControlState)}`,
|
|
2988
|
+
onPointerDownCapture: (event) => {
|
|
2989
|
+
const target = event.target;
|
|
2990
|
+
sidebarPointerActiveRef.current = Boolean(
|
|
2991
|
+
target?.closest("#orion-builder-v2-styles, #orion-builder-v2-traits, .orion-builder-v2-sidebar, .orion-builder-v2-inspector")
|
|
2992
|
+
);
|
|
2993
|
+
},
|
|
2994
|
+
onPointerUpCapture: () => {
|
|
2995
|
+
window.setTimeout(() => {
|
|
2996
|
+
sidebarPointerActiveRef.current = false;
|
|
2997
|
+
}, 0);
|
|
2998
|
+
},
|
|
2999
|
+
onChangeCapture: syncStylePanelInput,
|
|
3000
|
+
onInputCapture: syncStylePanelInput,
|
|
3001
|
+
children: [
|
|
3002
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "orion-builder-v2-topbar", children: [
|
|
3003
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
3004
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "orion-builder-v2-eyebrow", children: "Website Builder V2" }),
|
|
3005
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { children: initialData?.title || "Untitled page" })
|
|
3006
|
+
] }),
|
|
3007
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "orion-builder-v2-toolbar", "aria-label": "Builder controls", children: [
|
|
3008
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `orion-builder-v2-sync is-${isDirty ? "dirty" : publicationState}`, children: [
|
|
3009
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: statusLabel }),
|
|
3010
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: liveStatusLabel }),
|
|
3011
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: statusMeta })
|
|
3012
|
+
] }),
|
|
3013
|
+
["desktop", "tablet", "mobile"].map((device) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3014
|
+
"button",
|
|
3015
|
+
{
|
|
3016
|
+
"aria-pressed": selectedDevice === device,
|
|
3017
|
+
className: "orion-builder-v2-tool",
|
|
3018
|
+
onClick: () => setDevice(device),
|
|
3019
|
+
type: "button",
|
|
3020
|
+
children: device
|
|
3021
|
+
},
|
|
3022
|
+
device
|
|
3023
|
+
)),
|
|
3024
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3025
|
+
"button",
|
|
3026
|
+
{
|
|
3027
|
+
className: "orion-builder-v2-tool",
|
|
3028
|
+
disabled: !historyState.canUndo,
|
|
3029
|
+
onClick: () => {
|
|
3030
|
+
runHistoryAction("undo");
|
|
3031
|
+
},
|
|
3032
|
+
type: "button",
|
|
3033
|
+
children: "Undo"
|
|
3034
|
+
}
|
|
3035
|
+
),
|
|
3036
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3037
|
+
"button",
|
|
3038
|
+
{
|
|
3039
|
+
className: "orion-builder-v2-tool",
|
|
3040
|
+
disabled: !historyState.canRedo,
|
|
3041
|
+
onClick: () => {
|
|
3042
|
+
runHistoryAction("redo");
|
|
3043
|
+
},
|
|
3044
|
+
type: "button",
|
|
3045
|
+
children: "Redo"
|
|
3046
|
+
}
|
|
3047
|
+
),
|
|
3048
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "orion-builder-v2-tool is-primary", disabled: Boolean(saving), onClick: () => void save("draft"), type: "button", children: saving === "draft" ? "Saving..." : "Save draft" }),
|
|
3049
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "orion-builder-v2-tool is-publish", disabled: Boolean(saving), onClick: () => void save("published"), type: "button", children: saving === "published" ? "Publishing..." : "Publish" })
|
|
3050
|
+
] })
|
|
3051
|
+
] }),
|
|
3052
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("aside", { className: "orion-builder-v2-sidebar", children: [
|
|
3053
|
+
renderSidebarPanel("pages", "Pages", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "orion-builder-v2-page-tree", children: pageTree.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "No pages loaded." }) : pageTree.map((page) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3054
|
+
"a",
|
|
3055
|
+
{
|
|
3056
|
+
className: "orion-builder-v2-page-link",
|
|
3057
|
+
href: `${editorPageBasePath}/${page.id}`,
|
|
3058
|
+
onClick: (event) => {
|
|
3059
|
+
const target = `${editorPageBasePath}/${page.id}`;
|
|
3060
|
+
if (window.parent && window.parent !== window) {
|
|
3061
|
+
event.preventDefault();
|
|
3062
|
+
window.parent.location.href = target;
|
|
3063
|
+
}
|
|
3064
|
+
},
|
|
3065
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: page.title })
|
|
3066
|
+
},
|
|
3067
|
+
page.id
|
|
3068
|
+
)) })),
|
|
3069
|
+
renderSidebarPanel("blocks", "Blocks", /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
3070
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Drag sections into the page. Dynamic blocks render through the project adapter." }),
|
|
3071
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { id: "orion-builder-v2-blocks" })
|
|
3072
|
+
] })),
|
|
3073
|
+
renderSidebarPanel("validation", "Validation", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "orion-builder-v2-validation-list", children: validationIssues.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "No issues found." }) : validationIssues.map((issue) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `orion-builder-v2-validation is-${issue.severity}`, children: [
|
|
3074
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: issue.message }),
|
|
3075
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: issue.severity })
|
|
3076
|
+
] }, `${issue.code}-${issue.path}`)) }))
|
|
3077
|
+
] }),
|
|
3078
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("main", { className: "orion-builder-v2-main", children: [
|
|
3079
|
+
loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "orion-builder-v2-status", children: "Loading builder..." }) : null,
|
|
3080
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "orion-builder-v2-error", children: error }) : null,
|
|
3081
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "orion-builder-v2-canvas", ref: containerRef })
|
|
3082
|
+
] }),
|
|
3083
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("aside", { className: "orion-builder-v2-inspector", "aria-label": "Selected section settings", children: [
|
|
3084
|
+
renderInspectorPanel("section", selectionSummary ? selectionSummary.label : "No section selected", /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
3085
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: selectionSummary ? "Edit this section content, images, links, layout, and spacing." : "Select a section or element on the canvas to edit its settings." }),
|
|
3086
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { id: "orion-builder-v2-traits" })
|
|
3087
|
+
] })),
|
|
3088
|
+
selectionSummary?.items ? renderInspectorPanel("items", "Items", /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
3089
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Add, duplicate, remove, then click item text or images on the canvas to edit them." }),
|
|
3090
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "orion-builder-v2-items", children: selectionSummary.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "orion-builder-v2-item-row", children: [
|
|
3091
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "orion-builder-v2-item-title", children: [
|
|
3092
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Title" }),
|
|
3093
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3094
|
+
"input",
|
|
3095
|
+
{
|
|
3096
|
+
"aria-label": `Item ${item.index + 1} title`,
|
|
3097
|
+
onChange: (event) => {
|
|
3098
|
+
const title = event.target.value;
|
|
3099
|
+
updateSelectedItems(
|
|
3100
|
+
(items) => items.map(
|
|
3101
|
+
(currentItem, index) => index === item.index ? {
|
|
3102
|
+
...currentItem,
|
|
3103
|
+
title
|
|
3104
|
+
} : currentItem
|
|
3105
|
+
)
|
|
3106
|
+
);
|
|
3107
|
+
},
|
|
3108
|
+
type: "text",
|
|
3109
|
+
value: item.title
|
|
3110
|
+
}
|
|
3111
|
+
)
|
|
3112
|
+
] }),
|
|
3113
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3114
|
+
"button",
|
|
3115
|
+
{
|
|
3116
|
+
onClick: () => {
|
|
3117
|
+
updateSelectedItems((items) => {
|
|
3118
|
+
const source = items[item.index];
|
|
3119
|
+
if (!source) {
|
|
3120
|
+
return items;
|
|
3121
|
+
}
|
|
3122
|
+
const copy = [...items];
|
|
3123
|
+
copy.splice(item.index + 1, 0, {
|
|
3124
|
+
...source,
|
|
3125
|
+
title: typeof source.title === "string" ? `${source.title} copy` : source.title
|
|
3126
|
+
});
|
|
3127
|
+
return copy;
|
|
3128
|
+
});
|
|
3129
|
+
},
|
|
3130
|
+
type: "button",
|
|
3131
|
+
children: "Duplicate"
|
|
3132
|
+
}
|
|
3133
|
+
),
|
|
3134
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3135
|
+
"button",
|
|
3136
|
+
{
|
|
3137
|
+
onClick: () => {
|
|
3138
|
+
updateSelectedItems((items) => items.filter((_, index) => index !== item.index));
|
|
3139
|
+
},
|
|
3140
|
+
type: "button",
|
|
3141
|
+
children: "Remove"
|
|
3142
|
+
}
|
|
3143
|
+
)
|
|
3144
|
+
] }, `${item.index}-${item.title}`)) }),
|
|
3145
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3146
|
+
"button",
|
|
3147
|
+
{
|
|
3148
|
+
className: "orion-builder-v2-wide-action",
|
|
3149
|
+
onClick: () => {
|
|
3150
|
+
updateSelectedItems((items) => [
|
|
3151
|
+
...items,
|
|
3152
|
+
{
|
|
3153
|
+
description: "Describe this feature.",
|
|
3154
|
+
imageURL: "",
|
|
3155
|
+
title: "New feature"
|
|
3156
|
+
}
|
|
3157
|
+
]);
|
|
3158
|
+
},
|
|
3159
|
+
type: "button",
|
|
3160
|
+
children: "Add item"
|
|
3161
|
+
}
|
|
3162
|
+
)
|
|
3163
|
+
] })) : null,
|
|
3164
|
+
renderInspectorPanel("design", "Design", /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
3165
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Use quick controls for common layout changes, then fine tune exact values in Detailed design below." }),
|
|
3166
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "orion-builder-v2-quick-layout", "aria-label": "Quick layout controls", children: [
|
|
3167
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "orion-builder-v2-control-group", children: [
|
|
3168
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h3", { children: [
|
|
3169
|
+
"Layout",
|
|
3170
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(HelpTrigger, { help: "Choose a common arrangement for the selected section, such as stacked, row, columns, centered, or overlay.", label: "Layout" })
|
|
3171
|
+
] }),
|
|
3172
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "orion-builder-v2-choice-grid", children: quickLayoutOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
3173
|
+
"button",
|
|
3174
|
+
{
|
|
3175
|
+
"aria-pressed": quickLayoutState.layout === option.value,
|
|
3176
|
+
className: "orion-builder-v2-choice",
|
|
3177
|
+
disabled: !selectionSummary,
|
|
3178
|
+
onClick: () => applyQuickLayout(option.value),
|
|
3179
|
+
type: "button",
|
|
3180
|
+
children: [
|
|
3181
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
|
|
3182
|
+
option.label,
|
|
3183
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(HelpTrigger, { help: option.description, label: option.label })
|
|
3184
|
+
] }),
|
|
3185
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: option.description })
|
|
3186
|
+
]
|
|
3187
|
+
},
|
|
3188
|
+
option.value
|
|
3189
|
+
)) })
|
|
3190
|
+
] }),
|
|
3191
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "orion-builder-v2-control-group", children: [
|
|
3192
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h3", { children: [
|
|
3193
|
+
"Alignment",
|
|
3194
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(HelpTrigger, { help: "Control where content sits inside the selected section horizontally and vertically.", label: "Alignment" })
|
|
3195
|
+
] }),
|
|
3196
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "orion-builder-v2-segmented", role: "group", "aria-label": "Horizontal alignment", children: horizontalAlignOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
3197
|
+
"button",
|
|
3198
|
+
{
|
|
3199
|
+
"aria-pressed": quickLayoutState.horizontalAlign === option.value,
|
|
3200
|
+
disabled: !selectionSummary,
|
|
3201
|
+
onClick: () => applyQuickHorizontalAlign(option.value),
|
|
3202
|
+
type: "button",
|
|
3203
|
+
children: [
|
|
3204
|
+
option.label,
|
|
3205
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(HelpTrigger, { help: `${option.label} aligns content horizontally within the selected section.`, label: option.label })
|
|
3206
|
+
]
|
|
3207
|
+
},
|
|
3208
|
+
option.value
|
|
3209
|
+
)) }),
|
|
3210
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "orion-builder-v2-segmented", role: "group", "aria-label": "Vertical alignment", children: verticalAlignOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
3211
|
+
"button",
|
|
3212
|
+
{
|
|
3213
|
+
"aria-pressed": quickLayoutState.verticalAlign === option.value,
|
|
3214
|
+
disabled: !selectionSummary,
|
|
3215
|
+
onClick: () => applyQuickVerticalAlign(option.value),
|
|
3216
|
+
type: "button",
|
|
3217
|
+
children: [
|
|
3218
|
+
option.label,
|
|
3219
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(HelpTrigger, { help: `${option.label} aligns content vertically within the selected section.`, label: option.label })
|
|
3220
|
+
]
|
|
3221
|
+
},
|
|
3222
|
+
option.value
|
|
3223
|
+
)) })
|
|
3224
|
+
] }),
|
|
3225
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "orion-builder-v2-control-group", children: [
|
|
3226
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h3", { children: [
|
|
3227
|
+
"Spacing",
|
|
3228
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(HelpTrigger, { help: "Set a quick inside-padding preset for the selected section.", label: "Spacing" })
|
|
3229
|
+
] }),
|
|
3230
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "orion-builder-v2-segmented", role: "group", "aria-label": "Section spacing", children: quickSpacingOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
3231
|
+
"button",
|
|
3232
|
+
{
|
|
3233
|
+
"aria-pressed": quickLayoutState.spacing === option.value,
|
|
3234
|
+
disabled: !selectionSummary,
|
|
3235
|
+
onClick: () => applyQuickSpacing(option.value),
|
|
3236
|
+
type: "button",
|
|
3237
|
+
children: [
|
|
3238
|
+
option.label,
|
|
3239
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(HelpTrigger, { help: `${option.label} spacing changes the selected section's inside padding.`, label: option.label })
|
|
3240
|
+
]
|
|
3241
|
+
},
|
|
3242
|
+
option.value
|
|
3243
|
+
)) })
|
|
3244
|
+
] }),
|
|
3245
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "orion-builder-v2-toggle-list", children: [
|
|
3246
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3247
|
+
"button",
|
|
3248
|
+
{
|
|
3249
|
+
"aria-pressed": quickLayoutState.sticky,
|
|
3250
|
+
className: "orion-builder-v2-toggle",
|
|
3251
|
+
disabled: !selectionSummary,
|
|
3252
|
+
onClick: toggleSticky,
|
|
3253
|
+
type: "button",
|
|
3254
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
3255
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
|
|
3256
|
+
"Sticky section",
|
|
3257
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(HelpTrigger, { help: "Keep this selected section visible while visitors scroll past it.", label: "Sticky section" })
|
|
3258
|
+
] }),
|
|
3259
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Keep this section pinned while scrolling." })
|
|
3260
|
+
] })
|
|
3261
|
+
}
|
|
3262
|
+
),
|
|
3263
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
3264
|
+
"button",
|
|
3265
|
+
{
|
|
3266
|
+
"aria-pressed": quickLayoutState.hidden,
|
|
3267
|
+
className: "orion-builder-v2-toggle",
|
|
3268
|
+
disabled: !selectionSummary,
|
|
3269
|
+
onClick: toggleHidden,
|
|
3270
|
+
type: "button",
|
|
3271
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
3272
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
|
|
3273
|
+
"Hide section",
|
|
3274
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(HelpTrigger, { help: "Hide this selected section on the page without deleting its content.", label: "Hide section" })
|
|
3275
|
+
] }),
|
|
3276
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "Keep it saved but do not show it on the page." })
|
|
3277
|
+
] })
|
|
3278
|
+
}
|
|
3279
|
+
)
|
|
3280
|
+
] })
|
|
3281
|
+
] })
|
|
3282
|
+
] })),
|
|
3283
|
+
renderInspectorPanel("detailed-design", "Detailed design", /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
3284
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
|
|
3285
|
+
"Fine tune exact spacing, color, typography, borders, size, and layout values for the selected element.",
|
|
3286
|
+
canUseDeveloperControls ? " Developer access is active." : ""
|
|
3287
|
+
] }),
|
|
3288
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { id: "orion-builder-v2-styles" })
|
|
3289
|
+
] }))
|
|
3290
|
+
] })
|
|
3291
|
+
]
|
|
3292
|
+
}
|
|
3293
|
+
);
|
|
3294
|
+
}
|
|
3295
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
3296
|
+
0 && (module.exports = {
|
|
3297
|
+
GrapesPageEditor
|
|
3298
|
+
});
|