@ohhwells/bridge 0.1.105 → 0.1.107

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.js CHANGED
@@ -520,6 +520,19 @@ function alignSubjectOf(el) {
520
520
  while (subject.parentElement && !subject.parentElement.hasAttribute("data-ohw-section") && /^inline/.test(getComputedStyle(subject).display)) {
521
521
  subject = subject.parentElement;
522
522
  }
523
+ const TEXT_ROW = /^(P|LI|H[1-6]|BLOCKQUOTE|FIGCAPTION|DT|DD)$/;
524
+ const parent = subject.parentElement;
525
+ if (parent && TEXT_ROW.test(parent.tagName) && /^(inline-)?flex$/.test(getComputedStyle(parent).display)) {
526
+ return parent;
527
+ }
528
+ if (parent && !parent.hasAttribute("data-ohw-section")) {
529
+ const pcs = getComputedStyle(parent);
530
+ const children = Array.from(parent.children);
531
+ const textRowChild = (c) => c.hasAttribute("data-ohw-editable") || (c.textContent ?? "").trim().length === 0 || c.getAttribute("aria-hidden") === "true";
532
+ if (/^(inline-)?flex$/.test(pcs.display) && pcs.flexDirection.startsWith("row") && children.length > 0 && children.some((c) => c.hasAttribute("data-ohw-editable")) && children.every(textRowChild)) {
533
+ return parent;
534
+ }
535
+ }
523
536
  const row = subject.closest("li");
524
537
  if (row && row !== subject && /^(inline-)?flex$/.test(getComputedStyle(row).display)) {
525
538
  return row;
@@ -19434,10 +19447,21 @@ function OhhwellsBridge() {
19434
19447
  gap: 6px;
19435
19448
  }
19436
19449
  /* Not the form: it is a layout container (flex/grid with gaps), and forcing block
19437
- crushed its fields together (OHH-490). */
19438
- [data-ohw-editable]:not([data-ohw-editable="form"]) {
19450
+ crushed its fields together (OHH-490). Not media (image/bg-image/video/icon/map)
19451
+ either: those can be their own flex containers centering fallback content (a
19452
+ placeholder label, a mascot emoji) \u2014 forcing block broke that centering while the
19453
+ image was unset (OHH-758-ish). */
19454
+ [data-ohw-editable]:not([data-ohw-editable="form"]):not([data-ohw-editable="image"]):not([data-ohw-editable="bg-image"]):not([data-ohw-editable="video"]):not([data-ohw-editable="icon"]):not([data-ohw-editable="map"]) {
19439
19455
  display: block;
19440
19456
  }
19457
+ /* The block-force above is an author rule, so it beats the browser's own
19458
+ details-not-open child-display-none UA rule \u2014 origin always wins over specificity.
19459
+ Left alone, a closed FAQ's answer became a real, hoverable box that overflowed past
19460
+ the collapsed <details> into the gap before the next item. Restore the native
19461
+ collapse for editable content once it isn't the summary. */
19462
+ details:not([open]) > [data-ohw-editable]:not(summary) {
19463
+ display: none !important;
19464
+ }
19441
19465
  /* Body text (no item-action toolbar) \u2014 first click enters text edit \u2192 I-beam.
19442
19466
  Exclude select-first nav/footer labels so grab/default on [data-ohw-href-key] can win. */
19443
19467
  [data-ohw-editable]:not([contenteditable]):not([data-ohw-editable="image"]):not([data-ohw-editable="bg-image"]):not([data-ohw-editable="video"]):not([data-ohw-editable="link"]):not(:is([data-ohw-href-key] *)) {
@@ -19461,6 +19485,14 @@ function OhhwellsBridge() {
19461
19485
  [data-ohw-editable="video"], [data-ohw-editable="video"] *,
19462
19486
  [data-ohw-editable="bg-image"], [data-ohw-editable="bg-image"] * { cursor: pointer !important; }
19463
19487
  [data-ohw-editable="link"], [data-ohw-editable="link"] * { cursor: pointer !important; }
19488
+ /* A text/plain editable nested inside a media editable (e.g. a placeholder's fallback
19489
+ label inside its bg-image box) is its own click target, not the media picker \u2014 the
19490
+ blanket media cursor rule above would otherwise show pointer where a click actually
19491
+ opens text edit. */
19492
+ [data-ohw-editable="bg-image"] [data-ohw-editable="text"],
19493
+ [data-ohw-editable="bg-image"] [data-ohw-editable="text"] *,
19494
+ [data-ohw-editable="image"] [data-ohw-editable="text"],
19495
+ [data-ohw-editable="image"] [data-ohw-editable="text"] * { cursor: text !important; }
19464
19496
  /* A form field is a design surface in the editor: its input takes the pointer so the
19465
19497
  field can be picked and hovered from anywhere inside it (OHH-642). */
19466
19498
  [data-ohw-editable="form"] [data-ohw-form-field] input,
@@ -20047,6 +20079,8 @@ function OhhwellsBridge() {
20047
20079
  setFormHoverRect(null);
20048
20080
  }
20049
20081
  if (!editable) return;
20082
+ const editableRect = editable.getBoundingClientRect();
20083
+ if (editableRect.width <= 0 || editableRect.height <= 0) return;
20050
20084
  const selected = selectedElRef.current;
20051
20085
  if (selected && (selected === editable || selected.contains(editable))) return;
20052
20086
  if (!isMediaEditable(editable) && !editable.hasAttribute("contenteditable")) {
@@ -22150,6 +22184,18 @@ function OhhwellsBridge() {
22150
22184
  hoveredNavContainerRef.current = null;
22151
22185
  setHoveredNavContainerRect(null);
22152
22186
  };
22187
+ const handleDetailsToggle = (e) => {
22188
+ if (e.target?.tagName !== "DETAILS") return;
22189
+ document.querySelectorAll("[data-ohw-hovered]").forEach((hovered) => {
22190
+ hovered.removeAttribute("data-ohw-hovered");
22191
+ });
22192
+ setHoveredTextRect(null);
22193
+ hoveredItemElRef.current = null;
22194
+ setHoveredItemRect(null);
22195
+ hoveredNavContainerRef.current = null;
22196
+ setHoveredNavContainerRect(null);
22197
+ };
22198
+ document.addEventListener("toggle", handleDetailsToggle, true);
22153
22199
  window.addEventListener("resize", handleViewportResize, { passive: true });
22154
22200
  document.addEventListener("click", handleClick, true);
22155
22201
  document.addEventListener("dblclick", handleDblClick, true);
@@ -22167,6 +22213,7 @@ function OhhwellsBridge() {
22167
22213
  document.addEventListener("selectionchange", handleSelectionChange);
22168
22214
  window.addEventListener("scroll", handleScroll, true);
22169
22215
  return () => {
22216
+ document.removeEventListener("toggle", handleDetailsToggle, true);
22170
22217
  document.removeEventListener("click", handleClick, true);
22171
22218
  document.removeEventListener("dblclick", handleDblClick, true);
22172
22219
  document.removeEventListener("paste", handlePaste, true);
@@ -22420,7 +22467,7 @@ function OhhwellsBridge() {
22420
22467
  postToParent2({
22421
22468
  type: "ow:ready",
22422
22469
  version: "1",
22423
- bridgeVersion: "0.1.104",
22470
+ bridgeVersion: "0.1.106",
22424
22471
  path: pathname,
22425
22472
  nodes: collectEditableNodes(editContentRef.current),
22426
22473
  sections