如何在Google文档中使用kix定位符(或不定义)匹配图片上的评论 [英] How to match comments on an image using kix anchor (or not) in Google Docs

查看:134
本文介绍了如何在Google文档中使用kix定位符(或不定义)匹配图片上的评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以从

  DocumentApp.openById(doc_id,folder_id)$检索打开的Google文档文档的元素b $ b  

但通过Drive API检索文档上的注释, Comments.list



在包含2条评论的文档上运行此操作:图像上一个,段落中某个单词上的一个显示文本锚定注释执行时,图像不会返回 context entry:

 content:test comment on text,
删除:false,
status:open,
context:{
type:text / html,
value一些文字评论被放置在

anchor:kix.xxxxxxxxxxx1,






 content:对图片测试评论,
deleted:false,
状态:打开,
anchor:kix.xxxxxxxxxxx2,

其中 xxxxxxxxxxx1 / xxxxxxxxxxx2 是唯一的锚点ID后缀, kix 是Google的专有anchoring / 编辑 a>系统(正如Steven Bazyl在视频中描述的管理评论和讨论开发人员指南页面)。


锚点基本上告诉我们这个评论适用的文档在哪里。因为这是我们[在Google]的格式,所以我们确实拥有专有的锚定方案,这使得您很难 - 甚至不可能 - 管理锚定到文档中的文本的 create?注释格式......但如果它是一种您控制的文档格式,或者它是某种可以以可互换的方式找到它的方式,那么您可以将锚定在那里,您的应用可以正确定位,并且可能还有其他


如果我无法看到评论所在的元素,则尝试尝试将图片源URL存储在相应图片的注释中注定要失败? (context:make a .gdoc-to-.md converter



如果是这样,可能唯一的方法来匹配评论图像将检索所有上下文无区域评论并假定每个图像都是评论ted?

简单的答案是你无法比拟的可靠。锚点根本不在任何地方暴露在Document API中。如果他们被曝光,我希望他们显示为NamedRange或Bookmark条目,但都不会出现评论锚点。


It's possible to retrieve elements of an open Google Docs document, starting from

DocumentApp.openById(doc_id, folder_id)

but the comments on a document are retrieved through the Drive API, with Comments.list

Running this on a document with 2 comments: one on an image, one on a word in a paragraph shows that while text-anchored comments do, images don't return a context entry:

 "content": "test comment on text",
 "deleted": false,
 "status": "open",
 "context": {
  "type": "text/html",
  "value": "some text the comment is placed on"
 },
 "anchor": "kix.xxxxxxxxxxx1",


 "content": "test comment on an image",
 "deleted": false,
 "status": "open",
 "anchor": "kix.xxxxxxxxxxx2",

where xxxxxxxxxxx1/xxxxxxxxxxx2 are the unique anchor ID suffixes, and kix the prefix for Google's "proprietary" anchoring/editor system (as Steven Bazyl described it in the video on the "Managing comments and discussions" developer guide page).

"The anchor basically tells us where in the document this comment applies to. Because this is our format [at Google] we do have a proprietary anchoring scheme, which does make it difficult — or rather, impossible — for you to curatecreate? comments that are anchored to text in our document formats... but if it's a document format that you control, or if it's something where uh.. there are ways to locate it in an interchangeable way, you can put anchors in there that your app can position correctly, and potentially that other apps could read and position correctly as well."

If I can't see the element a comment is placed on, is an attempt to store an image source URL in a comment on the corresponding image doomed? (context: making a .gdoc-to-.md converter)

If so, might the only way to match comments to images be to retrieve all context field-less comments and assume every image to be commented?

  • GitHub doesn't list Google Apps Script as a language (presumably because it's based so closely on Javascript). Are there open source examples of custom comment anchoring systems I could take a look at?

  • If I were to write something with the Drive comments SDK (as Steven suggested), is there any way this could override the built in Google Docs commenting (such that Ctrl/Cmd + M or a custom button made a comment on an image with a GAS-accessible context) ?

解决方案

Simple answer is you can't match reliably. The anchors simply aren't exposed in the Document API anywhere. If they were exposed, I'd expect them to appear as NamedRange or Bookmark entries, but neither appears populated by comment anchors.

这篇关于如何在Google文档中使用kix定位符(或不定义)匹配图片上的评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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