QuillJS不适用于textarea [英] QuillJS doesn't work with 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 $ c $之间的源HTML中也存在初始文本,该初始文本也不会显示在编辑器中。 c>标签。
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.
有一个鹅毛笔表单提交示例。
这篇关于QuillJS不适用于textarea的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!