Skip to content

Conversation

@planarvoid
Copy link
Contributor

Fix

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

  • It locates the placeholder span based on predicate
  • It removes the placeholder span
  • it removes the wrapping media clickable span
  • it removes the magic whitespace char that represents the span
  • it refreshes the edit text

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:

  • If there are new strings that have to be translated, I have added them to the client's strings.xml as a part of the integration PR.

@planarvoid planarvoid requested a review from danilo04 June 10, 2022 08:23
@planarvoid planarvoid self-assigned this Jun 10, 2022
Copy link
Contributor

@danilo04 danilo04 left a comment

Choose a reason for hiding this comment

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

HI @planarvoid. Great work on this. I have tested it and is working!!!

@danilo04 danilo04 merged commit e8c934f into trunk Jun 10, 2022
@danilo04 danilo04 deleted the feature/add-option-to-remove-placeholders-programatically branch June 10, 2022 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants