@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,18 +0,0 @@
1
- import { type CollaborationPresenceUpdate } from './protocol.js';
2
- /**
3
- * Deterministic, readable caret color for a client ID.
4
- * @experimental
5
- */
6
- export declare function collaborationColor(clientId: string): string;
7
- /** @internal */
8
- export declare function sanitizeCollaborationUser(user: unknown, clientId: string): {
9
- id?: string;
10
- name: string;
11
- color: string;
12
- };
13
- /**
14
- * Read an untrusted presence record, for example in a server mutation.
15
- * Returns a normalized copy, or null for a malformed record.
16
- * @experimental
17
- */
18
- export declare function readCollaborationPresence(value: unknown): CollaborationPresenceUpdate | null;
@@ -1,103 +0,0 @@
1
- import type { Node } from '@tiptap/pm/model';
2
- import type { EditorState } from '@tiptap/pm/state';
3
- import { Mapping, type StepMap } from '@tiptap/pm/transform';
4
- import { DecorationSet } from '@tiptap/pm/view';
5
- import { type CollaborationPresenceChannel, type CollaborationPresenceSelection, type CollaborationUser } from './protocol.js';
6
- /**
7
- * A remote collaborator, with its selection mapped into this editor's current document.
8
- * @experimental
9
- */
10
- export interface CollaborationPeer {
11
- clientId: string;
12
- user: {
13
- id?: string;
14
- name: string;
15
- color: string;
16
- };
17
- /** Null when the peer has no selection or its document version cannot be mapped yet. */
18
- selection: CollaborationPresenceSelection | null;
19
- /** Confirmed document version that the peer reported. */
20
- version: number;
21
- updatedAt: number;
22
- }
23
- /** @experimental */
24
- export interface CollaborationPresenceOptions {
25
- /** Minimum time between two published updates. Default: 100 ms. */
26
- throttleMs?: number;
27
- /** Republish an unchanged state after this time. Default: 10 s. */
28
- heartbeatMs?: number;
29
- /** Remove peers that sent no new state for this time. Default: 30 s. */
30
- expiryMs?: number;
31
- /** Hide a peer's selection when it is more confirmed steps behind this editor. Default: 256. */
32
- maxVersionLag?: number;
33
- }
34
- /** Recent confirmed step maps, so a peer's older positions can be mapped forward. */
35
- export declare class ConfirmedHistory {
36
- private start;
37
- private readonly limit;
38
- private maps;
39
- constructor(start: number, limit?: number);
40
- get end(): number;
41
- append(fromVersion: number, maps: readonly StepMap[]): void;
42
- reset(version: number): void;
43
- /** Mapping from `from` to `to`, or null when the history no longer covers it. */
44
- mapping(from: number, to: number): Mapping | null;
45
- }
46
- /** Map a local selection back to the confirmed document, before unconfirmed steps. */
47
- export declare function toConfirmedSelection(state: EditorState, confirmedSize: number): CollaborationPresenceSelection;
48
- /**
49
- * Map a remote selection from its confirmed version into the local document:
50
- * first through accepted steps this editor has received since that version,
51
- * then through this editor's unconfirmed steps.
52
- */
53
- export declare function toLocalSelection(state: EditorState, history: ConfirmedHistory, selection: CollaborationPresenceSelection, version: number, maxVersionLag: number): CollaborationPresenceSelection | null;
54
- /** Build remote carets and selection highlights. Labels are hidden from assistive technology. */
55
- export declare function peerDecorations(doc: Node, peers: readonly CollaborationPeer[]): DecorationSet;
56
- interface PresenceTrackerOptions extends CollaborationPresenceOptions {
57
- clientId: string;
58
- epoch: string;
59
- channel: CollaborationPresenceChannel;
60
- user?: CollaborationUser;
61
- history: ConfirmedHistory;
62
- getState: () => EditorState | undefined;
63
- getConfirmedSize: () => number;
64
- /** Ask the editor to redraw decorations. */
65
- redraw: () => void;
66
- }
67
- /** Publishes local presence and tracks remote peers. Presence failures never affect editing. */
68
- export declare class PresenceTracker {
69
- private readonly options;
70
- private readonly peersById;
71
- private readonly listeners;
72
- private readonly user?;
73
- private mapped;
74
- private cache?;
75
- private revision;
76
- private unsubscribe?;
77
- private publishTimer?;
78
- private heartbeat?;
79
- private expiry?;
80
- private dirty;
81
- private lastPublishedAt;
82
- private lastSent?;
83
- private stopped;
84
- constructor(options: PresenceTrackerOptions);
85
- private get throttleMs();
86
- private get heartbeatMs();
87
- private get expiryMs();
88
- private get maxVersionLag();
89
- start(): void;
90
- /** Stop presence. `redraw` removes remote carets from a live editor. */
91
- stop(redraw?: boolean): void;
92
- get peers(): readonly CollaborationPeer[];
93
- onPeersChange(listener: (peers: readonly CollaborationPeer[]) => void): () => void;
94
- /** Call after any local selection, document or version change. */
95
- changed(): void;
96
- private publish;
97
- receive(updates: readonly unknown[]): void;
98
- private expire;
99
- private update;
100
- private map;
101
- decorations(state: EditorState): DecorationSet;
102
- }
103
- export {};
@@ -1,133 +0,0 @@
1
- /**
2
- * Increment when a wire step or the shared document schema changes.
3
- * `test/collaboration-schema.test.ts` fails when the schema fingerprint changes
4
- * without a new revision.
5
- * @experimental
6
- */
7
- export declare const editorSchemaRevision: "ginko-editor-2";
8
- /**
9
- * Version of the message envelope: heads, batches, replies and presence.
10
- * The schema revision identifies document content; this value identifies the
11
- * shape of the messages around it.
12
- * @experimental
13
- */
14
- export declare const collaborationProtocolVersion: 1;
15
- /** @experimental */
16
- export interface CollaborationFence {
17
- /** A new value fences clients after import, restore, or source replacement. */
18
- epoch: string;
19
- schemaRevision: string;
20
- /** The host changes this when the allowed content policy changes. */
21
- policyRevision: string;
22
- }
23
- /** @experimental */
24
- export interface CollaborationHead extends CollaborationFence {
25
- version: number;
26
- /**
27
- * Message envelope version. Clients send `1` with pull and push requests.
28
- * A missing value is read as version `1`; any other value is rejected.
29
- */
30
- protocolVersion?: typeof collaborationProtocolVersion;
31
- }
32
- /** @experimental */
33
- export interface CollaborationSnapshot extends CollaborationHead {
34
- /** ProseMirror JSON encoded as a string, including MDC's reserved `$` key. */
35
- document: string;
36
- }
37
- /** @experimental */
38
- export interface CollaborationSteps extends CollaborationHead {
39
- clientId: string;
40
- steps: string[];
41
- }
42
- /** @experimental */
43
- export interface CollaborationUpdate extends CollaborationHead {
44
- /** Version immediately before the first returned step. */
45
- fromVersion: number;
46
- steps: string[];
47
- clientIds: string[];
48
- }
49
- /** @experimental */
50
- export type CollaborationReply = {
51
- status: 'ok';
52
- update: CollaborationUpdate;
53
- } | {
54
- status: 'stale';
55
- head: CollaborationHead;
56
- reason: 'epoch' | 'schema' | 'policy' | 'history';
57
- };
58
- /** A collaborator's display identity. The host supplies it from its own accounts. */
59
- export interface CollaborationUser {
60
- /** Stable host account identifier. Do not use a secret or an email address. */
61
- id?: string;
62
- name: string;
63
- /** A CSS color: `#rgb`, `#rrggbb`, `rgb(...)` or `hsl(...)`. Derived from the client ID when omitted. */
64
- color?: string;
65
- }
66
- /**
67
- * Positions refer to the confirmed document at `version` in `epoch`.
68
- * @experimental
69
- */
70
- export interface CollaborationPresenceSelection {
71
- anchor: number;
72
- head: number;
73
- }
74
- /** One client's ephemeral presence record. The host must not store it with the document. */
75
- export interface CollaborationPresenceUpdate {
76
- protocolVersion: typeof collaborationProtocolVersion;
77
- clientId: string;
78
- user: CollaborationUser;
79
- epoch: string;
80
- /** Confirmed document version for the selection positions. */
81
- version: number;
82
- selection: CollaborationPresenceSelection | null;
83
- /** Milliseconds since the Unix epoch. Hosts should replace it with the server time. */
84
- updatedAt: number;
85
- }
86
- /**
87
- * Optional awareness channel. Presence is best effort: it never changes the
88
- * document and a failure never stops editing. The host must apply the same
89
- * document authorization and expire records it has not seen recently.
90
- * @experimental
91
- */
92
- export interface CollaborationPresenceChannel {
93
- publish(update: CollaborationPresenceUpdate): Promise<void> | void;
94
- /** Deliver all current records for the document, including this client's own record. */
95
- subscribe(onPeers: (updates: readonly CollaborationPresenceUpdate[]) => void): () => void;
96
- /** Remove this client's record when the session closes. */
97
- leave?(clientId: string): Promise<void> | void;
98
- }
99
- /**
100
- * The host closes over the document ID and supplies its authenticated client.
101
- * @experimental
102
- */
103
- export interface CollaborationTransport {
104
- subscribe(onHead: (head: CollaborationHead) => void, onError: (error: unknown) => void): () => void;
105
- pull(head: CollaborationHead): Promise<CollaborationReply>;
106
- push(batch: CollaborationSteps): Promise<CollaborationReply>;
107
- presence?: CollaborationPresenceChannel;
108
- }
109
- /** @experimental */
110
- export declare const collaborationLimits: Readonly<{
111
- documentBytes: number;
112
- batchBytes: number;
113
- stepsPerBatch: 128;
114
- jsonDepth: 64;
115
- }>;
116
- /**
117
- * Validation and transport failure codes. Servers use the first eight codes.
118
- * A host transport can throw `forbidden` for revoked access and `unavailable`
119
- * for a temporary server failure that the session should retry.
120
- * @experimental
121
- */
122
- export type CollaborationErrorCode = 'invalid' | 'limit' | 'version' | 'epoch' | 'schema' | 'policy' | 'content' | 'protocol' | 'forbidden' | 'unavailable';
123
- /** @experimental */
124
- export declare class CollaborationError extends Error {
125
- readonly code: CollaborationErrorCode;
126
- constructor(code: CollaborationErrorCode, message: string);
127
- }
128
- export declare function assertProtocolVersion(value: {
129
- protocolVersion?: unknown;
130
- }): void;
131
- export declare function assertCollaborationHead(head: CollaborationHead): void;
132
- /** @experimental */
133
- export declare function fenceMismatch(left: CollaborationFence, right: CollaborationFence): 'epoch' | 'schema' | 'policy' | undefined;
@@ -1,45 +0,0 @@
1
- import type { TiptapToMDCOptions } from '../tiptapToMdc.js';
2
- import { type CollaborationRecovery } from './session.js';
3
- /** @experimental */
4
- export type CollaborationRecoveryMarkdown = {
5
- ok: true;
6
- markdown: string;
7
- } | {
8
- ok: false;
9
- message: string;
10
- };
11
- /** @experimental */
12
- export type CollaborationRecoveryReadResult =
13
- /** Same schema revision. Pass `recovery` to a new session; construction still checks its document fence. */
14
- {
15
- status: 'current';
16
- recovery: CollaborationRecovery;
17
- }
18
- /** Older or newer schema revision. The pending document was converted to Markdown for manual reuse. */
19
- | {
20
- status: 'converted';
21
- schemaRevision: string;
22
- recovery: CollaborationRecovery;
23
- markdown: string;
24
- }
25
- /** The copy cannot be read or converted. Offer the stored text as a download. */
26
- | {
27
- status: 'unreadable';
28
- reason: 'format' | 'content';
29
- message: string;
30
- };
31
- /**
32
- * Convert the pending document in a recovery copy to Markdown with the current
33
- * schema. This does not check a Content policy; validate the result before use.
34
- * @experimental
35
- */
36
- export declare function collaborationRecoveryToMarkdown(recovery: CollaborationRecovery, output?: TiptapToMDCOptions): Promise<CollaborationRecoveryMarkdown>;
37
- /**
38
- * Read host-stored recovery text. A copy from the current schema revision is
39
- * returned for a new session. A copy from another schema revision cannot be
40
- * rebased, so its pending document is converted to Markdown when possible.
41
- * @experimental
42
- */
43
- export declare function readCollaborationRecovery(source: string, options?: {
44
- output?: TiptapToMDCOptions;
45
- }): Promise<CollaborationRecoveryReadResult>;
@@ -1,163 +0,0 @@
1
- import { Extension, type JSONContent } from '@tiptap/core';
2
- import { CollaborationError, type CollaborationHead, type CollaborationSnapshot, type CollaborationTransport, type CollaborationUser } from './protocol.js';
3
- import { type CollaborationPeer, type CollaborationPresenceOptions } from './presence.js';
4
- /** @experimental */
5
- export type CollaborationStatus = 'connecting' | 'syncing' | 'synced' | 'offline' | 'error' | 'stale' | 'closed';
6
- /**
7
- * Reason for an `offline`, `error` or `stale` state, or for a refused local change.
8
- * `offline`, `timeout` and `unavailable` retry automatically with backoff.
9
- * `rejected` means the server refused pending changes: call `discardPendingAndResync()`.
10
- * `schema_mismatch`, `policy_mismatch`, `replaced` and `history_expired` require a reopen.
11
- * @experimental
12
- */
13
- export type CollaborationStateCode = 'offline' | 'timeout' | 'unavailable' | 'rejected' | 'forbidden' | 'schema_mismatch' | 'policy_mismatch' | 'replaced' | 'history_expired' | 'conflict' | 'storage' | 'limit' | 'internal';
14
- /** @experimental */
15
- export interface CollaborationState {
16
- status: CollaborationStatus;
17
- version: number;
18
- pendingSteps: number;
19
- message?: string;
20
- code?: CollaborationStateCode;
21
- }
22
- /**
23
- * Hosts use this for connection failures. The session keeps local edits and retries.
24
- * @experimental
25
- */
26
- export declare class CollaborationConnectionError extends CollaborationError {
27
- constructor(message?: string);
28
- }
29
- /** @experimental */
30
- export interface CollaborationRecovery {
31
- format: 1;
32
- clientId: string;
33
- base: CollaborationSnapshot;
34
- steps: string[];
35
- /** Step counts for the original transactions. A batch must not split one. */
36
- groups: number[];
37
- /** Derived from base + steps, retained for recovery if a future client cannot decode old steps. */
38
- document: string;
39
- }
40
- /**
41
- * Parse host-owned recovery storage without trusting its JSON shape.
42
- * @experimental
43
- */
44
- export declare function parseCollaborationRecovery(source: string): CollaborationRecovery;
45
- /** @experimental */
46
- export interface EditorCollaborationOptions {
47
- clientId: string;
48
- snapshot: CollaborationSnapshot;
49
- transport: CollaborationTransport;
50
- recovery?: CollaborationRecovery;
51
- /**
52
- * Persist synchronously in host-owned storage. Throw if the recovery copy cannot be saved.
53
- * The session calls it at most once per `recoveryDelayMs`, when the page is hidden,
54
- * and from `flushRecovery()`, `flush()`, `discardPendingAndResync()` and `close()`.
55
- */
56
- onRecovery?: (recovery: CollaborationRecovery | null) => void;
57
- /** Delay for `onRecovery` writes. `0` writes after every change. Default: 300 ms. */
58
- recoveryDelayMs?: number;
59
- /** Receives unsent changes before `discardPendingAndResync()` removes them. Throw to keep them. */
60
- onDiscard?: (recovery: CollaborationRecovery) => void;
61
- /** Time limit for one pull or push request. Default: 15 s. */
62
- requestTimeoutMs?: number;
63
- /** Retry delay bounds. Each retry waits a random time up to the current bound. */
64
- backoff?: {
65
- initialMs?: number;
66
- maxMs?: number;
67
- };
68
- /** Local collaborator identity for presence. Without it, the session only shows other collaborators. */
69
- user?: CollaborationUser;
70
- /** Presence tuning, or `false` to turn presence off when the transport supports it. */
71
- presence?: false | CollaborationPresenceOptions;
72
- }
73
- interface Failure {
74
- status: 'offline' | 'error' | 'stale';
75
- code: CollaborationStateCode;
76
- message: string;
77
- }
78
- /** Classify a transport or validation failure. Unknown failures while sending are rejections. */
79
- export declare function classifyCollaborationFailure(error: unknown, sending?: boolean): Failure;
80
- /**
81
- * One session belongs to one mounted editor. Hosts own identity, transport and storage.
82
- * @experimental
83
- */
84
- export declare class EditorCollaborationSession {
85
- private readonly options;
86
- readonly extension: Extension;
87
- readonly initialDocument: JSONContent;
88
- private readonly initial;
89
- private readonly clientId;
90
- private readonly collabPlugin;
91
- private readonly history;
92
- private readonly presence?;
93
- private instance?;
94
- private confirmed;
95
- private current;
96
- private listeners;
97
- private unsubscribe?;
98
- private timer?;
99
- private timerDue;
100
- private busy;
101
- private requested;
102
- private generation;
103
- private observedVersion;
104
- private attempt;
105
- private restored;
106
- private restoring;
107
- private orphanOwnSteps;
108
- private recoveryTimer?;
109
- private recoveryDirty;
110
- private recoveryStored;
111
- private stepSizes;
112
- private docSizes;
113
- private estimate?;
114
- private removeWindowListeners?;
115
- constructor(options: EditorCollaborationOptions);
116
- get state(): Readonly<CollaborationState>;
117
- get canEdit(): boolean;
118
- /** Remote collaborators with selections mapped into this document. Empty without a presence channel. */
119
- get peers(): readonly CollaborationPeer[];
120
- /** Calls the listener now and after each collaborator change. Returns a cleanup function. */
121
- onPeersChange(listener: (peers: readonly CollaborationPeer[]) => void): () => void;
122
- subscribe(listener: (state: CollaborationState) => void): () => void;
123
- private setState;
124
- private refuse;
125
- private stepSize;
126
- private docSize;
127
- /**
128
- * Upper estimate of the next document size. Plain replace steps grow the JSON
129
- * by about their own size; the estimate doubles it and measures exactly near
130
- * the limit, after other step types and after a bounded number of estimates.
131
- */
132
- private nextDocumentSize;
133
- private filterLocal;
134
- private attach;
135
- private listenToPage;
136
- private startSubscription;
137
- private changed;
138
- private queueRecovery;
139
- /** Write the current recovery copy through `onRecovery` now. Returns false if the host could not save it. */
140
- flushRecovery(): boolean;
141
- getRecovery(): CollaborationRecovery | null;
142
- private schedule;
143
- private backoffDelay;
144
- private head;
145
- private request;
146
- private apply;
147
- private pump;
148
- private fail;
149
- /** Try again now. Pending changes are sent again; after a rejection use `discardPendingAndResync()`. */
150
- retry(): void;
151
- /**
152
- * Remove unsent local changes and continue from the last accepted document.
153
- * `onDiscard` receives the removed changes first; if it throws, nothing is removed.
154
- * Returns the removed recovery copy, or null when nothing was pending.
155
- */
156
- discardPendingAndResync(): CollaborationRecovery | null;
157
- /** Resolves only when all local steps have been accepted. The host owns publication. */
158
- flush(timeoutMs?: number): Promise<CollaborationHead>;
159
- close(): void;
160
- }
161
- /** @experimental */
162
- export declare function createEditorCollaboration(options: EditorCollaborationOptions): EditorCollaborationSession;
163
- export {};
@@ -1,42 +0,0 @@
1
- import type { Node, Schema } from '@tiptap/pm/model';
2
- import { Step } from '@tiptap/pm/transform';
3
- import { type PortableComponentPolicyV2 } from '@lupinum/ginko-content/cms-contract';
4
- import type { TiptapToMDCOptions } from '../tiptapToMdc.js';
5
- import { type CollaborationSnapshot, type CollaborationSteps } from './protocol.js';
6
- /** Step IDs accepted on the wire. Changing this list requires a new schema revision. */
7
- export declare const collaborationWireSteps: readonly string[];
8
- export declare function stableJson(value: unknown, depth?: number): string;
9
- /**
10
- * Reject unknown nodes, attributes and malformed shapes instead of dropping them.
11
- * @experimental
12
- */
13
- export declare function decodeCollaborationDocument(source: string, schema?: Schema): Node;
14
- /**
15
- * The caller must check host authorization and the document fence first.
16
- * @experimental
17
- */
18
- export declare function decodeCollaborationSteps(encoded: readonly string[], schema?: Schema): Step[];
19
- /** @experimental */
20
- export interface CollaborationContentOptions {
21
- policy: PortableComponentPolicyV2;
22
- output?: TiptapToMDCOptions;
23
- }
24
- /** @experimental */
25
- export interface CollaborationCheckpoint {
26
- snapshot: CollaborationSnapshot;
27
- /** Derived from the accepted snapshot, never taken from a client checkpoint. */
28
- markdown: string;
29
- }
30
- /**
31
- * Seed or replace a room only inside a host-authorized transaction with a new epoch.
32
- * @experimental
33
- */
34
- export declare function createCollaborationSnapshot(markdown: string, options: CollaborationContentOptions & {
35
- epoch: string;
36
- policyRevision: string;
37
- }): Promise<CollaborationCheckpoint>;
38
- /**
39
- * Apply an exact-version batch. Persist the result and operation log atomically.
40
- * @experimental
41
- */
42
- export declare function applyCollaborationSteps(snapshot: CollaborationSnapshot, batch: CollaborationSteps, options: CollaborationContentOptions): Promise<CollaborationCheckpoint>;
@@ -1,119 +0,0 @@
1
- /**
2
- * Component converters for MDC to TipTap transformation
3
- *
4
- * Handles custom components: file, image, video, template, comment, etc.
5
- */
6
- import type { JSONContent } from '@tiptap/core';
7
- import type { JsonRecord } from '../types.js';
8
- import type { MDCElement, MDCNode } from './mdcTypes.js';
9
- /**
10
- * Creates a file node
11
- */
12
- export declare function createFileNode(node: MDCNode, createTipTapNodeFn: (node: MDCElement, type: string, extra?: {
13
- attrs?: JsonRecord;
14
- children?: MDCNode[];
15
- }) => JSONContent): JSONContent;
16
- /**
17
- * Creates an image node (handles Image, image, and img tags)
18
- */
19
- export declare function createImageNode(node: MDCNode, createTipTapNodeFn: (node: MDCElement, type: string, extra?: {
20
- attrs?: JsonRecord;
21
- children?: MDCNode[];
22
- }) => JSONContent): JSONContent;
23
- /**
24
- * Creates a video node
25
- */
26
- export declare function createVideoNode(node: MDCNode, createTipTapNodeFn: (node: MDCElement, type: string, extra?: {
27
- attrs?: JsonRecord;
28
- children?: MDCNode[];
29
- }) => JSONContent): JSONContent;
30
- /**
31
- * Creates a comment node
32
- */
33
- export declare function createCommentNode(node: MDCNode, createTipTapNodeFn: (node: MDCElement, type: string, extra?: {
34
- attrs?: JsonRecord;
35
- children?: MDCNode[];
36
- }) => JSONContent): JSONContent;
37
- /**
38
- * Creates a blockquote node
39
- */
40
- export declare function createBlockquoteNode(node: MDCNode, createTipTapNodeFn: (node: MDCElement, type: string, extra?: {
41
- attrs?: JsonRecord;
42
- children?: MDCNode[];
43
- }) => JSONContent): JSONContent;
44
- /**
45
- * Creates a horizontal rule node
46
- */
47
- export declare function createHrNode(node: MDCNode, createTipTapNodeFn: (node: MDCElement, type: string, extra?: {
48
- attrs?: JsonRecord;
49
- children?: MDCNode[];
50
- }) => JSONContent): JSONContent;
51
- /**
52
- * Creates a hard break node
53
- */
54
- export declare function createBrNode(node: MDCNode, createTipTapNodeFn: (node: MDCElement, type: string, extra?: {
55
- attrs?: JsonRecord;
56
- children?: MDCNode[];
57
- }) => JSONContent): JSONContent;
58
- /**
59
- * Creates a table node
60
- */
61
- export declare function createTableNode(node: MDCNode, createTipTapNodeFn: (node: MDCElement, type: string, extra?: {
62
- attrs?: JsonRecord;
63
- children?: MDCNode[];
64
- }) => JSONContent): JSONContent;
65
- /**
66
- * Creates a table row node
67
- */
68
- export declare function createTrNode(node: MDCNode, createTipTapNodeFn: (node: MDCElement, type: string, extra?: {
69
- attrs?: JsonRecord;
70
- children?: MDCNode[];
71
- }) => JSONContent): JSONContent;
72
- /**
73
- * Creates a table header cell node
74
- */
75
- export declare function createThNode(node: MDCNode, createTableCellNodeFn: (node: MDCElement, type: 'tableCell' | 'tableHeader') => JSONContent): JSONContent;
76
- /**
77
- * Creates a table data cell node
78
- */
79
- export declare function createTdNode(node: MDCNode, createTableCellNodeFn: (node: MDCElement, type: 'tableCell' | 'tableHeader') => JSONContent): JSONContent;
80
- /**
81
- * Creates an ordered list node
82
- */
83
- export declare function createOlNode(node: MDCNode, createTipTapNodeFn: (node: MDCElement, type: string, extra?: {
84
- attrs?: JsonRecord;
85
- children?: MDCNode[];
86
- }) => JSONContent): JSONContent;
87
- /**
88
- * Creates an unordered list node
89
- */
90
- export declare function createUlNode(node: MDCNode, createTipTapNodeFn: (node: MDCElement, type: string, extra?: {
91
- attrs?: JsonRecord;
92
- children?: MDCNode[];
93
- }) => JSONContent): JSONContent;
94
- /**
95
- * Creates a list item node
96
- */
97
- export declare function createLiNode(node: MDCNode, createListItemNodeFn: (node: MDCElement) => JSONContent): JSONContent;
98
- /**
99
- * Creates a paragraph node
100
- */
101
- export declare function createPNode(node: MDCNode, createParagraphNodeFn: (node: MDCElement, options?: {
102
- allowImageLift?: boolean;
103
- }) => JSONContent | JSONContent[]): JSONContent | JSONContent[];
104
- /**
105
- * Creates a pre/code block node
106
- */
107
- export declare function createPreNodeWrapper(node: MDCNode, createPreNodeFn: (node: MDCElement) => JSONContent): JSONContent;
108
- /**
109
- * Creates a span-style node
110
- */
111
- export declare function createSpanNode(node: MDCNode, createSpanStyleNodeFn: (node: MDCElement) => JSONContent): JSONContent;
112
- /**
113
- * Creates a template/slot node
114
- */
115
- export declare function createTemplateNodeWrapper(node: MDCNode, createTemplateNodeFn: (node: MDCElement) => JSONContent): JSONContent;
116
- /**
117
- * Creates a text node. Text is kept verbatim; MDC syntax is handled by the parser.
118
- */
119
- export declare function createTextNodeWrapper(node: MDCNode): JSONContent;
@@ -1,19 +0,0 @@
1
- import type { NodeViewRenderer } from '@tiptap/core';
2
- import type { AuthoringKit } from '../../authoring.js';
3
- import type { JsonRecord } from '../../types.js';
4
- import type { TiptapToMDCOptions } from '../tiptapToMdc.js';
5
- interface DocumentExtensionOptions {
6
- getAuthoringKit?: () => AuthoringKit | undefined;
7
- getOutputOptions?: () => TiptapToMDCOptions;
8
- nodeViews?: Partial<Record<'codeBlock' | 'element' | 'image' | 'table', NodeViewRenderer>>;
9
- resolveAsset?: (props: JsonRecord) => string | null | undefined;
10
- showMarkdownMarkers?: boolean;
11
- codeBlockTheme?: string;
12
- /** Levels that commands and input rules can create. The schema accepts all six. */
13
- headingLevels?: readonly number[];
14
- }
15
- /** Schema-affecting definitions are shared by the canvas and server conversion. */
16
- export declare function createDocumentExtensions(options?: DocumentExtensionOptions): (import("@tiptap/core").Node<import("../extensions/code-block.js").CodeBlockOptions, any> | import("@tiptap/core").Node<import("../extensions/element.js").ElementOptions, any> | import("@tiptap/core").Node<import("../extensions/file.js").FileOptions, any> | import("@tiptap/core").Node<import("../extensions/heading.js").HeadingOptions, any> | import("@tiptap/core").Node<import("../extensions/image.js").ImageOptions, any> | import("@tiptap/core").Node<import("../extensions/inline-element.js").InlineElementOptions, any> | import("@tiptap/core").Node<import("../extensions/slot.js").SlotOptions, any> | import("@tiptap/core").Node<import("../extensions/span-style.js").SpanStyleAttrs, any> | import("@tiptap/core").Node<any, any> | import("@tiptap/core").Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-table").TableRowOptions, any>)[];
17
- /** Build the supported document schema without creating an editor or reading the DOM. */
18
- export declare function createEditorSchema(): import("@tiptap/pm/model").Schema<any, any>;
19
- export {};