Skip to content

Allow writing custom HTML in HTML mode#2312

Merged
Tug merged 7 commits intodevelopfrom
fix/freeform
May 26, 2020
Merged

Allow writing custom HTML in HTML mode#2312
Tug merged 7 commits intodevelopfrom
fix/freeform

Conversation

@Tug
Copy link
Copy Markdown
Contributor

@Tug Tug commented May 25, 2020

Fixes #2292

This PR registers the classic block for freeform support when parsing a post. It does not provide an Edit feature for the classic block though

Gutenberg PR: WordPress/gutenberg#22609

Testing Instructions

  • Boot WPAndroid
  • Switch to HTML mode
  • Type text
  • Wait for a second
  • Notice text is not replaced by <p>text</p>
  • Switch back to visual
  • Notice unsupported block is displayed

Warning

  • If a post with only HTML (no blocks) is saved it will load with aztec whenever it's opened again
  • Switching back and forth between visual and code mode might transform the HTML into paragraphs (or other blocks) as the web does

PR submission checklist:

  • I have considered adding unit tests where possible.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@Tug Tug added this to the 1.29 milestone May 25, 2020
@Tug Tug requested review from SergioEstevao, etoledom and hypest May 25, 2020 18:43
@Tug Tug self-assigned this May 25, 2020
@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented May 25, 2020

Wanna run full suite of Android and iOS UI tests? Click here and 'Approve' CI job!

@SergioEstevao
Copy link
Copy Markdown
Contributor

I gave this a spin and in general, it's working ok, but there are still some edge cases:

  • If you try to write something like I like to be <strong>bold</strong> and the auto-save occurs in the middle of writing the strong element you will get some strange HTML generation.

  • When you switch back to the visual mode you will see the unsupported block but when you tap to remove it you see:

Screenshot 2020-05-25 at 21 38 06

It says: Remove Classic is this expected/wanted?

@Tug
Copy link
Copy Markdown
Contributor Author

Tug commented May 26, 2020

@SergioEstevao Thanks for giving it a go. I do think Remove Classic is expected as it corresponds to the classic block. I have updated the PR to reflect that on the unsupported block ui.

If you try to write something like I like to be bold and the auto-save occurs in the middle of writing the strong element you will get some strange HTML generation.

Yeah that's a problem, maybe we could update the autosave in WP apps to be triggered less often? We can't do much on the RN side as we just react to the native-editor.persist-html action.

@Tug
Copy link
Copy Markdown
Contributor Author

Tug commented May 26, 2020

We can't do much on the RN side as we just react to the native-editor.persist-html action.

One thing we could do though is send the HTML as it is whenever the parent apps asks for it, no need to parse and serialize back while we're in the HTML mode. If the post is reloaded and some HTML is invalid the block parser will try to fix that (which may fail but there are always the possibility of falling back to aztec in that case)

@Tug
Copy link
Copy Markdown
Contributor Author

Tug commented May 26, 2020

@SergioEstevao I did just that. Could you give it another go please?

@hypest
Copy link
Copy Markdown
Contributor

hypest commented May 26, 2020

One thing we could do though is send the HTML as it is whenever the parent apps asks for it.

I feel that that'd be the expectation. When in html mode, the user has direct access to the raw post and I think it has to be the source of truth and stay unaltered. Switching back and forth between visual and html mode might be a different deal, but while editing in html mode I'd expect the edits to be kept as is.

Copy link
Copy Markdown
Contributor

@SergioEstevao SergioEstevao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving it, it's now working much better!

I do like that it does not alter your HTML in anyway!

@Tug Tug merged commit 855620e into develop May 26, 2020
@Tug Tug deleted the fix/freeform branch May 26, 2020 16:24
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

Successfully merging this pull request may close these issues.

[GlobalStep] [Android] Unable to operate or handle all tags in HTML mode.

3 participants