在线富文本编辑器如何工作? [英] How do online rich text editors work?

查看:129
本文介绍了在线富文本编辑器如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道当您粘贴文本时,在线富文本编辑器如何维护格式网页或文档。标准textarea框只接受文本,而这些WYSIWYG编辑器似乎使用DIV。它是如何工作的?

I was wondering how online rich text editors maintain the formatting when you paste text from a webpage or document. A standard textarea box only takes text while these WYSIWYG editors seem to use a DIV. How does it work?

推荐答案

在线富文本编辑器使用 contentEditable designMode ,以利用浏览器对HTML编辑的原生支持。粘贴到contentEditable或designMode元素时,浏览器会将HTML直接放入元素中。通过粘贴到 Midas Demo 然后使用Firebug的inspect元素查看HTML来自己尝试一下粘贴。

Online rich text editors use contentEditable or designMode to take advantage of the browser's native support for HTML editing. When you paste into a contentEditable or designMode element, the browser puts HTML directely into the element. Try it yourself by pasting into Midas Demo and then using Firebug's inspect element to look at the HTML you pasted.

JavaScript应用程序可以使用 execCommand 在富文本编辑器中格式化用户选择的方法。

JavaScript applications can use the execCommand method to format the user's selection in a rich text editor.

这篇关于在线富文本编辑器如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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