-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Fix: Adding empty td tag inside table throws RangeError #6241
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
base: develop
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 6621e38 The changes in this PR will be included in the next version bump. This PR includes changesets to release 54 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Verified the changes on local and the fix seems to be working fine. Can we prioitize merging this request? Thanks! |
@Meyazhagan thanks, I'm seeing the same issue |
@@ -10,7 +10,7 @@ import { Content } from '../types.js' | |||
import { elementFromString } from '../utilities/elementFromString.js' | |||
|
|||
export type CreateNodeFromContentOptions = { | |||
slice?: boolean |
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.
Isn't it already possible to disable DOMParser.parseSlice
by calling createNodeFromContent
with the parameter slice: false
? @Meyazhagan . I believe your PR only changes the name of the parameter from slice
to useParseSlice
. It also changes its default value from true
to false
, which is a breaking change.
Therefore, I believe you could achieve the desired behavior of disabling DOMParser.parseSlice
with the current code, by calling createNodeFromContent
with the slice
parameter to false
. Could you check that this is true?
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.
If it is already possible to disable DOMParser.parseSlice
by calling createNodeFromContent
with the slice
parameter set to false
, then this PR is likely not necessary. Or is there anything I'm missing? Correct me if I'm wrong.
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.
@arnaugomez is it possible to disable it while inserting the content into the editor?
Ref: #6237
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.
I think it's possible to achieve the same behavior of disabling DOMParser.parseSlice
by calling createNodeFromContent
with the slice
parameter set to false
. Have you tried it? @hafeezulkareem-yellow @Meyazhagan
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.
@arnaugomez yeah I tried this changes, it is working!
quick question: createNodeFromContent
function is being used in two places, createDocument
and in insertContentAt
both the place also we setting slice
to false
to use parse
function, instead we can change in createNodeFromContent
, by default to using parse
function!
is there any good reason to have parseSlice
as default parser ?
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.
@Meyazhagan Yes, sure, if you think we can refactor it so that the code is simpler, create another PR with your changes and we'll review it. Thanks for your suggestion!
3265f9d
to
57d1b89
Compare
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.
Add a changeset
@bdbch Could you review this? To me it looks good but I'm not familiar with this code and I want to make sure it does not break things. |
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.
I don't like that we hard-code slice: false
into the insertContentAt
function as it can potentially break the behavior for existing implementations.
Could we please have that as an option for insertContent
and insertContentAt
if this needs to be changed depending on what kind of content you want to insert and how you want to do it?
@@ -74,6 +74,7 @@ export const insertContentAt: RawCommands['insertContentAt'] = (position, value, | |||
|
|||
try { | |||
content = createNodeFromContent(value, editor.schema, { | |||
slice: false, |
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.
Should this be hard-coded in the insertContentAt
function?
Maybe we could expose this as an option rather than enforcing this.
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.
Also make sure to pass through this new option in insertContent
.changeset/warm-yaks-speak.md
Outdated
"@tiptap/core": minor | ||
--- | ||
|
||
fix parsing of empty html table in insertContentAt func |
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.
Please update the changeset accordingly.
Hi @Meyazhagan @bdbch, I appreciate the work you are doing. It would be extremely helpful if we fast-track a fix for it. Thanks again for your time and support! |
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
...options, | ||
} | ||
|
||
let content: Fragment | ProseMirrorNode | ||
|
||
try { | ||
content = createNodeFromContent(value, editor.schema, { | ||
slice: options.slice, |
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.
I am concerned this is a breaking change. Before these changes, the createNodeFromContent
was called with the slice
value being false. But now it is called with a default value of true
. If the default value of options.slice was false
then this would not be a breaking change. But if the value should be true by default, then you have my approval. Just wanted to point this out.
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.
I would also rather keep the previous default to not cause breaking changes.
Changes Overview
Closes: #6237
By default we using
DOMParser.parseSlice
(this function is not parsing the full node.), and no option to disable itso, I created an option
useParseSlice
,https://discuss.prosemirror.net/t/domparser-parseslice-not-parsing-correctly-empty-table-cell/5510
Implementation Approach
Testing Done
Verification Steps
Additional Notes
Checklist
Related Issues