Web文本编辑器中的RTF格式

问题描述:

网上是否有支持RTF格式文档输入的文本编辑器?

Is there a text editor on the web that supports input from RTF-formatted documents?

我知道这对webdev来说有点奇怪,但是我需要从数据库中读取RTF文档并在基于Web的文本编辑器中编辑它们并将其存储回RTF中。在我过度投入转换工具之前,我想我会问是否有许多网络文本编辑器支持RTF。我的研究显示他们没有。

I know it is a bit of an odd request for webdev, but I need to read RTF documents from the database and edit them in a web-based text editor and store it back in RTF. Before I invest too heavily in a conversion tool, I thought I would ask if any of the many web text editors supported RTF. My research is showing that they don't.

此外,由于这是一个MVC 4.6应用程序,编写双向RTF-HTML是一项巨大的工作吗? C#中的转换工具?

Additionally, since this is an MVC 4.6 application, would it be a huge effort to write a two-way RTF-HTML conversion tool in C#?

编辑器将收到的示例输入:

{\rtf1 \\ \\ ansi {\\\ tonttbl \f0 \fswiss Helvetica;} \f0 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ p>

Sample input that would be received by the editor: "{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard This is some {\b bold} text.\par }"

Quill 是一个富文本的Web编辑器。

Quill is a rich text web editor.

使用快速入门中的代码可以像这样启用它

Using the code from the quickstart you could enable it like this

<div id="toolbar">
  <button class="ql-bold">Bold</button>
  <button class="ql-italic">Italic</button>
</div>



创建编辑器容器



Create the editor container

<div id="editor">
  <div>Hello World!</div>
  <div>Some initial <b>bold</b> text</div>
  <div><br></div>
</div>



包括Quill库



Include the Quill library

<script src="//cdn.quilljs.com/0.20.1/quill.js"></script>



初始化Quill编辑器



Initialize Quill editor

<script>
  var quill = new Quill('#editor');
  quill.addModule('toolbar', { container: '#toolbar' });
</script>



设置编辑器文本



Setting the editor text

editor.setText("RTF document ");



获取编辑器文本



默认情况下,0将获得编辑器中的所有内容

var text = editor.getText(0);

另见 Mozilla发布,定义了如何实现自己的富文本编辑器。

also see this Mozilla post which defines how to implement your own rich text editor.