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

Raw Handling: Paste from MS Excel no longer creates a table block #42570

Open
admturner opened this issue Jul 20, 2022 · 5 comments · May be fixed by #55206
Open

Raw Handling: Paste from MS Excel no longer creates a table block #42570

admturner opened this issue Jul 20, 2022 · 5 comments · May be fixed by #55206
Assignees
Labels
[Block] Table Affects the Table Block [Feature] Paste [Status] In Progress Tracking issues with work in progress [Type] Regression Related to a regression in the latest release

Comments

@admturner
Copy link

Description

Pasting content from Microsoft Excel as a table is not working as expected. I expect to content copied from an Excel spreadsheet to create a table block when pasted in the editor. Instead, it pastes as a paragraph block.

Copying and pasting from Google Sheets works as expected -- it creates a table block in the editor. But copying and pasting from Excel appears to strip the HTML during an intermediary step between pasting and block creation (see screen recording).

This issue appears to have originated in v5.9, but I'm not sure. I used the "WP Downgrade | Specific Core Version" plugin to downgrade from 6.0.1 to 5.8.4 (my end users noticed the issue begin around March or April) and copy-paste from Excel works as expected in 5.8.4.

Step-by-step reproduction instructions

  1. Create an Excel spreadsheet with some content.
  2. Go to Pages > Add New.
  3. Copy the content of the Excel spreadsheet into the WP editor.
  4. See error.

Repeat steps from Google Sheets to see expected behavior.

Screenshots, screen recording, code snippet

On a fresh local WordPress 6.0.1 installation:

wp6-0-1-excel-table-format

Environment info

  • WordPress 6.0.1, not using Gutenberg plugin, default Twenty Twenty-One theme, and no plugins active. Issue appears in Twenty-Twenty Two theme as well, and when downgraded as far as WordPress 5.9.
  • Firefox 102.0.1 (64-bit). Issue also appears in Chrome (103.0.5060.134) and Edge (103.0.1264.62).
  • Desktop with Windows 10.
  • WordPress running in local Docker environment. Issue also appears in WP 6.0.1 running in hosted environment.

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@carolinan carolinan added [Block] Table Affects the Table Block [Feature] Paste labels Jul 21, 2022
@t-hamano t-hamano added the [Type] Regression Related to a regression in the latest release label Nov 12, 2022
@t-hamano
Copy link
Contributor

t-hamano commented Nov 12, 2022

@admturner
Thank you for your contribution.

I have confirmed that this process for Windows, added by #33607, caused the regression.

// Remove Windows-specific metadata appended within copied HTML text.
html = removeWindowsFragments( html );

Received HTML data differs depending on the presence or absence of this process:

With removeWindowsFragments
 <col width=70 span=2 style='width:53pt'>
 <tr height=24 style='height:18.0pt'>
  <td height=24 class=xl65 width=70 style='height:18.0pt;width:53pt'>Cell 1</td>
  <td class=xl65 width=70 style='width:53pt'>Cell 2</td>
 </tr>
 <tr height=24 style='height:18.0pt'>
  <td height=24 class=xl65 style='height:18.0pt'>Cell 3</td>
  <td class=xl65>Cell 4</td>
 </tr>
Without removeWindowsFragments
 <html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http:https://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 15">
<link id=Main-File rel=Main-File
href="file:https:///C:/Users/TETSUA~1.HAM/AppData/Local/Temp/msohtmlclip1/01/clip.htm">
<link rel=File-List
href="file:https:///C:/Users/TETSUA~1.HAM/AppData/Local/Temp/msohtmlclip1/01/clip_filelist.xml">
<style>
<!--table
	{mso-displayed-decimal-separator:"\.";
	mso-displayed-thousand-separator:"\,";}
@page
	{margin:.75in .7in .75in .7in;
	mso-header-margin:.3in;
	mso-footer-margin:.3in;}
.font5
	{color:windowtext;
	font-size:6.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:游ゴシック, monospace;
	mso-font-charset:128;}
tr
	{mso-height-source:auto;
	mso-ruby-visibility:none;}
col
	{mso-width-source:auto;
	mso-ruby-visibility:none;}
br
	{mso-data-placement:same-cell;}
td
	{padding-top:1px;
	padding-right:1px;
	padding-left:1px;
	mso-ignore:padding;
	color:black;
	font-size:11.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:游ゴシック, monospace;
	mso-font-charset:128;
	mso-number-format:General;
	text-align:general;
	vertical-align:bottom;
	border:none;
	mso-background-source:auto;
	mso-pattern:auto;
	mso-protection:locked visible;
	white-space:nowrap;
	mso-rotate:0;}
.xl65
	{font-family:"Noto Sans JP", sans-serif;
	mso-font-charset:128;}
ruby
	{ruby-align:left;}
rt
	{color:windowtext;
	font-size:6.0pt;
	font-weight:400;
	font-style:normal;
	text-decoration:none;
	font-family:游ゴシック, monospace;
	mso-font-charset:128;
	mso-char-type:katakana;
	display:none;}
-->
</style>
</head>

<body link="#0563C1" vlink="#954F72">

<table border=0 cellpadding=0 cellspacing=0 width=140 style='border-collapse:
 collapse;width:106pt'>
<!--StartFragment-->
 <col width=70 span=2 style='width:53pt'>
 <tr height=24 style='height:18.0pt'>
  <td height=24 class=xl65 width=70 style='height:18.0pt;width:53pt'>Cell 1</td>
  <td class=xl65 width=70 style='width:53pt'>Cell 2</td>
 </tr>
 <tr height=24 style='height:18.0pt'>
  <td height=24 class=xl65 style='height:18.0pt'>Cell 3</td>
  <td class=xl65>Cell 4</td>
 </tr>
<!--EndFragment-->
</table>

</body>

</html>

As the above data shows, data pasted from MS Excel has Startfragment and EndFragment in the Table tag.

Since #33607 removes the outside of the fragments, the removal of the table tag would have caused it to no longer match the table schema.

@t-hamano
Copy link
Contributor

I think it would be better to add the test proposed in #34235 first, so that the resolution of this issue does not cause regression #33607 to the contrary.

@annezazu annezazu changed the title Paste from MS Excel no longer creates a table block Raw Handling: Paste from MS Excel no longer creates a table block Aug 3, 2023
@ellatrix
Copy link
Member

ellatrix commented Oct 9, 2023

@admturner, or anyone else, could you please share the HTML that is logged in the console so we can fix and add a test? Example: #46832. No need to provide an example file. Thanks!

@t-hamano
Copy link
Contributor

t-hamano commented Oct 9, 2023

Below are the screencast and recorded logs. I also investigated the cause of this issue in this comment.

bcf47031253d3eb4ab3d51c3c112a657.mp4
Received HTML:

 
 <col width=70 span=3 style='width:53pt'>
 <tr height=24 style='height:18.0pt'>
  <td height=24 width=70 style='height:18.0pt;width:53pt'>One</td>
  <td width=70 style='width:53pt'>Two</td>
  <td width=70 style='width:53pt'>Three</td>
 </tr>
 <tr height=24 style='height:18.0pt'>
  <td height=24 style='height:18.0pt'>Four</td>
  <td>Five</td>
  <td>Six</td>
 </tr>Received HTML:

 
 <col width=70 span=3 style='width:53pt'>
 <tr height=24 style='height:18.0pt'>
  <td height=24 width=70 style='height:18.0pt;width:53pt'>One</td>
  <td width=70 style='width:53pt'>Two</td>
  <td width=70 style='width:53pt'>Three</td>
 </tr>
 <tr height=24 style='height:18.0pt'>
  <td height=24 style='height:18.0pt'>Four</td>
  <td>Five</td>
  <td>Six</td>
 </tr>
Received plain text:

 One	Two	Three
Four	Five	Six
Processed HTML piece:

 <p>One Two Three<br>Four Five Six</p>

Testing Environment

  • OS: Windows 11
  • Browser: Version 117.0.5938.150
  • Excel: Microsoft® Excel® 2016 MSO (verion 2309 build 16.0.16827.20130) 64bit

@t-hamano
Copy link
Contributor

Are you positive that this is the markup you're receiving?

Yes. Why such HTML is received is discussed in this comment.

Even in the gif image seen at the beginning of this issue, you can see that such HTML is recorded in the browser console, so it shouldn't be a problem in my environment.

@ellatrix ellatrix linked a pull request Oct 10, 2023 that will close this issue
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Oct 10, 2023
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 [Status] In Progress Tracking issues with work in progress [Type] Regression Related to a regression in the latest release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants