@ohhwells/bridge 0.1.91 → 0.1.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +192 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +192 -34
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -142,6 +142,7 @@ function isRenderableTree(value) {
|
|
|
142
142
|
|
|
143
143
|
// src/lib/ai-sections-store.ts
|
|
144
144
|
var AI_SECTIONS_KEY = "__ohw_ai_sections";
|
|
145
|
+
var AI_SLOT_KEY_PREFIX = "ai.";
|
|
145
146
|
var EMPTY_AI_SECTIONS = { v: 1, sections: [] };
|
|
146
147
|
function parseAiSectionsState(raw) {
|
|
147
148
|
if (!raw) return EMPTY_AI_SECTIONS;
|
|
@@ -185,6 +186,63 @@ function applyTreeToState(state, payload) {
|
|
|
185
186
|
const others = state.sections.filter((existing) => existing.id !== entry.id);
|
|
186
187
|
return { ...state, v: 1, sections: [...others, entry] };
|
|
187
188
|
}
|
|
189
|
+
function foldAlignIntoTrees(state, store) {
|
|
190
|
+
const byId = new Map(state.sections.map((entry) => [entry.id, entry]));
|
|
191
|
+
const nextTrees = /* @__PURE__ */ new Map();
|
|
192
|
+
const treeFor = (id) => {
|
|
193
|
+
const cloned = nextTrees.get(id);
|
|
194
|
+
if (cloned) return cloned;
|
|
195
|
+
const entry = byId.get(id);
|
|
196
|
+
if (!entry) return void 0;
|
|
197
|
+
const fresh = {
|
|
198
|
+
...entry.tree,
|
|
199
|
+
rows: entry.tree.rows.map((row) => ({ ...row, blocks: row.blocks.map((block) => ({ ...block })) }))
|
|
200
|
+
};
|
|
201
|
+
nextTrees.set(id, fresh);
|
|
202
|
+
return fresh;
|
|
203
|
+
};
|
|
204
|
+
const nodes = {};
|
|
205
|
+
for (const [key, override] of Object.entries(store.nodes)) {
|
|
206
|
+
const match = override.align !== void 0 && key.startsWith(AI_SLOT_KEY_PREFIX) ? key.match(/^ai\.(.+?)\.r(\d+)\.b(\d+)(?:\.|$)/) : null;
|
|
207
|
+
const tree = match ? treeFor(match[1]) : void 0;
|
|
208
|
+
const block = match && tree ? tree.rows[Number(match[2])]?.blocks[Number(match[3])] : void 0;
|
|
209
|
+
if (!block) {
|
|
210
|
+
nodes[key] = override;
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
block.align = override.align;
|
|
214
|
+
const rest = { ...override };
|
|
215
|
+
delete rest.align;
|
|
216
|
+
if (Object.keys(rest).length > 0) nodes[key] = rest;
|
|
217
|
+
}
|
|
218
|
+
const sections = {};
|
|
219
|
+
for (const [sectionId, override] of Object.entries(store.sections)) {
|
|
220
|
+
const tree = override.align !== void 0 ? treeFor(sectionId) : void 0;
|
|
221
|
+
if (!tree) {
|
|
222
|
+
sections[sectionId] = override;
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
for (const row of tree.rows) {
|
|
226
|
+
for (const block of row.blocks) block.align = override.align;
|
|
227
|
+
}
|
|
228
|
+
const rest = { ...override };
|
|
229
|
+
delete rest.align;
|
|
230
|
+
if (Object.keys(rest).length > 0) sections[sectionId] = rest;
|
|
231
|
+
}
|
|
232
|
+
if (nextTrees.size === 0) return { state, store, changed: false };
|
|
233
|
+
return {
|
|
234
|
+
state: {
|
|
235
|
+
...state,
|
|
236
|
+
v: 1,
|
|
237
|
+
sections: state.sections.map((entry) => {
|
|
238
|
+
const tree = nextTrees.get(entry.id);
|
|
239
|
+
return tree ? { ...entry, tree } : entry;
|
|
240
|
+
})
|
|
241
|
+
},
|
|
242
|
+
store: { v: 1, sections, nodes },
|
|
243
|
+
changed: true
|
|
244
|
+
};
|
|
245
|
+
}
|
|
188
246
|
function removeFromState(state, id) {
|
|
189
247
|
return { ...state, v: 1, sections: state.sections.filter((entry) => entry.id !== id) };
|
|
190
248
|
}
|
|
@@ -403,6 +461,9 @@ function styleSheetCss() {
|
|
|
403
461
|
`[data-ohw-style-spacing="${spacing}"] { padding-top: ${px}px !important; padding-bottom: ${px}px !important; }`
|
|
404
462
|
);
|
|
405
463
|
}
|
|
464
|
+
for (const align of ["left", "center", "right"]) {
|
|
465
|
+
rules.push(`[data-ohw-style-align="${align}"] { text-align: ${align} !important; }`);
|
|
466
|
+
}
|
|
406
467
|
return rules.join("\n");
|
|
407
468
|
}
|
|
408
469
|
var STYLE_FONT_LINK_ID = "ohw-style-fonts";
|
|
@@ -429,10 +490,24 @@ var SECTION_ATTRS = {
|
|
|
429
490
|
textDistribution: "data-ohw-style-distribution",
|
|
430
491
|
headlineScale: "data-ohw-style-headline",
|
|
431
492
|
imageAspect: "data-ohw-style-aspect",
|
|
432
|
-
spacing: "data-ohw-style-spacing"
|
|
493
|
+
spacing: "data-ohw-style-spacing",
|
|
494
|
+
align: "data-ohw-style-align"
|
|
433
495
|
};
|
|
434
496
|
var NODE_WROTE_ATTR = "data-ohw-style-node";
|
|
435
|
-
var NODE_PROPS = [
|
|
497
|
+
var NODE_PROPS = [
|
|
498
|
+
"color",
|
|
499
|
+
"font-family",
|
|
500
|
+
"font-size",
|
|
501
|
+
"background",
|
|
502
|
+
"text-align",
|
|
503
|
+
"justify-content",
|
|
504
|
+
"align-items"
|
|
505
|
+
];
|
|
506
|
+
var ALIGN_JUSTIFY = {
|
|
507
|
+
left: "flex-start",
|
|
508
|
+
center: "center",
|
|
509
|
+
right: "flex-end"
|
|
510
|
+
};
|
|
436
511
|
function saveInline(el, prop) {
|
|
437
512
|
const attr = `data-ohw-style-prev-${prop}`;
|
|
438
513
|
if (el.hasAttribute(attr)) return;
|
|
@@ -476,6 +551,10 @@ function clearNodeProps(root) {
|
|
|
476
551
|
function buttonSurfaceOf(el) {
|
|
477
552
|
return el.closest("a, button") ?? el;
|
|
478
553
|
}
|
|
554
|
+
function alignSubjectOf(el) {
|
|
555
|
+
const button = el.closest('[data-ohw-role="button"]');
|
|
556
|
+
return button?.parentElement ?? el;
|
|
557
|
+
}
|
|
479
558
|
function applyStylesToDom(store) {
|
|
480
559
|
ensureStyleSheet();
|
|
481
560
|
clearSectionAttrs(document);
|
|
@@ -521,6 +600,18 @@ function applyStylesToDom(store) {
|
|
|
521
600
|
el.style.setProperty("font-size", `${override.fontSize}px`, "important");
|
|
522
601
|
el.setAttribute(NODE_WROTE_ATTR, "");
|
|
523
602
|
}
|
|
603
|
+
if (override.align !== void 0) {
|
|
604
|
+
const subject = alignSubjectOf(el);
|
|
605
|
+
saveInline(subject, "text-align");
|
|
606
|
+
saveInline(subject, "justify-content");
|
|
607
|
+
subject.style.setProperty("text-align", override.align, "important");
|
|
608
|
+
subject.style.setProperty(
|
|
609
|
+
"justify-content",
|
|
610
|
+
ALIGN_JUSTIFY[override.align] ?? "flex-start",
|
|
611
|
+
"important"
|
|
612
|
+
);
|
|
613
|
+
subject.setAttribute(NODE_WROTE_ATTR, "");
|
|
614
|
+
}
|
|
524
615
|
if (override.buttonBackground !== void 0 || override.buttonText !== void 0) {
|
|
525
616
|
const surface = buttonSurfaceOf(el);
|
|
526
617
|
if (override.buttonBackground !== void 0) {
|
|
@@ -729,7 +820,7 @@ function TextBlock({ slots, ctx, path }) {
|
|
|
729
820
|
}
|
|
730
821
|
function SectionHeaderBlock({ node, ctx, path }) {
|
|
731
822
|
const slots = node.slots ?? {};
|
|
732
|
-
const align = slots.alignment === "center" ? "center" : "left";
|
|
823
|
+
const align = node.align ?? (slots.alignment === "center" ? "center" : "left");
|
|
733
824
|
const children = node.children ?? [];
|
|
734
825
|
const buttonRowIdx = children.findIndex((c) => c.type === "button-row");
|
|
735
826
|
const buttonRow = buttonRowIdx >= 0 ? children[buttonRowIdx] : void 0;
|
|
@@ -773,7 +864,7 @@ function SectionHeaderBlock({ node, ctx, path }) {
|
|
|
773
864
|
display: "flex",
|
|
774
865
|
gap: AI_TREE_TOKENS.spacing6,
|
|
775
866
|
marginTop: AI_TREE_TOKENS.spacing8,
|
|
776
|
-
justifyContent: align === "center" ? "center" : "flex-start"
|
|
867
|
+
justifyContent: align === "center" ? "center" : align === "right" ? "flex-end" : "flex-start"
|
|
777
868
|
},
|
|
778
869
|
children: (buttonRow.children ?? []).map((button, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
779
870
|
ButtonEl,
|
|
@@ -1106,7 +1197,7 @@ function CardBlock({ node, ctx, path }) {
|
|
|
1106
1197
|
editPath: `${path}.media`
|
|
1107
1198
|
}
|
|
1108
1199
|
) : null;
|
|
1109
|
-
const centered = slots.alignment === "center";
|
|
1200
|
+
const centered = (node.align ?? slots.alignment) === "center";
|
|
1110
1201
|
const content = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1111
1202
|
"div",
|
|
1112
1203
|
{
|
|
@@ -1825,6 +1916,19 @@ function AiTreeRenderer({
|
|
|
1825
1916
|
}
|
|
1826
1917
|
})();
|
|
1827
1918
|
const distributed = !isOverlay && settings.textDistribution;
|
|
1919
|
+
const rowAlignItems = (rowAlign) => {
|
|
1920
|
+
if (rowAlign === "top") return "start";
|
|
1921
|
+
if (rowAlign === "bottom") return "end";
|
|
1922
|
+
if (rowAlign === "center" || rowAlign === "stretch") return rowAlign;
|
|
1923
|
+
if (distributed === "space-between") return "stretch";
|
|
1924
|
+
return (distributed ?? settings.verticalPosition) === "top" ? "start" : "center";
|
|
1925
|
+
};
|
|
1926
|
+
const cellAlignStyle = (blockAlign) => blockAlign ? {
|
|
1927
|
+
display: "flex",
|
|
1928
|
+
flexDirection: "column",
|
|
1929
|
+
alignItems: blockAlign === "left" ? "flex-start" : blockAlign === "right" ? "flex-end" : "center",
|
|
1930
|
+
textAlign: blockAlign
|
|
1931
|
+
} : {};
|
|
1828
1932
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1829
1933
|
"section",
|
|
1830
1934
|
{
|
|
@@ -1861,7 +1965,7 @@ function AiTreeRenderer({
|
|
|
1861
1965
|
display: "grid",
|
|
1862
1966
|
gridTemplateColumns: "repeat(12, 1fr)",
|
|
1863
1967
|
gap: AI_TREE_TOKENS.spacing6,
|
|
1864
|
-
alignItems:
|
|
1968
|
+
alignItems: rowAlignItems(row.align),
|
|
1865
1969
|
marginTop: r2 > 0 ? AI_TREE_TOKENS.spacing8 : 0
|
|
1866
1970
|
},
|
|
1867
1971
|
children: (row.blocks ?? []).map((block, b) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -1871,6 +1975,8 @@ function AiTreeRenderer({
|
|
|
1871
1975
|
style: {
|
|
1872
1976
|
gridColumn: `span ${Math.min(12, Math.max(1, block.span))}`,
|
|
1873
1977
|
minWidth: 0,
|
|
1978
|
+
// Horizontal placement of the block's content within its column.
|
|
1979
|
+
...cellAlignStyle(block.align),
|
|
1874
1980
|
// space-between: each column becomes a flex column whose content spreads over
|
|
1875
1981
|
// the full row height instead of clumping at the top.
|
|
1876
1982
|
...distributed === "space-between" ? { display: "flex", flexDirection: "column", justifyContent: "space-between" } : {}
|
|
@@ -8152,17 +8258,40 @@ var REMOVED_ATTR2 = "data-ohw-section-removed";
|
|
|
8152
8258
|
function isRemovedSection(el) {
|
|
8153
8259
|
return el.hasAttribute(REMOVED_ATTR2);
|
|
8154
8260
|
}
|
|
8261
|
+
function movableUnit(el) {
|
|
8262
|
+
return el.closest("[data-ohw-section-container]") ?? el;
|
|
8263
|
+
}
|
|
8264
|
+
function sectionTypeOf(el) {
|
|
8265
|
+
return el.getAttribute("data-ohw-section") ?? el.querySelector("[data-ohw-section]")?.getAttribute("data-ohw-section") ?? "";
|
|
8266
|
+
}
|
|
8267
|
+
function sectionElementOf(el) {
|
|
8268
|
+
return el.hasAttribute("data-ohw-section") ? el : el.querySelector("[data-ohw-section]") ?? el;
|
|
8269
|
+
}
|
|
8270
|
+
function collectTopLevelUnits(predicate) {
|
|
8271
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8272
|
+
const result = [];
|
|
8273
|
+
document.querySelectorAll("[data-ohw-section]").forEach((el) => {
|
|
8274
|
+
if (!predicate(el)) return;
|
|
8275
|
+
const unit = movableUnit(el);
|
|
8276
|
+
if (unit.parentElement?.closest("[data-ohw-section],[data-ohw-section-container]")) return;
|
|
8277
|
+
if (seen.has(unit)) return;
|
|
8278
|
+
seen.add(unit);
|
|
8279
|
+
result.push(unit);
|
|
8280
|
+
});
|
|
8281
|
+
return result;
|
|
8282
|
+
}
|
|
8155
8283
|
function topLevelSections() {
|
|
8156
|
-
return
|
|
8157
|
-
(el) => !el.parentElement?.closest("[data-ohw-section]") && !isChromeSection(el) && !isRemovedSection(el)
|
|
8158
|
-
);
|
|
8284
|
+
return collectTopLevelUnits((el) => !isChromeSection(el) && !isRemovedSection(movableUnit(el)));
|
|
8159
8285
|
}
|
|
8160
8286
|
function instanceIdOf(el) {
|
|
8161
8287
|
return el.dataset.ohwInstance ?? el.dataset.ohwSection ?? "";
|
|
8162
8288
|
}
|
|
8163
8289
|
function findByInstanceId(instanceId) {
|
|
8164
8290
|
const escapedId = CSS.escape(instanceId);
|
|
8165
|
-
|
|
8291
|
+
const direct = document.querySelector(`[data-ohw-instance="${escapedId}"]`);
|
|
8292
|
+
if (direct) return movableUnit(direct);
|
|
8293
|
+
const bare = document.querySelector(`[data-ohw-section="${escapedId}"]:not([data-ohw-instance])`);
|
|
8294
|
+
return bare ? movableUnit(bare) : null;
|
|
8166
8295
|
}
|
|
8167
8296
|
function planSectionMove(instanceId, targetIndex, currentPath) {
|
|
8168
8297
|
const sections = topLevelSections();
|
|
@@ -8174,7 +8303,7 @@ function planSectionMove(instanceId, targetIndex, currentPath) {
|
|
|
8174
8303
|
const reordered = [...others.slice(0, clamped), dragged, ...others.slice(clamped)];
|
|
8175
8304
|
return reordered.map((el, order) => ({
|
|
8176
8305
|
instanceId: instanceIdOf(el),
|
|
8177
|
-
type: el
|
|
8306
|
+
type: sectionTypeOf(el),
|
|
8178
8307
|
order,
|
|
8179
8308
|
pagePath: currentPath
|
|
8180
8309
|
}));
|
|
@@ -8229,13 +8358,11 @@ function applyPersistedOrder(entries) {
|
|
|
8229
8358
|
function setSectionRemoved(instanceId, currentPath, existingEntries, removed) {
|
|
8230
8359
|
if (!findByInstanceId(instanceId)) return null;
|
|
8231
8360
|
const byId = new Map(existingEntries.map((e) => [e.instanceId, e]));
|
|
8232
|
-
const allSections =
|
|
8233
|
-
(el) => !el.parentElement?.closest("[data-ohw-section]") && !isChromeSection(el)
|
|
8234
|
-
);
|
|
8361
|
+
const allSections = collectTopLevelUnits((el) => !isChromeSection(el));
|
|
8235
8362
|
allSections.forEach((el, order) => {
|
|
8236
8363
|
const id = instanceIdOf(el);
|
|
8237
8364
|
if (!byId.has(id)) {
|
|
8238
|
-
byId.set(id, { instanceId: id, type: el
|
|
8365
|
+
byId.set(id, { instanceId: id, type: sectionTypeOf(el), order, pagePath: currentPath });
|
|
8239
8366
|
}
|
|
8240
8367
|
});
|
|
8241
8368
|
const target = byId.get(instanceId);
|
|
@@ -8263,7 +8390,7 @@ function duplicateSectionInstance(instanceId, newId, currentPath, existingEntrie
|
|
|
8263
8390
|
const id = instanceIdOf(el);
|
|
8264
8391
|
return {
|
|
8265
8392
|
instanceId: id,
|
|
8266
|
-
type: el
|
|
8393
|
+
type: sectionTypeOf(el),
|
|
8267
8394
|
order,
|
|
8268
8395
|
pagePath: currentPath,
|
|
8269
8396
|
...byId.get(id)?.removed ? { removed: true } : {}
|
|
@@ -8305,6 +8432,10 @@ function initSectionInstancesFromContent(content, currentPath) {
|
|
|
8305
8432
|
document.querySelectorAll("[data-ohw-section]:not([data-ohw-instance])").forEach((el) => {
|
|
8306
8433
|
el.setAttribute("data-ohw-instance", el.getAttribute("data-ohw-section") ?? "");
|
|
8307
8434
|
});
|
|
8435
|
+
document.querySelectorAll("[data-ohw-section-container]:not([data-ohw-instance])").forEach((el) => {
|
|
8436
|
+
const type = sectionTypeOf(el);
|
|
8437
|
+
if (type) el.setAttribute("data-ohw-instance", type);
|
|
8438
|
+
});
|
|
8308
8439
|
const entries = getPageSectionOrderEntries(content[SECTION_ORDER_KEY], currentPath);
|
|
8309
8440
|
for (const entry of entries) {
|
|
8310
8441
|
if (entry.instanceId === entry.type) continue;
|
|
@@ -8323,10 +8454,7 @@ function initSectionInstancesFromContent(content, currentPath) {
|
|
|
8323
8454
|
|
|
8324
8455
|
// src/ui/ai-section/AiSectionOverlay.tsx
|
|
8325
8456
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
8326
|
-
|
|
8327
|
-
const escaped = CSS.escape(instanceId);
|
|
8328
|
-
return document.querySelector(`[data-ohw-instance="${escaped}"]`) ?? document.querySelector(`[data-ohw-section="${escaped}"]:not([data-ohw-instance])`);
|
|
8329
|
-
}
|
|
8457
|
+
var findSectionElement = findByInstanceId;
|
|
8330
8458
|
function readRect(instanceId) {
|
|
8331
8459
|
const el = findSectionElement(instanceId);
|
|
8332
8460
|
if (!el) return null;
|
|
@@ -8366,7 +8494,7 @@ function useLiveSectionRect(sectionId) {
|
|
|
8366
8494
|
}
|
|
8367
8495
|
function computeSectionBoundaryFlags(instanceId) {
|
|
8368
8496
|
const topLevel = topLevelSections();
|
|
8369
|
-
const index = topLevel.findIndex((el) => (el
|
|
8497
|
+
const index = topLevel.findIndex((el) => instanceIdOf(el) === instanceId);
|
|
8370
8498
|
if (index === -1) return { isFirst: true, isLast: true };
|
|
8371
8499
|
return { isFirst: index === 0, isLast: index === topLevel.length - 1 };
|
|
8372
8500
|
}
|
|
@@ -8450,18 +8578,20 @@ function AiSectionOverlay({
|
|
|
8450
8578
|
selectedIdRef.current = selectedId;
|
|
8451
8579
|
const report = (0, import_react8.useCallback)(
|
|
8452
8580
|
(el) => {
|
|
8581
|
+
const labelSrc = el ? sectionElementOf(el) : null;
|
|
8453
8582
|
postToParent2({
|
|
8454
8583
|
type: "ow:section-selected",
|
|
8455
|
-
sectionId: el ? el
|
|
8456
|
-
sectionLabel:
|
|
8584
|
+
sectionId: el ? instanceIdOf(el) || null : null,
|
|
8585
|
+
sectionLabel: labelSrc ? labelSrc.dataset.ohwSectionLabel ?? titleCaseSectionId(labelSrc.dataset.ohwSection ?? "") : null
|
|
8457
8586
|
});
|
|
8458
8587
|
},
|
|
8459
8588
|
[postToParent2]
|
|
8460
8589
|
);
|
|
8461
8590
|
const selectFromElement = (0, import_react8.useCallback)(
|
|
8462
8591
|
(el, options) => {
|
|
8463
|
-
const
|
|
8464
|
-
const
|
|
8592
|
+
const inner = el?.closest("[data-ohw-section]") ?? null;
|
|
8593
|
+
const sectionEl = inner ? movableUnit(inner) : null;
|
|
8594
|
+
const id = sectionEl ? instanceIdOf(sectionEl) || null : null;
|
|
8465
8595
|
if (id === selectedIdRef.current) return;
|
|
8466
8596
|
setSelectedId(id);
|
|
8467
8597
|
if (options?.report !== false) report(sectionEl);
|
|
@@ -8527,7 +8657,8 @@ function AiSectionOverlay({
|
|
|
8527
8657
|
return;
|
|
8528
8658
|
}
|
|
8529
8659
|
const sec = t.closest("[data-ohw-section]");
|
|
8530
|
-
|
|
8660
|
+
const unit = sec ? movableUnit(sec) : null;
|
|
8661
|
+
setHoveredId(unit ? instanceIdOf(unit) || null : null);
|
|
8531
8662
|
};
|
|
8532
8663
|
const onLeave = () => setHoveredId(null);
|
|
8533
8664
|
document.addEventListener("mousemove", onMove, { passive: true });
|
|
@@ -14145,8 +14276,9 @@ function useSectionDrag({
|
|
|
14145
14276
|
const target = e.target;
|
|
14146
14277
|
if (!(target instanceof HTMLElement)) return;
|
|
14147
14278
|
if (target.closest(SECTION_DRAG_EXCLUDED_SELECTOR)) return;
|
|
14148
|
-
const
|
|
14149
|
-
if (!
|
|
14279
|
+
const inner = target.closest("[data-ohw-section]");
|
|
14280
|
+
if (!inner || isChromeSection(inner) || inner.dataset.ohwSection === "footer") return;
|
|
14281
|
+
const sectionEl = movableUnit(inner);
|
|
14150
14282
|
if (!topLevelSections().includes(sectionEl)) return;
|
|
14151
14283
|
startSectionPressDrag(sectionEl, e.clientX, e.clientY, e.pointerId);
|
|
14152
14284
|
};
|
|
@@ -15053,7 +15185,6 @@ function mountSchedulingWidget(insertAfter, notifyOnConnect = false, scheduleId,
|
|
|
15053
15185
|
if (!mountPoint) return false;
|
|
15054
15186
|
const container = document.createElement("div");
|
|
15055
15187
|
container.dataset.ohwSectionContainer = "scheduling";
|
|
15056
|
-
container.dataset.ohwSection = sectionId;
|
|
15057
15188
|
container.dataset.ohwInstance = sectionId;
|
|
15058
15189
|
if (insertBefore) {
|
|
15059
15190
|
const beforeAnchor = document.querySelector(`[data-ohw-section="${insertBefore}"]`);
|
|
@@ -18210,10 +18341,10 @@ function OhhwellsBridge() {
|
|
|
18210
18341
|
const applyFromCache = () => {
|
|
18211
18342
|
const content = contentCache.get(subdomain);
|
|
18212
18343
|
if (!content) return;
|
|
18213
|
-
retryMissingSchedulingMounts(getPageSchedulingEntries(content["__ohw_sections"]), false);
|
|
18214
|
-
initSectionInstancesFromContent(content, window.location.pathname);
|
|
18215
18344
|
observer?.disconnect();
|
|
18216
18345
|
try {
|
|
18346
|
+
retryMissingSchedulingMounts(getPageSchedulingEntries(content["__ohw_sections"]), false);
|
|
18347
|
+
initSectionInstancesFromContent(content, window.location.pathname);
|
|
18217
18348
|
applyBrandChrome(content);
|
|
18218
18349
|
if (typeof content[BRAND_KIT_KEY] === "string") {
|
|
18219
18350
|
applyBrandToDom(parseBrandKit(content[BRAND_KIT_KEY]));
|
|
@@ -18304,6 +18435,10 @@ function OhhwellsBridge() {
|
|
|
18304
18435
|
deselectRef.current();
|
|
18305
18436
|
deactivateRef.current();
|
|
18306
18437
|
}, [pathname, isEditMode]);
|
|
18438
|
+
(0, import_react17.useEffect)(() => {
|
|
18439
|
+
if (!isEditMode) return;
|
|
18440
|
+
initSectionInstancesFromContent(editContentRef.current, pathname);
|
|
18441
|
+
}, [pathname, isEditMode]);
|
|
18307
18442
|
(0, import_react17.useEffect)(() => {
|
|
18308
18443
|
const contentForNav = () => {
|
|
18309
18444
|
if (isEditMode) return editContentRef.current;
|
|
@@ -20324,12 +20459,35 @@ function OhhwellsBridge() {
|
|
|
20324
20459
|
window.addEventListener("message", handleAiSetBrand);
|
|
20325
20460
|
const handleAiSetStyles = (e) => {
|
|
20326
20461
|
if (e.data?.type !== "ow:ai-set-styles") return;
|
|
20327
|
-
|
|
20462
|
+
let value = typeof e.data.value === "string" ? e.data.value : "";
|
|
20328
20463
|
const previous = stylesRef.current;
|
|
20464
|
+
let previousSections;
|
|
20465
|
+
const store = parseStyleStore(value);
|
|
20466
|
+
if (store) {
|
|
20467
|
+
const folded = foldAlignIntoTrees(parseAiSectionsState(aiSectionsRef.current), store);
|
|
20468
|
+
if (folded.changed) {
|
|
20469
|
+
const nextSections = serializeAiSectionsState(folded.state);
|
|
20470
|
+
if (nextSections !== aiSectionsRef.current) {
|
|
20471
|
+
previousSections = aiSectionsRef.current;
|
|
20472
|
+
aiSectionsRef.current = nextSections;
|
|
20473
|
+
applyAiSectionsToDom(folded.state);
|
|
20474
|
+
postToParentRef.current({
|
|
20475
|
+
type: "ow:change",
|
|
20476
|
+
nodes: [{ key: AI_SECTIONS_KEY, text: nextSections }]
|
|
20477
|
+
});
|
|
20478
|
+
}
|
|
20479
|
+
value = JSON.stringify(folded.store);
|
|
20480
|
+
}
|
|
20481
|
+
}
|
|
20329
20482
|
stylesRef.current = value;
|
|
20330
20483
|
applyStylesToDom(parseStyleStore(value));
|
|
20331
20484
|
postToParentRef.current({ type: "ow:change", nodes: [{ key: STYLE_STORE_KEY, text: value }] });
|
|
20332
|
-
postToParentRef.current({
|
|
20485
|
+
postToParentRef.current({
|
|
20486
|
+
type: "ow:ai-styles-applied",
|
|
20487
|
+
previous,
|
|
20488
|
+
value,
|
|
20489
|
+
...previousSections !== void 0 ? { previousSections } : {}
|
|
20490
|
+
});
|
|
20333
20491
|
};
|
|
20334
20492
|
window.addEventListener("message", handleAiSetStyles);
|
|
20335
20493
|
const handleGetBrand = (e) => {
|
|
@@ -21350,7 +21508,7 @@ function OhhwellsBridge() {
|
|
|
21350
21508
|
postToParent2({
|
|
21351
21509
|
type: "ow:ready",
|
|
21352
21510
|
version: "1",
|
|
21353
|
-
bridgeVersion: "0.1.
|
|
21511
|
+
bridgeVersion: "0.1.92",
|
|
21354
21512
|
path: pathname,
|
|
21355
21513
|
nodes: collectEditableNodes(editContentRef.current),
|
|
21356
21514
|
sections
|