@coco-vexel/coco-office-editor 0.0.0-stage → 1.0.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/LICENSE +202 -0
- package/README.md +510 -2
- package/THIRD_PARTY_NOTICES.md +212 -0
- package/dist/index.cjs +26401 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +26192 -0
- package/dist/index.js.map +1 -0
- package/dist/model-DB6aN6uJ.d.cts +321 -0
- package/dist/model-DB6aN6uJ.d.ts +321 -0
- package/dist/native-B6B649CC.d.ts +1111 -0
- package/dist/native-Ct9nN06K.d.cts +1111 -0
- package/dist/ppt-native.cjs +5334 -0
- package/dist/ppt-native.cjs.map +1 -0
- package/dist/ppt-native.d.cts +2 -0
- package/dist/ppt-native.d.ts +2 -0
- package/dist/ppt-native.js +5332 -0
- package/dist/ppt-native.js.map +1 -0
- package/dist/ppt.cjs +5426 -0
- package/dist/ppt.cjs.map +1 -0
- package/dist/ppt.d.cts +306 -0
- package/dist/ppt.d.ts +306 -0
- package/dist/ppt.js +5410 -0
- package/dist/ppt.js.map +1 -0
- package/dist/spreadsheet.cjs +4276 -0
- package/dist/spreadsheet.cjs.map +1 -0
- package/dist/spreadsheet.d.cts +676 -0
- package/dist/spreadsheet.d.ts +676 -0
- package/dist/spreadsheet.js +4213 -0
- package/dist/spreadsheet.js.map +1 -0
- package/dist/word-editing.cjs +812 -0
- package/dist/word-editing.cjs.map +1 -0
- package/dist/word-editing.d.cts +149 -0
- package/dist/word-editing.d.ts +149 -0
- package/dist/word-editing.js +803 -0
- package/dist/word-editing.js.map +1 -0
- package/dist/word-native.cjs +13400 -0
- package/dist/word-native.cjs.map +1 -0
- package/dist/word-native.d.cts +4 -0
- package/dist/word-native.d.ts +4 -0
- package/dist/word-native.js +13293 -0
- package/dist/word-native.js.map +1 -0
- package/dist/word-prosemirror.cjs +489 -0
- package/dist/word-prosemirror.cjs.map +1 -0
- package/dist/word-prosemirror.d.cts +21 -0
- package/dist/word-prosemirror.d.ts +21 -0
- package/dist/word-prosemirror.js +483 -0
- package/dist/word-prosemirror.js.map +1 -0
- package/dist/word.cjs +16764 -0
- package/dist/word.cjs.map +1 -0
- package/dist/word.d.cts +84 -0
- package/dist/word.d.ts +84 -0
- package/dist/word.js +16632 -0
- package/dist/word.js.map +1 -0
- package/package.json +106 -3
- package/src/styles/editor.css +1507 -0
package/dist/ppt.d.cts
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { PptSlideSize, PptSlideBackgroundModel, PptShapeKind, PptTextStyle, PptTextParagraph, PptTextBodyProperties, PptImageCropModel, PptChartModel, PptTableModel, PptGradientFillModel, PptShapeStyle, PptCustomGeometryModel, PptShapeModel, PptSlideModel, PptPresentationModel, PptShapeGeometry, Presentation } from '@coco-vexel/coco-office/ppt';
|
|
2
|
+
|
|
3
|
+
type PptSceneNodeKind = PptShapeKind;
|
|
4
|
+
interface PptSceneRect {
|
|
5
|
+
left: number;
|
|
6
|
+
top: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
rotation?: number;
|
|
10
|
+
flipHorizontal?: boolean;
|
|
11
|
+
flipVertical?: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface PptSceneNode {
|
|
14
|
+
id: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
kind: PptSceneNodeKind;
|
|
17
|
+
bounds: PptSceneRect;
|
|
18
|
+
text?: string;
|
|
19
|
+
textStyle?: PptTextStyle;
|
|
20
|
+
textParagraphs?: PptTextParagraph[];
|
|
21
|
+
textBody?: PptTextBodyProperties;
|
|
22
|
+
imagePath?: string;
|
|
23
|
+
imageCrop?: PptImageCropModel;
|
|
24
|
+
imageFillRect?: PptImageCropModel;
|
|
25
|
+
imageOpacity?: number;
|
|
26
|
+
chart?: PptChartModel;
|
|
27
|
+
table?: PptTableModel;
|
|
28
|
+
fillColor?: string;
|
|
29
|
+
fillGradient?: PptGradientFillModel;
|
|
30
|
+
opacity?: number;
|
|
31
|
+
lineColor?: string;
|
|
32
|
+
lineGradient?: PptGradientFillModel;
|
|
33
|
+
lineOpacity?: number;
|
|
34
|
+
lineWidth?: number;
|
|
35
|
+
lineCap?: string;
|
|
36
|
+
lineDash?: string;
|
|
37
|
+
lineHeadEnd?: string;
|
|
38
|
+
lineTailEnd?: string;
|
|
39
|
+
shadow?: PptShapeStyle['shadow'];
|
|
40
|
+
presetGeometry?: string;
|
|
41
|
+
presetAdjustments?: Record<string, number>;
|
|
42
|
+
customGeometry?: PptCustomGeometryModel;
|
|
43
|
+
threeD?: NonNullable<PptShapeModel['raw']>['threeD'];
|
|
44
|
+
usesBackgroundFill?: boolean;
|
|
45
|
+
backgroundFill?: PptSlideBackgroundModel;
|
|
46
|
+
locked: boolean;
|
|
47
|
+
editable: boolean;
|
|
48
|
+
capabilities: PptSceneNodeCapabilities;
|
|
49
|
+
groupContext?: PptSceneGroupContext;
|
|
50
|
+
source: PptShapeModel;
|
|
51
|
+
children: PptSceneNode[];
|
|
52
|
+
}
|
|
53
|
+
interface PptSceneGroupContext {
|
|
54
|
+
parentId: string;
|
|
55
|
+
parentName?: string;
|
|
56
|
+
parentBounds: PptSceneRect;
|
|
57
|
+
parentTransform: {
|
|
58
|
+
childLeft: number;
|
|
59
|
+
childTop: number;
|
|
60
|
+
childWidth: number;
|
|
61
|
+
childHeight: number;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
interface PptSceneNodeCapabilities {
|
|
65
|
+
readonly select: boolean;
|
|
66
|
+
readonly editText: boolean;
|
|
67
|
+
readonly editTextStyle: boolean;
|
|
68
|
+
readonly editTableCells: boolean;
|
|
69
|
+
readonly editGeometry: boolean;
|
|
70
|
+
readonly editShapeStyle: boolean;
|
|
71
|
+
readonly reason?: string;
|
|
72
|
+
readonly reasons?: Partial<Record<PptSceneNodeCapability, string>>;
|
|
73
|
+
}
|
|
74
|
+
interface PptSlideScene {
|
|
75
|
+
id: string;
|
|
76
|
+
index: number;
|
|
77
|
+
name?: string;
|
|
78
|
+
title?: string;
|
|
79
|
+
size: PptSlideSize;
|
|
80
|
+
background?: PptSlideBackgroundModel;
|
|
81
|
+
nodes: PptSceneNode[];
|
|
82
|
+
groups: PptSceneNode[];
|
|
83
|
+
source: PptSlideModel;
|
|
84
|
+
}
|
|
85
|
+
interface PptPresentationScene {
|
|
86
|
+
size: PptSlideSize;
|
|
87
|
+
slides: PptSlideScene[];
|
|
88
|
+
}
|
|
89
|
+
type PptSceneNodeCapability = 'editText' | 'editTextStyle' | 'editTableCells' | 'editGeometry' | 'editShapeStyle';
|
|
90
|
+
declare const DEFAULT_PPT_SLIDE_SIZE: PptSlideSize;
|
|
91
|
+
declare function buildPptPresentationScene(model: PptPresentationModel): PptPresentationScene;
|
|
92
|
+
declare function buildPptSlideScene(slide: PptSlideModel, fallbackSize: PptSlideSize): PptSlideScene;
|
|
93
|
+
declare function buildPptSceneNode(shape: PptShapeModel, options?: {
|
|
94
|
+
slideSize?: PptSlideSize;
|
|
95
|
+
index?: number;
|
|
96
|
+
background?: PptSlideBackgroundModel;
|
|
97
|
+
backgroundFill?: PptSlideBackgroundModel;
|
|
98
|
+
}): PptSceneNode;
|
|
99
|
+
declare function isPptShapeEditable(shape: PptShapeModel): boolean;
|
|
100
|
+
declare function pptSceneNodeCapabilities(shape: PptShapeModel): PptSceneNodeCapabilities;
|
|
101
|
+
declare function pptSceneGeometryToSourceGeometry(node: PptSceneNode, geometry: Partial<PptShapeGeometry>): Partial<PptShapeGeometry>;
|
|
102
|
+
declare function normalizePptGeometry(geometry?: PptShapeGeometry): PptSceneRect;
|
|
103
|
+
declare function findPptSceneSlide(scene: PptPresentationScene, slideIdOrIndex: string | number): PptSlideScene | null;
|
|
104
|
+
declare function findPptSceneNode(slide: PptSlideScene, shapeIdOrName: string): PptSceneNode | null;
|
|
105
|
+
|
|
106
|
+
interface PptEditorImageResource {
|
|
107
|
+
url: string;
|
|
108
|
+
contentType: string;
|
|
109
|
+
}
|
|
110
|
+
interface PptEditorImagePreviewRequest {
|
|
111
|
+
path: string;
|
|
112
|
+
contentType: string;
|
|
113
|
+
bytes: Uint8Array;
|
|
114
|
+
}
|
|
115
|
+
interface PptEditorFontResource {
|
|
116
|
+
url: string;
|
|
117
|
+
contentType: string;
|
|
118
|
+
family: string;
|
|
119
|
+
weight?: number;
|
|
120
|
+
style?: 'normal' | 'italic';
|
|
121
|
+
}
|
|
122
|
+
interface PptEditorView {
|
|
123
|
+
presentation: Presentation;
|
|
124
|
+
model: PptPresentationModel;
|
|
125
|
+
scene: PptPresentationScene;
|
|
126
|
+
images: Record<string, PptEditorImageResource>;
|
|
127
|
+
fonts: PptEditorFontResource[];
|
|
128
|
+
}
|
|
129
|
+
interface PptEditorViewOptions {
|
|
130
|
+
presentationId?: string;
|
|
131
|
+
resolveImagePreview?: (image: PptEditorImagePreviewRequest) => Promise<PptEditorImageResource | undefined> | PptEditorImageResource | undefined;
|
|
132
|
+
}
|
|
133
|
+
declare function buildPptEditorViewFromPptx(bytes: Uint8Array | ArrayBuffer, options?: PptEditorViewOptions): Promise<PptEditorView>;
|
|
134
|
+
declare function buildPptEditorViewFromModel(model: PptPresentationModel, options?: PptEditorViewOptions): Promise<PptEditorView>;
|
|
135
|
+
declare function buildPptEditorViewFromPresentation(presentation: Presentation, options?: PptEditorViewOptions): Promise<PptEditorView>;
|
|
136
|
+
|
|
137
|
+
type PptEditorSelection = {
|
|
138
|
+
kind: 'slide';
|
|
139
|
+
slideId: string;
|
|
140
|
+
} | {
|
|
141
|
+
kind: 'shape';
|
|
142
|
+
slideId: string;
|
|
143
|
+
shapeId: string;
|
|
144
|
+
} | null;
|
|
145
|
+
type PptEditorCommand = {
|
|
146
|
+
kind: 'select-slide';
|
|
147
|
+
slideIdOrIndex: string | number;
|
|
148
|
+
} | {
|
|
149
|
+
kind: 'select-shape';
|
|
150
|
+
slideIdOrIndex: string | number;
|
|
151
|
+
shapeIdOrName: string;
|
|
152
|
+
} | {
|
|
153
|
+
kind: 'set-shape-text';
|
|
154
|
+
slideIdOrIndex: string | number;
|
|
155
|
+
shapeIdOrName: string;
|
|
156
|
+
text: string;
|
|
157
|
+
} | {
|
|
158
|
+
kind: 'set-shape-text-style';
|
|
159
|
+
slideIdOrIndex: string | number;
|
|
160
|
+
shapeIdOrName: string;
|
|
161
|
+
style: Partial<PptTextStyle>;
|
|
162
|
+
} | {
|
|
163
|
+
kind: 'set-table-cell-text';
|
|
164
|
+
slideIdOrIndex: string | number;
|
|
165
|
+
shapeIdOrName: string;
|
|
166
|
+
row: number;
|
|
167
|
+
column: number;
|
|
168
|
+
text: string;
|
|
169
|
+
} | {
|
|
170
|
+
kind: 'set-shape-geometry';
|
|
171
|
+
slideIdOrIndex: string | number;
|
|
172
|
+
shapeIdOrName: string;
|
|
173
|
+
geometry: Partial<PptShapeGeometry>;
|
|
174
|
+
preserveTextSizeOnResize?: boolean;
|
|
175
|
+
} | {
|
|
176
|
+
kind: 'set-shape-style';
|
|
177
|
+
slideIdOrIndex: string | number;
|
|
178
|
+
shapeIdOrName: string;
|
|
179
|
+
style: Partial<PptShapeStyle>;
|
|
180
|
+
} | {
|
|
181
|
+
kind: 'delete-shape';
|
|
182
|
+
slideIdOrIndex: string | number;
|
|
183
|
+
shapeIdOrName: string;
|
|
184
|
+
} | {
|
|
185
|
+
kind: 'duplicate-shape';
|
|
186
|
+
slideIdOrIndex: string | number;
|
|
187
|
+
shapeIdOrName: string;
|
|
188
|
+
offset?: Partial<PptShapeGeometry>;
|
|
189
|
+
} | {
|
|
190
|
+
kind: 'paste-shape';
|
|
191
|
+
slideIdOrIndex: string | number;
|
|
192
|
+
shapeIdOrName: string;
|
|
193
|
+
offset?: Partial<PptShapeGeometry>;
|
|
194
|
+
} | {
|
|
195
|
+
kind: 'bring-shape-to-front';
|
|
196
|
+
slideIdOrIndex: string | number;
|
|
197
|
+
shapeIdOrName: string;
|
|
198
|
+
} | {
|
|
199
|
+
kind: 'send-shape-to-back';
|
|
200
|
+
slideIdOrIndex: string | number;
|
|
201
|
+
shapeIdOrName: string;
|
|
202
|
+
};
|
|
203
|
+
type PptEditorRuntimeEvent = 'change' | 'selectionChange';
|
|
204
|
+
interface PptEditorChangeEvent {
|
|
205
|
+
readonly revision: number;
|
|
206
|
+
readonly command: PptEditorCommand;
|
|
207
|
+
readonly model: PptPresentationModel;
|
|
208
|
+
readonly scene: PptPresentationScene;
|
|
209
|
+
}
|
|
210
|
+
interface PptEditorSelectionChangeEvent {
|
|
211
|
+
readonly selection: PptEditorSelection;
|
|
212
|
+
}
|
|
213
|
+
interface PptEditorRuntimeEventMap {
|
|
214
|
+
change: PptEditorChangeEvent;
|
|
215
|
+
selectionChange: PptEditorSelectionChangeEvent;
|
|
216
|
+
}
|
|
217
|
+
interface PptEditorSessionOptions {
|
|
218
|
+
maxHistory?: number;
|
|
219
|
+
}
|
|
220
|
+
type Listener<T> = (event: T) => void;
|
|
221
|
+
declare class PptEditorSession {
|
|
222
|
+
private presentationValue;
|
|
223
|
+
private modelValue;
|
|
224
|
+
private sceneValue;
|
|
225
|
+
private selectionValue;
|
|
226
|
+
private revisionValue;
|
|
227
|
+
private readonly undoStack;
|
|
228
|
+
private readonly redoStack;
|
|
229
|
+
private readonly textBodyOverrides;
|
|
230
|
+
private readonly maxHistory;
|
|
231
|
+
private readonly changeListeners;
|
|
232
|
+
private readonly selectionListeners;
|
|
233
|
+
constructor(view: PptEditorView, options?: PptEditorSessionOptions);
|
|
234
|
+
presentation(): Presentation;
|
|
235
|
+
model(): PptPresentationModel;
|
|
236
|
+
scene(): PptPresentationScene;
|
|
237
|
+
selection(): PptEditorSelection;
|
|
238
|
+
revision(): number;
|
|
239
|
+
canUndo(): boolean;
|
|
240
|
+
canRedo(): boolean;
|
|
241
|
+
subscribe<K extends PptEditorRuntimeEvent>(event: K, listener: Listener<PptEditorRuntimeEventMap[K]>): () => void;
|
|
242
|
+
dispatch(command: PptEditorCommand): Promise<void>;
|
|
243
|
+
undo(): Promise<void>;
|
|
244
|
+
redo(): Promise<void>;
|
|
245
|
+
loadPresentation(bytes: Uint8Array | ArrayBuffer): Promise<void>;
|
|
246
|
+
toPptx(): Promise<Uint8Array>;
|
|
247
|
+
verifyExport(): Promise<PptPresentationModel>;
|
|
248
|
+
destroy(): Promise<void>;
|
|
249
|
+
private applySelectionCommand;
|
|
250
|
+
private applyEditCommand;
|
|
251
|
+
private assertEditableSceneNodeForCommand;
|
|
252
|
+
private applyShapeCollectionCommand;
|
|
253
|
+
private refreshAfterChange;
|
|
254
|
+
private replacePresentation;
|
|
255
|
+
private setSelection;
|
|
256
|
+
private pushUndo;
|
|
257
|
+
private historyEntry;
|
|
258
|
+
private restoreTextBodyOverrides;
|
|
259
|
+
private applyTextBodyOverrides;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
interface NativePptEditorOptions {
|
|
263
|
+
styleIsolation?: 'shadow' | 'none';
|
|
264
|
+
onChange?: (event: {
|
|
265
|
+
revision: number;
|
|
266
|
+
bytes: Uint8Array;
|
|
267
|
+
}) => void | Promise<void>;
|
|
268
|
+
onObjectAction?: (event: {
|
|
269
|
+
action: 'blocked-text-edit' | 'cycle-selection' | 'nudge-geometry' | 'snap-geometry' | 'copy-shape' | 'paste-shape' | 'delete-shape' | 'duplicate-shape' | 'bring-shape-to-front' | 'send-shape-to-back';
|
|
270
|
+
slideId: string;
|
|
271
|
+
shapeId: string;
|
|
272
|
+
kind: PptSceneNode['kind'];
|
|
273
|
+
name?: string;
|
|
274
|
+
reason: string;
|
|
275
|
+
candidateIndex?: number;
|
|
276
|
+
candidateCount?: number;
|
|
277
|
+
}) => void;
|
|
278
|
+
onTextEditStateChange?: (event: {
|
|
279
|
+
state: 'start' | 'commit' | 'cancel';
|
|
280
|
+
slideId: string;
|
|
281
|
+
shapeId: string;
|
|
282
|
+
text: string;
|
|
283
|
+
}) => void;
|
|
284
|
+
onTableCellSelectionChange?: (event: {
|
|
285
|
+
slideId: string;
|
|
286
|
+
shapeId: string;
|
|
287
|
+
row: number;
|
|
288
|
+
column: number;
|
|
289
|
+
text: string;
|
|
290
|
+
}) => void;
|
|
291
|
+
}
|
|
292
|
+
interface NativePptEditor {
|
|
293
|
+
session(): PptEditorSession;
|
|
294
|
+
selection(): PptEditorSelection;
|
|
295
|
+
dispatch(command: PptEditorCommand): Promise<void>;
|
|
296
|
+
loadPresentation(bytes: Uint8Array | ArrayBuffer): Promise<void>;
|
|
297
|
+
toPptx(): Promise<Uint8Array>;
|
|
298
|
+
canUndo(): boolean;
|
|
299
|
+
canRedo(): boolean;
|
|
300
|
+
undo(): Promise<void>;
|
|
301
|
+
redo(): Promise<void>;
|
|
302
|
+
destroy(): Promise<void>;
|
|
303
|
+
}
|
|
304
|
+
declare function renderNativePptEditor(host: HTMLElement, view: PptEditorView, options?: NativePptEditorOptions): NativePptEditor;
|
|
305
|
+
|
|
306
|
+
export { DEFAULT_PPT_SLIDE_SIZE, type NativePptEditor, type NativePptEditorOptions, type PptEditorChangeEvent, type PptEditorCommand, type PptEditorFontResource, type PptEditorImagePreviewRequest, type PptEditorImageResource, type PptEditorRuntimeEvent, type PptEditorRuntimeEventMap, type PptEditorSelection, type PptEditorSelectionChangeEvent, PptEditorSession, type PptEditorSessionOptions, type PptEditorView, type PptEditorViewOptions, type PptPresentationScene, type PptSceneGroupContext, type PptSceneNode, type PptSceneNodeCapabilities, type PptSceneNodeCapability, type PptSceneNodeKind, type PptSceneRect, type PptSlideScene, buildPptEditorViewFromModel, buildPptEditorViewFromPptx, buildPptEditorViewFromPresentation, buildPptPresentationScene, buildPptSceneNode, buildPptSlideScene, findPptSceneNode, findPptSceneSlide, isPptShapeEditable, normalizePptGeometry, pptSceneGeometryToSourceGeometry, pptSceneNodeCapabilities, renderNativePptEditor };
|
package/dist/ppt.d.ts
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { PptSlideSize, PptSlideBackgroundModel, PptShapeKind, PptTextStyle, PptTextParagraph, PptTextBodyProperties, PptImageCropModel, PptChartModel, PptTableModel, PptGradientFillModel, PptShapeStyle, PptCustomGeometryModel, PptShapeModel, PptSlideModel, PptPresentationModel, PptShapeGeometry, Presentation } from '@coco-vexel/coco-office/ppt';
|
|
2
|
+
|
|
3
|
+
type PptSceneNodeKind = PptShapeKind;
|
|
4
|
+
interface PptSceneRect {
|
|
5
|
+
left: number;
|
|
6
|
+
top: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
rotation?: number;
|
|
10
|
+
flipHorizontal?: boolean;
|
|
11
|
+
flipVertical?: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface PptSceneNode {
|
|
14
|
+
id: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
kind: PptSceneNodeKind;
|
|
17
|
+
bounds: PptSceneRect;
|
|
18
|
+
text?: string;
|
|
19
|
+
textStyle?: PptTextStyle;
|
|
20
|
+
textParagraphs?: PptTextParagraph[];
|
|
21
|
+
textBody?: PptTextBodyProperties;
|
|
22
|
+
imagePath?: string;
|
|
23
|
+
imageCrop?: PptImageCropModel;
|
|
24
|
+
imageFillRect?: PptImageCropModel;
|
|
25
|
+
imageOpacity?: number;
|
|
26
|
+
chart?: PptChartModel;
|
|
27
|
+
table?: PptTableModel;
|
|
28
|
+
fillColor?: string;
|
|
29
|
+
fillGradient?: PptGradientFillModel;
|
|
30
|
+
opacity?: number;
|
|
31
|
+
lineColor?: string;
|
|
32
|
+
lineGradient?: PptGradientFillModel;
|
|
33
|
+
lineOpacity?: number;
|
|
34
|
+
lineWidth?: number;
|
|
35
|
+
lineCap?: string;
|
|
36
|
+
lineDash?: string;
|
|
37
|
+
lineHeadEnd?: string;
|
|
38
|
+
lineTailEnd?: string;
|
|
39
|
+
shadow?: PptShapeStyle['shadow'];
|
|
40
|
+
presetGeometry?: string;
|
|
41
|
+
presetAdjustments?: Record<string, number>;
|
|
42
|
+
customGeometry?: PptCustomGeometryModel;
|
|
43
|
+
threeD?: NonNullable<PptShapeModel['raw']>['threeD'];
|
|
44
|
+
usesBackgroundFill?: boolean;
|
|
45
|
+
backgroundFill?: PptSlideBackgroundModel;
|
|
46
|
+
locked: boolean;
|
|
47
|
+
editable: boolean;
|
|
48
|
+
capabilities: PptSceneNodeCapabilities;
|
|
49
|
+
groupContext?: PptSceneGroupContext;
|
|
50
|
+
source: PptShapeModel;
|
|
51
|
+
children: PptSceneNode[];
|
|
52
|
+
}
|
|
53
|
+
interface PptSceneGroupContext {
|
|
54
|
+
parentId: string;
|
|
55
|
+
parentName?: string;
|
|
56
|
+
parentBounds: PptSceneRect;
|
|
57
|
+
parentTransform: {
|
|
58
|
+
childLeft: number;
|
|
59
|
+
childTop: number;
|
|
60
|
+
childWidth: number;
|
|
61
|
+
childHeight: number;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
interface PptSceneNodeCapabilities {
|
|
65
|
+
readonly select: boolean;
|
|
66
|
+
readonly editText: boolean;
|
|
67
|
+
readonly editTextStyle: boolean;
|
|
68
|
+
readonly editTableCells: boolean;
|
|
69
|
+
readonly editGeometry: boolean;
|
|
70
|
+
readonly editShapeStyle: boolean;
|
|
71
|
+
readonly reason?: string;
|
|
72
|
+
readonly reasons?: Partial<Record<PptSceneNodeCapability, string>>;
|
|
73
|
+
}
|
|
74
|
+
interface PptSlideScene {
|
|
75
|
+
id: string;
|
|
76
|
+
index: number;
|
|
77
|
+
name?: string;
|
|
78
|
+
title?: string;
|
|
79
|
+
size: PptSlideSize;
|
|
80
|
+
background?: PptSlideBackgroundModel;
|
|
81
|
+
nodes: PptSceneNode[];
|
|
82
|
+
groups: PptSceneNode[];
|
|
83
|
+
source: PptSlideModel;
|
|
84
|
+
}
|
|
85
|
+
interface PptPresentationScene {
|
|
86
|
+
size: PptSlideSize;
|
|
87
|
+
slides: PptSlideScene[];
|
|
88
|
+
}
|
|
89
|
+
type PptSceneNodeCapability = 'editText' | 'editTextStyle' | 'editTableCells' | 'editGeometry' | 'editShapeStyle';
|
|
90
|
+
declare const DEFAULT_PPT_SLIDE_SIZE: PptSlideSize;
|
|
91
|
+
declare function buildPptPresentationScene(model: PptPresentationModel): PptPresentationScene;
|
|
92
|
+
declare function buildPptSlideScene(slide: PptSlideModel, fallbackSize: PptSlideSize): PptSlideScene;
|
|
93
|
+
declare function buildPptSceneNode(shape: PptShapeModel, options?: {
|
|
94
|
+
slideSize?: PptSlideSize;
|
|
95
|
+
index?: number;
|
|
96
|
+
background?: PptSlideBackgroundModel;
|
|
97
|
+
backgroundFill?: PptSlideBackgroundModel;
|
|
98
|
+
}): PptSceneNode;
|
|
99
|
+
declare function isPptShapeEditable(shape: PptShapeModel): boolean;
|
|
100
|
+
declare function pptSceneNodeCapabilities(shape: PptShapeModel): PptSceneNodeCapabilities;
|
|
101
|
+
declare function pptSceneGeometryToSourceGeometry(node: PptSceneNode, geometry: Partial<PptShapeGeometry>): Partial<PptShapeGeometry>;
|
|
102
|
+
declare function normalizePptGeometry(geometry?: PptShapeGeometry): PptSceneRect;
|
|
103
|
+
declare function findPptSceneSlide(scene: PptPresentationScene, slideIdOrIndex: string | number): PptSlideScene | null;
|
|
104
|
+
declare function findPptSceneNode(slide: PptSlideScene, shapeIdOrName: string): PptSceneNode | null;
|
|
105
|
+
|
|
106
|
+
interface PptEditorImageResource {
|
|
107
|
+
url: string;
|
|
108
|
+
contentType: string;
|
|
109
|
+
}
|
|
110
|
+
interface PptEditorImagePreviewRequest {
|
|
111
|
+
path: string;
|
|
112
|
+
contentType: string;
|
|
113
|
+
bytes: Uint8Array;
|
|
114
|
+
}
|
|
115
|
+
interface PptEditorFontResource {
|
|
116
|
+
url: string;
|
|
117
|
+
contentType: string;
|
|
118
|
+
family: string;
|
|
119
|
+
weight?: number;
|
|
120
|
+
style?: 'normal' | 'italic';
|
|
121
|
+
}
|
|
122
|
+
interface PptEditorView {
|
|
123
|
+
presentation: Presentation;
|
|
124
|
+
model: PptPresentationModel;
|
|
125
|
+
scene: PptPresentationScene;
|
|
126
|
+
images: Record<string, PptEditorImageResource>;
|
|
127
|
+
fonts: PptEditorFontResource[];
|
|
128
|
+
}
|
|
129
|
+
interface PptEditorViewOptions {
|
|
130
|
+
presentationId?: string;
|
|
131
|
+
resolveImagePreview?: (image: PptEditorImagePreviewRequest) => Promise<PptEditorImageResource | undefined> | PptEditorImageResource | undefined;
|
|
132
|
+
}
|
|
133
|
+
declare function buildPptEditorViewFromPptx(bytes: Uint8Array | ArrayBuffer, options?: PptEditorViewOptions): Promise<PptEditorView>;
|
|
134
|
+
declare function buildPptEditorViewFromModel(model: PptPresentationModel, options?: PptEditorViewOptions): Promise<PptEditorView>;
|
|
135
|
+
declare function buildPptEditorViewFromPresentation(presentation: Presentation, options?: PptEditorViewOptions): Promise<PptEditorView>;
|
|
136
|
+
|
|
137
|
+
type PptEditorSelection = {
|
|
138
|
+
kind: 'slide';
|
|
139
|
+
slideId: string;
|
|
140
|
+
} | {
|
|
141
|
+
kind: 'shape';
|
|
142
|
+
slideId: string;
|
|
143
|
+
shapeId: string;
|
|
144
|
+
} | null;
|
|
145
|
+
type PptEditorCommand = {
|
|
146
|
+
kind: 'select-slide';
|
|
147
|
+
slideIdOrIndex: string | number;
|
|
148
|
+
} | {
|
|
149
|
+
kind: 'select-shape';
|
|
150
|
+
slideIdOrIndex: string | number;
|
|
151
|
+
shapeIdOrName: string;
|
|
152
|
+
} | {
|
|
153
|
+
kind: 'set-shape-text';
|
|
154
|
+
slideIdOrIndex: string | number;
|
|
155
|
+
shapeIdOrName: string;
|
|
156
|
+
text: string;
|
|
157
|
+
} | {
|
|
158
|
+
kind: 'set-shape-text-style';
|
|
159
|
+
slideIdOrIndex: string | number;
|
|
160
|
+
shapeIdOrName: string;
|
|
161
|
+
style: Partial<PptTextStyle>;
|
|
162
|
+
} | {
|
|
163
|
+
kind: 'set-table-cell-text';
|
|
164
|
+
slideIdOrIndex: string | number;
|
|
165
|
+
shapeIdOrName: string;
|
|
166
|
+
row: number;
|
|
167
|
+
column: number;
|
|
168
|
+
text: string;
|
|
169
|
+
} | {
|
|
170
|
+
kind: 'set-shape-geometry';
|
|
171
|
+
slideIdOrIndex: string | number;
|
|
172
|
+
shapeIdOrName: string;
|
|
173
|
+
geometry: Partial<PptShapeGeometry>;
|
|
174
|
+
preserveTextSizeOnResize?: boolean;
|
|
175
|
+
} | {
|
|
176
|
+
kind: 'set-shape-style';
|
|
177
|
+
slideIdOrIndex: string | number;
|
|
178
|
+
shapeIdOrName: string;
|
|
179
|
+
style: Partial<PptShapeStyle>;
|
|
180
|
+
} | {
|
|
181
|
+
kind: 'delete-shape';
|
|
182
|
+
slideIdOrIndex: string | number;
|
|
183
|
+
shapeIdOrName: string;
|
|
184
|
+
} | {
|
|
185
|
+
kind: 'duplicate-shape';
|
|
186
|
+
slideIdOrIndex: string | number;
|
|
187
|
+
shapeIdOrName: string;
|
|
188
|
+
offset?: Partial<PptShapeGeometry>;
|
|
189
|
+
} | {
|
|
190
|
+
kind: 'paste-shape';
|
|
191
|
+
slideIdOrIndex: string | number;
|
|
192
|
+
shapeIdOrName: string;
|
|
193
|
+
offset?: Partial<PptShapeGeometry>;
|
|
194
|
+
} | {
|
|
195
|
+
kind: 'bring-shape-to-front';
|
|
196
|
+
slideIdOrIndex: string | number;
|
|
197
|
+
shapeIdOrName: string;
|
|
198
|
+
} | {
|
|
199
|
+
kind: 'send-shape-to-back';
|
|
200
|
+
slideIdOrIndex: string | number;
|
|
201
|
+
shapeIdOrName: string;
|
|
202
|
+
};
|
|
203
|
+
type PptEditorRuntimeEvent = 'change' | 'selectionChange';
|
|
204
|
+
interface PptEditorChangeEvent {
|
|
205
|
+
readonly revision: number;
|
|
206
|
+
readonly command: PptEditorCommand;
|
|
207
|
+
readonly model: PptPresentationModel;
|
|
208
|
+
readonly scene: PptPresentationScene;
|
|
209
|
+
}
|
|
210
|
+
interface PptEditorSelectionChangeEvent {
|
|
211
|
+
readonly selection: PptEditorSelection;
|
|
212
|
+
}
|
|
213
|
+
interface PptEditorRuntimeEventMap {
|
|
214
|
+
change: PptEditorChangeEvent;
|
|
215
|
+
selectionChange: PptEditorSelectionChangeEvent;
|
|
216
|
+
}
|
|
217
|
+
interface PptEditorSessionOptions {
|
|
218
|
+
maxHistory?: number;
|
|
219
|
+
}
|
|
220
|
+
type Listener<T> = (event: T) => void;
|
|
221
|
+
declare class PptEditorSession {
|
|
222
|
+
private presentationValue;
|
|
223
|
+
private modelValue;
|
|
224
|
+
private sceneValue;
|
|
225
|
+
private selectionValue;
|
|
226
|
+
private revisionValue;
|
|
227
|
+
private readonly undoStack;
|
|
228
|
+
private readonly redoStack;
|
|
229
|
+
private readonly textBodyOverrides;
|
|
230
|
+
private readonly maxHistory;
|
|
231
|
+
private readonly changeListeners;
|
|
232
|
+
private readonly selectionListeners;
|
|
233
|
+
constructor(view: PptEditorView, options?: PptEditorSessionOptions);
|
|
234
|
+
presentation(): Presentation;
|
|
235
|
+
model(): PptPresentationModel;
|
|
236
|
+
scene(): PptPresentationScene;
|
|
237
|
+
selection(): PptEditorSelection;
|
|
238
|
+
revision(): number;
|
|
239
|
+
canUndo(): boolean;
|
|
240
|
+
canRedo(): boolean;
|
|
241
|
+
subscribe<K extends PptEditorRuntimeEvent>(event: K, listener: Listener<PptEditorRuntimeEventMap[K]>): () => void;
|
|
242
|
+
dispatch(command: PptEditorCommand): Promise<void>;
|
|
243
|
+
undo(): Promise<void>;
|
|
244
|
+
redo(): Promise<void>;
|
|
245
|
+
loadPresentation(bytes: Uint8Array | ArrayBuffer): Promise<void>;
|
|
246
|
+
toPptx(): Promise<Uint8Array>;
|
|
247
|
+
verifyExport(): Promise<PptPresentationModel>;
|
|
248
|
+
destroy(): Promise<void>;
|
|
249
|
+
private applySelectionCommand;
|
|
250
|
+
private applyEditCommand;
|
|
251
|
+
private assertEditableSceneNodeForCommand;
|
|
252
|
+
private applyShapeCollectionCommand;
|
|
253
|
+
private refreshAfterChange;
|
|
254
|
+
private replacePresentation;
|
|
255
|
+
private setSelection;
|
|
256
|
+
private pushUndo;
|
|
257
|
+
private historyEntry;
|
|
258
|
+
private restoreTextBodyOverrides;
|
|
259
|
+
private applyTextBodyOverrides;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
interface NativePptEditorOptions {
|
|
263
|
+
styleIsolation?: 'shadow' | 'none';
|
|
264
|
+
onChange?: (event: {
|
|
265
|
+
revision: number;
|
|
266
|
+
bytes: Uint8Array;
|
|
267
|
+
}) => void | Promise<void>;
|
|
268
|
+
onObjectAction?: (event: {
|
|
269
|
+
action: 'blocked-text-edit' | 'cycle-selection' | 'nudge-geometry' | 'snap-geometry' | 'copy-shape' | 'paste-shape' | 'delete-shape' | 'duplicate-shape' | 'bring-shape-to-front' | 'send-shape-to-back';
|
|
270
|
+
slideId: string;
|
|
271
|
+
shapeId: string;
|
|
272
|
+
kind: PptSceneNode['kind'];
|
|
273
|
+
name?: string;
|
|
274
|
+
reason: string;
|
|
275
|
+
candidateIndex?: number;
|
|
276
|
+
candidateCount?: number;
|
|
277
|
+
}) => void;
|
|
278
|
+
onTextEditStateChange?: (event: {
|
|
279
|
+
state: 'start' | 'commit' | 'cancel';
|
|
280
|
+
slideId: string;
|
|
281
|
+
shapeId: string;
|
|
282
|
+
text: string;
|
|
283
|
+
}) => void;
|
|
284
|
+
onTableCellSelectionChange?: (event: {
|
|
285
|
+
slideId: string;
|
|
286
|
+
shapeId: string;
|
|
287
|
+
row: number;
|
|
288
|
+
column: number;
|
|
289
|
+
text: string;
|
|
290
|
+
}) => void;
|
|
291
|
+
}
|
|
292
|
+
interface NativePptEditor {
|
|
293
|
+
session(): PptEditorSession;
|
|
294
|
+
selection(): PptEditorSelection;
|
|
295
|
+
dispatch(command: PptEditorCommand): Promise<void>;
|
|
296
|
+
loadPresentation(bytes: Uint8Array | ArrayBuffer): Promise<void>;
|
|
297
|
+
toPptx(): Promise<Uint8Array>;
|
|
298
|
+
canUndo(): boolean;
|
|
299
|
+
canRedo(): boolean;
|
|
300
|
+
undo(): Promise<void>;
|
|
301
|
+
redo(): Promise<void>;
|
|
302
|
+
destroy(): Promise<void>;
|
|
303
|
+
}
|
|
304
|
+
declare function renderNativePptEditor(host: HTMLElement, view: PptEditorView, options?: NativePptEditorOptions): NativePptEditor;
|
|
305
|
+
|
|
306
|
+
export { DEFAULT_PPT_SLIDE_SIZE, type NativePptEditor, type NativePptEditorOptions, type PptEditorChangeEvent, type PptEditorCommand, type PptEditorFontResource, type PptEditorImagePreviewRequest, type PptEditorImageResource, type PptEditorRuntimeEvent, type PptEditorRuntimeEventMap, type PptEditorSelection, type PptEditorSelectionChangeEvent, PptEditorSession, type PptEditorSessionOptions, type PptEditorView, type PptEditorViewOptions, type PptPresentationScene, type PptSceneGroupContext, type PptSceneNode, type PptSceneNodeCapabilities, type PptSceneNodeCapability, type PptSceneNodeKind, type PptSceneRect, type PptSlideScene, buildPptEditorViewFromModel, buildPptEditorViewFromPptx, buildPptEditorViewFromPresentation, buildPptPresentationScene, buildPptSceneNode, buildPptSlideScene, findPptSceneNode, findPptSceneSlide, isPptShapeEditable, normalizePptGeometry, pptSceneGeometryToSourceGeometry, pptSceneNodeCapabilities, renderNativePptEditor };
|