Skip to content

RichTextEditor: extra white space is removed when content is loaded #5533

@mihannus

Description

@mihannus

Description

We're using the RichTextEditor in Delta format (JSON) mode, and the value is bound to a String field that is stored in the database. When the component is loaded with existing Delta format data then extra whitespace is removed (tabs, spaces).

rich_text_editor_1
rich_text_editor_2

Expected outcome

We'd expect the text to appear as it was when it was saved, with extra whitespaces preserved.

For example when populating the component with this data:
[{"attributes":{"bold":true},"insert":"Line 1"},{"insert":"\n\tIndent 1\n\t\tIndent 2\nLast line with\textra spaces and a \ttab\n\n"}]
then when expect to get the same data back, but now we get:
[{"attributes":{"bold":true},"insert":"Line 1"},{"insert":"\nIndent 1\nIndent 2\nLast line with extra spaces and a tab\n"}]

Minimal reproducible example

getBinder().forField(ingredientListEditor.asDelta())
	.bind(product -> product.getIngredientList(), (product, s) -> {
		product.setIngredientList(s);
	});

Steps to reproduce

  1. Create RichTextEditor component
  2. Write text that contains tabs and extra spaces into the editor component
  3. Retrieve the JSON Delta format data from the component (should be correct at this point)
  4. Re-populate the component with the retrieved data
  5. Observe that the extra whitespace has been removed

Environment

Vaadin version(s): 24.1.10
OS: Windows 10

Browsers

Chrome

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions