@ohhwells/bridge 0.1.179-next.479 → 0.1.179-next.481
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 +53 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +52 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -124,6 +124,7 @@ __export(index_exports, {
|
|
|
124
124
|
isStickySearchParam: () => isStickySearchParam,
|
|
125
125
|
isValidUrl: () => isValidUrl,
|
|
126
126
|
layoutPreviewBackground: () => layoutPreviewBackground,
|
|
127
|
+
layoutPreviewBackgroundOf: () => layoutPreviewBackgroundOf,
|
|
127
128
|
linearGradientColourAt: () => linearGradientColourAt,
|
|
128
129
|
logoVersionNodesFromMessage: () => logoVersionNodesFromMessage,
|
|
129
130
|
mapRegionToImage: () => mapRegionToImage,
|
|
@@ -13522,6 +13523,15 @@ function layoutPreviewBackground(backgroundColor, backgroundImage) {
|
|
|
13522
13523
|
if (!color || TRANSPARENT2.test(color)) return "#ffffff";
|
|
13523
13524
|
return color;
|
|
13524
13525
|
}
|
|
13526
|
+
function layoutPreviewBackgroundOf(layers) {
|
|
13527
|
+
for (const { backgroundColor, backgroundImage } of layers) {
|
|
13528
|
+
const image = backgroundImage?.trim();
|
|
13529
|
+
if (image && image !== "none") return "#ffffff";
|
|
13530
|
+
const color = backgroundColor?.trim();
|
|
13531
|
+
if (color && !TRANSPARENT2.test(color)) return color;
|
|
13532
|
+
}
|
|
13533
|
+
return "#ffffff";
|
|
13534
|
+
}
|
|
13525
13535
|
function isLayoutPreviewRequest(value) {
|
|
13526
13536
|
if (!value || typeof value !== "object") return false;
|
|
13527
13537
|
const v = value;
|
|
@@ -13575,15 +13585,15 @@ async function settle(host) {
|
|
|
13575
13585
|
wait(SETTLE_CAP_MS)
|
|
13576
13586
|
]);
|
|
13577
13587
|
}
|
|
13578
|
-
function backgroundOf(host) {
|
|
13588
|
+
function backgroundOf(host, parent) {
|
|
13589
|
+
const layers = [];
|
|
13579
13590
|
let el = host.firstElementChild;
|
|
13580
13591
|
for (let depth = 0; el && depth < 3; depth++) {
|
|
13581
|
-
|
|
13582
|
-
const bg = layoutPreviewBackground(cs.backgroundColor, cs.backgroundImage);
|
|
13583
|
-
if (bg !== "#ffffff" || cs.backgroundImage && cs.backgroundImage !== "none") return bg;
|
|
13592
|
+
layers.push(getComputedStyle(el));
|
|
13584
13593
|
el = el.firstElementChild;
|
|
13585
13594
|
}
|
|
13586
|
-
|
|
13595
|
+
for (let up = parent; up; up = up.parentElement) layers.push(getComputedStyle(up));
|
|
13596
|
+
return layoutPreviewBackgroundOf(layers);
|
|
13587
13597
|
}
|
|
13588
13598
|
async function renderOne(layout, req, anchor, width) {
|
|
13589
13599
|
const empty = { id: layout.id, doc: "", width, height: 0, bg: "#ffffff" };
|
|
@@ -13614,7 +13624,7 @@ async function renderOne(layout, req, anchor, width) {
|
|
|
13614
13624
|
const rect = host.getBoundingClientRect();
|
|
13615
13625
|
const height = Math.max(1, Math.round(Math.max(rect.height, host.scrollHeight)));
|
|
13616
13626
|
const doc = buildLayoutPreviewDoc(host.innerHTML, readPageContext(parent), width);
|
|
13617
|
-
return { id: layout.id, doc, width, height, bg: backgroundOf(host) };
|
|
13627
|
+
return { id: layout.id, doc, width, height, bg: backgroundOf(host, parent) };
|
|
13618
13628
|
} catch {
|
|
13619
13629
|
return empty;
|
|
13620
13630
|
} finally {
|
|
@@ -20395,6 +20405,7 @@ function insertField(form, type) {
|
|
|
20395
20405
|
wrapper.setAttribute(FIELD_ATTR, key);
|
|
20396
20406
|
wrapper.setAttribute(FIELD_TYPE_ATTR, type);
|
|
20397
20407
|
wrapper.removeAttribute(DROPDOWN_OPEN_ATTR);
|
|
20408
|
+
wrapper.removeAttribute("data-half");
|
|
20398
20409
|
applyFieldType(wrapper, type);
|
|
20399
20410
|
const defaults = FIELD_DEFAULTS[type];
|
|
20400
20411
|
const input = fieldControlOf(wrapper);
|
|
@@ -20418,6 +20429,7 @@ function duplicateField(form, wrapper) {
|
|
|
20418
20429
|
const key = uniqueKey(form, `${fieldKeyOf(wrapper)}-copy`);
|
|
20419
20430
|
copy.setAttribute(FIELD_ATTR, key);
|
|
20420
20431
|
copy.removeAttribute(DROPDOWN_OPEN_ATTR);
|
|
20432
|
+
copy.removeAttribute("data-half");
|
|
20421
20433
|
clearDropdownOptionSelection(copy);
|
|
20422
20434
|
const input = fieldControlOf(copy);
|
|
20423
20435
|
if (input) {
|
|
@@ -20699,7 +20711,7 @@ function apiBase() {
|
|
|
20699
20711
|
function bridgeVersion() {
|
|
20700
20712
|
try {
|
|
20701
20713
|
if (true) {
|
|
20702
|
-
return "0.1.179-next.
|
|
20714
|
+
return "0.1.179-next.481";
|
|
20703
20715
|
}
|
|
20704
20716
|
} catch {
|
|
20705
20717
|
}
|
|
@@ -20713,7 +20725,7 @@ function stampBridgeVersionOnDocument() {
|
|
|
20713
20725
|
return;
|
|
20714
20726
|
}
|
|
20715
20727
|
try {
|
|
20716
|
-
const v = true ? "0.1.179-next.
|
|
20728
|
+
const v = true ? "0.1.179-next.481" : "";
|
|
20717
20729
|
if (v) {
|
|
20718
20730
|
document.documentElement.setAttribute("data-ohw-bridge-version", v);
|
|
20719
20731
|
window.__OHW_BRIDGE_VERSION__ = v;
|
|
@@ -31734,11 +31746,38 @@ function OhhwellsBridge() {
|
|
|
31734
31746
|
}, [buildFieldDropSlots, isEditMode, persistFields, selectField]);
|
|
31735
31747
|
(0, import_react27.useEffect)(() => {
|
|
31736
31748
|
if (!isEditMode) return;
|
|
31737
|
-
|
|
31738
|
-
|
|
31749
|
+
let applying = false;
|
|
31750
|
+
const syncForms = () => {
|
|
31751
|
+
if (applying) return;
|
|
31752
|
+
applying = true;
|
|
31753
|
+
try {
|
|
31754
|
+
document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
|
|
31755
|
+
const key = formKeyOf(form);
|
|
31756
|
+
if (key && editContentRef.current[fieldsKey(key)]) {
|
|
31757
|
+
reconcileFieldsFromContent(form, editContentRef.current);
|
|
31758
|
+
} else {
|
|
31759
|
+
markFormFields(form);
|
|
31760
|
+
}
|
|
31761
|
+
});
|
|
31762
|
+
} finally {
|
|
31763
|
+
queueMicrotask(() => {
|
|
31764
|
+
applying = false;
|
|
31765
|
+
});
|
|
31766
|
+
}
|
|
31767
|
+
};
|
|
31768
|
+
syncForms();
|
|
31769
|
+
const observer = new MutationObserver((mutations) => {
|
|
31770
|
+
const structural = mutations.some(
|
|
31771
|
+
(m) => m.type === "childList" && (m.addedNodes.length > 0 || m.removedNodes.length > 0)
|
|
31772
|
+
);
|
|
31773
|
+
if (!structural) {
|
|
31774
|
+
document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
|
|
31775
|
+
markFormFields(form);
|
|
31776
|
+
});
|
|
31777
|
+
return;
|
|
31778
|
+
}
|
|
31779
|
+
syncForms();
|
|
31739
31780
|
});
|
|
31740
|
-
mark();
|
|
31741
|
-
const observer = new MutationObserver(() => mark());
|
|
31742
31781
|
document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
|
|
31743
31782
|
observer.observe(form, { childList: true, subtree: true, characterData: true });
|
|
31744
31783
|
});
|
|
@@ -36004,7 +36043,7 @@ function OhhwellsBridge() {
|
|
|
36004
36043
|
postToParent2({
|
|
36005
36044
|
type: "ow:ready",
|
|
36006
36045
|
version: "1",
|
|
36007
|
-
bridgeVersion: "0.1.179-next.
|
|
36046
|
+
bridgeVersion: "0.1.179-next.481",
|
|
36008
36047
|
path: pathname,
|
|
36009
36048
|
nodes: collectEditableNodes(editContentRef.current),
|
|
36010
36049
|
sections
|
|
@@ -37473,6 +37512,7 @@ function EmptySection({ title, homeHref = "/", eyebrowKey, titleKey, subtitleKey
|
|
|
37473
37512
|
isStickySearchParam,
|
|
37474
37513
|
isValidUrl,
|
|
37475
37514
|
layoutPreviewBackground,
|
|
37515
|
+
layoutPreviewBackgroundOf,
|
|
37476
37516
|
linearGradientColourAt,
|
|
37477
37517
|
logoVersionNodesFromMessage,
|
|
37478
37518
|
mapRegionToImage,
|