谷歌文档文本光标

发布于 2024-12-11 08:41:58 字数 140 浏览 2 评论 0原文

我需要创建一个类似于谷歌文档的应用程序。我发现 google 文档不使用任何文本区域,而是使用常规 div 来创建页面。但我不知道他们是如何获得文本光标的。是图像闪烁吗?因为当我尝试使用 Chrome 开发者工具查看网页代码时,我没有看到任何图像。他们是如何做到的?

I need to create an application which is similar to google docs. I have seen that google docs doesn't use any textarea but regular divs to create pages. But what I don't know is how they manage to get a text cursor. Is it an image blinking? cause I didn't see any image when i tried to see the webpage code with chrome developer tools. How do they do it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

顾冷 2024-12-18 08:41:58

Google Docs 使用独特的编辑方法。没有启用 contentEditable 的文本区域,但所有内容都是使用 DOM 渲染的。它监听击键并操作 DIV。

光标只是绝对定位的 DIV,它以编程方式隐藏或显示。搜索名为“kix-cursor-caret”的类。

编辑器的代号为 Kix,您可以在此处查看其源代码: https://github.com/benjamn/kix-独立

Google Docs uses unique editing method. There is no text ares with contentEditable on, but everything is rendered using DOM. It listens for keystrokes and manipulates DIVs.

Cursor is just absolute positioned DIV which is programatically hidden or shown. Search for class named "kix-cursor-caret".

Editor is codenamed Kix and you can see it's source codes here: https://github.com/benjamn/kix-standalone

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文