@mcpher/gas-fakes 2.5.2 → 2.5.4
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 +17 -3
- package/package.json +1 -1
- package/pngs/srv.jpg +0 -0
- package/src/cli/app.js +1 -0
- package/src/cli/togas.js +23 -14
- package/src/index.js +1 -0
- package/src/services/advslides/fakeadvslides.js +11 -5
- package/src/services/base/app.js +9 -0
- package/src/services/base/fakebase.js +28 -0
- package/src/services/common/fakeadvresource.js +3 -2
- package/src/services/content/contentservice.js +3 -2
- package/src/services/enums/baseenums.js +47 -0
- package/src/services/enums/contentenums.js +1 -3
- package/src/services/enums/scriptenums.js +31 -4
- package/src/services/enums/slidesenums.js +3 -1
- package/src/services/enums/xmlenums.js +14 -0
- package/src/services/html/serverworker.js +1 -1
- package/src/services/scriptapp/app.js +14 -7
- package/src/services/scriptapp/fakeauthorizationinfo.js +4 -4
- package/src/services/slidesapp/app.js +5 -0
- package/src/services/slidesapp/fakeautofit.js +1 -1
- package/src/services/slidesapp/fakeborder.js +106 -0
- package/src/services/slidesapp/fakecolorscheme.js +1 -1
- package/src/services/slidesapp/fakefill.js +216 -0
- package/src/services/slidesapp/fakegroup.js +35 -0
- package/src/services/slidesapp/fakeimage.js +118 -0
- package/src/services/slidesapp/fakelayout.js +351 -0
- package/src/services/slidesapp/fakeline.js +2 -2
- package/src/services/slidesapp/fakelinefill.js +15 -16
- package/src/services/slidesapp/fakelink.js +20 -3
- package/src/services/slidesapp/fakelist.js +36 -0
- package/src/services/slidesapp/fakeliststyle.js +105 -0
- package/src/services/slidesapp/fakemaster.js +358 -0
- package/src/services/slidesapp/fakenotesmaster.js +125 -0
- package/src/services/slidesapp/fakenotespage.js +102 -2
- package/src/services/slidesapp/fakepagebackground.js +109 -1
- package/src/services/slidesapp/fakepageelement.js +157 -18
- package/src/services/slidesapp/fakepageelementrange.js +28 -0
- package/src/services/slidesapp/fakepagerange.js +28 -0
- package/src/services/slidesapp/fakeparagraphstyle.js +139 -0
- package/src/services/slidesapp/fakepicturefill.js +32 -0
- package/src/services/slidesapp/fakepresentation.js +126 -2
- package/src/services/slidesapp/fakeshape.js +9 -0
- package/src/services/slidesapp/fakeslide.js +216 -24
- package/src/services/slidesapp/fakesolidfill.js +45 -0
- package/src/services/slidesapp/fakespeakerspotlight.js +18 -0
- package/src/services/slidesapp/faketable.js +55 -9
- package/src/services/slidesapp/faketablecell.js +141 -12
- package/src/services/slidesapp/faketablecellrange.js +28 -0
- package/src/services/slidesapp/faketablecolumn.js +72 -0
- package/src/services/slidesapp/faketablerow.js +31 -0
- package/src/services/slidesapp/faketextrange.js +179 -135
- package/src/services/slidesapp/faketextstyle.js +158 -0
- package/src/services/slidesapp/fakevideo.js +35 -0
- package/src/services/slidesapp/fakewordart.js +22 -0
- package/src/services/slidesapp/pageelementfactory.js +24 -1
- package/src/services/spreadsheetapp/fakeembeddedchartbuilder.js +92 -12
- package/src/services/spreadsheetapp/fakespreadsheet.js +360 -62
- package/src/services/spreadsheetapp/fakespreadsheettheme.js +53 -0
- package/src/services/urlfetchapp/app.js +216 -175
- package/src/services/xmlservice/app.js +3 -78
- package/src/services/xmlservice/fakeattribute.js +15 -0
- package/src/services/xmlservice/fakecdata.js +40 -0
- package/src/services/xmlservice/fakecomment.js +34 -0
- package/src/services/xmlservice/fakecontent.js +51 -0
- package/src/services/xmlservice/fakedoctype.js +68 -0
- package/src/services/xmlservice/fakedocument.js +110 -13
- package/src/services/xmlservice/fakeelement.js +297 -82
- package/src/services/xmlservice/fakeentityref.js +54 -0
- package/src/services/xmlservice/fakeformat.js +67 -22
- package/src/services/xmlservice/fakeprocessinginstruction.js +44 -0
- package/src/services/xmlservice/faketext.js +39 -0
- package/src/services/xmlservice/fakexmlservice.js +118 -0
- package/src/support/sxfetch.js +60 -0
- package/tools/omlx.env.example +6 -0
- package/tools/omlx_mcp_server.cjs +157 -0
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Proxies } from '../../support/proxies.js';
|
|
2
2
|
import { newFakeColorScheme } from './fakecolorscheme.js';
|
|
3
|
+
import { newFakePageBackground } from './fakepagebackground.js';
|
|
4
|
+
import { newFakePageElement, PageElementRegistry } from './fakepageelement.js';
|
|
5
|
+
import { newFakeLayout } from './fakelayout.js';
|
|
3
6
|
|
|
4
7
|
export const newFakeMaster = (...args) => {
|
|
5
8
|
return Proxies.guard(new FakeMaster(...args));
|
|
@@ -24,6 +27,14 @@ export class FakeMaster {
|
|
|
24
27
|
return this.__id;
|
|
25
28
|
}
|
|
26
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Gets the background of the master.
|
|
32
|
+
* @returns {FakePageBackground} The background.
|
|
33
|
+
*/
|
|
34
|
+
getBackground() {
|
|
35
|
+
return newFakePageBackground(this);
|
|
36
|
+
}
|
|
37
|
+
|
|
27
38
|
/**
|
|
28
39
|
* Gets the color scheme of the master.
|
|
29
40
|
* @returns {FakeColorScheme} The color scheme.
|
|
@@ -32,6 +43,353 @@ export class FakeMaster {
|
|
|
32
43
|
return newFakeColorScheme(this);
|
|
33
44
|
}
|
|
34
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Gets the type of the page.
|
|
48
|
+
* @returns {SlidesApp.PageType}
|
|
49
|
+
*/
|
|
50
|
+
getPageType() {
|
|
51
|
+
return SlidesApp.PageType.MASTER;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Gets the list of page elements on the master.
|
|
56
|
+
* @returns {FakePageElement[]} The page elements.
|
|
57
|
+
*/
|
|
58
|
+
getPageElements() {
|
|
59
|
+
return (this.__resource.pageElements || []).map(pe => newFakePageElement(pe, this));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Gets a page element by ID.
|
|
64
|
+
* @param {string} id The ID.
|
|
65
|
+
* @returns {FakePageElement|null} The element.
|
|
66
|
+
*/
|
|
67
|
+
getPageElementById(id) {
|
|
68
|
+
return this.getPageElements().find(pe => pe.getObjectId() === id) || null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
getGroups() {
|
|
72
|
+
return this.getPageElements()
|
|
73
|
+
.filter(pe => pe.getPageElementType().toString() === 'GROUP')
|
|
74
|
+
.map(pe => pe.asGroup());
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
getImages() {
|
|
78
|
+
return this.getPageElements()
|
|
79
|
+
.filter(pe => pe.getPageElementType().toString() === 'IMAGE')
|
|
80
|
+
.map(pe => pe.asImage());
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
getLines() {
|
|
84
|
+
return this.getPageElements()
|
|
85
|
+
.filter(pe => pe.getPageElementType().toString() === 'LINE')
|
|
86
|
+
.map(pe => pe.asLine());
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
getShapes() {
|
|
90
|
+
return this.getPageElements()
|
|
91
|
+
.filter(pe => pe.getPageElementType().toString() === 'SHAPE')
|
|
92
|
+
.map(pe => pe.asShape());
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
getTables() {
|
|
96
|
+
return this.getPageElements()
|
|
97
|
+
.filter(pe => pe.getPageElementType().toString() === 'TABLE')
|
|
98
|
+
.map(pe => pe.asTable());
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
getVideos() {
|
|
102
|
+
return this.getPageElements()
|
|
103
|
+
.filter(pe => pe.getPageElementType().toString() === 'VIDEO')
|
|
104
|
+
.map(pe => pe.asVideo());
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
getWordArts() {
|
|
108
|
+
return this.getPageElements()
|
|
109
|
+
.filter(pe => pe.getPageElementType().toString() === 'WORD_ART')
|
|
110
|
+
.map(pe => pe.asWordArt());
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
getSheetsCharts() {
|
|
114
|
+
return this.getPageElements()
|
|
115
|
+
.filter(pe => pe.getPageElementType().toString() === 'SHEETS_CHART')
|
|
116
|
+
.map(pe => pe.asSheetsChart());
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Inserts a Google Sheets chart on the master.
|
|
121
|
+
* @param {EmbeddedChart} chart The chart.
|
|
122
|
+
* @returns {SheetsChart} The inserted chart.
|
|
123
|
+
*/
|
|
124
|
+
insertSheetsChart(chart) {
|
|
125
|
+
const presentationId = this.__presentation.getId();
|
|
126
|
+
const objectId = `chart_${Math.random().toString(36).substring(2, 11)}`;
|
|
127
|
+
const spreadsheetId = chart.getSpreadsheetId ? chart.getSpreadsheetId() : '';
|
|
128
|
+
const chartId = chart.getChartId ? chart.getChartId() : 0;
|
|
129
|
+
|
|
130
|
+
const requests = [{
|
|
131
|
+
createSheetsChart: {
|
|
132
|
+
objectId,
|
|
133
|
+
spreadsheetId,
|
|
134
|
+
chartId,
|
|
135
|
+
linkingMode: 'LINKED',
|
|
136
|
+
elementProperties: {
|
|
137
|
+
pageObjectId: this.getObjectId(),
|
|
138
|
+
size: {
|
|
139
|
+
width: { magnitude: 400, unit: 'PT' },
|
|
140
|
+
height: { magnitude: 300, unit: 'PT' }
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}];
|
|
145
|
+
|
|
146
|
+
Slides.Presentations.batchUpdate({ requests }, presentationId);
|
|
147
|
+
return this.getPageElementById(objectId).asSheetsChart();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Inserts a Google Sheets chart as an image on the master.
|
|
152
|
+
* @param {EmbeddedChart} chart The chart.
|
|
153
|
+
* @returns {Image} The inserted image.
|
|
154
|
+
*/
|
|
155
|
+
insertSheetsChartAsImage(chart) {
|
|
156
|
+
const presentationId = this.__presentation.getId();
|
|
157
|
+
const objectId = `chart_img_${Math.random().toString(36).substring(2, 11)}`;
|
|
158
|
+
const requests = [{
|
|
159
|
+
createImage: {
|
|
160
|
+
objectId,
|
|
161
|
+
url: 'https://via.placeholder.com/400x300?text=Sheets+Chart',
|
|
162
|
+
elementProperties: {
|
|
163
|
+
pageObjectId: this.getObjectId()
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}];
|
|
167
|
+
Slides.Presentations.batchUpdate({ requests }, presentationId);
|
|
168
|
+
return this.getPageElementById(objectId).asImage();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Gets the layouts associated with this master.
|
|
173
|
+
* @returns {FakeLayout[]} The layouts.
|
|
174
|
+
*/
|
|
175
|
+
getLayouts() {
|
|
176
|
+
const layouts = this.__presentation.__resource.layouts || [];
|
|
177
|
+
return layouts
|
|
178
|
+
.filter(l => l.layoutProperties?.masterObjectId === this.__id)
|
|
179
|
+
.map(l => newFakeLayout(l, this.__presentation));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
getPlaceholders() {
|
|
183
|
+
return this.getPageElements().filter(pe => pe.__resource.shape?.placeholder || pe.__resource.image?.placeholder);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
getPlaceholder(placeholderType, index = 0) {
|
|
187
|
+
const typeStr = placeholderType.toString();
|
|
188
|
+
return this.getPlaceholders().find(p => {
|
|
189
|
+
const ph = p.__resource.shape?.placeholder || p.__resource.image?.placeholder;
|
|
190
|
+
return ph.type === typeStr && (ph.index === index || (index === 0 && ph.index === undefined));
|
|
191
|
+
}) || null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
insertShape(shapeType, left = 0, top = 0, width = 300, height = 300) {
|
|
195
|
+
const presentationId = this.__presentation.getId();
|
|
196
|
+
const objectId = `shape_${Math.random().toString(36).substring(2, 11)}`;
|
|
197
|
+
const requests = [{
|
|
198
|
+
createShape: {
|
|
199
|
+
objectId,
|
|
200
|
+
shapeType: shapeType.toString(),
|
|
201
|
+
elementProperties: {
|
|
202
|
+
pageObjectId: this.getObjectId(),
|
|
203
|
+
size: {
|
|
204
|
+
width: { magnitude: width, unit: 'PT' },
|
|
205
|
+
height: { magnitude: height, unit: 'PT' }
|
|
206
|
+
},
|
|
207
|
+
transform: {
|
|
208
|
+
scaleX: 1,
|
|
209
|
+
scaleY: 1,
|
|
210
|
+
translateX: left,
|
|
211
|
+
translateY: top,
|
|
212
|
+
unit: 'PT'
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}];
|
|
217
|
+
|
|
218
|
+
Slides.Presentations.batchUpdate({ requests }, presentationId);
|
|
219
|
+
return this.getPageElementById(objectId).asShape();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
insertTextBox(text, left = 0, top = 0, width = 300, height = 50) {
|
|
223
|
+
const shape = this.insertShape(SlidesApp.ShapeType.TEXT_BOX, left, top, width, height);
|
|
224
|
+
if (text) shape.getText().setText(text);
|
|
225
|
+
return shape;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
insertTable(rows, columns, left = 0, top = 0, width = 300, height = 300) {
|
|
229
|
+
const presentationId = this.__presentation.getId();
|
|
230
|
+
const objectId = `table_${Math.random().toString(36).substring(2, 11)}`;
|
|
231
|
+
const requests = [{
|
|
232
|
+
createTable: {
|
|
233
|
+
objectId,
|
|
234
|
+
rows,
|
|
235
|
+
columns,
|
|
236
|
+
elementProperties: {
|
|
237
|
+
pageObjectId: this.getObjectId(),
|
|
238
|
+
size: {
|
|
239
|
+
width: { magnitude: width, unit: 'PT' },
|
|
240
|
+
height: { magnitude: height, unit: 'PT' }
|
|
241
|
+
},
|
|
242
|
+
transform: {
|
|
243
|
+
scaleX: 1,
|
|
244
|
+
scaleY: 1,
|
|
245
|
+
translateX: left,
|
|
246
|
+
translateY: top,
|
|
247
|
+
unit: 'PT'
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}];
|
|
252
|
+
|
|
253
|
+
Slides.Presentations.batchUpdate({ requests }, presentationId);
|
|
254
|
+
return this.getPageElementById(objectId).asTable();
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Inserts a video at the top left corner of the master.
|
|
259
|
+
* @param {string} videoUrl The video URL.
|
|
260
|
+
* @param {number} [left]
|
|
261
|
+
* @param {number} [top]
|
|
262
|
+
* @param {number} [width]
|
|
263
|
+
* @param {number} [height]
|
|
264
|
+
* @returns {FakeVideo} The inserted video.
|
|
265
|
+
*/
|
|
266
|
+
insertVideo(videoUrl, left = 0, top = 0, width = 300, height = 200) {
|
|
267
|
+
const presentationId = this.__presentation.getId();
|
|
268
|
+
const objectId = `video_${Math.random().toString(36).substring(2, 11)}`;
|
|
269
|
+
|
|
270
|
+
let videoId = videoUrl;
|
|
271
|
+
if (videoUrl.includes('v=')) {
|
|
272
|
+
videoId = videoUrl.split('v=')[1].split('&')[0];
|
|
273
|
+
} else if (videoUrl.includes('youtu.be/')) {
|
|
274
|
+
videoId = videoUrl.split('youtu.be/')[1].split('?')[0];
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const requests = [{
|
|
278
|
+
createVideo: {
|
|
279
|
+
objectId,
|
|
280
|
+
source: 'YOUTUBE',
|
|
281
|
+
id: videoId,
|
|
282
|
+
elementProperties: {
|
|
283
|
+
pageObjectId: this.getObjectId(),
|
|
284
|
+
size: {
|
|
285
|
+
width: { magnitude: width, unit: 'PT' },
|
|
286
|
+
height: { magnitude: height, unit: 'PT' }
|
|
287
|
+
},
|
|
288
|
+
transform: {
|
|
289
|
+
scaleX: 1,
|
|
290
|
+
scaleY: 1,
|
|
291
|
+
translateX: left,
|
|
292
|
+
translateY: top,
|
|
293
|
+
unit: 'PT'
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}];
|
|
298
|
+
|
|
299
|
+
Slides.Presentations.batchUpdate({ requests }, presentationId);
|
|
300
|
+
return this.getPageElementById(objectId).asVideo();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
insertImage(urlOrBlob, left = 0, top = 0, width = 300, height = 300) {
|
|
304
|
+
const presentationId = this.__presentation.getId();
|
|
305
|
+
const objectId = `image_${Math.random().toString(36).substring(2, 11)}`;
|
|
306
|
+
let url = typeof urlOrBlob === 'string' ? urlOrBlob : '';
|
|
307
|
+
|
|
308
|
+
const requests = [{
|
|
309
|
+
createImage: {
|
|
310
|
+
objectId,
|
|
311
|
+
url: url || 'https://via.placeholder.com/150',
|
|
312
|
+
elementProperties: {
|
|
313
|
+
pageObjectId: this.getObjectId(),
|
|
314
|
+
size: {
|
|
315
|
+
width: { magnitude: width, unit: 'PT' },
|
|
316
|
+
height: { magnitude: height, unit: 'PT' }
|
|
317
|
+
},
|
|
318
|
+
transform: {
|
|
319
|
+
scaleX: 1,
|
|
320
|
+
scaleY: 1,
|
|
321
|
+
translateX: left,
|
|
322
|
+
translateY: top,
|
|
323
|
+
unit: 'PT'
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}];
|
|
328
|
+
|
|
329
|
+
Slides.Presentations.batchUpdate({ requests }, presentationId);
|
|
330
|
+
return this.getPageElementById(objectId).asImage();
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
insertLine(lineCategory, startX, startY, endX, endY) {
|
|
334
|
+
const presentationId = this.__presentation.getId();
|
|
335
|
+
const objectId = `line_${Math.random().toString(36).substring(2, 11)}`;
|
|
336
|
+
const requests = [{
|
|
337
|
+
createLine: {
|
|
338
|
+
objectId,
|
|
339
|
+
lineCategory: lineCategory.toString(),
|
|
340
|
+
elementProperties: {
|
|
341
|
+
pageObjectId: this.getObjectId(),
|
|
342
|
+
size: {
|
|
343
|
+
width: { magnitude: Math.abs(endX - startX), unit: 'PT' },
|
|
344
|
+
height: { magnitude: Math.abs(endY - startY), unit: 'PT' }
|
|
345
|
+
},
|
|
346
|
+
transform: {
|
|
347
|
+
scaleX: 1,
|
|
348
|
+
scaleY: 1,
|
|
349
|
+
translateX: Math.min(startX, endX),
|
|
350
|
+
translateY: Math.min(startY, endY),
|
|
351
|
+
unit: 'PT'
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}];
|
|
356
|
+
|
|
357
|
+
Slides.Presentations.batchUpdate({ requests }, presentationId);
|
|
358
|
+
return this.getPageElementById(objectId).asLine();
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
remove() {
|
|
362
|
+
const presentationId = this.__presentation.getId();
|
|
363
|
+
Slides.Presentations.batchUpdate({ requests: [{
|
|
364
|
+
deleteObject: {
|
|
365
|
+
objectId: this.getObjectId()
|
|
366
|
+
}
|
|
367
|
+
}] }, presentationId);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
replaceAllText(findText, replaceText, matchCase = false) {
|
|
371
|
+
const presentationId = this.__presentation.getId();
|
|
372
|
+
Slides.Presentations.batchUpdate({ requests: [{
|
|
373
|
+
replaceAllText: {
|
|
374
|
+
replaceText,
|
|
375
|
+
containsText: {
|
|
376
|
+
text: findText,
|
|
377
|
+
matchCase
|
|
378
|
+
},
|
|
379
|
+
pageObjectIds: [this.getObjectId()]
|
|
380
|
+
}
|
|
381
|
+
}] }, presentationId);
|
|
382
|
+
return this;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
selectAsCurrentPage() {
|
|
386
|
+
return this;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
asLayout() { throw new Error('Cannot cast Master to Layout'); }
|
|
390
|
+
asSlide() { throw new Error('Cannot cast Master to Slide'); }
|
|
391
|
+
asMaster() { return this; }
|
|
392
|
+
|
|
35
393
|
toString() {
|
|
36
394
|
return 'Master';
|
|
37
395
|
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Proxies } from '../../support/proxies.js';
|
|
2
|
+
import { newFakeColorScheme } from './fakecolorscheme.js';
|
|
3
|
+
import { newFakePageBackground } from './fakepagebackground.js';
|
|
4
|
+
import { newFakePageElement } from './fakepageelement.js';
|
|
5
|
+
|
|
6
|
+
export const newFakeNotesMaster = (...args) => {
|
|
7
|
+
return Proxies.guard(new FakeNotesMaster(...args));
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export class FakeNotesMaster {
|
|
11
|
+
constructor(resource, presentation) {
|
|
12
|
+
this.__id = resource.objectId;
|
|
13
|
+
this.__presentation = presentation;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get __resource() {
|
|
17
|
+
const presentationResource = this.__presentation.__resource;
|
|
18
|
+
const notesMaster = presentationResource.notesMaster;
|
|
19
|
+
if (!notesMaster || notesMaster.objectId !== this.__id) {
|
|
20
|
+
throw new Error(`NotesMaster with ID ${this.__id} not found`);
|
|
21
|
+
}
|
|
22
|
+
return notesMaster;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getObjectId() {
|
|
26
|
+
return this.__id;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Gets the background of the notes master.
|
|
31
|
+
* @returns {FakePageBackground} The background.
|
|
32
|
+
*/
|
|
33
|
+
getBackground() {
|
|
34
|
+
return newFakePageBackground(this);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Gets the color scheme of the notes master.
|
|
39
|
+
* @returns {FakeColorScheme} The color scheme.
|
|
40
|
+
*/
|
|
41
|
+
getColorScheme() {
|
|
42
|
+
return newFakeColorScheme(this);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Gets the list of page elements on the notes master.
|
|
47
|
+
* @returns {FakePageElement[]} The page elements.
|
|
48
|
+
*/
|
|
49
|
+
getPageElements() {
|
|
50
|
+
return (this.__resource.pageElements || []).map(pe => newFakePageElement(pe, this));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Gets a page element by ID.
|
|
55
|
+
* @param {string} id The ID.
|
|
56
|
+
* @returns {FakePageElement|null} The element.
|
|
57
|
+
*/
|
|
58
|
+
getPageElementById(id) {
|
|
59
|
+
return this.getPageElements().find(pe => pe.getObjectId() === id) || null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
getGroups() {
|
|
63
|
+
return this.getPageElements()
|
|
64
|
+
.filter(pe => pe.getPageElementType().toString() === 'GROUP')
|
|
65
|
+
.map(pe => pe.asGroup());
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
getImages() {
|
|
69
|
+
return this.getPageElements()
|
|
70
|
+
.filter(pe => pe.getPageElementType().toString() === 'IMAGE')
|
|
71
|
+
.map(pe => pe.asImage());
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
getLines() {
|
|
75
|
+
return this.getPageElements()
|
|
76
|
+
.filter(pe => pe.getPageElementType().toString() === 'LINE')
|
|
77
|
+
.map(pe => pe.asLine());
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
getShapes() {
|
|
81
|
+
return this.getPageElements()
|
|
82
|
+
.filter(pe => pe.getPageElementType().toString() === 'SHAPE')
|
|
83
|
+
.map(pe => pe.asShape());
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
getTables() {
|
|
87
|
+
return this.getPageElements()
|
|
88
|
+
.filter(pe => pe.getPageElementType().toString() === 'TABLE')
|
|
89
|
+
.map(pe => pe.asTable());
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
getVideos() {
|
|
93
|
+
return this.getPageElements()
|
|
94
|
+
.filter(pe => pe.getPageElementType().toString() === 'VIDEO')
|
|
95
|
+
.map(pe => pe.asVideo());
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
getWordArts() {
|
|
99
|
+
return this.getPageElements()
|
|
100
|
+
.filter(pe => pe.getPageElementType().toString() === 'WORD_ART')
|
|
101
|
+
.map(pe => pe.asWordArt());
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
getSheetsCharts() {
|
|
105
|
+
return this.getPageElements()
|
|
106
|
+
.filter(pe => pe.getPageElementType().toString() === 'SHEETS_CHART')
|
|
107
|
+
.map(pe => pe.asSheetsChart());
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
getPlaceholders() {
|
|
111
|
+
return this.getPageElements().filter(pe => pe.__resource.shape?.placeholder || pe.__resource.image?.placeholder);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
getPlaceholder(placeholderType, index = 0) {
|
|
115
|
+
const typeStr = placeholderType.toString();
|
|
116
|
+
return this.getPlaceholders().find(p => {
|
|
117
|
+
const ph = p.__resource.shape?.placeholder || p.__resource.image?.placeholder;
|
|
118
|
+
return ph.type === typeStr && (ph.index === index || (index === 0 && ph.index === undefined));
|
|
119
|
+
}) || null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
toString() {
|
|
123
|
+
return 'NotesMaster';
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Proxies } from '../../support/proxies.js';
|
|
2
|
+
import { newFakePageBackground } from './fakepagebackground.js';
|
|
3
|
+
import { newFakeColorScheme } from './fakecolorscheme.js';
|
|
4
|
+
import { newFakePageElement } from './fakepageelement.js';
|
|
2
5
|
|
|
3
6
|
export const newFakeNotesPage = (...args) => {
|
|
4
7
|
return Proxies.guard(new FakeNotesPage(...args));
|
|
@@ -8,11 +11,108 @@ export class FakeNotesPage {
|
|
|
8
11
|
constructor(slide) {
|
|
9
12
|
this.__slide = slide;
|
|
10
13
|
}
|
|
14
|
+
|
|
11
15
|
get __resource() {
|
|
12
|
-
// notesPage is a property of slideProperties
|
|
13
16
|
const notesPage = this.__slide.__resource.slideProperties?.notesPage;
|
|
14
|
-
|
|
17
|
+
if (!notesPage) {
|
|
18
|
+
throw new Error(`NotesPage not found for slide ${this.__slide.getObjectId()}`);
|
|
19
|
+
}
|
|
20
|
+
return notesPage;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getObjectId() {
|
|
24
|
+
return this.__resource.objectId;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getBackground() {
|
|
28
|
+
return newFakePageBackground(this);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
getColorScheme() {
|
|
32
|
+
return newFakeColorScheme(this);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getPageElements() {
|
|
36
|
+
return (this.__resource.pageElements || []).map(pe => newFakePageElement(pe, this));
|
|
15
37
|
}
|
|
38
|
+
|
|
39
|
+
getPageElementById(id) {
|
|
40
|
+
return this.getPageElements().find(pe => pe.getObjectId() === id) || null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getGroups() {
|
|
44
|
+
return this.getPageElements()
|
|
45
|
+
.filter(pe => pe.getPageElementType().toString() === 'GROUP')
|
|
46
|
+
.map(pe => pe.asGroup());
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
getImages() {
|
|
50
|
+
return this.getPageElements()
|
|
51
|
+
.filter(pe => pe.getPageElementType().toString() === 'IMAGE')
|
|
52
|
+
.map(pe => pe.asImage());
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
getLines() {
|
|
56
|
+
return this.getPageElements()
|
|
57
|
+
.filter(pe => pe.getPageElementType().toString() === 'LINE')
|
|
58
|
+
.map(pe => pe.asLine());
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
getShapes() {
|
|
62
|
+
return this.getPageElements()
|
|
63
|
+
.filter(pe => pe.getPageElementType().toString() === 'SHAPE')
|
|
64
|
+
.map(pe => pe.asShape());
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
getTables() {
|
|
68
|
+
return this.getPageElements()
|
|
69
|
+
.filter(pe => pe.getPageElementType().toString() === 'TABLE')
|
|
70
|
+
.map(pe => pe.asTable());
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
getVideos() {
|
|
74
|
+
return this.getPageElements()
|
|
75
|
+
.filter(pe => pe.getPageElementType().toString() === 'VIDEO')
|
|
76
|
+
.map(pe => pe.asVideo());
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
getWordArts() {
|
|
80
|
+
return this.getPageElements()
|
|
81
|
+
.filter(pe => pe.getPageElementType().toString() === 'WORD_ART')
|
|
82
|
+
.map(pe => pe.asWordArt());
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
getSheetsCharts() {
|
|
86
|
+
return this.getPageElements()
|
|
87
|
+
.filter(pe => pe.getPageElementType().toString() === 'SHEETS_CHART')
|
|
88
|
+
.map(pe => pe.asSheetsChart());
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
getSpeakerNotesShape() {
|
|
92
|
+
// In Google Slides, speaker notes are usually in a placeholder of type BODY or SLIDE_NUMBER on the notes page
|
|
93
|
+
// Actually, there's a specific placeholder for speaker notes.
|
|
94
|
+
return this.getPlaceholders().find(p => {
|
|
95
|
+
const ph = p.__resource.shape?.placeholder;
|
|
96
|
+
return ph?.type === 'BODY'; // Typical for speaker notes in API
|
|
97
|
+
})?.asShape() || null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
getPlaceholders() {
|
|
101
|
+
return this.getPageElements().filter(pe => pe.__resource.shape?.placeholder || pe.__resource.image?.placeholder);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
getPlaceholder(placeholderType, index = 0) {
|
|
105
|
+
const typeStr = placeholderType.toString();
|
|
106
|
+
return this.getPlaceholders().find(p => {
|
|
107
|
+
const ph = p.__resource.shape?.placeholder || p.__resource.image?.placeholder;
|
|
108
|
+
return ph.type === typeStr && (ph.index === index || (index === 0 && ph.index === undefined));
|
|
109
|
+
}) || null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
asLayout() { throw new Error('Cannot cast NotesPage to Layout'); }
|
|
113
|
+
asSlide() { throw new Error('Cannot cast NotesPage to Slide'); }
|
|
114
|
+
asMaster() { throw new Error('Cannot cast NotesPage to Master'); }
|
|
115
|
+
|
|
16
116
|
toString() {
|
|
17
117
|
return 'NotesPage';
|
|
18
118
|
}
|