我试图了解如何在 Google Apps 脚本中使用 javascript 原型和继承,但显然我仍然缺少一些东西。
这是我正在研究的结构。
function Father ( ) {
this.init.apply ( this, arguments );
}
Father.prototype ={
init: function ( ) {
var optns = arguments[0] || {};
this.job = optns.job || "unemployed";
this.cars = optns.cars || [];
}
}
function Son ( ) {
this.init.apply ( this, arguments );
}
Son.prototype = {
init : function ( ) {
Father.prototype.init.apply (this, arguments);
var optns = arguments[0] || {};
this.computers = optns.tablets || [];
}
}
Run Code Online (Sandbox Code Playgroud)
儿子与父亲的不同之处仅在于拥有电脑的财产。 …
我正在尝试编写一个脚本,将光标周围的文本设置为大写,并将封闭的段落设置为 HEADING1。我能够做第一件事,但我无法弄清楚如何使用 getCursor() 方法获取包含光标的段落。这是我尝试过的:
var cursor = DocumentApp.getActiveDocument().getCursor();
var element = cursor.getElement();
var paragraph = element.asParagraph();
Run Code Online (Sandbox Code Playgroud)
但是,element 是 TEXT 元素,不能转换为 PARAGRAPH。有没有办法从文本元素中获取段落?
谢谢。