Split text combine text with previous <p> paragraph

Created on 8 September 2020, almost 4 years ago
Updated 29 June 2023, 12 months ago

There is case when "split text" doesn't work correct.

Tested with this source text:

<p>First text paragraph that will be combined with the second one</p>

<p>Second text paragraph. Set cursor right after this.</p>

<p></p>

<p>Third chunk</p>

When you set cursor after second <p> and press split you get two problems:
- first and second <p> tags are combined;
- newly created paragraph has additional linebreak at the beginning;

Result:

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine mostepaniukvm

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • @mbm80 opened merge request.
  • πŸ‡¦πŸ‡ΉAustria mbm80

    Found a bug where the selected range would be messed up due to the removal of a node within the range.

    For example:

    <body>[<p></p><span>text</span>]</body>
    range (container:offset): body:0 body:2 
    
    trimElements(firstNode); will then remove <p></p>
    
    if this happens after the range sets the end point the end node:offset will stay body:2 although, we only have 1 element now.
    
    <body>[<span>text</span>]</body>
    range (container:offset): body:0 body:2 (should be body:1) 
    
    

    Fixed by moving trimElements(firstNode); before ranges[0].setEndAfter(lastNode) so that it will have the correct amount of nodes to set the proper offset value.

    I applied the existing patch & added to commit to the fork MR

Production build 0.69.0 2024