Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When I need to render the data in the editor with data, there is no way to render it properly #7

Open
makejun168 opened this issue Jun 22, 2021 · 0 comments

Comments

@makejun168
Copy link

Feature Request

When I saved the Editor data by network and then I need to render the data in the editor, there is no way to render it properly

Basic example

import React, { useEffect, useState } from "react";
import EditorJs from "@natterstefan/react-editor-js";

const TestEditor = () => {
  const [data, setData] = useState({});
  const [renderData, saveRenderData] = useState(null);
  let editor = null;

  const getDataByNetwork = async () => {
    /**
     * http Request code
     */
  };

  /**
   * get
   */
  useEffect(() => {
    const renderData = getDataByNetwork();
    setData(renderData);
  }, []);

  const onSave = async () => {
    // https://editorjs.io/saving-data
    try {
      const outputData = await editor.save();
      console.log("Article data: ", outputData);
    } catch (e) {
      console.log("Saving failed: ", e);
    }
  };

  return (
    <div>
      <button onClick={onSave}>Save</button>
      {/* docs: https://editorjs.io/configuration */}
      <EditorJs
        data={data}
        // will be `editorjs` by default
        holder="custom-editor-container"
        editorInstance={(editorInstance) => {
          // invoked once the editorInstance is ready
          editor = editorInstance;
        }}
      >
        <div id="custom-editor-container" />
      </EditorJs>
    </div>
  );
};

export default TestEditor;

Motivation

This feature does not seem to be supported by the official Editorjs, and I hope good developers can support it ! thank u

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant