如何解决从HTML元素获取Quill编辑器实例
假设我为某个元素创建了一个编辑器实例,例如通过class B : public A {
char* t;
public:
B(int a,std::vector<int> k,int* z,char* t) : A(a,std::move(k),z),t(t) {
// again,t can't be an owning pointer
}
// rule of 5 start
B(const B& Other) : A(Other),t(Other.t) {} // copies the A part + t
// similar
B(B&& Other) : A(std::move(Other)),t(std::exchange(Other.t,nullptr)) {}
B& operator=(const B& Other) {
if(this == &Other) return *this;
// use the base class operator by specifying it explicitly
A::operator=(Other); // use the base class' copy assignment operator
t = Other.t; // just add t
return *this;
}
// similar as in copy assignment
B& operator=(B&& Other) {
if(this == &Other) return *this;
A::operator=(std::move(Other)); // use the base class' move assignment operator
std::swap(t,Other.t); // and just swap t
return *this;
}
~B() = default;
// rule of 5 end
};
现在,我想在只有元素可用的情况下获取此编辑器实例,例如类似于const editor = new Quill('#editor',{...some options});
原因是我正在构建一个可以插入现有网站的组件,以增强其编辑器,并且我需要一种获取其编辑器实例的方法。
解决方法
这可以通过使用Quill.find('#editor');
来完成,请参见https://quilljs.com/docs/api/#find-experimental
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。