What do I need to do to set Quill's content or output to be JSON/delta instead of HTML?
I can't believe I'm asking such a simple question but I can't find the answer anywhere.
There's nothing about how to set the format in either the QuillJS doc or react-quill doc.
import React, { useState } from "react";
import ReactQuill, from 'react-quill';
import 'react-quill/dist/quill.snow.css';
export const Comment = () => {
const [value, setValue] = useState('');
function submit(e) {
e.preventDefault();
console.log(value) # This currently returns HTML instead of JSON
}
return (
<>
<ReactQuill theme="snow" value={value} onChange={setValue}/>
<p>{value}</p>
<button onClick={submit}>Submit</button>
</>
);
}
It looks like the
onChange
prop is a function that has the HTML contents as the first argument, which will be the value used bysetState
. You'll want to define a custom function that setsvalue
toeditor.getContents()
, which returns a Delta representing the current document.