@ohhwells/bridge 0.1.53 → 0.1.54-next.146

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/README.md CHANGED
@@ -355,11 +355,40 @@ import { LinkPopover } from "@ohhwells/bridge";
355
355
  The iframe bridge reports page sections on `ow:ready`:
356
356
 
357
357
  ```json
358
- { "type": "ow:ready", "version": "1", "nodes": [...], "sections": [{ "id": "hero", "label": "Hero" }] }
358
+ { "type": "ow:ready", "version": "1", "bridgeVersion": "0.1.50", "nodes": [...], "sections": [{ "id": "hero", "label": "Hero" }] }
359
359
  ```
360
360
 
361
+ `version` is the protocol version; `bridgeVersion` is the npm package version (inlined at build time), letting the editor detect sites running an older bridge and gate version-dependent features (e.g. AI prompting) gracefully.
362
+
361
363
  Templates must mark sections with `data-ohw-section` (and optional `data-ohw-section-label`).
362
364
 
365
+ ### Section-scoped content collection (AI prompt context)
366
+
367
+ The editor can request a single section's editable content (edit mode only):
368
+
369
+ ```json
370
+ // editor → iframe
371
+ { "type": "ow:collect-section", "sectionId": "hero" }
372
+
373
+ // iframe → editor
374
+ { "type": "ow:section-nodes", "sectionId": "hero", "found": true,
375
+ "nodes": [{ "key": "hero-headline", "type": "text/rich", "text": "..." }],
376
+ "rect": { "top": 0, "left": 0, "width": 1280, "height": 720 } }
377
+ ```
378
+
379
+ - `found` is `false` (with empty `nodes`, `rect: null`) when no `[data-ohw-section="<id>"]` exists on the current page.
380
+ - `rect` is the section element's document-relative bounding box — the editor uses it to draw the in-flight overlay over just the target section.
381
+ - The returned set contains pure section content only: structural keys (`__ohw_*`), carousel/video-setting/meta nodes, and keyless editables are never included.
382
+ - Node `type` is normalized to the set `image | bg-image | video | link | plain | text/rich | text` (unknown template-declared types become `text`).
383
+
384
+ `ow:enter-edit` (iframe → editor, sent when the user clicks into an editable) also carries the enclosing section so the editor can offer that section as the AI prompt target:
385
+
386
+ ```json
387
+ { "type": "ow:enter-edit", "key": "hero-headline", "sectionId": "hero", "sectionLabel": "Hero" }
388
+ ```
389
+
390
+ `sectionId`/`sectionLabel` are `null` for editables outside any `[data-ohw-section]` (label also when `data-ohw-section-label` is absent).
391
+
363
392
  ### Local link-editor testing (dev fixtures)
364
393
 
365
394
  Without the canvas editor parent, add `ohw-fixtures=1` to the edit URL. This preloads Re:Bound pages and sections into the link popover: