wordpress-mobile / AztecEditor-Android

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

Add method to remove placeholder programatically #987

Closed planarvoid closed 1 year ago

planarvoid commented 1 year ago

Fix

This PR introduces a method to remove a placeholder from the AztecText programatically.

Test

  1. Initialize PlaceholderManager in the MainActivity.onCreate method
  2. Set aztec.addOnMediaDeletedListener(placeholderManager)
  3. Set aztec.addPlugin(placeholderManager)
  4. Register adapter placeholderManager.registerAdapter(ImageWithCaptionAdapter())
  5. Set EXAMPLE to "<placeholder type=\"image_with_caption\" src=\"https://file-examples.com/storage/febc474733629f43d9f078c/2017/10/file_example_JPG_100kB.jpg\" caption=\"1\"><br><placeholder type=\"image_with_caption\" src=\"https://file-examples.com/storage/febc474733629f43d9f078c/2017/10/file_example_JPG_100kB.jpg\" caption=\"2\">"
  6. Run the app
  7. Call the removeItem to remove a placeholder based on a predicate, for example I've tested it by adding the following call to the gallery button click:
placeholderManager.removeItem {
                    it.getValue("caption") == "1"
                }

Review

@danilo04

Make sure strings will be translated: