Skip to content

Conversation

@abhinayagarwal
Copy link
Collaborator

Fixes #364

execute(cmd, false);
}

public void execute(AbstractCommand<T> cmd, boolean skipUndo) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems a good fix, but there are many internal uses of CommandManager::execute, which are only exposed via ActionCmdFactory (i.e. ActionCmdFactory::decorate calls ActionCmdDecorate::apply that calls viewModel.getCommandManager().execute(new DecorateCmd(Objects.requireNonNull(decorations)));).

So this API change would only work for direct usage of execute, which I don't think is happening, given that the CommandManager is typically used only internally by the RTA view model, and not by developers, isn't it?

*/
package com.gluonhq.richtextarea.viewmodel;

public interface EditActionCmd extends ActionCmd {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need a new interface. ActionCmd could have:

public interface ActionCmd {
    void apply(RichTextAreaViewModel viewModel);

    default void apply(RichTextAreaViewModel viewModel, boolean skipUndo) {
        apply(viewModel);
    }
...

And then you could add the new apply where needed (ActionCmdXXX)

Copy link
Collaborator

Choose a reason for hiding this comment

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

DecorateAction and subclasses don't expose this.
BasicAction::execute doesn't expose this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

DecorateAction doesn’t directly use the CommandManager. DecorateAction is extended by TextDecorateAction and ParagraphDecorateAction with both the later using ACTION_CMD_FACTORY.decorate internally. Should skipUndo be added as a constructor parameter to DecorateAction ?

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.

Add support for programmatic control over undo/redo of text decorations

2 participants