-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Set the element after instantiation #1161
Comments
Hey, thanks for supporting tiptap 2! |
Happy to support! Excited to be using such a fun project! I can wait for the DOM, but it means I have a round trip - I want the editor to be created without knowledge of where the editor-element actually exists. Looking at my pseudocode above, the elements It might be a limitation in the way I'm thinking about it, will have another think :) |
@philippkuehn I've recorded a quick video (7 min) running through example code. I cover the current situation, and walk through how the code would be improved with having something like TLDR; I can make it work by waiting for the DOM, but it adds a lot of complexity. |
Solved it in a hacky, undocumented way.
It might be worth documenting or formalising this, it's a massive improvement to my codebase :) |
Thanks for sharing! It’s added to the documentation. |
After a little thought, I think it might be best to advise this approach:
That way you're not making promises about TipTap internals, and can make the element attribute required. |
Since I can't fork the repo, this is my docs proposal: https://github.com/ueberdosis/tiptap-next/blob/main/docs/src/docPages/api/editor.md Init before mountingYou can initiate your editor before mounting. This is useful when your DOM is not yet available, or you want to decouple the editor from the DOM.
You can then mount the element at a later date.
|
Thanks, I updated the documentation! |
Is your feature request related to a problem? Please describe.
Instantiation
Describe the solution you’d like
I'd like to be able to create the editor without an element, and use a method to set the element elsewhere in my app.
This way we can create the editor() without having to know if the DOM is ready, nor which element will be responsible for rendering. This will help me decouple the various UI elements for my application, ie:
^ in this example the
<Editor-Document>
may get access totiptap
and calltiptap.setElement(...)
once ready. Other components may also get access totiptap
to listen to events etc.Describe alternatives you’ve considered
Tried this without success
The text was updated successfully, but these errors were encountered: