BigW Consortium Gitlab
POC: Markdown shortcut buttons ## What does this MR do? Adds markdown shortcut buttons to text area for comments. ## Are there points in the code the reviewer needs to double check? Because changing `textarea.val('something')` kills the natural browser undo stack, I had to implement a custom undo stack using state. You can't use the "undoable" state undo pattern because you need to go back to a previous state regardless of cursor position. The undo also adds an undo history item once you delete stuff or press enter. You can also edit multiple textareas at once and it will keep an undo history for each textarea individually, so the undo state should not collide between textareas. ## Why was this MR needed? It has been requested multiple times and the competition has it. https://gitlab.com/gitlab-org/gitlab-ce/issues/17185#note_12073433 Libraries are available that already implement this functionality but they are enormous and bloaty. I implemented this in very few lines of code and kept it very simple and as minimal as possible. This was also some competitions approach. I believe so as to not include too much JS. Adding extra buttons with new functionality **should only need new HTML and no new JS**. Only extra complex thing was adding a overridden undo stack, which was made as simple as possible as well. ## What are the relevant issue numbers? https://gitlab.com/gitlab-org/gitlab-ce/issues/17185#note_12073433 ## Screenshots (if relevant) **NOTE:** One thing you cannot see in this screenshot is that I am pressing <kbd>Cmd</kbd><kbd>Z</kbd> to undo and <kbd>Cmd</kbd><kbd>Shift</kbd><kbd>Z</kbd> to redo which is the undo/redo stack I implemented. <kbd>Ctrl</kbd><kbd>Y</kbd> also works for redo. ![markdown-editor](/uploads/2517bfb1a7b4269da7fcc4003c88b7f6/markdown-editor.gif) cc @dzaporozhets for UI cc @iamphill @alfredo1 for JS review cc @JobV if you like the idea. Fixes: #17185 See merge request !4305
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
appearances_helper.rb | Loading commit data... | |
application_helper.rb | Loading commit data... | |
application_settings_helper.rb | Loading commit data... | |
auth_helper.rb | Loading commit data... | |
blob_helper.rb | Loading commit data... | |
branches_helper.rb | Loading commit data... | |
broadcast_messages_helper.rb | Loading commit data... | |
button_helper.rb | Loading commit data... | |
ci_status_helper.rb | Loading commit data... | |
commits_helper.rb | Loading commit data... | |
compare_helper.rb | Loading commit data... | |
dashboard_helper.rb | Loading commit data... | |
diff_helper.rb | Loading commit data... | |
dropdowns_helper.rb | Loading commit data... | |
emails_helper.rb | Loading commit data... | |
events_helper.rb | Loading commit data... | |
explore_helper.rb | Loading commit data... | |
external_wiki_helper.rb | Loading commit data... | |
form_helper.rb | Loading commit data... | |
git_helper.rb | Loading commit data... | |
gitlab_markdown_helper.rb | Loading commit data... | |
gitlab_routing_helper.rb | Loading commit data... | |
graph_helper.rb | Loading commit data... | |
groups_helper.rb | Loading commit data... | |
icons_helper.rb | Loading commit data... | |
import_helper.rb | Loading commit data... | |
issuables_helper.rb | Loading commit data... | |
issues_helper.rb | Loading commit data... | |
javascript_helper.rb | Loading commit data... | |
labels_helper.rb | Loading commit data... | |
members_helper.rb | Loading commit data... | |
merge_requests_helper.rb | Loading commit data... | |
milestones_helper.rb | Loading commit data... | |
namespaces_helper.rb | Loading commit data... | |
nav_helper.rb | Loading commit data... | |
notes_helper.rb | Loading commit data... | |
notifications_helper.rb | Loading commit data... | |
page_layout_helper.rb | Loading commit data... | |
preferences_helper.rb | Loading commit data... | |
projects_helper.rb | Loading commit data... | |
runners_helper.rb | Loading commit data... | |
search_helper.rb | Loading commit data... | |
selects_helper.rb | Loading commit data... | |
snippets_helper.rb | Loading commit data... | |
sorting_helper.rb | Loading commit data... | |
submodule_helper.rb | Loading commit data... | |
tab_helper.rb | Loading commit data... | |
tags_helper.rb | Loading commit data... | |
time_helper.rb | Loading commit data... | |
todos_helper.rb | Loading commit data... | |
tree_helper.rb | Loading commit data... | |
triggers_helper.rb | Loading commit data... | |
version_check_helper.rb | Loading commit data... | |
visibility_level_helper.rb | Loading commit data... | |
workhorse_helper.rb | Loading commit data... |