Skip to content

Commit 6ecca21

Browse files
committed
feat: update event payload descriptions and add 'root' attribute for enterSchema
1 parent ffcdecd commit 6ecca21

3 files changed

Lines changed: 27 additions & 23 deletions

File tree

‎docs/client.md‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -384,17 +384,17 @@ if (window.localess) {
384384
}
385385
```
386386

387-
| Event | Payload | When |
388-
|---------------|-----------------------------------------------|---------------------------------------|
389-
| `input` | `{ type: 'input', data: any }` | User typing in a field (real-time) |
390-
| `change` | `{ type: 'change', data: any }` | Field value confirmed |
391-
| `save` | `{ type: 'save' }` | Content saved |
392-
| `publish` | `{ type: 'publish' }` | Content published |
393-
| `unpublish` | `{ type: 'unpublish' }` | Content unpublished |
394-
| `pong` | `{ type: 'pong' }` | Editor heartbeat response |
395-
| `enterSchema` | `{ type: 'enterSchema', id, schema, field? }` | Editor cursor enters a schema block |
396-
| `hoverSchema` | `{ type: 'hoverSchema', id, schema, field? }` | Editor cursor hovers a schema block |
397-
| `leaveSchema` | `{ type: 'leaveSchema' }` | Editor cursor leaves a schema block |
387+
| Event | Payload | When |
388+
|---------------|------------------------------------------------------|-----------------------------------------------------------------------------|
389+
| `input` | `{ type: 'input', data: any }` | User typing in a field (real-time) |
390+
| `change` | `{ type: 'change', data: any }` | Field value confirmed |
391+
| `save` | `{ type: 'save' }` | Content saved |
392+
| `publish` | `{ type: 'publish' }` | Content published |
393+
| `unpublish` | `{ type: 'unpublish' }` | Content unpublished |
394+
| `pong` | `{ type: 'pong' }` | Editor heartbeat response |
395+
| `enterSchema` | `{ type: 'enterSchema', id, schema, field?, root? }` | Editor cursor enters a schema block; `root` is `true` for the document root |
396+
| `hoverSchema` | `{ type: 'hoverSchema', id, schema, field? }` | Editor cursor hovers a schema block |
397+
| `leaveSchema` | `{ type: 'leaveSchema' }` | Editor cursor leaves a schema block |
398398

399399
## Asset Transform Parameters
400400

‎packages/client/README.md‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -322,17 +322,17 @@ The `LocalessSync` interface (`on`, `onChange`) and the event types (`EventToApp
322322

323323
### Available Event Types
324324

325-
| Event | Payload | Description |
326-
|---------------|-----------------------------------------------|-------------------------------------------------|
327-
| `input` | `{ type: 'input', data: any }` | Fired while a field is being edited (real-time) |
328-
| `change` | `{ type: 'change', data: any }` | Fired after a field value is confirmed |
329-
| `save` | `{ type: 'save' }` | Fired when content is saved |
330-
| `publish` | `{ type: 'publish' }` | Fired when content is published |
331-
| `unpublish` | `{ type: 'unpublish' }` | Fired when content is unpublished |
332-
| `pong` | `{ type: 'pong' }` | Heartbeat response from the editor |
333-
| `enterSchema` | `{ type: 'enterSchema', id, schema, field? }` | Fired when entering a schema element |
334-
| `hoverSchema` | `{ type: 'hoverSchema', id, schema, field? }` | Fired when hovering over a schema element |
335-
| `leaveSchema` | `{ type: 'leaveSchema' }` | Fired when leaving a schema element |
325+
| Event | Payload | Description |
326+
|---------------|------------------------------------------------------|------------------------------------------------------------------------------|
327+
| `input` | `{ type: 'input', data: any }` | Fired while a field is being edited (real-time) |
328+
| `change` | `{ type: 'change', data: any }` | Fired after a field value is confirmed |
329+
| `save` | `{ type: 'save' }` | Fired when content is saved |
330+
| `publish` | `{ type: 'publish' }` | Fired when content is published |
331+
| `unpublish` | `{ type: 'unpublish' }` | Fired when content is unpublished |
332+
| `pong` | `{ type: 'pong' }` | Heartbeat response from the editor |
333+
| `enterSchema` | `{ type: 'enterSchema', id, schema, field?, root? }` | Fired when entering a schema element; `root` is `true` for the document root |
334+
| `hoverSchema` | `{ type: 'hoverSchema', id, schema, field? }` | Fired when hovering over a schema element |
335+
| `leaveSchema` | `{ type: 'leaveSchema' }` | Fired when leaving a schema element |
336336

337337
---
338338

‎packages/live-preview/src/events.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ export type EventToApp =
99
| { type: 'leaveSchema' }
1010
| { type: 'input'; data: any }
1111
| { type: 'change'; data: any }
12-
| { type: 'enterSchema'; id: string; schema: string; field?: string }
12+
/**
13+
* The editor opened a schema block in its form. `root` is `true` when it went back to the
14+
* document root, which the sync script treats as clearing the selection.
15+
*/
16+
| { type: 'enterSchema'; id: string; schema: string; field?: string; root?: boolean }
1317
| { type: 'hoverSchema'; id: string; schema: string; field?: string };
1418

1519
export type EventCallback = (event: EventToApp) => void;

0 commit comments

Comments
 (0)