0

I am trying to use rich-markdown-editor to get values but the method am using is not modular. Can someone suggest a better way. I have tried both onChange and onSave but cannot seem to get them to work.According to their documentation

onSave({ done: boolean }): void This callback is triggered when the user explicitly requests to save using a keyboard shortcut, Cmd+S or Cmd+Enter. You can use this as a signal to save the document to a remote server.

onChange(() => value): void This callback is triggered when the contents of the editor changes, usually due to user input such as a keystroke or using formatting options. You may use this to locally persist the editors state.

import React, { useState } from "react";
import Editor from "rich-markdown-editor";

const Whiteboard = () => {
  const [content, setContent] = useState("");

  return (
    <div>
      <div>
        <h1>Your Content</h1>
        <Editor id="123" value={content} onChange={setContent} />
      </div>
      {content}
    </div>
  );
};

export default Whiteboard;
3
  • It's unclear from your question what the problem is. Is the content in the editor not being persisted? Commented Aug 23, 2021 at 16:49
  • Yes...I want to store the content in the state in markdown format the persist it to the database but I can not figure how to do that Commented Oct 25, 2021 at 16:32
  • 1
    useState is for preserving data within your application, i.e. so that you can reference it from different functions (using the content variable). Saving that variable to a database like SQL would be a different task; there are lots of great answers here already about how to do that. Commented Oct 25, 2021 at 18:21

1 Answer 1

1

Try

<Editor id="123" value={content} onChange={(value) => setContent(value()} />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.