From 95aa340c95d2227e332e13e9e76128463cabccb7 Mon Sep 17 00:00:00 2001 From: "andrey.torsunov" Date: Thu, 21 Jul 2016 12:43:34 +0300 Subject: [PATCH] Added underline --- README.md | 2 ++ src/js/simplemde.js | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 03793c9..01e0ce7 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,7 @@ Name | Action | Tooltip
Class bold | toggleBold | Bold
fa fa-bold italic | toggleItalic | Italic
fa fa-italic strikethrough | toggleStrikethrough | Strikethrough
fa fa-strikethrough +underline | toggleUnderline | Underline
fa fa-underline heading | toggleHeadingSmaller | Heading
fa fa-header heading-smaller | toggleHeadingSmaller | Smaller Heading
fa fa-header heading-bigger | toggleHeadingBigger | Bigger Heading
fa fa-lg fa-header @@ -247,6 +248,7 @@ Shortcut | Action :------- | :----- *Cmd-'* | "toggleBlockquote" *Cmd-B* | "toggleBold" +*Cmd-U* | "toggleUnderline" *Cmd-E* | "cleanBlock" *Cmd-H* | "toggleHeadingSmaller" *Cmd-I* | "toggleItalic" diff --git a/src/js/simplemde.js b/src/js/simplemde.js index 016d693..426b00d 100644 --- a/src/js/simplemde.js +++ b/src/js/simplemde.js @@ -21,6 +21,7 @@ var isMac = /Mac/.test(navigator.platform); var bindings = { "toggleBold": toggleBold, "toggleItalic": toggleItalic, + "toggleUnderline": toggleUnderline, "drawLink": drawLink, "toggleHeadingSmaller": toggleHeadingSmaller, "toggleHeadingBigger": toggleHeadingBigger, @@ -46,6 +47,7 @@ var bindings = { var shortcuts = { "toggleBold": "Cmd-B", "toggleItalic": "Cmd-I", + "toggleUnderline": "Cmd-U", "drawLink": "Cmd-K", "toggleHeadingSmaller": "Cmd-H", "toggleHeadingBigger": "Shift-Cmd-H", @@ -242,6 +244,12 @@ function toggleItalic(editor) { _toggleBlock(editor, "italic", editor.options.blockStyles.italic); } +/** + * Action for toggling underline. + */ +function toggleUnderline(editor) { + _toggleBlock(editor, "underline", "__"); +} /** * Action for toggling strikethrough. @@ -1081,6 +1089,12 @@ var toolbarBuiltInButtons = { title: "Italic", default: true }, + "underline": { + name: "underline", + action: toggleUnderline, + className: "fa fa-underline", + title: "Underline" + }, "strikethrough": { name: "strikethrough", action: toggleStrikethrough, @@ -1881,6 +1895,7 @@ SimpleMDE.prototype.value = function(val) { */ SimpleMDE.toggleBold = toggleBold; SimpleMDE.toggleItalic = toggleItalic; +SimpleMDE.toggleUnderline = toggleUnderline; SimpleMDE.toggleStrikethrough = toggleStrikethrough; SimpleMDE.toggleBlockquote = toggleBlockquote; SimpleMDE.toggleHeadingSmaller = toggleHeadingSmaller; @@ -1911,6 +1926,9 @@ SimpleMDE.prototype.toggleBold = function() { SimpleMDE.prototype.toggleItalic = function() { toggleItalic(this); }; +SimpleMDE.prototype.toggleUnderline = function() { + toggleUnderline(this); +}; SimpleMDE.prototype.toggleStrikethrough = function() { toggleStrikethrough(this); }; @@ -2025,4 +2043,4 @@ SimpleMDE.prototype.toTextArea = function() { } }; -module.exports = SimpleMDE; \ No newline at end of file +module.exports = SimpleMDE;