Cavein Muthama
Cavein Muthama

Reputation: 35

using rich-markdown-editor react

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;

Upvotes: 0

Views: 871

Answers (1)

Doylet
Doylet

Reputation: 19

Try

<Editor id="123" value={content} onChange={(value) => setContent(value()} />

Upvotes: 1

Related Questions