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

Support pasting table with lists content #46512

Closed

Conversation

mpkelly
Copy link
Contributor

@mpkelly mpkelly commented Dec 13, 2022

Related to #45774

What?

It's based on requirement 2 from #45774. If you paste a table which includes ul or ol elements, these elements will be converted to simple content and formatted with whitespace to try and keep the original list structure. This avoids having to support complex nested content in tables.

Why?

Increase parity between Gutenberg and other editors.

How?

Allow the list schema to be embedded into td and th. Add a transform function for tables that can convert these tables into simple content.

Testing Instructions

  1. Check out this branch and create a table in Google Docs that has ordered or unordered in its cells. See the screenshots below.
  2. Paste the table into Gutenberg to see the result
  3. Try adding content before/after the list.
  4. Try nesting lists to any depth.

Testing Instructions for Keyboard

Screenshots or screencast

Source table (Google docs)

image

Gutenberg editor after pasting the table above

image

How the td which contained the list looks in the DOM when previewing

image

… is converted to simple content which is formatted to look like a list using whitespace.
@mpkelly mpkelly requested a review from ajitbohra as a code owner December 13, 2022 16:02
@mpkelly
Copy link
Contributor Author

mpkelly commented Dec 13, 2022

@danielbachhuber , @ellatrix. I recreated this PR from the draft #46254. Can you give it a review?

I can beef up the test suite but for now I would like to get some feedback and make sure this PR will be accepted.

@danielbachhuber danielbachhuber self-requested a review December 13, 2022 23:05
Copy link
Member

@danielbachhuber danielbachhuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet! This seems to work pretty well to me from a product perspective. I'll defer to others on the codes.

For Example 4 (below), do we want to alternate between letters and numbers?

Example 1

Google Docs

image

Paste Into Gutenberg

image

Example 2

Google Docs

image

Gutenberg Paste

image

Example 3

Google Docs

image

Paste Into Gutenberg

image

Example 4

Google Docs

image

Paste Into Gutenberg

image

Example 5

Google Docs

image

Paste Into Gutenberg

image

@danielbachhuber
Copy link
Member

@mpkelly Can you rebase trunk and make sure all of the tests pass?

@mpkelly
Copy link
Contributor Author

mpkelly commented Dec 21, 2022

Thanks for the ping, @danielbachhuber. There are some test failures, but I can't see why. The colspan test I added in a previous PR fails even though that's working fine in the dev environment. Another unrelated test fails due to a difference in how whitespace is encoded. I will try and get everything passing again.

… is converted to simple content which is formatted to look like a list using whitespace.
… the fixture test; add missing attribute to the out-file that got lost somewhere in the merging/rebasing.
… the fixture test; add missing attribute to the out-file that got lost somewhere in the merging/rebasing.
@mpkelly mpkelly closed this Dec 23, 2022
@mpkelly mpkelly deleted the add/support-for-pasting-lists branch December 23, 2022 12:41
@mpkelly mpkelly restored the add/support-for-pasting-lists branch December 23, 2022 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Table Affects the Table Block [Feature] Paste
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants