-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feature(html): allow caller to specify a document
implementation in generateHTML()
#4047
Conversation
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
document
implementation in generateHTML()
Nice idea. It seems like Netlify is crashing though because of this:
Could you take a look? |
Well that was a silly error. I can't get that command to run locally for some reason. Letting CI run again... |
@bdbch done, I think... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! I thought about adding this to the documentation, but I think we don't even have a documentation page that references getHTMLFromFragment
yet.
@svenadlung could you take a second look? Otherwise this one would be fine for me.
document
implementation in generateHTML()
document
implementation in generateHTML()
Please describe your changes
Allows callers of the
generateHTML()
fn to pass their owndocument
implementation. This is necessary becauserenderHTML()
can return aDOMElement
as aDOMOutputSpec
. However, therenderHTML()
method on nodes doesn't provide access to thedocument
used in the render (at least as far as I can tell).TipTap assumes that the
document
passed to DOMSerializer can always be thedocument
that comes fromzeed-dom
. However,zeed-dom
appears to be incompatible with jsdom. Without the change in this PR, any node that returns anHTMLElement
created via jsdom is serialized as the string{}
.How did you accomplish your changes
I added an option to
generateHTML()
that allows callers to specify adocument
alternative tozeed-dom
.How have you tested your changes
I have this implementation working in another project. I've not yet tested it in this repo--as my first PR, I want to see where the tests fail an then follow up.
How can we verify your changes
TBD
Remarks
An alternative might be to add the
document
being used to serialize the fragment to therenderHTML()
method, so that a node could do something like:As it stands with this PR, they can just use:
That approach would be a little less magical, and perhaps easier to use on the part of the caller. However, the approach I've taken works for my project and I'd like feedback from the maintainers before going on that more involved API change.
Checklist
Related issues
[add a link to the related issues here]