如何在 Google Docs 中使用 kix 锚(或不使用)匹配对图像的评论 [英] How to match comments on an image using kix anchor (or not) in Google Docs

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

问题描述

可以检索打开的 Google Docs 文档的元素,从

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

DocumentApp.openById(doc_id, folder_id)

但对文档的评论是通过 Drive API 检索的,使用 Comments.list

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

在具有 2 个评论的文档上运行此操作:一个在图像上,一个在段落中的单词上显示,虽然文本锚定评论可以,但图像不会返回 context 条目:

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",

其中 xxxxxxxxxxx1/xxxxxxxxxxx2 是唯一锚 ID 后缀,kix 是 Google 的专有前缀"锚定/编辑器系统(如 StevenBazyl 在管理评论和讨论" 开发者指南页面).

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).

锚点基本上告诉我们此评论适用于文档中的哪个位置.因为这是我们的格式 [在 Google],我们确实有一个专有的锚定方案,这确实使您难以——或者更确切地说,不可能——进行策划create? 锚定到我们文档格式中的文本的注释……但是如果它是您控制的文档格式,或者它是某种东西,呃……有办法以可互换的方式定位它,您可以在其中放置锚点,以便您的应用可以正确定位,并且可能其他应用也可以正确读取和定位."

"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."

如果我看不到评论所在的元素,那么尝试在相应图像的评论中存储图像源 URL 是否注定失败?(上下文:制作 .gdoc-to-.md 转换器)

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 没有将 Google Apps Script 列为一种语言(大概是因为它非常基于 Javascript).是否有我可以查看的自定义评论锚定系统的开源示例?

  • 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?

  • 我实际上并不相信当前的 API 可以实现这样的锚定系统.虽然 anchorComments.list 方法提供,Comments.insert 只允许 fileIdcontentcontext.typecontext.value:这里不可能有唯一的锚定 ID.

  • I don't actually believe such an anchoring system would be possible with the current API. While an anchor is provided by the Comments.list method, Comments.insert only allows fileId, content, context.type and context.value: no possibility for unique anchoring IDs here.

相关尝试:在 Google 文档中以编程方式创建锚定评论

如果我用 Drive 评论 SDK 写一些东西(正如 Steven 建议的那样),有什么办法可以覆盖内置的 Google Docs 评论(例如 Ctrl/Cmd + M 或自定义按钮制作一个评论带有 GAS 可访问的图像context) ?

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) ?

推荐答案

简单的答案是您无法可靠地匹配.锚点根本没有在文档 API 中的任何地方公开.如果它们被公开,我希望它们显示为 NamedRange 或 Bookmark 条目,但它们都不会被注释锚填充.

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 Docs 中使用 kix 锚(或不使用)匹配对图像的评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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