docxkeun 0.2.0 → 0.4.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.
@@ -10,6 +10,8 @@ export interface ParagraphChange {
10
10
  cuts: number[];
11
11
  /** The paragraph's text before (changed paragraphs). */
12
12
  before?: string;
13
+ /** Index (0-based) of the paragraph in the old text (changed paragraphs). */
14
+ from?: number;
13
15
  /** Only the formatting changed (bold, style, alignment, list). */
14
16
  formatting?: boolean;
15
17
  }
@@ -35,9 +37,23 @@ export declare function diffText(before: string, after: string): {
35
37
  };
36
38
  /** Paragraph-level changes between two versions of a document's paragraph texts. */
37
39
  export declare function diffParagraphs(before: string[], after: string[]): ParagraphDiff;
40
+ /** How the AI's work shows on the paragraphs it is changing (see `ACTIVITY_STYLES`). */
41
+ export type ActivityStyle = 'highlight' | 'words' | 'underline' | 'edge' | 'spotlight' | 'quiet' | 'sparkles';
42
+ /** The styles, with a label and a line to show in a picker, in the order to show them. */
43
+ export declare const ACTIVITY_STYLES: ReadonlyArray<{
44
+ style: ActivityStyle;
45
+ label: string;
46
+ description: string;
47
+ }>;
38
48
  export interface ActivityOptions {
39
49
  /** The name on the caret and in the change marks' tooltips (default "Claude"). */
40
50
  name?: string;
51
+ /**
52
+ * How the AI's work shows (default `'highlight'`), and so which mark stays after a change:
53
+ * highlight → a still tint on the changed paragraph, words → the changed words' letters stay in the AI's colours,
54
+ * underline → the changed words stay underlined, the others → the ✦ margin bar.
55
+ */
56
+ style?: ActivityStyle;
41
57
  /**
42
58
  * Colour of the caret, shimmer, glow and change marks: one CSS colour, or two for a gradient
43
59
  * (default `['#7c5cff', '#d97757']`). The caret's label text turns dark on light colours.
@@ -47,7 +63,7 @@ export interface ActivityOptions {
47
63
  enabled?: boolean;
48
64
  /** Motion: shimmer sweep, ink, ghosts, scan line, the gliding caret (default true). Off: static highlights. */
49
65
  animate?: boolean;
50
- /** Change bars and the change map that stay after a change (default true). */
66
+ /** The marks that stay after a change, and the change map on the right edge (default true). */
51
67
  marks?: boolean;
52
68
  }
53
69
  /** The AI's presence on the pages: see the module comment. Get it from `viewer.activity`. */
@@ -55,6 +71,7 @@ export declare class AiActivity {
55
71
  private readonly viewer;
56
72
  private aiName;
57
73
  private aiColor;
74
+ private aiStyle;
58
75
  private readonly layer;
59
76
  private readonly map;
60
77
  private readonly caret;
@@ -63,6 +80,11 @@ export declare class AiActivity {
63
80
  private shimmers;
64
81
  private marks;
65
82
  private markEls;
83
+ /** Letters coloured by the marks, the passing flash of a change, and the working shimmer (later wins). */
84
+ private readonly markPaint;
85
+ private readonly flashPaint;
86
+ private readonly workPaint;
87
+ private flashTimer;
66
88
  private hideTimer;
67
89
  private readonly cleanup;
68
90
  private on;
@@ -79,6 +101,12 @@ export declare class AiActivity {
79
101
  */
80
102
  get color(): string | [string, string] | undefined;
81
103
  set color(value: string | [string, string] | undefined);
104
+ /**
105
+ * How the AI's work shows, and so which mark stays after a change (see `ActivityOptions.style`).
106
+ * Changing it redraws the work in progress and the marks. Throws a TypeError for an unknown style.
107
+ */
108
+ get style(): ActivityStyle;
109
+ set style(style: ActivityStyle);
82
110
  /** Show the AI's activity at all. Turning it off clears everything on screen. */
83
111
  get enabled(): boolean;
84
112
  set enabled(on: boolean);
@@ -94,6 +122,13 @@ export declare class AiActivity {
94
122
  private lineRects;
95
123
  /** Rectangles (one per line piece) covering characters [from, to) of a paragraph. */
96
124
  private charRects;
125
+ /**
126
+ * A paragraph's text items, with the characters in `ranges` (all of them, list labels too, when
127
+ * `ranges` is omitted). Items of other paragraphs on the same lines (table cells) are left out.
128
+ */
129
+ private glyphs;
130
+ /** The working shimmer on the paragraphs' letters: one gradient per text colour. */
131
+ private shimmerPaint;
97
132
  private place;
98
133
  /**
99
134
  * Add an overlay. `life` (ms): remove it then (animation events are not dispatched reliably for
@@ -112,7 +147,10 @@ export declare class AiActivity {
112
147
  }): void;
113
148
  /** The AI finished (without a change to show). */
114
149
  idle(): void;
150
+ private clearWorking;
115
151
  private drawWorking;
152
+ /** The working effect of the current style over each paragraph's lines. */
153
+ private drawStyle;
116
154
  private workingText;
117
155
  private moveCaret;
118
156
  /** The caret near the top of the view (reading the whole document). */
@@ -128,11 +166,29 @@ export declare class AiActivity {
128
166
  reveal(before: ParagraphSnapshot | string[], options?: {
129
167
  scroll?: boolean;
130
168
  }): Promise<ParagraphDiff>;
131
- /** Remove the change bars and the change map. */
169
+ /**
170
+ * Remove every mark and the change map. Marks build up over a run of changes (each follows its
171
+ * paragraph as others are added or removed) until this is called, e.g. when a new request starts.
172
+ */
132
173
  clearMarks(): void;
174
+ /**
175
+ * The marks after a change: earlier marks follow their paragraphs (and go with deleted ones), a
176
+ * paragraph changed again is marked against its text before the first change, and new ones join.
177
+ */
178
+ private mergeMarks;
179
+ /** What a mark's tooltip says. */
180
+ private markTitle;
181
+ /** Draw the marks; those of the paragraphs in `fresh` (just changed) appear with a short animation. */
133
182
  private drawMarks;
183
+ /** The changed letters light up in the AI's colours for a moment (the word shimmer without marks). */
184
+ private flash;
134
185
  /** Ticks on the right edge for every change, scaled to the scroll height; click to jump. */
135
186
  private drawMap;
187
+ /**
188
+ * The viewer rebuilt its page rows (zoom, the comment column's width): redraw at the new positions.
189
+ * @internal
190
+ */
191
+ rowsBuilt(): void;
136
192
  private redraw;
137
193
  destroy(): void;
138
194
  }