wordpress-mobile / WordPress-Editor-Android

⛔️ [DEPRECATED] A reusable Android rich text editor component.
GNU General Public License v2.0
188 stars 50 forks source link

Issue #423: Can't backspace to delete images with captions #424

Closed aforcier closed 8 years ago

aforcier commented 8 years ago

Fixes #423.

For some reason, the cursor position gets reset when backspacing into an image with a caption. I could not reproduce the issue on emulators (using hardware or software keyboard), and I think this is another autocorrect+WebView bug.

The best fix I found was to make captions editable (previously they had contenteditable="false"). This allows backspace to focus on the caption, and backspacing after the caption is deleted will remove the image as expected (I guess this is actually a feature 🎉).

I also extended the changes of https://github.com/wordpress-mobile/WordPress-Editor-Android/pull/418 and https://github.com/wordpress-mobile/WordPress-Editor-Android/pull/420 to captioned images in this PR (properly wrapping media in paragraphs when switching from HTML to visual, and adding an empty space under media under the same circumstances).

The wp.loadText method we're using doesn't treat captions the same way as other media, so a few extensions had to be added (in editor-utils-formatter.js) to treat captions the same way (3f15fa3). I also extended the JS tests to check for this.

cc @maxme

aforcier commented 8 years ago

Updated to remove space that was being added in front of the caption text (predates this PR).

maxme commented 8 years ago

Tested in wpandroid on API 16, 21, 23. :shipit:

Note: I added c04f955 so I could quickly copy/paste the test command (adding it to the gradle build would be better, but this project will be put in maintenance mode soon).