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

查看:26
本文介绍了如何在 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 的专有前缀"锚定/editor 系统(作为 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).

锚基本上告诉我们该评论适用于文档中的哪个位置.因为这是我们 [at 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 只允许 fileId, content, context.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) ?

推荐答案

简单的答案是你不能可靠地匹配.锚点根本没有在 Document 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天全站免登陆