@ohhwells/bridge 0.1.165 → 0.1.166
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 +47 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +47 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6432,6 +6432,24 @@ function deleteSectionFromState(state, sectionId) {
|
|
|
6432
6432
|
if (removed.includes(sectionId)) return state;
|
|
6433
6433
|
return { ...state, v: 1, sections: state.sections, removed: [...removed, sectionId] };
|
|
6434
6434
|
}
|
|
6435
|
+
function moveSectionInState(state, sectionId, targetPath) {
|
|
6436
|
+
const entry = state.sections.find((section) => section.id === sectionId);
|
|
6437
|
+
if (!entry) return null;
|
|
6438
|
+
const moved = {
|
|
6439
|
+
id: entry.id,
|
|
6440
|
+
label: entry.label,
|
|
6441
|
+
path: targetPath,
|
|
6442
|
+
afterSection: null,
|
|
6443
|
+
tree: entry.tree,
|
|
6444
|
+
media: entry.media,
|
|
6445
|
+
...entry.brand ? { brand: entry.brand } : {}
|
|
6446
|
+
};
|
|
6447
|
+
return {
|
|
6448
|
+
...state,
|
|
6449
|
+
v: 1,
|
|
6450
|
+
sections: state.sections.map((section) => section.id === sectionId ? moved : section)
|
|
6451
|
+
};
|
|
6452
|
+
}
|
|
6435
6453
|
function reapRemovedAiSections(state, store, removedIds, excludeIds = /* @__PURE__ */ new Set()) {
|
|
6436
6454
|
const generated = new Set(state.sections.map((entry) => entry.id));
|
|
6437
6455
|
const reapedIds = [...new Set(removedIds)].filter((id) => generated.has(id) && !excludeIds.has(id));
|
|
@@ -17364,7 +17382,7 @@ function apiBase() {
|
|
|
17364
17382
|
function bridgeVersion() {
|
|
17365
17383
|
try {
|
|
17366
17384
|
if (true) {
|
|
17367
|
-
return "0.1.
|
|
17385
|
+
return "0.1.166";
|
|
17368
17386
|
}
|
|
17369
17387
|
} catch {
|
|
17370
17388
|
}
|
|
@@ -17378,7 +17396,7 @@ function stampBridgeVersionOnDocument() {
|
|
|
17378
17396
|
return;
|
|
17379
17397
|
}
|
|
17380
17398
|
try {
|
|
17381
|
-
const v = true ? "0.1.
|
|
17399
|
+
const v = true ? "0.1.166" : "";
|
|
17382
17400
|
if (v) {
|
|
17383
17401
|
document.documentElement.setAttribute("data-ohw-bridge-version", v);
|
|
17384
17402
|
window.__OHW_BRIDGE_VERSION__ = v;
|
|
@@ -31022,6 +31040,31 @@ function OhhwellsBridge() {
|
|
|
31022
31040
|
postAiSectionsChanged();
|
|
31023
31041
|
};
|
|
31024
31042
|
window.addEventListener("message", handleAiDeleteSection);
|
|
31043
|
+
const handleAiMoveSection = (e) => {
|
|
31044
|
+
if (e.data?.type !== "ow:ai-move-section") return;
|
|
31045
|
+
const sectionId = typeof e.data.sectionId === "string" ? e.data.sectionId : "";
|
|
31046
|
+
const targetPage = typeof e.data.targetPage === "string" ? e.data.targetPage : "";
|
|
31047
|
+
if (!sectionId || !targetPage) return;
|
|
31048
|
+
const previous = aiSectionsRef.current;
|
|
31049
|
+
const nextState = moveSectionInState(parseAiSectionsState(previous), sectionId, targetPage);
|
|
31050
|
+
if (!nextState) return;
|
|
31051
|
+
clearInteractionChrome();
|
|
31052
|
+
const nextValue = serializeAiSectionsState(nextState);
|
|
31053
|
+
aiSectionsRef.current = nextValue;
|
|
31054
|
+
applyAiSectionsToDom(nextState);
|
|
31055
|
+
const newHeight = document.body.scrollHeight;
|
|
31056
|
+
if (newHeight > 50) postToParentRef.current({ type: "ow:height", height: newHeight });
|
|
31057
|
+
postToParentRef.current({ type: "ow:change", nodes: [{ key: AI_SECTIONS_KEY, text: nextValue }] });
|
|
31058
|
+
postToParentRef.current({
|
|
31059
|
+
type: "ow:ai-section-moved",
|
|
31060
|
+
sectionId,
|
|
31061
|
+
targetPage,
|
|
31062
|
+
previous,
|
|
31063
|
+
value: nextValue
|
|
31064
|
+
});
|
|
31065
|
+
postAiSectionsChanged();
|
|
31066
|
+
};
|
|
31067
|
+
window.addEventListener("message", handleAiMoveSection);
|
|
31025
31068
|
const handleAiSetSections = (e) => {
|
|
31026
31069
|
if (e.data?.type !== "ow:ai-set-sections") return;
|
|
31027
31070
|
const value = typeof e.data.value === "string" ? e.data.value : "";
|
|
@@ -32221,6 +32264,7 @@ function OhhwellsBridge() {
|
|
|
32221
32264
|
window.removeEventListener("message", handleAiApplyTree);
|
|
32222
32265
|
window.removeEventListener("message", handleAiApplyFooter);
|
|
32223
32266
|
window.removeEventListener("message", handleAiDeleteSection);
|
|
32267
|
+
window.removeEventListener("message", handleAiMoveSection);
|
|
32224
32268
|
window.removeEventListener("message", handleAiSetSections);
|
|
32225
32269
|
window.removeEventListener("message", handleAiSetBrand);
|
|
32226
32270
|
window.removeEventListener("message", handleAiSetStyles);
|
|
@@ -32534,7 +32578,7 @@ function OhhwellsBridge() {
|
|
|
32534
32578
|
postToParent2({
|
|
32535
32579
|
type: "ow:ready",
|
|
32536
32580
|
version: "1",
|
|
32537
|
-
bridgeVersion: "0.1.
|
|
32581
|
+
bridgeVersion: "0.1.166",
|
|
32538
32582
|
path: pathname,
|
|
32539
32583
|
nodes: collectEditableNodes(editContentRef.current),
|
|
32540
32584
|
sections
|