forked from Neo-Hao/referencer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtext.gs
41 lines (36 loc) · 1017 Bytes
/
text.gs
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
/**
* update the text of textOjb to newText
*
* @param: textOjb - a text object
* newText - string
* start - int, where the old text starts
* end - int, where the old text ends
* .
* @returns
*/
function updateText(textObj, newText, start, end) {
textObj.deleteText(start, end)
textObj.insertText(start, newText);
}
function updateText2(textObj, newText) {
textObj.setText(newText);
}
/**
* update the text of textOjb to newText, and add url to the newText
*
* @param: textOjb - a text object
* newText - string
* start - int, where the old text starts
* end - int, where the old text ends
* url - str, link
* .
* @returns
*/
function updateLinkText(textObj, newText, start, end, url) {
// Logger.log('start: ' + start);
// Logger.log('end: ' + end);
textObj.deleteText(start, end)
textObj.insertText(start, newText);
textObj.setLinkUrl(start, start + newText.length - 1, url);
return start + newText.length - 1 - end;
}