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

empy <p> tag gets appended to existing RichtTextTile when inserting new RichTextTile #413

Closed
petschki opened this issue Jun 28, 2018 · 12 comments

Comments

@petschki
Copy link
Member

petschki commented Jun 28, 2018

I have a strange behavior in the mosaic layout editor.
Steps to reproduce:

  1. make new "mosaic layout" page
  2. edit and add RichTextTile and save
  3. edit again and add a new RichTextTile again
  4. the first RichTextTile markup gets an empty <p> tag appended to every existing <p> tags

see screenshots. can anybody else confirm this behavior?

Versions:
Plone=5.1-latest
plone.app.mosaic=2.1.1
plone.app.standardtiles=2.3.1

bildschirmfoto 2018-06-28 um 21 26 24

bildschirmfoto 2018-06-28 um 21 26 46

bildschirmfoto 2018-06-28 um 21 27 01

@petschki
Copy link
Member Author

googling around, I've found a hint in tinyMCE forum:
https://www.tinymce.com/docs/configure/content-filtering/#forced_root_block
forced_root_block -> this adds <p> elements to non block elements (even to newlines)

If I look at the @@plone.app.standardtiles.html XHR request I see newlines after each block and it looks like they are replaced with <p></p> tags by tinyMCE editor.

has anybody else encountered the same problems and should this be fixed in plone.app.standardtiles ?

CC @jensens @thet @agitator @frapell @datakurre

@datakurre
Copy link
Member

I have not seen this yet, but I am not yet on the latest TinyMCE.

Mosaic editor does a lot TinyMCE restarts (killing and creating the editor again), because every DOM change related to the editor used to break it. That something that is special for normal TinyMCE use cases.

Mosaic does override some of default Plone TinyMCE settings, so we could disable that setting. Also, because Mosaic uses most of Plone TinyMCE settings, you could try that setting locally without touching code.

@frapell
Copy link
Sponsor Member

frapell commented Jun 29, 2018

@petschki I remember having this issue, and the problem was with the automatic CSRF protection...

when the tile did the AJAX call to get its content, the response would include the <script> tag with the protect.js.
TinyMCE would then strip it out (Because <script> is not allowed) and leave that lovely empty <p>

I think I solved it by pulling a more recent version of one of mosaic dependencies... I don't remember which one

@datakurre
Copy link
Member

@frapell Thanks for the pointer.

@petschki Try with the latest plone.tiles and report the results.

@datakurre
Copy link
Member

@petschki I can confirm that I have done the changes @frapell mentioned into plone.tiles 2.0.0.

For a while, I have not been able to do any Mosaic development and therefore did not manage the latest release nor update versions in documentation. (Before that I was managing release towards 2.0.0 but I had never clear conscience to do that, because of various remaining bugs.)

@petschki
Copy link
Member Author

petschki commented Jun 29, 2018

@datakurre thank you ... plone.tile version is already the latest, but I try to dig down more on this.

@frapell thanks for your hint ... the tile response is already without any <script> tag ... in my case, every newline gets its empty paragraph ... so you end up with multiple empty lines on each and every edit action of the mosaic page ... I do not want to change tinyMCE configuration to not force a root block because then the empty paragraphs would be missing if you hit enter while editing (this is what the user gets in every other tiny on the page) ...

@frapell
Copy link
Sponsor Member

frapell commented Jun 29, 2018

@petschki mmm, then I don't know unfortunately...

I do remember also playing with those settings for TinyMCE until I was able to realize that this was the unwanted extra HTML coming from the server...

FWIW, I couldn't find any init setting for TinyMCE that wouldn't cause any unwanted side effect somewhere else...

I would make sure that the HTML coming from the server is exactly what was saved, just to be sure who's to blame... is it TinyMCE adding garbage? or is there something else?

@petschki
Copy link
Member Author

petschki commented Jul 2, 2018

@frapell the HTML data coming from the server is OK. I was able to get rid of this behavoir when setting {"forced_root_block": ""} in TinyMCE other_settings but that's not really what we want for editing (no <p> when hitting enter) ... So I quickfixed this issue by stripping all newlines when loading the data from the server here: plone/plone.app.standardtiles@e05ddd5

@datakurre though I'm not really sure if this should be fixed there. (btw. I also tried to add a DataConverter adapter to IHTMLTile.content without success ... )

Before wrapping my head more arround this I'd like your oppinion(s) whether this should be fixed when saving/reading the tile data or in the frontend when initializing TinyMCE.

cc/ @thet @jensens @agitator @vangheem

@datakurre
Copy link
Member

@petschki Your standardtiles fix gave me a hint what could cause this:

https://github.com/plone/plone.app.blocks/blob/master/plone/app/blocks/layoutbehavior.py#L309

Couple of years ago we changed default tile storage to be a single HTML-serialized field. That mimics the original Deco implementation where tile configuration and content was within the layout. Similarly to that, HTML of rich text tile is saved as HTML in that field. Attribute based storage has some benefits over annotation based storage in versioning, multilingual, restapi, etc...

The issue is probably that I've been naive enough to enable pretty print for that field. It sounds like it might be that pretty print that is causing extra newlines.

If you can confirm that, please, provide fix into plone.app.blocks. I have no idea, why I have not seen this issue myself. Possibly because of using older TinyMCE-version...

@petschki
Copy link
Member Author

petschki commented Jul 2, 2018

erm ... maybe the circle is closing here with plone/plone.app.blocks#63 ... seems like some similar problems reported from @frapell ?

@frapell
Copy link
Sponsor Member

frapell commented Jul 2, 2018

When @datakurre mentioned this issue, I remembered that plone.app.blocks issue... However, in that case, there were new lines being added all over the place, and not only at the end... I don't quite remember why I didn't remove the pretty_print. @petschki if you remove that pretty_print, does your issue gets resolved? In this case, you will need to save the tile content again so the data is saved without the pretty_print in the first place...

@petschki
Copy link
Member Author

petschki commented Jul 2, 2018

I can confirm that this issue gets fixed with this plone/plone.app.blocks#69

@petschki petschki closed this as completed Jul 2, 2018
krissik pushed a commit that referenced this issue Mar 11, 2024
Update view methods and layouts from LIF/LRF FTI and objects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants