【问题标题】:Use another Add-On for Google Apps Script Google Docs使用另一个 Google Apps 脚本 Google Docs 插件
【发布时间】:2019-10-23 06:33:24
【问题描述】:

我制作了一个应用程序,可以将文档转换为 MLA 格式(例如 Times New Roman、12 pt 等),现在我想更进一步,让用户选择所有链接,我想要它使用 EasyBib API 来引用它们。有一个由 EasyBib 制作的附加组件,如果您在其中放置链接,它会提供引文,然后单击“将参考书目添加到 Doc”以按字母顺序将 MLA 引文添加到“被引作品”页面,最后一个Google 文档中的页面。谷歌搜索这个问题已被证明是无用的。

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 插件或 Google Apps 脚本中的 Google Docs 中的任何其他插件

【问题讨论】:

  • 问题是什么?
  • 我不知道如何在 Google Apps 脚本代码中使用插件

标签: google-apps-script google-docs google-apps-script-addon


【解决方案1】:

没有从 Google Apps 脚本使用第三方插件的通用方法。每个附加组件开发人员都应决定是否为其附加组件添加 API。虽然我发现有可能拥有自己的 API 的现有 Web 服务创建了一个插件,以便更轻松地使用他们的服务,而不是以其他方式。

【讨论】:

  • 所以你的意思是,我不能使用其他插件,必须自己编写代码?
  • @Marvin Exactly
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多