Web文本编辑器中的RTF格式 [英] RTF Format in Web Text Editor

查看:477
本文介绍了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.

这篇关于Web文本编辑器中的RTF格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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