From 443a3d5de8e03291206a781dfbb84b200684f9f3 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 9 Feb 2016 13:28:19 +0100 Subject: [PATCH 1/2] Extended with: 1) breake
after enter on empty line 2) added cross browser rich text hotkeys + metaKey + ctrlKey + u -> Toggles the current selection between underlined and not underlined + metaKey + ctrlKey + b -> Toggles the current selection between bold and non-bold + metaKey + ctrlKey + i -> Toggles the current selection between italic and non-italic + metaKey + ctrlKey + r -> Removes the formatting tags from the current selection + metaKey + ctrlKey + h -> Inserts a Horizontal Rule + metaKey + ctrlKey + l -> Toggles the text selection between an unordered list and a normal block + metaKey + ctrlKey + k -> Toggles the text selection between an ordered list and a normal block + metaKey + ctrlKey + o -> Draws a line through the middle of the current selection + metaKey + ctrlKey + r -> Removes any hyperlink from the current selection --- .../app/lib/base/jquery.contenteditable.js | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/app/assets/javascripts/app/lib/base/jquery.contenteditable.js b/app/assets/javascripts/app/lib/base/jquery.contenteditable.js index f9a688cf9..7995def19 100644 --- a/app/assets/javascripts/app/lib/base/jquery.contenteditable.js +++ b/app/assets/javascripts/app/lib/base/jquery.contenteditable.js @@ -83,6 +83,64 @@ e.preventDefault() return } + + // breack
after enter on empty line + sel = window.getSelection() + node = $(sel.anchorNode) + if (node.parent().is('blockquote')) { + e.preventDefault() + document.execCommand('Insertparagraph') + document.execCommand('Outdent') + } + } + + // on zammad metaKey + ctrlKey + i/b/u + // + metaKey + ctrlKey + u -> Toggles the current selection between underlined and not underlined + // + metaKey + ctrlKey + b -> Toggles the current selection between bold and non-bold + // + metaKey + ctrlKey + i -> Toggles the current selection between italic and non-italic + // + metaKey + ctrlKey + r -> Removes the formatting tags from the current selection + // + metaKey + ctrlKey + h -> Inserts a Horizontal Rule + // + metaKey + ctrlKey + l -> Toggles the text selection between an unordered list and a normal block + // + metaKey + ctrlKey + k -> Toggles the text selection between an ordered list and a normal block + // + metaKey + ctrlKey + o -> Draws a line through the middle of the current selection + // + metaKey + ctrlKey + r -> Removes any hyperlink from the current selection + if ( !e.altKey && e.ctrlKey && e.metaKey && (_this.options.richTextFormatKey[ e.keyCode ] + || e.keyCode == 82 + || e.keyCode == 72 + || e.keyCode == 76 + || e.keyCode == 75 + || e.keyCode == 79 + || e.keyCode == 87)) { + e.preventDefault() + if (e.keyCode == 66) { + document.execCommand('Bold') + } + if (e.keyCode == 73) { + document.execCommand('Italic') + } + if (e.keyCode == 85) { + document.execCommand('Underline') + } + if (e.keyCode == 82) { + document.execCommand('RemoveFormat') + } + if (e.keyCode == 72) { + document.execCommand('insertHorizontalRule') + } + if (e.keyCode == 76) { + document.execCommand('InsertUnorderedList') + } + if (e.keyCode == 75) { + document.execCommand('InsertOrderedList') + } + if (e.keyCode == 79) { + document.execCommand('StrikeThrough') + } + if (e.keyCode == 87) { + document.execCommand('Unlink') + } + _this.log('content editable richtext key', e.keyCode) + return true } // limit check From dad59d36c018c5be53fc16a9f53efda85ae9eeab Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 9 Feb 2016 15:40:55 +0100 Subject: [PATCH 2/2] Fixed typos. --- .../app/lib/base/jquery.contenteditable.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/app/lib/base/jquery.contenteditable.js b/app/assets/javascripts/app/lib/base/jquery.contenteditable.js index 7995def19..ed1ecad53 100644 --- a/app/assets/javascripts/app/lib/base/jquery.contenteditable.js +++ b/app/assets/javascripts/app/lib/base/jquery.contenteditable.js @@ -84,7 +84,7 @@ return } - // breack
after enter on empty line + // break
after enter on empty line sel = window.getSelection() node = $(sel.anchorNode) if (node.parent().is('blockquote')) { @@ -95,15 +95,15 @@ } // on zammad metaKey + ctrlKey + i/b/u - // + metaKey + ctrlKey + u -> Toggles the current selection between underlined and not underlined - // + metaKey + ctrlKey + b -> Toggles the current selection between bold and non-bold - // + metaKey + ctrlKey + i -> Toggles the current selection between italic and non-italic - // + metaKey + ctrlKey + r -> Removes the formatting tags from the current selection - // + metaKey + ctrlKey + h -> Inserts a Horizontal Rule - // + metaKey + ctrlKey + l -> Toggles the text selection between an unordered list and a normal block - // + metaKey + ctrlKey + k -> Toggles the text selection between an ordered list and a normal block - // + metaKey + ctrlKey + o -> Draws a line through the middle of the current selection - // + metaKey + ctrlKey + r -> Removes any hyperlink from the current selection + // metaKey + ctrlKey + u -> Toggles the current selection between underlined and not underlined + // metaKey + ctrlKey + b -> Toggles the current selection between bold and non-bold + // metaKey + ctrlKey + i -> Toggles the current selection between italic and non-italic + // metaKey + ctrlKey + r -> Removes the formatting tags from the current selection + // metaKey + ctrlKey + h -> Inserts a Horizontal Rule + // metaKey + ctrlKey + l -> Toggles the text selection between an unordered list and a normal block + // metaKey + ctrlKey + k -> Toggles the text selection between an ordered list and a normal block + // metaKey + ctrlKey + o -> Draws a line through the middle of the current selection + // metaKey + ctrlKey + w -> Removes any hyperlink from the current selection if ( !e.altKey && e.ctrlKey && e.metaKey && (_this.options.richTextFormatKey[ e.keyCode ] || e.keyCode == 82 || e.keyCode == 72