@quirekit/pptx-editor 0.3.0 → 0.3.1
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 +21 -0
- package/README.zh-CN.md +21 -0
- package/dist/ai.d.mts +24 -1
- package/dist/ai.mjs +51 -51
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +36 -32
- package/dist/open-aKqKXJ6B.mjs +2 -0
- package/dist/styles.css +29 -0
- package/dist/svg-raster-BWlVOKxM.mjs +11 -0
- package/dist/templates.d.mts +575 -0
- package/dist/templates.mjs +1 -0
- package/dist/{types-B8CWBpnf.d.mts → types-Brh5JARz.d.mts} +437 -674
- package/dist/types-DeGx0c3N.d.mts +687 -0
- package/package.json +33 -29
- package/dist/svg-raster-DL19F7ez.mjs +0 -11
|
@@ -0,0 +1,687 @@
|
|
|
1
|
+
import { S as PptxTemplateSource, c as PptxTransitionSide, o as PptxCommands, p as PptxTemplateFile, t as PptxChain } from "./types-Brh5JARz.mjs";
|
|
2
|
+
import { EditorWorkspaceLocale } from "@quirekit/editor-ui/vue/localization";
|
|
3
|
+
import { MediaPlayback, SlideAnimationStep } from "@quirekit/office-kit-pptx";
|
|
4
|
+
//#region src/show/timeline/types.d.ts
|
|
5
|
+
/** What a behaviour points at: a whole shape, or a range of its paragraphs. */
|
|
6
|
+
interface PptxTimelineTarget {
|
|
7
|
+
/** Shape id. */
|
|
8
|
+
readonly shape: number;
|
|
9
|
+
/** First and last paragraph counted from 0, or null for the whole shape. */
|
|
10
|
+
readonly paragraphs: readonly [number, number] | null;
|
|
11
|
+
}
|
|
12
|
+
/** One key time of an `anim` behaviour. */
|
|
13
|
+
interface PptxTimelineKey {
|
|
14
|
+
/** Position in the behaviour's simple duration, 0–1. */
|
|
15
|
+
readonly time: number;
|
|
16
|
+
/** A number, or a formula over the shape's geometry such as `#ppt_x` or `0-#ppt_w/2`. */
|
|
17
|
+
readonly value: number | string;
|
|
18
|
+
/** Formula the value is put through, with `$` standing for it. */
|
|
19
|
+
readonly formula: string | null;
|
|
20
|
+
}
|
|
21
|
+
/** What one behaviour changes, as PresentationML states it. */
|
|
22
|
+
type PptxTimelineEffect = /** `p:set` of `style.visibility`. */{
|
|
23
|
+
readonly kind: "visibility";
|
|
24
|
+
readonly visible: boolean;
|
|
25
|
+
} /** `p:animEffect`: a reveal or conceal by a named filter such as `fade` or `wipe(left)`. */ | {
|
|
26
|
+
readonly kind: "filter";
|
|
27
|
+
readonly filter: string;
|
|
28
|
+
readonly entering: boolean;
|
|
29
|
+
} /** `p:animMotion` along a path in fractions of the slide, relative to where the shape is laid out. */ | {
|
|
30
|
+
readonly kind: "motion";
|
|
31
|
+
readonly path: string;
|
|
32
|
+
} /** `p:animScale` by a factor per axis, multiplying what the shape already shows. */ | {
|
|
33
|
+
readonly kind: "scale";
|
|
34
|
+
readonly by: readonly [number, number];
|
|
35
|
+
} /** `p:animRot` by degrees, added to what the shape already shows. */ | {
|
|
36
|
+
readonly kind: "rotate";
|
|
37
|
+
readonly by: number;
|
|
38
|
+
} /** `p:anim` or `p:set` of one attribute over key times; from/to values become two keys. */ | {
|
|
39
|
+
readonly kind: "anim";
|
|
40
|
+
readonly attribute: PptxTimelineAttribute;
|
|
41
|
+
readonly keys: readonly PptxTimelineKey[];
|
|
42
|
+
readonly discrete: boolean;
|
|
43
|
+
};
|
|
44
|
+
/** Attributes an `anim` behaviour can drive: the shape's centre, size, turn and opacity. */
|
|
45
|
+
type PptxTimelineAttribute = "ppt_x" | "ppt_y" | "ppt_w" | "ppt_h" | "r" | "style.opacity";
|
|
46
|
+
/**
|
|
47
|
+
* One clock between a click group and a behaviour that changes how time runs: easing, reversal, repeats or
|
|
48
|
+
* playing backwards. Containers that only delay their children add no clock of their own.
|
|
49
|
+
*/
|
|
50
|
+
interface PptxTimeFrame {
|
|
51
|
+
/** Start on the clock of the frame outside it, or of the click group for the outermost one, in ms. */
|
|
52
|
+
readonly begin: number;
|
|
53
|
+
/** Simple duration in ms; Infinity for an open-ended one. */
|
|
54
|
+
readonly simple: number;
|
|
55
|
+
/** Share of the simple duration spent speeding up. */
|
|
56
|
+
readonly accel: number;
|
|
57
|
+
/** Share of the simple duration spent slowing down. */
|
|
58
|
+
readonly decel: number;
|
|
59
|
+
/** Whether each repeat plays forward and back. */
|
|
60
|
+
readonly autoReverse: boolean;
|
|
61
|
+
/** Whether it plays backwards. */
|
|
62
|
+
readonly reversed: boolean;
|
|
63
|
+
/** Times it repeats; Infinity until something ends it. */
|
|
64
|
+
readonly repeat: number;
|
|
65
|
+
}
|
|
66
|
+
/** A behaviour placed on the clock of its click group. */
|
|
67
|
+
interface PptxScheduledBehavior {
|
|
68
|
+
/** What it changes. */
|
|
69
|
+
readonly effect: PptxTimelineEffect;
|
|
70
|
+
/** What it points at. */
|
|
71
|
+
readonly target: PptxTimelineTarget;
|
|
72
|
+
/** Clocks from the click group down to the behaviour's own, which is last. */
|
|
73
|
+
readonly frames: readonly PptxTimeFrame[];
|
|
74
|
+
/** Milliseconds from the start of its click group to its start. */
|
|
75
|
+
readonly begin: number;
|
|
76
|
+
/** Milliseconds from the start of its click group to its end; Infinity for an open-ended one. */
|
|
77
|
+
readonly end: number;
|
|
78
|
+
/** Whether its value stays once it ends. */
|
|
79
|
+
readonly hold: boolean;
|
|
80
|
+
/** Class of the effect it belongs to: `entr`, `exit`, `emph`, `path` or null. */
|
|
81
|
+
readonly presetClass: string | null;
|
|
82
|
+
/** Order in the document, which decides between behaviours that start together. */
|
|
83
|
+
readonly order: number;
|
|
84
|
+
}
|
|
85
|
+
/** One click group of a slide's main sequence. */
|
|
86
|
+
interface PptxTimelineStop {
|
|
87
|
+
/** Whether it starts by itself as the slide opens rather than on a click. */
|
|
88
|
+
readonly auto: boolean;
|
|
89
|
+
/** Behaviours in start order. */
|
|
90
|
+
readonly behaviors: readonly PptxScheduledBehavior[];
|
|
91
|
+
/** Milliseconds until its last behaviour that ends has ended. */
|
|
92
|
+
readonly length: number;
|
|
93
|
+
}
|
|
94
|
+
/** A slide's main sequence ready to play. */
|
|
95
|
+
interface PptxTimeline {
|
|
96
|
+
/** Click groups in order. */
|
|
97
|
+
readonly stops: readonly PptxTimelineStop[];
|
|
98
|
+
/** Targets, by `targetKey`, that start hidden because their first entrance or exit is an entrance. */
|
|
99
|
+
readonly hiddenAtStart: ReadonlySet<string>;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/commands/slide-show/types.d.ts
|
|
103
|
+
/** Which slides a show presents. */
|
|
104
|
+
type PptxShowRange = {
|
|
105
|
+
readonly kind: "all";
|
|
106
|
+
} | {
|
|
107
|
+
readonly kind: "range";
|
|
108
|
+
readonly start: number;
|
|
109
|
+
readonly end: number;
|
|
110
|
+
} | {
|
|
111
|
+
readonly kind: "customShow";
|
|
112
|
+
readonly id: number;
|
|
113
|
+
};
|
|
114
|
+
/** Deck-wide slide show settings as the show settings dialog edits them. */
|
|
115
|
+
interface PptxShowSettings {
|
|
116
|
+
/** `present` for a presenter-driven show, `kiosk` for one that runs by itself at a booth. */
|
|
117
|
+
readonly mode: "present" | "kiosk";
|
|
118
|
+
/** Whether the show starts over after its last slide until Esc; a kiosk show always loops. */
|
|
119
|
+
readonly loop: boolean;
|
|
120
|
+
/** Slides presented; range numbers count slides from 1 in deck order. */
|
|
121
|
+
readonly slides: PptxShowRange;
|
|
122
|
+
/** Whether slides advance by their saved timings; false advances by click only. */
|
|
123
|
+
readonly useTimings: boolean;
|
|
124
|
+
}
|
|
125
|
+
/** A named slide sequence. */
|
|
126
|
+
interface PptxCustomShow {
|
|
127
|
+
/** Stable id, or undefined for a show not yet in the deck. */
|
|
128
|
+
readonly id?: number | undefined;
|
|
129
|
+
/** Name shown in lists. */
|
|
130
|
+
readonly name: string;
|
|
131
|
+
/** Slide part names in show order; a slide may repeat. */
|
|
132
|
+
readonly slides: readonly string[];
|
|
133
|
+
}
|
|
134
|
+
/** One pen or highlighter stroke kept as a drawn shape. */
|
|
135
|
+
interface PptxInkShape {
|
|
136
|
+
/** Points the stroke passes, in EMU on the slide. */
|
|
137
|
+
readonly points: readonly {
|
|
138
|
+
readonly x: number;
|
|
139
|
+
readonly y: number;
|
|
140
|
+
}[];
|
|
141
|
+
/** Stroke colour as `#RRGGBB`. */
|
|
142
|
+
readonly color: string;
|
|
143
|
+
/** Stroke width in EMU. */
|
|
144
|
+
readonly width: number;
|
|
145
|
+
/** Opacity from 0 to 1; highlighters are translucent. */
|
|
146
|
+
readonly opacity: number;
|
|
147
|
+
}
|
|
148
|
+
/** Ink of one slide. */
|
|
149
|
+
interface PptxSlideInk {
|
|
150
|
+
/** Slide part name. */
|
|
151
|
+
readonly slide: string;
|
|
152
|
+
/** Strokes in drawing order. */
|
|
153
|
+
readonly strokes: readonly PptxInkShape[];
|
|
154
|
+
}
|
|
155
|
+
/** Rehearsed time of one slide. */
|
|
156
|
+
interface PptxSlideTiming {
|
|
157
|
+
/** Slide part name. */
|
|
158
|
+
readonly slide: string;
|
|
159
|
+
/** Milliseconds the slide stays on screen before the show advances. */
|
|
160
|
+
readonly ms: number;
|
|
161
|
+
}
|
|
162
|
+
/** Summary properties of a deck as the properties dialog edits them. */
|
|
163
|
+
interface PptxDocumentProperties {
|
|
164
|
+
/** Title. */
|
|
165
|
+
readonly title: string;
|
|
166
|
+
/** Subject. */
|
|
167
|
+
readonly subject: string;
|
|
168
|
+
/** Author. */
|
|
169
|
+
readonly creator: string;
|
|
170
|
+
/** Keywords. */
|
|
171
|
+
readonly keywords: string;
|
|
172
|
+
/** Comments. */
|
|
173
|
+
readonly description: string;
|
|
174
|
+
}
|
|
175
|
+
/** How a clip plays, as the media tools edit it; fields left out stay as they are. */
|
|
176
|
+
interface PptxMediaPlayback {
|
|
177
|
+
/** Starts with the slide instead of waiting for a click. */
|
|
178
|
+
readonly autoplay?: boolean;
|
|
179
|
+
/** Milliseconds after the slide starts before automatic playback. */
|
|
180
|
+
readonly delayMs?: number;
|
|
181
|
+
/** Plays again from the beginning until the slide moves on. */
|
|
182
|
+
readonly loop?: boolean;
|
|
183
|
+
/** Volume from 0 to 1. */
|
|
184
|
+
readonly volume?: number;
|
|
185
|
+
/** Plays without sound. */
|
|
186
|
+
readonly muted?: boolean;
|
|
187
|
+
/** Video only: fills the screen while it plays. */
|
|
188
|
+
readonly fullScreen?: boolean;
|
|
189
|
+
/** Hides the clip while it is not playing; an audio clip is hidden for the whole show. */
|
|
190
|
+
readonly hideWhenStopped?: boolean;
|
|
191
|
+
/** Slides the clip keeps playing across, 1 to 999; 999 plays to the end of the show. */
|
|
192
|
+
readonly slideCount?: number;
|
|
193
|
+
/** Returns to the beginning once it has played. */
|
|
194
|
+
readonly rewindAfterPlaying?: boolean;
|
|
195
|
+
/** Milliseconds cut from the start and the end of the clip. */
|
|
196
|
+
readonly trim?: {
|
|
197
|
+
readonly startMs: number;
|
|
198
|
+
readonly endMs: number;
|
|
199
|
+
};
|
|
200
|
+
/** Milliseconds the sound fades in at the start and out at the end. */
|
|
201
|
+
readonly fade?: {
|
|
202
|
+
readonly inMs: number;
|
|
203
|
+
readonly outMs: number;
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
declare module "../../command/types" {
|
|
207
|
+
interface PptxCommandRegistry {
|
|
208
|
+
/** Writes the deck's slide show settings: show type, loop, slide range and how slides advance. */
|
|
209
|
+
setShowSettings: (options: {
|
|
210
|
+
settings: PptxShowSettings;
|
|
211
|
+
}) => PptxCommand;
|
|
212
|
+
/** Replaces the deck's custom shows; a show left out is deleted, and a deleted show the settings presented falls back to all slides. */
|
|
213
|
+
setCustomShows: (options: {
|
|
214
|
+
shows: readonly PptxCustomShow[];
|
|
215
|
+
}) => PptxCommand;
|
|
216
|
+
/** Keeps slide show ink as freeform shapes on their slides. */
|
|
217
|
+
addInkShapes: (options: {
|
|
218
|
+
slides: readonly PptxSlideInk[];
|
|
219
|
+
}) => PptxCommand;
|
|
220
|
+
/** Writes rehearsed timings as each slide's automatic advance and makes the show use them. */
|
|
221
|
+
setSlideTimings: (options: {
|
|
222
|
+
timings: readonly PptxSlideTiming[];
|
|
223
|
+
}) => PptxCommand;
|
|
224
|
+
/** Changes how an audio or video clip plays: start, delay, loop, volume, full screen, hiding, slides it plays across, rewinding, trim and fades. */
|
|
225
|
+
setMediaPlayback: (options: {
|
|
226
|
+
slide: string;
|
|
227
|
+
shape: number;
|
|
228
|
+
playback: PptxMediaPlayback;
|
|
229
|
+
}) => PptxCommand;
|
|
230
|
+
/** Removes media and other parts nothing in the deck uses any more. */
|
|
231
|
+
compactMedia: (options: Record<string, never>) => PptxCommand;
|
|
232
|
+
/** Writes the deck's title, subject, author, keywords and comments; empty text removes a field. */
|
|
233
|
+
setDocumentProperties: (options: {
|
|
234
|
+
properties: Partial<PptxDocumentProperties>;
|
|
235
|
+
}) => PptxCommand;
|
|
236
|
+
}
|
|
237
|
+
} //# sourceMappingURL=types.d.ts.map
|
|
238
|
+
//#endregion
|
|
239
|
+
//#region src/show/types.d.ts
|
|
240
|
+
/** How a show runs, read from the deck's show settings. */
|
|
241
|
+
interface PptxSlideShowSettings {
|
|
242
|
+
/** Whether the show runs by itself at a booth: clicks do not advance and it loops. */
|
|
243
|
+
readonly kiosk: boolean;
|
|
244
|
+
/** Whether the show starts over after its last slide until Esc. */
|
|
245
|
+
readonly loop: boolean;
|
|
246
|
+
/** Whether slides advance by their saved timings. */
|
|
247
|
+
readonly useTimings: boolean;
|
|
248
|
+
}
|
|
249
|
+
/** Slides a show presented at one time, kept while a custom show takes over; opaque to callers. */
|
|
250
|
+
interface PptxShowSequence {
|
|
251
|
+
/** Marks the sequence as the deck's own. */
|
|
252
|
+
readonly kind: "sequence";
|
|
253
|
+
}
|
|
254
|
+
/** Visible slides of one deck version, rendered on demand for a slide show. */
|
|
255
|
+
interface PptxSlideShowDeck {
|
|
256
|
+
/** Number of slides the show presents. */
|
|
257
|
+
readonly count: number;
|
|
258
|
+
/** Slide part names in show order, matching the editor's slide identity; a custom show may repeat one. */
|
|
259
|
+
readonly parts: readonly string[];
|
|
260
|
+
/** Slide numbers counted from 1 in deck order, per show position. */
|
|
261
|
+
readonly numbers: readonly number[];
|
|
262
|
+
/** Slide size in EMU. */
|
|
263
|
+
readonly size: {
|
|
264
|
+
readonly width: number;
|
|
265
|
+
readonly height: number;
|
|
266
|
+
};
|
|
267
|
+
/** How the show runs. */
|
|
268
|
+
readonly settings: PptxSlideShowSettings;
|
|
269
|
+
/**
|
|
270
|
+
* @param index - Show position counted from 0.
|
|
271
|
+
* @returns The slide's speaker notes.
|
|
272
|
+
*/
|
|
273
|
+
notes(index: number): string;
|
|
274
|
+
/**
|
|
275
|
+
* Replaces a slide's notes in the show's own copy, so views of the running show read the new text.
|
|
276
|
+
* @param index - Show position.
|
|
277
|
+
* @param text - New notes.
|
|
278
|
+
*/
|
|
279
|
+
writeNotes(index: number, text: string): void;
|
|
280
|
+
/**
|
|
281
|
+
* Brings in the slide after the one at a position when that slide is hidden, as presentation apps' H key does.
|
|
282
|
+
* @param index - Show position.
|
|
283
|
+
* @returns Show position of the hidden slide, or -1 when the next slide is not hidden.
|
|
284
|
+
*/
|
|
285
|
+
nextHidden(index: number): number;
|
|
286
|
+
/**
|
|
287
|
+
* @param index - Show position counted from 0.
|
|
288
|
+
* @returns The audio and video clips on the slide.
|
|
289
|
+
*/
|
|
290
|
+
media(index: number): readonly PptxShowMedia[];
|
|
291
|
+
/**
|
|
292
|
+
* @param index - Show position counted from 0.
|
|
293
|
+
* @returns The sound the slide's transition plays, an order to stop the sound before, or null.
|
|
294
|
+
*/
|
|
295
|
+
sound(index: number): PptxShowSound | null;
|
|
296
|
+
/**
|
|
297
|
+
* Brings a slide into the show by its deck number, as a link to a hidden slide does: it joins the
|
|
298
|
+
* show where it stands in the deck, which moves the positions after it on by one.
|
|
299
|
+
* @param number - Slide number counted from 1 in deck order, hidden slides included.
|
|
300
|
+
* @returns Its show position, or -1 when the deck has no such slide.
|
|
301
|
+
*/
|
|
302
|
+
reveal(number: number): number;
|
|
303
|
+
/**
|
|
304
|
+
* Presents other slides from now on, as a link to a custom show does.
|
|
305
|
+
* @param slides - Slides to present.
|
|
306
|
+
* @returns What the show presented before, to restore when the custom show returns.
|
|
307
|
+
*/
|
|
308
|
+
switchTo(slides: PptxShowRange): PptxShowSequence;
|
|
309
|
+
/** @param sequence - Slides the show presented before a custom show took over. */
|
|
310
|
+
restore(sequence: PptxShowSequence): void;
|
|
311
|
+
/**
|
|
312
|
+
* @param index - Show position counted from 0.
|
|
313
|
+
* @returns The slide as a self-contained SVG document string.
|
|
314
|
+
*/
|
|
315
|
+
render(index: number): string;
|
|
316
|
+
/**
|
|
317
|
+
* @param index - Show position counted from 0.
|
|
318
|
+
* @returns How the slide comes on screen and when the show leaves it.
|
|
319
|
+
*/
|
|
320
|
+
transition(index: number): PptxSlideShowTransition;
|
|
321
|
+
/**
|
|
322
|
+
* @param index - Show position counted from 0.
|
|
323
|
+
* @returns The slide's animation effects in click order, with repeats and rewinds applied.
|
|
324
|
+
*/
|
|
325
|
+
animations(index: number): readonly SlideAnimationStep[];
|
|
326
|
+
/**
|
|
327
|
+
* @param index - Show position counted from 0.
|
|
328
|
+
* @returns Effects played by clicks on trigger shapes, per shape.
|
|
329
|
+
*/
|
|
330
|
+
triggers(index: number): PptxShowEffects["triggers"];
|
|
331
|
+
/**
|
|
332
|
+
* @param index - Show position counted from 0.
|
|
333
|
+
* @returns The slide's main sequence read from its time tree, which the show plays behaviour by behaviour.
|
|
334
|
+
*/
|
|
335
|
+
timeline?(index: number): PptxTimeline;
|
|
336
|
+
}
|
|
337
|
+
/** Transition of a slide in the show, with how the show advances from it. */
|
|
338
|
+
interface PptxSlideShowTransition extends PptxTransitionPlayback {
|
|
339
|
+
/** Whether a click advances. */
|
|
340
|
+
readonly advanceOnClick: boolean;
|
|
341
|
+
/** Milliseconds after which the show advances by itself, or undefined. */
|
|
342
|
+
readonly advanceAfterMs?: number | undefined;
|
|
343
|
+
}
|
|
344
|
+
/** What the pointer does in a show. */
|
|
345
|
+
type PptxShowTool = "pointer" | "laser" | "spotlight" | "magnifier" | "pen" | "highlighter" | "eraser";
|
|
346
|
+
/** Colour a blanked show covers the slide with. */
|
|
347
|
+
type PptxShowBlank = "black" | "white";
|
|
348
|
+
/** What a show leaves behind for the deck once it ends. */
|
|
349
|
+
interface PptxSlideShowResult {
|
|
350
|
+
/** Ink drawn on each slide, in EMU; empty when nothing was drawn or all of it was erased. */
|
|
351
|
+
readonly ink: readonly PptxSlideInk[];
|
|
352
|
+
/** Rehearsed time per slide, or null when the show was not rehearsed. */
|
|
353
|
+
readonly timings: readonly PptxSlideTiming[] | null;
|
|
354
|
+
}
|
|
355
|
+
/** Clock of a rehearsed show. */
|
|
356
|
+
interface PptxRehearsal {
|
|
357
|
+
/** Whether the clock is paused. */
|
|
358
|
+
readonly paused: boolean;
|
|
359
|
+
/** @returns Milliseconds the current slide has been on screen. */
|
|
360
|
+
slideMs(): number;
|
|
361
|
+
/** @returns Milliseconds the whole rehearsal has taken. */
|
|
362
|
+
totalMs(): number;
|
|
363
|
+
/** Pauses or resumes the clock. */
|
|
364
|
+
toggle(): void;
|
|
365
|
+
/** Restarts the current slide's time. */
|
|
366
|
+
repeat(): void;
|
|
367
|
+
}
|
|
368
|
+
/** A running slide show. */
|
|
369
|
+
interface PptxSlideShow {
|
|
370
|
+
/** Show position counted from 0. */
|
|
371
|
+
readonly index: number;
|
|
372
|
+
/** Slides presented. */
|
|
373
|
+
readonly deck: PptxSlideShowDeck;
|
|
374
|
+
/** Full-screen element; controls placed inside it stay visible in full screen. */
|
|
375
|
+
readonly surface: HTMLElement;
|
|
376
|
+
/** What the pointer does. */
|
|
377
|
+
readonly tool: PptxShowTool;
|
|
378
|
+
/** Colour of the ink tool in hand, or of the pen. */
|
|
379
|
+
readonly inkColor: string;
|
|
380
|
+
/** Colour covering the slide, or null when it shows. */
|
|
381
|
+
readonly blank: PptxShowBlank | null;
|
|
382
|
+
/** Whether any slide carries ink. */
|
|
383
|
+
readonly hasInk: boolean;
|
|
384
|
+
/** Click stops of the current slide's animations: how many have played and how many there are; the next click plays one while some remain. */
|
|
385
|
+
readonly animation: {
|
|
386
|
+
readonly played: number;
|
|
387
|
+
readonly total: number;
|
|
388
|
+
};
|
|
389
|
+
/** Clock of a rehearsed show, or null. */
|
|
390
|
+
readonly rehearsal: PptxRehearsal | null;
|
|
391
|
+
/** Whether the show stays in the browser window, as the reading view does. */
|
|
392
|
+
readonly windowed: boolean;
|
|
393
|
+
/** Milliseconds since the show started. */
|
|
394
|
+
elapsedMs(): number;
|
|
395
|
+
/** Resolves once the show has ended, by the viewer or by `close()`, with its ink and timings. */
|
|
396
|
+
readonly closed: Promise<PptxSlideShowResult>;
|
|
397
|
+
/** @param index - Show position to present; clamped to the deck. */
|
|
398
|
+
go(index: number): void;
|
|
399
|
+
/** Plays the next animation step or moves to the next slide. */
|
|
400
|
+
next(): void;
|
|
401
|
+
/** Steps one animation back or returns to the previous slide. */
|
|
402
|
+
previous(): void;
|
|
403
|
+
/** @param tool - What the pointer does from now on. */
|
|
404
|
+
setTool(tool: PptxShowTool): void;
|
|
405
|
+
/** @param color - Colour of the ink tool in hand as `#RRGGBB`; without one in hand the pen takes it. */
|
|
406
|
+
setInkColor(color: string): void;
|
|
407
|
+
/** @param scope - Erases the ink of the current slide, or of every slide. */
|
|
408
|
+
clearInk(scope?: "slide" | "all"): void;
|
|
409
|
+
/** @param blank - Colour to cover the slide with, or null to show it. */
|
|
410
|
+
setBlank(blank: PptxShowBlank | null): void;
|
|
411
|
+
/**
|
|
412
|
+
* Runs a show key pressed elsewhere, such as in the presenter view.
|
|
413
|
+
* @param event - Key press.
|
|
414
|
+
* @returns Whether it was a show key.
|
|
415
|
+
*/
|
|
416
|
+
handleKey(event: Pick<KeyboardEvent, "key" | "ctrlKey" | "metaKey" | "altKey">): boolean;
|
|
417
|
+
/** @param listener - Called after the slide, tool or blank changes. @returns Detaches it. */
|
|
418
|
+
subscribe(listener: () => void): () => void;
|
|
419
|
+
/**
|
|
420
|
+
* Keeps the show covering the page when the browser leaves full screen by itself within the next second, as
|
|
421
|
+
* browsers do when the page opens another window; any later exit ends the show.
|
|
422
|
+
*/
|
|
423
|
+
expectWindowed(): void;
|
|
424
|
+
/** Whether slides that advance by their timings wait until resumed. */
|
|
425
|
+
readonly paused: boolean;
|
|
426
|
+
/** @param paused - Holds automatic advancing, or resumes it; a rehearsal clock pauses with it. */
|
|
427
|
+
setPaused(paused: boolean): void;
|
|
428
|
+
/** Whether the ink drawn in the show is shown. */
|
|
429
|
+
readonly inkVisible: boolean;
|
|
430
|
+
/** @param visible - Shows or hides the ink without erasing it. */
|
|
431
|
+
setInkVisible(visible: boolean): void;
|
|
432
|
+
/** Returns to the slide shown before the current one. */
|
|
433
|
+
goLastViewed(): void;
|
|
434
|
+
/** Ends the show and removes its surface. */
|
|
435
|
+
close(): void;
|
|
436
|
+
}
|
|
437
|
+
/** A transition as the player runs it. */
|
|
438
|
+
interface PptxTransitionPlayback {
|
|
439
|
+
/** Effect name; effects the player does not draw fade. */
|
|
440
|
+
readonly effect: string;
|
|
441
|
+
/** Side sliding effects enter from. */
|
|
442
|
+
readonly from?: PptxTransitionSide | undefined;
|
|
443
|
+
/** Whether split and zoom open out (`out`) or close in (`in`). */
|
|
444
|
+
readonly inOut?: "in" | "out" | undefined;
|
|
445
|
+
/** Axis of a split. */
|
|
446
|
+
readonly orientation?: "horz" | "vert" | undefined;
|
|
447
|
+
/**
|
|
448
|
+
* Direction token as the file writes it, for effects whose direction is not a side: `horz` or
|
|
449
|
+
* `vert` for blinds, checker, comb, random bars, doors and window, and a corner (`lu`, `ru`,
|
|
450
|
+
* `ld`, `rd`) for strips. Side tokens name the way the slide moves, so `l` enters from the right.
|
|
451
|
+
*/
|
|
452
|
+
readonly direction?: string | undefined;
|
|
453
|
+
/** Spokes of a wheel; four when left out. */
|
|
454
|
+
readonly spokes?: number | undefined;
|
|
455
|
+
/** Whether a fade or cut passes through black. */
|
|
456
|
+
readonly thruBlack?: boolean | undefined;
|
|
457
|
+
/** Length in milliseconds. */
|
|
458
|
+
readonly durationMs: number;
|
|
459
|
+
}
|
|
460
|
+
/** An audio or video clip on a slide of the show. */
|
|
461
|
+
interface PptxShowMedia {
|
|
462
|
+
/** Shape id of the clip's picture. */
|
|
463
|
+
readonly shape: number;
|
|
464
|
+
/** Audio or video; online clips play as video. */
|
|
465
|
+
readonly kind: "audio" | "video";
|
|
466
|
+
/** Embedded bytes with their media type, or the address of a linked clip. */
|
|
467
|
+
readonly source: {
|
|
468
|
+
readonly bytes: Uint8Array;
|
|
469
|
+
readonly type: string;
|
|
470
|
+
} | {
|
|
471
|
+
readonly url: string;
|
|
472
|
+
};
|
|
473
|
+
/** How the clip plays, or null for the file defaults: on click, once. */
|
|
474
|
+
readonly playback: MediaPlayback | null;
|
|
475
|
+
/** Unrotated frame of the picture in fractions of the slide. */
|
|
476
|
+
readonly box: {
|
|
477
|
+
readonly x: number;
|
|
478
|
+
readonly y: number;
|
|
479
|
+
readonly width: number;
|
|
480
|
+
readonly height: number;
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
/** Sound of a slide transition. */
|
|
484
|
+
type PptxShowSound = {
|
|
485
|
+
readonly kind: "stop";
|
|
486
|
+
} | {
|
|
487
|
+
readonly kind: "play";
|
|
488
|
+
readonly bytes: Uint8Array;
|
|
489
|
+
readonly loop: boolean;
|
|
490
|
+
readonly name: string;
|
|
491
|
+
};
|
|
492
|
+
/** A slide's effects as the show plays them. */
|
|
493
|
+
interface PptxShowEffects {
|
|
494
|
+
/** Effects of the slide's own click sequence. */
|
|
495
|
+
readonly main: readonly SlideAnimationStep[];
|
|
496
|
+
/** Effects each trigger shape's clicks play, one click group after another. */
|
|
497
|
+
readonly triggers: readonly {
|
|
498
|
+
readonly shape: number;
|
|
499
|
+
readonly steps: readonly SlideAnimationStep[];
|
|
500
|
+
}[];
|
|
501
|
+
}
|
|
502
|
+
//#endregion
|
|
503
|
+
//#region src/types.d.ts
|
|
504
|
+
/** Optional file opened when the workspace first mounts. */
|
|
505
|
+
interface PptxEditorInitialDocument {
|
|
506
|
+
/** File name shown in the title bar and used for downloads. */
|
|
507
|
+
readonly name: string;
|
|
508
|
+
/**
|
|
509
|
+
* Loads the initial deck, falling back to a new presentation when unavailable.
|
|
510
|
+
* @param signal - Aborted when another file opens or the editor is destroyed.
|
|
511
|
+
* @returns Deck bytes, or undefined to start with a new presentation.
|
|
512
|
+
*/
|
|
513
|
+
readonly read: (signal: AbortSignal) => Promise<Uint8Array | undefined>;
|
|
514
|
+
}
|
|
515
|
+
/** How a request sent to the assistant runs. */
|
|
516
|
+
interface PptxAskOptions {
|
|
517
|
+
/** Whether it creates the deck, so its edits apply at once instead of waiting for review. */
|
|
518
|
+
readonly create?: boolean | undefined;
|
|
519
|
+
}
|
|
520
|
+
/** One version the host is asked to store. */
|
|
521
|
+
interface PptxEditorSaveRequest {
|
|
522
|
+
/** File name the session knows the deck by. */
|
|
523
|
+
readonly name: string;
|
|
524
|
+
/** Complete deck as `.pptx` bytes. */
|
|
525
|
+
readonly bytes: Uint8Array;
|
|
526
|
+
}
|
|
527
|
+
/** Host configuration for one mounted PPTX editor. */
|
|
528
|
+
interface PptxEditorOptions {
|
|
529
|
+
/** Interface language of this editor. */
|
|
530
|
+
readonly locale?: EditorWorkspaceLocale | undefined;
|
|
531
|
+
/** @param locale - Language chosen in the File menu. */
|
|
532
|
+
readonly onLocaleChange?: ((locale: EditorWorkspaceLocale) => void) | undefined;
|
|
533
|
+
/** License key supplied by the host. Null selects evaluation mode. */
|
|
534
|
+
readonly licenseKey?: string | null;
|
|
535
|
+
/** Initial file. Without a file the editor opens a new presentation. */
|
|
536
|
+
readonly initialDocument?: PptxEditorInitialDocument;
|
|
537
|
+
/**
|
|
538
|
+
* Stores a version on the host. Without it, saving downloads a copy and counts as saved.
|
|
539
|
+
* @param request - Name and bytes of the version.
|
|
540
|
+
* @returns Whether the host stored it; false keeps the deck marked as changed so the user can retry.
|
|
541
|
+
*/
|
|
542
|
+
readonly save?: (request: PptxEditorSaveRequest) => Promise<boolean>;
|
|
543
|
+
/** Saves shortly after each edit through `save`; ignored without it. */
|
|
544
|
+
readonly autoSave?: boolean;
|
|
545
|
+
/** @param session - Session of the open deck, or undefined after destruction. */
|
|
546
|
+
readonly onSessionChange?: (session: PptxEditorSession | undefined) => void;
|
|
547
|
+
/** Side panels, such as the assistant from `@quirekit/pptx-editor/ai`. */
|
|
548
|
+
readonly panels?: readonly PptxEditorPanel[] | undefined;
|
|
549
|
+
/** Where presentation templates come from, such as the company's own or a template library; people's own uploads are always offered. */
|
|
550
|
+
readonly templates?: readonly PptxTemplateSource[] | undefined;
|
|
551
|
+
}
|
|
552
|
+
/** Where an observed change came from: the user, a command call, the AI assistant, undo or redo, or another file. */
|
|
553
|
+
type PptxChangeSource = "user" | "command" | "agent" | "history" | "file";
|
|
554
|
+
/**
|
|
555
|
+
* Where a panel is shown: beside the slide, widened, or over the main area with the slide previewed beside it, still
|
|
556
|
+
* editable.
|
|
557
|
+
*/
|
|
558
|
+
type PptxEditorPanelLayout = "side" | "wide" | "page";
|
|
559
|
+
/** What a side panel plugin receives when it mounts. */
|
|
560
|
+
interface PptxEditorPanelContext {
|
|
561
|
+
/** Interface language when the panel mounts. */
|
|
562
|
+
readonly locale?: EditorWorkspaceLocale;
|
|
563
|
+
/** Session of the open deck. */
|
|
564
|
+
readonly session: PptxEditorSession;
|
|
565
|
+
/** Document the editor is mounted in. */
|
|
566
|
+
readonly ownerDocument: Document;
|
|
567
|
+
/** @param part - Slide part name. @returns The editor's drawing of the slide, from the cache the slide list and stage share. */
|
|
568
|
+
readonly renderSlide?: (part: string) => string;
|
|
569
|
+
/**
|
|
570
|
+
* @param part - Slide part name.
|
|
571
|
+
* @param width - Picture width in pixels.
|
|
572
|
+
* @returns The slide drawn as the show draws it, as PNG bytes.
|
|
573
|
+
*/
|
|
574
|
+
readonly pictureSlide?: (part: string, width: number) => Promise<Uint8Array>;
|
|
575
|
+
/** Closes the panel. */
|
|
576
|
+
close(): void;
|
|
577
|
+
/** @param layout - Layout to show the panel in, one of the panel's `layouts`; the editor reports it back with `layout`. */
|
|
578
|
+
setLayout(layout: PptxEditorPanelLayout): void;
|
|
579
|
+
}
|
|
580
|
+
/** Mounted content of a side panel. */
|
|
581
|
+
interface PptxEditorPanelMount {
|
|
582
|
+
/** Element placed in the side panel. */
|
|
583
|
+
readonly element: HTMLElement;
|
|
584
|
+
/**
|
|
585
|
+
* Sends a request to an assistant panel as if the person typed it.
|
|
586
|
+
* @param text - Request text.
|
|
587
|
+
* @param options - How the request runs.
|
|
588
|
+
* @returns Whether it was sent or queued.
|
|
589
|
+
*/
|
|
590
|
+
ask?(text: string, options?: PptxAskOptions): Promise<boolean>;
|
|
591
|
+
/** @param layout - Layout the editor now shows the panel in; it returns to the side when the panel closes. */
|
|
592
|
+
layout?(layout: PptxEditorPanelLayout): void;
|
|
593
|
+
/** @param locale - New workspace language. */
|
|
594
|
+
setLocale?(locale: EditorWorkspaceLocale): void;
|
|
595
|
+
/** Releases the content. */
|
|
596
|
+
destroy(): void;
|
|
597
|
+
}
|
|
598
|
+
/** A side panel beside the slide, such as the AI assistant. */
|
|
599
|
+
interface PptxEditorPanel {
|
|
600
|
+
/** Stable identity. */
|
|
601
|
+
readonly id: string;
|
|
602
|
+
/** Button and panel name. */
|
|
603
|
+
readonly label: string;
|
|
604
|
+
/** Icon of the panel's rail button, named by the label in its tooltip; a panel icon when left out. */
|
|
605
|
+
readonly icon?: string | undefined;
|
|
606
|
+
/** Open the panel when the editor mounts. */
|
|
607
|
+
readonly defaultOpen?: boolean | undefined;
|
|
608
|
+
/** Layouts the panel can be shown in; default the side only. */
|
|
609
|
+
readonly layouts?: readonly PptxEditorPanelLayout[] | undefined;
|
|
610
|
+
/** Whether the panel is the deck's assistant, which views of the editor can send requests to, such as confirming a storyline. */
|
|
611
|
+
readonly assistant?: boolean | undefined;
|
|
612
|
+
/** @param context - Session and panel controls. @returns Mounted content, created on first open and kept while the editor lives. */
|
|
613
|
+
mount(context: PptxEditorPanelContext): PptxEditorPanelMount;
|
|
614
|
+
}
|
|
615
|
+
/** Event the session reports to its host. */
|
|
616
|
+
type PptxEditorEvent = {
|
|
617
|
+
/** The deck kept an edit, an undo or redo, or another file was opened. */readonly type: "change"; /** Origin of the change. */
|
|
618
|
+
readonly source: PptxChangeSource;
|
|
619
|
+
} | {
|
|
620
|
+
/** The deck gained unsaved changes, or they were saved. */readonly type: "dirty"; /** Whether changes are waiting to be saved. */
|
|
621
|
+
readonly dirty: boolean;
|
|
622
|
+
};
|
|
623
|
+
/** Shape the user has selected, named so that it stays valid while slides move. */
|
|
624
|
+
interface PptxShapeReference {
|
|
625
|
+
/** Slide part name, such as `/ppt/slides/slide3.xml`. */
|
|
626
|
+
readonly slide: string;
|
|
627
|
+
/** Slide position counted from 0 when the selection was read. */
|
|
628
|
+
readonly slideIndex: number;
|
|
629
|
+
/** Shape id inside the slide. */
|
|
630
|
+
readonly shape: number;
|
|
631
|
+
/** Shape name, for people. */
|
|
632
|
+
readonly name: string;
|
|
633
|
+
}
|
|
634
|
+
/** Open deck as the host and its first-party features see it. */
|
|
635
|
+
interface PptxEditorSession {
|
|
636
|
+
/** Resolves once the first deck is open and shown. */
|
|
637
|
+
readonly ready: Promise<void>;
|
|
638
|
+
/** @returns File name the session knows the deck by. */
|
|
639
|
+
name(): string;
|
|
640
|
+
/** @returns Whether the deck has changes the host has not stored. */
|
|
641
|
+
isDirty(): boolean;
|
|
642
|
+
/** @returns Shapes the user has selected. */
|
|
643
|
+
selection(): readonly PptxShapeReference[];
|
|
644
|
+
/** @returns The deck as it is now; it does not save or mark it saved. */
|
|
645
|
+
snapshot(): Promise<Uint8Array>;
|
|
646
|
+
/**
|
|
647
|
+
* Opens another deck in place of the current one.
|
|
648
|
+
* @param name - File name.
|
|
649
|
+
* @param bytes - Deck bytes.
|
|
650
|
+
* @returns Whether the deck could be read and opened.
|
|
651
|
+
*/
|
|
652
|
+
open(name: string, bytes: Uint8Array): Promise<boolean>;
|
|
653
|
+
/** Replaces the deck with a new presentation of one title slide. */
|
|
654
|
+
createDocument(): Promise<void>;
|
|
655
|
+
/** @param name - File name to keep the deck under; `.pptx` is added when missing. */
|
|
656
|
+
rename(name: string): void;
|
|
657
|
+
/**
|
|
658
|
+
* Puts the deck on a template as one undo step: its slides take the template's masters, layouts and theme, and the
|
|
659
|
+
* assistant and the Design tab offer its pages. A new deck starts with the template's cover.
|
|
660
|
+
* @param template - Template of one of the host's sources, or a file with an optional manifest.
|
|
661
|
+
* @returns Whether it was applied; false when its source no longer has it.
|
|
662
|
+
*/
|
|
663
|
+
applyTemplate(template: {
|
|
664
|
+
readonly source: string;
|
|
665
|
+
readonly id: string;
|
|
666
|
+
} | PptxTemplateFile): Promise<boolean>;
|
|
667
|
+
/** @returns Whether a step was undone. */
|
|
668
|
+
undo(): Promise<boolean>;
|
|
669
|
+
/** @returns Whether a step was redone. */
|
|
670
|
+
redo(): Promise<boolean>;
|
|
671
|
+
/** @returns Whether the current version is stored afterwards. */
|
|
672
|
+
save(): Promise<boolean>;
|
|
673
|
+
/** Typed commands; each call is one undoable edit. */
|
|
674
|
+
readonly commands: PptxCommands;
|
|
675
|
+
/** @returns A chain whose commands run as one undoable edit. */
|
|
676
|
+
chain(): PptxChain;
|
|
677
|
+
/**
|
|
678
|
+
* Presents the deck from a slide, by default the one holding the selection.
|
|
679
|
+
* @param start - Slide position counted from 0.
|
|
680
|
+
* @returns The running show.
|
|
681
|
+
*/
|
|
682
|
+
present(start?: number): Promise<PptxSlideShow>;
|
|
683
|
+
/** @param listener - Receives every event. @returns Detaches it. */
|
|
684
|
+
subscribe(listener: (event: PptxEditorEvent) => void): () => void;
|
|
685
|
+
}
|
|
686
|
+
//#endregion
|
|
687
|
+
export { PptxEditorOptions as a, PptxEditorPanelLayout as c, PptxEditorSession as d, PptxShapeReference as f, PptxEditorInitialDocument as i, PptxEditorPanelMount as l, PptxChangeSource as n, PptxEditorPanel as o, PptxSlideShow as p, PptxEditorEvent as r, PptxEditorPanelContext as s, PptxAskOptions as t, PptxEditorSaveRequest as u };
|