@ohhwells/bridge 0.1.114-next.309 → 0.1.114-next.310

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
@@ -11191,6 +11191,17 @@ var import_react11 = require("react");
11191
11191
  var import_react_dom3 = require("react-dom");
11192
11192
  var import_lucide_react14 = require("lucide-react");
11193
11193
  var import_navigation2 = require("next/navigation");
11194
+
11195
+ // src/lib/parent-scroll.ts
11196
+ function getIframeVisibleClip(parentScroll) {
11197
+ if (!parentScroll) return null;
11198
+ const { iframeOffsetTop, headerH: visibleCanvasTop, canvasH, promptBarH = 0 } = parentScroll;
11199
+ const clipTop = Math.max(0, visibleCanvasTop - iframeOffsetTop);
11200
+ const clipBottom = Math.min(window.innerHeight, visibleCanvasTop + canvasH - iframeOffsetTop) - promptBarH;
11201
+ return { top: clipTop, bottom: Math.max(clipTop, clipBottom) };
11202
+ }
11203
+
11204
+ // src/ui/link-modal/SectionPickerOverlay.tsx
11194
11205
  var import_jsx_runtime26 = require("react/jsx-runtime");
11195
11206
  var DIM_OVERLAY = "rgba(0, 0, 0, 0.45)";
11196
11207
  function rectsEqual(a, b) {
@@ -11328,20 +11339,22 @@ function SectionPickerOverlay({
11328
11339
  []
11329
11340
  );
11330
11341
  (0, import_react11.useEffect)(() => {
11331
- const applyClip = (iframeOffsetTop, visibleCanvasTop, canvasH) => {
11332
- const top = Math.max(0, visibleCanvasTop - iframeOffsetTop);
11333
- const bottom = Math.min(
11334
- window.innerHeight,
11335
- visibleCanvasTop + canvasH - iframeOffsetTop
11336
- );
11342
+ const applyClip = (iframeOffsetTop, visibleCanvasTop, canvasH, promptBarH = 0) => {
11343
+ const next = getIframeVisibleClip({
11344
+ iframeOffsetTop,
11345
+ headerH: visibleCanvasTop,
11346
+ canvasH,
11347
+ promptBarH
11348
+ });
11349
+ if (!next) return;
11337
11350
  setChromeClip(
11338
- (prev) => prev.top === top && prev.bottom === bottom ? prev : { top, bottom: Math.max(top, bottom) }
11351
+ (prev) => prev.top === next.top && prev.bottom === next.bottom ? prev : next
11339
11352
  );
11340
11353
  };
11341
11354
  const onParentScroll = (e) => {
11342
11355
  if (e.data?.type !== "ow:parent-scroll") return;
11343
- const { iframeOffsetTop, headerH, canvasH } = e.data;
11344
- applyClip(iframeOffsetTop, headerH, canvasH);
11356
+ const { iframeOffsetTop, headerH, canvasH, promptBarH = 0 } = e.data;
11357
+ applyClip(iframeOffsetTop, headerH, canvasH, promptBarH);
11345
11358
  iframeOffsetTopRef.current = iframeOffsetTop;
11346
11359
  if (!pointerScreenRef.current && pointerRef.current) {
11347
11360
  pointerScreenRef.current = {
@@ -15009,13 +15022,11 @@ var EDGE_MARGIN = 16;
15009
15022
  function getVisibleClip(parentScroll) {
15010
15023
  const left = 0;
15011
15024
  const right = window.innerWidth;
15012
- if (!parentScroll) {
15025
+ const band = getIframeVisibleClip(parentScroll);
15026
+ if (!band) {
15013
15027
  return { top: 0, bottom: window.innerHeight, left, right };
15014
15028
  }
15015
- const { iframeOffsetTop, headerH: visibleCanvasTop, canvasH } = parentScroll;
15016
- const top = Math.max(0, visibleCanvasTop - iframeOffsetTop);
15017
- const bottom = Math.min(window.innerHeight, visibleCanvasTop + canvasH - iframeOffsetTop);
15018
- return { top, bottom: Math.max(top, bottom), left, right };
15029
+ return { ...band, left, right };
15019
15030
  }
15020
15031
  function defaultFloatingPanelPosition(parentScroll, panelHeight = 280) {
15021
15032
  const clip = getVisibleClip(parentScroll);
@@ -15891,7 +15902,10 @@ function assignmentFor(el, content, tokens) {
15891
15902
  function labelElement(el) {
15892
15903
  return el.querySelector('[data-ohw-editable="text"], [data-ohw-editable="plain"]') ?? (el.matches('[data-ohw-editable="text"], [data-ohw-editable="plain"]') ? el : null);
15893
15904
  }
15894
- function applyButtonStyle(el, assignment, tokens) {
15905
+ var paintLockByEl = /* @__PURE__ */ new WeakMap();
15906
+ var paintObserverByEl = /* @__PURE__ */ new WeakMap();
15907
+ var paintingButton = false;
15908
+ function paintButtonChrome(el, assignment, tokens) {
15895
15909
  const origin = captureButtonOrigin(el);
15896
15910
  const chrome = tokens.variants[assignment.variant];
15897
15911
  const originSlot = classifyHeight(origin.size.height);
@@ -15899,6 +15913,7 @@ function applyButtonStyle(el, assignment, tokens) {
15899
15913
  const { typography } = origin;
15900
15914
  el.setAttribute("data-ohw-btn-variant", assignment.variant);
15901
15915
  el.setAttribute("data-ohw-btn-size", assignment.size);
15916
+ el.style.transition = "none";
15902
15917
  el.style.boxSizing = "border-box";
15903
15918
  el.style.display = "inline-flex";
15904
15919
  el.style.alignItems = "center";
@@ -15925,6 +15940,26 @@ function applyButtonStyle(el, assignment, tokens) {
15925
15940
  const label = labelElement(el);
15926
15941
  if (label && label !== el) label.style.color = chrome.color;
15927
15942
  }
15943
+ function guardTemplateHover(el) {
15944
+ if (paintObserverByEl.has(el)) return;
15945
+ const observer = new MutationObserver(() => {
15946
+ if (paintingButton) return;
15947
+ const lock = paintLockByEl.get(el);
15948
+ if (!lock) return;
15949
+ paintingButton = true;
15950
+ paintButtonChrome(el, lock.assignment, lock.tokens);
15951
+ paintingButton = false;
15952
+ });
15953
+ observer.observe(el, { attributes: true, attributeFilter: ["style", "class"] });
15954
+ paintObserverByEl.set(el, observer);
15955
+ }
15956
+ function applyButtonStyle(el, assignment, tokens) {
15957
+ paintLockByEl.set(el, { assignment, tokens });
15958
+ paintingButton = true;
15959
+ paintButtonChrome(el, assignment, tokens);
15960
+ paintingButton = false;
15961
+ guardTemplateHover(el);
15962
+ }
15928
15963
  function applyButtonStylesFromContent(doc, content) {
15929
15964
  const assignments = readAssignments(content);
15930
15965
  for (const [id, assignment] of Object.entries(assignments)) {
@@ -16114,6 +16149,9 @@ function isLastNavbarButton(el) {
16114
16149
  function canDeleteButton(el) {
16115
16150
  return !isLastNavbarButton(el);
16116
16151
  }
16152
+ function canDuplicateButton(el) {
16153
+ return isNavbarCta(el);
16154
+ }
16117
16155
  function labelElement2(el) {
16118
16156
  return el.querySelector('[data-ohw-editable="text"], [data-ohw-editable="plain"]') ?? el.querySelector("[data-ohw-key]");
16119
16157
  }
@@ -16168,12 +16206,27 @@ function nextCollectionId(content, doc) {
16168
16206
  while (used.has(`bc-${n}`)) n += 1;
16169
16207
  return `bc-${n}`;
16170
16208
  }
16209
+ var COLLECTION_GAP_MAX_PX = 12;
16210
+ var COLLECTION_GAP_DEFAULT = "12px";
16211
+ function usableGap(value) {
16212
+ if (!value || value === "normal") return null;
16213
+ const n = parseFloat(value);
16214
+ if (!Number.isFinite(n) || n <= 0) return null;
16215
+ if (n > COLLECTION_GAP_MAX_PX) return COLLECTION_GAP_DEFAULT;
16216
+ return `${Math.round(n * 100) / 100}px`;
16217
+ }
16171
16218
  function collectionGap(el, tokens) {
16172
- if (tokens) return tokens.sizes.m.gap;
16219
+ const fromCollection = usableGap(buttonCollectionOf(el)?.style.gap);
16220
+ if (fromCollection) return fromCollection;
16173
16221
  const parent = el.parentElement;
16174
- if (!parent) return "12px";
16175
- const gap = getComputedStyle(parent).columnGap || getComputedStyle(parent).gap;
16176
- return gap && gap !== "normal" ? gap : "12px";
16222
+ if (parent) {
16223
+ const style = getComputedStyle(parent);
16224
+ const fromParent = usableGap(style.columnGap) ?? usableGap(style.gap);
16225
+ if (fromParent) return fromParent;
16226
+ }
16227
+ const fromTokens = usableGap(tokens?.sizes.m.gap);
16228
+ if (fromTokens) return fromTokens;
16229
+ return COLLECTION_GAP_DEFAULT;
16177
16230
  }
16178
16231
  function styleCollection(collection, gap) {
16179
16232
  collection.style.display = "inline-flex";
@@ -16221,6 +16274,7 @@ function findButton(doc, id) {
16221
16274
  return doc.querySelector(`[data-ohw-href-key="${CSS.escape(id)}"]`);
16222
16275
  }
16223
16276
  function duplicateButton(source, content) {
16277
+ if (!canDuplicateButton(source)) return null;
16224
16278
  const sourceId = buttonId(source);
16225
16279
  if (!sourceId) return null;
16226
16280
  const doc = source.ownerDocument;
@@ -16239,7 +16293,7 @@ function duplicateButton(source, content) {
16239
16293
  const collections = readCollections(content);
16240
16294
  let collectionId = collection?.getAttribute(COLLECTION_ATTR) ?? "";
16241
16295
  let members = collectionId && collections[collectionId] ? [...collections[collectionId].members] : [];
16242
- const gap = collection?.style.gap || collectionGap(source, tokens);
16296
+ const gap = collectionGap(source, tokens);
16243
16297
  if (!collection) {
16244
16298
  collectionId = nextCollectionId(content, doc);
16245
16299
  collection = createCollection(doc, collectionId, gap);
@@ -17225,12 +17279,6 @@ var SECTION_DRAG_EXCLUDED_SELECTOR = [
17225
17279
  "[data-ohw-media-overlay]",
17226
17280
  "[data-ohw-media-skeleton]"
17227
17281
  ].join(", ");
17228
- function visibleClip(ps) {
17229
- if (!ps) return null;
17230
- const top = Math.max(0, ps.headerH - ps.iframeOffsetTop);
17231
- const bottom = Math.min(window.innerHeight, ps.headerH + ps.canvasH - ps.iframeOffsetTop);
17232
- return { top, bottom: Math.max(top, bottom) };
17233
- }
17234
17282
  function useSectionDrag({
17235
17283
  isEditMode,
17236
17284
  editContentRef,
@@ -17267,7 +17315,7 @@ function useSectionDrag({
17267
17315
  }, [postToParentRef, stopAutoScroll]);
17268
17316
  const updateAutoScroll = (0, import_react16.useCallback)(
17269
17317
  (clientY) => {
17270
- const clip = visibleClip(parentScrollRef.current);
17318
+ const clip = getIframeVisibleClip(parentScrollRef.current);
17271
17319
  let delta = 0;
17272
17320
  if (clip) {
17273
17321
  const distTop = clientY - clip.top;
@@ -19176,16 +19224,6 @@ function EditGlowChrome({
19176
19224
  }
19177
19225
  );
19178
19226
  }
19179
- function getIframeVisibleClip(parentScroll) {
19180
- if (!parentScroll) return null;
19181
- const { iframeOffsetTop, headerH: visibleCanvasTop, canvasH } = parentScroll;
19182
- const clipTop = Math.max(0, visibleCanvasTop - iframeOffsetTop);
19183
- const clipBottom = Math.min(
19184
- window.innerHeight,
19185
- visibleCanvasTop + canvasH - iframeOffsetTop
19186
- );
19187
- return { top: clipTop, bottom: Math.max(clipTop, clipBottom) };
19188
- }
19189
19227
  function isRectOutsideClip(rect, clip) {
19190
19228
  if (!clip) return false;
19191
19229
  return rect.bottom < clip.top || rect.top > clip.bottom;
@@ -24934,10 +24972,10 @@ function OhhwellsBridge() {
24934
24972
  };
24935
24973
  const handleParentScroll = (e) => {
24936
24974
  if (e.data?.type !== "ow:parent-scroll") return;
24937
- const { iframeOffsetTop, headerH, canvasH } = e.data;
24938
- parentScrollRef.current = { iframeOffsetTop, headerH, canvasH };
24975
+ const { iframeOffsetTop, headerH, canvasH, promptBarH = 0 } = e.data;
24976
+ parentScrollRef.current = { iframeOffsetTop, headerH, canvasH, promptBarH };
24939
24977
  if (floatingPanelOpenRef.current) {
24940
- setParentScrollSnap({ iframeOffsetTop, headerH, canvasH });
24978
+ setParentScrollSnap({ iframeOffsetTop, headerH, canvasH, promptBarH });
24941
24979
  }
24942
24980
  if (visibleViewportRef.current) {
24943
24981
  applyVisibleViewport(visibleViewportRef.current, parentScrollRef.current);
@@ -26230,7 +26268,7 @@ function OhhwellsBridge() {
26230
26268
  const social = getSocialItem(selectedElRef.current);
26231
26269
  return social ? !canRemoveSocialItem(social) : false;
26232
26270
  })(),
26233
- duplicateDisabled: isFooterFrameSelection || selectedIsSocialsRow || selectedElRef.current !== null && (() => {
26271
+ duplicateDisabled: isFooterFrameSelection || selectedIsSocialsRow || selectedElRef.current !== null && isCtaButton(selectedElRef.current) && !canDuplicateButton(selectedElRef.current) || selectedElRef.current !== null && (() => {
26234
26272
  const social = getSocialItem(selectedElRef.current);
26235
26273
  const row = social ? findSocialsRow(social) : null;
26236
26274
  return row ? !canAddSocialItem(row) : false;