Skip to content
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

Add table cell text alignment options to table block toolbar #6970

Closed

Conversation

SymbolicallyMe
Copy link

@SymbolicallyMe SymbolicallyMe commented May 27, 2018

Description

This PR addresses #6699 which requested that the left, center and right text alignment control be added to the table block toolbar.

How has this been tested?

This solution was tested using the following steps:

  1. Create a new page and add a Table block.
  2. Add text to each of the four initial table cells.
  3. Locate the new text alignment controls in the toolbar and adjust the alignment of text in all four cells.
  4. Ensure that selecting the same text alignment control, twice or more times in a row, toggles both the highlight of that specific control in the toolbar and the value of the table cell's CSS text-align property.
  5. Ensure that each adjustment of text alignment creates an undo level for the TinyMCE instance by checking changes that occur when pressing the Undo and Redo action buttons.
  6. Ensure that all text alignment changes save correctly by previewing the page.

Screenshot

ezgif-4-4ea90c5714

Types of changes

Added dependencies:
In order to have functioning text alignment controls for the Table block, the following dependencies were added:

  • External: Lodash's find function
  • WordPress: AlignmentToolbar
  • Internal: domToFormat function from the rich-text editor component group.

Added TinyMCE event handler:
A nodechange TinyMCE event handler was added within the handleSetup method of the table-block component in order to update the alignment toolbar to match the CSS text-align property of the table cell that is being focused.

Added new method to the Table block:
The textAlign method was added to the table-block component to serve as the onChange callback function for the AlignmentToolbar component. This allows us to update the focused table cell's text alignment when the user clicks on either the left, center or right text alignment control.

This was tested in:

  • WordPress 4.9.6
  • Gutenberg 2.9.2
  • Apache/PHP 7.1.16
  • MySQL 5.7.22

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@nfmohit
Copy link
Member

nfmohit commented May 28, 2018

I believe you'll want to move the alignment setting from the block toolbar to the sidebar, because that long toolbar might not fit in mobile devices.

@ZebulanStanphill
Copy link
Member

Yeah, the block alignment toolbar should be moved to the inspector/sidebar. Having both it and the text alignment options in the toolbar make it too long for mobile.

@SymbolicallyMe
Copy link
Author

@nfmohit-wpmudev @SuperGeniusZeb The block alignment toolbar was moved to the inspector sidebar.

It would be nice to have all related toolbar controls in the same area for desktop and mobile. Seems like the toolbar container would have to allow controls to wrap to the next line, sort of how the Classic block controls works.

screen shot 2018-05-29 at 1 15 23 pm

@aduth
Copy link
Member

aduth commented Sep 13, 2018

Is it likely this will be resumed, or can it be closed? Or is it needing a fresh review?

@aduth aduth added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Sep 13, 2018
@aduth
Copy link
Member

aduth commented Oct 15, 2018

Closing as stale without response. It can be reopened if development is expected to continue, or a new pull request can be submitted.

@aduth aduth closed this Oct 15, 2018
@MrSwed
Copy link

MrSwed commented Oct 31, 2019

in WP 5.2,4 there is no way to align cell content

image

how to can align cell content in WP 5.2.4 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants