Jungwoo-An / react-editor-js

โš›๏ธ๐Ÿ“The unofficial editor-js component for React
https://codesandbox.io/s/react-editor-js-v2-34bfl
MIT License
954 stars 77 forks source link

Cannot access editorJS instance #183

Closed jimmycrequer closed 2 years ago

jimmycrequer commented 2 years ago

Environment

Describe

With the newest version we are no longer able to access the editorJS instance. However, our application relies on having access to that instance to handle some specific logic, such as appending a new empty block on readonly toggle.

What do you recommend to handle such cases?

Jungwoo-An commented 2 years ago

@jimmycrequer Hi! First of all, thanks for your interest! ๐Ÿ‘‹

I'm sorry. Can you show me an example of the use case?

Thanks!

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

jimmycrequer commented 2 years ago

@Jungwoo-An Sorry for long wait !

I want to do something like this :

const Editor: FC = (data) => {
  const editorJS = useRef<EditorJS>();

  const ReactEditorJS = createReactEditorJS();

  return (
    <>
      <ReactEditorJS
        onInitialize={(instance) => { editorJS.current = instance }}
        defaultValue={data}
        tools={EDITOR_JS_TOOLS}
      />
      <button onClick={() => { editorJS.current!.blocks.insert() }}>
        Add an empty block
      </button>
    </>
  );
};

But with the latest version, we don't have access to blocks anymore.

What is the recommended approach to handle such case?

Babbz75 commented 2 years ago

Has anyone found a way to use blocks in the most recent version?