如何在textarea
下面显示工具栏。
我的代码:
var quill = new Quill('#txtMessage', {
theme: 'snow',
modules: {
toolbar: {
container: [
['bold', 'italic', 'underline'],
[{
'list': 'ordered'
}, {
'list': 'bullet'
}],
['clean'],
['code-block'],
[{
'variables': ['{Name}', '{Email}']
}],
],
handlers: {
"variables": function(value) {
if (value) {
const cursorPosition = this.quill.getSelection().index;
this.quill.insertText(cursorPosition, value);
this.quill.setSelection(cursorPosition + value.length);
}
}
}
}
}
});
// Variables
const placeholderPickerItems = Array.prototype.slice.call(document.querySelectorAll('.ql-variables .ql-picker-item'));
placeholderPickerItems.forEach(item => item.textContent = item.dataset.value);
document.querySelector('.ql-variables .ql-picker-label').innerHTML = 'Variables' + document.querySelector('.ql-variables .ql-picker-label').innerHTML;
<script src="//cdn.quilljs.com/1.3.6/quill.js"></script>
<link href="//cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet"/>
<link href="//cdn.quilljs.com/1.3.6/quill.bubble.css" rel="stylesheet"/>
<div id="txtMessage"></div>
答案 0 :(得分:1)
我不明白为什么不只使用css。
这样的事情:
var quill = new Quill('#editor-container', {
modules: {
toolbar: [
[{
header: [1, 2, false]
}],
['bold', 'italic', 'underline'],
['image', 'code-block']
]
},
placeholder: 'Compose an epic...',
theme: 'snow' // or 'bubble'
});
&#13;
#editor-container {
height: 375px;
}
.editor-wrapper {
position: relative;
}
.ql-toolbar {
position: absolute;
bottom: 0;
width: 100%;
transform: translateY(100%);
}
&#13;
<script src="//cdn.quilljs.com/1.3.6/quill.js"></script>
<link href="//cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet"/>
<link href="//cdn.quilljs.com/1.3.6/quill.bubble.css" rel="stylesheet"/>
<div class="editor-wrapper">
<div id="editor-container">
</div>
</div>
&#13;
答案 1 :(得分:0)
这可以解决问题:
.ql-container {
display: flex;
flex-direction: column-reverse;
}
答案 2 :(得分:0)
您可以使用flexbox实现此目的。这样的事情应该可以解决问题:
<div class="d-flex flex-column-reverse">
<div id="quill-editor"></div>
</div>
还请记住,您需要更新Quill css样式(边界等)