wordpress-mobile / AztecEditor-Android

A reusable native Android rich text editor component.
Mozilla Public License 2.0
675 stars 112 forks source link

Hide Gutenberg blocks #594

Closed 0nko closed 6 years ago

0nko commented 6 years ago

This PR implements the special Gutenberg code block HTML from the visual editor, as suggested in #541.

The regular comment-hiding was unsuitable for this task so now there is a new type of plugin interface - IHtmlContentHandler. A plugin that implements it is supplied with the content of a declared element and the element is skipped by the parser.

daniloercoli commented 6 years ago

I've tested this PR with a small GB post, and was wondering if we should show the Unknown block item ?, instead of hiding GB blocks altogether. If you edit a GB post it looks empty in the visual mode, or, if you edit a post that is a mix of GB blocks and "conventional" text, it looks half empty and the result is a weird experience.

Sorry if this has already been discussed somewhere and I've forgot about it, or missed the convo.

0nko commented 6 years ago

Good question. @diegoreymendez, do have this in Aztec iOS?

diegoreymendez commented 6 years ago

In WPiOS we're replacing the Gutenberg comment blocks with zero-width spaces in visual mode... sort of hiding them (although backspacing would sort of let you know you're deleting one). At the time we implemented this it was agreed to be a simple compromise solution. Especially since Aztec is an HTML-standard editor so any efforts to make it "handle" Gutenberg code would be misplaced and counterproductive IMO.

Anything more complicated has the potential of becoming a big effort we'd rather avoid in Aztec (since Gutenberg mobile is where we want to be putting that effort).

@maxme is the closest we have to a product owner though, so maybe he has other thoughts on this.

diegoreymendez commented 6 years ago

Just to be clear... we're "hiding" the opening and closing comment blocks, but the content is parsed as regular HTML.

0nko commented 6 years ago

I've changed the implementation so that only the GB comments are hidden, the content is rendered normally. I've added figure, figcaption and section to a list of hidden elements because GB blocks place HTML inside them.

daniloercoli commented 6 years ago

@mzorz I'd like to get another review on this PR. Would you mind to take a quick look?

mzorz commented 6 years ago

Would you mind to take a quick look?

sure thing!