@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 CHANGED
@@ -6548,6 +6548,24 @@ function deleteSectionFromState(state, sectionId) {
6548
6548
  if (removed.includes(sectionId)) return state;
6549
6549
  return { ...state, v: 1, sections: state.sections, removed: [...removed, sectionId] };
6550
6550
  }
6551
+ function moveSectionInState(state, sectionId, targetPath) {
6552
+ const entry = state.sections.find((section) => section.id === sectionId);
6553
+ if (!entry) return null;
6554
+ const moved = {
6555
+ id: entry.id,
6556
+ label: entry.label,
6557
+ path: targetPath,
6558
+ afterSection: null,
6559
+ tree: entry.tree,
6560
+ media: entry.media,
6561
+ ...entry.brand ? { brand: entry.brand } : {}
6562
+ };
6563
+ return {
6564
+ ...state,
6565
+ v: 1,
6566
+ sections: state.sections.map((section) => section.id === sectionId ? moved : section)
6567
+ };
6568
+ }
6551
6569
  function reapRemovedAiSections(state, store, removedIds, excludeIds = /* @__PURE__ */ new Set()) {
6552
6570
  const generated = new Set(state.sections.map((entry) => entry.id));
6553
6571
  const reapedIds = [...new Set(removedIds)].filter((id) => generated.has(id) && !excludeIds.has(id));
@@ -17480,7 +17498,7 @@ function apiBase() {
17480
17498
  function bridgeVersion() {
17481
17499
  try {
17482
17500
  if (true) {
17483
- return "0.1.165";
17501
+ return "0.1.166";
17484
17502
  }
17485
17503
  } catch {
17486
17504
  }
@@ -17494,7 +17512,7 @@ function stampBridgeVersionOnDocument() {
17494
17512
  return;
17495
17513
  }
17496
17514
  try {
17497
- const v = true ? "0.1.165" : "";
17515
+ const v = true ? "0.1.166" : "";
17498
17516
  if (v) {
17499
17517
  document.documentElement.setAttribute("data-ohw-bridge-version", v);
17500
17518
  window.__OHW_BRIDGE_VERSION__ = v;
@@ -31132,6 +31150,31 @@ function OhhwellsBridge() {
31132
31150
  postAiSectionsChanged();
31133
31151
  };
31134
31152
  window.addEventListener("message", handleAiDeleteSection);
31153
+ const handleAiMoveSection = (e) => {
31154
+ if (e.data?.type !== "ow:ai-move-section") return;
31155
+ const sectionId = typeof e.data.sectionId === "string" ? e.data.sectionId : "";
31156
+ const targetPage = typeof e.data.targetPage === "string" ? e.data.targetPage : "";
31157
+ if (!sectionId || !targetPage) return;
31158
+ const previous = aiSectionsRef.current;
31159
+ const nextState = moveSectionInState(parseAiSectionsState(previous), sectionId, targetPage);
31160
+ if (!nextState) return;
31161
+ clearInteractionChrome();
31162
+ const nextValue = serializeAiSectionsState(nextState);
31163
+ aiSectionsRef.current = nextValue;
31164
+ applyAiSectionsToDom(nextState);
31165
+ const newHeight = document.body.scrollHeight;
31166
+ if (newHeight > 50) postToParentRef.current({ type: "ow:height", height: newHeight });
31167
+ postToParentRef.current({ type: "ow:change", nodes: [{ key: AI_SECTIONS_KEY, text: nextValue }] });
31168
+ postToParentRef.current({
31169
+ type: "ow:ai-section-moved",
31170
+ sectionId,
31171
+ targetPage,
31172
+ previous,
31173
+ value: nextValue
31174
+ });
31175
+ postAiSectionsChanged();
31176
+ };
31177
+ window.addEventListener("message", handleAiMoveSection);
31135
31178
  const handleAiSetSections = (e) => {
31136
31179
  if (e.data?.type !== "ow:ai-set-sections") return;
31137
31180
  const value = typeof e.data.value === "string" ? e.data.value : "";
@@ -32331,6 +32374,7 @@ function OhhwellsBridge() {
32331
32374
  window.removeEventListener("message", handleAiApplyTree);
32332
32375
  window.removeEventListener("message", handleAiApplyFooter);
32333
32376
  window.removeEventListener("message", handleAiDeleteSection);
32377
+ window.removeEventListener("message", handleAiMoveSection);
32334
32378
  window.removeEventListener("message", handleAiSetSections);
32335
32379
  window.removeEventListener("message", handleAiSetBrand);
32336
32380
  window.removeEventListener("message", handleAiSetStyles);
@@ -32644,7 +32688,7 @@ function OhhwellsBridge() {
32644
32688
  postToParent2({
32645
32689
  type: "ow:ready",
32646
32690
  version: "1",
32647
- bridgeVersion: "0.1.165",
32691
+ bridgeVersion: "0.1.166",
32648
32692
  path: pathname,
32649
32693
  nodes: collectEditableNodes(editContentRef.current),
32650
32694
  sections