问题描述
我试图编写一个非常简单的wysiwyg编辑器,用户可以在选择部分文本后简单地添加粗体文本,超链接和项目符号。实际上就像CKEditor一样。
但据我所知,没有办法将格式添加到textarea。所以我想知道,CKEditor等其他编辑器如何解决这个问题。
您正在编辑的文档/文本的HTML。换句话说,你基本上是在浏览器中编辑HTML,而不是在 TEXTAREA
中的文本。您可能需要查看的源代码,以及在开始编写所有的东西之前,先查阅Mozilla的。 i'm trying to write a very simple wysiwyg editor, where users can simply add bold text, hyperlinks and bullets, after selecting part of the text.. actualy just like CKEditor.
But as far as i know there is no way to add formatting to a textarea. So I would like to know, how do other wysiwyg editors like CKEditor solve this.
The browser based WYSIWYG editors work by building the HTML for the document/text you're editing. In other words, you're essentially editing HTML inside the browser and not the text in a TEXTAREA
. You might want to have a look at the source code for Rich Text Editor and check out Mozilla's Midas Specification before you embark on writing everything from scratch.
这篇关于在textarea中加粗的文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!