-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupportFile.gs
More file actions
68 lines (52 loc) · 1.47 KB
/
supportFile.gs
File metadata and controls
68 lines (52 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const Image_Title = "Math_Equation_Generated"
function getCurrentSlide()
{
return SlidesApp.getActivePresentation().getSelection().getCurrentPage();
}
function convertBase64StringToBlob(base64String){
return Utilities.newBlob(Utilities.base64Decode(base64String), MimeType.PNG);
}
function findImageSlide(imageObjectId){
var slide = getCurrentSlide();
var allImage = slide.getImages();
var imageSlide = undefined;
for(var i = 0; i < allImage.length; i++)
{
if(allImage[i].getObjectId() == imageObjectId){
imageSlide = allImage[i]
}
}
if(imageSlide == undefined){throw "coudn't get image"}
return imageSlide;
}
function getImageProps(image){
let title = image.getTitle();
let description = image.getDescription();
var newDescription;
if(title == Image_Title)
{
try{
newDescription = JSON.parse(description);
}
catch(e){
throw "bad image description - " + description
}
}
//old way of doing it
else if(title.search("MathEquation") != -1)
{
var color = description.split(",")[1];
var newDescription = {
"mathType": "LaTEX", //i never actually saved the type
"color": color,
"text": description
};
image.setTitle(Image_Title);
image.setDescription(JSON.stringify(newDescription));
}
else{
throw "doesn't look like this image has a math equation attached to it";
}
newDescription["height"] = Math.round(image.getHeight()) * 2;
return newDescription;
}