@ohhwells/bridge 0.1.139-next.393 → 0.1.139-next.395
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 +91 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +90 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -87,6 +87,7 @@ __export(index_exports, {
|
|
|
87
87
|
resolveFooterCopyright: () => resolveFooterCopyright,
|
|
88
88
|
serializeAiFooterState: () => serializeAiFooterState,
|
|
89
89
|
stepViableSlide: () => stepViableSlide,
|
|
90
|
+
stripTextAlignCss: () => stripTextAlignCss,
|
|
90
91
|
toggleVariants: () => toggleVariants,
|
|
91
92
|
useOhwCarousel: () => useOhwCarousel,
|
|
92
93
|
validateUrlInput: () => validateUrlInput,
|
|
@@ -6266,6 +6267,26 @@ function applyTreeToState(state, payload) {
|
|
|
6266
6267
|
const others = state.sections.filter((existing) => existing.id !== entry.id);
|
|
6267
6268
|
return { ...state, v: 1, sections: [...others, entry] };
|
|
6268
6269
|
}
|
|
6270
|
+
function stripTextAlignCss(html) {
|
|
6271
|
+
return html.replace(/\sstyle="([^"]*)"/gi, (whole, value) => {
|
|
6272
|
+
if (!/text-align\s*:/i.test(value)) return whole;
|
|
6273
|
+
const kept = value.split(";").map((decl) => decl.trim()).filter((decl) => decl && !/^text-align\s*:/i.test(decl)).join("; ");
|
|
6274
|
+
return kept ? ` style="${kept}"` : "";
|
|
6275
|
+
});
|
|
6276
|
+
}
|
|
6277
|
+
function stripTextAlignInValue(value) {
|
|
6278
|
+
if (typeof value === "string") return stripTextAlignCss(value);
|
|
6279
|
+
if (Array.isArray(value)) return value.map(stripTextAlignInValue);
|
|
6280
|
+
if (value && typeof value === "object") {
|
|
6281
|
+
return Object.fromEntries(
|
|
6282
|
+
Object.entries(value).map(([key, inner]) => [
|
|
6283
|
+
key,
|
|
6284
|
+
stripTextAlignInValue(inner)
|
|
6285
|
+
])
|
|
6286
|
+
);
|
|
6287
|
+
}
|
|
6288
|
+
return value;
|
|
6289
|
+
}
|
|
6269
6290
|
function foldAlignIntoTrees(state, store) {
|
|
6270
6291
|
const byId = new Map(state.sections.map((entry) => [entry.id, entry]));
|
|
6271
6292
|
const nextTrees = /* @__PURE__ */ new Map();
|
|
@@ -6288,6 +6309,12 @@ function foldAlignIntoTrees(state, store) {
|
|
|
6288
6309
|
return stripChildAligns(rest);
|
|
6289
6310
|
})
|
|
6290
6311
|
} : node;
|
|
6312
|
+
const stripContentAligns = (node) => ({
|
|
6313
|
+
...node,
|
|
6314
|
+
...node.slots ? { slots: stripTextAlignInValue(node.slots) } : {},
|
|
6315
|
+
...node.children ? { children: node.children.map(stripContentAligns) } : {}
|
|
6316
|
+
});
|
|
6317
|
+
const authoritative = (block) => stripChildAligns(stripContentAligns(block));
|
|
6291
6318
|
const nodes = {};
|
|
6292
6319
|
for (const [key, override] of Object.entries(store.nodes)) {
|
|
6293
6320
|
const match = override.align !== void 0 && key.startsWith(AI_SLOT_KEY_PREFIX) ? key.match(/^ai\.(.+?)\.r(\d+)\.b(\d+)(?:\.|$)/) : null;
|
|
@@ -6299,7 +6326,7 @@ function foldAlignIntoTrees(state, store) {
|
|
|
6299
6326
|
nodes[key] = override;
|
|
6300
6327
|
continue;
|
|
6301
6328
|
}
|
|
6302
|
-
row.blocks[blockIdx] = { ...
|
|
6329
|
+
row.blocks[blockIdx] = { ...authoritative(block), align: override.align };
|
|
6303
6330
|
const rest = { ...override };
|
|
6304
6331
|
delete rest.align;
|
|
6305
6332
|
if (Object.keys(rest).length > 0) nodes[key] = rest;
|
|
@@ -6312,7 +6339,7 @@ function foldAlignIntoTrees(state, store) {
|
|
|
6312
6339
|
continue;
|
|
6313
6340
|
}
|
|
6314
6341
|
for (const row of tree.rows) {
|
|
6315
|
-
row.blocks = row.blocks.map((block) => ({ ...
|
|
6342
|
+
row.blocks = row.blocks.map((block) => ({ ...authoritative(block), align: override.align }));
|
|
6316
6343
|
}
|
|
6317
6344
|
const rest = { ...override };
|
|
6318
6345
|
delete rest.align;
|
|
@@ -30297,14 +30324,73 @@ function OhhwellsBridge() {
|
|
|
30297
30324
|
value = JSON.stringify(foldedHeight.store);
|
|
30298
30325
|
}
|
|
30299
30326
|
}
|
|
30327
|
+
const restoreNodes = e.data.restoreNodes;
|
|
30328
|
+
const restored = [];
|
|
30329
|
+
if (restoreNodes && typeof restoreNodes === "object") {
|
|
30330
|
+
for (const [key, html] of Object.entries(restoreNodes)) {
|
|
30331
|
+
if (typeof html !== "string") continue;
|
|
30332
|
+
const els = document.querySelectorAll(`[data-ohw-key="${CSS.escape(key)}"]`);
|
|
30333
|
+
if (els.length === 0) continue;
|
|
30334
|
+
for (const el of Array.from(els)) el.innerHTML = html;
|
|
30335
|
+
editContentRef.current = { ...editContentRef.current, [key]: html };
|
|
30336
|
+
restored.push({ key, text: html });
|
|
30337
|
+
}
|
|
30338
|
+
}
|
|
30339
|
+
const previousNodes = {};
|
|
30340
|
+
const strippedNodes = [];
|
|
30341
|
+
if (!restoreNodes) {
|
|
30342
|
+
const aligned = parseStyleStore(value);
|
|
30343
|
+
const prior = parseStyleStore(previous);
|
|
30344
|
+
const keys = /* @__PURE__ */ new Set();
|
|
30345
|
+
if (aligned) {
|
|
30346
|
+
for (const [key, override] of Object.entries(aligned.nodes)) {
|
|
30347
|
+
if (override.align === void 0) continue;
|
|
30348
|
+
if (prior?.nodes[key]?.align === override.align) continue;
|
|
30349
|
+
keys.add(key);
|
|
30350
|
+
}
|
|
30351
|
+
for (const [sectionId, override] of Object.entries(aligned.sections)) {
|
|
30352
|
+
if (override.align === void 0) continue;
|
|
30353
|
+
if (prior?.sections[sectionId]?.align === override.align) continue;
|
|
30354
|
+
const escaped = CSS.escape(sectionId);
|
|
30355
|
+
const markers = document.querySelectorAll(
|
|
30356
|
+
`[data-ohw-instance="${escaped}"], [data-ohw-section="${escaped}"]`
|
|
30357
|
+
);
|
|
30358
|
+
for (const marker of Array.from(markers)) {
|
|
30359
|
+
const editables = marker.querySelectorAll(
|
|
30360
|
+
'[data-ohw-key][data-ohw-editable="text"], [data-ohw-key][data-ohw-editable="plain"]'
|
|
30361
|
+
);
|
|
30362
|
+
for (const el of Array.from(editables)) {
|
|
30363
|
+
const key = el.getAttribute("data-ohw-key");
|
|
30364
|
+
if (key) keys.add(key);
|
|
30365
|
+
}
|
|
30366
|
+
}
|
|
30367
|
+
}
|
|
30368
|
+
}
|
|
30369
|
+
for (const key of keys) {
|
|
30370
|
+
if (key.startsWith(AI_SLOT_KEY_PREFIX) || key.startsWith("__ohw_")) continue;
|
|
30371
|
+
const els = document.querySelectorAll(`[data-ohw-key="${CSS.escape(key)}"]`);
|
|
30372
|
+
if (els.length === 0) continue;
|
|
30373
|
+
const before = sanitizeHtml(els[0].innerHTML);
|
|
30374
|
+
const after = stripTextAlignCss(before);
|
|
30375
|
+
if (after === before) continue;
|
|
30376
|
+
for (const el of Array.from(els)) el.innerHTML = after;
|
|
30377
|
+
previousNodes[key] = before;
|
|
30378
|
+
editContentRef.current = { ...editContentRef.current, [key]: after };
|
|
30379
|
+
strippedNodes.push({ key, text: after });
|
|
30380
|
+
}
|
|
30381
|
+
}
|
|
30300
30382
|
stylesRef.current = value;
|
|
30301
30383
|
applyStylesToDom(parseStyleStore(value));
|
|
30302
|
-
postToParentRef.current({
|
|
30384
|
+
postToParentRef.current({
|
|
30385
|
+
type: "ow:change",
|
|
30386
|
+
nodes: [{ key: STYLE_STORE_KEY, text: value }, ...strippedNodes, ...restored]
|
|
30387
|
+
});
|
|
30303
30388
|
postToParentRef.current({
|
|
30304
30389
|
type: "ow:ai-styles-applied",
|
|
30305
30390
|
previous,
|
|
30306
30391
|
value,
|
|
30307
|
-
...previousSections !== void 0 ? { previousSections } : {}
|
|
30392
|
+
...previousSections !== void 0 ? { previousSections } : {},
|
|
30393
|
+
...Object.keys(previousNodes).length > 0 ? { previousNodes } : {}
|
|
30308
30394
|
});
|
|
30309
30395
|
};
|
|
30310
30396
|
window.addEventListener("message", handleAiSetStyles);
|
|
@@ -32886,6 +32972,7 @@ function EmptySection({ title, homeHref = "/", eyebrowKey, titleKey, subtitleKey
|
|
|
32886
32972
|
resolveFooterCopyright,
|
|
32887
32973
|
serializeAiFooterState,
|
|
32888
32974
|
stepViableSlide,
|
|
32975
|
+
stripTextAlignCss,
|
|
32889
32976
|
toggleVariants,
|
|
32890
32977
|
useOhwCarousel,
|
|
32891
32978
|
validateUrlInput,
|