@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 +0,0 @@
1
- {"version":3,"file":"collaboration.js","names":[],"sources":["../src/lib/collaboration/presence.ts","../src/lib/collaboration/session.ts","../src/lib/collaboration/recovery.ts"],"sourcesContent":["import type { Node } from '@tiptap/pm/model'\nimport type { EditorState } from '@tiptap/pm/state'\nimport { Mapping, type StepMap } from '@tiptap/pm/transform'\nimport { Decoration, DecorationSet } from '@tiptap/pm/view'\nimport { getVersion, sendableSteps } from 'prosemirror-collab'\nimport {\n collaborationProtocolVersion,\n type CollaborationPresenceChannel, type CollaborationPresenceSelection, type CollaborationPresenceUpdate, type CollaborationUser,\n} from './protocol'\nimport { readCollaborationPresence, sanitizeCollaborationUser } from './presence-record'\n\n/**\n * A remote collaborator, with its selection mapped into this editor's current document.\n * @experimental\n */\nexport interface CollaborationPeer {\n clientId: string\n user: { id?: string; name: string; color: string }\n /** Null when the peer has no selection or its document version cannot be mapped yet. */\n selection: CollaborationPresenceSelection | null\n /** Confirmed document version that the peer reported. */\n version: number\n updatedAt: number\n}\n\n/** @experimental */\nexport interface CollaborationPresenceOptions {\n /** Minimum time between two published updates. Default: 100 ms. */\n throttleMs?: number\n /** Republish an unchanged state after this time. Default: 10 s. */\n heartbeatMs?: number\n /** Remove peers that sent no new state for this time. Default: 30 s. */\n expiryMs?: number\n /** Hide a peer's selection when it is more confirmed steps behind this editor. Default: 256. */\n maxVersionLag?: number\n}\n\n/** Recent confirmed step maps, so a peer's older positions can be mapped forward. */\nexport class ConfirmedHistory {\n private maps: StepMap[] = []\n constructor(private start: number, private readonly limit = 512) {}\n\n get end() { return this.start + this.maps.length }\n\n append(fromVersion: number, maps: readonly StepMap[]) {\n if (fromVersion !== this.end) { this.start = fromVersion; this.maps = [] }\n this.maps.push(...maps)\n if (this.maps.length > this.limit) {\n const removed = this.maps.length - this.limit\n this.maps.splice(0, removed)\n this.start += removed\n }\n }\n\n reset(version: number) { this.start = version; this.maps = [] }\n\n /** Mapping from `from` to `to`, or null when the history no longer covers it. */\n mapping(from: number, to: number) {\n if (from < this.start || to > this.end || from > to) return null\n return new Mapping(this.maps.slice(from - this.start, to - this.start))\n }\n}\n\n/** Map a local selection back to the confirmed document, before unconfirmed steps. */\nexport function toConfirmedSelection(state: EditorState, confirmedSize: number): CollaborationPresenceSelection {\n let { anchor, head } = state.selection\n const pending = sendableSteps(state)\n if (pending) {\n const inverse = new Mapping(pending.steps.map(step => step.getMap())).invert()\n anchor = inverse.map(anchor, -1)\n head = inverse.map(head, -1)\n }\n return { anchor: clamp(anchor, confirmedSize), head: clamp(head, confirmedSize) }\n}\n\nfunction clamp(value: number, size: number) {\n return Math.max(0, Math.min(size, value))\n}\n\n/**\n * Map a remote selection from its confirmed version into the local document:\n * first through accepted steps this editor has received since that version,\n * then through this editor's unconfirmed steps.\n */\nexport function toLocalSelection(state: EditorState, history: ConfirmedHistory, selection: CollaborationPresenceSelection,\n version: number, maxVersionLag: number): CollaborationPresenceSelection | null {\n const local = getVersion(state)\n if (version > local || local - version > maxVersionLag) return null\n const mapping = new Mapping()\n if (version < local) {\n const confirmed = history.mapping(version, local)\n if (!confirmed) return null\n mapping.appendMapping(confirmed)\n }\n const pending = sendableSteps(state)\n if (pending) for (const step of pending.steps) mapping.appendMap(step.getMap())\n const size = state.doc.content.size\n return { anchor: clamp(mapping.map(selection.anchor), size), head: clamp(mapping.map(selection.head), size) }\n}\n\nfunction caretWidget(peer: CollaborationPeer) {\n return () => {\n const caret = document.createElement('span')\n caret.className = 'ginko-collab-caret'\n caret.setAttribute('aria-hidden', 'true')\n caret.setAttribute('contenteditable', 'false')\n caret.style.setProperty('--ginko-collab-color', peer.user.color)\n if (peer.user.name) {\n const label = document.createElement('span')\n label.className = 'ginko-collab-caret__label'\n label.textContent = peer.user.name\n caret.append(label)\n }\n return caret\n }\n}\n\n/** Build remote carets and selection highlights. Labels are hidden from assistive technology. */\nexport function peerDecorations(doc: Node, peers: readonly CollaborationPeer[]) {\n const decorations: Decoration[] = []\n for (const peer of peers) {\n if (!peer.selection) continue\n const { anchor, head } = peer.selection\n const from = Math.min(anchor, head), to = Math.max(anchor, head)\n if (from !== to) {\n decorations.push(Decoration.inline(from, to, { class: 'ginko-collab-selection',\n style: `--ginko-collab-color: ${peer.user.color}` }, { peer: peer.clientId }))\n }\n decorations.push(Decoration.widget(head, caretWidget(peer), { side: 10, ignoreSelection: true,\n key: `ginko-collab:${peer.clientId}:${peer.user.color}:${peer.user.name}` }))\n }\n return DecorationSet.create(doc, decorations)\n}\n\ninterface TrackedPeer { update: CollaborationPresenceUpdate; receivedAt: number }\n\ninterface PresenceTrackerOptions extends CollaborationPresenceOptions {\n clientId: string\n epoch: string\n channel: CollaborationPresenceChannel\n user?: CollaborationUser\n history: ConfirmedHistory\n getState: () => EditorState | undefined\n getConfirmedSize: () => number\n /** Ask the editor to redraw decorations. */\n redraw: () => void\n}\n\n/** Publishes local presence and tracks remote peers. Presence failures never affect editing. */\nexport class PresenceTracker {\n private readonly peersById = new Map<string, TrackedPeer>()\n private readonly listeners = new Set<(peers: readonly CollaborationPeer[]) => void>()\n private readonly user?: CollaborationPeer['user']\n private mapped: readonly CollaborationPeer[] = Object.freeze([])\n private cache?: { doc: Node; version: number; revision: number; peers: readonly CollaborationPeer[]; set: DecorationSet }\n private revision = 0\n private unsubscribe?: () => void\n private publishTimer?: ReturnType<typeof setTimeout>\n private heartbeat?: ReturnType<typeof setInterval>\n private expiry?: ReturnType<typeof setInterval>\n private dirty = false\n private lastPublishedAt = -Infinity\n private lastSent?: string\n private stopped = false\n\n constructor(private readonly options: PresenceTrackerOptions) {\n if (options.user) this.user = sanitizeCollaborationUser(options.user, options.clientId)\n }\n\n private get throttleMs() { return this.options.throttleMs ?? 100 }\n private get heartbeatMs() { return this.options.heartbeatMs ?? 10_000 }\n private get expiryMs() { return this.options.expiryMs ?? 30_000 }\n private get maxVersionLag() { return this.options.maxVersionLag ?? 256 }\n\n start() {\n try {\n this.unsubscribe = this.options.channel.subscribe(updates => { this.receive(updates) })\n } catch { /* Presence is optional. */ }\n if (this.user) {\n this.heartbeat = setInterval(() => { this.publish(true) }, this.heartbeatMs)\n this.changed()\n }\n this.expiry = setInterval(() => { this.expire() }, Math.max(250, Math.min(5000, this.expiryMs / 3)))\n }\n\n /** Stop presence. `redraw` removes remote carets from a live editor. */\n stop(redraw = false) {\n if (this.stopped) return\n this.stopped = true\n clearTimeout(this.publishTimer)\n clearInterval(this.heartbeat)\n clearInterval(this.expiry)\n try { this.unsubscribe?.() } catch { /* Presence is optional. */ }\n if (this.user) {\n try { void Promise.resolve(this.options.channel.leave?.(this.options.clientId)).catch(() => {}) } catch { /* Presence is optional. */ }\n }\n this.peersById.clear()\n this.update()\n this.listeners.clear()\n if (redraw) this.options.redraw()\n }\n\n get peers() { return this.mapped }\n\n onPeersChange(listener: (peers: readonly CollaborationPeer[]) => void) {\n this.listeners.add(listener)\n listener(this.mapped)\n return () => { this.listeners.delete(listener) }\n }\n\n /** Call after any local selection, document or version change. */\n changed() {\n if (!this.user || this.stopped) return\n this.dirty = true\n if (this.publishTimer) return\n const wait = Math.max(0, this.lastPublishedAt + this.throttleMs - Date.now())\n this.publishTimer = setTimeout(() => {\n this.publishTimer = undefined\n if (this.dirty) this.publish(false)\n }, wait)\n }\n\n private publish(force: boolean) {\n const state = this.options.getState()\n if (!this.user || this.stopped || !state) return\n this.dirty = false\n const selection = toConfirmedSelection(state, this.options.getConfirmedSize())\n const update: CollaborationPresenceUpdate = { protocolVersion: collaborationProtocolVersion, clientId: this.options.clientId,\n user: this.user, epoch: this.options.epoch, version: getVersion(state), selection, updatedAt: Date.now() }\n const key = JSON.stringify([update.version, selection, this.user])\n if (!force && key === this.lastSent) return\n this.lastSent = key\n this.lastPublishedAt = update.updatedAt\n try { void Promise.resolve(this.options.channel.publish(update)).catch(() => {}) } catch { /* Presence is optional. */ }\n }\n\n receive(updates: readonly unknown[]) {\n if (this.stopped || !Array.isArray(updates)) return\n const now = Date.now()\n const seen = new Set<string>()\n for (const raw of updates.slice(0, 256)) {\n const update = readCollaborationPresence(raw)\n if (!update || update.clientId === this.options.clientId || update.epoch !== this.options.epoch || seen.has(update.clientId)) continue\n seen.add(update.clientId)\n const previous = this.peersById.get(update.clientId)\n const changed = !previous || previous.update.updatedAt !== update.updatedAt\n || JSON.stringify(previous.update) !== JSON.stringify(update)\n this.peersById.set(update.clientId, { update, receivedAt: changed ? now : previous.receivedAt })\n }\n for (const id of [...this.peersById.keys()]) if (!seen.has(id)) this.peersById.delete(id)\n this.expire(now, true)\n }\n\n private expire(now = Date.now(), force = false) {\n let removed = false\n for (const [id, peer] of this.peersById) {\n if (now - peer.receivedAt > this.expiryMs) { this.peersById.delete(id); removed = true }\n }\n if (removed || force) this.update()\n }\n\n private update() {\n this.revision += 1\n this.mapped = this.map(this.options.getState())\n for (const listener of this.listeners) listener(this.mapped)\n if (!this.stopped) this.options.redraw()\n }\n\n private map(state: EditorState | undefined): readonly CollaborationPeer[] {\n return Object.freeze([...this.peersById.values()].map(({ update }) => Object.freeze({\n clientId: update.clientId, user: update.user as CollaborationPeer['user'], version: update.version, updatedAt: update.updatedAt,\n selection: state && update.selection ? toLocalSelection(state, this.options.history, update.selection, update.version, this.maxVersionLag) : null,\n })))\n }\n\n decorations(state: EditorState) {\n const version = getVersion(state)\n const cache = this.cache\n if (cache && cache.doc === state.doc && cache.version === version && cache.revision === this.revision) return cache.set\n const peers = this.map(state)\n const set = peerDecorations(state.doc, peers)\n this.cache = { doc: state.doc, version, revision: this.revision, peers, set }\n return set\n }\n}\n","import { Extension, type Editor, type JSONContent } from '@tiptap/core'\nimport type { Node } from '@tiptap/pm/model'\nimport { Plugin, PluginKey, type EditorState, type Transaction } from '@tiptap/pm/state'\nimport { ReplaceStep, Transform, type Step } from '@tiptap/pm/transform'\nimport { collab, getVersion, receiveTransaction, sendableSteps } from 'prosemirror-collab'\nimport { profileExemptMeta } from '../profiles'\nimport { decodeCollaborationDocument, decodeCollaborationSteps, stableJson } from './validation'\nimport {\n assertCollaborationHead, collaborationLimits, collaborationProtocolVersion, CollaborationError, fenceMismatch,\n type CollaborationErrorCode, type CollaborationHead, type CollaborationReply, type CollaborationSnapshot,\n type CollaborationTransport, type CollaborationUser,\n} from './protocol'\nimport { ConfirmedHistory, PresenceTracker, type CollaborationPeer, type CollaborationPresenceOptions } from './presence'\n\nconst remoteChange = new PluginKey('ginkoCollaborationRemote')\nconst presenceKey = new PluginKey('ginkoCollaborationPresence')\nconst maxPendingSteps = 2048\nconst maxPendingBytes = 2 * 1024 * 1024\nconst maxRecoveryBytes = 4 * 1024 * 1024\n// Rebasing can enlarge both document copies and escaped pending operations.\n// Reserve import capacity for that accepted remote growth. Local edits still\n// use the smaller budget before dispatch; no pending work is truncated.\nconst maxRecoveredBytes = 16 * 1024 * 1024\n// Typing uses a size estimate below this share of the document limit and\n// measures the document exactly above it.\nconst estimatedDocumentShare = 0.5\nconst maxEstimatedTransactions = 64\nconst encoder = new TextEncoder()\n\nfunction transactionGroups(pending: NonNullable<ReturnType<typeof sendableSteps>>) {\n const groups: string[][] = []\n for (let index = 0; index < pending.steps.length; index++) {\n if (index === 0 || pending.origins[index] !== pending.origins[index - 1]) groups.push([])\n groups.at(-1)!.push(JSON.stringify(pending.steps[index]!.toJSON()))\n }\n return groups\n}\n\n/** @experimental */\nexport type CollaborationStatus = 'connecting' | 'syncing' | 'synced' | 'offline' | 'error' | 'stale' | 'closed'\n\n/**\n * Reason for an `offline`, `error` or `stale` state, or for a refused local change.\n * `offline`, `timeout` and `unavailable` retry automatically with backoff.\n * `rejected` means the server refused pending changes: call `discardPendingAndResync()`.\n * `schema_mismatch`, `policy_mismatch`, `replaced` and `history_expired` require a reopen.\n * @experimental\n */\nexport type CollaborationStateCode = 'offline' | 'timeout' | 'unavailable' | 'rejected' | 'forbidden'\n | 'schema_mismatch' | 'policy_mismatch' | 'replaced' | 'history_expired' | 'conflict' | 'storage' | 'limit' | 'internal'\n\n/** @experimental */\nexport interface CollaborationState {\n status: CollaborationStatus\n version: number\n pendingSteps: number\n message?: string\n code?: CollaborationStateCode\n}\n\n/**\n * Hosts use this for connection failures. The session keeps local edits and retries.\n * @experimental\n */\nexport class CollaborationConnectionError extends CollaborationError {\n constructor(message = 'Connection lost. Your changes are kept in this editor.') {\n super('unavailable', message)\n this.name = 'CollaborationConnectionError'\n }\n}\n\nclass CollaborationTimeoutError extends CollaborationConnectionError {\n constructor() {\n super('The server did not answer in time. Your changes are kept in this editor.')\n this.name = 'CollaborationTimeoutError'\n }\n}\n\n/** A failure raised by the session itself, with its state code. */\nclass SessionFailure extends CollaborationError {\n constructor(code: CollaborationErrorCode, readonly stateCode: CollaborationStateCode, message: string) {\n super(code, message)\n }\n}\n\n/** @experimental */\nexport interface CollaborationRecovery {\n format: 1\n clientId: string\n base: CollaborationSnapshot\n steps: string[]\n /** Step counts for the original transactions. A batch must not split one. */\n groups: number[]\n /** Derived from base + steps, retained for recovery if a future client cannot decode old steps. */\n document: string\n}\n\n/**\n * Parse host-owned recovery storage without trusting its JSON shape.\n * @experimental\n */\nexport function parseCollaborationRecovery(source: string): CollaborationRecovery {\n if (encoder.encode(source).byteLength > maxRecoveredBytes) throw new CollaborationError('limit', 'The editor recovery copy is too large.')\n let value: unknown\n try {\n value = JSON.parse(source)\n } catch {\n throw new CollaborationError('invalid', 'Invalid editor recovery copy.')\n }\n if (!value || typeof value !== 'object' || !('format' in value) || value.format !== 1\n || !('clientId' in value) || typeof value.clientId !== 'string'\n || !('document' in value) || typeof value.document !== 'string'\n || !('steps' in value) || !Array.isArray(value.steps) || !value.steps.every((step: unknown): step is string => typeof step === 'string')\n || !('groups' in value) || !Array.isArray(value.groups) || !value.groups.every((group: unknown): group is number => typeof group === 'number')\n || !('base' in value) || !value.base || typeof value.base !== 'object') {\n throw new CollaborationError('invalid', 'Invalid editor recovery copy.')\n }\n const base = value.base\n if (!('epoch' in base) || typeof base.epoch !== 'string'\n || !('schemaRevision' in base) || typeof base.schemaRevision !== 'string'\n || !('policyRevision' in base) || typeof base.policyRevision !== 'string'\n || !('version' in base) || typeof base.version !== 'number'\n || !('document' in base) || typeof base.document !== 'string') {\n throw new CollaborationError('invalid', 'Invalid editor recovery base.')\n }\n // Session construction validates fences, limits, and base + steps against\n // the stored document before attaching it to an editor.\n return { format: 1, clientId: value.clientId, document: value.document,\n steps: value.steps, groups: value.groups, base: { epoch: base.epoch,\n schemaRevision: base.schemaRevision, policyRevision: base.policyRevision,\n version: base.version, document: base.document } }\n}\n\n/** @experimental */\nexport interface EditorCollaborationOptions {\n clientId: string\n snapshot: CollaborationSnapshot\n transport: CollaborationTransport\n recovery?: CollaborationRecovery\n /**\n * Persist synchronously in host-owned storage. Throw if the recovery copy cannot be saved.\n * The session calls it at most once per `recoveryDelayMs`, when the page is hidden,\n * and from `flushRecovery()`, `flush()`, `discardPendingAndResync()` and `close()`.\n */\n onRecovery?: (recovery: CollaborationRecovery | null) => void\n /** Delay for `onRecovery` writes. `0` writes after every change. Default: 300 ms. */\n recoveryDelayMs?: number\n /** Receives unsent changes before `discardPendingAndResync()` removes them. Throw to keep them. */\n onDiscard?: (recovery: CollaborationRecovery) => void\n /** Time limit for one pull or push request. Default: 15 s. */\n requestTimeoutMs?: number\n /** Retry delay bounds. Each retry waits a random time up to the current bound. */\n backoff?: { initialMs?: number; maxMs?: number }\n /** Local collaborator identity for presence. Without it, the session only shows other collaborators. */\n user?: CollaborationUser\n /** Presence tuning, or `false` to turn presence off when the transport supports it. */\n presence?: false | CollaborationPresenceOptions\n}\n\nconst errorCodes: Record<CollaborationStateCode, CollaborationErrorCode> = {\n offline: 'unavailable', timeout: 'unavailable', unavailable: 'unavailable', rejected: 'content', forbidden: 'forbidden',\n schema_mismatch: 'schema', policy_mismatch: 'policy', replaced: 'epoch', history_expired: 'version', conflict: 'version',\n storage: 'limit', limit: 'limit', internal: 'invalid',\n}\nconst staleCodes = { epoch: 'replaced', schema: 'schema_mismatch', policy: 'policy_mismatch', history: 'history_expired' } as const\nconst transientPattern = /network|timed? ?out|timeout|temporarily|unavailable|ECONN|EPIPE|ENOTFOUND|EAI_AGAIN|socket|fetch failed|failed to fetch/i\n\ninterface Failure { status: 'offline' | 'error' | 'stale'; code: CollaborationStateCode; message: string }\n\nfunction readCode(error: object): unknown {\n if ('code' in error && typeof error.code === 'string') return error.code\n if ('data' in error && error.data && typeof error.data === 'object' && 'code' in error.data) return error.data.code\n}\n\nfunction readStatus(error: object): number | undefined {\n for (const key of ['status', 'statusCode']) {\n if (key in error && typeof (error as Record<string, unknown>)[key] === 'number') return (error as Record<string, number>)[key]\n }\n}\n\n/** Classify a transport or validation failure. Unknown failures while sending are rejections. */\nexport function classifyCollaborationFailure(error: unknown, sending = false): Failure {\n const message = error instanceof Error && error.message ? error.message : 'Synchronization failed. Keep this editor open and retry.'\n if (error instanceof SessionFailure) {\n return { status: ['schema_mismatch', 'policy_mismatch', 'replaced'].includes(error.stateCode) ? 'stale' : 'error', code: error.stateCode, message }\n }\n if (error instanceof CollaborationTimeoutError) return { status: 'offline', code: 'timeout', message }\n if (error instanceof CollaborationConnectionError) return { status: 'offline', code: 'offline', message }\n if (error && typeof error === 'object') {\n const code = readCode(error)\n const status = readStatus(error)\n if (code === 'unavailable' || (status !== undefined && (status >= 500 || [408, 425, 429].includes(status)))) {\n return { status: 'offline', code: 'unavailable', message }\n }\n if (['forbidden', 'unauthenticated', 'unauthorized'].includes(String(code)) || status === 401 || status === 403) {\n return { status: 'error', code: 'forbidden', message }\n }\n if (code === 'schema' || code === 'protocol') return { status: 'stale', code: 'schema_mismatch', message }\n if (code === 'policy') return { status: 'stale', code: 'policy_mismatch', message }\n if (code === 'epoch') return { status: 'stale', code: 'replaced', message }\n if (code === 'version') return { status: 'error', code: 'conflict', message }\n if (['content', 'invalid', 'limit'].includes(String(code))) return { status: 'error', code: sending ? 'rejected' : 'internal', message }\n if (error instanceof Error && (['AbortError', 'TimeoutError', 'NetworkError'].includes(error.name) || transientPattern.test(error.message))) {\n return { status: 'offline', code: error.name === 'TimeoutError' ? 'timeout' : 'unavailable', message }\n }\n }\n return { status: 'error', code: sending ? 'rejected' : 'internal', message }\n}\n\ninterface CollabStateShape { version: number; unconfirmed: unknown[] }\n\n/**\n * One session belongs to one mounted editor. Hosts own identity, transport and storage.\n * @experimental\n */\nexport class EditorCollaborationSession {\n readonly extension: Extension\n readonly initialDocument: JSONContent\n private readonly initial: CollaborationSnapshot\n private readonly clientId: string\n private readonly collabPlugin: Plugin\n private readonly history: ConfirmedHistory\n private readonly presence?: PresenceTracker\n private instance?: Editor\n private confirmed: Node\n private current: CollaborationState\n private listeners = new Set<(state: CollaborationState) => void>()\n private unsubscribe?: () => void\n private timer?: ReturnType<typeof setTimeout>\n private timerDue = Infinity\n private busy = false\n private requested = false\n private generation = 0\n private observedVersion: number\n private attempt = 0\n private restored = false\n private restoring = false\n private orphanOwnSteps = false\n private recoveryTimer?: ReturnType<typeof setTimeout>\n private recoveryDirty = false\n private recoveryStored: boolean\n private stepSizes = new WeakMap<Step, number>()\n private docSizes = new WeakMap<Node, number>()\n private estimate?: { doc: Node; bytes: number; count: number }\n private removeWindowListeners?: () => void\n\n constructor(private readonly options: EditorCollaborationOptions) {\n // Vue must not wrap the session or its ProseMirror values in reactive\n // proxies: node type identity is part of the schema. This is `markRaw()`.\n Object.defineProperty(this, '__v_skip', { value: true })\n assertCollaborationHead(options.snapshot)\n const recovery = options.recovery\n if (recovery) {\n if (recovery.format !== 1 || !Array.isArray(recovery.steps) || recovery.steps.length > maxPendingSteps\n || !Array.isArray(recovery.groups) || recovery.groups.some(count => !Number.isSafeInteger(count) || count <= 0 || count > collaborationLimits.stepsPerBatch)\n || recovery.groups.reduce((sum, count) => sum + count, 0) !== recovery.steps.length\n || encoder.encode(JSON.stringify(recovery)).byteLength > maxRecoveredBytes) {\n throw new CollaborationError('invalid', 'Invalid editor recovery copy.')\n }\n assertCollaborationHead(recovery.base)\n const mismatch = fenceMismatch(recovery.base, options.snapshot)\n if (mismatch) throw new CollaborationError(mismatch, 'This recovery copy belongs to an older document. Keep it before reopening.')\n if (recovery.base.version > options.snapshot.version) throw new CollaborationError('version', 'The server is older than this recovery copy.')\n }\n this.initial = { ...(recovery?.base ?? options.snapshot) }\n delete this.initial.protocolVersion\n this.clientId = recovery?.clientId ?? options.clientId\n if (typeof this.clientId !== 'string' || !this.clientId || this.clientId.length > 200) {\n throw new CollaborationError('invalid', 'Invalid editor client ID.')\n }\n this.confirmed = decodeCollaborationDocument(this.initial.document)\n if (recovery) {\n const local = new Transform(this.confirmed)\n let index = 0\n for (const count of recovery.groups) {\n for (const step of decodeCollaborationSteps(recovery.steps.slice(index, index + count), this.confirmed.type.schema)) local.step(step)\n index += count\n }\n if (JSON.stringify(local.doc.toJSON()) !== recovery.document) throw new CollaborationError('invalid', 'The recovery copy does not match its pending steps.')\n }\n this.recoveryStored = !!recovery?.steps.length\n this.initialDocument = this.confirmed.toJSON()\n this.observedVersion = options.snapshot.version\n this.history = new ConfirmedHistory(this.initial.version)\n this.current = { status: 'connecting', version: this.initial.version, pendingSteps: recovery?.steps.length ?? 0 }\n this.collabPlugin = collab({ version: this.initial.version, clientID: this.clientId })\n const channel = options.presence === false ? undefined : options.transport.presence\n if (channel) {\n this.presence = new PresenceTracker({ ...(options.presence || {}), clientId: this.clientId, epoch: this.initial.epoch,\n channel, user: options.user, history: this.history,\n getState: () => this.instance?.isDestroyed === false ? this.instance.state : undefined,\n getConfirmedSize: () => this.confirmed.content.size,\n redraw: () => {\n const editor = this.instance\n if (editor && !editor.isDestroyed) editor.view.dispatch(editor.state.tr.setMeta(presenceKey, true).setMeta('addToHistory', false))\n },\n })\n }\n const presence = this.presence\n this.extension = Extension.create({\n name: 'ginkoCollaboration',\n priority: 1000,\n addProseMirrorPlugins: () => [this.collabPlugin, new Plugin({\n filterTransaction: (transaction, state) => this.filterLocal(transaction, state),\n }), ...(presence ? [new Plugin({ key: presenceKey, props: { decorations: state => presence.decorations(state) } })] : [])],\n onCreate: ({ editor }) => { this.attach(editor) },\n onTransaction: ({ transaction }) => {\n if (transaction.docChanged || transaction.getMeta(remoteChange)) this.changed()\n if (!transaction.getMeta(presenceKey) && (transaction.docChanged || transaction.selectionSet || transaction.getMeta(remoteChange))) {\n this.presence?.changed()\n }\n },\n onDestroy: () => { this.close() },\n })\n }\n\n get state(): Readonly<CollaborationState> { return this.current }\n get canEdit() {\n return !['error', 'stale', 'closed'].includes(this.current.status) && this.current.pendingSteps < maxPendingSteps\n }\n /** Remote collaborators with selections mapped into this document. Empty without a presence channel. */\n get peers(): readonly CollaborationPeer[] { return this.presence?.peers ?? [] }\n /** Calls the listener now and after each collaborator change. Returns a cleanup function. */\n onPeersChange(listener: (peers: readonly CollaborationPeer[]) => void) {\n if (!this.presence) { listener([]); return () => {} }\n return this.presence.onPeersChange(listener)\n }\n\n subscribe(listener: (state: CollaborationState) => void) {\n this.listeners.add(listener)\n listener(this.current)\n return () => { this.listeners.delete(listener) }\n }\n\n private setState(status: CollaborationStatus, message?: string, code?: CollaborationStateCode) {\n const state: CollaborationState = { status, version: this.instance ? getVersion(this.instance.state) : this.initial.version,\n pendingSteps: this.instance ? sendableSteps(this.instance.state)?.steps.length ?? 0 : this.current.pendingSteps }\n if (state.pendingSteps >= maxPendingSteps) {\n state.message = 'Reconnect to continue writing. This editor has reached its unsent change limit.'\n state.code = 'limit'\n } else {\n if (message) state.message = message\n if (code) state.code = code\n }\n this.current = Object.freeze(state)\n for (const listener of this.listeners) listener(this.current)\n }\n\n private refuse(message: string) {\n this.setState(this.current.status, message, 'limit')\n return false\n }\n\n private stepSize(step: Step) {\n let size = this.stepSizes.get(step)\n if (size === undefined) {\n size = encoder.encode(JSON.stringify(step.toJSON())).byteLength\n this.stepSizes.set(step, size)\n }\n return size\n }\n\n private docSize(doc: Node) {\n let size = this.docSizes.get(doc)\n if (size === undefined) {\n size = encoder.encode(JSON.stringify(doc.toJSON())).byteLength\n this.docSizes.set(doc, size)\n }\n return size\n }\n\n /**\n * Upper estimate of the next document size. Plain replace steps grow the JSON\n * by about their own size; the estimate doubles it and measures exactly near\n * the limit, after other step types and after a bounded number of estimates.\n */\n private nextDocumentSize(before: Node, after: Node, steps: readonly Step[], added: number) {\n const known = this.docSizes.get(before) ?? (this.estimate?.doc === before ? this.estimate.bytes : undefined)\n const count = this.estimate?.doc === before ? this.estimate.count : 0\n if (known !== undefined && count < maxEstimatedTransactions && steps.every(step => step instanceof ReplaceStep)) {\n const bytes = known + 2 * added\n if (bytes < collaborationLimits.documentBytes * estimatedDocumentShare) {\n this.estimate = { doc: after, bytes, count: count + 1 }\n return bytes\n }\n }\n const bytes = this.docSize(after)\n this.estimate = { doc: after, bytes, count: 0 }\n return bytes\n }\n\n private filterLocal(transaction: Transaction, state: EditorState) {\n if (!transaction.docChanged || transaction.getMeta(remoteChange)) return true\n if (!this.canEdit) return false\n const size = transaction.steps.reduce((sum, step) => sum + this.stepSize(step), 0)\n if (transaction.steps.length > collaborationLimits.stepsPerBatch || size > collaborationLimits.batchBytes) {\n return this.refuse('This change is too large. Insert a smaller part of the content.')\n }\n const pending = sendableSteps(state)\n if ((pending?.steps.length ?? 0) + transaction.steps.length > maxPendingSteps) return false\n const pendingBytes = pending?.steps.reduce((sum, step) => sum + this.stepSize(step), 0) ?? 0\n const recoveryLimit = 'Reconnect before adding more changes. The recovery copy has reached its size limit.'\n if (pendingBytes + size > maxPendingBytes) return this.refuse(recoveryLimit)\n const documentBytes = this.nextDocumentSize(state.doc, transaction.doc, transaction.steps, size)\n if (documentBytes > collaborationLimits.documentBytes) return this.refuse('This change is too large. Insert a smaller part of the content.')\n // JSON escaping at most doubles an encoded string inside the recovery file.\n // Build the actual file only when this bound is too close to the budget.\n const steps = (pending?.steps.length ?? 0) + transaction.steps.length\n const bound = 2 * (this.docSize(this.confirmed) + documentBytes + pendingBytes + size) + 16 * steps + 4096\n if (bound <= maxRecoveryBytes) return true\n if (this.docSize(transaction.doc) > collaborationLimits.documentBytes) return this.refuse('This change is too large. Insert a smaller part of the content.')\n const encoded = pending?.steps.map(step => JSON.stringify(step.toJSON())) ?? []\n const added = transaction.steps.map(step => JSON.stringify(step.toJSON()))\n const recovery: CollaborationRecovery = { format: 1, clientId: this.clientId,\n base: { ...this.initial, version: getVersion(state), document: JSON.stringify(this.confirmed.toJSON()) },\n steps: [...encoded, ...added], groups: [...(pending ? transactionGroups(pending).map(group => group.length) : []), added.length],\n document: JSON.stringify(transaction.doc.toJSON()),\n }\n if (encoder.encode(JSON.stringify(recovery)).byteLength > maxRecoveryBytes) return this.refuse(recoveryLimit)\n return true\n }\n\n private attach(editor: Editor) {\n if (this.instance || this.current.status === 'closed') throw new Error('A collaboration session can only mount once.')\n const confirmed = decodeCollaborationDocument(this.initial.document, editor.schema)\n if (!editor.state.doc.eq(confirmed)) {\n const error = new CollaborationError('content', 'The editor must start from the session document.')\n this.fail(error)\n throw error\n }\n this.instance = editor\n this.confirmed = confirmed\n const recovery = this.options.recovery\n if (recovery?.steps.length && !this.restored) {\n this.restored = true\n this.restoring = true\n let index = 0\n for (const count of recovery.groups) {\n const transaction = editor.state.tr.setMeta(remoteChange, true).setMeta(profileExemptMeta, true)\n for (const step of decodeCollaborationSteps(recovery.steps.slice(index, index + count), editor.schema)) transaction.step(step)\n editor.view.dispatch(transaction)\n index += count\n }\n this.restoring = false\n this.changed()\n }\n this.listenToPage()\n this.startSubscription()\n this.presence?.start()\n this.schedule(0)\n }\n\n private listenToPage() {\n if (typeof window === 'undefined' || typeof document === 'undefined') return\n const persist = () => { this.flushRecovery() }\n const hidden = () => { if (document.visibilityState === 'hidden') this.flushRecovery() }\n const online = () => { if (this.current.status === 'offline') this.schedule(0) }\n window.addEventListener('pagehide', persist)\n window.addEventListener('online', online)\n document.addEventListener('visibilitychange', hidden)\n this.removeWindowListeners = () => {\n window.removeEventListener('pagehide', persist)\n window.removeEventListener('online', online)\n document.removeEventListener('visibilitychange', hidden)\n }\n }\n\n private startSubscription() {\n this.unsubscribe?.()\n const generation = this.generation\n this.unsubscribe = this.options.transport.subscribe(head => {\n if (generation !== this.generation) return\n if (this.current.status === 'closed' || this.current.status === 'stale') return\n try {\n const mismatch = fenceMismatch(this.initial, head)\n if (mismatch) {\n this.setState('stale', 'This document was replaced or its policy changed. Keep your recovery copy and reopen it.', staleCodes[mismatch])\n this.presence?.stop(true)\n return\n }\n assertCollaborationHead(head)\n this.observedVersion = Math.max(this.observedVersion, head.version)\n if (this.current.status === 'error') return\n // A new head also ends a retry wait early.\n this.schedule(0)\n } catch (error) { this.fail(error) }\n }, error => { if (generation === this.generation) this.fail(error) })\n }\n\n private changed() {\n if (!this.instance || this.restoring || this.current.status === 'closed') return\n this.queueRecovery()\n if (['error', 'stale'].includes(this.current.status)) { this.setState(this.current.status, this.current.message, this.current.code); return }\n if (this.current.status === 'offline') {\n // Keep the retry wait. A new head or the browser `online` event ends it early.\n this.setState('offline', this.current.message, this.current.code)\n if (!this.timer) this.schedule(40)\n return\n }\n this.setState('syncing', this.current.message, this.current.code === 'limit' ? 'limit' : undefined)\n this.schedule(40)\n }\n\n private queueRecovery() {\n if (!this.options.onRecovery || !this.instance) return\n // Remote changes without local work do not change an empty recovery copy.\n if (!this.recoveryStored && !sendableSteps(this.instance.state)) return\n this.recoveryDirty = true\n const delay = this.options.recoveryDelayMs ?? 300\n if (delay <= 0) { this.flushRecovery(); return }\n this.recoveryTimer ??= setTimeout(() => { this.recoveryTimer = undefined; this.flushRecovery() }, delay)\n }\n\n /** Write the current recovery copy through `onRecovery` now. Returns false if the host could not save it. */\n flushRecovery(): boolean {\n clearTimeout(this.recoveryTimer)\n this.recoveryTimer = undefined\n if (!this.recoveryDirty || !this.options.onRecovery || !this.instance) return true\n this.recoveryDirty = false\n const recovery = this.getRecovery()\n try {\n this.options.onRecovery(recovery)\n this.recoveryStored = recovery !== null\n return true\n } catch {\n this.recoveryDirty = true\n if (this.current.status !== 'closed') {\n this.setState('error', 'The recovery copy could not be saved. Keep this editor open and retry after freeing storage.', 'storage')\n }\n return false\n }\n }\n\n getRecovery(): CollaborationRecovery | null {\n if (!this.instance) return this.options.recovery ? structuredClone(this.options.recovery) : null\n const pending = sendableSteps(this.instance.state)\n return pending ? { format: 1, clientId: this.clientId,\n base: { ...this.initial, version: getVersion(this.instance.state), document: JSON.stringify(this.confirmed.toJSON()) },\n steps: pending.steps.map(step => JSON.stringify(step.toJSON())), groups: transactionGroups(pending).map(group => group.length),\n document: JSON.stringify(this.instance.state.doc.toJSON()),\n } : null\n }\n\n private schedule(delay: number) {\n if (!this.instance || ['error', 'stale', 'closed'].includes(this.current.status)) return\n this.requested = true\n if (this.busy) return\n const due = Date.now() + delay\n if (this.timer && this.timerDue <= due) return\n clearTimeout(this.timer)\n this.timerDue = due\n this.timer = setTimeout(() => { this.timer = undefined; this.timerDue = Infinity; void this.pump() }, delay)\n }\n\n private backoffDelay() {\n const initial = this.options.backoff?.initialMs ?? 1000\n const max = this.options.backoff?.maxMs ?? 30_000\n const bound = Math.min(max, initial * 2 ** Math.min(this.attempt, 30))\n return Math.round(Math.random() * bound)\n }\n\n private head(): CollaborationHead {\n return { epoch: this.initial.epoch, schemaRevision: this.initial.schemaRevision,\n policyRevision: this.initial.policyRevision, version: getVersion(this.instance!.state), protocolVersion: collaborationProtocolVersion }\n }\n\n private request<T>(operation: () => Promise<T>): Promise<T> {\n const timeout = this.options.requestTimeoutMs ?? 15_000\n return new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => { reject(new CollaborationTimeoutError()) }, timeout)\n Promise.resolve().then(operation).then(\n value => { clearTimeout(timer); resolve(value) },\n (error: unknown) => { clearTimeout(timer); reject(error) })\n })\n }\n\n private apply(reply: CollaborationReply) {\n if (!reply || typeof reply !== 'object') throw new SessionFailure('invalid', 'internal', 'The server returned an invalid reply.')\n if (reply.status === 'stale') {\n const code = staleCodes[reply.reason] ?? 'replaced'\n this.setState('stale', 'The server cannot merge this editing session. Keep your recovery copy and reopen the document.', code)\n this.presence?.stop(true)\n return false\n }\n const editor = this.instance!\n const update = reply.update\n assertCollaborationHead(update)\n if (fenceMismatch(this.initial, update)) throw new SessionFailure('epoch', 'replaced', 'The server returned a different document generation.')\n if (update.fromVersion !== getVersion(editor.state) || !Array.isArray(update.steps) || !Array.isArray(update.clientIds)\n || update.version !== update.fromVersion + update.steps.length || update.steps.length !== update.clientIds.length\n || update.clientIds.some(id => typeof id !== 'string' || !id || id.length > 200)) {\n throw new SessionFailure('invalid', 'internal', 'The server returned an inconsistent editor history.')\n }\n this.observedVersion = Math.max(this.observedVersion, update.version)\n if (!update.steps.length) return true\n const steps = decodeCollaborationSteps(update.steps, editor.schema)\n const pending = sendableSteps(editor.state)\n const clientIds = [...update.clientIds]\n let ownPrefix = true\n for (let index = 0; index < steps.length; index++) {\n if (clientIds[index] !== this.clientId) { ownPrefix = false; continue }\n if (!ownPrefix || !pending?.steps[index] || stableJson(steps[index]!.toJSON()) !== stableJson(pending.steps[index]!.toJSON())) {\n // After a discard, the server may still accept a request sent before it.\n // Those steps are ordinary accepted history, not confirmations.\n if (this.orphanOwnSteps) { clientIds[index] = `\\u0000discarded:${this.clientId}`; ownPrefix = false; continue }\n throw new SessionFailure('version', 'conflict', 'Another editor is using this client ID. Keep this recovery copy and reopen with a unique session.')\n }\n }\n const confirmed = new Transform(this.confirmed)\n for (const step of steps) confirmed.step(step)\n confirmed.doc.check()\n const transaction = receiveTransaction(editor.state, steps, clientIds, { mapSelectionBackward: true }).setMeta(remoteChange, true).setMeta(profileExemptMeta, true)\n this.history.append(update.fromVersion, confirmed.mapping.maps)\n this.confirmed = confirmed.doc\n editor.view.dispatch(transaction)\n return true\n }\n\n private async pump() {\n if (!this.instance || this.busy || ['error', 'stale', 'closed'].includes(this.current.status)) return\n this.busy = true\n const generation = this.generation\n let sending = false\n this.setState('syncing')\n try {\n do {\n this.requested = false\n const before = getVersion(this.instance.state)\n const received = await this.request(() => this.options.transport.pull(this.head()))\n if (generation !== this.generation || ['error', 'stale', 'closed'].includes(this.current.status) || !this.apply(received)) return\n if (getVersion(this.instance.state) < this.observedVersion) {\n if (getVersion(this.instance.state) === before) throw new SessionFailure('version', 'conflict', 'The server did not return the missing editor history.')\n this.requested = true\n continue\n }\n const pending = sendableSteps(this.instance.state)\n if (pending) {\n const steps: string[] = []\n let bytes = 0\n for (const group of transactionGroups(pending)) {\n const size = group.reduce((sum, encoded) => sum + encoder.encode(encoded).byteLength, 0)\n if (steps.length + group.length > collaborationLimits.stepsPerBatch || bytes + size > collaborationLimits.batchBytes) break\n bytes += size\n steps.push(...group)\n }\n if (!steps.length) throw new SessionFailure('limit', 'rejected', 'A pending edit is too large to send. Keep a recovery copy before changing it.')\n sending = true\n const reply = await this.request(() => this.options.transport.push({ ...this.head(), clientId: this.clientId, steps }))\n sending = false\n if (generation !== this.generation || ['error', 'stale', 'closed'].includes(this.current.status) || !this.apply(reply)) return\n if (getVersion(this.instance.state) === pending.version) throw new SessionFailure('version', 'conflict', 'The server did not acknowledge the submitted changes.')\n if ((sendableSteps(this.instance.state)?.steps.length ?? 0) < pending.steps.length) this.orphanOwnSteps = false\n this.requested = true\n }\n } while (this.requested && !['error', 'stale', 'closed'].includes(this.current.status))\n if (!['error', 'stale', 'closed'].includes(this.current.status)) {\n this.attempt = 0\n this.setState('synced')\n }\n } catch (error) {\n if (generation === this.generation) this.fail(error, sending)\n } finally {\n if (generation === this.generation) {\n this.busy = false\n if (this.current.status === 'offline') this.schedule(this.backoffDelay())\n else if (this.requested) this.schedule(0)\n }\n }\n }\n\n private fail(error: unknown, sending = false) {\n if (['closed', 'stale'].includes(this.current.status)) return\n const failure = classifyCollaborationFailure(error, sending)\n this.setState(failure.status, failure.message, failure.code)\n if (failure.status === 'stale') this.presence?.stop(true)\n if (failure.status === 'offline') {\n this.attempt += 1\n this.schedule(this.backoffDelay())\n }\n }\n\n /** Try again now. Pending changes are sent again; after a rejection use `discardPendingAndResync()`. */\n retry() {\n if (['closed', 'stale'].includes(this.current.status)) return\n // A disconnected transport may leave a promise pending indefinitely. The\n // old request may still complete, but cannot mutate this new attempt.\n this.generation += 1\n this.busy = false\n clearTimeout(this.timer)\n this.timer = undefined\n this.timerDue = Infinity\n this.setState('connecting')\n this.startSubscription()\n this.schedule(0)\n }\n\n /**\n * Remove unsent local changes and continue from the last accepted document.\n * `onDiscard` receives the removed changes first; if it throws, nothing is removed.\n * Returns the removed recovery copy, or null when nothing was pending.\n */\n discardPendingAndResync(): CollaborationRecovery | null {\n const editor = this.instance\n if (!editor || editor.isDestroyed || ['closed', 'stale'].includes(this.current.status)) return null\n const discarded = this.getRecovery()\n if (discarded) this.options.onDiscard?.(structuredClone(discarded))\n this.generation += 1\n this.busy = false\n clearTimeout(this.timer)\n this.timer = undefined\n this.timerDue = Infinity\n if (discarded) {\n const collabState: CollabStateShape = { version: getVersion(editor.state), unconfirmed: [] }\n this.orphanOwnSteps = true\n editor.view.dispatch(editor.state.tr.replaceWith(0, editor.state.doc.content.size, this.confirmed.content)\n .setMeta(remoteChange, true).setMeta(profileExemptMeta, true).setMeta('addToHistory', false).setMeta(this.collabPlugin, collabState))\n }\n this.recoveryDirty = true\n this.flushRecovery()\n this.attempt = 0\n this.setState('connecting')\n this.startSubscription()\n this.schedule(0)\n return discarded\n }\n\n /** Resolves only when all local steps have been accepted. The host owns publication. */\n flush(timeoutMs = 10_000): Promise<CollaborationHead> {\n this.flushRecovery()\n if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) return Promise.reject(new RangeError('Flush timeout must be positive.'))\n const settled = () => {\n this.flushRecovery()\n const head = this.head()\n delete head.protocolVersion\n return head\n }\n const failure = (state: CollaborationState) => new CollaborationError(state.code ? errorCodes[state.code] : 'invalid',\n state.message ?? 'The editing session is closed.')\n if (this.current.status === 'synced' && !this.busy && !this.current.pendingSteps) return Promise.resolve(settled())\n if (['error', 'stale', 'closed'].includes(this.current.status)) return Promise.reject(failure(this.current))\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => { unsubscribe(); reject(new CollaborationConnectionError('Changes are still waiting for the server. Keep this editor open.')) }, timeoutMs)\n const listener = (state: CollaborationState) => {\n if (state.status === 'synced' && !state.pendingSteps) { clearTimeout(timer); unsubscribe(); resolve(settled()) }\n else if (['error', 'stale', 'closed'].includes(state.status)) { clearTimeout(timer); unsubscribe(); reject(failure(state)) }\n }\n const unsubscribe = () => { this.listeners.delete(listener) }\n this.listeners.add(listener)\n this.schedule(0)\n })\n }\n\n close() {\n if (this.current.status === 'closed') return\n this.flushRecovery()\n this.generation += 1\n clearTimeout(this.timer)\n clearTimeout(this.recoveryTimer)\n this.unsubscribe?.()\n this.removeWindowListeners?.()\n this.presence?.stop()\n this.setState('closed', this.current.pendingSteps ? 'Unsent changes remain in the host recovery copy.' : undefined)\n this.listeners.clear()\n }\n}\n\n/** @experimental */\nexport function createEditorCollaboration(options: EditorCollaborationOptions) {\n return new EditorCollaborationSession(options)\n}\n","import { createEditorSchema } from '../config/documentConfig'\nimport { convertTiptapDocToMarkdown } from '../conversionPipeline'\nimport type { TiptapToMDCOptions } from '../tiptapToMdc'\nimport { CollaborationError, editorSchemaRevision } from './protocol'\nimport { parseCollaborationRecovery, type CollaborationRecovery } from './session'\n\n/** @experimental */\nexport type CollaborationRecoveryMarkdown =\n | { ok: true; markdown: string }\n | { ok: false; message: string }\n\n/** @experimental */\nexport type CollaborationRecoveryReadResult =\n /** Same schema revision. Pass `recovery` to a new session; construction still checks its document fence. */\n | { status: 'current'; recovery: CollaborationRecovery }\n /** Older or newer schema revision. The pending document was converted to Markdown for manual reuse. */\n | { status: 'converted'; schemaRevision: string; recovery: CollaborationRecovery; markdown: string }\n /** The copy cannot be read or converted. Offer the stored text as a download. */\n | { status: 'unreadable'; reason: 'format' | 'content'; message: string }\n\n/**\n * Convert the pending document in a recovery copy to Markdown with the current\n * schema. This does not check a Content policy; validate the result before use.\n * @experimental\n */\nexport async function collaborationRecoveryToMarkdown(recovery: CollaborationRecovery,\n output?: TiptapToMDCOptions): Promise<CollaborationRecoveryMarkdown> {\n const failure = { ok: false as const, message: 'This recovery copy cannot be converted to Markdown by this editor version. Keep the file.' }\n try {\n const schema = createEditorSchema()\n const doc = schema.nodeFromJSON(JSON.parse(recovery.document))\n doc.check()\n const result = await convertTiptapDocToMarkdown(doc.toJSON(), output)\n return result.ok && result.value !== undefined ? { ok: true, markdown: result.value } : failure\n } catch {\n return failure\n }\n}\n\n/**\n * Read host-stored recovery text. A copy from the current schema revision is\n * returned for a new session. A copy from another schema revision cannot be\n * rebased, so its pending document is converted to Markdown when possible.\n * @experimental\n */\nexport async function readCollaborationRecovery(source: string,\n options: { output?: TiptapToMDCOptions } = {}): Promise<CollaborationRecoveryReadResult> {\n let recovery: CollaborationRecovery\n try {\n recovery = parseCollaborationRecovery(source)\n } catch (error) {\n return { status: 'unreadable', reason: 'format',\n message: error instanceof CollaborationError ? error.message : 'Invalid editor recovery copy.' }\n }\n if (recovery.base.schemaRevision === editorSchemaRevision) return { status: 'current', recovery }\n const converted = await collaborationRecoveryToMarkdown(recovery, options.output)\n if (!converted.ok) return { status: 'unreadable', reason: 'content', message: converted.message }\n return { status: 'converted', schemaRevision: recovery.base.schemaRevision, recovery, markdown: converted.markdown }\n}\n"],"mappings":";;;;;;;;AAsCA,IAAa,IAAb,MAA8B;CAER;CAAgC;CADpD,OAA0B,CAAC;CAC3B,YAAY,GAAuB,IAAyB,KAAK;EAAb,AAAhC,KAAA,QAAA,GAAgC,KAAA,QAAA;CAAc;CAElE,IAAI,MAAM;EAAE,OAAO,KAAK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A,SAAgB,EAA0B,GAAqC;CAC7E,OAAO,IAAI,EAA2B,CAAO;AAC/C;;;ACxuBA,eAAsB,EAAgC,GACpD,GAAqE;CACrE,IAAM,IAAU;EAAE,IAAI;EAAgB,SAAS;CAA4F;CAC3I,IAAI;EAEF,IAAM,IADS,EACH,CAAA,CAAO,aAAa,KAAK,MAAM,EAAS,QAAQ,CAAC;EAC7D,EAAI,MAAM;EACV,IAAM,IAAS,MAAM,EAA2B,EAAI,OAAO,GAAG,CAAM;EACpE,OAAO,EAAO,MAAM,EAAO,UAAU,KAAA,IAAY;GAAE,IAAI;GAAM,UAAU,EAAO;EAAM,IAAI;CAC1F,QAAQ;EACN,OAAO;CACT;AACF;AAQA,eAAsB,GAA0B,GAC9C,IAA2C,CAAC,GAA6C;CACzF,IAAI;CACJ,IAAI;EACF,IAAW,EAA2B,CAAM;CAC9C,SAAS,GAAO;EACd,OAAO;GAAE,QAAQ;GAAc,QAAQ;GACrC,SAAS,aAAiB,IAAqB,EAAM,UAAU;EAAgC;CACnG;CACA,IAAI,EAAS,KAAK,mBAAA,kBAAyC,OAAO;EAAE,QAAQ;EAAW;CAAS;CAChG,IAAM,IAAY,MAAM,EAAgC,GAAU,EAAQ,MAAM;CAEhF,OADK,EAAU,KACR;EAAE,QAAQ;EAAa,gBAAgB,EAAS,KAAK;EAAgB;EAAU,UAAU,EAAU;CAAS,IADzF;EAAE,QAAQ;EAAc,QAAQ;EAAW,SAAS,EAAU;CAAQ;AAElG"}
@@ -1,44 +0,0 @@
1
- import type { Editor } from '@tiptap/core';
2
- import { type Ref, type ShallowRef } from 'vue';
3
- import type { AssetProvider, EditorAssetRequest, EditorFile, EditorImage, EditorVideo, ImagePicker, ImageUploadHandler, LegacyImageUploadResult } from '../types.js';
4
- type ImageInput = EditorImage | LegacyImageUploadResult;
5
- export interface AssetRequestProps {
6
- assetProvider?: AssetProvider;
7
- disabled: boolean;
8
- enableFiles: boolean;
9
- enableImages: boolean;
10
- enableVideo: boolean;
11
- imagePicker?: ImagePicker;
12
- imageUpload?: ImageUploadHandler;
13
- }
14
- export interface AssetRequestOptions {
15
- props: AssetRequestProps;
16
- editor: ShallowRef<Editor | undefined>;
17
- /** True when the canvas accepts a change now, and the optional feature is on. */
18
- canMutate: (featureEnabled?: boolean) => boolean;
19
- /** Changes when the canvas document is replaced or edited. */
20
- documentRevision: () => number;
21
- selectionRevision: Ref<number>;
22
- viewMode: Ref<string>;
23
- /** Changes only when the authoring policy changes. */
24
- policyRevision: Ref<number>;
25
- emitImage: (request: EditorAssetRequest<EditorImage>) => void;
26
- emitFile: (request: EditorAssetRequest<EditorFile>) => void;
27
- emitVideo: (request: EditorAssetRequest<EditorVideo>) => void;
28
- }
29
- /**
30
- * Host-owned asset selection. Requests complete once and only while the document,
31
- * selection, mode, editability, and asset capabilities are unchanged.
32
- */
33
- export declare function useAssetRequests(options: AssetRequestOptions): {
34
- resolvedAssetProvider: import("vue").ComputedRef<AssetProvider>;
35
- insertUploadedImageAt: (asset: ImageInput, pos: number, replaceSize?: number) => boolean;
36
- removeSelectedMedia: () => boolean;
37
- requestImage: (range?: {
38
- from: number;
39
- to: number;
40
- }) => void;
41
- requestFile: () => void;
42
- requestVideo: () => void;
43
- };
44
- export {};
@@ -1,59 +0,0 @@
1
- import type { CollaborationPeer, CollaborationStatus, EditorCollaborationSession } from '../collaboration.js';
2
- import type { EditorMessageKey } from '../ui/messages.js';
3
- /**
4
- * Bind one shared session for the lifetime of one mounted editor.
5
- * The session prop is read once. A different session requires a remount.
6
- */
7
- export declare function useCollaborationBinding(getSession: () => EditorCollaborationSession | undefined): {
8
- session: EditorCollaborationSession | undefined;
9
- state: import("vue").Ref<{
10
- readonly status: CollaborationStatus;
11
- readonly version: number;
12
- readonly pendingSteps: number;
13
- readonly message?: string | undefined;
14
- readonly code?: import("../collaboration.js").CollaborationStateCode | undefined;
15
- } | undefined, Readonly<import("../collaboration.js").CollaborationState> | {
16
- readonly status: CollaborationStatus;
17
- readonly version: number;
18
- readonly pendingSteps: number;
19
- readonly message?: string | undefined;
20
- readonly code?: import("../collaboration.js").CollaborationStateCode | undefined;
21
- } | undefined>;
22
- invalidBinding: import("vue").Ref<boolean, boolean>;
23
- invalidate: () => void;
24
- canEdit: () => boolean;
25
- pendingSteps: () => number;
26
- statusMessage: () => EditorMessageKey | undefined;
27
- extensions: import("@tiptap/core").Extension<any, any>[];
28
- downloadRecovery: () => void;
29
- peers: import("vue").Ref<readonly {
30
- clientId: string;
31
- user: {
32
- id?: string | undefined;
33
- name: string;
34
- color: string;
35
- };
36
- selection: {
37
- anchor: number;
38
- head: number;
39
- } | null;
40
- version: number;
41
- updatedAt: number;
42
- }[], readonly CollaborationPeer[] | readonly {
43
- clientId: string;
44
- user: {
45
- id?: string | undefined;
46
- name: string;
47
- color: string;
48
- };
49
- selection: {
50
- anchor: number;
51
- head: number;
52
- } | null;
53
- version: number;
54
- updatedAt: number;
55
- }[]>;
56
- canDiscard: () => boolean;
57
- discardPending: () => import("../collaboration.js").CollaborationRecovery | null | undefined;
58
- };
59
- export type CollaborationBinding = ReturnType<typeof useCollaborationBinding>;
@@ -1,10 +0,0 @@
1
- import { type Ref } from 'vue';
2
- /** A reactive media query. False during server rendering and without `matchMedia`. */
3
- export declare function useMediaQuery(query: string): Readonly<Ref<boolean>>;
4
- /** A device whose primary input is a finger, where native selection menus and on-screen keyboards appear. */
5
- export declare function useTouchDevice(): Readonly<Ref<boolean, boolean>>;
6
- /**
7
- * The height that an on-screen keyboard or browser bar covers at the bottom
8
- * of the layout viewport. Fixed elements move up by this inset to stay visible.
9
- */
10
- export declare function useKeyboardInset(): Readonly<Ref<number>>;
@@ -1,67 +0,0 @@
1
- import type { Editor } from '@tiptap/core';
2
- import { type Ref, type ShallowRef } from 'vue';
3
- import type { AuthoringKit, AuthoringRecipe } from '../authoring.js';
4
- import type { EditorOperationContext } from '../lib/editor-operations.js';
5
- import type { EditorOverlayController } from '../ui/context.js';
6
- import { type EditorProfile } from '../lib/profiles.js';
7
- import { type RecipeGroup, type RecipeMatch } from '../ui/recipe-search.js';
8
- type BrowserElement = InstanceType<typeof globalThis.HTMLElement>;
9
- type BrowserKeyboardEvent = InstanceType<typeof globalThis.KeyboardEvent>;
10
- /** The rendered menu parts that positioning and focus need. */
11
- export interface InsertMenuElements {
12
- root?: BrowserElement;
13
- search?: InstanceType<typeof globalThis.HTMLInputElement>;
14
- }
15
- export interface InsertMenuOptions {
16
- editor: ShallowRef<Editor | undefined>;
17
- editorRoot: Ref<BrowserElement | undefined>;
18
- menu: Ref<InsertMenuElements | undefined>;
19
- overlays: EditorOverlayController;
20
- kit: ShallowRef<AuthoringKit | undefined>;
21
- enableImages: () => boolean;
22
- canMutate: () => boolean;
23
- isDisposed: () => boolean;
24
- operationContext: EditorOperationContext;
25
- requestImage: (range?: {
26
- from: number;
27
- to: number;
28
- }) => void;
29
- /** The content profile. Recipes outside it are not offered. */
30
- profile?: EditorProfile;
31
- }
32
- export declare function useInsertMenu(options: InsertMenuOptions): {
33
- id: string;
34
- open: Ref<boolean, boolean>;
35
- origin: Ref<"button" | "slash", "button" | "slash">;
36
- query: Ref<string, string>;
37
- activeIndex: Ref<number, number>;
38
- activeRecipe: import("vue").ComputedRef<AuthoringRecipe>;
39
- recipes: import("vue").ComputedRef<AuthoringRecipe[]>;
40
- groups: import("vue").ComputedRef<RecipeGroup[]>;
41
- entries: import("vue").ComputedRef<RecipeMatch[]>;
42
- error: Ref<string | null, string | null>;
43
- busy: Ref<boolean, boolean>;
44
- position: Ref<{
45
- left: string;
46
- top: string;
47
- maxHeight: string;
48
- }, {
49
- left: string;
50
- top: string;
51
- maxHeight: string;
52
- } | {
53
- left: string;
54
- top: string;
55
- maxHeight: string;
56
- }>;
57
- container: ShallowRef<HTMLElement | undefined, HTMLElement | undefined>;
58
- editorAttributes: import("vue").ComputedRef<Record<string, string>>;
59
- show: (from: "button" | "slash") => Promise<void>;
60
- close: (restore?: boolean, dismissSlash?: boolean) => void;
61
- toggle: () => void;
62
- insert: (recipe: AuthoringRecipe | undefined) => Promise<void>;
63
- handleKeys: (event: BrowserKeyboardEvent) => boolean;
64
- syncSlash: (instance: Editor) => void;
65
- };
66
- export type InsertMenu = ReturnType<typeof useInsertMenu>;
67
- export {};
@@ -1,96 +0,0 @@
1
- import type { Editor } from '@tiptap/core';
2
- import { type Ref, type ShallowRef } from 'vue';
3
- import type { ConversionErrorPayload, ConversionRecoveredPayload } from '../lib/conversionPipeline.js';
4
- import type { TiptapToMDCOptions } from '../lib/tiptapToMdc.js';
5
- import type { EditorFlushResult } from '../types.js';
6
- import type { EditorText } from '../ui/messages.js';
7
- import type { CollaborationBinding } from './useCollaborationBinding.js';
8
- import type { StableAuthoringKit } from './useStableAuthoringKit.js';
9
- export type EditorViewMode = 'raw' | 'visual';
10
- export interface MarkdownSyncOptions {
11
- editor: ShallowRef<Editor | undefined>;
12
- binding: CollaborationBinding;
13
- authoring: StableAuthoringKit;
14
- getModelValue: () => string;
15
- getDebounceMs: () => number;
16
- getOutputOptions: () => TiptapToMDCOptions;
17
- text: EditorText;
18
- pendingImages: Ref<number>;
19
- pendingCommands: Ref<number>;
20
- emitSource: (value: string) => void;
21
- emitError: (payload: ConversionErrorPayload) => void;
22
- emitRecovered: (payload: ConversionRecoveredPayload) => void;
23
- /** Show why a flush cannot finish while an image operation is open. */
24
- onImagesPending: (message: string) => void;
25
- /** Discard transient visual state before another document replaces it. */
26
- beforeLoad: () => void;
27
- /** Close visual-only UI before the Markdown source replaces the canvas. */
28
- beforeSource: () => void;
29
- }
30
- /**
31
- * Own the Markdown value, its conversion to and from the canvas, and mode changes.
32
- * Markdown stays canonical: the canvas only emits a value after a validated conversion.
33
- */
34
- export declare function useMarkdownSync(options: MarkdownSyncOptions): {
35
- viewMode: Ref<EditorViewMode, EditorViewMode>;
36
- rawContent: Ref<string, string>;
37
- conversionError: Ref<{
38
- traceId: string;
39
- phase: import("../index.js").ConversionPhase;
40
- code: import("../index.js").ConversionIssueCode;
41
- message: string;
42
- recoverable: boolean;
43
- issues: {
44
- code: import("../index.js").ConversionIssueCode;
45
- severity: import("../index.js").ConversionSeverity;
46
- phase: import("../index.js").ConversionPhase;
47
- message: string;
48
- detail?: unknown;
49
- context?: Record<string, unknown> | undefined;
50
- }[];
51
- timeline: {
52
- at: string;
53
- kind: "finish" | "issue" | "phase" | "start";
54
- phase?: import("../index.js").ConversionPhase | undefined;
55
- data?: Record<string, unknown> | undefined;
56
- issueCode?: import("../index.js").ConversionIssueCode | undefined;
57
- message?: string | undefined;
58
- severity?: import("../index.js").ConversionSeverity | undefined;
59
- }[];
60
- } | null, ConversionErrorPayload | {
61
- traceId: string;
62
- phase: import("../index.js").ConversionPhase;
63
- code: import("../index.js").ConversionIssueCode;
64
- message: string;
65
- recoverable: boolean;
66
- issues: {
67
- code: import("../index.js").ConversionIssueCode;
68
- severity: import("../index.js").ConversionSeverity;
69
- phase: import("../index.js").ConversionPhase;
70
- message: string;
71
- detail?: unknown;
72
- context?: Record<string, unknown> | undefined;
73
- }[];
74
- timeline: {
75
- at: string;
76
- kind: "finish" | "issue" | "phase" | "start";
77
- phase?: import("../index.js").ConversionPhase | undefined;
78
- data?: Record<string, unknown> | undefined;
79
- issueCode?: import("../index.js").ConversionIssueCode | undefined;
80
- message?: string | undefined;
81
- severity?: import("../index.js").ConversionSeverity | undefined;
82
- }[];
83
- } | null>;
84
- hasPendingVisualChanges: Ref<boolean, boolean>;
85
- loaded: Ref<boolean, boolean>;
86
- /** Changes whenever the canvas document is replaced or edited. */
87
- revision: () => number;
88
- isDisposed: () => boolean;
89
- isApplyingDocument: () => boolean;
90
- scheduleVisualUpdate: (instance: Editor) => void;
91
- flush: () => Promise<EditorFlushResult>;
92
- showSource: () => Promise<void>;
93
- showVisual: () => Promise<void>;
94
- updateRaw: (value: string) => void;
95
- };
96
- export type MarkdownSync = ReturnType<typeof useMarkdownSync>;
@@ -1,16 +0,0 @@
1
- import { type ShallowRef } from 'vue';
2
- import type { AuthoringKit } from '../authoring.js';
3
- /** JSON with sorted object keys, so equal kits from separate objects compare equal. */
4
- export declare function stableJson(value: unknown): string;
5
- export interface StableAuthoringKit {
6
- /** Changes identity only when the kit content changes. */
7
- kit: ShallowRef<AuthoringKit | undefined>;
8
- /** Increments only when the Content policy changes. */
9
- policyRevision: ShallowRef<number>;
10
- }
11
- /**
12
- * Hosts often pass a new, equal kit object on each render. Keep the previous
13
- * object until the content changes, so equal kits do not reload the document,
14
- * abort uploads, or close a shared session.
15
- */
16
- export declare function useStableAuthoringKit(getKit: () => AuthoringKit | undefined): StableAuthoringKit;