Dynamically change Quill placeholder

无人久伴 提交于 2019-12-30 09:37:31

问题


I know that on instantiation of a Quill editor, there is a placeholder option. Is there a way that I can change this placeholder dynamically after the editor is instantiated?


回答1:


The placeholder is implemented with a CSS rule:

.ql-editor::before { 
   content: attr(data-placeholder);
}

So you can do quill.root.dataset.placeholder = 'Your new placeholder';




回答2:


If you are using react-quill

The placeholder in the tooltip is coming from the value of the data-link attribute. So you can replace the value with your own when the component finishes mounting.

Here is the code:

componentDidMount() {
    //Replcae link in placeholder to your own text
    document.querySelector('.ql-tooltip-editor input').setAttribute("data-link", "your own placeholder");
}

Note: I am using bubble theme



来源:https://stackoverflow.com/questions/38936594/dynamically-change-quill-placeholder

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!