Hube2 / acf-medium-editor

Configurable Medium Editor WYSIWYG Field for ACF5 Pro
77 stars 10 forks source link

Editor creates ugly markup in backend #30

Open marcwieland95 opened 5 years ago

marcwieland95 commented 5 years ago

I tested the editor and just got feedback from my client that certain things broke on the website. When looking closer into the markup which the medium editor creates it's not a wonder.

Screenshot 2019-06-27 09 54 51

Is there a possibility to get a more clean output without stylings, etc.. At least in the database? Else I need to revert my fields to the ACF TinyMCE. But the Medium Editor looks very clean and is user friendly so I like to keep it

Hube2 commented 5 years ago

The code created is what Medium Editor is doing https://github.com/yabwe/medium-editor. I don't really have any control over that aspect of this plugin. The only thing that this plugin really does is to incorporate the editor into ACF. I do know that one needs to be careful when using it for multiple line fields. Also, the styles are not something that medium editor is adding unless you've created a custom button that does this styling. Copying and pasting from another source might also cause this as there isn't anything in medium editor that will clean it up for you.

There is a reason why disable return settings are on by default, the only reason that I created this plugin was that I needed single line entry fields that clients could edit an apply styling to individual words without 1) creating multiple field or 2) giving them some complex markdown schema that they'd never remember.

Quite honestly, if I want the client to have a multi-line editor I just give them a wysiwyg.

marcwieland95 commented 5 years ago

Jep, I know that this is up to the other repo and I like your implementation into ACF.

Multiline changes a lot of things as you said. For single line I also do not have issues and markdown is not really nice for the client.

I returned the wysiwyg editor but this feels also very clunky for just two lines. In my case there's a headline which can spread over two lines with added stylings (bold, italic). So your plugin would make total sense in my case. But with added styles it happens very quickly that something breaks.

Hube2 commented 5 years ago

The above is the reason why I created 1 extra setting "allowBreakInSingleLineInput" This is the only real thing that I have control over. This allows the editor to add <br> tags directly into the editor. It's the only html allowed and something I think that they can be easily remembered. Not sure if that helps you or not.

The only other thing that I do when the field is saved is that I remove any empty html elements because medium editor has a habit of throwing these in.

marcwieland95 commented 5 years ago

Good input, thanks. I give it a new try with that solution.

The editor adds a lot of these <span> elements (visible in the editor at the top). I make sure that these are remove in the frontend and just allow my allowed markup. Should work fine.