@mcpher/gas-fakes 2.0.14 → 2.0.16
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/package.json
CHANGED
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"zod": "^4.3.6"
|
|
26
26
|
},
|
|
27
27
|
"overrides": {
|
|
28
|
-
"minimatch": "^10.2.1",
|
|
29
28
|
"glob": "^13.0.0",
|
|
30
29
|
"rimraf": "^6.1.3",
|
|
30
|
+
"minimatch": "^10.2.1",
|
|
31
31
|
"node-domexception": "^1.0.0"
|
|
32
32
|
},
|
|
33
33
|
"type": "module",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"name": "@mcpher/gas-fakes",
|
|
41
41
|
"author": "bruce mcpherson",
|
|
42
|
-
"version": "2.0.
|
|
42
|
+
"version": "2.0.16",
|
|
43
43
|
"license": "MIT",
|
|
44
44
|
"main": "main.js",
|
|
45
45
|
"description": "An implementation of the Google Workspace Apps Script runtime: Run native App Script Code on Node and Cloud Run",
|
|
@@ -86,6 +86,26 @@ export class FakeSlide {
|
|
|
86
86
|
return background ? newFakePageBackground(this) : null;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Gets the list of tables on the slide.
|
|
91
|
+
* @returns {FakeTable[]} The tables.
|
|
92
|
+
*/
|
|
93
|
+
getTables() {
|
|
94
|
+
return this.getPageElements()
|
|
95
|
+
.filter(pe => pe.toString() === 'Table')
|
|
96
|
+
.map(pe => pe.asTable());
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Gets the list of shapes on the slide.
|
|
101
|
+
* @returns {FakeShape[]} The shapes.
|
|
102
|
+
*/
|
|
103
|
+
getShapes() {
|
|
104
|
+
return this.getPageElements()
|
|
105
|
+
.filter(pe => pe.toString() === 'Shape')
|
|
106
|
+
.map(pe => pe.asShape());
|
|
107
|
+
}
|
|
108
|
+
|
|
89
109
|
/**
|
|
90
110
|
* Deletes the slide.
|
|
91
111
|
*/
|
|
@@ -367,6 +387,30 @@ export class FakeSlide {
|
|
|
367
387
|
}], presentationId);
|
|
368
388
|
}
|
|
369
389
|
|
|
390
|
+
/**
|
|
391
|
+
* Replaces all instances of text matching a find string with a replace string.
|
|
392
|
+
* @param {string} findText The text to find.
|
|
393
|
+
* @param {string} replaceText The text to replace with.
|
|
394
|
+
* @param {boolean} matchCase Whether to match case.
|
|
395
|
+
* @returns {number} The number of occurrences replaced.
|
|
396
|
+
*/
|
|
397
|
+
replaceAllText(findText, replaceText, matchCase) {
|
|
398
|
+
const presentationId = this.__presentation.getId();
|
|
399
|
+
const requests = [{
|
|
400
|
+
replaceAllText: {
|
|
401
|
+
replaceText: replaceText,
|
|
402
|
+
containsText: {
|
|
403
|
+
text: findText,
|
|
404
|
+
matchCase: matchCase
|
|
405
|
+
},
|
|
406
|
+
pageObjectIds: [this.getObjectId()]
|
|
407
|
+
}
|
|
408
|
+
}];
|
|
409
|
+
|
|
410
|
+
const response = Slides.Presentations.batchUpdate(requests, presentationId);
|
|
411
|
+
return response.replies[0].replaceAllText.occurrencesChanged || 0;
|
|
412
|
+
}
|
|
413
|
+
|
|
370
414
|
toString() {
|
|
371
415
|
return 'Slide';
|
|
372
416
|
}
|
|
@@ -22,8 +22,8 @@ export class FakeTable extends FakePageElement {
|
|
|
22
22
|
* @returns {FakeTableRow[]} The rows.
|
|
23
23
|
*/
|
|
24
24
|
getRows() {
|
|
25
|
-
return (this.__resource.table?.tableRows || []).map((
|
|
26
|
-
newFakeTableRow(
|
|
25
|
+
return (this.__resource.table?.tableRows || []).map((_, index) =>
|
|
26
|
+
newFakeTableRow(this, index)
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -6,13 +6,16 @@ export const newFakeTableCell = (...args) => {
|
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
export class FakeTableCell {
|
|
9
|
-
constructor(
|
|
10
|
-
this.__resource = resource;
|
|
9
|
+
constructor(table, rowIndex, colIndex) {
|
|
11
10
|
this.__table = table;
|
|
12
11
|
this.__rowIndex = rowIndex;
|
|
13
12
|
this.__colIndex = colIndex;
|
|
14
13
|
}
|
|
15
14
|
|
|
15
|
+
get __resource() {
|
|
16
|
+
return this.__table.__resource.table?.tableRows?.[this.__rowIndex]?.tableCells?.[this.__colIndex];
|
|
17
|
+
}
|
|
18
|
+
|
|
16
19
|
/**
|
|
17
20
|
* Gets the text in the cell.
|
|
18
21
|
* @returns {FakeTextRange} The text range.
|
|
@@ -30,7 +33,7 @@ export class FakeTableCell {
|
|
|
30
33
|
getObjectId: () => this.__table.getObjectId(),
|
|
31
34
|
__resource: {
|
|
32
35
|
shape: {
|
|
33
|
-
text: this.__resource
|
|
36
|
+
text: this.__resource?.text || { textElements: [] }
|
|
34
37
|
}
|
|
35
38
|
},
|
|
36
39
|
__cellLocation: {
|
|
@@ -39,9 +42,6 @@ export class FakeTableCell {
|
|
|
39
42
|
},
|
|
40
43
|
__presentation: this.__table.__presentation
|
|
41
44
|
};
|
|
42
|
-
if (!this.__resource.text) {
|
|
43
|
-
this.__resource.text = mockShape.__resource.shape.text;
|
|
44
|
-
}
|
|
45
45
|
return newFakeTextRange(mockShape);
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -6,19 +6,22 @@ export const newFakeTableRow = (...args) => {
|
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
export class FakeTableRow {
|
|
9
|
-
constructor(
|
|
10
|
-
this.__resource = resource;
|
|
9
|
+
constructor(table, rowIndex) {
|
|
11
10
|
this.__table = table;
|
|
12
11
|
this.__rowIndex = rowIndex;
|
|
13
12
|
}
|
|
14
13
|
|
|
14
|
+
get __resource() {
|
|
15
|
+
return this.__table.__resource.table?.tableRows?.[this.__rowIndex];
|
|
16
|
+
}
|
|
17
|
+
|
|
15
18
|
/**
|
|
16
19
|
* Gets the cells in the row.
|
|
17
20
|
* @returns {FakeTableCell[]} The cells.
|
|
18
21
|
*/
|
|
19
22
|
getCells() {
|
|
20
|
-
return (this.__resource
|
|
21
|
-
newFakeTableCell(
|
|
23
|
+
return (this.__resource?.tableCells || []).map((_, colIndex) =>
|
|
24
|
+
newFakeTableCell(this.__table, this.__rowIndex, colIndex)
|
|
22
25
|
);
|
|
23
26
|
}
|
|
24
27
|
|
|
@@ -40,7 +43,7 @@ export class FakeTableRow {
|
|
|
40
43
|
* @returns {number} The number of cells.
|
|
41
44
|
*/
|
|
42
45
|
getNumCells() {
|
|
43
|
-
return (this.__resource
|
|
46
|
+
return (this.__resource?.tableCells || []).length;
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
toString() {
|