【发布时间】:2020-04-27 15:34:40
【问题描述】:
我正计划在我的网站中实现 Quill,但不幸的是 insertText 函数正在生成以下内容:
TypeError: n.appendChild is not a function shadow.ts:150
wrap shadow.ts:150
formatAt shadow.ts:70
format embed.ts:26
value cursor.js:25
formatAt embed.ts:30
formatAt container.ts:98
forEachAt linked-list.ts:114
formatAt container.ts:97
formatAt block.ts:42
value block.js:78
value cursor.js:35
value selection.js:110
value quill.js:157
a quill.js:437
value quill.js:149
value toolbar.js:101
我正在扩展文本印迹并尝试使用文档 notes from here(复制分隔符代码),但输出最终只打印到编辑器中。
JS
const Text = Quill.import("blots/text");
class SchoolNameBlot extends Text {}
SchoolNameBlot.blotName = "tagName";
SchoolNameBlot.tagName = "NAME";
const toolbarOptions = [['bold', 'italic'], ['link', 'image', 'tagName']];
Quill.register(SchoolNameBlot);
const options = {
debug: 'info',
theme: 'snow',
modules: {
toolbar: toolbarOptions
}
}
const editor = new Quill("#msgText", options);
$("#tagName-Button").click(function() {
let range = editor.getSelection(true);
editor.insertText(range.index, "insertText");
});
HTML 元素:
<div class="col-md-11">
<div id="msgText"></div>
</div>
输出
据我所知,我正确使用了 Quill,所以我不确定为什么会产生这个错误。我正在使用他们页面上提供的CDN's。
【问题讨论】:
标签: javascript quill