froala / wordpress-froala-wysiwyg

Wordpress plugin for Froala WYSIWYG HTML Editor.
https://www.froala.com/wysiwyg-editor
GNU General Public License v3.0
42 stars 26 forks source link

Issue with paragraphs when pasting in rich text content #3

Closed KTS915 closed 7 years ago

KTS915 commented 7 years ago

I have tried pasting in content from both traditional wordprocessors (like MS Word) and simpler, rich-text editors. In each case, Froala adds an extra (empty) paragraph between each paragraph.

To start with, I thought this was probably caused by WordPress's own wpautop function, but it isn't. (In fact, if I disable wpautop, I just get a line break added to the phantom paragraph, thus making the gap between the real paragraphs even bigger.)

stefanneculai commented 7 years ago

@KTS915 if you would like to disable this, then you should change the option enter to $.FroalaEditor.ENTER_BR: https://www.froala.com/wysiwyg-editor/examples/enter/.

KTS915 commented 7 years ago

Sorry, @stefanneculai, but that's not a solution. It's just a kludgy workaround. All that does is strip out paragraphs altogether, so that you end up with one long div with line breaks.

stefanneculai commented 7 years ago

@KTS915 could you send us the document you're pasting from?

KTS915 commented 7 years ago

I just saw it on your own CodePen: https://codepen.io/Froala/pen/aJxPJP

You just need to interpret two consecutive strikes of the ENTER key as one. (You could instead change Froala's default behavior, so that two consecutive strikes of the ENTER key are required to end a paragraph and start a new one, but I assume you don't want to do that.)

stefanneculai commented 7 years ago

@KTS915 I see what you mean now. You would want that when you hit enter inside a paragraph, it would make a new line inside it instead of outside. We believe the current behavior is the correct one.

KTS915 commented 7 years ago

@stefanneculai, I take it from this "We believe the current behavior is the correct one" that you aren't going to change anything. In which case, I'm afraid, Froala will be useless for almost all WordPress users I know, because they paste in content from Word all the time.

stefanneculai commented 7 years ago

Could you send us the document you're pasting from so we could check that? Thanks.

KTS915 commented 7 years ago

I haven't actually tried -- just saw the CodePen and realized it was pointless.

If you want me to try it, tell me where to put the JS code to modify Froala's behavior.

stefanneculai commented 7 years ago

Word paste is different from the typing behavior. We would be happy to look into it if you are willing to collaborate with us. Thank you.

KTS915 commented 7 years ago

Sure, I'm willing, but you have to tell me where to paste the JS code to which you referred. On a regular html page, I'd know eactly how to do it, and for the front-end on WordPress, I'd put it in the theme's javascript file.

But your JS function needs to affect the admin side of WordPress. I have no idea where I need to put it to get it to work.