forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
google-apps-script.document.d.ts
1482 lines (1440 loc) · 61.9 KB
/
google-apps-script.document.d.ts
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for Google Apps Script 2015-11-12
// Project: https://developers.google.com/apps-script/
// Definitions by: motemen <https://github.com/motemen/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="google-apps-script.types.d.ts" />
/// <reference path="google-apps-script.base.d.ts" />
declare namespace GoogleAppsScript {
export module Document {
/**
* An enumeration of the element attributes.
*
* Use attributes to compose custom styles. For example:
*
* // Define a style with yellow background.
* var highlightStyle = {};
* highlightStyle[DocumentApp.Attribute.BACKGROUND_COLOR] = '#FFFF00';
* highlightStyle[DocumentApp.Attribute.BOLD] = true;
*
* // Insert "Hello", highlighted.
* DocumentApp.getActiveDocument().editAsText()
* .insertText(0, 'Hello\n')
* .setAttributes(0, 4, highlightStyle);
*/
export enum Attribute { BACKGROUND_COLOR, BOLD, BORDER_COLOR, BORDER_WIDTH, CODE, FONT_FAMILY, FONT_SIZE, FOREGROUND_COLOR, HEADING, HEIGHT, HORIZONTAL_ALIGNMENT, INDENT_END, INDENT_FIRST_LINE, INDENT_START, ITALIC, GLYPH_TYPE, LEFT_TO_RIGHT, LINE_SPACING, LINK_URL, LIST_ID, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT, MARGIN_TOP, NESTING_LEVEL, MINIMUM_HEIGHT, PADDING_BOTTOM, PADDING_LEFT, PADDING_RIGHT, PADDING_TOP, PAGE_HEIGHT, PAGE_WIDTH, SPACING_AFTER, SPACING_BEFORE, STRIKETHROUGH, UNDERLINE, VERTICAL_ALIGNMENT, WIDTH }
/**
* An element representing a document body. The Body may contain ListItem,
* Paragraph, Table, and TableOfContents elements. For more information on
* document structure, see the
* guide to extending Google Docs.
*
* The Body typically contains the full document contents except for the
* HeaderSection, FooterSection, and any FootnoteSection elements.
*
* var doc = DocumentApp.getActiveDocument();
* var body = doc.getBody();
*
* // Append a paragraph and a page break to the document body section directly.
* body.appendParagraph("A paragraph.");
* body.appendPageBreak();
*/
export interface Body {
appendHorizontalRule(): HorizontalRule;
appendImage(image: Base.BlobSource): InlineImage;
appendImage(image: InlineImage): InlineImage;
appendListItem(listItem: ListItem): ListItem;
appendListItem(text: string): ListItem;
appendPageBreak(): PageBreak;
appendPageBreak(pageBreak: PageBreak): PageBreak;
appendParagraph(paragraph: Paragraph): Paragraph;
appendParagraph(text: string): Paragraph;
appendTable(): Table;
appendTable(cells: String[][]): Table;
appendTable(table: Table): Table;
clear(): Body;
copy(): Body;
editAsText(): Text;
findElement(elementType: ElementType): RangeElement;
findElement(elementType: ElementType, from: RangeElement): RangeElement;
findText(searchPattern: string): RangeElement;
findText(searchPattern: string, from: RangeElement): RangeElement;
getAttributes(): Object;
getChild(childIndex: Integer): Element;
getChildIndex(child: Element): Integer;
getImages(): InlineImage[];
getListItems(): ListItem[];
getMarginBottom(): Number;
getMarginLeft(): Number;
getMarginRight(): Number;
getMarginTop(): Number;
getNumChildren(): Integer;
getPageHeight(): Number;
getPageWidth(): Number;
getParagraphs(): Paragraph[];
getParent(): ContainerElement;
getTables(): Table[];
getText(): string;
getTextAlignment(): TextAlignment;
getType(): ElementType;
insertHorizontalRule(childIndex: Integer): HorizontalRule;
insertImage(childIndex: Integer, image: Base.BlobSource): InlineImage;
insertImage(childIndex: Integer, image: InlineImage): InlineImage;
insertListItem(childIndex: Integer, listItem: ListItem): ListItem;
insertListItem(childIndex: Integer, text: string): ListItem;
insertPageBreak(childIndex: Integer): PageBreak;
insertPageBreak(childIndex: Integer, pageBreak: PageBreak): PageBreak;
insertParagraph(childIndex: Integer, paragraph: Paragraph): Paragraph;
insertParagraph(childIndex: Integer, text: string): Paragraph;
insertTable(childIndex: Integer): Table;
insertTable(childIndex: Integer, cells: String[][]): Table;
insertTable(childIndex: Integer, table: Table): Table;
removeChild(child: Element): Body;
replaceText(searchPattern: string, replacement: string): Element;
setAttributes(attributes: Object): Body;
setMarginBottom(marginBottom: Number): Body;
setMarginLeft(marginLeft: Number): Body;
setMarginRight(marginRight: Number): Body;
setMarginTop(marginTop: Number): Body;
setPageHeight(pageHeight: Number): Body;
setPageWidth(pageWidth: Number): Body;
setText(text: string): Body;
setTextAlignment(textAlignment: TextAlignment): Body;
getFootnotes(): Footnote[];
getLinkUrl(): string;
getNextSibling(): Element;
getPreviousSibling(): Element;
isAtDocumentEnd(): boolean;
setLinkUrl(url: string): Body;
}
/**
* An object representing a bookmark.
*
* // Insert a bookmark at the cursor position and log its ID.
* var doc = DocumentApp.getActiveDocument();
* var cursor = doc.getCursor();
* var bookmark = doc.addBookmark(cursor);
* Logger.log(bookmark.getId());
*/
export interface Bookmark {
getId(): string;
getPosition(): Position;
remove(): void;
}
/**
* A generic element that may contain other elements. All elements that may contain child elements,
* such as Paragraph, inherit from ContainerElement.
*/
export interface ContainerElement {
asBody(): Body;
asEquation(): Equation;
asFooterSection(): FooterSection;
asFootnoteSection(): FootnoteSection;
asHeaderSection(): HeaderSection;
asListItem(): ListItem;
asParagraph(): Paragraph;
asTable(): Table;
asTableCell(): TableCell;
asTableOfContents(): TableOfContents;
asTableRow(): TableRow;
clear(): ContainerElement;
copy(): ContainerElement;
editAsText(): Text;
findElement(elementType: ElementType): RangeElement;
findElement(elementType: ElementType, from: RangeElement): RangeElement;
findText(searchPattern: string): RangeElement;
findText(searchPattern: string, from: RangeElement): RangeElement;
getAttributes(): Object;
getChild(childIndex: Integer): Element;
getChildIndex(child: Element): Integer;
getLinkUrl(): string;
getNextSibling(): Element;
getNumChildren(): Integer;
getParent(): ContainerElement;
getPreviousSibling(): Element;
getText(): string;
getTextAlignment(): TextAlignment;
getType(): ElementType;
isAtDocumentEnd(): boolean;
merge(): ContainerElement;
removeFromParent(): ContainerElement;
replaceText(searchPattern: string, replacement: string): Element;
setAttributes(attributes: Object): ContainerElement;
setLinkUrl(url: string): ContainerElement;
setTextAlignment(textAlignment: TextAlignment): ContainerElement;
}
/**
* A document, containing rich text and elements such as tables and lists.
*
* Documents may be opened or created using DocumentApp.
*
* // Open a document by ID.
* var doc = DocumentApp.openById("<my-id>");
*
* // Create and open a document.
* doc = DocumentApp.create("Document Title");
*/
export interface Document {
addBookmark(position: Position): Bookmark;
addEditor(emailAddress: string): Document;
addEditor(user: Base.User): Document;
addEditors(emailAddresses: String[]): Document;
addFooter(): FooterSection;
addHeader(): HeaderSection;
addNamedRange(name: string, range: Range): NamedRange;
addViewer(emailAddress: string): Document;
addViewer(user: Base.User): Document;
addViewers(emailAddresses: String[]): Document;
getAs(contentType: string): Base.Blob;
getBlob(): Base.Blob;
getBody(): Body;
getBookmark(id: string): Bookmark;
getBookmarks(): Bookmark[];
getCursor(): Position;
getEditors(): Base.User[];
getFooter(): FooterSection;
getFootnotes(): Footnote[];
getHeader(): HeaderSection;
getId(): string;
getName(): string;
getNamedRangeById(id: string): NamedRange;
getNamedRanges(): NamedRange[];
getNamedRanges(name: string): NamedRange[];
getSelection(): Range;
getUrl(): string;
getViewers(): Base.User[];
newPosition(element: Element, offset: Integer): Position;
newRange(): RangeBuilder;
removeEditor(emailAddress: string): Document;
removeEditor(user: Base.User): Document;
removeViewer(emailAddress: string): Document;
removeViewer(user: Base.User): Document;
saveAndClose(): void;
setCursor(position: Position): Document;
setName(name: string): Document;
setSelection(range: Range): Document;
}
/**
* The document service creates and opens Documents that can be edited.
*
* // Open a document by ID.
* var doc = DocumentApp.openById('DOCUMENT_ID_GOES_HERE');
*
* // Create and open a document.
* doc = DocumentApp.create('Document Name');
*/
export interface DocumentApp {
Attribute: Attribute
ElementType: ElementType
FontFamily: FontFamily
GlyphType: GlyphType
HorizontalAlignment: HorizontalAlignment
ParagraphHeading: ParagraphHeading
TextAlignment: TextAlignment
VerticalAlignment: VerticalAlignment
create(name: string): Document;
getActiveDocument(): Document;
getUi(): Base.Ui;
openById(id: string): Document;
openByUrl(url: string): Document;
}
/**
* A generic element. Document contents are
* represented as elements. For example, ListItem, Paragraph, and Table
* are elements and inherit all of the methods defined by Element, such as
* getType().
* Implementing classes
*
* NameBrief description
*
* BodyAn element representing a document body.
*
* ContainerElementA generic element that may contain other elements.
*
* EquationAn element representing a mathematical expression.
*
* EquationFunctionAn element representing a function in a mathematical Equation.
*
* EquationFunctionArgumentSeparatorAn element representing a function separator in a mathematical Equation.
*
* EquationSymbolAn element representing a symbol in a mathematical Equation.
*
* FooterSectionAn element representing a footer section.
*
* FootnoteAn element representing a footnote.
*
* FootnoteSectionAn element representing a footnote section.
*
* HeaderSectionAn element representing a header section.
*
* HorizontalRuleAn element representing an horizontal rule.
*
* InlineDrawingAn element representing an embedded drawing.
*
* InlineImageAn element representing an embedded image.
*
* ListItemAn element representing a list item.
*
* PageBreakAn element representing a page break.
*
* ParagraphAn element representing a paragraph.
*
* TableAn element representing a table.
*
* TableCellAn element representing a table cell.
*
* TableOfContentsAn element containing a table of contents.
*
* TableRowAn element representing a table row.
*
* TextAn element representing a rich text region.
*
* UnsupportedElementAn element representing a region that is unknown or cannot be affected by a script, such as a
* page number.
*/
export interface Element {
asBody(): Body;
asEquation(): Equation;
asEquationFunction(): EquationFunction;
asEquationFunctionArgumentSeparator(): EquationFunctionArgumentSeparator;
asEquationSymbol(): EquationSymbol;
asFooterSection(): FooterSection;
asFootnote(): Footnote;
asFootnoteSection(): FootnoteSection;
asHeaderSection(): HeaderSection;
asHorizontalRule(): HorizontalRule;
asInlineDrawing(): InlineDrawing;
asInlineImage(): InlineImage;
asListItem(): ListItem;
asPageBreak(): PageBreak;
asParagraph(): Paragraph;
asTable(): Table;
asTableCell(): TableCell;
asTableOfContents(): TableOfContents;
asTableRow(): TableRow;
asText(): Text;
copy(): Element;
getAttributes(): Object;
getNextSibling(): Element;
getParent(): ContainerElement;
getPreviousSibling(): Element;
getType(): ElementType;
isAtDocumentEnd(): boolean;
merge(): Element;
removeFromParent(): Element;
setAttributes(attributes: Object): Element;
}
/**
* An enumeration of all the element types.
*
* Use the ElementType enumeration to check the type of a given
* element, for instance:
*
* var firstChild = DocumentApp.getActiveDocument().getBody().getChild(0);
* if (firstChild.getType() == DocumentApp.ElementType.PARAGRAPH) {
* // It's a paragraph, apply a paragraph heading.
* firstChild.asParagraph().setHeading(DocumentApp.ParagraphHeading.HEADING1);
* }
*/
export enum ElementType { BODY_SECTION, COMMENT_SECTION, DOCUMENT, EQUATION, EQUATION_FUNCTION, EQUATION_FUNCTION_ARGUMENT_SEPARATOR, EQUATION_SYMBOL, FOOTER_SECTION, FOOTNOTE, FOOTNOTE_SECTION, HEADER_SECTION, HORIZONTAL_RULE, INLINE_DRAWING, INLINE_IMAGE, LIST_ITEM, PAGE_BREAK, PARAGRAPH, TABLE, TABLE_CELL, TABLE_OF_CONTENTS, TABLE_ROW, TEXT, UNSUPPORTED }
/**
* An element representing a mathematical expression. An Equation may contain
* EquationFunction, EquationSymbol, and Text elements. For more
* information on document structure, see the
* guide to extending Google Docs.
*/
export interface Equation {
clear(): Equation;
copy(): Equation;
editAsText(): Text;
findElement(elementType: ElementType): RangeElement;
findElement(elementType: ElementType, from: RangeElement): RangeElement;
findText(searchPattern: string): RangeElement;
findText(searchPattern: string, from: RangeElement): RangeElement;
getAttributes(): Object;
getChild(childIndex: Integer): Element;
getChildIndex(child: Element): Integer;
getLinkUrl(): string;
getNextSibling(): Element;
getNumChildren(): Integer;
getParent(): ContainerElement;
getPreviousSibling(): Element;
getText(): string;
getTextAlignment(): TextAlignment;
getType(): ElementType;
isAtDocumentEnd(): boolean;
merge(): Equation;
removeFromParent(): Equation;
replaceText(searchPattern: string, replacement: string): Element;
setAttributes(attributes: Object): Equation;
setLinkUrl(url: string): Equation;
setTextAlignment(textAlignment: TextAlignment): Equation;
}
/**
* An element representing a function in a mathematical Equation. An
* EquationFunction may contain EquationFunction,
* EquationFunctionArgumentSeparator, EquationSymbol, and Text elements. For
* more information on document structure, see the
* guide to extending Google Docs.
*/
export interface EquationFunction {
clear(): EquationFunction;
copy(): EquationFunction;
editAsText(): Text;
findElement(elementType: ElementType): RangeElement;
findElement(elementType: ElementType, from: RangeElement): RangeElement;
findText(searchPattern: string): RangeElement;
findText(searchPattern: string, from: RangeElement): RangeElement;
getAttributes(): Object;
getChild(childIndex: Integer): Element;
getChildIndex(child: Element): Integer;
getCode(): string;
getLinkUrl(): string;
getNextSibling(): Element;
getNumChildren(): Integer;
getParent(): ContainerElement;
getPreviousSibling(): Element;
getText(): string;
getTextAlignment(): TextAlignment;
getType(): ElementType;
isAtDocumentEnd(): boolean;
merge(): EquationFunction;
removeFromParent(): EquationFunction;
replaceText(searchPattern: string, replacement: string): Element;
setAttributes(attributes: Object): EquationFunction;
setLinkUrl(url: string): EquationFunction;
setTextAlignment(textAlignment: TextAlignment): EquationFunction;
}
/**
* An element representing a function separator in a mathematical Equation. An
* EquationFunctionArgumentSeparator cannot contain any other element. For more information
* on document structure, see the
* guide to extending Google Docs.
*/
export interface EquationFunctionArgumentSeparator {
copy(): EquationFunctionArgumentSeparator;
getAttributes(): Object;
getNextSibling(): Element;
getParent(): ContainerElement;
getPreviousSibling(): Element;
getType(): ElementType;
isAtDocumentEnd(): boolean;
merge(): EquationFunctionArgumentSeparator;
removeFromParent(): EquationFunctionArgumentSeparator;
setAttributes(attributes: Object): EquationFunctionArgumentSeparator;
}
/**
* An element representing a symbol in a mathematical Equation. An EquationSymbol
* cannot contain any other element. For more information on document structure, see the
* guide to extending Google Docs.
*/
export interface EquationSymbol {
copy(): EquationSymbol;
getAttributes(): Object;
getCode(): string;
getNextSibling(): Element;
getParent(): ContainerElement;
getPreviousSibling(): Element;
getType(): ElementType;
isAtDocumentEnd(): boolean;
merge(): EquationSymbol;
removeFromParent(): EquationSymbol;
setAttributes(attributes: Object): EquationSymbol;
}
/**
*
* Deprecated. The methods getFontFamily() and setFontFamily(String) now use string
* names for fonts instead of this enum. Although this enum is deprecated, it will remain
* available for compatibility with older scripts.
* An enumeration of the supported fonts.
*
* Use the FontFamily enumeration to set the font for a range of
* text, element or document.
*
* var body = DocumentApp.getActiveDocument().getBody();
*
* // Insert a paragraph at the start of the document.
* body.insertParagraph(0, "Hello, Apps Script!");
*
* // Set the document font to Calibri.
* body.editAsText().setFontFamily(DocumentApp.FontFamily.CALIBRI);
*
* // Set the first paragraph font to Arial.
* body.getParagraphs()[0].setFontFamily(DocumentApp.FontFamily.ARIAL);
*
* // Set "Apps Script" to Comic Sans MS.
* var text = 'Apps Script';
* var a = body.getText().indexOf(text);
* var b = a + text.length - 1;
* body.editAsText().setFontFamily(a, b, DocumentApp.FontFamily.COMIC_SANS_MS);
*/
export enum FontFamily { AMARANTH, ARIAL, ARIAL_BLACK, ARIAL_NARROW, ARVO, CALIBRI, CAMBRIA, COMIC_SANS_MS, CONSOLAS, CORSIVA, COURIER_NEW, DANCING_SCRIPT, DROID_SANS, DROID_SERIF, GARAMOND, GEORGIA, GLORIA_HALLELUJAH, GREAT_VIBES, LOBSTER, MERRIWEATHER, PACIFICO, PHILOSOPHER, POIRET_ONE, QUATTROCENTO, ROBOTO, SHADOWS_INTO_LIGHT, SYNCOPATE, TAHOMA, TIMES_NEW_ROMAN, TREBUCHET_MS, UBUNTU, VERDANA }
/**
* An element representing a footer section. A
* Document typically contains at most one
* FooterSection. The FooterSection may contain ListItem, Paragraph,
* and Table elements. For more information on document structure, see the
* guide to extending Google Docs.
*/
export interface FooterSection {
appendHorizontalRule(): HorizontalRule;
appendImage(image: Base.BlobSource): InlineImage;
appendImage(image: InlineImage): InlineImage;
appendListItem(listItem: ListItem): ListItem;
appendListItem(text: string): ListItem;
appendParagraph(paragraph: Paragraph): Paragraph;
appendParagraph(text: string): Paragraph;
appendTable(): Table;
appendTable(cells: String[][]): Table;
appendTable(table: Table): Table;
clear(): FooterSection;
copy(): FooterSection;
editAsText(): Text;
findElement(elementType: ElementType): RangeElement;
findElement(elementType: ElementType, from: RangeElement): RangeElement;
findText(searchPattern: string): RangeElement;
findText(searchPattern: string, from: RangeElement): RangeElement;
getAttributes(): Object;
getChild(childIndex: Integer): Element;
getChildIndex(child: Element): Integer;
getImages(): InlineImage[];
getListItems(): ListItem[];
getNumChildren(): Integer;
getParagraphs(): Paragraph[];
getParent(): ContainerElement;
getTables(): Table[];
getText(): string;
getTextAlignment(): TextAlignment;
getType(): ElementType;
insertHorizontalRule(childIndex: Integer): HorizontalRule;
insertImage(childIndex: Integer, image: Base.BlobSource): InlineImage;
insertImage(childIndex: Integer, image: InlineImage): InlineImage;
insertListItem(childIndex: Integer, listItem: ListItem): ListItem;
insertListItem(childIndex: Integer, text: string): ListItem;
insertParagraph(childIndex: Integer, paragraph: Paragraph): Paragraph;
insertParagraph(childIndex: Integer, text: string): Paragraph;
insertTable(childIndex: Integer): Table;
insertTable(childIndex: Integer, cells: String[][]): Table;
insertTable(childIndex: Integer, table: Table): Table;
removeChild(child: Element): FooterSection;
removeFromParent(): FooterSection;
replaceText(searchPattern: string, replacement: string): Element;
setAttributes(attributes: Object): FooterSection;
setText(text: string): FooterSection;
setTextAlignment(textAlignment: TextAlignment): FooterSection;
getFootnotes(): Footnote[];
getLinkUrl(): string;
getNextSibling(): Element;
getPreviousSibling(): Element;
isAtDocumentEnd(): boolean;
setLinkUrl(url: string): FooterSection;
}
/**
* An element representing a footnote. Each Footnote is contained within a ListItem
* or Paragraph and has a corresponding FootnoteSection element for the footnote's
* contents. The Footnote itself cannot contain any other element. For more information on
* document structure, see the
* guide to extending Google Docs.
*/
export interface Footnote {
copy(): Footnote;
getAttributes(): Object;
getFootnoteContents(): FootnoteSection;
getNextSibling(): Element;
getParent(): ContainerElement;
getPreviousSibling(): Element;
getType(): ElementType;
isAtDocumentEnd(): boolean;
removeFromParent(): Footnote;
setAttributes(attributes: Object): Footnote;
}
/**
* An element representing a footnote section. A FootnoteSection contains the text that
* corresponds to a Footnote. The FootnoteSection may contain ListItem or
* Paragraph elements. For more information on document structure, see the
* guide to extending Google Docs.
*/
export interface FootnoteSection {
appendParagraph(paragraph: Paragraph): Paragraph;
appendParagraph(text: string): Paragraph;
clear(): FootnoteSection;
copy(): FootnoteSection;
editAsText(): Text;
findElement(elementType: ElementType): RangeElement;
findElement(elementType: ElementType, from: RangeElement): RangeElement;
findText(searchPattern: string): RangeElement;
findText(searchPattern: string, from: RangeElement): RangeElement;
getAttributes(): Object;
getChild(childIndex: Integer): Element;
getChildIndex(child: Element): Integer;
getNextSibling(): Element;
getNumChildren(): Integer;
getParagraphs(): Paragraph[];
getParent(): ContainerElement;
getPreviousSibling(): Element;
getText(): string;
getTextAlignment(): TextAlignment;
getType(): ElementType;
insertParagraph(childIndex: Integer, paragraph: Paragraph): Paragraph;
insertParagraph(childIndex: Integer, text: string): Paragraph;
removeChild(child: Element): FootnoteSection;
removeFromParent(): FootnoteSection;
replaceText(searchPattern: string, replacement: string): Element;
setAttributes(attributes: Object): FootnoteSection;
setText(text: string): FootnoteSection;
setTextAlignment(textAlignment: TextAlignment): FootnoteSection;
getFootnotes(): Footnote[];
getLinkUrl(): string;
isAtDocumentEnd(): boolean;
setLinkUrl(url: string): FootnoteSection;
}
/**
* An enumeration of the supported glyph types.
*
* Use the GlyphType enumeration to set the bullet type for list
* items.
*
* var body = DocumentApp.getActiveDocument().getBody();
*
* // Insert at list item, with the default nesting level of zero.
* body.appendListItem("Item 1");
*
* // Append a second list item, with a nesting level of one, indented one inch.
* // The two items will have different bullet glyphs.
* body.appendListItem("Item 2").setNestingLevel(1).setIndentStart(72)
* .setGlyphType(DocumentApp.GlyphType.SQUARE_BULLET);
*/
export enum GlyphType { BULLET, HOLLOW_BULLET, SQUARE_BULLET, NUMBER, LATIN_UPPER, LATIN_LOWER, ROMAN_UPPER, ROMAN_LOWER }
/**
* An element representing a header section. A
* Document typically
* contains at most one HeaderSection. The HeaderSection may contain
* ListItem, Paragraph, and Table elements. For more information on document
* structure, see the
* guide to extending Google Docs.
*/
export interface HeaderSection {
appendHorizontalRule(): HorizontalRule;
appendImage(image: Base.BlobSource): InlineImage;
appendImage(image: InlineImage): InlineImage;
appendListItem(listItem: ListItem): ListItem;
appendListItem(text: string): ListItem;
appendParagraph(paragraph: Paragraph): Paragraph;
appendParagraph(text: string): Paragraph;
appendTable(): Table;
appendTable(cells: String[][]): Table;
appendTable(table: Table): Table;
clear(): HeaderSection;
copy(): HeaderSection;
editAsText(): Text;
findElement(elementType: ElementType): RangeElement;
findElement(elementType: ElementType, from: RangeElement): RangeElement;
findText(searchPattern: string): RangeElement;
findText(searchPattern: string, from: RangeElement): RangeElement;
getAttributes(): Object;
getChild(childIndex: Integer): Element;
getChildIndex(child: Element): Integer;
getImages(): InlineImage[];
getListItems(): ListItem[];
getNumChildren(): Integer;
getParagraphs(): Paragraph[];
getParent(): ContainerElement;
getTables(): Table[];
getText(): string;
getTextAlignment(): TextAlignment;
getType(): ElementType;
insertHorizontalRule(childIndex: Integer): HorizontalRule;
insertImage(childIndex: Integer, image: Base.BlobSource): InlineImage;
insertImage(childIndex: Integer, image: InlineImage): InlineImage;
insertListItem(childIndex: Integer, listItem: ListItem): ListItem;
insertListItem(childIndex: Integer, text: string): ListItem;
insertParagraph(childIndex: Integer, paragraph: Paragraph): Paragraph;
insertParagraph(childIndex: Integer, text: string): Paragraph;
insertTable(childIndex: Integer): Table;
insertTable(childIndex: Integer, cells: String[][]): Table;
insertTable(childIndex: Integer, table: Table): Table;
removeChild(child: Element): HeaderSection;
removeFromParent(): HeaderSection;
replaceText(searchPattern: string, replacement: string): Element;
setAttributes(attributes: Object): HeaderSection;
setText(text: string): HeaderSection;
setTextAlignment(textAlignment: TextAlignment): HeaderSection;
getFootnotes(): Footnote[];
getLinkUrl(): string;
getNextSibling(): Element;
getPreviousSibling(): Element;
isAtDocumentEnd(): boolean;
setLinkUrl(url: string): HeaderSection;
}
/**
* An enumeration of the supported horizontal alignment types.
*
* Use the HorizontalAlignment enumeration to manipulate the
* alignment of Paragraph contents.
*
* var body = DocumentApp.getActiveDocument().getBody();
*
* // Insert a paragraph and a table at the start of document.
* var par1 = body.insertParagraph(0, "Center");
* var table = body.insertTable(1, [['Left', 'Right']]);
* var par2 = table.getCell(0, 0).getChild(0).asParagraph();
* var par3 = table.getCell(0, 0).getChild(0).asParagraph();
*
* // Center align the first paragraph.
* par1.setAlignment(DocumentApp.HorizontalAlignment.CENTER);
*
* // Left align the first cell.
* par2.setAlignment(DocumentApp.HorizontalAlignment.LEFT);
*
* // Right align the second cell.
* par3.setAlignment(DocumentApp.HorizontalAlignment.RIGHT);
*/
export enum HorizontalAlignment { LEFT, CENTER, RIGHT, JUSTIFY }
/**
* An element representing an horizontal rule. A HorizontalRule can be contained within a
* ListItem or Paragraph, but cannot itself contain any other element. For more
* information on document structure, see the
* guide to extending Google Docs.
*/
export interface HorizontalRule {
copy(): HorizontalRule;
getAttributes(): Object;
getNextSibling(): Element;
getParent(): ContainerElement;
getPreviousSibling(): Element;
getType(): ElementType;
isAtDocumentEnd(): boolean;
removeFromParent(): HorizontalRule;
setAttributes(attributes: Object): HorizontalRule;
}
/**
* An element representing an embedded drawing. An InlineDrawing can be contained within a
* ListItem or Paragraph, unless the ListItem or Paragraph is within
* a FootnoteSection. An InlineDrawing cannot itself contain any other element. For
* more information on document structure, see the
* guide to extending Google Docs.
*/
export interface InlineDrawing {
copy(): InlineDrawing;
getAttributes(): Object;
getNextSibling(): Element;
getParent(): ContainerElement;
getPreviousSibling(): Element;
getType(): ElementType;
isAtDocumentEnd(): boolean;
merge(): InlineDrawing;
removeFromParent(): InlineDrawing;
setAttributes(attributes: Object): InlineDrawing;
}
/**
* An element representing an embedded image. An InlineImage can be contained within a
* ListItem or Paragraph, unless the ListItem or Paragraph is within
* a FootnoteSection. An InlineImage cannot itself contain any other element. For
* more information on document structure, see the
* guide to extending Google Docs.
*/
export interface InlineImage {
copy(): InlineImage;
getAs(contentType: string): Base.Blob;
getAttributes(): Object;
getBlob(): Base.Blob;
getHeight(): Integer;
getLinkUrl(): string;
getNextSibling(): Element;
getParent(): ContainerElement;
getPreviousSibling(): Element;
getType(): ElementType;
getWidth(): Integer;
isAtDocumentEnd(): boolean;
merge(): InlineImage;
removeFromParent(): InlineImage;
setAttributes(attributes: Object): InlineImage;
setHeight(height: Integer): InlineImage;
setLinkUrl(url: string): InlineImage;
setWidth(width: Integer): InlineImage;
}
/**
* An element representing a list item. A ListItem is a Paragraph that is
* associated with a list ID. A ListItem may contain Equation, Footnote,
* HorizontalRule, InlineDrawing, InlineImage, PageBreak, and
* Text elements. For more information on document structure, see the
* guide to extending Google Docs.
*
* ListItems may not contain new-line characters. New-line characters ("\n") are
* converted to line-break characters ("\r").
*
* ListItems with the same list ID belong to the same list and are numbered accordingly.
* The ListItems for a given list are not required to be adjacent in the document or even
* have the same parent element. Two items belonging to the same list may exist anywhere in the
* document while maintaining consecutive numbering, as the following example illustrates:
*
* var body = DocumentApp.getActiveDocument().getBody();
*
* // Append a new list item to the body.
* var item1 = body.appendListItem('Item 1');
*
* // Log the new list item's list ID.
* Logger.log(item1.getListId());
*
* // Append a table after the list item.
* body.appendTable([
* ['Cell 1', 'Cell 2']
* ]);
*
* // Append a second list item with the same list ID. The two items are treated as the same list,
* // despite not being consecutive.
* var item2 = body.appendListItem('Item 2');
* item2.setListId(item1);
*/
export interface ListItem {
appendHorizontalRule(): HorizontalRule;
appendInlineImage(image: Base.BlobSource): InlineImage;
appendInlineImage(image: InlineImage): InlineImage;
appendPageBreak(): PageBreak;
appendPageBreak(pageBreak: PageBreak): PageBreak;
appendText(text: string): Text;
appendText(text: Text): Text;
clear(): ListItem;
copy(): ListItem;
editAsText(): Text;
findElement(elementType: ElementType): RangeElement;
findElement(elementType: ElementType, from: RangeElement): RangeElement;
findText(searchPattern: string): RangeElement;
findText(searchPattern: string, from: RangeElement): RangeElement;
getAlignment(): HorizontalAlignment;
getAttributes(): Object;
getChild(childIndex: Integer): Element;
getChildIndex(child: Element): Integer;
getGlyphType(): GlyphType;
getHeading(): ParagraphHeading;
getIndentEnd(): Number;
getIndentFirstLine(): Number;
getIndentStart(): Number;
getLineSpacing(): Number;
getLinkUrl(): string;
getListId(): string;
getNestingLevel(): Integer;
getNextSibling(): Element;
getNumChildren(): Integer;
getParent(): ContainerElement;
getPreviousSibling(): Element;
getSpacingAfter(): Number;
getSpacingBefore(): Number;
getText(): string;
getTextAlignment(): TextAlignment;
getType(): ElementType;
insertHorizontalRule(childIndex: Integer): HorizontalRule;
insertInlineImage(childIndex: Integer, image: Base.BlobSource): InlineImage;
insertInlineImage(childIndex: Integer, image: InlineImage): InlineImage;
insertPageBreak(childIndex: Integer): PageBreak;
insertPageBreak(childIndex: Integer, pageBreak: PageBreak): PageBreak;
insertText(childIndex: Integer, text: string): Text;
insertText(childIndex: Integer, text: Text): Text;
isAtDocumentEnd(): boolean;
isLeftToRight(): boolean;
merge(): ListItem;
removeChild(child: Element): ListItem;
removeFromParent(): ListItem;
replaceText(searchPattern: string, replacement: string): Element;
setAlignment(alignment: HorizontalAlignment): ListItem;
setAttributes(attributes: Object): ListItem;
setGlyphType(glyphType: GlyphType): ListItem;
setHeading(heading: ParagraphHeading): ListItem;
setIndentEnd(indentEnd: Number): ListItem;
setIndentFirstLine(indentFirstLine: Number): ListItem;
setIndentStart(indentStart: Number): ListItem;
setLeftToRight(leftToRight: boolean): ListItem;
setLineSpacing(multiplier: Number): ListItem;
setLinkUrl(url: string): ListItem;
setListId(listItem: ListItem): ListItem;
setNestingLevel(nestingLevel: Integer): ListItem;
setSpacingAfter(spacingAfter: Number): ListItem;
setSpacingBefore(spacingBefore: Number): ListItem;
setText(text: string): void;
setTextAlignment(textAlignment: TextAlignment): ListItem;
}
/**
* A Range that has a name and ID to allow later retrieval. Names are not
* necessarily unique; several different ranges in the same document may share the same name, much
* like a class in HTML. By contrast, IDs are unique within the document, like an ID in HTML. Once a
* NamedRange has been added to a document, it cannot be modified, only removed.
*
* A NamedRange can be accessed by any script that accesses the document. To avoid
* unintended conflicts between scripts, consider prefixing range names with a unique string.
*
* // Create a named range that includes every table in the document.
* var doc = DocumentApp.getActiveDocument();
* var rangeBuilder = doc.newRange();
* var tables = doc.getBody().getTables();
* for (var i = 0; i < tables.length; i++) {
* rangeBuilder.addElement(tables[i]);
* }
* doc.addNamedRange('myUniquePrefix-tables', rangeBuilder.build());
*/
export interface NamedRange {
getId(): string;
getName(): string;
getRange(): Range;
remove(): void;
}
/**
* An element representing a page break. A PageBreak can be contained within a
* ListItem or Paragraph, unless the ListItem or Paragraph is within
* a Table, HeaderSection, FooterSection, or FootnoteSection. A
* PageBreak cannot itself contain any other element. For more information on document
* structure, see the
* guide to extending Google Docs.
*/
export interface PageBreak {
copy(): PageBreak;
getAttributes(): Object;
getNextSibling(): Element;
getParent(): ContainerElement;
getPreviousSibling(): Element;
getType(): ElementType;
isAtDocumentEnd(): boolean;
removeFromParent(): PageBreak;
setAttributes(attributes: Object): PageBreak;
}
/**
* An element representing a paragraph. A Paragraph may contain Equation,
* Footnote, HorizontalRule, InlineDrawing, InlineImage,
* PageBreak, and Text elements. For more information on document structure, see the
* guide to extending Google Docs.
*
* Paragraphs may not contain new-line characters. New-line characters ("\n") are
* converted to line-break characters ("\r").
*
* var body = DocumentApp.getActiveDocument().getBody();
*
* // Append a document header paragraph.
* var header = body.appendParagraph("A Document");
* header.setHeading(DocumentApp.ParagraphHeading.HEADING1);
*
* // Append a section header paragraph.
* var section = body.appendParagraph("Section 1");
* section.setHeading(DocumentApp.ParagraphHeading.HEADING2);
*
* // Append a regular paragraph.
* body.appendParagraph("This is a typical paragraph.");
*/
export interface Paragraph {
appendHorizontalRule(): HorizontalRule;
appendInlineImage(image: Base.BlobSource): InlineImage;
appendInlineImage(image: InlineImage): InlineImage;
appendPageBreak(): PageBreak;
appendPageBreak(pageBreak: PageBreak): PageBreak;
appendText(text: string): Text;
appendText(text: Text): Text;
clear(): Paragraph;
copy(): Paragraph;
editAsText(): Text;
findElement(elementType: ElementType): RangeElement;
findElement(elementType: ElementType, from: RangeElement): RangeElement;
findText(searchPattern: string): RangeElement;
findText(searchPattern: string, from: RangeElement): RangeElement;
getAlignment(): HorizontalAlignment;
getAttributes(): Object;
getChild(childIndex: Integer): Element;
getChildIndex(child: Element): Integer;
getHeading(): ParagraphHeading;
getIndentEnd(): Number;
getIndentFirstLine(): Number;
getIndentStart(): Number;
getLineSpacing(): Number;
getLinkUrl(): string;
getNextSibling(): Element;
getNumChildren(): Integer;
getParent(): ContainerElement;
getPreviousSibling(): Element;
getSpacingAfter(): Number;
getSpacingBefore(): Number;
getText(): string;
getTextAlignment(): TextAlignment;
getType(): ElementType;
insertHorizontalRule(childIndex: Integer): HorizontalRule;
insertInlineImage(childIndex: Integer, image: Base.BlobSource): InlineImage;
insertInlineImage(childIndex: Integer, image: InlineImage): InlineImage;
insertPageBreak(childIndex: Integer): PageBreak;
insertPageBreak(childIndex: Integer, pageBreak: PageBreak): PageBreak;
insertText(childIndex: Integer, text: string): Text;
insertText(childIndex: Integer, text: Text): Text;
isAtDocumentEnd(): boolean;
isLeftToRight(): boolean;
merge(): Paragraph;
removeChild(child: Element): Paragraph;
removeFromParent(): Paragraph;
replaceText(searchPattern: string, replacement: string): Element;
setAlignment(alignment: HorizontalAlignment): Paragraph;
setAttributes(attributes: Object): Paragraph;
setHeading(heading: ParagraphHeading): Paragraph;
setIndentEnd(indentEnd: Number): Paragraph;
setIndentFirstLine(indentFirstLine: Number): Paragraph;
setIndentStart(indentStart: Number): Paragraph;
setLeftToRight(leftToRight: boolean): Paragraph;