Markdown formatting toolbar for rich text fields.
Review Request #11004 — Created May 15, 2020 and updated
This patch adds a markdown formatting toolbar for rich text editors.
The formatting-related buttons 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 with a
text to displayplaceholder. For the upload image
button, it opens a dialog to upload an image. A reference to the image
is added to the editor.
Manual testing only so far.
This doesn't quite have everything from the project description just yet. I'm not sure if the current implementation is easily open to modification by extensions though so I thought I'd just put up an initial review request to see if there's something big.
This bit looks a bit weird; it's for the upload image button, which is different from the other buttons because it's an input hidden in a label. It needs the
RB.TextEditorViewbut also needs access to the
inputelement to get the file. There must be a nicer way to do it but I'm not sure how.