@lupinum/ginko-editor 0.1.0 → 0.18.0

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.
Files changed (166) hide show
  1. package/CHANGELOG.md +7 -73
  2. package/LICENSE +1 -1
  3. package/README.md +15 -340
  4. package/dist/assets.d.ts +70 -0
  5. package/dist/assets.js +31 -0
  6. package/dist/core/component-props.d.ts +87 -0
  7. package/dist/core/component-props.js +134 -0
  8. package/dist/core/convert.d.ts +24 -0
  9. package/dist/core/convert.js +278 -0
  10. package/dist/core/editor.d.ts +60 -0
  11. package/dist/core/editor.js +85 -0
  12. package/dist/core/extensions.d.ts +38 -0
  13. package/dist/core/extensions.js +444 -0
  14. package/dist/core/file-images.d.ts +9 -0
  15. package/dist/core/file-images.js +54 -0
  16. package/dist/core/image-frame.d.ts +23 -0
  17. package/dist/core/image-frame.js +24 -0
  18. package/dist/core/index.d.ts +17 -0
  19. package/dist/core/index.js +17 -0
  20. package/dist/core/link-card.d.ts +20 -0
  21. package/dist/core/link-card.js +70 -0
  22. package/dist/core/link.d.ts +3 -0
  23. package/dist/core/link.js +8 -0
  24. package/dist/core/move.d.ts +11 -0
  25. package/dist/core/move.js +37 -0
  26. package/dist/core/paste-html.d.ts +6 -0
  27. package/dist/core/paste-html.js +384 -0
  28. package/dist/core/paste.d.ts +21 -0
  29. package/dist/core/paste.js +108 -0
  30. package/dist/core/problems.d.ts +31 -0
  31. package/dist/core/problems.js +54 -0
  32. package/dist/core/search.d.ts +47 -0
  33. package/dist/core/search.js +148 -0
  34. package/dist/core/slash.d.ts +93 -0
  35. package/dist/core/slash.js +215 -0
  36. package/dist/core/table.d.ts +34 -0
  37. package/dist/core/table.js +141 -0
  38. package/dist/core/uploads.d.ts +23 -0
  39. package/dist/core/uploads.js +71 -0
  40. package/dist/core/use-editor.d.ts +19 -0
  41. package/dist/core/use-editor.js +53 -0
  42. package/dist/index.d.ts +6 -15
  43. package/dist/index.js +6 -5668
  44. package/dist/issues.d.ts +49 -0
  45. package/dist/issues.js +9 -0
  46. package/dist/today.d.ts +6 -0
  47. package/dist/today.js +19 -0
  48. package/dist/useUpload.d.ts +48 -0
  49. package/dist/useUpload.js +59 -0
  50. package/dist/values.d.ts +14 -0
  51. package/dist/values.js +36 -0
  52. package/package.json +35 -95
  53. package/dist/GinkoEditor.vue.d.ts +0 -96
  54. package/dist/GinkoImagePicker.vue.d.ts +0 -36
  55. package/dist/agent/AGENTS.md +0 -13
  56. package/dist/agent/pages/docs/getting-started/collaboration.md +0 -435
  57. package/dist/agent/pages/docs/getting-started/component-coverage.md +0 -107
  58. package/dist/agent/pages/docs/getting-started/customize.md +0 -384
  59. package/dist/agent/pages/docs/getting-started/images.md +0 -188
  60. package/dist/agent/pages/docs/getting-started/in-place-editing.md +0 -110
  61. package/dist/agent/pages/docs/getting-started/layout-blocks.md +0 -148
  62. package/dist/agent/pages/docs/getting-started/runtime.md +0 -111
  63. package/dist/agent/pages/docs/getting-started.md +0 -128
  64. package/dist/authoring-D7MJezVG.js +0 -1780
  65. package/dist/authoring-D7MJezVG.js.map +0 -1
  66. package/dist/authoring.d.ts +0 -122
  67. package/dist/authoring.js +0 -2
  68. package/dist/collaboration.d.ts +0 -14
  69. package/dist/collaboration.js +0 -907
  70. package/dist/collaboration.js.map +0 -1
  71. package/dist/composables/useAssetRequests.d.ts +0 -44
  72. package/dist/composables/useCollaborationBinding.d.ts +0 -59
  73. package/dist/composables/useDevice.d.ts +0 -10
  74. package/dist/composables/useInsertMenu.d.ts +0 -67
  75. package/dist/composables/useMarkdownSync.d.ts +0 -96
  76. package/dist/composables/useStableAuthoringKit.d.ts +0 -16
  77. package/dist/documentConfig-Z6LdrWZj.js +0 -2360
  78. package/dist/documentConfig-Z6LdrWZj.js.map +0 -1
  79. package/dist/editorProps.d.ts +0 -124
  80. package/dist/index.js.map +0 -1
  81. package/dist/layout-kit.d.ts +0 -922
  82. package/dist/lib/collaboration/presence-record.d.ts +0 -18
  83. package/dist/lib/collaboration/presence.d.ts +0 -103
  84. package/dist/lib/collaboration/protocol.d.ts +0 -133
  85. package/dist/lib/collaboration/recovery.d.ts +0 -45
  86. package/dist/lib/collaboration/session.d.ts +0 -163
  87. package/dist/lib/collaboration/validation.d.ts +0 -42
  88. package/dist/lib/component-converters.d.ts +0 -119
  89. package/dist/lib/config/documentConfig.d.ts +0 -19
  90. package/dist/lib/config/editorConfig.d.ts +0 -38
  91. package/dist/lib/container-items.d.ts +0 -55
  92. package/dist/lib/conversionInvariants.d.ts +0 -3
  93. package/dist/lib/conversionLogger.d.ts +0 -10
  94. package/dist/lib/conversionPipeline.d.ts +0 -17
  95. package/dist/lib/conversionState.d.ts +0 -10
  96. package/dist/lib/conversionTypes.d.ts +0 -50
  97. package/dist/lib/editor-operations.d.ts +0 -39
  98. package/dist/lib/environment.d.ts +0 -6
  99. package/dist/lib/extensions/code-block.d.ts +0 -18
  100. package/dist/lib/extensions/component-boundary.d.ts +0 -9
  101. package/dist/lib/extensions/container-items.d.ts +0 -29
  102. package/dist/lib/extensions/element.d.ts +0 -19
  103. package/dist/lib/extensions/file.d.ts +0 -24
  104. package/dist/lib/extensions/heading.d.ts +0 -5
  105. package/dist/lib/extensions/image-upload.d.ts +0 -39
  106. package/dist/lib/extensions/image.d.ts +0 -39
  107. package/dist/lib/extensions/index.d.ts +0 -10
  108. package/dist/lib/extensions/inline-element.d.ts +0 -13
  109. package/dist/lib/extensions/markdown-clipboard.d.ts +0 -21
  110. package/dist/lib/extensions/profile.d.ts +0 -11
  111. package/dist/lib/extensions/slot.d.ts +0 -16
  112. package/dist/lib/extensions/span-style.d.ts +0 -15
  113. package/dist/lib/extensions/video.d.ts +0 -15
  114. package/dist/lib/image-properties.d.ts +0 -20
  115. package/dist/lib/input-rules.d.ts +0 -7
  116. package/dist/lib/markdown.d.ts +0 -11
  117. package/dist/lib/marks.d.ts +0 -7
  118. package/dist/lib/mdcToTiptap.d.ts +0 -20
  119. package/dist/lib/mdcTypes.d.ts +0 -20
  120. package/dist/lib/nodes.d.ts +0 -57
  121. package/dist/lib/nodeviews/block-actions.d.ts +0 -7
  122. package/dist/lib/nodeviews/code.d.ts +0 -4
  123. package/dist/lib/nodeviews/columns.d.ts +0 -17
  124. package/dist/lib/nodeviews/component.d.ts +0 -6
  125. package/dist/lib/nodeviews/icons.d.ts +0 -26
  126. package/dist/lib/nodeviews/image.d.ts +0 -9
  127. package/dist/lib/nodeviews/items.d.ts +0 -15
  128. package/dist/lib/nodeviews/lifecycle.d.ts +0 -45
  129. package/dist/lib/nodeviews/popover.d.ts +0 -15
  130. package/dist/lib/nodeviews/settings.d.ts +0 -11
  131. package/dist/lib/nodeviews/table-operations.d.ts +0 -50
  132. package/dist/lib/nodeviews/table.d.ts +0 -4
  133. package/dist/lib/profiles.d.ts +0 -62
  134. package/dist/lib/property-input.d.ts +0 -10
  135. package/dist/lib/property-step.d.ts +0 -77
  136. package/dist/lib/props.d.ts +0 -13
  137. package/dist/lib/stripStyleNodes.d.ts +0 -2
  138. package/dist/lib/tiptapToMdc.d.ts +0 -18
  139. package/dist/presence-record-CLdPZWKC.js +0 -291
  140. package/dist/presence-record-CLdPZWKC.js.map +0 -1
  141. package/dist/runtime.d.ts +0 -13
  142. package/dist/runtime.js +0 -3
  143. package/dist/style.css +0 -2
  144. package/dist/types.d.ts +0 -126
  145. package/dist/ui/GinkoActionButton.vue.d.ts +0 -8
  146. package/dist/ui/GinkoInsertMenu.vue.d.ts +0 -49
  147. package/dist/ui/GinkoKeyboardDock.vue.d.ts +0 -15
  148. package/dist/ui/GinkoNodePopover.vue.d.ts +0 -21
  149. package/dist/ui/GinkoRecipeIcon.vue.d.ts +0 -6
  150. package/dist/ui/GinkoSelectionToolbar.vue.d.ts +0 -10
  151. package/dist/ui/GinkoToolbar.vue.d.ts +0 -26
  152. package/dist/ui/GinkoToolbarIcon.vue.d.ts +0 -6
  153. package/dist/ui/block-shortcuts.d.ts +0 -6
  154. package/dist/ui/commands.d.ts +0 -78
  155. package/dist/ui/context.d.ts +0 -23
  156. package/dist/ui/editor-keyboard.d.ts +0 -15
  157. package/dist/ui/messages.d.ts +0 -214
  158. package/dist/ui/messages.de.d.ts +0 -6
  159. package/dist/ui/recipe-command.d.ts +0 -14
  160. package/dist/ui/recipe-search.d.ts +0 -47
  161. package/dist/ui/slash-command.d.ts +0 -17
  162. package/dist/ui/writingRecipes.d.ts +0 -13
  163. package/skills/ginko-editor/SKILL.md +0 -40
  164. package/skills/ginko-editor/agents/openai.yaml +0 -4
  165. package/skills/ginko-editor/references/in-place-editing.md +0 -50
  166. package/skills/ginko-editor/references/quickstart.md +0 -55
@@ -1,435 +0,0 @@
1
- ---
2
- title: "Share an editing session"
3
- description: "Connect the Vue editor to a host-owned, versioned document service."
4
- url: "https://ginko-editor.lupinum.com/docs/getting-started/collaboration"
5
- route: "/docs/getting-started/collaboration"
6
- locale: "en"
7
- section: "Documentation"
8
- collection: "docs"
9
- source: "ginko-content"
10
- ---
11
-
12
- > Connect the Vue editor to a host-owned, versioned document service.
13
-
14
- # Share an editing session
15
-
16
- <warning title="Experimental API">
17
- The collaboration API is experimental in version 1.0. A minor release can
18
- change it. Pin the exact Editor version on the client and the server, and read
19
- the changelog before you update.
20
- </warning>
21
-
22
- Ginko Editor can share a document through a host transport. It uses ProseMirror
23
- operations to merge text changes. The host owns authentication, authorization,
24
- storage, recovery files, and publication. The editor does not open a Convex
25
- connection or create accounts.
26
-
27
- The package provides two boundaries:
28
-
29
- - `@lupinum/ginko-editor/collaboration`: a Vue-compatible editing session,
30
- its state and error types, recovery helpers, and presence types.
31
- - `@lupinum/ginko-editor/runtime`: the shared schema, the protocol and
32
- transport types, strict operation decoding, and server checkpoint
33
- validation. This entry does not import Vue views or browser globals.
34
-
35
- Import transport types such as `CollaborationTransport` and
36
- `CollaborationHead` from `@lupinum/ginko-editor/runtime`. Use `import type` in
37
- browser code so the bundle does not include server validation.
38
-
39
- Use the same Editor package and Content policy on the client and server. A
40
- schema revision identifies the document schema and the operation format. A
41
- protocol version identifies the message envelope. A policy revision
42
- identifies the host's permitted components and properties. An epoch
43
- identifies one generation of a document. Replacing a document starts a new
44
- epoch.
45
-
46
- ## Migrate an existing host
47
-
48
- CMS, Luis and Chili hosts built against an earlier candidate must update the
49
- client, backend and stored rooms together. A dependency version change alone
50
- does not migrate a room.
51
-
52
- 1. Import `CollaborationTransport`, heads, snapshots and operation types from
53
- `/runtime`. Keep Vue session and recovery imports on `/collaboration`.
54
- 2. Adapt the host's authorized open and head-query functions, plus the
55
- transport's `subscribe`, `pull` and `push` methods. Current clients include
56
- `protocolVersion: 1` in pull and push requests. Add an optional literal `1`
57
- to strict argument, return and stored-snapshot validators. An absent value
58
- means protocol 1; any other value is unsupported. Never remove the field
59
- from a browser batch just to bypass a strict validator.
60
- 3. Inspect stored room metadata before enabling the new client. The current
61
- schema revision is `ginko-editor-2`. Adding protocol metadata to a room
62
- with the same document schema does not require discarding its history.
63
- An older schema needs the [schema replacement procedure](#change-the-schema-revision)
64
- below: use the accepted source checkpoint, a new epoch and version 0.
65
- Do not relabel an old document or operation log with the new revision.
66
- 4. Preserve pending browser recovery before replacing a room. Use
67
- `readCollaborationRecovery()` to offer converted Markdown after a schema
68
- change. A `current` result only confirms the schema: compare its epoch and
69
- policy fence with the opened snapshot too. If an epoch reset made otherwise
70
- current operations stale, use `collaborationRecoveryToMarkdown()` for a
71
- deliberate merge. Keep the raw recovery if conversion fails. Never reset a room from an
72
- unconfirmed browser source preview. Keep the canonical accepted draft and
73
- published content available throughout the migration.
74
- 5. Preserve classified failures at the transport boundary. If a host wrapper
75
- stores the original failure in `Error.cause`, expose its known classification
76
- on the thrown error. The session reads the top-level `code`, `data.code` or
77
- HTTP status; it does not search a cause chain. An `Error` with `status: 403`
78
- means revoked access; `status: 503` means a temporary service failure.
79
- Use `CollaborationError('content', message)` or
80
- `CollaborationError('invalid', message)` for rejected writes. Do not pass
81
- `forbidden` or `unavailable` to that constructor: they are session failure
82
- classifications, not runtime error codes. Do not turn a permission failure
83
- into an automatic retry.
84
- 6. Test with two independent authenticated users against the actual host.
85
- Verify simultaneous typing, a lost push response and retry, reload,
86
- revocation with pending edits, an old stored room, an old recovery copy,
87
- and switching or publishing while edits are pending. Publication still
88
- compares the accepted epoch and version after `flush()`.
89
-
90
- For strict Convex validators, use `v.optional(v.literal(1))` for protocol
91
- metadata. Keep authorization in the host's query or mutation and persist the
92
- accepted snapshot, operations and source checkpoint in one transaction.
93
- Presence is a separate optional transport channel; a passing text-convergence
94
- test does not prove that cursors or selection sharing work.
95
-
96
- ## Keep component source origins
97
-
98
- Adopt Content's angle authoring default together with the Editor origin fix
99
- on both client and backend. New command insertions record angle syntax.
100
- Explicit `::component` and `:component[text]` input records colon syntax.
101
- Parsed components retain their authored form.
102
-
103
- Older command-created room nodes can have no `props.$` origin. Editor keeps
104
- the colon serialization default for those nodes, so an unrelated edit does
105
- not rewrite their source. The room JSON and operation history stay intact.
106
- Do not remove this fallback merely because a room has the current schema.
107
-
108
- After all old writers retire, the host can reseed these rooms once from the
109
- accepted canonical Markdown with a new epoch and version 0. Preserve pending
110
- recovery and backups as described above. Verify source equality and an
111
- unrelated edit before retiring the fallback. No room migration runs when the
112
- library is installed.
113
-
114
- ## Mount one session
115
-
116
- The host first opens an authorized document and obtains its current snapshot.
117
- It supplies three transport operations: subscribe to the current head, pull
118
- accepted operations, and push a batch at an exact version.
119
-
120
- ```ts
121
- import { createEditorCollaboration } from '@lupinum/ginko-editor/collaboration'
122
-
123
- const session = createEditorCollaboration({
124
- snapshot: opened.snapshot,
125
- clientId: opened.clientPrefix + crypto.randomUUID(),
126
- transport,
127
- recovery: savedRecovery,
128
- onRecovery(value) {
129
- if (value) sessionStorage.setItem(recoveryKey, JSON.stringify(value))
130
- else sessionStorage.removeItem(recoveryKey)
131
- },
132
- })
133
- ```
134
-
135
- ```vue
136
- <GinkoEditor
137
- v-model="sourcePreview"
138
- :collaboration="session"
139
- :authoring-kit="authoringKit"
140
- />
141
- ```
142
-
143
- Keep the session in a `shallowRef` or an ordinary variable. Do not make its
144
- internal editor state deeply reactive. One session belongs to one mounted
145
- editor. Create a new session and remount when switching documents, epochs, or
146
- content policies. During normal navigation, await `flush()` before leaving;
147
- keep the editor mounted if flush fails. Access revocation or a principal change
148
- must stop the old transport even when flush fails. Retain its recovery under
149
- the original principal so a different account cannot resume those pending edits.
150
-
151
- In shared mode, the session snapshot supplies the initial document. `v-model`
152
- receives a source preview. Changes to that prop do not replace the shared
153
- document. Source view is read-only. A successful `flush()` means all pending
154
- operations have been accepted and the local source preview is current. It does
155
- not publish content. Another writer can still edit after the flush.
156
-
157
- The default status shows connecting, saving, saved, offline, and recovery
158
- states. The `collaboration` slot receives `state` and `session` if the host
159
- needs its own status control. Use `session.subscribe()` for application state
160
- and call the returned cleanup function when the host unmounts.
161
-
162
- ## Handle connection and server failures
163
-
164
- `session.state.code` gives the reason for an `offline`, `error`, or `stale`
165
- status:
166
-
167
- | Code | Status | Meaning and host action |
168
- | --- | --- | --- |
169
- | `offline`, `timeout`, `unavailable` | `offline` | The session keeps local edits and retries automatically. |
170
- | `rejected` | `error` | The server refused the unsent changes. Offer `discardPendingAndResync()`. |
171
- | `forbidden` | `error` | Access was revoked. Keep the recovery copy and close the editor. |
172
- | `conflict`, `internal` | `error` | The server history is inconsistent. Offer `retry()` and the recovery download. |
173
- | `storage` | `error` | `onRecovery` threw. Free storage, then call `retry()`. |
174
- | `schema_mismatch`, `policy_mismatch`, `replaced`, `history_expired` | `stale` | Keep the recovery copy and reopen the document. |
175
- | `limit` | any | A local change was refused because it is too large. |
176
-
177
- A transport signals a failure through the error it throws:
178
-
179
- - Throw `CollaborationConnectionError` when the network is not available.
180
- - Throw `new CollaborationError('forbidden', message)` for revoked access.
181
- - Throw `new CollaborationError('unavailable', message)` for a temporary
182
- server failure.
183
- - A server `CollaborationError` code, a `data.code` value such as Convex
184
- `ConvexError` data, or an HTTP `status` also classifies the failure. Status
185
- 408, 425, 429, and 5xx retry. Status 401 and 403 stop.
186
-
187
- Retries use full jitter: each wait is a random time up to a bound that
188
- doubles from 1 second to 30 seconds. A new server head or the browser
189
- `online` event ends the wait early. Each pull and push has a 15-second
190
- limit. Set `requestTimeoutMs` and `backoff` to change these values.
191
-
192
- `retry()` sends the same pending changes again. After a `rejected` state,
193
- call `discardPendingAndResync()`. It gives the unsent changes to `onDiscard`,
194
- removes them, and continues from the last accepted document. If `onDiscard`
195
- throws, the session keeps the changes. `flush()` rejects with a
196
- `CollaborationError` that has a `code`.
197
-
198
- ```ts
199
- const session = createEditorCollaboration({
200
- // ...
201
- onDiscard(recovery) {
202
- offerDownload(JSON.stringify(recovery))
203
- },
204
- })
205
-
206
- if (session.state.code === 'rejected') session.discardPendingAndResync()
207
- ```
208
-
209
- ## Validate each write
210
-
211
- The backend checks document access on every read and write. Do not trust a
212
- room ID, client ID, source preview, or snapshot supplied by a browser.
213
-
214
- ```ts
215
- import { applyCollaborationSteps } from '@lupinum/ginko-editor/runtime'
216
-
217
- const accepted = await applyCollaborationSteps(storedSnapshot, batch, {
218
- policy: hostPolicy,
219
- output: hostOutputOptions,
220
- })
221
-
222
- // In one database transaction:
223
- // 1. Store accepted.snapshot.
224
- // 2. Append the accepted operations and authenticated client identity.
225
- // 3. Store accepted.markdown with the same epoch and version.
226
- ```
227
-
228
- `applyCollaborationSteps()` rejects an incorrect version or document fence,
229
- an unknown protocol version, unknown operations, malformed positions, unknown
230
- schema attributes or marks, invalid attribute values, unsafe link URLs,
231
- unsupported metadata, and results outside the Content policy. It checks the
232
- result against the schema and derives Markdown from the accepted document. It
233
- never accepts a browser's Markdown checkpoint.
234
-
235
- Attribute values have fixed rules. For example, a heading level is a whole
236
- number from 1 to 6, code language and filename are one line of text, and a
237
- link target uses the same URL rules as Content: `https`, `mailto`, `tel`,
238
- local paths, and `#` anchors.
239
-
240
- Clients send `protocolVersion: 1` with pull and push requests. If your
241
- backend validates request arguments strictly, accept this optional field.
242
-
243
- Seed or replace a room with `createCollaborationSnapshot()`. It refuses source
244
- that requires source-only editing. A replacement must check the current fence
245
- and version in the same authorized transaction, then start a new epoch. Keep
246
- old published content until the host explicitly publishes the replacement.
247
-
248
- For Convex, query the current head reactively with `ConvexClient.onUpdate()` and
249
- use generated, typed query and mutation references for pull and push. Check
250
- the membership or document permission inside each function. Scope client IDs
251
- to the authenticated member and add a random identifier for each session.
252
- Return accepted operations after a version conflict so the editor can rebase
253
- and retry. Do not use last-write-wins Markdown updates.
254
-
255
- The repository's `test/fixtures/convex-collaboration` directory contains an
256
- executable local example with signed test identities. It demonstrates
257
- authorization, bounded history reads, version conflicts, revocation,
258
- replacement, publication, and pruning. Its test authentication and membership
259
- tables are fixture code. Use the host application's real authentication and
260
- document permissions in an application.
261
-
262
- ## Store checkpoints and history separately
263
-
264
- Store the ProseMirror document as an encoded JSON string. Its nested tree must
265
- not become deeply nested database fields. Store the derived source in a
266
- separate record when the two representations could exceed the database's
267
- document-size limit. Both records carry the same epoch and version.
268
-
269
- The server snapshot is the authority for the active editing session. Markdown
270
- is a derived, versioned checkpoint for Content readers, export, and
271
- publication. It can be rebuilt from the snapshot. Do not independently edit
272
- both representations.
273
-
274
- Publish an exact `{ epoch, version }` checkpoint after checking that it is still
275
- current. Record the publication epoch as well as its version: version numbers
276
- restart after replacement. A failed comparison requires the host to refresh
277
- and show the newer draft.
278
-
279
- History queries must use an index and a bounded page. The provided protocol
280
- limits a document to 512 KiB, a batch to 256 KiB, and a batch to 128 operations.
281
- A client keeps each original transaction in one outgoing batch. Read pages
282
- must preserve operation order and return their actual start and end versions.
283
-
284
- Set an explicit retention policy in the host. Keep a minimum retained version.
285
- If a disconnected client needs older operations, return `status: 'stale'` with
286
- reason `history`. Do not silently discard its pending edits or substitute a new
287
- snapshot. Delete old log pages in bounded jobs. Replacing a document also
288
- requires eventual cleanup of the old epoch's log.
289
-
290
- ## Recover pending changes
291
-
292
- Supply `onRecovery` when unsent edits must survive reload. Persist the value
293
- synchronously in host-owned browser storage; throwing stops editing and keeps
294
- the current document available. The editor does not promise durable recovery
295
- when this callback is omitted.
296
-
297
- The session calls `onRecovery` at most once every 300 milliseconds while the
298
- user types. It also calls it immediately when the page is hidden or unloaded,
299
- and from `flushRecovery()`, `flush()`, `discardPendingAndResync()`, and
300
- `close()`. Set `recoveryDelayMs: 0` to write after every change. Remote
301
- changes do not write a recovery copy when there is no local work.
302
-
303
- A recovery copy includes the confirmed base, pending operations, transaction
304
- groups, and the resulting document. Reopening checks its format and document
305
- fence, then rebases pending operations over accepted server history. A lost
306
- acknowledgement does not duplicate an accepted operation.
307
-
308
- Use `readCollaborationRecovery(storedJson)` to read untrusted storage. It
309
- returns one of three results:
310
-
311
- - `current`: pass `result.recovery` to a new session. Session construction
312
- then checks the document, operations, limits, and fences.
313
- - `converted`: the copy uses another schema revision. Its operations cannot
314
- be rebased, so `result.markdown` contains the pending document as Markdown.
315
- Show it to the user for a manual merge.
316
- - `unreadable`: offer the stored text as a download.
317
-
318
- `parseCollaborationRecovery()` only checks the storage shape. Keep an invalid
319
- copy available for download; do not silently discard it or enable a fresh
320
- writable session over it.
321
-
322
- Only one live session may own a client ID. Browsers can copy `sessionStorage`
323
- when a tab is duplicated or opened from another tab. Claim an exclusive Web Lock
324
- for the client ID before opening either a new or recovered session, and release
325
- it after closing that session. If another tab owns the ID, offer the recovery
326
- download and a deliberate reopen with a new identity. Do not replay the same
327
- pending operations under a second identity.
328
-
329
- The client bounds recovery to 2,048 pending operations, 2 MiB of encoded
330
- operations, and a 4 MiB recovery budget for local changes. Rebased remote
331
- changes can enlarge a recovery file; reopening accepts up to 16 MiB. A local change that would
332
- exceed a limit is refused before replacing the local document. Reconnect to
333
- continue writing. The limits describe recovery capacity, not an offline-first
334
- database.
335
-
336
- Revoked access, a changed schema or policy, a new epoch, or expired history
337
- must remain visible. The default control can download the pending recovery
338
- JSON. Keep that copy before reopening or importing its content into a new
339
- document. Never apply old operations to a different epoch automatically.
340
-
341
- ## Change the schema revision
342
-
343
- `editorSchemaRevision` changes when an Editor release changes the document
344
- schema or an operation format. A test in this repository compares a
345
- fingerprint of the schema and operation types with a recorded revision, so a
346
- schema change cannot ship without a new revision.
347
-
348
- Clients and rooms with different revisions cannot exchange operations. Use
349
- this procedure when you deploy a release with a new revision:
350
-
351
- 1. Deploy the new Editor package to the server and the browser together.
352
- 2. For each room with the old revision, read its accepted Markdown checkpoint
353
- in one authorized transaction.
354
- 3. Call `createCollaborationSnapshot(markdown, { epoch: newEpoch, policy, policyRevision })`. Store the new snapshot with version 0, a new epoch, and
355
- the new revision. Reset the minimum retained version.
356
- 4. Keep the published content until the host publishes again.
357
- 5. Delete the old epoch's operation log in bounded jobs.
358
-
359
- You can also run steps 2 and 3 when a user opens a room with the old
360
- revision. Old browser sessions become `stale`. Their recovery copies return
361
- `converted` from `readCollaborationRecovery()`; show the Markdown so the user
362
- can merge it by hand.
363
-
364
- ## Understand concurrent controls
365
-
366
- Body text merges through ProseMirror. Component controls change individual
367
- properties. Independent properties preserve each other; two changes to the
368
- same property use the last accepted operation. Titles in separate property
369
- inputs are field updates, not character-level shared text. Code language and
370
- filename controls also update separate fields. Image replacement preserves
371
- unrelated properties, including another writer's description.
372
-
373
- Shared tables support cell editing and inserting, deleting, or
374
- duplicating body rows. Column layout, alignment changes, and row moves are disabled during a shared
375
- session. ProseMirror does not preserve pending edits through arbitrary node
376
- moves, and concurrent row and column layout changes can produce incompatible
377
- rectangles. Local tables retain their full controls. Merged cells and custom
378
- cell widths are rejected because the Content checkpoint cannot preserve them.
379
-
380
- ## Show other collaborators
381
-
382
- Presence is optional. Add a `presence` channel to the transport to show other
383
- collaborators' carets and selections. Presence records are separate from
384
- document operations. Do not treat a caret as proof that a writer's changes
385
- have been accepted.
386
-
387
- ```ts
388
- import type { CollaborationTransport } from '@lupinum/ginko-editor/runtime'
389
-
390
- const transport: CollaborationTransport = {
391
- subscribe, pull, push,
392
- presence: {
393
- publish: update => client.mutation(api.rooms.publishPresence, { roomId, update }).then(() => {}),
394
- subscribe: onPeers => client.onUpdate(api.rooms.presence, { roomId }, onPeers),
395
- leave: clientId => client.mutation(api.rooms.leavePresence, { roomId, clientId }).then(() => {}),
396
- },
397
- }
398
-
399
- const session = createEditorCollaboration({
400
- // ...
401
- transport,
402
- user: { name: account.displayName, color: account.color },
403
- })
404
- ```
405
-
406
- The session publishes its selection when it changes, at most every 100
407
- milliseconds, and again every 10 seconds. Positions refer to the last
408
- accepted document version, which the record includes. The session maps other
409
- collaborators' positions through accepted operations and through its own
410
- unsent operations before it shows them. It hides a selection that it cannot
411
- map yet. It removes a collaborator after 30 seconds without a new record.
412
- Without `user`, the session shows others but does not publish. Set
413
- `presence: false` to turn presence off.
414
-
415
- `session.extension` shows the carets. Each caret has a name label that is
416
- hidden from assistive technology. Show a collaborator list for screen reader
417
- users from `session.peers` and `session.onPeersChange()`:
418
-
419
- ```ts
420
- const peers = shallowRef(session.peers)
421
- const stopPeers = session.onPeersChange(value => { peers.value = value })
422
- ```
423
-
424
- Style the carets with the `.ginko-collab-caret`,
425
- `.ginko-collab-caret__label`, and `.ginko-collab-selection` classes. Each
426
- caret and selection sets `--ginko-collab-color`.
427
-
428
- On the server, check document access for every presence read and write. Use
429
- `readCollaborationPresence()` from the runtime entry to validate the record.
430
- Check that the client ID belongs to the member. Take the display name from
431
- the account, not from the browser. Set `updatedAt` to the server time and
432
- delete records that have not changed for 30 seconds. The
433
- `test/fixtures/convex-collaboration` example stores presence in its own
434
- table, reads only records that have not expired, and deletes expired records
435
- with a scheduled function.
@@ -1,107 +0,0 @@
1
- ---
2
- title: "Component coverage"
3
- description: "See which components have an editing contract and how unsupported source is preserved."
4
- url: "https://ginko-editor.lupinum.com/docs/getting-started/component-coverage"
5
- route: "/docs/getting-started/component-coverage"
6
- locale: "en"
7
- section: "Documentation"
8
- collection: "docs"
9
- source: "ginko-content"
10
- ---
11
-
12
- > See which components have an editing contract and how unsupported source is preserved.
13
-
14
- # Component coverage
15
-
16
- Ginko Content owns what a document means: component names, property values,
17
- slots, parent/child rules, and media references. Ginko Editor uses that contract
18
- to decide what it can edit without losing meaning. A host kit adds labels,
19
- controls, insertion recipes, and canvas hints. The host's renderer supplies the
20
- real reading preview.
21
-
22
- ## Built-in layout kit
23
-
24
- The editor exports `ginkoLayoutKitSource` from `@lupinum/ginko-editor/authoring`.
25
- Its policy is the Ginko Docs component policy. It contains 32 component tags and
26
- 26 recipes. A Ginko Docs site renders the same tags with its `Mdc*` components.
27
- See [Layout blocks](/raw/docs/getting-started/layout-blocks.md) for each block.
28
-
29
- | Docs tags | Visual authoring in the layout kit |
30
- | --- | --- |
31
- | `note`, `warning`, `error`, `success`, `idea`, `info` | Callout recipes, inline title, compatible variant switch, properties, and editable default content |
32
- | `aside`, `excerpt` | Recipes, inline label, properties, and editable default content |
33
- | `layout`, `column` | Two-column recipe; nested content; width and layout controls. A column must remain inside a layout. |
34
- | `tabs`, `tab`, `code-group` | Tab strip: select, add, rename, and remove items. One tab is visible at a time. |
35
- | `accordion`, `accordion-item` | Item titles on the canvas; items collapse in this view only; add and remove items |
36
- | `steps`, `cards`, `card`, `timeline`, `timeline-item`, `code-tree`, `quiz`, `quiz-question` | Numbered steps, card grids, timeline markers, and item lists with an add control |
37
- | `collapse`, `center`, `dropcap`, `figure`, `files`, `kbd`, `read-more`, `toc`, `api` | Recipes, properties, and editable default content. Structured properties use a JSON field. The canvas does not imitate their reading layout. |
38
- | `img` | Native editor image handling; the host supplies storage and URL resolution. This is separate from the kit. |
39
-
40
- Rendering support is not visual editing support. The canvas is a stable writing
41
- view. It is not an exact copy of interactive tabs, quizzes, or other reading
42
- components. Expand a kit only after its implementation metadata, Content policy,
43
- recipe validation, and edit/reload checks agree.
44
-
45
- ## Titles, properties, and columns
46
-
47
- Canvas title fields write the existing declared property. A populated title
48
- slot keeps its rich content instead of being flattened into a text property.
49
- Variant changes preserve properties and children and must pass the full Content
50
- policy. An incompatible switch leaves the document unchanged.
51
-
52
- Column presets are exactly Small / Large, Medium / Medium, and Large / Small.
53
- The divider changes both widths as one undoable edit. Imported custom widths
54
- and layouts with another number of columns remain unchanged on opening. The
55
- editor does not infer heading sections or restructure a document automatically.
56
-
57
- ## Host components and named slots
58
-
59
- A host can combine its own source with the layout kit through
60
- `composeAuthoringKits`. This function validates the combined kit. Use
61
- `createAuthoringKit` to validate a single source. The builder
62
- checks implementation metadata against the policy and validates every recipe.
63
- It freezes the provided configuration before asynchronous validation starts;
64
- pass a fresh object if the host needs an editable configuration draft.
65
-
66
- Declare named slots in both the implementation metadata and Content policy.
67
- Authoring metadata can give each slot a readable label. The editor preserves
68
- separate default and named content through visual edits and source conversion.
69
- The playground's `learning-objective` component demonstrates `default` and `tip`:
70
-
71
- ```mdc
72
- <learning-objective title="Understand the contract" assessed>
73
- Explain the outcome.
74
-
75
- <template #tip>
76
- Keep the example concrete.
77
- </template>
78
- </learning-objective>
79
- ```
80
-
81
- This is a host example, not a built-in Docs tag. The layout kit keeps the named
82
- slots of cards and accordion items in the document, but the canvas edits only
83
- their default slots and their text properties.
84
-
85
- ## Source safety and preview
86
-
87
- The canonical value is Markdown/MDC source, not TipTap JSON. The editor opens
88
- visual mode only after parsing, schema conversion, and a semantic round-trip
89
- check succeed. Unsupported or invalid documents stay in Markdown with their
90
- original source available. Opening, closing, or changing modes does not rewrite
91
- source. A real visual edit may normalize formatting while preserving meaning.
92
-
93
- Unsupported paste leaves the current document unchanged. A failed conversion
94
- keeps pending visual work and blocks switching to Markdown until the author can
95
- recover. Hosts must respect a failed `flush()` before closing or changing the
96
- document.
97
-
98
- The `recipe-preview` slot receives `{ recipe }`. Render `recipe.source` through
99
- Ginko Content with the same policy and registered host components. This shows
100
- the actual reading component; the stable writing canvas is not an exact copy of
101
- interactive tabs, quizzes, or other application UI. A renderer preview cannot
102
- make unsupported visual editing safe.
103
-
104
- Native Markdown tables keep their first row as a header and support column
105
- alignment. Merged cells and persisted column widths are outside that contract.
106
- HTML, arbitrary Vue expressions, and arbitrary editor extension injection are
107
- not an escape route around Content validation.