From 30e40b62d10ad2295fc501b1bf240f09c645dbc2 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 17 May 2016 13:51:20 +0200 Subject: [PATCH] Added shortcut "y" to remove formatting of whole text area. Streamline of common css behaviour for p and code in mail clients. --- .../widget/keyboard_shortcuts.coffee | 6 +++ .../app/lib/base/jquery.contenteditable.js | 7 +++- app/assets/stylesheets/zammad.scss | 39 ++++++++++--------- app/models/channel/email_build.rb | 3 +- 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/app/assets/javascripts/app/controllers/widget/keyboard_shortcuts.coffee b/app/assets/javascripts/app/controllers/widget/keyboard_shortcuts.coffee index e7929c663..325cc799f 100644 --- a/app/assets/javascripts/app/controllers/widget/keyboard_shortcuts.coffee +++ b/app/assets/javascripts/app/controllers/widget/keyboard_shortcuts.coffee @@ -361,6 +361,12 @@ App.Config.set( description: 'Removes the formatting' globalEvent: 'richtext-remove-formating' } + { + key: 'y' + hotkeys: true + description: '... of whole textarea' + globalEvent: 'richtext-remove-formating-textarea' + } { key: 'z' hotkeys: true, diff --git a/app/assets/javascripts/app/lib/base/jquery.contenteditable.js b/app/assets/javascripts/app/lib/base/jquery.contenteditable.js index 1eab9a987..51a10207e 100644 --- a/app/assets/javascripts/app/lib/base/jquery.contenteditable.js +++ b/app/assets/javascripts/app/lib/base/jquery.contenteditable.js @@ -111,6 +111,7 @@ // altKey + ctrlKey + i -> Toggles the current selection between italic and non-italic // altKey + ctrlKey + v -> Toggles the current selection between strike and non-strike // altKey + ctrlKey + f -> Removes the formatting tags from the current selection + // altKey + ctrlKey + y -> Removes the formatting from while textarea // altKey + ctrlKey + z -> Inserts a Horizontal Rule // altKey + ctrlKey + l -> Toggles the text selection between an unordered list and a normal block // altKey + ctrlKey + k -> Toggles the text selection between an ordered list and a normal block @@ -125,7 +126,8 @@ || e.keyCode == 76 || e.keyCode == 75 || e.keyCode == 86 - || e.keyCode == 87)) { + || e.keyCode == 87 + || e.keyCode == 89)) { e.preventDefault() // disable rich text b/u/i @@ -145,6 +147,9 @@ if (e.keyCode == 70) { document.execCommand('RemoveFormat') } + if (e.keyCode == 89) { + App.Utils.htmlRemoveRichtext(_this.$element) + } if (e.keyCode == 90) { document.execCommand('insertHorizontalRule') } diff --git a/app/assets/stylesheets/zammad.scss b/app/assets/stylesheets/zammad.scss index 04fdb7636..857adbb2b 100644 --- a/app/assets/stylesheets/zammad.scss +++ b/app/assets/stylesheets/zammad.scss @@ -147,6 +147,10 @@ blockquote { display: inline-block; } +.u-notAllowed { + cursor: not-allowed; +} + .zIndex-1, .zIndex-2, .zIndex-3, @@ -6409,7 +6413,7 @@ label + .wizard-buttonList { [data-toggle=dropdown] { position: relative; } - + .icon { opacity: 0.8; } @@ -6426,10 +6430,10 @@ label + .wizard-buttonList { margin: 0 32px 32px 0; border-radius: 100%; box-shadow: 0 0 0 4px white; - + .avatar { @extend .u-clickable; - + &.is-active { box-shadow: 0 0 0 4px hsl(200,71%,59%); } @@ -6461,7 +6465,7 @@ label + .wizard-buttonList { opacity: 0.5; fill: hsl(234,10%,19%); } - + &:hover svg { opacity: 1; } @@ -6499,13 +6503,13 @@ label + .wizard-buttonList { } .fileUpload input { - position: absolute; - right: 0; + position: absolute; + right: 0; top: 0; - font-size: 118px; - margin: 0; - padding: 0; - cursor: pointer; + font-size: 118px; + margin: 0; + padding: 0; + cursor: pointer; opacity: 0; } @@ -7116,11 +7120,11 @@ output { line-height: 1; padding-top: 11px; padding-bottom: 9px; - + &:hover { color: hsl(60,1%,34%); } - + .icon { fill: currentColor; vertical-align: top; @@ -7131,7 +7135,7 @@ output { .settings-list-controls { padding: 0; - + & > div { display: flex; min-height: 40px; @@ -7147,7 +7151,7 @@ output { .settings-list-control-cell { padding: 5px; - + & ~ .settings-list-row-control { padding-bottom: 7px; } @@ -8120,10 +8124,9 @@ output { } .richtext-content { - p, table, pre, - blockquote { + blockquote { margin-bottom: 16px; } @@ -8147,7 +8150,7 @@ output { width: 100%; overflow: auto; word-break: keep-all; - + td, th { padding: 7px 12px; border: 1px solid hsl(0,0%,87%); @@ -8175,7 +8178,7 @@ output { code { border: none; background: hsl(0,0%,97%); - white-space: normal; + white-space: pre-wrap; } pre { diff --git a/app/models/channel/email_build.rb b/app/models/channel/email_build.rb index 4871cee7b..0befc7c1f 100644 --- a/app/models/channel/email_build.rb +++ b/app/models/channel/email_build.rb @@ -180,7 +180,6 @@ Check if string is a complete html document. If not, add head and css styles. p, table, div, td { max-width: 600px; } - p, table, pre, blockquote { @@ -203,7 +202,7 @@ Check if string is a complete html document. If not, add head and css styles. code { border: none; background: hsl(0,0%,97%); - white-space: normal; + white-space: pre-wrap; } blockquote { padding: 8px 12px;