如何在Google文档中使用kix定位符(或不定义)匹配图片上的评论 [英] How to match comments on an image using kix anchor (or not) in Google Docs
问题描述
可以从
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?
-
GitHub没有列出Google Apps Script作为语言(大概是因为它基于Javascript)。有没有我可以看看的自定义评论锚定系统的开源示例?
-
实际上我并不相信这样的锚定系统可能适用于当前的API。
定位
是由Comments.list
方法提供的, fileId / code>,content
,context.type
和context.value
:这里没有唯一锚点ID的可能性。
相关尝试:以编程方式在Google文档中创建锚定评论
$ b -
-
如果我要使用Drive comments SDK编写某些内容(如Steven建议的那样),是否有任何方法可以覆盖内置的Google文档评论(例如Ctrl / Cmd + M或自定义按钮对使用GAS可访问的
context
)的图片发表了评论。 =h2_lin>解决方案
简单的答案是你无法比拟的可靠。锚点根本不在任何地方暴露在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?
I don't actually believe such an anchoring system would be possible with the current API. While an
anchor
is provided by theComments.list
method,Comments.insert
only allowsfileId
,content
,context.type
andcontext.value
: no possibility for unique anchoring IDs here.Related attempt: Creating anchored comments programmatically in Google Docs
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屋!