【发布时间】:2020-01-01 14:26:24
【问题描述】:
使用工具选项中的添加链接工具添加链接允许我添加链接,但在从编辑器保存数据并刷新页面后,链接溢出文本编辑器后的文本。
<div class="short-description" style="height: 150px;">
{!! $product_details->short_description !!}
</div>
var quill_short = new Quill('.short-description', {
theme: 'snow',
modules: {
toolbar: toolbarOptions
},
});
var htmlButton = document.querySelector('#short-description-row .ql-html');
htmlButton.addEventListener('click', function() {
var htmlEditor = document.querySelector('#short-description-row .ql-html-editor');
if (htmlEditor) {
console.log(htmlEditor.value.replace(/\n/g, ""));
quill_short.root.innerHTML = htmlEditor.value.replace(/\n/g, "");
quill_short.container.removeChild(htmlEditor);
} else {
options = {
"indent": "auto",
"indent-spaces": 2,
"wrap": 80,
"markup": true,
"output-xml": false,
"numeric-entities": true,
"quote-marks": true,
"quote-nbsp": false,
"show-body-only": true,
"quote-ampersand": false,
"break-before-br": true,
"uppercase-tags": false,
"uppercase-attributes": false,
"drop-font-tags": true,
"tidy-mark": false
}
htmlEditor = document.createElement("textarea");
htmlEditor.className = 'short-desc ql-editor ql-html-editor'
htmlEditor.innerHTML = tidy_html5(quill_short.root.innerHTML, options).replace(/\n\n/g, "\n");
quill_short.container.appendChild(htmlEditor);
}
});
quill_short.on('text-change', function(delta, oldDelta, source) {
var quill_data = document.querySelector(".short-description .ql-editor").innerHTML;
console.log('quill_data S',quill_data);
$('#short-description').val(quill_data);
})
document.querySelector(".short-description .ql-editor").innerHTML = $('#short-description').val();
【问题讨论】: