@ohhwells/bridge 0.1.52 → 0.1.53-next.145
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 +42 -2
- package/dist/index.cjs +3538 -756
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +140 -1
- package/dist/index.d.ts +140 -1
- package/dist/index.js +3501 -718
- package/dist/index.js.map +1 -1
- package/dist/styles.css +89 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -194,12 +194,23 @@ For links whose **destination URL** is edited in the canvas, use a plain `<a>` w
|
|
|
194
194
|
</a>
|
|
195
195
|
```
|
|
196
196
|
|
|
197
|
+
Section / body CTAs use the same two-phase select + Edit-link toolbar with `data-ohw-role="button"` (preferred). `navbar-button` remains supported as an alias for nav header CTAs:
|
|
198
|
+
|
|
199
|
+
```tsx
|
|
200
|
+
<a href="/contact" data-ohw-href-key="hero-cta-href" data-ohw-role="button" data-ohw-drag-disabled="true">
|
|
201
|
+
<span data-ohw-editable="text" data-ohw-key="hero-cta-label">
|
|
202
|
+
Get started
|
|
203
|
+
</span>
|
|
204
|
+
</a>
|
|
205
|
+
```
|
|
206
|
+
|
|
197
207
|
| Attribute | Purpose |
|
|
198
208
|
|-----------|---------|
|
|
199
209
|
| `data-ohw-href-key` | Storage key for the link destination |
|
|
200
210
|
| `href` | Default URL for SSR / first paint |
|
|
201
211
|
| `data-ohw-key` + `data-ohw-editable` on inner span | Editable label text |
|
|
202
|
-
| `data-ohw-role="
|
|
212
|
+
| `data-ohw-role="button"` | Section CTA — two-phase select + link-action toolbar (no reorder/More) |
|
|
213
|
+
| `data-ohw-role="navbar-button"` | Alias of `button` for navbar / header CTAs |
|
|
203
214
|
|
|
204
215
|
The bridge persists and restores `href` values (including after React re-renders). No template-side wrapper component is required.
|
|
205
216
|
|
|
@@ -344,11 +355,40 @@ import { LinkPopover } from "@ohhwells/bridge";
|
|
|
344
355
|
The iframe bridge reports page sections on `ow:ready`:
|
|
345
356
|
|
|
346
357
|
```json
|
|
347
|
-
{ "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" }] }
|
|
348
359
|
```
|
|
349
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
|
+
|
|
350
363
|
Templates must mark sections with `data-ohw-section` (and optional `data-ohw-section-label`).
|
|
351
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
|
+
|
|
352
392
|
### Local link-editor testing (dev fixtures)
|
|
353
393
|
|
|
354
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:
|