Skip to content

Commit eb41e26

Browse files
committed
fix(docs): address review comments
1 parent af9c095 commit eb41e26

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

docs/cursorInspector/cursorInspector.gs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function getDocumentInfo() {
7474

7575
/**
7676
* Gets information about a given element.
77-
* @param {GoogleAppsScript.Document.Element} element The element.
77+
* @param {Object} element The element.
7878
* @return {Object} The information.
7979
*/
8080
function getElementInfo(element) {

docs/translate/translate.gs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function getSelectedText() {
8787
const element = elements[i].getElement();
8888
// Only translate elements that can be edited as text; skip images and
8989
// other non-text elements.
90-
if ((/** @type {any} */ (element)).editAsText) {
90+
if (element.getType() === DocumentApp.ElementType.TEXT) {
9191
const elementText = element.asText().getText();
9292
// This check is necessary to exclude images, which return a blank
9393
// text element.
@@ -190,19 +190,21 @@ function insertText(newText) {
190190
}
191191
} else {
192192
const element = elements[i].getElement();
193-
if (!replaced && (/** @type {any} */ (element)).editAsText) {
194-
// Only translate elements that can be edited as text, removing other
195-
// elements.
196-
(/** @type {any} */ (element)).clear();
197-
element.asText().setText(newText);
193+
// Only translate elements that can be edited as text; skip images and
194+
// other non-text elements.
195+
const type = element.getType();
196+
if (!replaced && type === DocumentApp.ElementType.TEXT) {
197+
const textElement = element.asText();
198+
textElement.clear();
199+
textElement.setText(newText);
198200
replaced = true;
199201
} else {
200202
// We cannot remove the last paragraph of a doc. If this is the case,
201203
// just clear the element.
202204
if (element.getNextSibling()) {
203205
element.removeFromParent();
204-
} else {
205-
(/** @type {any} */ (element)).clear();
206+
} else if (type === DocumentApp.ElementType.TEXT) {
207+
element.asText().clear();
206208
}
207209
}
208210
}

0 commit comments

Comments
 (0)