我在DOM中的元素的單擊事件中動態實例化QuillJS編輯器。所以我的要求是,一旦用戶完成了該元素的編輯,他/她應該能夠關閉編輯器。目前,我沒有在羽毛球API中看到任何關閉方法。啓用/禁用API方法不適用於我,因爲我想完全關閉編輯器並向用戶顯示他/她在查看編輯器之前所看到的相同視圖,當然還有保存的更改。如何在編輯完成時關閉套筒編輯器
這樣做的演示可以在這裏
https://codepen.io/curiousdj/pen/eEjbPK
const options = { theme: "snow" };
var divs = document.getElementsByTagName("div");
var initializeQuill = function (e){
if(!this.quill){
console.log(e);
this.target = event.currentTarget;
this.quill = new Quill(this.target, options);
this.target.children[0].onclick = function(et) { et.preventDefault(); };
this.target.children[0].onblur = function(l) {
l.target.parentElement.quill.close;
};
}
this.quill.focus();
e.stopPropagation();
e.preventDefault();
}
for(var i = 0; i < divs.length; i++){
divs[i].onclick = initializeQuill;
}
非常感謝@Joe .. –