如何在表单中发布羽毛笔编辑器的内容? [英] How do I post contents of a Quill editor in a form?

查看:83
本文介绍了如何在表单中发布羽毛笔编辑器的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这是一个非常常见的情况.我通常会有这种形式:

I have what I think is a very common scenario. I would normally have this form:

<form method="post">

<textarea name="text"></textarea>
<input type="submit" value="Save" />

</form>

然后使用PHP,我将从形式($ _POST ['text'])捕获数据,并且可以在另一个变量中使用它.

Then with PHP I would capture the data from the form ($_POST['text']) and I could use that in another variable.

现在,我想使用 Quill ,以便用户使用一个不错的富文本编辑器.羽毛笔似乎非常适合此操作,并且文档非常详细.但是,由于某种原因,我找不到如何将数据发布"到表单中.有一个单个示例页面可以满足我的要求,但是我无法完全实现在我的示例中,以及快速入门指南中,都没有讨论这个相当基本的主题(对我而言) ,在文档中也找不到.

Now, I'd like to use Quill so users have a nice rich text editor instead. Quill seems very well suited for this and the documentation is very detailed. However, for some reason I can not find how I can "post" the data to the form. There is one single sample page that sort of does what I want, but I am unable to fully implement this in my sample, and in the quick start guide this rather fundamental (to me) topic is not discussed, and I can not find this in the documentation either.

是否应该像这样使用羽毛笔?我在监督什么吗?有推荐的方法可以使这项工作吗?

Is Quill supposed to be used like this? Am I overseeing something? Is there a recommended way to make this work?

这是我目前拥有的:

<!doctype html>
<html>
<head>
<title>Test</title>
<meta charset="UTF-8" />
<link href="https://cdn.quilljs.com/1.0.0/quill.snow.css" rel="stylesheet">
</head>
<body>
<form method="post">


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


<form method="post">

<!-- Create the editor container -->
<div id="editor">
  <p>Hello World!</p>
</div>

<input type="submit" value="Save" />

</form>

<!-- Include the Quill library -->
<script src="https://cdn.quilljs.com/1.0.0/quill.js"></script>

<!-- Initialize Quill editor -->
<script>
  var editor = new Quill('#editor', {
    modules: { toolbar: '#toolbar' },
    theme: 'snow'
  });
</script>
</body>
</html>

推荐答案

您可以查看有关它的相关讨论 https://github.com/quilljs/quill/issues/87

You can check related discussion about it https://github.com/quilljs/quill/issues/87

虽然这不是理想的解决方案:

While this is not an ideal solution :

var myEditor = document.querySelector('#editor')
var html = myEditor.children[0].innerHTML

这篇关于如何在表单中发布羽毛笔编辑器的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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