rapier-embed 1.2.45 → 1.2.46
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 +104 -40
- package/embed.d.mts +14 -6
- package/embed.mjs +190 -78
- package/package.json +1 -1
- package/rapier-plugins.json +195 -195
package/README.md
CHANGED
|
@@ -44,13 +44,13 @@ downloaded copy yourself and pass it as `src`.
|
|
|
44
44
|
- The reader changes nothing. Restyle it with CSS custom properties and your own fonts; keep it and its plug-ins
|
|
45
45
|
on your own origin.
|
|
46
46
|
- Editor saves are revision-checked: a conflict keeps the person's source in the editor.
|
|
47
|
-
- `<rapier-editor>` is a form field whose value is the exact
|
|
47
|
+
- `<rapier-editor>` is a form field whose value is the exact captured Markdown, pictures and line endings included.
|
|
48
48
|
- With `agent: true`, your app's agent works beside the person or while they are away. Rapier shows what changed;
|
|
49
49
|
`show {target:"comparison"}` lets the agent display a diff deliberately. Currentness, source scope and authenticated
|
|
50
50
|
document access remain enforced.
|
|
51
51
|
|
|
52
52
|
```sh
|
|
53
|
-
npm install rapier-embed@1.2.
|
|
53
|
+
npm install rapier-embed@1.2.46
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
Or copy the package's `embed.mjs` and `contract.mjs` into one directory of your app; no runtime CDN is needed.
|
|
@@ -68,7 +68,7 @@ editor and lightweight reader (about 400 kB). The agent edits live; the person s
|
|
|
68
68
|
changes, taps a change to see the before and undoes anything. Use `show {target:"comparison"}` to show a diff deliberately.
|
|
69
69
|
|
|
70
70
|
1. **Work together live.** Connect to `https://mcp.rapier.website/door/mcp`, then call `open` to share one document with the person.
|
|
71
|
-
2. **Deliver an offline editor.** Run `npx rapier-html@1.2.
|
|
71
|
+
2. **Deliver an offline editor.** Run `npx rapier-html@1.2.46 notes.md` to put the document and editor in one HTML file ([rapier-html](https://github.com/jackskip22/rapier-plugins/tree/main/npm/rapier-html)).
|
|
72
72
|
3. **Embed in your app.** Install [rapier-embed](https://github.com/jackskip22/rapier-plugins/tree/main/npm/rapier-embed); mount the editor or reader, with your app's agent over WebMCP in the editor.
|
|
73
73
|
4. **Keep portable Markdown.** Use [rapier-markdown-kit](https://github.com/jackskip22/rapier-plugins/tree/main/npm/rapier-markdown-kit) for pictures, editable SVG drawings and layout in one `.md` file. Respect [Will/1](https://github.com/jackskip22/will) `keep`, `append` and `edit` regions.
|
|
74
74
|
5. **Encode JPEG XL.** Install [rapier-jxl](https://github.com/jackskip22/rapier-jxl) to encode pixels, photographs and existing JPEGs in JavaScript.
|
|
@@ -118,11 +118,11 @@ The frame needs the host page to be an `https` page, or `http` on `localhost`. `
|
|
|
118
118
|
| The browser is offline | `offline` | The hosted copies cannot be fetched. Mount again when the network is back, or serve a copy and set `src`. |
|
|
119
119
|
| Your own `<iframe sandbox>` without `allow-scripts` or `allow-same-origin` | `sandbox_token_missing` | `mount` never widens a sandbox you wrote. Add the token, or pass a container and let `mount` create the iframe (it sets `allow-scripts allow-same-origin allow-downloads`). |
|
|
120
120
|
|
|
121
|
-
A frame that loads but never connects rejects `ready` and calls `onError` with `connect_timeout` once `timeout` (15 seconds) has passed since the frame's load event, so a slow download is not counted. A frame that never finishes loading rejects with `load_timeout` after 120 seconds.
|
|
121
|
+
A frame that loads but never connects rejects `ready` and calls `onError` with `connect_timeout` once `timeout` (15 seconds by default) has passed since the frame's load event, so a slow download is not counted. A frame that never finishes loading rejects with `load_timeout` after 120 seconds by default. After connection, the first host loader and the frame's load acknowledgment together have the same 120-second bound; later `load()` calls use that acknowledgment bound too. A `timeout` greater than 120,000 milliseconds raises those load bounds. A late connection can still become live and load the document: `connected` becomes true and its event fires, but an already rejected `ready` stays rejected. After a first-load failure, a connected handle can retry with `load()`; old loader results cannot replace the accepted retry. A host whose own `frame-src` (or `default-src`) does not list the frame's origin blocks it the same way; the browser console names the policy. A page that does not allow your parent is the usual cause: the hosted pages send `frame-ancestors https: http://localhost:* http://127.0.0.1:*`, so a parent on `file://`, a custom scheme or plain http on a LAN address is blocked and never connects (`mount` names the first three at once, above). A copy you serve sets its own `frame-ancestors` (an HTTP response header; a `<meta>` tag cannot set it); list your parent's origin there. A plain `<iframe src=".../rapier.html">` with no helper opens an empty document when the parent shares the page's origin. From another origin it stays closed and says why. With `?embed=1` and no helper connected, the reader says "No document is loaded."
|
|
122
122
|
|
|
123
123
|
### Keep typing when the tab closes
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
Draft recovery needs the same identity, saved revision and content in the same tab (see Draft identity below). Closing the tab ends its session storage. Ask the browser to confirm while something is unsaved:
|
|
126
126
|
|
|
127
127
|
```js
|
|
128
128
|
let dirty = false;
|
|
@@ -136,17 +136,20 @@ The reader on its own page opens a document at an address on its own origin: `ht
|
|
|
136
136
|
|
|
137
137
|
## Keep Rapier in your codebase
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
Keep the helper, page and plug-in manifest on one version. For version 1.2.45:
|
|
140
140
|
|
|
141
|
-
1.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
frame
|
|
141
|
+
1. Install the helper: `npm install rapier-embed@1.2.46`.
|
|
142
|
+
2. Create `public/vendor/rapier/` and download the reader:
|
|
143
|
+
`curl --fail -L -o public/vendor/rapier/rapier-reader.html https://cdn.jsdelivr.net/gh/jackskip22/rapier-plugins@cdn-v1.2.45/embed/rapier-reader.html`.
|
|
144
|
+
3. Fetch its plug-ins from the same version's manifest:
|
|
145
|
+
`npx rapier-embed@1.2.46 plugins public/vendor/rapier/plugins --build reader`. This command does not fetch the page.
|
|
146
|
+
4. Use the complete mount in Show a document above, with `src`, `plugins` and `load`. Serve the files over HTTPS
|
|
147
|
+
(HTTP on localhost) and allow their origin in your `frame-src`. Give the container a height. A same-origin
|
|
148
|
+
parent can script its frame; use a dedicated origin when the frame must be isolated.
|
|
148
149
|
|
|
149
|
-
|
|
150
|
+
For the editor, download `rapier.html` from the same tag and use `--build full`. To update, replace the helper,
|
|
151
|
+
page and plug-ins together. Serving your own files avoids a runtime CDN dependency; offline navigation still
|
|
152
|
+
needs the host to make those files available.
|
|
150
153
|
|
|
151
154
|
## Plug-ins
|
|
152
155
|
|
|
@@ -157,7 +160,7 @@ length and SHA-384 before it runs it, and keeps on the device. A file that fails
|
|
|
157
160
|
| Plug-in | Adds | Size | Pages |
|
|
158
161
|
| --- | --- | --- | --- |
|
|
159
162
|
| `flowchart` | Draws Mermaid flowcharts and graphs natively, in the editor's own style. | 0.33 MB | The reader |
|
|
160
|
-
| `docx` | Opens a Word document (.docx) as a Markdown document: headings, lists, tables, pictures and comments. | 0.
|
|
163
|
+
| `docx` | Opens a Word document (.docx) as a Markdown document: headings, lists, tables, pictures and comments. | 0.76 MB | The reader |
|
|
161
164
|
| `math` | Typesets TeX math ($...$ and $$...$$) as SVG. | 0.74 MB | Both |
|
|
162
165
|
| `diagrams` | Draws every other Mermaid diagram: sequence, class, state, ER, Gantt, pie and more. | 1.14 MB (2 files) | Both |
|
|
163
166
|
| `pdf` | Opens a PDF as a Markdown document: its text layer, or each page as a picture. Fetches the pdf.js files itself. | 6.13 MB (198 files) | Both |
|
|
@@ -168,11 +171,11 @@ length and SHA-384 before it runs it, and keeps on the device. A file that fails
|
|
|
168
171
|
| `elements` | The Elements sheet's traced ornaments: 3,155 pieces from the ornament book. | 16.2 MB (51 files) | `rapier.html` |
|
|
169
172
|
| `lettersets` | The Gallery's letter sets: 31 sets of ornamental capitals. | 2.82 MB (31 files) | `rapier.html` |
|
|
170
173
|
|
|
171
|
-
Totals: the reader,
|
|
174
|
+
Totals: the reader, 9.10 MB (30.8 MB with `ocr`); `rapier.html`, 57.2 MB. Release 1.2.46.
|
|
172
175
|
<!-- PLUGIN_TABLE_END -->
|
|
173
176
|
|
|
174
177
|
The manifest lists every plug-in file and, in `builds`, the pages that use it. `rapier.html` has flowcharts and Word import
|
|
175
|
-
built in. `npx rapier-embed@1.2.
|
|
178
|
+
built in. `npx rapier-embed@1.2.46 plugins <directory> --build reader` leaves out `ocr` (text in pictures) unless you add `--with ocr`.
|
|
176
179
|
|
|
177
180
|
**Approve plug-ins up front.** Without `plugins`, a frame asks its person "Install math plug-in?" the first time a document needs math or a diagram, and math and diagrams stay raw until they answer. A host that has decided passes `approvePlugins: true`: the frame installs the plug-in it needs without a question. Naming `plugins` has the same effect, because the host then serves the files itself. In a frame shorter than the question's sheet, the sheet's body scrolls.
|
|
178
181
|
|
|
@@ -185,7 +188,7 @@ The directory must be on the page's own origin, because the page's Content Secur
|
|
|
185
188
|
throws a `TypeError` for a directory on another origin, and a page opened with one shows each plug-in as failed, with the
|
|
186
189
|
reason, without making a request. To keep the plug-ins on a CDN, serve the page from the same origin.
|
|
187
190
|
|
|
188
|
-
`npx rapier-embed@1.2.
|
|
191
|
+
`npx rapier-embed@1.2.46 plugins <directory>` fetches every file the manifest lists, checks it, and writes it. It
|
|
189
192
|
keeps a file that is already there and correct, and exits with status 1 if any file is missing or fails its check.
|
|
190
193
|
`--build reader` or `--build full` keeps the files that page uses, `--only name,name` fetches some
|
|
191
194
|
plug-ins, `--check` verifies a directory without fetching, `--from <address>` fetches from your own mirror, and
|
|
@@ -302,14 +305,15 @@ Mount takes a container or an iframe and owns its navigation, title and clipboar
|
|
|
302
305
|
navigation, and accepts readiness only from that iframe's window and exact origin. HTTPS is required, except HTTP
|
|
303
306
|
on localhost.
|
|
304
307
|
|
|
305
|
-
`load` is a record or an async callback returning `{content, revision, filename?, readOnly?, title?, baseUrl?}`.
|
|
306
|
-
callback
|
|
307
|
-
|
|
308
|
-
|
|
308
|
+
`load` is a record or an async callback returning `{content, revision, filename?, readOnly?, title?, baseUrl?}`.
|
|
309
|
+
Mount snapshots a record; a callback is called again after each connection to request the host's current record.
|
|
310
|
+
The `save` callback receives `{content, filename, docKind, codeLang, requestId, baseRevision}` and returns
|
|
311
|
+
`{revision}` directly or through a promise, only after durable storage confirms the write. A repeated request ID
|
|
312
|
+
shares the first write and repeats its first answer, even while that write is pending. A repeated ID with different source, metadata or base revision is refused as
|
|
309
313
|
`save_request_conflict`. Source must fit the session's UTF-8 document byte limit before it reaches your callback.
|
|
310
314
|
Oversized source is `document_too_large`; ill-formed Unicode and malformed metadata are `save_payload_invalid`.
|
|
311
315
|
The helper holds answers for its lifetime; your store must also deduplicate IDs across host
|
|
312
|
-
reloads.
|
|
316
|
+
reloads. Choose the draft identity described below when you intend to recover a session.
|
|
313
317
|
|
|
314
318
|
Switch documents with `editor.load(content, {revision, filename})` or `editor.load({content, revision, filename})`. `revision` is optional in `load()`: left out, the helper uses one above the last revision it saw, or 1. `mount`'s `load` needs it. A load always shows and saves the document you gave it. It is refused by code while the person has unsaved edits (`unsaved_changes`; call `save()` first), and for the same filename with a revision older than the frame's (`revision_stale`) or with the same revision and other content (`revision_conflict`). Another filename is another document with its own revisions.
|
|
315
319
|
|
|
@@ -379,6 +383,7 @@ apply the old insertion to the replacement document. Asset failures do not rejec
|
|
|
379
383
|
| --- | --- |
|
|
380
384
|
| `build` | `'full'` (default; `rapier.html`, also named `'document'`) or `'reader'` |
|
|
381
385
|
| `src` | Your copy of the page; omitted, the hosted current build |
|
|
386
|
+
| `sessionId`, `documentId` | The fixed draft identity for this handle; see Draft identity below |
|
|
382
387
|
| `load` | Grants `open` |
|
|
383
388
|
| `save` | Grants `read`, plus `changes` to observe save completion |
|
|
384
389
|
| `onState(state)` | Grants `changes` |
|
|
@@ -394,11 +399,37 @@ apply the old insertion to the replacement document. Asset failures do not rejec
|
|
|
394
399
|
| `timeout` | Milliseconds after the frame loads that it has to connect before `ready` rejects with `connect_timeout`; default 15000 |
|
|
395
400
|
|
|
396
401
|
The handle has `iframe`, `ready` (a promise) and `connected`. `load(content, {revision, filename?, readOnly?,
|
|
397
|
-
title?})`, `save()`, `compare(content, {filename?})` and `close()` use their grants. `theme(value)` changes
|
|
398
|
-
host theme; `style({css, fonts})` restyles the reader
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
+
title?, baseUrl?})`, `save()`, `compare(content, {filename?})` and `close()` use their grants. `theme(value)` changes
|
|
403
|
+
the host theme; `style({css, fonts})` restyles the reader. `ready` resolves after connection and the initial load,
|
|
404
|
+
when supplied. The `connected` event identifies a live connection; it does not mean that the document has loaded.
|
|
405
|
+
The original `ready` promise is not replaced on reconnect.
|
|
406
|
+
|
|
407
|
+
A created iframe has 100% width and height and no border; your CSS can override those attributes. Give its
|
|
408
|
+
container a height. Mount adds the frame after what the container already holds: clear a server-rendered
|
|
409
|
+
placeholder first (`container.replaceChildren()`).
|
|
410
|
+
|
|
411
|
+
### Lifecycle
|
|
412
|
+
|
|
413
|
+
| Transition | What happens |
|
|
414
|
+
| --- | --- |
|
|
415
|
+
| Mount | Fix the IDs, grants and settings before navigation. Snapshot an initial load record, or call its loader after connection. |
|
|
416
|
+
| Accepted load | Keep the complete record: content, revision, filename, readOnly, title and baseUrl. A refused load leaves the last accepted record intact. |
|
|
417
|
+
| Confirmed Save | Keep the identity, update the saved content and revision, and wait for the frame to hold no newer edits before `save()` resolves. |
|
|
418
|
+
| Iframe navigation or reload | Reject old pending operations. Replay the last accepted record, updated by confirmed saves, when `load` was an object; call a function loader again for the current record. |
|
|
419
|
+
| Port error | Retire the connection and reject pending calls with `disconnected`. Recovery waits for a later iframe load. |
|
|
420
|
+
| Move within one task | Keep the connection if the iframe is attached when removal is observed. |
|
|
421
|
+
| Observed removal | Set `connected` to false, reject pending calls with `frame_removed` and release the active ID pair. The handle keeps its recovery state and iframe load listener. |
|
|
422
|
+
| Reinsert the same iframe | Reconnect that handle if it was not explicitly disconnected and the ID pair is free. If another writer owns the pair, refuse with `document_open_elsewhere`. Retired operations do not resume. |
|
|
423
|
+
| `disconnect()` | End the handle permanently, even while detached; reject unfinished operations and release ports, listeners, observers and timers. Remove an iframe mount created; leave an iframe you supplied. A new mount gets a new handle. |
|
|
424
|
+
|
|
425
|
+
Removal, reconnect and `disconnect()` do not save or discard the document. There is no autosave on unmount. A
|
|
426
|
+
late callback from an old connection cannot acknowledge work on its replacement; storage it already performed
|
|
427
|
+
remains your application's responsibility. A matching draft can be recovered as described below.
|
|
428
|
+
|
|
429
|
+
An editor iframe you supplied keeps its loaded document and its claim after disconnection. Another frame with
|
|
430
|
+
the same ID pair remains refused while that document is open. Remove or navigate the supplied iframe before
|
|
431
|
+
another frame opens the pair. Ending the transport does not discard the retained unsaved words.
|
|
432
|
+
|
|
402
433
|
Tab walks every control and link in the frame, except inside the editor text, where Tab indents. Escape, with nothing open in the frame and no text field focused, moves
|
|
403
434
|
focus to the next control on your page after the frame; Shift+Escape moves it to the control before. From the editor text the way out is Escape, then Tab (Shift+Tab goes back).
|
|
404
435
|
`on('connected' | 'state' | 'close-request' | 'closed' | 'error', fn)` returns an
|
|
@@ -408,10 +439,11 @@ change grants or settings. A denied or dirty replacement load rejects.
|
|
|
408
439
|
Every refusal is an `Error` with a `code`. A connect the frame refuses rejects `ready`: `contract_unsupported`,
|
|
409
440
|
`capabilities_invalid`, a `settings_*` code, or `invalid_payload` with a `reason`. A frame that cannot start rejects
|
|
410
441
|
`ready` and calls `onError`: `boot_failed` when the page shows its startup error, `connect_timeout` when it does not connect
|
|
411
|
-
within `timeout` of loading, `load_timeout` when
|
|
412
|
-
does not answer within
|
|
413
|
-
|
|
414
|
-
|
|
442
|
+
within `timeout` of loading, or `load_timeout` when the page or first document exceeds its load bound. `load()`
|
|
443
|
+
rejects with `load_timeout` when the frame does not answer within that bound, `load_busy` while an earlier load is
|
|
444
|
+
still being shown, `invalid_payload` for malformed input, `invalid_filename` or `invalid_base_url` for those
|
|
445
|
+
fields, `load_failed` when the frame cannot finish loading, and `document_unshowable` when the reader cannot
|
|
446
|
+
show the document; the reader keeps the document it showed. A document over 1 MB resolves `load()` when its first screen shows; the reader draws the rest after it. It rejects with `revision_stale` for a
|
|
415
447
|
revision older than the frame's and `revision_conflict` for the same revision with other content. It rejects with `document_open_elsewhere` when another editor already has the same `sessionId` and `documentId` open (on mount, `ready` rejects with it); the first editor keeps its typing. `mount` throws a
|
|
416
448
|
`TypeError` with a code for an unknown option (`option_unknown`), a build whose `src` names the other page (`build_mismatch`)
|
|
417
449
|
and a reader feature the reader does not have (`settings_feature_unavailable`). `Rapier.version` is this package's version;
|
|
@@ -424,7 +456,24 @@ frame could not capture; the person is told why). `close()` resolves with the fr
|
|
|
424
456
|
`{saved: true}` or `{discarded: true}` after your answer, `{forced: true}` when the person closes without your
|
|
425
457
|
answer, or `{cancelled: true}` when you answer `cancel`.
|
|
426
458
|
|
|
427
|
-
|
|
459
|
+
### Draft identity
|
|
460
|
+
|
|
461
|
+
| Mount options | Identity |
|
|
462
|
+
| --- | --- |
|
|
463
|
+
| Both `sessionId` and `documentId` | The exact pair you supply. |
|
|
464
|
+
| `documentId` and `save`, with no `sessionId` | Your document ID and a stable session derived from the host's origin and path. |
|
|
465
|
+
| Neither ID, with `save` and a `load` object | An automatic pair derived from the host page, filename, loaded text and an available matching-document slot. |
|
|
466
|
+
| Other omitted IDs | Generated IDs; provide your own stable pair for recovery across new mounts. |
|
|
467
|
+
|
|
468
|
+
The chosen IDs stay fixed for the handle. Changing filename changes the document's revision rules, not those
|
|
469
|
+
IDs. A second live mount of the same pair on a page is refused before its frame loads: `ready` rejects with
|
|
470
|
+
`document_open_elsewhere`, and the first keeps its document. Retire the first frame's document before another
|
|
471
|
+
frame acquires that pair; disconnect removes a helper-created frame, while a supplied frame needs removal or
|
|
472
|
+
navigation. Recovery after a route change, unmount or reload needs the same IDs, saved revision
|
|
473
|
+
and content in the same tab. Form replacements have the further limit described below.
|
|
474
|
+
|
|
475
|
+
`save()` and `requestSubmit()` ask the frame to capture its current text. With nothing unsaved, the frame answers
|
|
476
|
+
at once and the save callback is not called.
|
|
428
477
|
|
|
429
478
|
The frame keeps the person's unsaved work only for the document you loaded: a draft in that tab's session storage,
|
|
430
479
|
which a load of the same revision and content reopens and your `discard` answer retires. A load of another document drops a draft with no unsaved edits. It never reads, offers or writes the
|
|
@@ -452,9 +501,10 @@ Write here.</textarea>
|
|
|
452
501
|
</script>
|
|
453
502
|
```
|
|
454
503
|
|
|
455
|
-
The textarea works without script. After upgrade, `element.value` is the exact
|
|
456
|
-
|
|
457
|
-
|
|
504
|
+
The textarea works without script. After upgrade, `element.value` is the exact captured Markdown;
|
|
505
|
+
`await element.save()` captures the current source and returns that string. `change` fires when captured text
|
|
506
|
+
updates the field. Submit captures the edited source first, then continues native form validation and
|
|
507
|
+
submission with its submitter. Use `requestSubmit()` for scripted submissions; `form.submit()` bypasses submit events and cannot
|
|
458
508
|
capture pending edits.
|
|
459
509
|
|
|
460
510
|
The successful field is a `text/markdown` file part named `body`: read its uploaded bytes on the server, or
|
|
@@ -462,9 +512,23 @@ The successful field is a `text/markdown` file part named `body`: read its uploa
|
|
|
462
512
|
exactly; native text parts normalize line endings. The restoration state and `value` remain strings. Pictures
|
|
463
513
|
already live in the Markdown, so use `multipart/form-data`.
|
|
464
514
|
|
|
465
|
-
Reset restores the initial text
|
|
466
|
-
|
|
467
|
-
|
|
515
|
+
Reset restores the initial text. Assigning `value` selects that exact string; when the browser supplies a string
|
|
516
|
+
for form state restoration, the field restores it exactly. Each replacement retires pending field work and
|
|
517
|
+
selects fresh draft IDs held in the element's memory. A late capture cannot overwrite the replacement or resume
|
|
518
|
+
an old form submission.
|
|
519
|
+
|
|
520
|
+
On its first mount, a field with a DOM `id` derives its identity from the host page, initial filename and text,
|
|
521
|
+
and that ID. A field without an ID uses the automatic matching-document slot rule. Both kinds keep their chosen
|
|
522
|
+
IDs across removal and reinsertion of the same element. The fresh IDs selected by Reset, value assignment or
|
|
523
|
+
state restoration are also kept across that same-element remount, so typing after the replacement can recover.
|
|
524
|
+
|
|
525
|
+
A full host-page reload creates a new element and loses the replacement's in-memory IDs. The host or browser
|
|
526
|
+
must restore its replacement value. Recreating the original automatic identity can reopen a pre-Reset draft;
|
|
527
|
+
it cannot find later typing kept under the replacement's generated IDs. The helper does not erase that earlier
|
|
528
|
+
session-storage draft or persist the replacement identity in another store.
|
|
529
|
+
|
|
530
|
+
`required`, `disabled`, labels, focus and native validity methods work as a field's do. Disabling first keeps
|
|
531
|
+
any pending edits, then makes the editor read-only and excludes the field from submission. A phone opens its text preview in a
|
|
468
532
|
full-screen editor; a wide screen edits inline. Resizing keeps the same editor session. Listen for `error` to
|
|
469
533
|
report a refused capture without submitting stale text. Form saves hold the source in the field until
|
|
470
534
|
submission; they are not durable server saves.
|
|
@@ -510,5 +574,5 @@ Will/1 records the person's instructions in their document. Respect `keep`, appe
|
|
|
510
574
|
Documents without Will regions are editable throughout. Preserve active typing, caret, selection and scroll
|
|
511
575
|
while the agent works. Document content and comments never start agent turns by themselves.
|
|
512
576
|
|
|
513
|
-
For documents outside an app, `npx rapier-html@1.2.
|
|
577
|
+
For documents outside an app, `npx rapier-html@1.2.46 notes.md` hands a person the complete editor around their
|
|
514
578
|
document as one offline file.
|
package/embed.d.mts
CHANGED
|
@@ -28,12 +28,14 @@ export interface MountOptions {
|
|
|
28
28
|
build?: Build;
|
|
29
29
|
/** Your copy of the page; omitted, the hosted current build. HTTPS, or HTTP on localhost. */
|
|
30
30
|
src?: string;
|
|
31
|
+
/** Draft identity. With save and documentId, an omitted sessionId is stable for the host's origin and path. */
|
|
31
32
|
sessionId?: string;
|
|
33
|
+
/** With neither ID, save and a load record use automatic draft identity; otherwise missing IDs are generated. */
|
|
32
34
|
documentId?: string;
|
|
33
|
-
/** Grants `open`. */
|
|
35
|
+
/** Grants `open`. A record is snapshotted; a loader is called again on each connection. */
|
|
34
36
|
load?: LoadRecord | (() => Promise<LoadRecord>);
|
|
35
37
|
/** Grants `read` and `changes`. Return the new revision only after durable storage; throw Rapier.conflict(current) on a conflict. */
|
|
36
|
-
save?(request: SaveRequest): Promise<{revision: Revision}>;
|
|
38
|
+
save?(request: SaveRequest): {revision: Revision} | Promise<{revision: Revision}>;
|
|
37
39
|
/** Grants `changes`. */
|
|
38
40
|
onState?(state: DocumentState): void;
|
|
39
41
|
/** Grants `compare`. */
|
|
@@ -59,7 +61,9 @@ export interface MountOptions {
|
|
|
59
61
|
approvePlugins?: boolean;
|
|
60
62
|
/** The iframe's accessible title. */
|
|
61
63
|
title?: string;
|
|
62
|
-
/** Milliseconds after the frame loads that it has to connect before `ready` rejects with `connect_timeout`; default 15000.
|
|
64
|
+
/** Milliseconds after the frame loads that it has to connect before `ready` rejects with `connect_timeout`; default 15000.
|
|
65
|
+
* The page download and, after connection, the first loader plus load acknowledgment each have a 120-second bound
|
|
66
|
+
* (or this timeout if greater). Expiry rejects with `load_timeout`. */
|
|
63
67
|
timeout?: number;
|
|
64
68
|
onError?(error: Refusal | Error): void;
|
|
65
69
|
}
|
|
@@ -74,7 +78,9 @@ export interface EditorEvents {
|
|
|
74
78
|
|
|
75
79
|
export interface MountedEditor {
|
|
76
80
|
readonly iframe: HTMLIFrameElement;
|
|
77
|
-
/** Resolves
|
|
81
|
+
/** Resolves after connection and the initial load, when supplied; rejects with a Refusal (`boot_failed`, `connect_timeout`, ...).
|
|
82
|
+
* This promise is not replaced on reconnect. Once rejected, it stays rejected even if a late connection or a later load succeeds.
|
|
83
|
+
* Observe `connected` and use the handle to retry. */
|
|
78
84
|
readonly ready: Promise<MountedEditor>;
|
|
79
85
|
readonly connected: boolean;
|
|
80
86
|
/** The frame's Rapier version and contract, once connected; null before. */
|
|
@@ -94,6 +100,8 @@ export interface MountedEditor {
|
|
|
94
100
|
close(): Promise<CloseResult>;
|
|
95
101
|
theme(value: Theme): Promise<void>;
|
|
96
102
|
style(value: ReaderStyle): Promise<void>;
|
|
103
|
+
/** Ends this handle permanently, even while detached. Rejects pending work and removes a helper-created iframe.
|
|
104
|
+
* An iframe supplied by the host remains. This does not save or discard the document. */
|
|
97
105
|
disconnect(): void;
|
|
98
106
|
/** Returns an unsubscribe function. */
|
|
99
107
|
on<K extends keyof EditorEvents>(type: K, listener: (value: EditorEvents[K]) => void): () => void;
|
|
@@ -127,8 +135,8 @@ export class RapierEditor extends HTMLElement {
|
|
|
127
135
|
checkValidity(): boolean;
|
|
128
136
|
reportValidity(): boolean;
|
|
129
137
|
setCustomValidity(message: string): void;
|
|
130
|
-
/** Captures the editor's latest source into value. */
|
|
131
|
-
save(): Promise<
|
|
138
|
+
/** Captures the editor's latest source into value and resolves that exact string. Field memory is not a durable server save. */
|
|
139
|
+
save(): Promise<string>;
|
|
132
140
|
}
|
|
133
141
|
/** Defines <rapier-editor> once; returns the class. */
|
|
134
142
|
export function defineRapierEditor(registry?: CustomElementRegistry): typeof RapierEditor;
|