Skip to content

Fix disappearing letters and words from lists pasted from Word#6690

Closed
aautio wants to merge 1 commit intotinymce:developfrom
aautio:word_list_paste_cleanup
Closed

Fix disappearing letters and words from lists pasted from Word#6690
aautio wants to merge 1 commit intotinymce:developfrom
aautio:word_list_paste_cleanup

Conversation

@aautio
Copy link
Copy Markdown
Contributor

@aautio aautio commented Mar 31, 2021

This pull request replaces #6621 as agreed with @JamesToohey.

Fixes #2810, Fixes #3017, Fixes #3480, Fixes #5474

This commit includes fixes to multiple subtle errors in MS Word list
cleanups. The bugs caused any characters ending with a dot to disappear
from the lists under certain circumstances:

Font/style -changes cause multiple text nodes to appear as siblings in
the AST.

Function filterStyles marked only the first node with _listIgnore and
thus missed the nodes with roman numerals. This was fixed.

The removeIgnoredNodes-function used node.remove() to delete nodes
from the AST. The method sets node.next to null and thus recursion
did not proceed further. Sibling text nodes with _listIgnore would
not be deleted. This was fixed by avoiding node.remove().

The trimListStart -function did not trim the beginning of the
paragraph. It trimmed all text nodes instead and removed the ones with
words ending with dot. This was fixed by merging the paragraph
text nodes before trimming the first text node.

Regex for cleaning up the beginning is now safe. It no longer removes
any letters (with \w). Instead it only looks for bullets. One
regex is enough to filter those as the text nodes have been merged
before matching.

Added a couple of test cases as a proof that the fixes work correctly.

Pre-checks:

  • Tests have been added (if applicable)

Review:

  • Milestone set
  • Review comments resolved

GitHub issues (if applicable):

Fixes tinymce#2810, Fixes tinymce#3017, Fixes tinymce#3480, Fixes tinymce#5474

This commit includes fixes to multiple subtle errors in MS Word list
cleanups. The bugs caused any characters ending with a dot to disappear
from the lists under certain circumstances:

Font/style -changes cause multiple text nodes to appear as siblings in
the AST.

Function filterStyles marked only the first node with _listIgnore and
thus missed the nodes with roman numerals. This was fixed.

The removeIgnoredNodes-function used node.remove() to delete nodes
from the AST. The method sets node.next to null and thus recursion
did not proceed further. Sibling text nodes with _listIgnore would
not be deleted. This was fixed by avoiding node.remove().

The trimListStart -function did not trim the beginning of the
paragraph. It trimmed all text nodes instead and removed the ones with
words ending with dot. This was fixed by mering the paragraph
text nodes before trimming the first text node.

Regex for cleaning up the beginning is now safe. It no longer removes
any letters (with \w). Instead it only looks for certain bullets. One
regex is enough to filter those as the text nodes have been merged
before matching.

Added a couple of test cases as a proof that the fixes work correctly.
@metricjs
Copy link
Copy Markdown
Contributor

metricjs commented Aug 3, 2021

Hey @aautio, apologies for not updating you regarding this PR in a while. We want to merge it, but we've noticed there's a potential breaking change in your changes. As such we also want to do some testing and other work on our side first. We had hoped to fit this in the TinyMCE 5.9 release, but that is looking unlikely. So, unfortunately, I'm going to remove this from the 5.9 milestone and we'll reschedule it for another future release.

@metricjs metricjs removed this from the 5.9.0 milestone Aug 3, 2021
@TheSpyder
Copy link
Copy Markdown
Member

Closing as discussed via email - I've opened the topic to search for a community maintainer at #7487.

@TheSpyder TheSpyder closed this Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants