Markdown formatting toolbar for rich text fields.

Review Request #11004 — Created May 15, 2020 and submitted — Latest diff uploaded

Information

Review Board
master
f1fc4f0...

Reviewers

This patch adds a markdown formatting toolbar for rich text editors.
The buttons for inline formatting add the corresponding syntax to the
selection if one exists, or just inserts the syntax and positions
the cursor. This applies to the bold, italic, strikethrough, ordered
and unordered list, and code buttons. If the selection begins and ends
with the same syntax as the button being pressed, the syntax is removed.
For example, if the bold button is pressed and the selection is already
bolded, the bold syntax is removed.

For the insert link button, if there is a selection, the selection
becomes the text to display for the url. Otherwise, it inserts syntax
for a link and positions the cursor where the text to display will go.
Positioning the cursor in a formatted link, selecting the text in the
link, or the either link will remove the formatting.

For the upload image button, it opens a dialog to upload an image.
A reference to the image is added to the editor.

For the ordered and unordered list buttons, numbers (1.) or dashes (-)
are appended to or removed from to the beginning of the current line.

Unit tests for each type of formatting with:
- an empty selection
- cursor positioned in text
- unformatted text selection
- formatted text selection with text only, not including syntax
- formatted text selection including both text & syntax