Skip to content

INSERT_ONLY_TEXT removes line breaks instead of conserving them like inserting plaintext #1033

@ghost

Description

Jodit Version: 3.24.5 & 4.0.0-beta.94

Browser: Chrome, Edge, Safari, FF
OS: Windows, Mac, Linux
Is React App: False

Code

<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore<br><br>magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd<br><br>gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing<br><br>elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eo<br><br></p>
  1. put the html text from above into a html file and open it, then copy the text
  2. open https://xdsoft.net/jodit/play.html
  3. remove all predefined content from the editor strg + a -> entf
  4. strg + v -> insert only text

Expected behavior:
The new lines "br" should be respected and the text should look like this.

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore

magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd

gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing

elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eo

Actual behavior:
processHTML -> insertByType -> striptags removes the line breaks.

Auswahl_564

What leads to this behavior?

insertByType calls striptags without the exclude parameter, as result the line breaks are getting removed.

https://github.com/xdan/jodit/blob/main/src/plugins/paste/paste.ts#L160

For test purposes, I have added the following.

    if( exclude === null ){
        exclude = new Set(['br', 'hr']);
    }

I then tried the insert only text again and it worked mostly as I would expect it.
It inserts one additional line break instead of the two defined.

My expectation was like that, that when clicking on insert text only, the behavior of CTRL + Shift + v would be mimicked.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions