QuillJS 不适用于 textarea [英] QuillJS doesn't work with textarea

查看:20
本文介绍了QuillJS 不适用于 textarea的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的 Django 1.10 模板中的特定表单字段上使用 QuillJS,如下所示:

I am trying to use QuillJS on a specific form field in my Django 1.10 template as follows:

<link href="https://cdn.quilljs.com/1.1.3/quill.snow.css" rel="stylesheet">

<script src="https://cdn.quilljs.com/1.1.3/quill.js"></script>
<!-- Initialize Quill editor -->
<script>
  var quill = new Quill('#id_text', {
    theme: 'snow'
  });
</script>

问题是 Django 将我想使用 Quill 的表单字段呈现为 textarea 而不是 div,而 Quill 似乎无法处理它:应用于文本的任何效果都不会在视觉上或结果输出中注册,并且当我尝试编辑现有记录时,初始文本不会显示在编辑器中,即使它存在于textarea 标签.

The problem is that Django renders the form field I want to use Quill on as a textarea instead of a div, and Quill doesn't seem to work on it: any effects applied to text don't register either visually or in the resulting output, and when I try to edit an existing record the initial text doesn't show up in the editor, even though it is there in the source HTML between the textarea tags.

Quill 不能与 textarea 一起使用是一个已知问题,还是有其他可能出错的地方?

Is it a known issue that Quill doesn't work with textarea or is there something else that could be wrong?

推荐答案

您可以将 Quill 与 div 一起使用并同步编辑器的内容(Delta) 与表单中的隐藏输入字段.

You can use Quill with a div and sync the editor's content(Delta) with a hidden input field in the form.

有一个 Quill 表单提交示例.

There is a Quill Form Submit example.

这篇关于QuillJS 不适用于 textarea的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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