-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix copying html table with unequal number of cells in a row #5824
Fix copying html table with unequal number of cells in a row #5824
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
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.
Fantastic! Thank you, Katsia!
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
@KatsiarynaDzibrova tests are still failing |
Looking into it |
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.
Thank you, have you considered having a transform for this at the plugin level? While I think this approach is correct ultimately we want to lean toward a $normalizer (aka Schemas) which would help mitigate bad structures originating from text input and plugins.
This might also help simplify the additional exported utilities introduced in this PR. WDYT?
I thought about implementing it on plugin level, but I assumed that table plugin deals only with cells merging and background color logic. |
ping @zurfyx |
The normalizer was an example, we definitely want to think about it further before we can propose something generic. But you can still have the table plugin do these checks for you.
Because of the current implementation which relies on a full scan of rows and column this might not be very efficient for long tables so we may want to restrict to the paste event for now, you can control this via commands. In the future, we would ideally keep track of the previously explored columns and rows and resume the check from the position instead of scanning the full table. |
I agree that it makes sense to trigger this logic only on paste. |
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.
Thanks for iterating on this and sorry for keeping you blocked for so long, stamping but please address the last comment before merging
}, | ||
COMMAND_PRIORITY_EDITOR, | ||
), | ||
editor.registerNodeTransform(TableNode, (node) => { |
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.
Let's see how this perform, otherwise we may want to add a check that this only happens strictly on clipboard paste.
@Sahejkm this is the case we discussed offline, ideally this map is cached and future checks are O(1).
export function $computeTableMapSkipCellCheck(grid: TableNode) { | ||
const [tableMap] = $computeTableMapHelper(grid, null, null); | ||
return tableMap; | ||
} |
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.
export function $computeTableMapSkipCellCheck(grid: TableNode) { | |
const [tableMap] = $computeTableMapHelper(grid, null, null); | |
return tableMap; | |
} |
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 see any changes here
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.
@zurfyx I don't see any changes either in the suggestion, did you mean something else here?
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.
This function becomes redundant now that the other takes nullable values, doesn't it? Should we use the other function instead?
Issue: when copying html table with not equal number of cells in row the pasted table is broken. The number of cells in each row is different and it breaks on selection.
Fix: adding empty cells on paste
Before:
After: