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

Whitespace and formatting lost when pasting from web based Microsoft Word into Portable Text #8064

Open
marcusforsberg opened this issue Dec 16, 2024 · 0 comments

Comments

@marcusforsberg
Copy link

Describe the bug

These are technically two, potentially related, issues.
When pasting text from a Word document, in this case the web based version, into a Portable Text Editor, there are two issues:

  1. It seems that when using non-English characters such as åäö, Sanity will randomly strip spaces between words, merging words into one.
  2. Formatting doesn't appear to be respected at all, even basic formatting such as bold and italic is removed when pasting from Word, but it works when pasting from Google Docs.

To Reproduce

Steps to reproduce the behavior:

  1. Open this sample Word document in the web based version of Microsoft Word: Sanity Portable Text Editor bug.docx
  2. Copy its entire contents
  3. Paste the text using CMD/CTRL + V into a Portable Text field in Sanity
  4. Notice that spaces in most of the Swedish sentences are randomly stripped away
  5. Notice that no formatting was included
  6. You can read through the text in the document for my findings, but it clearly appears that the whitespace issue happens in sentences using åäö.

Expected behavior

When copy/pasting text from Word, Editors expect whitespace to be intact and basic formatting such as bold, italic and underline to be respected. This is already the case when using Google Docs.

Even copy/pasting the text from the sample Word document into Google Docs, and then copy/pasting from there into Sanity, everything works fine.

Screenshots

This shows the resulting text in the Portable Text editor:

Screenshot 2024-12-16 at 10 33 37

Here's a video of the issue happening, and also showing how it works as expected when going via a Google Doc.

Screen.Recording.2024-12-16.at.10.38.43.mov

Looking at the HTML output of the Word editor, it appears that it's adding individual span tags around the spaces that are being removed:

Screenshot 2024-12-16 at 10 46 46

Which versions of Sanity are you using?

@sanity/cli (global)             3.67.1 (up to date)
@sanity/icons                     3.5.2 (up to date)
@sanity/image-url                 1.1.0 (up to date)
@sanity/orderable-document-list   1.2.2 (up to date)
@sanity/preview-url-secret        2.0.5 (up to date)
@sanity/studio-secrets            3.0.0 (up to date)
@sanity/table                     1.1.2 (up to date)
@sanity/ui                       2.10.9 (up to date)
@sanity/vision                   3.67.1 (up to date)
@sanity/webhook                   4.0.4 (up to date)
sanity                           3.67.1 (up to date)

What operating system are you using?

MacOS 14.6.1 in Google Chrome, but the issue is not browser specific and has been reported by our client's editorial team running on Windows machines and different browsers.

Which versions of Node.js / npm are you running?

10.5.0
v20.12.0

Additional context

In this comment it's stated that Word should be supported when copy/pasting, but it's the only information I found on the topic so I'm not sure if that's still the case, but I'm hoping it is: #1437 (comment)

Couple of related issue around formatting, but I'm opening this specifically since it appears to be an åäö-issue: #3834 #3240

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant