From 862a1d9f632b4b31be43dcd69616dd603bdbd973 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Wed, 18 Mar 2020 14:38:34 -0400 Subject: [PATCH] Allow for copying to HeaderSection and FooterSection, as well as Body --- Code.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Code.ts b/Code.ts index 6c9e29b..8847bf5 100644 --- a/Code.ts +++ b/Code.ts @@ -5,9 +5,14 @@ function onOpen() { .addToUi(); } +type DocSection = + | GoogleAppsScript.Document.Body + | GoogleAppsScript.Document.HeaderSection + | GoogleAppsScript.Document.FooterSection; + function copyElement( source_element: GoogleAppsScript.Document.Element, - dest: GoogleAppsScript.Document.Body, + dest: DocSection, index?: number ) { const element = source_element.copy(); @@ -31,11 +36,7 @@ function copyElement( ); } -function copyBody( - source: GoogleAppsScript.Document.Body, - dest: GoogleAppsScript.Document.Body, - index?: number -) { +function copySection(source: DocSection, dest: DocSection, index?: number) { const totalElements = source.getNumChildren(); for (let j = 0; j < totalElements; ++j) { if (index) copyElement(source.getChild(j), dest, index + j);