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

Multiple EditorJs in the DOM #11

Closed
hasufell opened this issue Nov 15, 2019 · 12 comments
Closed

Multiple EditorJs in the DOM #11

hasufell opened this issue Nov 15, 2019 · 12 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@hasufell
Copy link

It seems I can only have one. I have virtual tabs where each of the sub-doms are hidden.

Only the first EditorJs shows.

@Jungwoo-An
Copy link
Owner

@hasufell Hi! First of all, thanks for your interest! 😍

It's difficult to understand. can you reproduce on codesandbox or others?

@Jungwoo-An Jungwoo-An added the bug Something isn't working label Nov 16, 2019
@hasufell
Copy link
Author

Check out this: https://codesandbox.io/s/react-editor-js-elilp

It seems it has something to do with the hidden attribute:

ReactDOM.render(
  <div>
    <div hidden={true}>
      <ReactEditor />
    </div>
    <div>
      <ReactEditor />
    </div>
  </div>,
  document.getElementById("root")
);

@Jungwoo-An
Copy link
Owner

@hasufell Thanks!

I'll check it. sorry. (feel free to submit pr whenever you want)

@hasufell
Copy link
Author

hasufell commented Nov 19, 2019

I thought maybe it's the <div id="editor-js" />, but appears it isn't: https://codesandbox.io/s/react-typescript-te1ky

It appears there must be some instance-sharing going on.

@Jungwoo-An
Copy link
Owner

@hasufell Hi!

You may need to set different holder property between editors. (Check Ref)

ex)

render() {
  return (
    <div>
      <ReactEditorJs holder="holder">
        <div id="holder" />
      </ReactEditorJs>
      <ReactEditorJs holder="holder2">
        <div id="holder2" />
      </ReactEditorJs>
    </div>
  );
}

Thanks!

@hasufell
Copy link
Author

IMO, this should be done automatically and the ids be randomized by default. Only className should be set to something like editor-js.

@Jungwoo-An
Copy link
Owner

I don't think so.
by default, react-editor-js use div#holder.
However, in some cases, i think can use a different tag or id.

Thanks!

@hasufell
Copy link
Author

I don't think so.

Why not? API-wise this is neither documented properly, nor intuitive, nor what you would expect from most react libraries.

@Jungwoo-An
Copy link
Owner

@hasufell

Thanks for your good opinion. on second thought, you are right.

I'll change id to random value by default. (If you don't mind, feel free to submit pull request)

@hasufell
Copy link
Author

Sure, I'll try to write something up.

@Jungwoo-An Jungwoo-An assigned Jungwoo-An and hasufell and unassigned Jungwoo-An Nov 20, 2019
@Jungwoo-An Jungwoo-An added good first issue Good for newcomers enhancement New feature or request and removed bug Something isn't working labels Jan 17, 2020
@jakekara
Copy link
Contributor

Not sure if this in line with the overall code base, as I haven't looked at this project's code prior to fiddling with this, but here's one approach.

This adds a constructor to add a holderID property that gets populated wherever the hard-coded "editor-js" had appeared.

jakekara@122a032

@Jungwoo-An
Copy link
Owner

resolved (#76)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants