Google apps script 为谷歌应用程序脚本谷歌文档使用另一个附加组件
我制作了一个将文档转换为MLA格式的应用程序,例如Times New Roman、12 pt等。现在我想更进一步,让用户选择所有链接,我希望它使用EasyBib API引用这些链接。EasyBib制作了一个附加组件,如果你在其中添加一个链接,它会给出引用,然后你点击“将参考书目添加到文档”,以便按字母顺序将MLA引用添加到引用的作品页面,这是谷歌文档中的最后一页。谷歌搜索这个问题已经证明是无用的Google apps script 为谷歌应用程序脚本谷歌文档使用另一个附加组件,google-apps-script,google-docs,google-apps-script-addon,Google Apps Script,Google Docs,Google Apps Script Addon,我制作了一个将文档转换为MLA格式的应用程序,例如Times New Roman、12 pt等。现在我想更进一步,让用户选择所有链接,我希望它使用EasyBib API引用这些链接。EasyBib制作了一个附加组件,如果你在其中添加一个链接,它会给出引用,然后你点击“将参考书目添加到文档”,以便按字母顺序将MLA引用添加到引用的作品页面,这是谷歌文档中的最后一页。谷歌搜索这个问题已经证明是无用的 function myFunction() { /* This function turns
function myFunction() {
/*
This function turns the document's format into standard MLA.
*/
var body = DocumentApp.getActiveDocument().getBody();
body.setFontSize(12); // Set the font size of the contents of the documents to 12
body.setForegroundColor('#000000'); // Set the color to black
body.setFontFamily("Times New Roman"); // Set the font family to Times New Roman (standard MLA)
body.editAsText().setBold(false); // Make everything not bold
// Set the four headings at the top
var datum = '3 February 1976';
var course = 'Social Studies';
var teacher = 'Your Teacher\'s Name Here';
var student = 'Your Name Here';
if (body.getParagraphs().length >= 4) {
var firstPar = body.getParagraphs()[0].getText();
var secondPar = body.getParagraphs()[1].getText();
var thirdPar = body.getParagraphs()[2].getText();
var lastPar = body.getParagraphs()[3].getText();
if (!(firstPar == student && secondPar == teacher && thirdPar == course && lastPar == datum)) {
body.insertParagraph(0, datum).setIndentFirstLine(0);
body.insertParagraph(0, course).setIndentFirstLine(0);
body.insertParagraph(0, teacher).setIndentFirstLine(0);
body.insertParagraph(0, student).setIndentFirstLine(0);
}
} else if (body.getParagraphs().length >= 1 && body.getParagraphs()[0].getText() !== '') {
body.insertParagraph(0, datum).setIndentFirstLine(0);
body.insertParagraph(0, course).setIndentFirstLine(0);
body.insertParagraph(0, teacher).setIndentFirstLine(0);
body.insertParagraph(0, student).setIndentFirstLine(0);
}
// Loops through paragraphs in body and sets each to double spaced
var paragraphs = body.getParagraphs();
for (var i = 0; i < paragraphs.length; i++) {
var paragraph = paragraphs[i];
// Double-spaced
paragraph.setLineSpacing(2);
// Left align the first cell.
paragraph.setAlignment(DocumentApp.HorizontalAlignment.LEFT);
if (i > 3) {
// Set to 1 indent per paragraph
Logger.log(paragraph.getIndentFirstLine());
paragraph.setIndentFirstLine(36);
}
}
}
function onOpen() {
var ui = DocumentApp.getUi();
ui.createMenu('AutoFormat')
.addItem('MLA', 'myFunction')
.addToUi();
}
onOpen()
我的问题是,我需要使用什么代码才能使用EasyBib附加组件,或者谷歌应用程序脚本中谷歌文档中的任何其他附加组件。没有通用的方法使用谷歌应用程序脚本中的第三方附加组件。每个附加组件开发人员都应该决定是否为其附加组件添加API。虽然我发现有可能现有的web服务有自己的API,但它们创建了一个附加组件,以使使用它们的服务更容易,而不是以其他方式。问题是什么?我不知道如何在Google Apps脚本代码中使用附加组件,所以你的意思是,“我不能再使用另一个附加组件,而必须自己编写该部分?”马文说得没错