在Google文档中以编程方式创建锚定评论 [英] Creating anchored comments programmatically in Google Docs

查看:80
本文介绍了在Google文档中以编程方式创建锚定评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法以编程方式使用文档中的应用程序脚本创建锚定到Google文档中特定文本的评论。



Google文档介绍如何使用Google云端硬盘API创建锚定评论:
https://developers.google .com / drive / web / manage-comments



以下是我必须在doc中创建注释的代码:$ b $ (
kind:drive#comment,

Drive.Comments.insert作者:{
kind:drive#user,
displayName:USER_EMAIL,
isAuthenticatedUser:true,
},
content :CONTENT,
status:open,
anchor:{'r':
+ REVISION_ID
+,'a':[ 'txt':{'o':
+ STARTING_OFFSET
+,'l':
+ OFFSET_LENGTH
+,'ml':
+ TOTAL_CHARS
+}}]},
fileId:FILE_ID
},FILE_ID);
$ b $ * USER_EMAIL,CONTENT,REVISION_ID,FILE_ID:string,
STARTING_OFFSET,OFFSET_LENGTH,TOTAL_CHARS:int * /

在这种情况下,我试图为文档中的 STARTING_OFFSET OFFSET_LENGTH



目前,此代码会在Google文档中创建一条可访问的评论;但是,它并没有固定在文档中的任何文本中,这对于预期的目的是必要的。



我确定使用了当前版本ID(因为这个可能会导致问题,如Google文档中所述)。



任何建议都非常感谢,如果有人可以发布或指向在Google文档中创建锚定评论的示例以编程方式,我将非常感激。



预先感谢!

解决方案

Google Drive API的锚定评论功能是适用于非Google文档编辑器文件,不适用于Google文档。请参阅 https://youtu.be/ZBU52nacbLw?t=5m26s (授予Bryan P谁通过评论分享了此网址)



此时不幸的是,文档服务不包含类别评论以处理评论和讨论。

在2016年初,功能请求通过Google Apps脚本问题和功能请求官方网站发布。通过介绍此功能请求,您可以帮助Google员工关注它:



问题5650:提供创建Drive API注释锚点资源作为DocumentApp选择类的方法的功能



2012年发布的较老的参考文献非常相似但更为广泛,通过 Alexander

问题1618:提供对Google文档评论的读/写权限



参考资料




I have been unable to programmatically create a comment that is anchored to specific text in a Google Doc using an app script with the document.

Google documentation about how to create an anchored comment using the Google Drive API: https://developers.google.com/drive/web/manage-comments

Here is the code I have to create the comment in the doc:

Drive.Comments.insert({
  "kind": "drive#comment",
  "author": {
    "kind": "drive#user",
    "displayName": USER_EMAIL,
    "isAuthenticatedUser": true,
  },
  "content": CONTENT,
  "status": "open",
  "anchor": "{'r':"
             + REVISION_ID
             + ",'a':[{'txt':{'o':"
             + STARTING_OFFSET
             + ",'l':"
             + OFFSET_LENGTH
             + ",'ml':"
             + TOTAL_CHARS
             + "}}]}", 
  "fileId": FILE_ID
}, FILE_ID);

 /* USER_EMAIL, CONTENT, REVISION_ID, FILE_ID: string,
    STARTING_OFFSET, OFFSET_LENGTH, TOTAL_CHARS: int  */

In this case, I am trying to create a text anchor to specific characters in the doc which correspond to the STARTING_OFFSET and OFFSET_LENGTH.

Currently this code creates a comment accessible in Google Docs; however, it is not anchored to any text in the document, which is necessary for the intended purpose.

I have made sure that the current revision id is used (as this could cause issues, as mentioned in the Google documentation).

Any suggestions are greatly appreciated and if any one could post or point to an example of creating anchored comments in Google Docs programmatically, I would be extremely grateful.

Thanks in advance!

解决方案

The Anchoring Comments feature from the Google Drive API is intended for non-Google Docs editors files, not for Google Documents. See https://youtu.be/ZBU52nacbLw?t=5m26s (credit to Bryan P who shared this URL through a comment)

Unfortunatelly at this time the Document Service from Google Apps Script doesn't include a Class Comment to handle comments and discussions.

At the beginning of 2016 a feature request was posted through the Google Apps Scripts Issues and features requests official site. By starring this feature request you could help to make that Googlers put attention to it:

Issue 5650: Provide ability to create a Drive API Comment anchor resource as method on DocumentApp selection class

An older reference, posted on 2012, very similar but broader, referred through a comment by Alexander:
Issue 1618: Provide read/write access to comments in Google Docs

References

这篇关于在Google文档中以编程方式创建锚定评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆