Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure to save remove action to history #1038

Merged
merged 1 commit into from
Mar 17, 2023

Conversation

planarvoid
Copy link
Contributor

Fix

Add undo action to removeItem operation in the placeholders.

Before you start make sure you setup the MainActivity like this:

Set the EXAMPLE to:

        private val EXAMPLE = """
            <p>Line</p>
            <placeholder type="image_with_caption" src="https://file-examples.com/storage/fed220eb286401af1a43037/2017/10/file_example_JPG_100kB.jpg" caption="Caption 1"
            <p>Line</p>
        """.trimIndent()

Create a placeholderManager field:

    protected lateinit var placeholderManager: PlaceholderManager

and initialize it in onCreate:

        placeholderManager = PlaceholderManager(visualEditor, findViewById(R.id.container_frame_layout))
        placeholderManager.registerAdapter(ImageWithCaptionAdapter())

and set it on aztec as media deleted listener and as a plugin:

 aztec = Aztec.with(visualEditor, sourceEditor, toolbar, this)
                ...
                .addOnMediaDeletedListener(placeholderManager)
               ...
                .addPlugin(placeholderManager)

Test

  1. Launch the MainActivity
  2. Press backspace behind the placeholder
  3. Notice it disappears
  4. Click on "undo"
  5. Notice it jumps back

Review

@khaykov

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 added the bug label Mar 16, 2023
@planarvoid planarvoid requested a review from khaykov March 16, 2023 09:40
@planarvoid planarvoid self-assigned this Mar 16, 2023
@khaykov khaykov self-assigned this Mar 17, 2023
Copy link
Member

@khaykov khaykov left a comment

Choose a reason for hiding this comment

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

Works well 👍 Thanks for the fix!

@khaykov khaykov merged commit 9cd1615 into trunk Mar 17, 2023
@khaykov khaykov deleted the fix/undo-when-deleting-placeholder branch March 17, 2023 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants