-
Notifications
You must be signed in to change notification settings - Fork 0
/
Code.gs
40 lines (35 loc) · 1.02 KB
/
Code.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
function onOpen(e) {
DocumentApp.getUi().createAddonMenu()
.addItem('Start', 'showSidebar')
.addToUi();
showSidebar()
}
function onInstall(e) {
onOpen(e);
}
function showSidebar() {
var ui = HtmlService.createHtmlOutputFromFile('Interface')
.setTitle('Easy Highlighter')
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
DocumentApp.getUi().showSidebar(ui);
}
let trigger;
const highlighter = function(){
DocumentApp.getUi().alert('Hello, world');
let selection = DocumentApp.getActiveDocument().getSelection();
if(selection){
selection.getRangeElements().forEach(e => {
let range = [e.getStartOffset(), e.getEndOffsetInclusive()];
e.getElement().editAsText()
.setBackgroundColor(...range, '#FFFF00')
});
}
}
const highlight = function(){
DocumentApp.getUi().alert('Hello, world2');
trigger = ScriptApp.newTrigger('highlighter')
.forDocument(DocumentApp.getActiveDocument())
.timeBased()
.everyMinutes(1)
.create();
}