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

Redo doesn't work, wrong sort order #58

Open
wolfadex opened this issue Sep 3, 2024 · 0 comments
Open

Redo doesn't work, wrong sort order #58

wolfadex opened this issue Sep 3, 2024 · 0 comments

Comments

@wolfadex
Copy link

wolfadex commented Sep 3, 2024

RichText.Config.Command.namedCommandListFromKeyboardEvent calls keyboardEventToDictKey internally which sorts the keys before converting the short key to __Short__ whereas the command mapping setup code converts first and then sorts. This causes redo to not work (at least on Mac) in the examples, e.g. in https://mweiss.github.io/elm-rte-toolkit/#/examples/markdown. I have a vendored fork that changes keyboardEventToDictKey to be

keyboardEventToDictKey : String -> KeyboardEvent -> List String
keyboardEventToDictKey shortKey keyboardEvent =
    ([ keyboardEvent.key ]
        |> addShiftKey keyboardEvent
        |> addMetaKey keyboardEvent
        |> addCtrlKey keyboardEvent
        |> addAltKey keyboardEvent
    )
        |> List.map
            (\v ->
                if v == shortKey then
                    short

                else
                    v
            )
        |> List.sort

which fixes the problem. I'll try and make a PR later, but wanted to document it so I don't forget.

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

No branches or pull requests

1 participant