简体   繁体   English

如何使用 Google Apps 脚本获取有关 Google Docs 的建议

[英]How to get suggestions on Google Docs with Google Apps Script

I found this StackOverflow answer that says "You can get the suggestions made in a document doing a get request," but when I follow the link I see Java and Python options.我发现这个StackOverflow 答案说“您可以在执行获取请求的文档中获得建议”,但是当我点击链接时,我看到 Java 和 Python 选项。 How can I actually get suggestions using exclusively Google Apps Script?我如何才能真正使用专门的 Google Apps 脚本获得建议? I don't need to modify them at all, just get their existence.我根本不需要修改它们,只需获得它们的存在即可。

Use Docs service of Apps Script and access the data you need to have based on its response.使用 Apps Script 的Docs服务并根据其响应访问您需要拥有的数据。

Script:脚本:

function myFunction() {
  var documentId = <document ID>;
  var doc = Docs.Documents.get(documentId);
  doc.body.content.forEach(function (content){
    if (content.paragraph) {
      var elements = content.paragraph.elements;
      elements.forEach(function (element){
        if(element.textRun.suggestedDeletionIds)
          Logger.log("suggested to delete: " + element.textRun.content)
        if(element.textRun.suggestedInsertionIds)
          Logger.log("suggested to insert: " + element.textRun.content)
      });
    }
  });
}

Sample Data:样本数据:

样本

Output: Output:

输出

Reference:参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM