Apps脚本与Chrome扩展程序:向Google文档编写替代的拼写检查器 [英] Apps Script vs Chrome Extension: Writing an alternative spellchecker to Google Docs

查看:81
本文介绍了Apps脚本与Chrome扩展程序:向Google文档编写替代的拼写检查器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说,我想为Google文档开发一个替代的拼写检查模块. 这意味着我必须从后端获取更正,并为拼写错误的文本的背景着色,并在用户将鼠标悬停在其上方时显示一个小的弹出气泡,以便在其中显示更正内容. (请注意,拼写检查不是我项目的实际目标,但确实可以更简化地解决我的问题)

Say, I want to develop an alternative spellcheck module to google docs. This means that I have to get corrections from my backend, and color the misspelled text's background, and do a small popup bubble when user hovers over it, where I'd display the correction. (please mind that spellcheck is not the actual goal of my project, but it does address my problems in a more simplified way)

我有什么选择?有任何想法如何做到吗?

我想出的几种可能的解决方案:

Few possible solutions I came up with:

Chrome扩展程序与Apps脚本

Chrome扩展程序

Chrome extension

  • 优点:用户必须授予一次权限,可以通过内容脚本自由遍历并将任何内容添加到dom
  • cons:这是一种"hacky"方式,如果google更改类名或js源,它将停止工作,并且无法对Google docs的编辑器引擎进行反向工程

应用脚本

  • 优点:受Google支持:如果可行,我就不必担心文档更新
  • 缺点:在我看来,我不能仅仅因为dom(由于Caja编译器)而摆弄dom,它对自定义突出显示或悬停功能的支持非常有限(如果有的话).

如我所见,这些都不是该项目的完美解决方案.你怎么认为?任何建议都非常欢迎.

As I see it, neither of these are perfect solutions for this project. What do you think? Any suggestions are very welcomed.

推荐答案

我知道这是一个老问题,但是我最近遇到了同样的问题,并且相信我有解决方案.因此,对于将来的Google员工,我将在此处发布我的答案.

I know this is an old question, but I have recently gotten into the same problem, and believe I have a solution. So for future Googler's I will post my answer here.

我的解决方案是创建一个Chrome扩展程序,并了解Google Docs DOM是如何与其交互的结构.

My solution was to create a Chrome Extension and understand how the Google Docs DOM's are structures to interact with it.

您可以在我的代码中使用Google Doc DOM的此处

You can find my code to work with the Google Doc DOM's here

这篇关于Apps脚本与Chrome扩展程序:向Google文档编写替代的拼写检查器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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