简体   繁体   English

HTML5 文本区域内的富文本

[英]HTML5 rich-text inside textarea

I heard that the new HTML5 will add rich text capability to textareas (it will make them more flexible), so you can do stuff like code syntax highlighting editors without very nasty javascript (like creating iframes and stuff).我听说新的 HTML5 将为 textareas 添加富文本功能(这将使它们更加灵活),因此您可以执行代码语法高亮编辑器之类的操作,而无需非常讨厌的 javascript(例如创建 iframe 和其他东西)。

Is this true?这是真的? Are there browsers with support for it yet?是否有支持它的浏览器? And where can I find some API?我在哪里可以找到一些 API?

NO - jQuery否 - jQuery

If what you where looking for NO-jquery tools (pure HTML/CSS + basic JS) as me, then some of the best options found (back in 2016) are:如果您像我一样在寻找 NO-jquery 工具(纯 HTML/CSS + 基本 JS),那么找到的一些最佳选择(早在 2016 年)是:

  1. wysihtml5所见即所得
  2. Squire乡绅
  3. ckeditor编辑器
  4. widgEditor widg编辑器

Nevertheless , those in the list above all convert the element (textarea) into an iframe, so they weren't exactly what I was searching for, finally I found this one which respects the original element (divs or so, but if you use textarea it does creates an additional div), allowing full straightforward JS app development:尽管如此,上面列表中的那些都将元素 (textarea) 转换为 iframe,所以它们并不是我要搜索的内容,最后我找到了这个尊重原始元素的元素(div 左右,但如果你使用 textarea它确实创建了一个额外的 div),允许完全直接的 JS 应用程序开发:

  1. nicedit编辑

Hope this helps you too!希望这对你也有帮助!

Are you looking for Aloha Editor ?您在寻找Aloha 编辑器吗?

It's using the new contenteditable attribute to add a WYSIWYG editor to any div you choose.它使用新的contenteditable属性将 WYSIWYG 编辑器添加到您选择的任何 div。

Look at the demos .看看演示

I believe what you are referring to is the new contentEditable attribute.我相信您所指的是新的 contentEditable 属性。 This is not a textarea, but rather an element attribute.这不是一个文本区域,而是一个元素属性。 This is good for allowing changes to content.这有利于允许更改内容。

Try http://html5demos.com/contenteditable试试http://html5demos.com/contenteditable

Notice that your browser likely doesn't give you the toolbar with bold, italics, etc. Yet chrome will let you select text and use CTR-B, CTR-I, etc. Things are still being ironed out with this.请注意,您的浏览器可能不会为您提供带有粗体、斜体等的工具栏。但 chrome 可以让您选择文本并使用 CTR-B、CTR-I 等。事情仍在解决中。

Basically, it's a work in progress and your best bet for browser compatability is using a wysiwyg editer like tinymce et al.基本上,这是一项正在进行的工作,浏览器兼容性的最佳选择是使用像 tinymce 等人这样的所见即所得编辑器。

Where have you heard that?你在哪里听说过? Looking at W3Schools > HTML5 > textarea I can't see anything that hints this is true.看着W3Schools > HTML5 > textarea我看不到任何暗示这是真的。

Edit : added more links due to comments of people who dislike w3schools编辑:由于不喜欢 w3schools 的人的评论添加了更多链接

Even tho it's essentially the same thing at this point, here's the link to w3.org for wiki textarea, as well as the spec for textarea.即使在这一点上它本质上是相同的,这里是wiki textarea 的 w3.org 链接,以及 textarea 的规范 Also, here's the document with differences of html 4 and 5 as of march 29, 2012此外,这是截至 2012 年 3 月 29 日的 html 4 和 5差异的文档

You can use Quill instead of TextArea: https://quilljs.com/docs/quickstart/您可以使用 Quill 而不是 TextArea: https://quilljs.com/docs/quickstart/

<!-- Include stylesheet -->
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">

<!-- Create the editor container -->
<div id="editor">
  <p>Hello World!</p>
  <p>Some initial <strong>bold</strong> text</p>
  <p><br></p>
</div>

<!-- Include the Quill library -->
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>

<!-- Initialize Quill editor -->
<script>
  var quill = new Quill('#editor', {
    theme: 'snow'
  });
</script>

10 years 3 months ago the question was asked:HTML5 rich-text inside textarea. 10 年 3 个月前有人问过这个问题:HTML5 富文本 inside textarea。 I hope this link is along that line of possible solution.我希望这个链接沿着可能的解决方案。 https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Editable_content Has a nice a nice example of a RTF using editable content. https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Editable_content有一个很好的使用可编辑内容的 RTF 示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM