2021年4月7日星期三

What part of the react-quilljs object should I save to the database in the backend?

I am trying to use react-quilljs to implement text editor in a full mern stack app, but I am not sure what part of the quill object should I save to the database in the backend. I have the follow code for the editor:

import React, { useState } from 'react';    import { useQuill } from 'react-quilljs';  // or const { useQuill } = require('react-quilljs');    import 'quill/dist/quill.snow.css'; // Add css for snow theme  // or import 'quill/dist/quill.bubble.css'; // Add css for bubble theme    export default () => {    const { quill, quillRef } = useQuill();      const [content, setContent] = useState('');      console.log(quill); // undefined > Quill Object    console.log(quillRef); // { current: undefined } > { current: Quill Editor Reference }      React.useEffect(() => {      if (quill) {        quill.on('text-change', () => {          setContent(?) // What part of the quill object I need to use here to set the content before sending it to the backend <-----------------          console.log(quill.getFormat());          console.log('Text change!');        });      }    }, [quill]);      const submitHandler = (e) => {//here I will send the editor content to the bakcend};      return (      <div style=>        <div ref={quillRef} />        <form onSubmit={submitHandler}>          <button type='submit'>Submit</button>        </form>      </div>    );  };  
https://stackoverflow.com/questions/66996814/what-part-of-the-react-quilljs-object-should-i-save-to-the-database-in-the-backe April 08, 2021 at 11:06AM

没有评论:

发表评论