How do I retrieve the contents of a Quill text editor

前端 未结 2 1871
时光说笑
时光说笑 2020-12-09 15:39

I am using the quill text editor in a javascript app and I need to retrieve the contents of the text editor as a string with the HTML included but the docs are a little spar

2条回答
  •  感情败类
    2020-12-09 16:20

    Depends what you want to get, here's an example showing a few ways:

    http://codepen.io/k3no/pen/amwpqk

    var delta = editor.getContents();
    var text = editor.getText();
    var justHtml = editor.root.innerHTML;
    preciousContent.innerHTML = JSON.stringify(delta);
    justTextContent.innerHTML = text;
    justHtmlContent.innerHTML = justHtml;
    

提交回复
热议问题