@pixerate/editor 0.23.0 → 0.24.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.
- package/README.md +96 -1
- package/THIRD_PARTY_NOTICES.md +51 -0
- package/dist/agent/index.cjs +9 -8
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +4 -3
- package/dist/agent/index.d.ts +4 -3
- package/dist/agent/index.js +3 -2
- package/dist/agent/index.js.map +1 -1
- package/dist/canvas/index.cjs +1210 -17
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +318 -1
- package/dist/canvas/index.d.ts +318 -1
- package/dist/canvas/index.js +1199 -6
- package/dist/canvas/index.js.map +1 -1
- package/dist/{chunk-QBJ22YZR.js → chunk-3CN2WD3X.js} +1354 -206
- package/dist/chunk-3CN2WD3X.js.map +1 -0
- package/dist/{chunk-JJDLPEWL.js → chunk-3LV6RRPH.js} +2 -2
- package/dist/{chunk-MJZBNWG7.js → chunk-5S3Z4PPF.js} +78 -557
- package/dist/chunk-5S3Z4PPF.js.map +1 -0
- package/dist/chunk-664LQYFJ.js +115 -0
- package/dist/chunk-664LQYFJ.js.map +1 -0
- package/dist/{chunk-AA4ZEVCC.cjs → chunk-D27YFC46.cjs} +101 -580
- package/dist/chunk-D27YFC46.cjs.map +1 -0
- package/dist/chunk-D6FH2YAX.cjs +131 -0
- package/dist/chunk-D6FH2YAX.cjs.map +1 -0
- package/dist/{chunk-4SUNJZWB.cjs → chunk-FD4LPFAE.cjs} +48 -200
- package/dist/chunk-FD4LPFAE.cjs.map +1 -0
- package/dist/chunk-FODNLX5N.js +749 -0
- package/dist/chunk-FODNLX5N.js.map +1 -0
- package/dist/{chunk-OYXSKQFR.js → chunk-FPENXAEJ.js} +35 -187
- package/dist/chunk-FPENXAEJ.js.map +1 -0
- package/dist/chunk-HLIMTC6N.js +1 -0
- package/dist/chunk-HLIMTC6N.js.map +1 -0
- package/dist/{chunk-QGHGJ56O.js → chunk-ITBSKI26.js} +1483 -19
- package/dist/chunk-ITBSKI26.js.map +1 -0
- package/dist/{chunk-XDMXXC4Z.cjs → chunk-MA2F5KHF.cjs} +350 -227
- package/dist/chunk-MA2F5KHF.cjs.map +1 -0
- package/dist/{chunk-RIKBJLS2.cjs → chunk-MCSJFWAO.cjs} +1356 -208
- package/dist/chunk-MCSJFWAO.cjs.map +1 -0
- package/dist/chunk-MKA3AHLV.cjs +256 -0
- package/dist/chunk-MKA3AHLV.cjs.map +1 -0
- package/dist/chunk-OLZJXL4R.cjs +749 -0
- package/dist/chunk-OLZJXL4R.cjs.map +1 -0
- package/dist/chunk-OXSV64JX.js +689 -0
- package/dist/chunk-OXSV64JX.js.map +1 -0
- package/dist/chunk-P3RQ5UJE.cjs +689 -0
- package/dist/chunk-P3RQ5UJE.cjs.map +1 -0
- package/dist/chunk-P6ODPZ4W.js +256 -0
- package/dist/chunk-P6ODPZ4W.js.map +1 -0
- package/dist/chunk-PGNZKFQS.js +685 -0
- package/dist/chunk-PGNZKFQS.js.map +1 -0
- package/dist/chunk-PL4JB3BF.cjs +1 -0
- package/dist/chunk-PL4JB3BF.cjs.map +1 -0
- package/dist/{chunk-GVSMRPHB.cjs → chunk-SBCZ6RN5.cjs} +1568 -104
- package/dist/chunk-SBCZ6RN5.cjs.map +1 -0
- package/dist/{chunk-CL37JGFW.cjs → chunk-SML64VJG.cjs} +4 -4
- package/dist/{chunk-CL37JGFW.cjs.map → chunk-SML64VJG.cjs.map} +1 -1
- package/dist/chunk-TNNJXF46.cjs +115 -0
- package/dist/chunk-TNNJXF46.cjs.map +1 -0
- package/dist/chunk-U5HZSFCS.js +131 -0
- package/dist/chunk-U5HZSFCS.js.map +1 -0
- package/dist/{chunk-K3R5NG2D.js → chunk-U5KWZU4X.js} +251 -128
- package/dist/chunk-U5KWZU4X.js.map +1 -0
- package/dist/chunk-XNORY7M6.cjs +685 -0
- package/dist/chunk-XNORY7M6.cjs.map +1 -0
- package/dist/commands/index.d.cts +5 -353
- package/dist/commands/index.d.ts +5 -353
- package/dist/comment-store-BEMgVlAA.d.cts +135 -0
- package/dist/comment-store-BEMgVlAA.d.ts +135 -0
- package/dist/compare/index.cjs +15 -0
- package/dist/compare/index.cjs.map +1 -0
- package/dist/compare/index.d.cts +58 -0
- package/dist/compare/index.d.ts +58 -0
- package/dist/compare/index.js +15 -0
- package/dist/compare/index.js.map +1 -0
- package/dist/{controller-pePCJLT1.d.cts → controller-BhLLAoi8.d.cts} +45 -4
- package/dist/{controller-pePCJLT1.d.ts → controller-BhLLAoi8.d.ts} +45 -4
- package/dist/documents-BQjzJNe2.d.ts +76 -0
- package/dist/documents-KRTPhvst.d.cts +76 -0
- package/dist/extensions/index.cjs +53 -5
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +7 -3
- package/dist/extensions/index.d.ts +7 -3
- package/dist/extensions/index.js +52 -4
- package/dist/generation/index.cjs +1373 -0
- package/dist/generation/index.cjs.map +1 -0
- package/dist/generation/index.d.cts +554 -0
- package/dist/generation/index.d.ts +554 -0
- package/dist/generation/index.js +1373 -0
- package/dist/generation/index.js.map +1 -0
- package/dist/grammar/index.cjs +48 -3
- package/dist/grammar/index.cjs.map +1 -1
- package/dist/grammar/index.d.cts +322 -100
- package/dist/grammar/index.d.ts +322 -100
- package/dist/grammar/index.js +54 -9
- package/dist/image-editor/index.cjs +1831 -30
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +590 -3
- package/dist/image-editor/index.d.ts +590 -3
- package/dist/image-editor/index.js +1807 -6
- package/dist/image-editor/index.js.map +1 -1
- package/dist/{index-CCr_z9kF.d.cts → index-BhJBSm2d.d.cts} +370 -4
- package/dist/{index-Ck6ajwXh.d.ts → index-fJrlkJCd.d.ts} +370 -4
- package/dist/index.cjs +162 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -8
- package/dist/index.d.ts +14 -8
- package/dist/index.js +174 -37
- package/dist/index.js.map +1 -1
- package/dist/migrate-iTlm3a8h.d.cts +112 -0
- package/dist/migrate-iTlm3a8h.d.ts +112 -0
- package/dist/persistence/index.cjs +676 -0
- package/dist/persistence/index.cjs.map +1 -0
- package/dist/persistence/index.d.cts +347 -0
- package/dist/persistence/index.d.ts +347 -0
- package/dist/persistence/index.js +676 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/{registry-D5-R90p0.d.cts → registry-BDe-vlv3.d.ts} +2 -40
- package/dist/registry-D32LpIc4.d.cts +354 -0
- package/dist/{registry-D5-R90p0.d.ts → registry-DnzpgY27.d.cts} +2 -40
- package/dist/registry-evKTP4ls.d.ts +354 -0
- package/dist/schema-DYDGdYL9.d.cts +41 -0
- package/dist/schema-DYDGdYL9.d.ts +41 -0
- package/dist/serializers/index.cjs +4 -3
- package/dist/serializers/index.cjs.map +1 -1
- package/dist/serializers/index.d.cts +2 -1
- package/dist/serializers/index.d.ts +2 -1
- package/dist/serializers/index.js +3 -2
- package/dist/sourcemap-C8AH3MBQ.d.cts +91 -0
- package/dist/sourcemap-DA1Evhrv.d.ts +91 -0
- package/dist/spreadsheet/index.cjs +37 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.d.cts +188 -17
- package/dist/spreadsheet/index.d.ts +188 -17
- package/dist/spreadsheet/index.js +43 -9
- package/dist/{tokens-CyLZmIei.d.cts → tokens-D7yXvUU6.d.cts} +15 -2
- package/dist/{tokens-CyLZmIei.d.ts → tokens-D7yXvUU6.d.ts} +15 -2
- package/dist/{track-changes-BSF58RK0.d.ts → track-changes-BK5sVf4_.d.cts} +18 -136
- package/dist/{track-changes-BSF58RK0.d.cts → track-changes-CDjCrwKe.d.ts} +18 -136
- package/package.json +16 -1
- package/dist/chunk-4SUNJZWB.cjs.map +0 -1
- package/dist/chunk-AA4ZEVCC.cjs.map +0 -1
- package/dist/chunk-AXV2ZW34.cjs +0 -118
- package/dist/chunk-AXV2ZW34.cjs.map +0 -1
- package/dist/chunk-B2ZRLN4S.js +0 -118
- package/dist/chunk-B2ZRLN4S.js.map +0 -1
- package/dist/chunk-GVSMRPHB.cjs.map +0 -1
- package/dist/chunk-K3R5NG2D.js.map +0 -1
- package/dist/chunk-MJZBNWG7.js.map +0 -1
- package/dist/chunk-OYXSKQFR.js.map +0 -1
- package/dist/chunk-QBJ22YZR.js.map +0 -1
- package/dist/chunk-QGHGJ56O.js.map +0 -1
- package/dist/chunk-RIKBJLS2.cjs.map +0 -1
- package/dist/chunk-XDMXXC4Z.cjs.map +0 -1
- /package/dist/{chunk-JJDLPEWL.js.map → chunk-3LV6RRPH.js.map} +0 -0
package/dist/commands/index.d.ts
CHANGED
|
@@ -1,359 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as CommandRegistry, P as Platform, a as CommandResult, b as CommandEntry, K as KeyboardEventLike, S as ShortcutBinding, c as CommandSpec } from '../registry-evKTP4ls.js';
|
|
2
|
+
export { d as Chord, e as CommandErrorCode, f as CommandHistoryTarget, g as CommandListOptions, h as CommandParamsSchema, i as CommandRegistryError, j as CommandRegistryOptions, E as EffectiveChord, k as PLATFORMS, l as ShortcutConflict, m as ShortcutInput, n as ShortcutMap, o as ShortcutMapOptions, p as ShortcutMatch, q as ShortcutResolveOptions, r as chordToString, s as codeFromKey, t as codeToKeyText, u as createCommandRegistry, v as defineCommand, w as detectPlatform, x as effectiveChord, y as effectiveChordKey, z as eventCode, A as formatShortcut, B as isEditableEventTarget, D as keyToCode, F as normalizeChord, G as parseChord, H as shortcutCode, I as toShortcutBindings } from '../registry-evKTP4ls.js';
|
|
3
|
+
import { A as AgentToolProvider } from '../registry-BDe-vlv3.js';
|
|
2
4
|
import { H as HistoryState } from '../types-GT5a5YAX.js';
|
|
3
5
|
import { C as CanvasArrangeAction, A as AlignEdge, D as DistributeAxis, a as DistributeMode, Z as ZOrderOperation } from '../arrangeShortcuts-sLlD2rSX.js';
|
|
6
|
+
import '../schema-DYDGdYL9.js';
|
|
4
7
|
import '../types-DX4Mh4SL.js';
|
|
5
8
|
|
|
6
|
-
/**
|
|
7
|
-
* Keyboard chords in a platform-neutral notation.
|
|
8
|
-
*
|
|
9
|
-
* | token | macOS | Windows / Linux |
|
|
10
|
-
* |---|---|---|
|
|
11
|
-
* | `Mod` | ⌘ Command | Ctrl |
|
|
12
|
-
* | `Ctrl` | ⌃ Control | Ctrl (same key as `Mod`: conflicts are reported) |
|
|
13
|
-
* | `Meta` / `Cmd` | ⌘ Command | Win / Super |
|
|
14
|
-
* | `Alt` / `Option` | ⌥ Option | Alt |
|
|
15
|
-
* | `Shift` | ⇧ Shift | Shift |
|
|
16
|
-
*
|
|
17
|
-
* Keys are stored as `KeyboardEvent.code` values (`KeyZ`, `Digit1`, `BracketRight`,
|
|
18
|
-
* `PageDown`), so Option/Alt chords work on macOS (where Option changes `event.key`).
|
|
19
|
-
*/
|
|
20
|
-
type Platform = 'mac' | 'windows' | 'linux';
|
|
21
|
-
declare const PLATFORMS: readonly Platform[];
|
|
22
|
-
/** A parsed chord. `mod` is the platform's primary modifier. */
|
|
23
|
-
interface Chord {
|
|
24
|
-
/** `KeyboardEvent.code` of the key, e.g. `KeyZ`. */
|
|
25
|
-
key: string;
|
|
26
|
-
mod?: boolean;
|
|
27
|
-
ctrl?: boolean;
|
|
28
|
-
meta?: boolean;
|
|
29
|
-
alt?: boolean;
|
|
30
|
-
shift?: boolean;
|
|
31
|
-
}
|
|
32
|
-
/** The modifiers a chord needs on one platform (`mod` resolved to `meta` or `ctrl`). */
|
|
33
|
-
interface EffectiveChord {
|
|
34
|
-
key: string;
|
|
35
|
-
ctrl: boolean;
|
|
36
|
-
meta: boolean;
|
|
37
|
-
alt: boolean;
|
|
38
|
-
shift: boolean;
|
|
39
|
-
}
|
|
40
|
-
/** The current platform from `navigator` (`linux` when unknown, e.g. in Node). */
|
|
41
|
-
declare function detectPlatform(): Platform;
|
|
42
|
-
/** `KeyboardEvent.code` for a key token (`Z`, `1`, `]`, `PageDown`, `F5`, `KeyZ`), or `null`. */
|
|
43
|
-
declare function keyToCode(token: string): string | null;
|
|
44
|
-
/** Neutral text for a code: `KeyZ` → `Z`, `BracketRight` → `]`, `ArrowUp` → `Up`. */
|
|
45
|
-
declare function codeToKeyText(code: string): string;
|
|
46
|
-
/**
|
|
47
|
-
* Parses chord text (`Mod+Shift+Z`, `Alt+]`, `⌥⇧⌘K`, `CmdOrCtrl+K`). Throws on unknown
|
|
48
|
-
* modifiers or keys. The last `+`-separated token is the key (`+` itself is `Plus`).
|
|
49
|
-
*/
|
|
50
|
-
declare function parseChord(text: string): Chord;
|
|
51
|
-
/** Canonical platform-neutral text: `Mod+Ctrl+Meta+Alt+Shift+<key>`. */
|
|
52
|
-
declare function chordToString(chord: Chord): string;
|
|
53
|
-
/** Canonical spelling of chord text (`shift+cmdorctrl+z` → `Mod+Shift+Z`). Throws when invalid. */
|
|
54
|
-
declare function normalizeChord(text: string): string;
|
|
55
|
-
/** The modifiers a chord needs on `platform`: `Mod` is ⌘ (meta) on macOS and Ctrl elsewhere. */
|
|
56
|
-
declare function effectiveChord(chord: string | Chord, platform: Platform): EffectiveChord;
|
|
57
|
-
/** Identity of an effective chord, for conflict detection (`Ctrl+Shift+KeyZ`). */
|
|
58
|
-
declare function effectiveChordKey(chord: string | Chord, platform: Platform): string;
|
|
59
|
-
/**
|
|
60
|
-
* Display text: `⌥⇧⌘K` on macOS, `Ctrl+Alt+Shift+K` on Windows / Linux (`Meta` shows as
|
|
61
|
-
* `Win` / `Super`). Invalid text is returned unchanged.
|
|
62
|
-
*/
|
|
63
|
-
declare function formatShortcut(chord: string | Chord, platform?: Platform): string;
|
|
64
|
-
/** Minimal keyboard event surface (DOM `KeyboardEvent` satisfies it). */
|
|
65
|
-
interface KeyboardEventLike {
|
|
66
|
-
key?: string;
|
|
67
|
-
code?: string;
|
|
68
|
-
ctrlKey?: boolean;
|
|
69
|
-
metaKey?: boolean;
|
|
70
|
-
altKey?: boolean;
|
|
71
|
-
shiftKey?: boolean;
|
|
72
|
-
target?: EventTarget | null | unknown;
|
|
73
|
-
defaultPrevented?: boolean;
|
|
74
|
-
preventDefault?: () => void;
|
|
75
|
-
}
|
|
76
|
-
/** `event.code`, or one derived from `event.key` for synthetic events without a code. */
|
|
77
|
-
declare function eventCode(event: KeyboardEventLike): string;
|
|
78
|
-
/**
|
|
79
|
-
* The key code a shortcut event is matched by: `event.code` (layout-independent, so
|
|
80
|
-
* Option/Alt chords work on macOS and punctuation chords follow the physical key),
|
|
81
|
-
* except that a letter key producing a different Latin letter without Alt (AZERTY,
|
|
82
|
-
* QWERTZ, Dvorak) uses the produced letter, as browsers and operating systems do.
|
|
83
|
-
*/
|
|
84
|
-
declare function shortcutCode(event: KeyboardEventLike): string;
|
|
85
|
-
/** The code a printable `event.key` names on a US layout (`z` → `KeyZ`, `]` → `BracketRight`). */
|
|
86
|
-
declare function codeFromKey(key: string): string | null;
|
|
87
|
-
/**
|
|
88
|
-
* Whether a keyboard event comes from a text-entry element: `<input>`, `<textarea>`,
|
|
89
|
-
* `<select>`, a `contenteditable` element (or a descendant) or a ProseMirror editor.
|
|
90
|
-
* Falls back to `document.activeElement` when the event has no element target.
|
|
91
|
-
*/
|
|
92
|
-
declare function isEditableEventTarget(event: {
|
|
93
|
-
target?: unknown;
|
|
94
|
-
}): boolean;
|
|
95
|
-
|
|
96
|
-
/** One key binding: a chord that runs `command`, optionally only in one scope / on some platforms. */
|
|
97
|
-
interface ShortcutBinding {
|
|
98
|
-
command: string;
|
|
99
|
-
/** Chord text (`Mod+Shift+Z`) or a parsed chord. */
|
|
100
|
-
chord: string | Chord;
|
|
101
|
-
/** Scope (e.g. `canvas`, `spreadsheet`); scoped bindings win over global ones. Omit for global. */
|
|
102
|
-
scope?: string;
|
|
103
|
-
/** Platforms the binding exists on (default: all). E.g. `Mod+Y` redo only off macOS. */
|
|
104
|
-
platforms?: readonly Platform[];
|
|
105
|
-
/** Also fire while focus is in an input, textarea or contenteditable (default `false`). */
|
|
106
|
-
allowInEditable?: boolean;
|
|
107
|
-
}
|
|
108
|
-
/** Shortcut declaration on a command: chord text, or an object for platform / scope specifics. */
|
|
109
|
-
type ShortcutInput = string | Omit<ShortcutBinding, 'command'> | ReadonlyArray<string | Omit<ShortcutBinding, 'command'>>;
|
|
110
|
-
/** Expands a command's `shortcut` declaration into bindings. */
|
|
111
|
-
declare function toShortcutBindings(command: string, input: ShortcutInput | undefined, scope?: string): ShortcutBinding[];
|
|
112
|
-
interface ShortcutConflict {
|
|
113
|
-
/** Scope shared by the bindings (`undefined` = global). */
|
|
114
|
-
scope?: string;
|
|
115
|
-
/** Effective chord, e.g. `Ctrl+KeyZ`. */
|
|
116
|
-
chord: string;
|
|
117
|
-
/** Commands bound to it (two or more). */
|
|
118
|
-
commands: string[];
|
|
119
|
-
}
|
|
120
|
-
interface ShortcutMatch {
|
|
121
|
-
command: string;
|
|
122
|
-
binding: ShortcutBinding;
|
|
123
|
-
}
|
|
124
|
-
interface ShortcutResolveOptions {
|
|
125
|
-
/** Active scopes, most specific first. Bindings in these scopes win over global ones. */
|
|
126
|
-
scopes?: string | readonly string[];
|
|
127
|
-
/** Resolve even when the event comes from a text input (default: per binding). */
|
|
128
|
-
allowInEditable?: boolean;
|
|
129
|
-
/** Override the map's platform. */
|
|
130
|
-
platform?: Platform;
|
|
131
|
-
}
|
|
132
|
-
interface ShortcutMapOptions {
|
|
133
|
-
/** Platform used to resolve `Mod` (default: detected from `navigator` on every resolve). */
|
|
134
|
-
platform?: Platform;
|
|
135
|
-
/**
|
|
136
|
-
* `platform` (default): `Mod` means ⌘ on macOS and Ctrl elsewhere, exactly.
|
|
137
|
-
* `either`: `Mod` (and `Ctrl` / `Meta`) match ⌘ or Ctrl on every platform.
|
|
138
|
-
*/
|
|
139
|
-
modifierMode?: 'platform' | 'either';
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Keyboard shortcuts as data: default bindings plus user overrides, resolved from
|
|
143
|
-
* `KeyboardEvent`s by `event.code` (so Option/Alt chords work on macOS), with scopes
|
|
144
|
-
* (scoped bindings win), conflict detection per platform and display formatting.
|
|
145
|
-
*/
|
|
146
|
-
declare class ShortcutMap {
|
|
147
|
-
private defaults;
|
|
148
|
-
private overrides;
|
|
149
|
-
private readonly listeners;
|
|
150
|
-
private readonly options;
|
|
151
|
-
constructor(bindings?: readonly ShortcutBinding[], options?: ShortcutMapOptions);
|
|
152
|
-
get platform(): Platform;
|
|
153
|
-
private entry;
|
|
154
|
-
private changed;
|
|
155
|
-
/** Subscribes to binding changes. Returns an unsubscribe function. */
|
|
156
|
-
subscribe(listener: () => void): () => void;
|
|
157
|
-
/** Adds default bindings (throws on invalid chord text). Returns a function removing them. */
|
|
158
|
-
bind(bindings: ShortcutBinding | readonly ShortcutBinding[]): () => void;
|
|
159
|
-
/**
|
|
160
|
-
* User override for a command: replaces all of its default bindings with `chords`
|
|
161
|
-
* (an empty list unbinds it). Throws on invalid chord text.
|
|
162
|
-
*/
|
|
163
|
-
setOverride(command: string, chords: string | Chord | ReadonlyArray<string | Chord | Omit<ShortcutBinding, 'command'>>): void;
|
|
164
|
-
/** Removes a user override (the defaults apply again). */
|
|
165
|
-
clearOverride(command: string): void;
|
|
166
|
-
/** User overrides as plain data (`{ command: ['Mod+K'] }`), e.g. to persist them. */
|
|
167
|
-
getOverrides(): Record<string, string[]>;
|
|
168
|
-
/** Restores overrides saved with `getOverrides` (replacing the current ones). */
|
|
169
|
-
setOverrides(overrides: Record<string, readonly string[]>): void;
|
|
170
|
-
private active;
|
|
171
|
-
/** Effective bindings on `platform` (defaults without overridden commands, plus overrides). */
|
|
172
|
-
bindings(platform?: Platform): ShortcutBinding[];
|
|
173
|
-
/** Canonical chord text bound to `command` on `platform` (first = primary). */
|
|
174
|
-
forCommand(command: string, platform?: Platform): string[];
|
|
175
|
-
/**
|
|
176
|
-
* The command a keydown event runs, or `null`. Events from text inputs are ignored
|
|
177
|
-
* unless the binding (or `options`) allows them. Bindings in the active scopes
|
|
178
|
-
* (in order) win over global bindings; bindings in other scopes never match.
|
|
179
|
-
* Keys are matched by `event.code`, except that a letter key producing another Latin
|
|
180
|
-
* letter (AZERTY, QWERTZ, Dvorak) matches that letter when Alt is not held, so
|
|
181
|
-
* `Mod+Z` follows the Z label (see `shortcutCode`).
|
|
182
|
-
*/
|
|
183
|
-
resolve(event: KeyboardEventLike, options?: ShortcutResolveOptions): ShortcutMatch | null;
|
|
184
|
-
private matches;
|
|
185
|
-
/**
|
|
186
|
-
* Groups of bindings that share an effective chord in one scope on `platform`
|
|
187
|
-
* (e.g. `Mod+Y` and `Ctrl+Y` collide off macOS). A scoped binding shadowing a
|
|
188
|
-
* global one is not a conflict.
|
|
189
|
-
*/
|
|
190
|
-
findConflicts(platform?: Platform): ShortcutConflict[];
|
|
191
|
-
/** Conflicts on every platform, keyed by platform (only platforms with conflicts). */
|
|
192
|
-
findAllConflicts(): Partial<Record<Platform, ShortcutConflict[]>>;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/** Object JSON Schema describing a command's parameters. */
|
|
196
|
-
type CommandParamsSchema = JsonSchema & {
|
|
197
|
-
type: 'object';
|
|
198
|
-
};
|
|
199
|
-
/**
|
|
200
|
-
* Metadata and implementation of one command. Menus, shortcuts, the palette and agent
|
|
201
|
-
* tools all run commands by id, so every entry point shares enablement and validation.
|
|
202
|
-
*/
|
|
203
|
-
interface CommandSpec<TContext = any, TParams = any, TResult = unknown> {
|
|
204
|
-
/** Unique id, e.g. `history.undo` or `canvas.alignLeft`. */
|
|
205
|
-
id: string;
|
|
206
|
-
label: string;
|
|
207
|
-
/** Group / menu name shown next to the label, e.g. `Edit` or `Arrange`. */
|
|
208
|
-
group?: string;
|
|
209
|
-
/** Extra search terms for the palette. */
|
|
210
|
-
keywords?: readonly string[];
|
|
211
|
-
description?: string;
|
|
212
|
-
/** Object JSON Schema for `params`. Unknown keys are rejected unless `additionalProperties` allows them. */
|
|
213
|
-
params?: CommandParamsSchema;
|
|
214
|
-
/** Default shortcut(s): platform-neutral chord text such as `Mod+Shift+Z`. */
|
|
215
|
-
shortcut?: ShortcutInput;
|
|
216
|
-
/** Scope the command (and its shortcuts) belong to, e.g. `canvas`. Omit for global commands. */
|
|
217
|
-
scope?: string;
|
|
218
|
-
/**
|
|
219
|
-
* Whether the command can run: `true` (or `undefined`), `false`, or a reason string
|
|
220
|
-
* ("Nothing to undo"). Receives the params a caller named, so a command acting on the
|
|
221
|
-
* selection can still run on targets passed explicitly (`params` is `undefined` for menus).
|
|
222
|
-
*/
|
|
223
|
-
enabled?: (context: TContext, params: TParams | undefined) => boolean | string | undefined;
|
|
224
|
-
run: (context: TContext, params: TParams) => TResult;
|
|
225
|
-
/**
|
|
226
|
-
* Runs inside the registry's `history.batch(label, …)`, so all history entries the
|
|
227
|
-
* command records become one undo step and a throw rolls back its partial changes.
|
|
228
|
-
*/
|
|
229
|
-
undoable?: boolean;
|
|
230
|
-
/** The command only reads state (agent tools mark it read-only). */
|
|
231
|
-
readOnly?: boolean;
|
|
232
|
-
/** Hide from the palette and `list()` unless `includeHidden` (still runnable by id). */
|
|
233
|
-
hidden?: boolean;
|
|
234
|
-
}
|
|
235
|
-
type CommandErrorCode = 'unknown_command' | 'disabled' | 'invalid_params' | 'failed';
|
|
236
|
-
type CommandResult<T = unknown> = {
|
|
237
|
-
ok: true;
|
|
238
|
-
id: string;
|
|
239
|
-
result: T;
|
|
240
|
-
} | {
|
|
241
|
-
ok: false;
|
|
242
|
-
id: string;
|
|
243
|
-
code: CommandErrorCode;
|
|
244
|
-
message: string;
|
|
245
|
-
details?: SchemaValidationError[];
|
|
246
|
-
};
|
|
247
|
-
/** A command as listed for menus, palettes and agents. */
|
|
248
|
-
interface CommandEntry {
|
|
249
|
-
id: string;
|
|
250
|
-
label: string;
|
|
251
|
-
group?: string;
|
|
252
|
-
keywords?: readonly string[];
|
|
253
|
-
description?: string;
|
|
254
|
-
params?: CommandParamsSchema;
|
|
255
|
-
scope?: string;
|
|
256
|
-
/** Canonical chord text bound on the registry's platform (first = primary). */
|
|
257
|
-
shortcuts: string[];
|
|
258
|
-
enabled: boolean;
|
|
259
|
-
/** Why the command is disabled (only when `enabled` is false). */
|
|
260
|
-
disabledReason?: string;
|
|
261
|
-
undoable: boolean;
|
|
262
|
-
readOnly: boolean;
|
|
263
|
-
}
|
|
264
|
-
interface CommandListOptions<TContext = any> {
|
|
265
|
-
/** Only global commands plus commands of these scopes. */
|
|
266
|
-
scope?: string | readonly string[];
|
|
267
|
-
enabledOnly?: boolean;
|
|
268
|
-
includeHidden?: boolean;
|
|
269
|
-
/** Context for the enablement check (default: the registry's context). */
|
|
270
|
-
context?: TContext;
|
|
271
|
-
}
|
|
272
|
-
/** Minimal history surface (`HistoryManager` satisfies it). */
|
|
273
|
-
interface CommandHistoryTarget {
|
|
274
|
-
batch(name: string, fn: () => void): void;
|
|
275
|
-
}
|
|
276
|
-
interface CommandRegistryOptions<TContext = any> {
|
|
277
|
-
/** Default context passed to `enabled` / `run` (a value or a getter). */
|
|
278
|
-
context?: TContext | (() => TContext);
|
|
279
|
-
/** Wraps `undoable` commands in one history step (see `CommandSpec.undoable`). */
|
|
280
|
-
history?: CommandHistoryTarget;
|
|
281
|
-
/** Options for the registry's `ShortcutMap`. */
|
|
282
|
-
shortcuts?: ShortcutMapOptions;
|
|
283
|
-
}
|
|
284
|
-
declare class CommandRegistryError extends Error {
|
|
285
|
-
readonly code: 'duplicate_command' | 'invalid_command';
|
|
286
|
-
constructor(code: CommandRegistryError['code'], message: string);
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Registry of commands: one id per action, shared by shortcuts (`shortcuts`), the
|
|
290
|
-
* command palette (`list` + `rankCommands`) and agent tools (`createCommandToolProvider`).
|
|
291
|
-
*/
|
|
292
|
-
declare class CommandRegistry<TContext = any> {
|
|
293
|
-
/** Shortcut bindings of the registered commands (plus any user overrides). */
|
|
294
|
-
readonly shortcuts: ShortcutMap;
|
|
295
|
-
private readonly commands;
|
|
296
|
-
private readonly listeners;
|
|
297
|
-
private readonly options;
|
|
298
|
-
private version;
|
|
299
|
-
private muted;
|
|
300
|
-
constructor(options?: CommandRegistryOptions<TContext>);
|
|
301
|
-
/** Monotonic counter bumped on every change (useful as a snapshot key). */
|
|
302
|
-
getVersion(): number;
|
|
303
|
-
/** The default context. */
|
|
304
|
-
get context(): TContext;
|
|
305
|
-
/**
|
|
306
|
-
* Registers a command (or several) and returns a function that unregisters it.
|
|
307
|
-
* Throws a `CommandRegistryError` for a duplicate or invalid id, or invalid chord text.
|
|
308
|
-
*/
|
|
309
|
-
register(spec: CommandSpec<TContext> | readonly CommandSpec<TContext>[]): () => void;
|
|
310
|
-
/** Removes a command by id. Returns whether it was registered. */
|
|
311
|
-
unregister(id: string): boolean;
|
|
312
|
-
private unbindQuietly;
|
|
313
|
-
has(id: string): boolean;
|
|
314
|
-
get(id: string): CommandSpec<TContext> | undefined;
|
|
315
|
-
/** Registered ids in registration order. */
|
|
316
|
-
ids(): string[];
|
|
317
|
-
/** Whether `id` can run now (`{ enabled, reason }`); `params` are the targets a caller named. */
|
|
318
|
-
isEnabled(id: string, params?: unknown, context?: TContext): {
|
|
319
|
-
enabled: boolean;
|
|
320
|
-
reason?: string;
|
|
321
|
-
};
|
|
322
|
-
/** Commands for menus, palettes and agents, with their current enablement. */
|
|
323
|
-
list(options?: CommandListOptions<TContext>): CommandEntry[];
|
|
324
|
-
private check;
|
|
325
|
-
private invoke;
|
|
326
|
-
/**
|
|
327
|
-
* Runs a command synchronously and returns a structured result; never throws.
|
|
328
|
-
* A command whose `run` returns a promise yields `{ ok: true, result: promise }`
|
|
329
|
-
* (use `executeAsync` to await it and catch its rejection).
|
|
330
|
-
*/
|
|
331
|
-
execute<T = unknown>(id: string, params?: unknown, context?: TContext): CommandResult<T>;
|
|
332
|
-
/** Like `execute`, but awaits async commands (rejections become `failed` results). */
|
|
333
|
-
executeAsync<T = unknown>(id: string, params?: unknown, context?: TContext): Promise<CommandResult<T>>;
|
|
334
|
-
/**
|
|
335
|
-
* Resolves a keydown event to a command (see `ShortcutMap.resolve`) and runs it when
|
|
336
|
-
* enabled, calling `preventDefault()`. Disabled commands leave the event alone, so the
|
|
337
|
-
* browser or a focused editor can still handle it. Returns the result, or `null`.
|
|
338
|
-
*/
|
|
339
|
-
handleKeyDown(event: KeyboardEventLike, options?: ShortcutResolveOptions & {
|
|
340
|
-
context?: TContext;
|
|
341
|
-
}): CommandResult | null;
|
|
342
|
-
/** Display-ready primary shortcut of a command (`⇧⌘Z` / `Ctrl+Shift+Z`), or `undefined`. */
|
|
343
|
-
shortcutFor(id: string, platform?: Platform): string | undefined;
|
|
344
|
-
/**
|
|
345
|
-
* Subscribes to changes: commands registered or removed, shortcut overrides, executed
|
|
346
|
-
* commands and `invalidate()` calls (e.g. when enablement inputs change).
|
|
347
|
-
*/
|
|
348
|
-
subscribe(listener: () => void): () => void;
|
|
349
|
-
/** Tells subscribers that enablement may have changed (e.g. the selection changed). */
|
|
350
|
-
invalidate(): void;
|
|
351
|
-
private notify;
|
|
352
|
-
}
|
|
353
|
-
declare function createCommandRegistry<TContext = any>(options?: CommandRegistryOptions<TContext>): CommandRegistry<TContext>;
|
|
354
|
-
/** Identity helper that types a command spec. */
|
|
355
|
-
declare function defineCommand<TContext = any, TParams = any, TResult = unknown>(spec: CommandSpec<TContext, TParams, TResult>): CommandSpec<TContext, TParams, TResult>;
|
|
356
|
-
|
|
357
9
|
/** The fields `rankCommands` searches (a `CommandEntry` satisfies it). */
|
|
358
10
|
interface RankableCommand {
|
|
359
11
|
id: string;
|
|
@@ -589,4 +241,4 @@ interface SpreadsheetCommandOptions {
|
|
|
589
241
|
/** Palette / agent commands for common spreadsheet table actions (no default shortcuts). */
|
|
590
242
|
declare function createSpreadsheetCommands(controller: SpreadsheetCommandTarget, options?: SpreadsheetCommandOptions): CommandSpec[];
|
|
591
243
|
|
|
592
|
-
export { type ArrangeCommandOptions, type ArrangeCommandTarget,
|
|
244
|
+
export { type ArrangeCommandOptions, type ArrangeCommandTarget, CommandEntry, type CommandPaletteController, type CommandPaletteItem, type CommandPaletteOptions, type CommandPaletteState, CommandRegistry, CommandResult, CommandSpec, type CommandToolProviderOptions, DEFAULT_HISTORY_SHORTCUTS, DEFAULT_RECENT_LIMIT, type FuzzyMatch, type HistoryCommandOptions, type HistoryCommandTarget, KeyboardEventLike, Platform, type RankCommandsOptions, type RankableCommand, type RankedCommand, ShortcutBinding, type SpreadsheetCommandOptions, type SpreadsheetCommandTarget, createArrangeCommands, createCommandPaletteController, createCommandToolProvider, createHistoryCommands, createSpreadsheetCommands, exactBonus, fuzzyMatch, fuzzyScore, matchHistoryShortcut, matchPaletteHotkey, pushRecent, rankCommands };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who made a comment, reply or tracked change.
|
|
3
|
+
*/
|
|
4
|
+
interface ReviewAuthor {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
color?: string;
|
|
8
|
+
avatarUrl?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Where a comment thread is attached in the document. `from`/`to` are
|
|
12
|
+
* ProseMirror positions and `quote` is the commented text at the time the
|
|
13
|
+
* anchor was last synced. Positions are only meaningful for the current
|
|
14
|
+
* document; the `comment` mark in the document is the source of truth.
|
|
15
|
+
*/
|
|
16
|
+
interface CommentAnchor {
|
|
17
|
+
from: number;
|
|
18
|
+
to: number;
|
|
19
|
+
quote: string;
|
|
20
|
+
}
|
|
21
|
+
interface CommentReply {
|
|
22
|
+
id: string;
|
|
23
|
+
author: ReviewAuthor;
|
|
24
|
+
body: string;
|
|
25
|
+
createdAt: number;
|
|
26
|
+
editedAt?: number;
|
|
27
|
+
}
|
|
28
|
+
interface CommentThread {
|
|
29
|
+
id: string;
|
|
30
|
+
/** `null` while the thread has no text in the document (see `orphaned`). */
|
|
31
|
+
anchor: CommentAnchor | null;
|
|
32
|
+
author: ReviewAuthor;
|
|
33
|
+
createdAt: number;
|
|
34
|
+
/** An empty body marks a draft that has not been posted yet. */
|
|
35
|
+
body: string;
|
|
36
|
+
editedAt?: number;
|
|
37
|
+
replies: CommentReply[];
|
|
38
|
+
resolved: boolean;
|
|
39
|
+
resolvedAt?: number;
|
|
40
|
+
resolvedBy?: ReviewAuthor;
|
|
41
|
+
/**
|
|
42
|
+
* True when the commented text was deleted from the document. Undoing the
|
|
43
|
+
* deletion re-attaches the thread.
|
|
44
|
+
*/
|
|
45
|
+
orphaned: boolean;
|
|
46
|
+
/** The quote the thread had before it was orphaned. */
|
|
47
|
+
lastQuote?: string;
|
|
48
|
+
}
|
|
49
|
+
interface CommentStoreSnapshot {
|
|
50
|
+
/** Threads in document order (anchored first), then orphaned threads. */
|
|
51
|
+
threads: readonly CommentThread[];
|
|
52
|
+
activeThreadId: string | null;
|
|
53
|
+
}
|
|
54
|
+
/** JSON shape produced by `CommentStore.toJSON()`. */
|
|
55
|
+
interface SerializedComments {
|
|
56
|
+
version: 1;
|
|
57
|
+
threads: CommentThread[];
|
|
58
|
+
}
|
|
59
|
+
interface CommentStoreOptions {
|
|
60
|
+
threads?: CommentThread[] | SerializedComments;
|
|
61
|
+
generateId?: () => string;
|
|
62
|
+
now?: () => number;
|
|
63
|
+
}
|
|
64
|
+
interface CreateThreadInput {
|
|
65
|
+
id?: string;
|
|
66
|
+
body: string;
|
|
67
|
+
author: ReviewAuthor;
|
|
68
|
+
anchor?: CommentAnchor | null;
|
|
69
|
+
createdAt?: number;
|
|
70
|
+
}
|
|
71
|
+
type CommentStoreListener = (snapshot: CommentStoreSnapshot) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Generates a reasonably unique id without depending on `crypto`.
|
|
74
|
+
*/
|
|
75
|
+
declare function createReviewId(prefix?: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* Headless, framework-agnostic store of comment threads.
|
|
78
|
+
*
|
|
79
|
+
* The store never talks to a server: persist `toJSON()` yourself and pass it
|
|
80
|
+
* back via `new CommentStore({ threads })` or `load()`. Snapshots are
|
|
81
|
+
* immutable and only replaced when something changes, so `getSnapshot` is safe
|
|
82
|
+
* to use with React's `useSyncExternalStore`. `subscribe` calls the listener
|
|
83
|
+
* immediately (Svelte store contract).
|
|
84
|
+
*/
|
|
85
|
+
declare class CommentStore {
|
|
86
|
+
private threads;
|
|
87
|
+
private activeThreadId;
|
|
88
|
+
private snapshot;
|
|
89
|
+
private listeners;
|
|
90
|
+
/** Deleted threads, kept so undoing a "Delete Comment" can restore them. */
|
|
91
|
+
private deleted;
|
|
92
|
+
private generateId;
|
|
93
|
+
private now;
|
|
94
|
+
constructor(options?: CommentStoreOptions);
|
|
95
|
+
/** Parses `toJSON()` output (or a plain thread array). */
|
|
96
|
+
static parse(json: string | CommentThread[] | SerializedComments): CommentThread[];
|
|
97
|
+
subscribe: (listener: CommentStoreListener) => (() => void);
|
|
98
|
+
getSnapshot: () => CommentStoreSnapshot;
|
|
99
|
+
getThread(id: string): CommentThread | undefined;
|
|
100
|
+
createThread(input: CreateThreadInput): CommentThread;
|
|
101
|
+
/** Edits the thread's body, or one of its replies when `replyId` is given. */
|
|
102
|
+
editComment(threadId: string, body: string, replyId?: string): boolean;
|
|
103
|
+
addReply(threadId: string, input: {
|
|
104
|
+
body: string;
|
|
105
|
+
author: ReviewAuthor;
|
|
106
|
+
id?: string;
|
|
107
|
+
}): CommentReply | null;
|
|
108
|
+
deleteReply(threadId: string, replyId: string): boolean;
|
|
109
|
+
resolveThread(id: string, resolved?: boolean, by?: ReviewAuthor): boolean;
|
|
110
|
+
deleteThread(id: string): boolean;
|
|
111
|
+
/** Deletes every thread whose text is no longer in the document. */
|
|
112
|
+
removeOrphanedThreads(): string[];
|
|
113
|
+
setActiveThread(id: string | null): void;
|
|
114
|
+
/**
|
|
115
|
+
* Updates anchors from the document. Threads missing from `anchors` become
|
|
116
|
+
* orphaned. Threads that were deleted but whose mark re-appeared (e.g. after
|
|
117
|
+
* undoing "Delete Comment") are restored. Returns true if anything changed.
|
|
118
|
+
*/
|
|
119
|
+
syncAnchors(anchors: Map<string, CommentAnchor>): boolean;
|
|
120
|
+
/** Replaces all threads, e.g. with data loaded from a server. */
|
|
121
|
+
load(json: string | CommentThread[] | SerializedComments): void;
|
|
122
|
+
clear(): void;
|
|
123
|
+
toJSON(): SerializedComments;
|
|
124
|
+
private updateThread;
|
|
125
|
+
private computeSnapshot;
|
|
126
|
+
private emit;
|
|
127
|
+
}
|
|
128
|
+
declare function createCommentStore(options?: CommentStoreOptions): CommentStore;
|
|
129
|
+
/**
|
|
130
|
+
* Short, human-readable timestamp for review UIs ("just now", "5m ago",
|
|
131
|
+
* "3h ago", then a locale date). Shared by the React and Svelte components.
|
|
132
|
+
*/
|
|
133
|
+
declare function formatReviewTime(timestamp: number, now?: number): string;
|
|
134
|
+
|
|
135
|
+
export { type CommentAnchor as C, type ReviewAuthor as R, type SerializedComments as S, type CommentReply as a, CommentStore as b, type CommentStoreListener as c, type CommentStoreOptions as d, type CommentStoreSnapshot as e, type CommentThread as f, type CreateThreadInput as g, createCommentStore as h, createReviewId as i, formatReviewTime as j };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who made a comment, reply or tracked change.
|
|
3
|
+
*/
|
|
4
|
+
interface ReviewAuthor {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
color?: string;
|
|
8
|
+
avatarUrl?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Where a comment thread is attached in the document. `from`/`to` are
|
|
12
|
+
* ProseMirror positions and `quote` is the commented text at the time the
|
|
13
|
+
* anchor was last synced. Positions are only meaningful for the current
|
|
14
|
+
* document; the `comment` mark in the document is the source of truth.
|
|
15
|
+
*/
|
|
16
|
+
interface CommentAnchor {
|
|
17
|
+
from: number;
|
|
18
|
+
to: number;
|
|
19
|
+
quote: string;
|
|
20
|
+
}
|
|
21
|
+
interface CommentReply {
|
|
22
|
+
id: string;
|
|
23
|
+
author: ReviewAuthor;
|
|
24
|
+
body: string;
|
|
25
|
+
createdAt: number;
|
|
26
|
+
editedAt?: number;
|
|
27
|
+
}
|
|
28
|
+
interface CommentThread {
|
|
29
|
+
id: string;
|
|
30
|
+
/** `null` while the thread has no text in the document (see `orphaned`). */
|
|
31
|
+
anchor: CommentAnchor | null;
|
|
32
|
+
author: ReviewAuthor;
|
|
33
|
+
createdAt: number;
|
|
34
|
+
/** An empty body marks a draft that has not been posted yet. */
|
|
35
|
+
body: string;
|
|
36
|
+
editedAt?: number;
|
|
37
|
+
replies: CommentReply[];
|
|
38
|
+
resolved: boolean;
|
|
39
|
+
resolvedAt?: number;
|
|
40
|
+
resolvedBy?: ReviewAuthor;
|
|
41
|
+
/**
|
|
42
|
+
* True when the commented text was deleted from the document. Undoing the
|
|
43
|
+
* deletion re-attaches the thread.
|
|
44
|
+
*/
|
|
45
|
+
orphaned: boolean;
|
|
46
|
+
/** The quote the thread had before it was orphaned. */
|
|
47
|
+
lastQuote?: string;
|
|
48
|
+
}
|
|
49
|
+
interface CommentStoreSnapshot {
|
|
50
|
+
/** Threads in document order (anchored first), then orphaned threads. */
|
|
51
|
+
threads: readonly CommentThread[];
|
|
52
|
+
activeThreadId: string | null;
|
|
53
|
+
}
|
|
54
|
+
/** JSON shape produced by `CommentStore.toJSON()`. */
|
|
55
|
+
interface SerializedComments {
|
|
56
|
+
version: 1;
|
|
57
|
+
threads: CommentThread[];
|
|
58
|
+
}
|
|
59
|
+
interface CommentStoreOptions {
|
|
60
|
+
threads?: CommentThread[] | SerializedComments;
|
|
61
|
+
generateId?: () => string;
|
|
62
|
+
now?: () => number;
|
|
63
|
+
}
|
|
64
|
+
interface CreateThreadInput {
|
|
65
|
+
id?: string;
|
|
66
|
+
body: string;
|
|
67
|
+
author: ReviewAuthor;
|
|
68
|
+
anchor?: CommentAnchor | null;
|
|
69
|
+
createdAt?: number;
|
|
70
|
+
}
|
|
71
|
+
type CommentStoreListener = (snapshot: CommentStoreSnapshot) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Generates a reasonably unique id without depending on `crypto`.
|
|
74
|
+
*/
|
|
75
|
+
declare function createReviewId(prefix?: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* Headless, framework-agnostic store of comment threads.
|
|
78
|
+
*
|
|
79
|
+
* The store never talks to a server: persist `toJSON()` yourself and pass it
|
|
80
|
+
* back via `new CommentStore({ threads })` or `load()`. Snapshots are
|
|
81
|
+
* immutable and only replaced when something changes, so `getSnapshot` is safe
|
|
82
|
+
* to use with React's `useSyncExternalStore`. `subscribe` calls the listener
|
|
83
|
+
* immediately (Svelte store contract).
|
|
84
|
+
*/
|
|
85
|
+
declare class CommentStore {
|
|
86
|
+
private threads;
|
|
87
|
+
private activeThreadId;
|
|
88
|
+
private snapshot;
|
|
89
|
+
private listeners;
|
|
90
|
+
/** Deleted threads, kept so undoing a "Delete Comment" can restore them. */
|
|
91
|
+
private deleted;
|
|
92
|
+
private generateId;
|
|
93
|
+
private now;
|
|
94
|
+
constructor(options?: CommentStoreOptions);
|
|
95
|
+
/** Parses `toJSON()` output (or a plain thread array). */
|
|
96
|
+
static parse(json: string | CommentThread[] | SerializedComments): CommentThread[];
|
|
97
|
+
subscribe: (listener: CommentStoreListener) => (() => void);
|
|
98
|
+
getSnapshot: () => CommentStoreSnapshot;
|
|
99
|
+
getThread(id: string): CommentThread | undefined;
|
|
100
|
+
createThread(input: CreateThreadInput): CommentThread;
|
|
101
|
+
/** Edits the thread's body, or one of its replies when `replyId` is given. */
|
|
102
|
+
editComment(threadId: string, body: string, replyId?: string): boolean;
|
|
103
|
+
addReply(threadId: string, input: {
|
|
104
|
+
body: string;
|
|
105
|
+
author: ReviewAuthor;
|
|
106
|
+
id?: string;
|
|
107
|
+
}): CommentReply | null;
|
|
108
|
+
deleteReply(threadId: string, replyId: string): boolean;
|
|
109
|
+
resolveThread(id: string, resolved?: boolean, by?: ReviewAuthor): boolean;
|
|
110
|
+
deleteThread(id: string): boolean;
|
|
111
|
+
/** Deletes every thread whose text is no longer in the document. */
|
|
112
|
+
removeOrphanedThreads(): string[];
|
|
113
|
+
setActiveThread(id: string | null): void;
|
|
114
|
+
/**
|
|
115
|
+
* Updates anchors from the document. Threads missing from `anchors` become
|
|
116
|
+
* orphaned. Threads that were deleted but whose mark re-appeared (e.g. after
|
|
117
|
+
* undoing "Delete Comment") are restored. Returns true if anything changed.
|
|
118
|
+
*/
|
|
119
|
+
syncAnchors(anchors: Map<string, CommentAnchor>): boolean;
|
|
120
|
+
/** Replaces all threads, e.g. with data loaded from a server. */
|
|
121
|
+
load(json: string | CommentThread[] | SerializedComments): void;
|
|
122
|
+
clear(): void;
|
|
123
|
+
toJSON(): SerializedComments;
|
|
124
|
+
private updateThread;
|
|
125
|
+
private computeSnapshot;
|
|
126
|
+
private emit;
|
|
127
|
+
}
|
|
128
|
+
declare function createCommentStore(options?: CommentStoreOptions): CommentStore;
|
|
129
|
+
/**
|
|
130
|
+
* Short, human-readable timestamp for review UIs ("just now", "5m ago",
|
|
131
|
+
* "3h ago", then a locale date). Shared by the React and Svelte components.
|
|
132
|
+
*/
|
|
133
|
+
declare function formatReviewTime(timestamp: number, now?: number): string;
|
|
134
|
+
|
|
135
|
+
export { type CommentAnchor as C, type ReviewAuthor as R, type SerializedComments as S, type CommentReply as a, CommentStore as b, type CommentStoreListener as c, type CommentStoreOptions as d, type CommentStoreSnapshot as e, type CommentThread as f, type CreateThreadInput as g, createCommentStore as h, createReviewId as i, formatReviewTime as j };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-PL4JB3BF.cjs');
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkOLZJXL4Rcjs = require('../chunk-OLZJXL4R.cjs');
|
|
8
|
+
require('../chunk-D27YFC46.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.compareDocuments = _chunkOLZJXL4Rcjs.compareDocuments; exports.compareHtml = _chunkOLZJXL4Rcjs.compareHtml; exports.diffChanges = _chunkOLZJXL4Rcjs.diffChanges; exports.diffSequences = _chunkOLZJXL4Rcjs.diffSequences;
|
|
15
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/compare/index.cjs"],"names":[],"mappings":"AAAA,0GAA8B;AAC9B;AACE;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACF,iOAAC","file":"/home/runner/work/editor/editor/packages/core/dist/compare/index.cjs"}
|