@ohhwells/bridge 0.1.70-next.212 → 0.1.70-next.215
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 +223 -108
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +223 -108
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7870,6 +7870,150 @@ function parseSectionsFromHtml(html) {
|
|
|
7870
7870
|
return parseSectionsFromRoot(doc);
|
|
7871
7871
|
}
|
|
7872
7872
|
|
|
7873
|
+
// src/lib/section-instances.ts
|
|
7874
|
+
var SECTION_ORDER_KEY = "__ohw_section_order";
|
|
7875
|
+
var REMOVED_ATTR2 = "data-ohw-section-removed";
|
|
7876
|
+
function isRemovedSection(el) {
|
|
7877
|
+
return el.hasAttribute(REMOVED_ATTR2);
|
|
7878
|
+
}
|
|
7879
|
+
function topLevelSections() {
|
|
7880
|
+
return Array.from(document.querySelectorAll("[data-ohw-section]")).filter(
|
|
7881
|
+
(el) => !el.parentElement?.closest("[data-ohw-section]") && !isChromeSection(el) && !isRemovedSection(el)
|
|
7882
|
+
);
|
|
7883
|
+
}
|
|
7884
|
+
function instanceIdOf(el) {
|
|
7885
|
+
return el.dataset.ohwInstance ?? el.dataset.ohwSection ?? "";
|
|
7886
|
+
}
|
|
7887
|
+
function planSectionMove(instanceId, targetIndex, currentPath) {
|
|
7888
|
+
const sections = topLevelSections();
|
|
7889
|
+
const index = sections.findIndex((el) => instanceIdOf(el) === instanceId);
|
|
7890
|
+
if (index === -1) return null;
|
|
7891
|
+
const dragged = sections[index];
|
|
7892
|
+
const others = sections.filter((_, i) => i !== index);
|
|
7893
|
+
const clamped = Math.max(0, Math.min(targetIndex, others.length));
|
|
7894
|
+
const reordered = [...others.slice(0, clamped), dragged, ...others.slice(clamped)];
|
|
7895
|
+
return reordered.map((el, order) => ({
|
|
7896
|
+
instanceId: instanceIdOf(el),
|
|
7897
|
+
type: el.getAttribute("data-ohw-section") ?? "",
|
|
7898
|
+
order,
|
|
7899
|
+
pagePath: currentPath
|
|
7900
|
+
}));
|
|
7901
|
+
}
|
|
7902
|
+
function moveSectionInstance(instanceId, direction, currentPath) {
|
|
7903
|
+
const sections = topLevelSections();
|
|
7904
|
+
const index = sections.findIndex((el) => instanceIdOf(el) === instanceId);
|
|
7905
|
+
if (index === -1) return null;
|
|
7906
|
+
const siblingIndex = direction === "up" ? index - 1 : index + 1;
|
|
7907
|
+
if (siblingIndex < 0 || siblingIndex >= sections.length) return null;
|
|
7908
|
+
const entries = planSectionMove(instanceId, siblingIndex, currentPath);
|
|
7909
|
+
if (!entries) return null;
|
|
7910
|
+
applyPersistedOrder(entries);
|
|
7911
|
+
return entries;
|
|
7912
|
+
}
|
|
7913
|
+
function syncRemovedFlags(entries) {
|
|
7914
|
+
const removedIds = new Set(entries.filter((e) => e.removed).map((e) => e.instanceId));
|
|
7915
|
+
document.querySelectorAll(`[${REMOVED_ATTR2}]`).forEach((el) => {
|
|
7916
|
+
if (!removedIds.has(instanceIdOf(el))) {
|
|
7917
|
+
el.style.removeProperty("display");
|
|
7918
|
+
el.removeAttribute(REMOVED_ATTR2);
|
|
7919
|
+
}
|
|
7920
|
+
});
|
|
7921
|
+
for (const id of removedIds) {
|
|
7922
|
+
const el = document.querySelector(`[data-ohw-instance="${CSS.escape(id)}"]`);
|
|
7923
|
+
if (el) {
|
|
7924
|
+
el.style.display = "none";
|
|
7925
|
+
el.setAttribute(REMOVED_ATTR2, "");
|
|
7926
|
+
}
|
|
7927
|
+
}
|
|
7928
|
+
}
|
|
7929
|
+
function applyPersistedOrder(entries) {
|
|
7930
|
+
syncRemovedFlags(entries);
|
|
7931
|
+
if (entries.length === 0) return;
|
|
7932
|
+
const sections = topLevelSections();
|
|
7933
|
+
if (sections.length === 0) return;
|
|
7934
|
+
const orderIndex = new Map(entries.map((e) => [e.instanceId, e.order]));
|
|
7935
|
+
const ordered = [...sections].sort((a, b) => {
|
|
7936
|
+
const aOrder = orderIndex.get(instanceIdOf(a));
|
|
7937
|
+
const bOrder = orderIndex.get(instanceIdOf(b));
|
|
7938
|
+
if (aOrder === void 0 && bOrder === void 0) return 0;
|
|
7939
|
+
if (aOrder === void 0) return 1;
|
|
7940
|
+
if (bOrder === void 0) return -1;
|
|
7941
|
+
return aOrder - bOrder;
|
|
7942
|
+
});
|
|
7943
|
+
let prev = null;
|
|
7944
|
+
for (const el of ordered) {
|
|
7945
|
+
if (prev) prev.after(el);
|
|
7946
|
+
prev = el;
|
|
7947
|
+
}
|
|
7948
|
+
}
|
|
7949
|
+
function setSectionRemoved(instanceId, currentPath, existingEntries, removed) {
|
|
7950
|
+
if (!document.querySelector(`[data-ohw-instance="${CSS.escape(instanceId)}"]`)) return null;
|
|
7951
|
+
const byId = new Map(existingEntries.map((e) => [e.instanceId, e]));
|
|
7952
|
+
const allSections = Array.from(document.querySelectorAll("[data-ohw-section]")).filter(
|
|
7953
|
+
(el) => !el.parentElement?.closest("[data-ohw-section]") && !isChromeSection(el)
|
|
7954
|
+
);
|
|
7955
|
+
allSections.forEach((el, order) => {
|
|
7956
|
+
const id = instanceIdOf(el);
|
|
7957
|
+
if (!byId.has(id)) {
|
|
7958
|
+
byId.set(id, { instanceId: id, type: el.getAttribute("data-ohw-section") ?? "", order, pagePath: currentPath });
|
|
7959
|
+
}
|
|
7960
|
+
});
|
|
7961
|
+
const target = byId.get(instanceId);
|
|
7962
|
+
if (!target) return null;
|
|
7963
|
+
byId.set(instanceId, { ...target, removed });
|
|
7964
|
+
const entries = Array.from(byId.values());
|
|
7965
|
+
applyPersistedOrder(entries);
|
|
7966
|
+
return entries;
|
|
7967
|
+
}
|
|
7968
|
+
function deleteSectionInstance(instanceId, currentPath, existingEntries) {
|
|
7969
|
+
return setSectionRemoved(instanceId, currentPath, existingEntries, true);
|
|
7970
|
+
}
|
|
7971
|
+
function restoreSectionInstance(instanceId, currentPath, existingEntries) {
|
|
7972
|
+
return setSectionRemoved(instanceId, currentPath, existingEntries, false);
|
|
7973
|
+
}
|
|
7974
|
+
function newInstanceId() {
|
|
7975
|
+
return typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `instance-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
7976
|
+
}
|
|
7977
|
+
function getPageSectionOrderEntries(raw, currentPath) {
|
|
7978
|
+
if (!raw) return [];
|
|
7979
|
+
try {
|
|
7980
|
+
const entries = JSON.parse(raw);
|
|
7981
|
+
return entries.filter((e) => !e.pagePath || e.pagePath === currentPath);
|
|
7982
|
+
} catch {
|
|
7983
|
+
return [];
|
|
7984
|
+
}
|
|
7985
|
+
}
|
|
7986
|
+
function rekeySectionSubtree(root, instanceId) {
|
|
7987
|
+
const suffix = `::${instanceId}`;
|
|
7988
|
+
const rekey = (el, attr) => {
|
|
7989
|
+
const current = el.getAttribute(attr);
|
|
7990
|
+
if (current) el.setAttribute(attr, `${current}${suffix}`);
|
|
7991
|
+
};
|
|
7992
|
+
if (root.hasAttribute("data-ohw-key")) rekey(root, "data-ohw-key");
|
|
7993
|
+
if (root.hasAttribute("data-ohw-href-key")) rekey(root, "data-ohw-href-key");
|
|
7994
|
+
root.querySelectorAll("[data-ohw-key]").forEach((el) => rekey(el, "data-ohw-key"));
|
|
7995
|
+
root.querySelectorAll("[data-ohw-href-key]").forEach((el) => rekey(el, "data-ohw-href-key"));
|
|
7996
|
+
}
|
|
7997
|
+
function initSectionInstancesFromContent(content, currentPath) {
|
|
7998
|
+
document.querySelectorAll("[data-ohw-section]:not([data-ohw-instance])").forEach((el) => {
|
|
7999
|
+
el.setAttribute("data-ohw-instance", el.getAttribute("data-ohw-section") ?? "");
|
|
8000
|
+
});
|
|
8001
|
+
const entries = getPageSectionOrderEntries(content[SECTION_ORDER_KEY], currentPath);
|
|
8002
|
+
for (const entry of entries) {
|
|
8003
|
+
if (entry.instanceId === entry.type) continue;
|
|
8004
|
+
if (document.querySelector(`[data-ohw-instance="${CSS.escape(entry.instanceId)}"]`)) continue;
|
|
8005
|
+
const original = document.querySelector(
|
|
8006
|
+
`[data-ohw-section="${CSS.escape(entry.type)}"][data-ohw-instance="${CSS.escape(entry.type)}"]`
|
|
8007
|
+
);
|
|
8008
|
+
if (!original) continue;
|
|
8009
|
+
const clone = original.cloneNode(true);
|
|
8010
|
+
clone.setAttribute("data-ohw-instance", entry.instanceId);
|
|
8011
|
+
rekeySectionSubtree(clone, entry.instanceId);
|
|
8012
|
+
original.insertAdjacentElement("afterend", clone);
|
|
8013
|
+
}
|
|
8014
|
+
applyPersistedOrder(entries);
|
|
8015
|
+
}
|
|
8016
|
+
|
|
7873
8017
|
// src/ui/ai-section/AiSectionOverlay.tsx
|
|
7874
8018
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
7875
8019
|
function findSectionElement(instanceId) {
|
|
@@ -7914,9 +8058,7 @@ function useLiveSectionRect(sectionId) {
|
|
|
7914
8058
|
return rect;
|
|
7915
8059
|
}
|
|
7916
8060
|
function computeSectionBoundaryFlags(instanceId) {
|
|
7917
|
-
const topLevel =
|
|
7918
|
-
(el) => !el.parentElement?.closest("[data-ohw-section]") && !isChromeSection(el)
|
|
7919
|
-
);
|
|
8061
|
+
const topLevel = topLevelSections();
|
|
7920
8062
|
const index = topLevel.findIndex((el) => (el.dataset.ohwInstance ?? el.dataset.ohwSection) === instanceId);
|
|
7921
8063
|
if (index === -1) return { isFirst: true, isLast: true };
|
|
7922
8064
|
return { isFirst: index === 0, isLast: index === topLevel.length - 1 };
|
|
@@ -8033,12 +8175,15 @@ function AiSectionOverlay({
|
|
|
8033
8175
|
selectFromElement(sectionEl);
|
|
8034
8176
|
return sectionEl != null;
|
|
8035
8177
|
},
|
|
8036
|
-
clear: () =>
|
|
8178
|
+
clear: () => {
|
|
8179
|
+
setSelectedId(null);
|
|
8180
|
+
report(null);
|
|
8181
|
+
}
|
|
8037
8182
|
};
|
|
8038
8183
|
return () => {
|
|
8039
8184
|
apiRef.current = null;
|
|
8040
8185
|
};
|
|
8041
|
-
}, [apiRef, selectFromElement]);
|
|
8186
|
+
}, [apiRef, selectFromElement, report]);
|
|
8042
8187
|
(0, import_react8.useEffect)(() => {
|
|
8043
8188
|
const onMessage = (e) => {
|
|
8044
8189
|
if (e.data?.type === "ow:ai-select" && e.data.sectionId === null) {
|
|
@@ -8213,101 +8358,6 @@ function AiSectionOverlay({
|
|
|
8213
8358
|
] });
|
|
8214
8359
|
}
|
|
8215
8360
|
|
|
8216
|
-
// src/lib/section-instances.ts
|
|
8217
|
-
var SECTION_ORDER_KEY = "__ohw_section_order";
|
|
8218
|
-
function topLevelSections() {
|
|
8219
|
-
return Array.from(document.querySelectorAll("[data-ohw-section]")).filter(
|
|
8220
|
-
(el) => !el.parentElement?.closest("[data-ohw-section]") && !isChromeSection(el)
|
|
8221
|
-
);
|
|
8222
|
-
}
|
|
8223
|
-
function instanceIdOf(el) {
|
|
8224
|
-
return el.dataset.ohwInstance ?? el.dataset.ohwSection ?? "";
|
|
8225
|
-
}
|
|
8226
|
-
function planSectionMove(instanceId, targetIndex, currentPath) {
|
|
8227
|
-
const sections = topLevelSections();
|
|
8228
|
-
const index = sections.findIndex((el) => instanceIdOf(el) === instanceId);
|
|
8229
|
-
if (index === -1) return null;
|
|
8230
|
-
const dragged = sections[index];
|
|
8231
|
-
const others = sections.filter((_, i) => i !== index);
|
|
8232
|
-
const clamped = Math.max(0, Math.min(targetIndex, others.length));
|
|
8233
|
-
const reordered = [...others.slice(0, clamped), dragged, ...others.slice(clamped)];
|
|
8234
|
-
return reordered.map((el, order) => ({
|
|
8235
|
-
instanceId: instanceIdOf(el),
|
|
8236
|
-
type: el.getAttribute("data-ohw-section") ?? "",
|
|
8237
|
-
order,
|
|
8238
|
-
pagePath: currentPath
|
|
8239
|
-
}));
|
|
8240
|
-
}
|
|
8241
|
-
function moveSectionInstance(instanceId, direction, currentPath) {
|
|
8242
|
-
const sections = topLevelSections();
|
|
8243
|
-
const index = sections.findIndex((el) => instanceIdOf(el) === instanceId);
|
|
8244
|
-
if (index === -1) return null;
|
|
8245
|
-
const siblingIndex = direction === "up" ? index - 1 : index + 1;
|
|
8246
|
-
if (siblingIndex < 0 || siblingIndex >= sections.length) return null;
|
|
8247
|
-
const entries = planSectionMove(instanceId, siblingIndex, currentPath);
|
|
8248
|
-
if (!entries) return null;
|
|
8249
|
-
applyPersistedOrder(entries);
|
|
8250
|
-
return entries;
|
|
8251
|
-
}
|
|
8252
|
-
function applyPersistedOrder(entries) {
|
|
8253
|
-
if (entries.length === 0) return;
|
|
8254
|
-
const sections = topLevelSections();
|
|
8255
|
-
if (sections.length === 0) return;
|
|
8256
|
-
const orderIndex = new Map(entries.map((e) => [e.instanceId, e.order]));
|
|
8257
|
-
const ordered = [...sections].sort((a, b) => {
|
|
8258
|
-
const aOrder = orderIndex.get(instanceIdOf(a));
|
|
8259
|
-
const bOrder = orderIndex.get(instanceIdOf(b));
|
|
8260
|
-
if (aOrder === void 0 && bOrder === void 0) return 0;
|
|
8261
|
-
if (aOrder === void 0) return 1;
|
|
8262
|
-
if (bOrder === void 0) return -1;
|
|
8263
|
-
return aOrder - bOrder;
|
|
8264
|
-
});
|
|
8265
|
-
let prev = null;
|
|
8266
|
-
for (const el of ordered) {
|
|
8267
|
-
if (prev) prev.after(el);
|
|
8268
|
-
prev = el;
|
|
8269
|
-
}
|
|
8270
|
-
}
|
|
8271
|
-
function getPageSectionOrderEntries(raw, currentPath) {
|
|
8272
|
-
if (!raw) return [];
|
|
8273
|
-
try {
|
|
8274
|
-
const entries = JSON.parse(raw);
|
|
8275
|
-
return entries.filter((e) => !e.pagePath || e.pagePath === currentPath);
|
|
8276
|
-
} catch {
|
|
8277
|
-
return [];
|
|
8278
|
-
}
|
|
8279
|
-
}
|
|
8280
|
-
function rekeySectionSubtree(root, instanceId) {
|
|
8281
|
-
const suffix = `::${instanceId}`;
|
|
8282
|
-
const rekey = (el, attr) => {
|
|
8283
|
-
const current = el.getAttribute(attr);
|
|
8284
|
-
if (current) el.setAttribute(attr, `${current}${suffix}`);
|
|
8285
|
-
};
|
|
8286
|
-
if (root.hasAttribute("data-ohw-key")) rekey(root, "data-ohw-key");
|
|
8287
|
-
if (root.hasAttribute("data-ohw-href-key")) rekey(root, "data-ohw-href-key");
|
|
8288
|
-
root.querySelectorAll("[data-ohw-key]").forEach((el) => rekey(el, "data-ohw-key"));
|
|
8289
|
-
root.querySelectorAll("[data-ohw-href-key]").forEach((el) => rekey(el, "data-ohw-href-key"));
|
|
8290
|
-
}
|
|
8291
|
-
function initSectionInstancesFromContent(content, currentPath) {
|
|
8292
|
-
document.querySelectorAll("[data-ohw-section]:not([data-ohw-instance])").forEach((el) => {
|
|
8293
|
-
el.setAttribute("data-ohw-instance", el.getAttribute("data-ohw-section") ?? "");
|
|
8294
|
-
});
|
|
8295
|
-
const entries = getPageSectionOrderEntries(content[SECTION_ORDER_KEY], currentPath);
|
|
8296
|
-
for (const entry of entries) {
|
|
8297
|
-
if (entry.instanceId === entry.type) continue;
|
|
8298
|
-
if (document.querySelector(`[data-ohw-instance="${CSS.escape(entry.instanceId)}"]`)) continue;
|
|
8299
|
-
const original = document.querySelector(
|
|
8300
|
-
`[data-ohw-section="${CSS.escape(entry.type)}"][data-ohw-instance="${CSS.escape(entry.type)}"]`
|
|
8301
|
-
);
|
|
8302
|
-
if (!original) continue;
|
|
8303
|
-
const clone = original.cloneNode(true);
|
|
8304
|
-
clone.setAttribute("data-ohw-instance", entry.instanceId);
|
|
8305
|
-
rekeySectionSubtree(clone, entry.instanceId);
|
|
8306
|
-
original.insertAdjacentElement("afterend", clone);
|
|
8307
|
-
}
|
|
8308
|
-
applyPersistedOrder(entries);
|
|
8309
|
-
}
|
|
8310
|
-
|
|
8311
8361
|
// src/OhhwellsBridge.tsx
|
|
8312
8362
|
var import_react_dom4 = require("react-dom");
|
|
8313
8363
|
var import_navigation3 = require("next/navigation");
|
|
@@ -11013,6 +11063,10 @@ function markSocialsRows(root = document) {
|
|
|
11013
11063
|
item.setAttribute(SOCIALS_ITEM_ATTR, String(index));
|
|
11014
11064
|
}
|
|
11015
11065
|
const iconKey = socialIconKey(item) ?? socialHrefKey(item)?.replace(/-href$/, "");
|
|
11066
|
+
if (iconKey && !item.querySelector(ICON_SELECTOR)) {
|
|
11067
|
+
const drawn = item.querySelector("svg, img");
|
|
11068
|
+
if (drawn) adoptAsIconSlot(drawn, iconKey);
|
|
11069
|
+
}
|
|
11016
11070
|
if (iconKey) ensureLabelSlot(item, iconKey);
|
|
11017
11071
|
});
|
|
11018
11072
|
});
|
|
@@ -11444,12 +11498,30 @@ function socialsMissingIcons(row) {
|
|
|
11444
11498
|
label: (socialLabelElement(item)?.textContent ?? item.getAttribute("aria-label") ?? "").trim()
|
|
11445
11499
|
})).filter((entry) => Boolean(entry.hrefKey));
|
|
11446
11500
|
}
|
|
11501
|
+
function adoptAsIconSlot(drawn, base) {
|
|
11502
|
+
const parent = drawn.parentElement;
|
|
11503
|
+
if (!parent) return null;
|
|
11504
|
+
const taken = drawn.ownerDocument.querySelector(`[data-ohw-key="${base}"]`);
|
|
11505
|
+
const iconKey = taken ? `${base}-icon` : base;
|
|
11506
|
+
const slot = drawn.ownerDocument.createElement("span");
|
|
11507
|
+
slot.setAttribute("data-ohw-key", iconKey);
|
|
11508
|
+
slot.setAttribute("data-ohw-editable", "icon");
|
|
11509
|
+
slot.style.display = "inline-flex";
|
|
11510
|
+
parent.insertBefore(slot, drawn);
|
|
11511
|
+
slot.appendChild(drawn);
|
|
11512
|
+
return iconKey;
|
|
11513
|
+
}
|
|
11447
11514
|
function ensureIconSlot(item) {
|
|
11448
11515
|
const existing = item.querySelector(ICON_SELECTOR);
|
|
11449
11516
|
if (existing) return existing.dataset.ohwKey ?? null;
|
|
11450
11517
|
const hrefKey = socialHrefKey(item);
|
|
11451
11518
|
if (!hrefKey) return null;
|
|
11452
11519
|
const base = hrefKey.replace(/-href$/, "");
|
|
11520
|
+
const drawn = item.querySelector("svg, img");
|
|
11521
|
+
if (drawn) {
|
|
11522
|
+
const adopted = adoptAsIconSlot(drawn, base);
|
|
11523
|
+
if (adopted) return adopted;
|
|
11524
|
+
}
|
|
11453
11525
|
const taken = document.querySelector(`[data-ohw-key="${base}"]`);
|
|
11454
11526
|
const iconKey = taken && taken !== item ? `${base}-icon` : base;
|
|
11455
11527
|
const slot = document.createElement("span");
|
|
@@ -16366,7 +16438,7 @@ function OhhwellsBridge() {
|
|
|
16366
16438
|
const original = originalContentRef.current ?? "";
|
|
16367
16439
|
if (html !== sanitizeHtml(original)) {
|
|
16368
16440
|
postToParentRef.current({ type: "ow:change", nodes: [{ key, text: html }] });
|
|
16369
|
-
const h = document.
|
|
16441
|
+
const h = document.body.scrollHeight;
|
|
16370
16442
|
if (h > 50) postToParentRef.current({ type: "ow:height", height: h });
|
|
16371
16443
|
}
|
|
16372
16444
|
}
|
|
@@ -16528,7 +16600,7 @@ function OhhwellsBridge() {
|
|
|
16528
16600
|
const original = originalContentRef.current ?? "";
|
|
16529
16601
|
if (html !== sanitizeHtml(original)) {
|
|
16530
16602
|
postToParent2({ type: "ow:change", nodes: [{ key, text: html }] });
|
|
16531
|
-
const h = document.
|
|
16603
|
+
const h = document.body.scrollHeight;
|
|
16532
16604
|
if (h > 50) postToParent2({ type: "ow:height", height: h });
|
|
16533
16605
|
}
|
|
16534
16606
|
}
|
|
@@ -19556,7 +19628,7 @@ function OhhwellsBridge() {
|
|
|
19556
19628
|
timers.set(key, setTimeout(() => {
|
|
19557
19629
|
timers.delete(key);
|
|
19558
19630
|
postToParentRef.current({ type: "ow:change", nodes: [{ key, text: html }] });
|
|
19559
|
-
const h = document.
|
|
19631
|
+
const h = document.body.scrollHeight;
|
|
19560
19632
|
if (h > 50) postToParentRef.current({ type: "ow:height", height: h });
|
|
19561
19633
|
}, 400));
|
|
19562
19634
|
};
|
|
@@ -19624,7 +19696,7 @@ function OhhwellsBridge() {
|
|
|
19624
19696
|
reconcileFooterOrderFromContent(editContentRef.current);
|
|
19625
19697
|
syncNavigationDragCursorAttrs();
|
|
19626
19698
|
enforceLinkHrefs();
|
|
19627
|
-
const hydratedHeight = document.
|
|
19699
|
+
const hydratedHeight = document.body.scrollHeight;
|
|
19628
19700
|
if (hydratedHeight > 50) postToParentRef.current({ type: "ow:height", height: hydratedHeight });
|
|
19629
19701
|
postToParentRef.current({ type: "ow:hydrate-done" });
|
|
19630
19702
|
};
|
|
@@ -19706,7 +19778,7 @@ function OhhwellsBridge() {
|
|
|
19706
19778
|
const nextValue = serializeAiSectionsState(nextState);
|
|
19707
19779
|
aiSectionsRef.current = nextValue;
|
|
19708
19780
|
applyAiSectionsToDom(nextState);
|
|
19709
|
-
const newHeight = document.
|
|
19781
|
+
const newHeight = document.body.scrollHeight;
|
|
19710
19782
|
if (newHeight > 50) postToParentRef.current({ type: "ow:height", height: newHeight });
|
|
19711
19783
|
postToParentRef.current({ type: "ow:change", nodes: [{ key: AI_SECTIONS_KEY, text: nextValue }] });
|
|
19712
19784
|
const appliedEl = document.querySelector(`[data-ohw-section="${CSS.escape(payload.id)}"]`);
|
|
@@ -19728,7 +19800,7 @@ function OhhwellsBridge() {
|
|
|
19728
19800
|
const nextValue = serializeAiSectionsState(nextState);
|
|
19729
19801
|
aiSectionsRef.current = nextValue;
|
|
19730
19802
|
applyAiSectionsToDom(nextState);
|
|
19731
|
-
const newHeight = document.
|
|
19803
|
+
const newHeight = document.body.scrollHeight;
|
|
19732
19804
|
if (newHeight > 50) postToParentRef.current({ type: "ow:height", height: newHeight });
|
|
19733
19805
|
postToParentRef.current({ type: "ow:change", nodes: [{ key: AI_SECTIONS_KEY, text: nextValue }] });
|
|
19734
19806
|
postToParentRef.current({ type: "ow:ai-section-deleted", sectionId, previous, value: nextValue });
|
|
@@ -19742,7 +19814,7 @@ function OhhwellsBridge() {
|
|
|
19742
19814
|
aiSectionsRef.current = value;
|
|
19743
19815
|
applyAiSectionsToDom(parseAiSectionsState(value));
|
|
19744
19816
|
applyStylesToDom(parseStyleStore(stylesRef.current));
|
|
19745
|
-
const restoredHeight = document.
|
|
19817
|
+
const restoredHeight = document.body.scrollHeight;
|
|
19746
19818
|
if (restoredHeight > 50) postToParentRef.current({ type: "ow:height", height: restoredHeight });
|
|
19747
19819
|
postToParentRef.current({ type: "ow:change", nodes: [{ key: AI_SECTIONS_KEY, text: value }] });
|
|
19748
19820
|
postAiSectionsChanged();
|
|
@@ -19796,6 +19868,48 @@ function OhhwellsBridge() {
|
|
|
19796
19868
|
else document.documentElement.removeAttribute("data-ohw-panel-dragging");
|
|
19797
19869
|
};
|
|
19798
19870
|
window.addEventListener("message", handlePanelDragging);
|
|
19871
|
+
const handleDeleteSection = (e) => {
|
|
19872
|
+
if (e.data?.type !== "ow:delete-section") return;
|
|
19873
|
+
const instanceId = typeof e.data.instanceId === "string" ? e.data.instanceId : "";
|
|
19874
|
+
if (!instanceId) return;
|
|
19875
|
+
const currentEntries = getPageSectionOrderEntries(editContentRef.current[SECTION_ORDER_KEY], window.location.pathname);
|
|
19876
|
+
const entries = deleteSectionInstance(instanceId, window.location.pathname, currentEntries);
|
|
19877
|
+
if (!entries) return;
|
|
19878
|
+
const orderJson = JSON.stringify(entries);
|
|
19879
|
+
editContentRef.current = { ...editContentRef.current, [SECTION_ORDER_KEY]: orderJson };
|
|
19880
|
+
postToParentRef.current({ type: "ow:change", nodes: [{ key: SECTION_ORDER_KEY, text: orderJson }] });
|
|
19881
|
+
aiSectionApiRef.current?.clear();
|
|
19882
|
+
window.dispatchEvent(new Event("resize"));
|
|
19883
|
+
const deleteHeight = document.body.scrollHeight;
|
|
19884
|
+
if (deleteHeight > 50) postToParentRef.current({ type: "ow:height", height: deleteHeight });
|
|
19885
|
+
const actionId = newInstanceId();
|
|
19886
|
+
pendingDeleteUndoRef.current = {
|
|
19887
|
+
actionId,
|
|
19888
|
+
restore: () => {
|
|
19889
|
+
const restoredEntries = getPageSectionOrderEntries(
|
|
19890
|
+
editContentRef.current[SECTION_ORDER_KEY],
|
|
19891
|
+
window.location.pathname
|
|
19892
|
+
);
|
|
19893
|
+
const restored = restoreSectionInstance(instanceId, window.location.pathname, restoredEntries);
|
|
19894
|
+
if (!restored) return;
|
|
19895
|
+
const restoredJson = JSON.stringify(restored);
|
|
19896
|
+
editContentRef.current = { ...editContentRef.current, [SECTION_ORDER_KEY]: restoredJson };
|
|
19897
|
+
postToParentRef.current({ type: "ow:change", nodes: [{ key: SECTION_ORDER_KEY, text: restoredJson }] });
|
|
19898
|
+
window.dispatchEvent(new Event("resize"));
|
|
19899
|
+
const restoreHeight = document.body.scrollHeight;
|
|
19900
|
+
if (restoreHeight > 50) postToParentRef.current({ type: "ow:height", height: restoreHeight });
|
|
19901
|
+
}
|
|
19902
|
+
};
|
|
19903
|
+
postToParentRef.current({
|
|
19904
|
+
type: "ow:toast",
|
|
19905
|
+
title: "Section deleted",
|
|
19906
|
+
toastType: "success",
|
|
19907
|
+
actionLabel: "Undo",
|
|
19908
|
+
actionId,
|
|
19909
|
+
duration: 6e3
|
|
19910
|
+
});
|
|
19911
|
+
};
|
|
19912
|
+
window.addEventListener("message", handleDeleteSection);
|
|
19799
19913
|
const handleDeactivate = (e) => {
|
|
19800
19914
|
if (e.data?.type !== "ow:deactivate") return;
|
|
19801
19915
|
if (document.documentElement.hasAttribute("data-ohw-panel-dragging")) return;
|
|
@@ -20131,7 +20245,7 @@ function OhhwellsBridge() {
|
|
|
20131
20245
|
const updated = sections.filter((s) => !(s.type === "scheduling" && s.pagePath === currentPath));
|
|
20132
20246
|
tracker.textContent = JSON.stringify(updated);
|
|
20133
20247
|
postToParentRef.current({ type: "ow:change", nodes: [{ key: "__ohw_sections", text: tracker.textContent }] });
|
|
20134
|
-
const h = document.
|
|
20248
|
+
const h = document.body.scrollHeight;
|
|
20135
20249
|
if (h > 50) postToParentRef.current({ type: "ow:height", height: h });
|
|
20136
20250
|
};
|
|
20137
20251
|
const handleCollectSection = (e) => {
|
|
@@ -20482,6 +20596,7 @@ function OhhwellsBridge() {
|
|
|
20482
20596
|
window.removeEventListener("message", handleAiSetStyles);
|
|
20483
20597
|
window.removeEventListener("message", handleGetBrand);
|
|
20484
20598
|
window.removeEventListener("message", handlePanelDragging);
|
|
20599
|
+
window.removeEventListener("message", handleDeleteSection);
|
|
20485
20600
|
window.removeEventListener("message", handleDeactivate);
|
|
20486
20601
|
window.removeEventListener("message", handleToastAction);
|
|
20487
20602
|
window.removeEventListener("message", handleFormCount);
|