@betteroffice/pptx-react 0.1.1 → 0.5.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 +115 -102
- package/dist/chunk-3Y6BQIW3.js +1 -0
- package/dist/chunk-66PPYFHW.js +4 -0
- package/dist/chunk-HGG45CCF.js +1 -0
- package/dist/chunk-HQ2N3DQ7.js +1 -0
- package/dist/chunk-J3YQUJUG.js +1 -0
- package/dist/chunk-M267LYSF.js +1 -0
- package/dist/chunk-O2XFH626.js +1 -0
- package/dist/chunk-V62S3LXB.js +1 -0
- package/dist/chunk-X2M23RXQ.js +1 -0
- package/dist/chunk-X6B77B3U.js +1 -0
- package/dist/index.d.ts +1137 -46
- package/dist/index.js +1 -4
- package/package.json +9 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,46 +1,97 @@
|
|
|
1
|
+
import * as _betteroffice_pptx from '@betteroffice/pptx';
|
|
2
|
+
import { ParagraphAlignment, PptxEditRefusal, PptxReadRequest, PptxReadResult, PptxFindRequest, PptxFindResult, PptxEditRequest, PptxValidationResult, PptxEditResult, PptxFontFace, CollaborationReplica, PptxPresence, HitTestResult, PresentationHandle, DeckSnapshot } from '@betteroffice/pptx';
|
|
1
3
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
4
|
+
import { ComponentType, ReactNode, CSSProperties, JSX } from 'react';
|
|
5
|
+
import { TranslationKey, Translations, TFunction } from '@betteroffice/pptx-i18n';
|
|
6
|
+
import { PptxWorkerEditorFailedError, PptxWorkerEditorAccess, PptxWorkerEditorRecovery, PresentationCommandAccessMethod, PresentationCommandAccessMethods, PresentationCommandMutationMethods } from '@betteroffice/pptx/worker';
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
/**
|
|
9
|
+
* A value that survives `JSON.stringify` / `JSON.parse` unchanged.
|
|
10
|
+
* @experimental
|
|
11
|
+
*/
|
|
12
|
+
type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
|
|
13
|
+
readonly [key: string]: JsonValue;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A machine-readable code with a localized explanation for people.
|
|
17
|
+
* @experimental
|
|
18
|
+
*/
|
|
19
|
+
interface CommandReason<Code extends string = string> {
|
|
20
|
+
code: Code;
|
|
21
|
+
message: string;
|
|
20
22
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Serializable availability of one editor command. A disabled command always
|
|
25
|
+
* says why; branch on `disabledReason.code`, show `disabledReason.message`.
|
|
26
|
+
* @experimental
|
|
27
|
+
*/
|
|
28
|
+
type CommandState<Value extends JsonValue = JsonValue, Code extends string = string> = {
|
|
29
|
+
/** Toggle state; `'mixed'` when the selection disagrees. */
|
|
30
|
+
active?: boolean | 'mixed';
|
|
31
|
+
/** The command's current value, such as the selected style or font size. */
|
|
32
|
+
value?: Value;
|
|
33
|
+
} & ({
|
|
34
|
+
enabled: true;
|
|
35
|
+
disabledReason?: never;
|
|
36
|
+
} | {
|
|
37
|
+
enabled: false;
|
|
38
|
+
disabledReason: CommandReason<Code>;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Plugin DTOs shared by the formats' editor plugin hosts. Clients, selections, anchors, layouts
|
|
43
|
+
* and command maps stay format-owned; these shapes fix grants, lifecycle metadata and refusals.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
47
|
+
/**
|
|
48
|
+
* What a host lets one plugin do. Without a grant a plugin reads, validates and navigates only.
|
|
49
|
+
* Built-in commands need their id listed; mutating ones also need `document: 'write'`.
|
|
50
|
+
*/
|
|
51
|
+
type PluginGrant<CommandId extends string> = {
|
|
52
|
+
commands?: readonly CommandId[];
|
|
53
|
+
} & ({
|
|
54
|
+
document?: 'read';
|
|
55
|
+
editBatches?: never;
|
|
56
|
+
untrackedHistory?: never;
|
|
57
|
+
} | {
|
|
58
|
+
document: 'write';
|
|
59
|
+
/** Allows applying edit batches. */
|
|
60
|
+
editBatches?: true;
|
|
61
|
+
/** Allows batches with `history: 'none'`. */
|
|
62
|
+
untrackedHistory?: true;
|
|
63
|
+
});
|
|
64
|
+
/** Why a plugin's cleanups run. */
|
|
65
|
+
type PluginCleanupReason = 'removed' | 'document-replaced' | 'definition-replaced' | 'unmounted' | 'failed';
|
|
66
|
+
/** `attached`: the plugin was added while a document was open. */
|
|
67
|
+
type PluginLoadReason = 'loaded' | 'replaced' | 'attached';
|
|
68
|
+
type PluginFailureCode = 'plugin-unavailable' | 'document-replaced' | 'aborted' | 'permission-denied' | 'read-only' | 'input-failed' | 'unsupported-policy' | 'plugin-failed';
|
|
69
|
+
/** A plugin client call refused before it reached the document. */
|
|
70
|
+
interface PluginRefusal<Code extends string = PluginFailureCode> {
|
|
71
|
+
ok: false;
|
|
72
|
+
failure: CommandReason<Code>;
|
|
26
73
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
className?: string;
|
|
35
|
-
/** Download name for the save button; falls back to `presentation.pptx`. */
|
|
36
|
-
fileName?: string;
|
|
37
|
-
onReady?: (api: PptxEditorApi) => void;
|
|
38
|
-
onChange?: (snapshot: DeckSnapshot) => void;
|
|
39
|
-
onError?: (error: Error) => void;
|
|
40
|
-
/** Receives the saved bytes; without it, saving downloads the file. */
|
|
41
|
-
onSave?: (bytes: Uint8Array) => void;
|
|
74
|
+
type PluginErrorPhase = 'definition' | 'initialize' | 'event' | 'render' | 'command-state' | 'command' | 'cleanup' | 'action';
|
|
75
|
+
/** A plugin failure reported to the host; `generation` is null outside a document. */
|
|
76
|
+
interface PluginError<Phase extends string = PluginErrorPhase> {
|
|
77
|
+
pluginId: string;
|
|
78
|
+
generation: string | null;
|
|
79
|
+
phase: Phase;
|
|
80
|
+
error: unknown;
|
|
42
81
|
}
|
|
43
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Outcome of a contributed command. Failure codes are the plugin's own, and a refused edit batch
|
|
84
|
+
* can be returned as-is, keeping its structured failure.
|
|
85
|
+
*/
|
|
86
|
+
type PluginCommandResult<Status extends string = string, Refusal extends {
|
|
87
|
+
ok: false;
|
|
88
|
+
} = never> = {
|
|
89
|
+
ok: true;
|
|
90
|
+
status: Status;
|
|
91
|
+
} | {
|
|
92
|
+
ok: false;
|
|
93
|
+
failure: CommandReason;
|
|
94
|
+
} | Refusal;
|
|
44
95
|
|
|
45
96
|
declare const SHAPE_PRESETS: readonly [{
|
|
46
97
|
readonly geometry: "rect";
|
|
@@ -126,6 +177,7 @@ interface ShapeFormatting {
|
|
|
126
177
|
strokeWidthPt?: number | null;
|
|
127
178
|
adjustments?: Record<string, number>;
|
|
128
179
|
}
|
|
180
|
+
type ShapeZOrder = 'front' | 'forward' | 'backward' | 'back';
|
|
129
181
|
type ShapeFormattingAction = {
|
|
130
182
|
type: 'fillColor';
|
|
131
183
|
value: string | null;
|
|
@@ -139,19 +191,841 @@ type ShapeFormattingAction = {
|
|
|
139
191
|
type: 'adjust';
|
|
140
192
|
name: string;
|
|
141
193
|
value: number;
|
|
194
|
+
} | {
|
|
195
|
+
type: 'zOrder';
|
|
196
|
+
value: ShapeZOrder;
|
|
142
197
|
};
|
|
143
198
|
interface SlideLayoutOption {
|
|
144
199
|
partPath: string | null;
|
|
145
200
|
label?: string;
|
|
146
201
|
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* A paint-order move of the selected object among its siblings.
|
|
205
|
+
* @experimental
|
|
206
|
+
*/
|
|
207
|
+
type PptxZOrderMove = 'front' | 'forward' | 'backward' | 'back';
|
|
208
|
+
/**
|
|
209
|
+
* Arguments of every PPTX editor command, keyed by command id.
|
|
210
|
+
* @experimental
|
|
211
|
+
*/
|
|
212
|
+
interface PptxCommandArgs {
|
|
213
|
+
bold: null;
|
|
214
|
+
italic: null;
|
|
215
|
+
underline: null;
|
|
216
|
+
fontFamily: {
|
|
217
|
+
family: string;
|
|
218
|
+
};
|
|
219
|
+
/** Size in points, 1 to 400. */
|
|
220
|
+
fontSize: {
|
|
221
|
+
points: number;
|
|
222
|
+
};
|
|
223
|
+
fontSizeStep: {
|
|
224
|
+
direction: 'increase' | 'decrease';
|
|
225
|
+
};
|
|
226
|
+
/** `#rrggbb`. */
|
|
227
|
+
textColor: {
|
|
228
|
+
color: string;
|
|
229
|
+
};
|
|
230
|
+
alignment: {
|
|
231
|
+
value: ParagraphAlignment;
|
|
232
|
+
};
|
|
233
|
+
/** Omit the layout to reuse the current slide's; `null` inserts without one. */
|
|
234
|
+
insertSlide: {
|
|
235
|
+
layoutPartPath?: string | null;
|
|
236
|
+
};
|
|
237
|
+
insertImage: null;
|
|
238
|
+
/** Selects, or arms text-box or `shape:<preset>` placement on the canvas. */
|
|
239
|
+
tool: {
|
|
240
|
+
value: PptxEditorTool;
|
|
241
|
+
};
|
|
242
|
+
/** `#rrggbb`; `null` removes the fill. */
|
|
243
|
+
shapeFill: {
|
|
244
|
+
color: string | null;
|
|
245
|
+
};
|
|
246
|
+
/** `#rrggbb`; `null` removes the outline. */
|
|
247
|
+
shapeStrokeColor: {
|
|
248
|
+
color: string | null;
|
|
249
|
+
};
|
|
250
|
+
/** Outline width in points; `null` removes the outline. */
|
|
251
|
+
shapeStrokeWidth: {
|
|
252
|
+
points: number | null;
|
|
253
|
+
};
|
|
254
|
+
/** An adjustment of the selected shape, as a fraction of its range. */
|
|
255
|
+
shapeAdjustment: {
|
|
256
|
+
name: string;
|
|
257
|
+
value: number;
|
|
258
|
+
};
|
|
259
|
+
zOrder: {
|
|
260
|
+
value: PptxZOrderMove;
|
|
261
|
+
};
|
|
262
|
+
save: null;
|
|
263
|
+
exportPng: null;
|
|
264
|
+
slideshow: null;
|
|
265
|
+
undo: null;
|
|
266
|
+
redo: null;
|
|
267
|
+
/** 1 is 100%, from 0.1 to 5; `'fit'` fits the slide to the window. */
|
|
268
|
+
zoom: {
|
|
269
|
+
scale: number | 'fit';
|
|
270
|
+
};
|
|
271
|
+
/** `null` toggles the panel. */
|
|
272
|
+
proposalsPanel: {
|
|
273
|
+
open: boolean;
|
|
274
|
+
} | null;
|
|
275
|
+
proposalSelect: {
|
|
276
|
+
proposalId: string;
|
|
277
|
+
};
|
|
278
|
+
/** Shows the selected proposal's changes on the canvas, or the editable slide. */
|
|
279
|
+
proposalDiff: {
|
|
280
|
+
enabled: boolean;
|
|
281
|
+
};
|
|
282
|
+
/** `force` applies a proposal whose targets changed after it was made. */
|
|
283
|
+
proposalAccept: {
|
|
284
|
+
proposalId: string;
|
|
285
|
+
force?: boolean;
|
|
286
|
+
};
|
|
287
|
+
proposalReject: {
|
|
288
|
+
proposalId: string;
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
/** @experimental */
|
|
292
|
+
type PptxCommandId = keyof PptxCommandArgs;
|
|
293
|
+
/**
|
|
294
|
+
* Commands presented as a choice between options.
|
|
295
|
+
* @experimental
|
|
296
|
+
*/
|
|
297
|
+
type PptxSelectCommandId = 'fontFamily' | 'fontSize' | 'alignment' | 'insertSlide' | 'tool' | 'shapeStrokeWidth' | 'shapeAdjustment' | 'zoom' | 'proposalSelect';
|
|
298
|
+
/**
|
|
299
|
+
* Current values reported in {@link PptxCommandState.value}, keyed by command id.
|
|
300
|
+
* @experimental
|
|
301
|
+
*/
|
|
302
|
+
interface PptxCommandValues {
|
|
303
|
+
bold: null;
|
|
304
|
+
italic: null;
|
|
305
|
+
underline: null;
|
|
306
|
+
/** `null` when the selection mixes families. */
|
|
307
|
+
fontFamily: string | null;
|
|
308
|
+
/** Points; `null` when the selection mixes sizes. */
|
|
309
|
+
fontSize: number | null;
|
|
310
|
+
fontSizeStep: null;
|
|
311
|
+
/** `#rrggbb`; `null` when the selection mixes colors. */
|
|
312
|
+
textColor: string | null;
|
|
313
|
+
/** `null` when the selected paragraphs differ. */
|
|
314
|
+
alignment: ParagraphAlignment | null;
|
|
315
|
+
/** The current slide's layout part. */
|
|
316
|
+
insertSlide: string | null;
|
|
317
|
+
insertImage: null;
|
|
318
|
+
tool: PptxEditorTool;
|
|
319
|
+
/** `#rrggbb`; `null` without a fill. */
|
|
320
|
+
shapeFill: string | null;
|
|
321
|
+
/** `#rrggbb`; `null` without an outline. */
|
|
322
|
+
shapeStrokeColor: string | null;
|
|
323
|
+
/** Points; `null` without an outline. */
|
|
324
|
+
shapeStrokeWidth: number | null;
|
|
325
|
+
/** The shape's primary adjustment; `null` when it has none. */
|
|
326
|
+
shapeAdjustment: {
|
|
327
|
+
name: string;
|
|
328
|
+
value: number;
|
|
329
|
+
} | null;
|
|
330
|
+
zOrder: null;
|
|
331
|
+
save: null;
|
|
332
|
+
exportPng: null;
|
|
333
|
+
slideshow: null;
|
|
334
|
+
undo: null;
|
|
335
|
+
redo: null;
|
|
336
|
+
zoom: PptxZoom;
|
|
337
|
+
/** Whether the proposals panel is open. */
|
|
338
|
+
proposalsPanel: boolean;
|
|
339
|
+
/** The proposal shown on the canvas. */
|
|
340
|
+
proposalSelect: string | null;
|
|
341
|
+
/** Whether the canvas shows the selected proposal's changes. */
|
|
342
|
+
proposalDiff: boolean;
|
|
343
|
+
proposalAccept: null;
|
|
344
|
+
proposalReject: null;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Why a command is unavailable.
|
|
348
|
+
* @experimental
|
|
349
|
+
*/
|
|
350
|
+
type PptxCommandDisabledCode = 'editor-unavailable' | 'document-loading' | 'no-document' | 'read-only' | 'nothing-to-undo' | 'nothing-to-redo' | 'text-selection-required' | 'shape-required' | 'slide-required' | 'unsupported-selection' | 'invalid-layout' | 'invalid-adjustment' | 'z-order-boundary' | 'review-active'
|
|
351
|
+
/** The canvas diff of a proposal has not painted yet; reported by the canvas review control. */
|
|
352
|
+
| 'preview-pending'
|
|
353
|
+
/** The canvas diff of a proposal could not be laid out; reported by the canvas review control. */
|
|
354
|
+
| 'preview-failed' | 'proposal-stale' | 'proposal-not-found' | 'proposals-unavailable' | 'host-disabled' | 'unsupported-command' | 'invalid-arguments' | 'permission-denied' | 'unsupported-policy' | 'plugin-unavailable';
|
|
355
|
+
/**
|
|
356
|
+
* Why an executed command did not complete.
|
|
357
|
+
* @experimental
|
|
358
|
+
*/
|
|
359
|
+
type PptxCommandFailureCode = PptxCommandDisabledCode | 'input-failed' | 'document-replaced' | 'target-changed' | 'gesture-active' | 'command-failed' | 'aborted';
|
|
360
|
+
/**
|
|
361
|
+
* One choice of a selector command.
|
|
362
|
+
* @experimental
|
|
363
|
+
*/
|
|
364
|
+
interface PptxCommandOption<K extends PptxCommandId = PptxCommandId> {
|
|
365
|
+
args: PptxCommandArgs[K];
|
|
366
|
+
label: string;
|
|
367
|
+
/** Whether this choice is available and current, as `getState(id, args)` reports it. */
|
|
368
|
+
state: CommandState<never, PptxCommandDisabledCode>;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Serializable state of one PPTX command. Without arguments it describes the
|
|
372
|
+
* control, including its choices; with arguments, that one choice.
|
|
373
|
+
* @experimental
|
|
374
|
+
*/
|
|
375
|
+
type PptxCommandState<K extends PptxCommandId = PptxCommandId> = CommandState<PptxCommandValues[K], PptxCommandDisabledCode> & {
|
|
376
|
+
/** Choices a selector presents, in display order. */
|
|
377
|
+
options?: readonly PptxCommandOption<K>[];
|
|
378
|
+
};
|
|
379
|
+
/**
|
|
380
|
+
* A keyboard binding; `Mod` is Cmd on macOS and Ctrl elsewhere.
|
|
381
|
+
* @experimental
|
|
382
|
+
*/
|
|
383
|
+
interface PptxCommandShortcut<K extends PptxCommandId = PptxCommandId> {
|
|
384
|
+
chord: string;
|
|
385
|
+
args: PptxCommandArgs[K];
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Static, serializable description of a command.
|
|
389
|
+
* @experimental
|
|
390
|
+
*/
|
|
391
|
+
interface PptxCommandDescriptor<K extends PptxCommandId = PptxCommandId> {
|
|
392
|
+
id: K;
|
|
393
|
+
labelKey: TranslationKey;
|
|
394
|
+
mutatesDocument: boolean;
|
|
395
|
+
shortcuts: readonly PptxCommandShortcut<K>[];
|
|
396
|
+
}
|
|
397
|
+
/** @experimental */
|
|
398
|
+
type PptxCommandStatus = 'executed' | 'noop' | 'opened' | 'requested';
|
|
399
|
+
/**
|
|
400
|
+
* Outcome of {@link PptxCommandStore.execute}: `executed` changed something,
|
|
401
|
+
* `noop` was valid but changed nothing, `opened` showed a picker or panel,
|
|
402
|
+
* and `requested` handed the change to the host.
|
|
403
|
+
* @experimental
|
|
404
|
+
*/
|
|
405
|
+
type PptxCommandResult = {
|
|
406
|
+
ok: true;
|
|
407
|
+
status: PptxCommandStatus;
|
|
408
|
+
} | {
|
|
409
|
+
ok: false;
|
|
410
|
+
failure: CommandReason<PptxCommandFailureCode>;
|
|
411
|
+
};
|
|
412
|
+
/**
|
|
413
|
+
* A command a plugin contributes, registered as `plugin:<pluginId>/<localId>`.
|
|
414
|
+
* @experimental
|
|
415
|
+
*/
|
|
416
|
+
type PptxPluginCommandId = `plugin:${string}/${string}`;
|
|
417
|
+
/**
|
|
418
|
+
* Static description of a contributed command.
|
|
419
|
+
* @experimental
|
|
420
|
+
*/
|
|
421
|
+
interface PptxPluginCommandDescriptor {
|
|
422
|
+
id: PptxPluginCommandId;
|
|
423
|
+
label: string;
|
|
424
|
+
mutatesDocument: boolean;
|
|
425
|
+
shortcuts: readonly {
|
|
426
|
+
chord: string;
|
|
427
|
+
args: null;
|
|
428
|
+
}[];
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* State of a contributed command; the plugin chooses its own disabled codes.
|
|
432
|
+
* @experimental
|
|
433
|
+
*/
|
|
434
|
+
type PptxPluginCommandState = CommandState;
|
|
435
|
+
/**
|
|
436
|
+
* Outcome of a contributed command: a plugin-defined failure, or a refused edit batch as-is.
|
|
437
|
+
*
|
|
438
|
+
* @experimental The plugin API may change in minor releases.
|
|
439
|
+
*/
|
|
440
|
+
type PptxPluginCommandResult = PluginCommandResult<PptxCommandStatus, PptxEditRefusal>;
|
|
441
|
+
/**
|
|
442
|
+
* The command authority of one editor, shared by built-in and host chrome.
|
|
443
|
+
* @experimental
|
|
444
|
+
*/
|
|
445
|
+
interface PptxCommandStore {
|
|
446
|
+
getDescriptor<K extends PptxCommandId>(id: K): PptxCommandDescriptor<K>;
|
|
447
|
+
/** Null while no active plugin contributes `id`. */
|
|
448
|
+
getDescriptor(id: PptxPluginCommandId): PptxPluginCommandDescriptor | null;
|
|
449
|
+
/** Snapshots are stable until the state changes; pass `args` to evaluate one option. */
|
|
450
|
+
getState<K extends PptxCommandId>(id: K, args?: PptxCommandArgs[K]): PptxCommandState<K>;
|
|
451
|
+
getState(id: PptxPluginCommandId, args?: null): PptxPluginCommandState;
|
|
452
|
+
subscribe(listener: () => void): () => void;
|
|
453
|
+
/** Runs after input accepted before the call; availability is checked again first. */
|
|
454
|
+
execute<K extends PptxCommandId>(id: K, args: PptxCommandArgs[K]): Promise<PptxCommandResult>;
|
|
455
|
+
/** Runs a contributed command with its plugin's own clients, outside the input queue. */
|
|
456
|
+
execute(id: PptxPluginCommandId, args: null): Promise<PptxPluginCommandResult>;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* What the host lets one plugin do. Without a grant a plugin reads, validates and navigates only.
|
|
461
|
+
* Built-in commands need their id listed and, when they mutate, `document: 'write'`; edit
|
|
462
|
+
* batches need `document: 'write'` and `editBatches`, and `history: 'none'` also needs
|
|
463
|
+
* `untrackedHistory`. `readOnly` refuses every write regardless.
|
|
464
|
+
*
|
|
465
|
+
* @experimental The plugin API may change in minor releases.
|
|
466
|
+
*/
|
|
467
|
+
type PptxPluginGrant = PluginGrant<PptxCommandId>;
|
|
468
|
+
type PptxPluginFailureCode = PluginFailureCode;
|
|
469
|
+
/**
|
|
470
|
+
* A client call refused before it reached the presentation.
|
|
471
|
+
*
|
|
472
|
+
* @experimental The plugin API may change in minor releases.
|
|
473
|
+
*/
|
|
474
|
+
type PptxPluginRefusal = PluginRefusal<PptxPluginFailureCode>;
|
|
475
|
+
/**
|
|
476
|
+
* Versioned presentation reads. Each runs after pending input.
|
|
477
|
+
*
|
|
478
|
+
* @experimental The plugin API may change in minor releases.
|
|
479
|
+
*/
|
|
480
|
+
interface PptxPluginReadClient {
|
|
481
|
+
version(): Promise<{
|
|
482
|
+
ok: true;
|
|
483
|
+
version: string;
|
|
484
|
+
} | PptxPluginRefusal>;
|
|
485
|
+
readContent(request?: PptxReadRequest): Promise<PptxReadResult | PptxPluginRefusal>;
|
|
486
|
+
findText(request: PptxFindRequest): Promise<PptxFindResult | PptxPluginRefusal>;
|
|
487
|
+
/** Checks a batch without granting anything; a later apply is checked again. */
|
|
488
|
+
validateEdits(request: PptxEditRequest): Promise<PptxValidationResult | PptxPluginRefusal>;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Granted edit batches; the grant and `readOnly` are checked when the batch applies.
|
|
492
|
+
*
|
|
493
|
+
* @experimental The plugin API may change in minor releases.
|
|
494
|
+
*/
|
|
495
|
+
interface PptxPluginEditClient {
|
|
496
|
+
applyEdits(request: PptxEditRequest): Promise<PptxEditResult | PptxPluginRefusal>;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* The editor's commands as this plugin may use them.
|
|
500
|
+
*
|
|
501
|
+
* @experimental The plugin API may change in minor releases.
|
|
502
|
+
*/
|
|
503
|
+
interface PptxPluginCommandClient {
|
|
504
|
+
getDescriptor<K extends PptxCommandId>(id: K): PptxCommandDescriptor<K>;
|
|
505
|
+
getDescriptor(id: PptxPluginCommandId): PptxPluginCommandDescriptor | null;
|
|
506
|
+
getState<K extends PptxCommandId>(id: K, args?: PptxCommandArgs[K]): PptxCommandState<K> | {
|
|
507
|
+
enabled: false;
|
|
508
|
+
disabledReason: PptxPluginRefusal['failure'];
|
|
509
|
+
};
|
|
510
|
+
getState(id: PptxPluginCommandId, args?: null): PptxPluginCommandState;
|
|
511
|
+
subscribe(listener: () => void): () => void;
|
|
512
|
+
execute<K extends PptxCommandId>(id: K, args: PptxCommandArgs[K]): Promise<PptxCommandResult | PptxPluginRefusal>;
|
|
513
|
+
/** Only this plugin's own contributed commands. */
|
|
514
|
+
execute(id: PptxPluginCommandId, args: null): Promise<PptxPluginCommandResult | PptxPluginRefusal>;
|
|
515
|
+
}
|
|
516
|
+
/** A rectangle in the units of the space it is used in. */
|
|
517
|
+
interface PptxPluginRect {
|
|
518
|
+
x: number;
|
|
519
|
+
y: number;
|
|
520
|
+
width: number;
|
|
521
|
+
height: number;
|
|
522
|
+
}
|
|
523
|
+
/** A presented slide frame and the presentation version its pixels show. */
|
|
524
|
+
interface PptxPluginLayout {
|
|
525
|
+
/** Changes with every presented frame, slide or zoom; unrelated to document versions. */
|
|
526
|
+
id: string;
|
|
527
|
+
version: string;
|
|
528
|
+
slideId: string;
|
|
529
|
+
/** One-based display number. */
|
|
530
|
+
slide: number;
|
|
531
|
+
/** The resolved scale, including fit. */
|
|
532
|
+
zoom: number;
|
|
533
|
+
/** Unzoomed slide display-list width, in slide pixels. */
|
|
534
|
+
width: number;
|
|
535
|
+
/** Unzoomed slide display-list height, in slide pixels. */
|
|
536
|
+
height: number;
|
|
537
|
+
}
|
|
538
|
+
/** The current slide and what is selected on it; ids are session-scoped. */
|
|
539
|
+
type PptxPluginSelection = {
|
|
540
|
+
slideId: string;
|
|
541
|
+
/** One-based display number. */
|
|
542
|
+
slide: number;
|
|
543
|
+
target: {
|
|
544
|
+
kind: 'slide';
|
|
545
|
+
} | {
|
|
546
|
+
kind: 'shape';
|
|
547
|
+
shapeId: string;
|
|
548
|
+
} | {
|
|
549
|
+
kind: 'text';
|
|
550
|
+
shapeId: string;
|
|
551
|
+
storyId: string;
|
|
552
|
+
/** UTF-16 story offsets; `focus` may precede `anchor`. */
|
|
553
|
+
anchor: number;
|
|
554
|
+
focus: number;
|
|
555
|
+
};
|
|
556
|
+
} | null;
|
|
557
|
+
interface PptxPluginSnapshot {
|
|
558
|
+
/** The open presentation; changes when a presentation replaces it. */
|
|
559
|
+
generation: string;
|
|
560
|
+
version: string;
|
|
561
|
+
readOnly: boolean;
|
|
562
|
+
grant: PptxPluginGrant;
|
|
563
|
+
selection: PptxPluginSelection;
|
|
564
|
+
/** Null while no presented frame shows `version`. */
|
|
565
|
+
layout: PptxPluginLayout | null;
|
|
566
|
+
}
|
|
567
|
+
/** A hit under the pointer, with the layout it was resolved against. */
|
|
568
|
+
type PptxPluginPointPosition = PptxPointPosition & {
|
|
569
|
+
version: string;
|
|
570
|
+
layoutId: string;
|
|
571
|
+
};
|
|
572
|
+
/**
|
|
573
|
+
* Geometry of the presented slide. Rectangles it returns are in pixels of the unscaled overlay
|
|
574
|
+
* layer; every method returns null once its layout is no longer presented.
|
|
575
|
+
*/
|
|
576
|
+
interface PptxPluginGeometry {
|
|
577
|
+
layout: PptxPluginLayout;
|
|
578
|
+
/**
|
|
579
|
+
* Converts a slide rectangle into overlay pixels: `slide-emu` in EMU from the slide's top left
|
|
580
|
+
* corner, `slide-px` in unzoomed display-list pixels.
|
|
581
|
+
*/
|
|
582
|
+
toOverlayRect(input: {
|
|
583
|
+
space: 'slide-emu' | 'slide-px';
|
|
584
|
+
rect: PptxPluginRect;
|
|
585
|
+
}): PptxPluginRect | null;
|
|
586
|
+
/** The rendered bounds of a shape on the presented slide, group descendants included. */
|
|
587
|
+
getShapeRect(shapeId: string): PptxPluginRect | null;
|
|
588
|
+
/** Client coordinates; null outside slide content or during proposal review. */
|
|
589
|
+
getPositionAtPoint(clientX: number, clientY: number): PptxPluginPointPosition | null;
|
|
590
|
+
}
|
|
591
|
+
type PptxPluginNavigationFailureCode = 'stale-version' | 'missing-target' | 'ambiguous-target' | 'layout-unavailable' | 'unsupported';
|
|
592
|
+
/** @experimental The plugin API may change in minor releases. */
|
|
593
|
+
type PptxPluginNavigationResult = {
|
|
594
|
+
ok: true;
|
|
595
|
+
} | PptxPluginRefusal | {
|
|
596
|
+
ok: false;
|
|
597
|
+
failure: {
|
|
598
|
+
code: PptxPluginNavigationFailureCode;
|
|
599
|
+
message: string;
|
|
600
|
+
};
|
|
601
|
+
};
|
|
602
|
+
interface PptxPluginNavigationOptions {
|
|
603
|
+
/** The version the target was read at; a newer presentation refuses with `stale-version`. */
|
|
604
|
+
expectVersion: string;
|
|
605
|
+
/** Moves keyboard focus to the slide; focus stays where it is by default. */
|
|
606
|
+
focus?: boolean;
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Navigation after pending input, against the current presentation.
|
|
610
|
+
*
|
|
611
|
+
* @experimental The plugin API may change in minor releases.
|
|
612
|
+
*/
|
|
613
|
+
interface PptxPluginNavigation {
|
|
614
|
+
goToSlide(target: {
|
|
615
|
+
slideId: string;
|
|
616
|
+
}, options: PptxPluginNavigationOptions): Promise<PptxPluginNavigationResult>;
|
|
617
|
+
selectShape(target: {
|
|
618
|
+
slideId: string;
|
|
619
|
+
shapeId: string;
|
|
620
|
+
}, options: PptxPluginNavigationOptions): Promise<PptxPluginNavigationResult>;
|
|
621
|
+
/** Selects `anchor` to `focus` in UTF-16 story offsets, keeping their direction. */
|
|
622
|
+
selectText(target: {
|
|
623
|
+
slideId: string;
|
|
624
|
+
shapeId: string;
|
|
625
|
+
storyId: string;
|
|
626
|
+
anchor: number;
|
|
627
|
+
focus: number;
|
|
628
|
+
}, options: PptxPluginNavigationOptions): Promise<PptxPluginNavigationResult>;
|
|
629
|
+
}
|
|
630
|
+
/** Lifecycle notifications describe current state; several changes may arrive as one. */
|
|
631
|
+
type PptxPluginEvent = {
|
|
632
|
+
type: 'load';
|
|
633
|
+
generation: string;
|
|
634
|
+
version: string;
|
|
635
|
+
reason: PluginLoadReason;
|
|
636
|
+
} | {
|
|
637
|
+
type: 'document-change';
|
|
638
|
+
generation: string;
|
|
639
|
+
version: string;
|
|
640
|
+
} | {
|
|
641
|
+
type: 'selection-change';
|
|
642
|
+
generation: string;
|
|
643
|
+
version: string;
|
|
644
|
+
selection: PptxPluginSelection;
|
|
645
|
+
} | {
|
|
646
|
+
type: 'mode-change';
|
|
647
|
+
generation: string;
|
|
648
|
+
readOnly: boolean;
|
|
649
|
+
} | {
|
|
650
|
+
type: 'layout-change';
|
|
651
|
+
generation: string;
|
|
652
|
+
layout: PptxPluginLayout | null;
|
|
653
|
+
} | {
|
|
654
|
+
type: 'grants-change';
|
|
655
|
+
generation: string;
|
|
656
|
+
grant: PptxPluginGrant;
|
|
657
|
+
};
|
|
658
|
+
/**
|
|
659
|
+
* What a hook, renderer or action receives. Clients refuse once it is superseded or ended.
|
|
660
|
+
*
|
|
661
|
+
* @experimental The plugin API may change in minor releases.
|
|
662
|
+
*/
|
|
663
|
+
interface PptxPluginContext<S> {
|
|
664
|
+
pluginId: string;
|
|
665
|
+
snapshot: PptxPluginSnapshot;
|
|
666
|
+
readonly state: Readonly<S>;
|
|
667
|
+
/** Aborted when this hook is superseded or the plugin ends. */
|
|
668
|
+
signal: AbortSignal;
|
|
669
|
+
/** Aborted when this activation ends. */
|
|
670
|
+
lifetimeSignal: AbortSignal;
|
|
671
|
+
read: PptxPluginReadClient;
|
|
672
|
+
commands: PptxPluginCommandClient;
|
|
673
|
+
/** Null without an edit batch grant. */
|
|
674
|
+
edits: PptxPluginEditClient | null;
|
|
675
|
+
/** Null while no presented frame shows the current version. */
|
|
676
|
+
geometry: PptxPluginGeometry | null;
|
|
677
|
+
navigation: PptxPluginNavigation;
|
|
678
|
+
/**
|
|
679
|
+
* Replaces the plugin's state. Returns false for a superseded context, an ended plugin, or when
|
|
680
|
+
* the presentation is no longer at `atVersion`, which defaults to `snapshot.version`.
|
|
681
|
+
*/
|
|
682
|
+
setState(next: S | ((previous: S) => S), atVersion?: string): boolean;
|
|
683
|
+
/** Registers a disposer; after the plugin ended it runs at once. */
|
|
684
|
+
onCleanup(cleanup: (reason: PluginCleanupReason) => MaybePromise<void>): void;
|
|
685
|
+
/** Runs an event-handler action with a fresh context, isolating its failure. */
|
|
686
|
+
run(action: (context: PptxPluginContext<S>) => MaybePromise<void>): Promise<void>;
|
|
687
|
+
}
|
|
688
|
+
interface PptxPluginPanel<S> {
|
|
689
|
+
title: string;
|
|
690
|
+
placement: 'left' | 'right' | 'bottom';
|
|
691
|
+
/** Width for side panels, height for the bottom panel, in CSS pixels. */
|
|
692
|
+
preferredSize?: number;
|
|
693
|
+
defaultCollapsed?: boolean;
|
|
694
|
+
render: ComponentType<{
|
|
695
|
+
context: PptxPluginContext<S>;
|
|
696
|
+
width: number;
|
|
697
|
+
height: number;
|
|
698
|
+
}>;
|
|
699
|
+
}
|
|
700
|
+
/** A command registered as `plugin:<pluginId>/<id>`. */
|
|
701
|
+
interface PptxPluginCommand<S> {
|
|
702
|
+
id: string;
|
|
703
|
+
label: string;
|
|
704
|
+
/** Disables the command while read-only; grants nothing. */
|
|
705
|
+
mutatesDocument: boolean;
|
|
706
|
+
/** Chords such as `Mod+Shift+R`; built-in shortcuts take precedence. */
|
|
707
|
+
shortcuts?: readonly string[];
|
|
708
|
+
getState?(context: PptxPluginContext<S>): CommandState;
|
|
709
|
+
execute(context: PptxPluginContext<S>): MaybePromise<PptxPluginCommandResult>;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* A plugin. `createState`, renderers and command `getState` must be pure; `initialize`,
|
|
713
|
+
* `onEvent`, command `execute` and `context.run` are managed effects.
|
|
714
|
+
*
|
|
715
|
+
* @experimental The plugin API may change in minor releases.
|
|
716
|
+
*/
|
|
717
|
+
interface PptxPluginDefinition<S> {
|
|
718
|
+
id: string;
|
|
719
|
+
/** Changing it restarts the plugin; other definition changes keep its state. */
|
|
720
|
+
revision?: string | number;
|
|
721
|
+
createState(): S;
|
|
722
|
+
initialize?(context: PptxPluginContext<S>): MaybePromise<void>;
|
|
723
|
+
onEvent?(context: PptxPluginContext<S>, event: PptxPluginEvent): MaybePromise<void>;
|
|
724
|
+
panel?: PptxPluginPanel<S>;
|
|
725
|
+
overlay?: ComponentType<{
|
|
726
|
+
context: PptxPluginContext<S>;
|
|
727
|
+
geometry: PptxPluginGeometry;
|
|
728
|
+
}>;
|
|
729
|
+
commands?: readonly PptxPluginCommand<S>[];
|
|
730
|
+
/** Local command ids, in display order. */
|
|
731
|
+
toolbar?: readonly string[];
|
|
732
|
+
}
|
|
733
|
+
declare const pptxPluginBrand: unique symbol;
|
|
734
|
+
/**
|
|
735
|
+
* An installable plugin, created by `definePptxPlugin`.
|
|
736
|
+
*
|
|
737
|
+
* @experimental The plugin API may change in minor releases.
|
|
738
|
+
*/
|
|
739
|
+
interface PptxPlugin {
|
|
740
|
+
readonly id: string;
|
|
741
|
+
readonly revision?: string | number;
|
|
742
|
+
readonly [pptxPluginBrand]: true;
|
|
743
|
+
}
|
|
744
|
+
type PptxPluginErrorPhase = PluginErrorPhase;
|
|
745
|
+
/**
|
|
746
|
+
* A plugin failure; the failing activation has already been stopped and cleaned up.
|
|
747
|
+
*
|
|
748
|
+
* @experimental The plugin API may change in minor releases.
|
|
749
|
+
*/
|
|
750
|
+
type PptxPluginError = PluginError<PptxPluginErrorPhase>;
|
|
751
|
+
/** @experimental The plugin API may change in minor releases. */
|
|
752
|
+
interface PptxEditorPluginProps {
|
|
753
|
+
/** @experimental The plugin API may change in minor releases. */
|
|
754
|
+
plugins?: readonly PptxPlugin[];
|
|
755
|
+
/**
|
|
756
|
+
* Keyed by plugin id; omitted plugins read, validate and navigate only.
|
|
757
|
+
*
|
|
758
|
+
* @experimental The plugin API may change in minor releases.
|
|
759
|
+
*/
|
|
760
|
+
pluginGrants?: Readonly<Record<string, PptxPluginGrant>>;
|
|
761
|
+
/** @experimental The plugin API may change in minor releases. */
|
|
762
|
+
onPluginError?(error: PptxPluginError): void;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
declare const LEGACY_SYNC_API: "legacySyncApi";
|
|
766
|
+
|
|
767
|
+
/** @experimental */
|
|
768
|
+
interface PptxWorkerEditorApi extends Omit<PptxEditorApi, 'handle' | 'save'> {
|
|
769
|
+
readonly handle: null;
|
|
770
|
+
save(): null;
|
|
771
|
+
saveAsync(): Promise<Uint8Array>;
|
|
772
|
+
goToSlideAsync(slide: number): Promise<boolean>;
|
|
773
|
+
readonly hydrated: boolean;
|
|
774
|
+
readonly failure: PptxWorkerEditorFailedError | undefined;
|
|
775
|
+
whenHydrated(): Promise<void>;
|
|
776
|
+
handleAsync(): Promise<PptxWorkerEditorAccess>;
|
|
777
|
+
recoverySave(): Promise<PptxWorkerEditorRecovery>;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
type PptxWorkerEditorProps = Omit<PptxInThreadEditorProps, 'onReady' | 'readOnly' | 'experimentalWorkerOpen' | 'collaboration'> & {
|
|
781
|
+
/** @deprecated Removed in 0.6.0. Omit for the async editor. */
|
|
782
|
+
[LEGACY_SYNC_API]: true;
|
|
783
|
+
collaboration?: undefined;
|
|
784
|
+
/** Edits in the worker; without it the legacy runtime runs in-thread. */
|
|
785
|
+
experimentalWorkerOpen: true;
|
|
786
|
+
readOnly?: false;
|
|
787
|
+
/** Without `Worker`, falls back to the in-thread engine and passes `PptxEditorApi`. */
|
|
788
|
+
onReady?: (api: PptxWorkerEditorApi) => void;
|
|
789
|
+
};
|
|
790
|
+
|
|
791
|
+
type AsyncOperations = Pick<PptxWorkerEditorApi, 'getPositionAtPoint' | 'clearSelection' | 'selectText' | 'goToSlide' | 'refresh' | 'refreshProposals'>;
|
|
792
|
+
type PptxAsyncEditorAccess = {
|
|
793
|
+
[K in PresentationCommandAccessMethod]: (...args: Parameters<PresentationCommandAccessMethods[K]>) => Promise<ReturnType<PresentationCommandAccessMethods[K]>>;
|
|
794
|
+
} & {
|
|
795
|
+
[K in keyof PresentationCommandMutationMethods]: (...args: Parameters<PresentationCommandMutationMethods[K]>) => Promise<ReturnType<PresentationCommandMutationMethods[K]>>;
|
|
796
|
+
} & Pick<PptxWorkerEditorApi, 'version' | 'readContent' | 'findText' | 'validateEdits' | 'applyEdits'> & {
|
|
797
|
+
registerFont(face: PptxFontFace): Promise<number>;
|
|
798
|
+
registerFallbackFont(face: PptxFontFace): Promise<number>;
|
|
799
|
+
};
|
|
800
|
+
type PptxAsyncEditorApi = Omit<PptxWorkerEditorApi, 'handle' | 'save' | 'saveAsync' | 'handleAsync' | 'recoverySave' | keyof AsyncOperations> & {
|
|
801
|
+
[K in keyof AsyncOperations]: (...args: Parameters<AsyncOperations[K]>) => Promise<ReturnType<AsyncOperations[K]>>;
|
|
802
|
+
} & Pick<PptxAsyncEditorAccess, 'exportStructured' | 'exportMarkdown'> & {
|
|
803
|
+
handleAsync(): Promise<PptxAsyncEditorAccess>;
|
|
804
|
+
/** Flushes pending input, then serializes the presentation to .pptx bytes. Does not call onSave or download. */
|
|
805
|
+
save(): Promise<Uint8Array>;
|
|
806
|
+
/** @deprecated Use {@link save}, which is async on the default editor. */
|
|
807
|
+
saveAsync(): Promise<Uint8Array>;
|
|
808
|
+
recoverySave(): Promise<{
|
|
809
|
+
bytes: Uint8Array;
|
|
810
|
+
recovery: true;
|
|
811
|
+
throughSeq: number;
|
|
812
|
+
version: string;
|
|
813
|
+
}>;
|
|
814
|
+
};
|
|
815
|
+
|
|
816
|
+
declare class PptxWorkerEditorChunkLoadError extends Error {
|
|
817
|
+
readonly cause: unknown;
|
|
818
|
+
readonly code = "chunk-load-failed";
|
|
819
|
+
constructor(cause: unknown);
|
|
820
|
+
}
|
|
821
|
+
interface PptxTextSelection {
|
|
822
|
+
shapeId: string;
|
|
823
|
+
storyId: string;
|
|
824
|
+
anchor: number;
|
|
825
|
+
focus: number;
|
|
826
|
+
focusLine?: number;
|
|
827
|
+
}
|
|
828
|
+
interface PptxTextSelectionTarget {
|
|
829
|
+
/** 1-based slide number. */
|
|
830
|
+
slide: number;
|
|
831
|
+
shapeId: string;
|
|
832
|
+
storyId: string;
|
|
833
|
+
start: number;
|
|
834
|
+
end: number;
|
|
835
|
+
}
|
|
836
|
+
type PptxPointPosition = HitTestResult & {
|
|
837
|
+
slide: number;
|
|
838
|
+
slideId: string;
|
|
839
|
+
};
|
|
840
|
+
interface PptxEditorApi {
|
|
841
|
+
/** Waits for accepted input; rejects during unfinished pointer gestures. */
|
|
842
|
+
flushPendingInput: () => Promise<void>;
|
|
843
|
+
/** Client coordinates; returns null outside slide content. */
|
|
844
|
+
getPositionAtPoint: (clientX: number, clientY: number) => PptxPointPosition | null;
|
|
845
|
+
clearSelection: () => void;
|
|
846
|
+
focus: () => void;
|
|
847
|
+
/** Accepts a 1-based slide number. */
|
|
848
|
+
goToSlide: (slide: number) => boolean;
|
|
849
|
+
handle: PresentationHandle;
|
|
850
|
+
/**
|
|
851
|
+
* The editor's commands, shared by built-in and host chrome; `api.handle` edits bypass them.
|
|
852
|
+
* @experimental
|
|
853
|
+
*/
|
|
854
|
+
readonly commands: PptxCommandStore;
|
|
855
|
+
refresh: () => void;
|
|
856
|
+
refreshProposals: () => void;
|
|
857
|
+
/** Serialize the presentation back to .pptx bytes, edits included. */
|
|
858
|
+
save: () => Uint8Array;
|
|
859
|
+
/** Also navigates to the slide. */
|
|
860
|
+
selectText: (target: PptxTextSelectionTarget) => boolean;
|
|
861
|
+
/** Flushes pending input, then returns the session version. */
|
|
862
|
+
version: () => Promise<string>;
|
|
863
|
+
/** Flushes pending input, then reads slides and story text with the version they were read at. */
|
|
864
|
+
readContent: (request?: PptxReadRequest) => Promise<PptxReadResult>;
|
|
865
|
+
/** Flushes pending input, then searches exactly and case-sensitively. */
|
|
866
|
+
findText: (request: PptxFindRequest) => Promise<PptxFindResult>;
|
|
867
|
+
/** Flushes pending input, then checks a batch without changing anything. */
|
|
868
|
+
validateEdits: (request: PptxEditRequest) => Promise<PptxValidationResult>;
|
|
869
|
+
/**
|
|
870
|
+
* Flushes pending input, then applies every step or none against `expectVersion` and refreshes
|
|
871
|
+
* the editor once. A refusal is data and never rolls back the flushed input. Read-only editors
|
|
872
|
+
* refuse with `read-only`. Rejects when the presentation is replaced while input flushes.
|
|
873
|
+
*/
|
|
874
|
+
applyEdits: (request: PptxEditRequest) => Promise<PptxEditResult>;
|
|
875
|
+
}
|
|
876
|
+
/** @experimental */
|
|
877
|
+
interface PptxWorkerViewerApi extends Omit<PptxEditorApi, 'handle' | 'save' | 'getPositionAtPoint' | 'selectText' | 'version' | 'readContent' | 'findText' | 'validateEdits' | 'applyEdits'> {
|
|
878
|
+
handle: null;
|
|
879
|
+
save: () => null;
|
|
880
|
+
getPositionAtPoint: (clientX: number, clientY: number) => null;
|
|
881
|
+
selectText: (target: PptxTextSelectionTarget) => false;
|
|
882
|
+
saveAsync: () => Promise<Uint8Array | null>;
|
|
883
|
+
version: () => Promise<string | null>;
|
|
884
|
+
readContent: (request?: PptxReadRequest) => Promise<PptxReadResult | null>;
|
|
885
|
+
findText: (request: PptxFindRequest) => Promise<PptxFindResult | null>;
|
|
886
|
+
validateEdits: (request: PptxEditRequest) => Promise<PptxValidationResult | null>;
|
|
887
|
+
applyEdits: (request: PptxEditRequest) => Promise<PptxEditResult | null>;
|
|
888
|
+
/** Accepts a 1-based slide number; resolves after painting. */
|
|
889
|
+
goToSlideAsync: (slide: number) => Promise<boolean>;
|
|
890
|
+
}
|
|
891
|
+
interface PptxAsyncCollaborationOptions extends Omit<PptxEditorCollaborationOptions, 'clientId' | 'onReplica'> {
|
|
892
|
+
/** Generated for each opened session when omitted. */
|
|
893
|
+
clientId?: number;
|
|
894
|
+
/** Change to open a different collaboration room. */
|
|
895
|
+
roomId?: string;
|
|
896
|
+
onReplica?: (replica: _betteroffice_pptx.AsyncCollaborationReplica | null) => void;
|
|
897
|
+
}
|
|
898
|
+
interface PptxEditorCollaborationOptions {
|
|
899
|
+
clientId: number;
|
|
900
|
+
initialUpdate?: Uint8Array;
|
|
901
|
+
onReplica?: (replica: CollaborationReplica | null) => void;
|
|
902
|
+
presence?: PptxPresence;
|
|
903
|
+
}
|
|
904
|
+
interface PptxInThreadEditorProps extends PptxEditorPluginProps {
|
|
905
|
+
file?: Uint8Array;
|
|
906
|
+
/** Font faces; equivalent inline arrays do not reopen the presentation. */
|
|
907
|
+
fonts: ReadonlyArray<PptxFontFace>;
|
|
908
|
+
clientId?: number;
|
|
909
|
+
/** Uses the deprecated in-thread engine when set. */
|
|
910
|
+
collaboration?: PptxEditorCollaborationOptions;
|
|
911
|
+
/** @deprecated Omit this prop to use the default worker-owned editor. */
|
|
912
|
+
experimentalWorkerOpen?: false;
|
|
913
|
+
i18n?: Translations;
|
|
914
|
+
className?: string;
|
|
915
|
+
/** Download name for the save button; falls back to `presentation.pptx`. */
|
|
916
|
+
fileName?: string;
|
|
917
|
+
/** 1-based; clamped to the deck. */
|
|
918
|
+
initialSlide?: number;
|
|
919
|
+
onReady?: (api: PptxEditorApi) => void;
|
|
920
|
+
onChange?: (snapshot: DeckSnapshot) => void;
|
|
921
|
+
onError?: (error: Error) => void;
|
|
922
|
+
/** Receives the saved bytes; without it, saving downloads the file. */
|
|
923
|
+
onSave?: (bytes: Uint8Array) => void;
|
|
924
|
+
/** Return true for built-in saving; false or void handles/cancels the request. */
|
|
925
|
+
onSaveRequest?: () => boolean | void | Promise<boolean | void>;
|
|
926
|
+
/** Blocks user edits; navigation and selection remain available. */
|
|
927
|
+
readOnly?: boolean;
|
|
928
|
+
/**
|
|
929
|
+
* Replaces the toolbar: omit it for the default controls, pass `null` for
|
|
930
|
+
* none, or pass chrome composed from the toolbar parts, which also renders
|
|
931
|
+
* while `readOnly`. `showToolbar={false}` hides the whole region.
|
|
932
|
+
* @experimental
|
|
933
|
+
*/
|
|
934
|
+
toolbar?: ReactNode;
|
|
935
|
+
/** Shows the toolbar region; defaults to true. */
|
|
936
|
+
showToolbar?: boolean;
|
|
937
|
+
}
|
|
938
|
+
/** @deprecated Removed in 0.6.0. Use PptxAsyncEditorProps. */
|
|
939
|
+
type PptxWorkerViewerProps = Omit<PptxInThreadEditorProps, 'onReady' | 'readOnly' | 'experimentalWorkerOpen' | 'collaboration' | 'plugins' | 'onChange'> & {
|
|
940
|
+
/** @deprecated Removed in 0.6.0. Omit for the async editor. */
|
|
941
|
+
[LEGACY_SYNC_API]: true;
|
|
942
|
+
collaboration?: undefined;
|
|
943
|
+
plugins?: readonly [];
|
|
944
|
+
onChange?: undefined;
|
|
945
|
+
readOnly: true;
|
|
946
|
+
/** Opens in the worker; without it the legacy runtime runs in-thread. */
|
|
947
|
+
experimentalWorkerOpen: true;
|
|
948
|
+
/** Without `Worker`, falls back to the in-thread engine and passes `PptxEditorApi`. */
|
|
949
|
+
onReady?: (api: PptxWorkerViewerApi) => void;
|
|
950
|
+
};
|
|
951
|
+
interface PptxDocumentChange {
|
|
952
|
+
version: string;
|
|
953
|
+
}
|
|
954
|
+
interface PptxAsyncPresentationProps {
|
|
955
|
+
/** Receives the version after a committed edit changes the presentation. */
|
|
956
|
+
onDocumentChange?: (change: PptxDocumentChange) => void;
|
|
957
|
+
/** Whether Save also downloads a copy. Defaults to true without onSave, false with it. */
|
|
958
|
+
downloadOnSave?: boolean;
|
|
959
|
+
/** Initial zoom scale, clamped to 0.1 to 5; omit to fit the slide. */
|
|
960
|
+
initialZoom?: number;
|
|
961
|
+
/** Rendered while the presentation opens. */
|
|
962
|
+
loadingIndicator?: ReactNode;
|
|
963
|
+
/** Inline styles for the editor root. */
|
|
964
|
+
style?: CSSProperties;
|
|
965
|
+
}
|
|
966
|
+
type PptxAsyncEditorProps = Omit<PptxInThreadEditorProps, 'file' | 'onReady' | 'collaboration' | 'experimentalWorkerOpen'> & PptxAsyncPresentationProps & {
|
|
967
|
+
file?: Uint8Array | ArrayBuffer;
|
|
968
|
+
/** @deprecated Removed in 0.6.0. Omit for the async editor. */
|
|
969
|
+
[LEGACY_SYNC_API]?: false;
|
|
970
|
+
/** @deprecated False selects the in-thread engine. */
|
|
971
|
+
experimentalWorkerOpen?: boolean;
|
|
972
|
+
collaboration?: PptxAsyncCollaborationOptions;
|
|
973
|
+
onReady?: (api: PptxAsyncEditorApi) => void | (() => void);
|
|
974
|
+
};
|
|
975
|
+
/** @deprecated Removed in 0.6.0. Use PptxAsyncEditorProps. */
|
|
976
|
+
type PptxLegacyEditorProps = PptxInThreadEditorProps & {
|
|
977
|
+
/** @deprecated Removed in 0.6.0. Omit for the async editor. */
|
|
978
|
+
[LEGACY_SYNC_API]: true;
|
|
979
|
+
};
|
|
980
|
+
type WorkerSessionProps = Omit<PptxWorkerEditorProps, 'readOnly' | 'onReady' | 'experimentalWorkerOpen'> & {
|
|
981
|
+
experimentalWorkerOpen: true;
|
|
982
|
+
readOnly?: boolean;
|
|
983
|
+
onReady?: (api: PptxWorkerEditorApi | PptxWorkerViewerApi) => void;
|
|
984
|
+
};
|
|
985
|
+
type WorkerEditorSessionProps = Omit<PptxWorkerEditorProps, 'readOnly'> & {
|
|
986
|
+
readOnly?: boolean;
|
|
987
|
+
};
|
|
988
|
+
type CollaborationSessionProps = Omit<PptxLegacyEditorProps, 'experimentalWorkerOpen'> & {
|
|
989
|
+
collaboration: PptxEditorCollaborationOptions;
|
|
990
|
+
experimentalWorkerOpen?: boolean;
|
|
991
|
+
};
|
|
992
|
+
type GeneralEditorSessionProps = Omit<PptxLegacyEditorProps, 'experimentalWorkerOpen' | 'onReady'> & {
|
|
993
|
+
experimentalWorkerOpen?: boolean;
|
|
994
|
+
onReady?: (api: PptxEditorApi | PptxWorkerEditorApi | PptxWorkerViewerApi) => void;
|
|
995
|
+
};
|
|
996
|
+
type PptxEditorProps = PptxAsyncEditorProps | GeneralEditorSessionProps;
|
|
997
|
+
declare function PptxEditor(props: PptxAsyncEditorProps): JSX.Element;
|
|
998
|
+
declare function PptxEditor(props: PptxLegacyEditorProps): JSX.Element;
|
|
999
|
+
declare function PptxEditor(props: CollaborationSessionProps): JSX.Element;
|
|
1000
|
+
declare function PptxEditor(props: PptxWorkerEditorProps): JSX.Element;
|
|
1001
|
+
declare function PptxEditor(props: WorkerEditorSessionProps & {
|
|
1002
|
+
onChange: NonNullable<PptxInThreadEditorProps['onChange']>;
|
|
1003
|
+
}): JSX.Element;
|
|
1004
|
+
declare function PptxEditor(props: WorkerEditorSessionProps & {
|
|
1005
|
+
plugins: readonly [PptxPlugin, ...PptxPlugin[]];
|
|
1006
|
+
}): JSX.Element;
|
|
1007
|
+
declare function PptxEditor(props: PptxWorkerViewerProps): JSX.Element;
|
|
1008
|
+
declare function PptxEditor(props: WorkerSessionProps): JSX.Element;
|
|
1009
|
+
declare function PptxEditor(props: PptxEditorProps): JSX.Element;
|
|
1010
|
+
|
|
1011
|
+
/**
|
|
1012
|
+
* Props of the legacy toolbar, which shows the state it is given and reports
|
|
1013
|
+
* actions through callbacks. Prefer `mode="commands"`, which binds controls to
|
|
1014
|
+
* the editor's command store.
|
|
1015
|
+
*/
|
|
147
1016
|
interface ToolbarProps {
|
|
1017
|
+
/** `legacy` (the default outside a command-mode `EditorToolbar`) binds controls to these props. */
|
|
1018
|
+
mode?: 'legacy';
|
|
148
1019
|
currentFormatting?: SelectionFormatting;
|
|
149
1020
|
textSelectionActive?: boolean;
|
|
150
1021
|
onFormat?: (action: FormattingAction) => void;
|
|
151
1022
|
currentShapeFormatting?: ShapeFormatting;
|
|
152
1023
|
shapeSelectionActive?: boolean;
|
|
1024
|
+
/** Enables the arrange (z-order) menu for any selected object. */
|
|
1025
|
+
shapeArrangeActive?: boolean;
|
|
153
1026
|
onShapeFormat?: (action: ShapeFormattingAction) => void;
|
|
154
1027
|
onInsertSlide?: (layoutPartPath?: string | null) => void;
|
|
1028
|
+
onInsertImage?: () => void;
|
|
155
1029
|
slideLayouts?: readonly SlideLayoutOption[];
|
|
156
1030
|
currentLayoutPartPath?: string | null;
|
|
157
1031
|
onSave?: () => void;
|
|
@@ -169,33 +1043,75 @@ interface ToolbarProps {
|
|
|
169
1043
|
disabled?: boolean;
|
|
170
1044
|
className?: string;
|
|
171
1045
|
style?: CSSProperties;
|
|
1046
|
+
/** Host controls appended after the default ones. */
|
|
172
1047
|
children?: ReactNode;
|
|
173
1048
|
}
|
|
174
|
-
|
|
1049
|
+
type LegacyStateKey = Exclude<keyof ToolbarProps, 'mode' | 'className' | 'style' | 'children'>;
|
|
1050
|
+
/**
|
|
1051
|
+
* Props of a toolbar bound to the nearest editor's commands.
|
|
1052
|
+
* @experimental
|
|
1053
|
+
*/
|
|
1054
|
+
type CommandToolbarProps = {
|
|
1055
|
+
/** Binds every control to the command store of the nearest editor or `PptxCommandProvider`. */
|
|
1056
|
+
mode: 'commands';
|
|
1057
|
+
/** The complete arrangement; omit to render the default controls. */
|
|
1058
|
+
children?: ReactNode;
|
|
1059
|
+
className?: string;
|
|
1060
|
+
style?: CSSProperties;
|
|
1061
|
+
} & {
|
|
1062
|
+
[K in LegacyStateKey]?: never;
|
|
1063
|
+
};
|
|
1064
|
+
/**
|
|
1065
|
+
* The formatting rail, with overflow into an accessible "More" menu. In
|
|
1066
|
+
* command mode (explicit, or inherited from `EditorToolbar mode="commands"`)
|
|
1067
|
+
* children replace the default controls; in legacy mode they follow them.
|
|
1068
|
+
*/
|
|
1069
|
+
declare function Toolbar(props: ToolbarProps | CommandToolbarProps): react.JSX.Element;
|
|
175
1070
|
|
|
176
1071
|
type EditorToolbarProps = ToolbarProps;
|
|
177
1072
|
declare const EditorToolbarContext: react.Context<ToolbarProps | null>;
|
|
178
1073
|
declare function useEditorToolbar(): ToolbarProps;
|
|
179
1074
|
|
|
1075
|
+
/**
|
|
1076
|
+
* A toolbar region bound to the nearest editor's or `PptxCommandProvider`'s commands.
|
|
1077
|
+
* @experimental
|
|
1078
|
+
*/
|
|
1079
|
+
type EditorToolbarCommandProps = Omit<CommandToolbarProps, 'children'> & {
|
|
1080
|
+
/** Compound parts; defaults to the formatting rail with the built-in controls. */
|
|
1081
|
+
children?: ReactNode;
|
|
1082
|
+
/** Locale when rendered outside the editor; defaults to the editor's. */
|
|
1083
|
+
i18n?: Translations;
|
|
1084
|
+
};
|
|
180
1085
|
interface EditorToolbarComponent {
|
|
181
|
-
(props: EditorToolbarProps & {
|
|
1086
|
+
(props: (EditorToolbarProps & {
|
|
182
1087
|
children: ReactNode;
|
|
183
|
-
|
|
1088
|
+
style?: CSSProperties;
|
|
1089
|
+
}) | EditorToolbarCommandProps): React.JSX.Element;
|
|
184
1090
|
Toolbar: typeof Toolbar;
|
|
185
1091
|
}
|
|
186
1092
|
declare const EditorToolbar: EditorToolbarComponent;
|
|
187
1093
|
|
|
188
1094
|
interface ToolbarButtonProps {
|
|
189
|
-
|
|
1095
|
+
/** Pressed state; omit for buttons that are not toggles. */
|
|
1096
|
+
active?: boolean | 'mixed';
|
|
190
1097
|
disabled?: boolean;
|
|
1098
|
+
/** Why the button is disabled; announced and shown on hover. */
|
|
1099
|
+
description?: string;
|
|
1100
|
+
/** Accessible name and tooltip. */
|
|
191
1101
|
title: string;
|
|
1102
|
+
/** Keyboard shortcut shown in the tooltip and overflow menu, such as `Ctrl+B`. */
|
|
1103
|
+
shortcut?: string;
|
|
192
1104
|
onClick?: () => void;
|
|
193
1105
|
children: ReactNode;
|
|
1106
|
+
className?: string;
|
|
194
1107
|
style?: CSSProperties;
|
|
195
1108
|
testId?: string;
|
|
196
1109
|
ariaExpanded?: boolean;
|
|
1110
|
+
/** Label of the overflow-menu entry; defaults to `title`. */
|
|
1111
|
+
overflowLabel?: string;
|
|
197
1112
|
}
|
|
198
|
-
|
|
1113
|
+
/** A toolbar button; at narrow widths it moves into the overflow menu. */
|
|
1114
|
+
declare function ToolbarButton(props: ToolbarButtonProps): react.JSX.Element;
|
|
199
1115
|
declare function ToolbarGroup({ label, children, style, }: {
|
|
200
1116
|
label: string;
|
|
201
1117
|
children: ReactNode;
|
|
@@ -207,21 +1123,33 @@ interface ToolbarDropdownProps {
|
|
|
207
1123
|
trigger: ReactNode;
|
|
208
1124
|
children: (close: () => void) => ReactNode;
|
|
209
1125
|
disabled?: boolean;
|
|
1126
|
+
/** Why the dropdown is disabled; announced and shown on hover. */
|
|
1127
|
+
description?: string;
|
|
210
1128
|
active?: boolean;
|
|
211
1129
|
menuWidth?: number;
|
|
212
1130
|
style?: CSSProperties;
|
|
213
1131
|
testId?: string;
|
|
1132
|
+
/**
|
|
1133
|
+
* `menu` for content made of `ToolbarMenuItem`s, `dialog` for other controls.
|
|
1134
|
+
* Omitted, it follows the content.
|
|
1135
|
+
*/
|
|
1136
|
+
popup?: 'menu' | 'dialog';
|
|
214
1137
|
}
|
|
215
|
-
|
|
1138
|
+
/** A button with a popup; hidden at narrow widths, it opens from the overflow menu. */
|
|
1139
|
+
declare function ToolbarDropdown(props: ToolbarDropdownProps): react.JSX.Element;
|
|
216
1140
|
interface ToolbarMenuItemProps {
|
|
217
1141
|
label: string;
|
|
218
1142
|
icon?: ReactNode;
|
|
219
1143
|
selected?: boolean;
|
|
1144
|
+
/** Presents the item as one choice of several, checked when `selected`. */
|
|
1145
|
+
radio?: boolean;
|
|
220
1146
|
disabled?: boolean;
|
|
1147
|
+
/** Why the item is disabled. */
|
|
1148
|
+
description?: string;
|
|
221
1149
|
onClick?: () => void;
|
|
222
1150
|
close?: () => void;
|
|
223
1151
|
}
|
|
224
|
-
declare function ToolbarMenuItem({ label, icon, selected, disabled, onClick, close, }: ToolbarMenuItemProps): react.JSX.Element;
|
|
1152
|
+
declare function ToolbarMenuItem({ label, icon, selected, radio, disabled, description, onClick, close, }: ToolbarMenuItemProps): react.JSX.Element;
|
|
225
1153
|
declare function ToolbarMenuSeparator(): react.JSX.Element;
|
|
226
1154
|
|
|
227
1155
|
interface LocaleProviderProps {
|
|
@@ -233,4 +1161,167 @@ declare function useTranslation(): {
|
|
|
233
1161
|
t: TFunction;
|
|
234
1162
|
};
|
|
235
1163
|
|
|
236
|
-
|
|
1164
|
+
/** @experimental */
|
|
1165
|
+
interface PptxCommandProviderProps {
|
|
1166
|
+
/** An editor's `api.commands`; `null` until the editor is ready. */
|
|
1167
|
+
commands: PptxCommandStore | null;
|
|
1168
|
+
children?: ReactNode;
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Provides one editor's commands to toolbar parts rendered anywhere in the tree.
|
|
1172
|
+
* @experimental
|
|
1173
|
+
*/
|
|
1174
|
+
declare function PptxCommandProvider({ commands, children }: PptxCommandProviderProps): react.JSX.Element;
|
|
1175
|
+
|
|
1176
|
+
type PptxCommandAdmissionCode = Extract<PptxCommandFailureCode, 'input-failed' | 'document-replaced' | 'target-changed' | 'gesture-active' | 'editor-unavailable' | 'read-only' | 'invalid-arguments'>;
|
|
1177
|
+
/** Raised when an admitted command cannot run against its originating input or target. */
|
|
1178
|
+
declare class PptxCommandAdmissionError extends Error {
|
|
1179
|
+
readonly code: PptxCommandAdmissionCode;
|
|
1180
|
+
constructor(code: PptxCommandAdmissionCode);
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* The nearest editor's command store.
|
|
1185
|
+
* @experimental
|
|
1186
|
+
*/
|
|
1187
|
+
declare function usePptxCommands(): PptxCommandStore;
|
|
1188
|
+
/**
|
|
1189
|
+
* Subscribes to one command's state, optionally for specific arguments.
|
|
1190
|
+
* @experimental
|
|
1191
|
+
*/
|
|
1192
|
+
declare function usePptxCommandState<K extends PptxCommandId>(id: K, args?: PptxCommandArgs[K]): PptxCommandState<K>;
|
|
1193
|
+
/** Subscribes to a contributed command's state. */
|
|
1194
|
+
declare function usePptxCommandState(id: PptxPluginCommandId, args?: null): PptxPluginCommandState;
|
|
1195
|
+
/**
|
|
1196
|
+
* A command bound to this component, with its localized label and shortcut.
|
|
1197
|
+
* @experimental
|
|
1198
|
+
*/
|
|
1199
|
+
interface PptxBoundCommand<K extends PptxCommandId> {
|
|
1200
|
+
id: K;
|
|
1201
|
+
descriptor: PptxCommandDescriptor<K>;
|
|
1202
|
+
state: PptxCommandState<K>;
|
|
1203
|
+
label: string;
|
|
1204
|
+
/** The keyboard shortcut as people read it on this platform, such as `Ctrl+B`. */
|
|
1205
|
+
shortcut: string | null;
|
|
1206
|
+
/** Executes with `args`, falling back to the arguments bound to the hook. */
|
|
1207
|
+
execute(args?: PptxCommandArgs[K]): Promise<PptxCommandResult>;
|
|
1208
|
+
}
|
|
1209
|
+
/**
|
|
1210
|
+
* A contributed command bound to this component.
|
|
1211
|
+
* @experimental
|
|
1212
|
+
*/
|
|
1213
|
+
interface PptxBoundPluginCommand {
|
|
1214
|
+
id: PptxPluginCommandId;
|
|
1215
|
+
/** Null while no active plugin contributes the command. */
|
|
1216
|
+
descriptor: PptxPluginCommandDescriptor | null;
|
|
1217
|
+
state: PptxPluginCommandState;
|
|
1218
|
+
/** The contributed label, or the id while no plugin contributes it. */
|
|
1219
|
+
label: string;
|
|
1220
|
+
shortcut: string | null;
|
|
1221
|
+
execute(): Promise<PptxPluginCommandResult>;
|
|
1222
|
+
}
|
|
1223
|
+
/**
|
|
1224
|
+
* Binds one command for a custom control.
|
|
1225
|
+
* @experimental
|
|
1226
|
+
*/
|
|
1227
|
+
declare function usePptxCommand<K extends PptxCommandId>(id: K, args?: PptxCommandArgs[K]): PptxBoundCommand<K>;
|
|
1228
|
+
/** Binds a contributed command for a custom control. */
|
|
1229
|
+
declare function usePptxCommand(id: PptxPluginCommandId, args?: null): PptxBoundPluginCommand;
|
|
1230
|
+
|
|
1231
|
+
/**
|
|
1232
|
+
* Arguments a control binds; required when the command cannot run without them.
|
|
1233
|
+
* @experimental
|
|
1234
|
+
*/
|
|
1235
|
+
type ToolbarCommandArgs<K extends PptxCommandId | PptxPluginCommandId> = K extends PptxCommandId ? null extends PptxCommandArgs[K] ? {
|
|
1236
|
+
args?: PptxCommandArgs[K];
|
|
1237
|
+
} : {} extends PptxCommandArgs[K] ? {
|
|
1238
|
+
args?: PptxCommandArgs[K];
|
|
1239
|
+
} : {
|
|
1240
|
+
args: PptxCommandArgs[K];
|
|
1241
|
+
} : {
|
|
1242
|
+
args?: null;
|
|
1243
|
+
};
|
|
1244
|
+
/**
|
|
1245
|
+
* A built-in or contributed command; a contributed one renders nothing while inactive.
|
|
1246
|
+
* @experimental
|
|
1247
|
+
*/
|
|
1248
|
+
type ToolbarCommandButtonProps<K extends PptxCommandId | PptxPluginCommandId> = {
|
|
1249
|
+
id: K;
|
|
1250
|
+
/** Button content; defaults to the command's icon, or its label when it has none. */
|
|
1251
|
+
children?: ReactNode;
|
|
1252
|
+
/** Accessible name; defaults to the localized or contributed command label. */
|
|
1253
|
+
label?: string;
|
|
1254
|
+
className?: string;
|
|
1255
|
+
style?: CSSProperties;
|
|
1256
|
+
} & ToolbarCommandArgs<K>;
|
|
1257
|
+
/** @experimental */
|
|
1258
|
+
interface ToolbarCommandSelectProps<K extends PptxSelectCommandId> {
|
|
1259
|
+
id: K;
|
|
1260
|
+
className?: string;
|
|
1261
|
+
}
|
|
1262
|
+
/**
|
|
1263
|
+
* Commands whose full built-in control chooses their arguments.
|
|
1264
|
+
* @experimental
|
|
1265
|
+
*/
|
|
1266
|
+
type PptxControlCommandId = PptxSelectCommandId | 'textColor' | 'shapeFill' | 'shapeStrokeColor' | 'zOrder' | 'fontSizeStep';
|
|
1267
|
+
/** @experimental */
|
|
1268
|
+
type ToolbarCommandProps<K extends PptxCommandId | PptxPluginCommandId> = {
|
|
1269
|
+
id: K;
|
|
1270
|
+
className?: string;
|
|
1271
|
+
} & (K extends PptxControlCommandId ? {
|
|
1272
|
+
/** Binds arguments; omit to render the command's full built-in control. */
|
|
1273
|
+
args?: PptxCommandArgs[K];
|
|
1274
|
+
} : ToolbarCommandArgs<K>);
|
|
1275
|
+
/**
|
|
1276
|
+
* A button bound to one command, showing its pressed and disabled state.
|
|
1277
|
+
* @experimental
|
|
1278
|
+
*/
|
|
1279
|
+
declare function ToolbarCommandButton<K extends PptxCommandId | PptxPluginCommandId>(props: ToolbarCommandButtonProps<K>): react.JSX.Element | null;
|
|
1280
|
+
/**
|
|
1281
|
+
* The built-in picker of a selector command.
|
|
1282
|
+
* @experimental
|
|
1283
|
+
*/
|
|
1284
|
+
declare function ToolbarCommandSelect<K extends PptxSelectCommandId>({ id, className, }: ToolbarCommandSelectProps<K>): react.JSX.Element;
|
|
1285
|
+
/**
|
|
1286
|
+
* The built-in control of any command, as the default toolbar presents it.
|
|
1287
|
+
* @experimental
|
|
1288
|
+
*/
|
|
1289
|
+
declare function ToolbarCommand<K extends PptxCommandId | PptxPluginCommandId>(props: ToolbarCommandProps<K>): react.JSX.Element;
|
|
1290
|
+
|
|
1291
|
+
/** @experimental */
|
|
1292
|
+
interface ToolbarOverflowProps {
|
|
1293
|
+
/** Label of the menu entry that replaces the content at narrow widths. */
|
|
1294
|
+
label: string;
|
|
1295
|
+
onSelect(): void;
|
|
1296
|
+
disabled?: boolean;
|
|
1297
|
+
/** Why the action is disabled. */
|
|
1298
|
+
description?: string;
|
|
1299
|
+
/** Toggle state for a checkbox entry. */
|
|
1300
|
+
checked?: boolean;
|
|
1301
|
+
children: ReactNode;
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Gives arbitrary host content a menu entry, so it can move into the overflow
|
|
1305
|
+
* menu instead of scrolling with the row in a narrow toolbar.
|
|
1306
|
+
* @experimental
|
|
1307
|
+
*/
|
|
1308
|
+
declare function ToolbarOverflow({ label, onSelect, disabled, description, checked, children, }: ToolbarOverflowProps): react.JSX.Element;
|
|
1309
|
+
|
|
1310
|
+
/**
|
|
1311
|
+
* Wraps a plugin for `PptxEditor`'s `plugins` prop. The definition is checked when the editor
|
|
1312
|
+
* installs it; a problem is reported through `onPluginError` and disables only this plugin. Its
|
|
1313
|
+
* panel, commands and toolbar are copied and frozen, so changing them takes a new definition.
|
|
1314
|
+
*
|
|
1315
|
+
* @experimental The plugin API may change in minor releases.
|
|
1316
|
+
*/
|
|
1317
|
+
declare function definePptxPlugin<S>(definition: PptxPluginDefinition<S>): PptxPlugin;
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* The toolbar commands installed plugins contribute, in plugin and declaration order. The
|
|
1321
|
+
* default toolbar includes it; place it in replacement chrome to keep those commands reachable.
|
|
1322
|
+
*
|
|
1323
|
+
* @experimental The plugin API may change in minor releases.
|
|
1324
|
+
*/
|
|
1325
|
+
declare function PptxPluginToolbar(): React.ReactElement | null;
|
|
1326
|
+
|
|
1327
|
+
export { type CommandReason, type CommandState, type CommandToolbarProps, EditorToolbar, type EditorToolbarCommandProps, EditorToolbarContext, type EditorToolbarProps, type FormattingAction, type JsonValue, LocaleProvider, type LocaleProviderProps, type MaybePromise, type PluginCleanupReason, type PluginGrant, type PluginLoadReason, type PptxAsyncCollaborationOptions, type PptxAsyncEditorAccess, type PptxAsyncEditorApi, type PptxAsyncEditorProps, type PptxBoundCommand, type PptxBoundPluginCommand, type PptxCommandAdmissionCode, PptxCommandAdmissionError, type PptxCommandArgs, type PptxCommandDescriptor, type PptxCommandDisabledCode, type PptxCommandFailureCode, type PptxCommandId, type PptxCommandOption, PptxCommandProvider, type PptxCommandProviderProps, type PptxCommandResult, type PptxCommandShortcut, type PptxCommandState, type PptxCommandStatus, type PptxCommandStore, type PptxCommandValues, type PptxControlCommandId, type PptxDocumentChange, PptxEditor, type PptxEditorApi, type PptxEditorCollaborationOptions, type PptxEditorPluginProps, type PptxEditorProps, type PptxEditorTool, type PptxLegacyEditorProps, type PptxPlugin, type PptxPluginCommand, type PptxPluginCommandClient, type PptxPluginCommandDescriptor, type PptxPluginCommandId, type PptxPluginCommandResult, type PptxPluginCommandState, type PptxPluginContext, type PptxPluginDefinition, type PptxPluginEditClient, type PptxPluginError, type PptxPluginErrorPhase, type PptxPluginEvent, type PptxPluginFailureCode, type PptxPluginGeometry, type PptxPluginGrant, type PptxPluginLayout, type PptxPluginNavigation, type PptxPluginNavigationFailureCode, type PptxPluginNavigationOptions, type PptxPluginNavigationResult, type PptxPluginPanel, type PptxPluginPointPosition, type PptxPluginReadClient, type PptxPluginRect, type PptxPluginRefusal, type PptxPluginSelection, type PptxPluginSnapshot, PptxPluginToolbar, type PptxPointPosition, type PptxSelectCommandId, type PptxShapePreset, type PptxTextSelection, type PptxTextSelectionTarget, Toolbar as PptxToolbar, type PptxWorkerEditorApi, PptxWorkerEditorChunkLoadError, type PptxWorkerEditorProps, type PptxWorkerViewerApi, type PptxWorkerViewerProps, type PptxZOrderMove, type PptxZoom, SHAPE_PRESETS, type SelectionFormatting, type ShapeFormatting, type ShapeFormattingAction, type SlideLayoutOption, Toolbar, ToolbarButton, type ToolbarButtonProps, ToolbarCommand, type ToolbarCommandArgs, ToolbarCommandButton, type ToolbarCommandButtonProps, type ToolbarCommandProps, ToolbarCommandSelect, type ToolbarCommandSelectProps, ToolbarDropdown, type ToolbarDropdownProps, ToolbarGroup, ToolbarMenuItem, type ToolbarMenuItemProps, ToolbarMenuSeparator, ToolbarOverflow, type ToolbarOverflowProps, type ToolbarProps, ToolbarSeparator, definePptxPlugin, useEditorToolbar, usePptxCommand, usePptxCommandState, usePptxCommands, useTranslation };
|