contentful / field-editors

React components and extensions for building Contentful entry editor
https://contentful-field-editors.netlify.app/
MIT License
149 stars 114 forks source link

fix: spaces removed for non english text [ZEND-5011] #1660

Closed YvesRijckaert closed 1 month ago

YvesRijckaert commented 1 month ago

Summary

This pull request addresses an issue where spaces were removed from Korean text pasted into the rich text field. The problem was caused by the cleanHtmlEmptyElements plugin from Plate, which removes all empty elements, including <span> elements used by MS Word to represent spaces in Korean text. Content support ticket: https://contentful.atlassian.net/browse/ZEND-5011

Problem

MS Word adds <span> elements for each Korean word, and spaces are represented by empty <span> elements. The cleanHtmlEmptyElements plugin removed these empty <span> elements, causing spaces to be removed in Korean text when pasted into the rich text field.

Solution

We have customized the plugin to ignore empty <span> elements, ensuring that spaces in Korean text are preserved. This change means we no longer rely on the cleanHtmlEmptyElements plugin from Plate.

Additional Changes

Added a test to ensure this behavior is maintained in the future.