Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Orgoth opened this issue Oct 27, 2023 · 0 comments

Comments

@Orgoth
Copy link

Orgoth commented Oct 27, 2023

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.

xdan added a commit that referenced this issue Nov 14, 2023
@xdan xdan closed this as completed Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants