-
Notifications
You must be signed in to change notification settings - Fork 422
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
Refactor and add tests for annotation editor toolbar commands #3017
Conversation
8b26a11
to
5d6604c
Compare
I'm not sure if this is a bug introduced by this code, but the "quote"/blockquote button doesn't update the selection appropriately to account for the new characters at the start of the line. |
The same is true of the |
* Separate the logic for transforming the input field from the logic for actually reading the state of the input field and applying changes. This enables testing of the commands without instantiating the component. Toolbar commands are functions which take the current state of the input field and return the updated state. * Add tests for the individual commands and use of the commands in the markdown editor.
Previously all modified lines in a block were replaced in one call to replaceText() when applying block formatting, which lost the selection. This rewrites the command to transform each line separately which preserves the selection.
5d6604c
to
67409c8
Compare
Agreed. I've rewritten the block formatting command to preserve the selection. |
Current coverage is
|
Great! FWIW, I really like the |
LGTM. |
…actor Refactor and add tests for annotation editor toolbar commands
This is one of the reasons I find functional approaches to front-end architecture so interesting. The logic which can be expressed in a functional way becomes very easy to test. |
This is part of a cleanup of the markdown editor to make fixing the related UX bugs for this sprint easier.
This commit refactors the markdown editor's toolbar command handling by separating out the logic for applying commands (make selection bold, insert link, convert selected lines to a list etc.) and the logic for actually applying that to the input field in the markdown editor.
I also removed a couple of
$timeout
calls which trigger an unnecessary full $digest cycle. As a temporary measure this will make the UI more responsive when typing in the editor on pages with large numbers of annotations.