Skip to content

Spaces at the end of list items are not correctly processed when saving and loading data #18960

@scofalik

Description

@scofalik

📝 Provide detailed reproduction steps (if any)

  1. Create a document that has two list items, with a space character at the end of them.
  2. Call editor.getData(), you will get e.g. '<ul><li data-list-item-id="ecc9d729c373b5aaa016128bebcc27479">Foo </li><li data-list-item-id="e3412a4e17839d1f3c9dc4c4461d0607b">Bar&nbsp;</li></ul>'.
  3. This is already incorrect because first <li> should end with nbsp too.
  4. Even if you paste nbsp manually at the end of list item instead of using space character, it also leads to 'Foo ' instead of 'Foo '. AFAIR this is because we normalize nbsps on paste to spaces anyway.
  5. When you load this data, (try editor.setData(editor.getData())), the space character will be gone.
  6. This leads to crashes in revision history.

This only happens in lists. When I test the same for paragraphs, spaces at the end are correctly saved to &nbsp; on editor.getData().

Some more insight:

If you paste it from external content, and you paste it with styles (e.g. copy from Google Docs), it will paste as nbsp:

'<ul><li class="ck-list-marker-color" style="--ck-content-list-marker-color:#000000;" data-list-item-id="ecba710193f3aac83c6d3d55bccf1bbd9"><span style="background-color:transparent;color:#000000;">Foo&nbsp;</span></li><li data-list-item-id="e8d450211c3b565443b68c230146a564b">Foo&nbsp;</li></ul>'
editor.model.document.getRoot().getChild(0).getChild(0).data.charCodeAt(3);
160

However, after editor.setData(editor.getData()) it gets normalized anyway, and the bug/crash still occurs.

Metadata

Metadata

Assignees

Labels

package:listsquad:coreIssue to be handled by the Core team.support:2An issue reported by a commercially licensed client.type:bugThis issue reports a buggy (incorrect) behavior.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions