-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Table Block: Preserve Column Alignment when Pasting Markdown Tables #69322
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
Table Block: Preserve Column Alignment when Pasting Markdown Tables #69322
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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.
Sorry for the late reply.
I'm not sure why we need to use the getAlignmentFromStyle()
function to extract the text alignment style.
Can't we extract simply like this?
gutenberg/packages/block-library/src/paragraph/transforms.js
Lines 26 to 34 in e49849c
const { textAlign } = node.style || {}; | |
if ( | |
textAlign === 'left' || | |
textAlign === 'center' || | |
textAlign === 'right' | |
) { | |
attributes.align = textAlign; | |
} |
Additionally, it would be good to add a unit test here:
describe( 'pasteHandler', () => { |
You're right! I've simplified the implementation and also added a unit test. |
I'm not familiar with the native app, but I think we need to update this field to fix the Mobile unit test:
cc @dcalhoun @geriux We are trying to preserve column alignment when pasting table HTML that has alignment applied. However, mobile unit tests are failing, with the |
I believe the test failure stems from subtle differences in global For this particular context, the diff --git a/test/native/jest.config.js b/test/native/jest.config.js
index 7123275873..d91d3fd5a3 100644
--- a/test/native/jest.config.js
+++ b/test/native/jest.config.js
@@ -27,6 +27,9 @@ const RAW_HANDLING_UNSUPPORTED_UNIT_TESTS = [
'figure-content-reducer',
'normalise-blocks',
'image-corrector',
+ // Disabled due to jsdom-jscore-rn limitations
+ // See: https://github.com/WordPress/gutenberg/pull/69322#issuecomment-2789510963
+ 'paste-handler',
];
module.exports = {
Additional context: the Table block type is unsupported in the native mobile editor, so the proposed changes should have no impact on the native mobile editor. |
@dcalhoun Thank you for the feedback! @Sukhendu2002 Can we use the following approach?
|
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!
…ordPress#69322) * Preserve column alignment when pasting Markdown tables * Simplify column alignment extraction and add unit tests * Rename markdownTableHTML variable and reorder test cases * Disable paste-handler test in native * Update test description Co-authored-by: Sukhendu2002 <sukhendu2002@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: dcalhoun <dpcalhoun@git.wordpress.org> Co-authored-by: stronenv <vevas@git.wordpress.org>
What?
Closes: #69319
This PR improves the Table block by making sure column alignments are preserved when pasting Markdown tables.
Testing Instructions
Screenshots or screencast