RTF Format in Web Text Editor

拟墨画扇 提交于 2019-12-03 15:45:34

Quill is a rich text web editor.

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

Create the toolbar container

<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>

Include the Quill library

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

Initialize Quill editor

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

Setting the editor text

editor.setText("RTF document ");

Getting the editor text

by default 0 will get everything in the editor

var text = editor.getText(0);

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

You could use Word to load the RTF file, then Save As HTML. Works but generates a pile of spurious MS- tags.

Or I've written a program (Visual Studio) that you can have if you want - it's a bit basic, doesn't deal with fonts, but converts most text formatting. Let me know if you're interested (I'd need to tidy it a bit - it's very old - a bit like me).

Though as I write this, I see that Wamadahama may have a better solution.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!