summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrateek Saxena <prtksxna@gmail.com>2014-10-11 22:46:01 +0530
committerPrateek Saxena <prtksxna@gmail.com>2014-10-11 22:51:20 +0530
commit001d75cd1eb11f77b111569108888f3bb19ee974 (patch)
treef0ce0bab2b28616ade0156da72fcbe4ad41d9ddc
parent6ec55309a7ef06ef02ca251595b3c81238127a54 (diff)
downloadetherpad-lite-001d75cd1eb11f77b111569108888f3bb19ee974.zip
Add 'Ctrl-5' keyboard shortcut for 'strikethrough' #1987
A quick search revealed that 'Ctrl-5' is a popular shortcut for strikethrough. Implemented in 'ace2_inner' and updated the English l10n file for the tooltip.
-rw-r--r--src/locales/en.json4
-rw-r--r--src/static/js/ace2_inner.js12
2 files changed, 12 insertions, 4 deletions
diff --git a/src/locales/en.json b/src/locales/en.json
index 01d3ff4f..43de0bff 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -5,7 +5,7 @@
"pad.toolbar.bold.title": "Bold (Ctrl-B)",
"pad.toolbar.italic.title": "Italic (Ctrl-I)",
"pad.toolbar.underline.title": "Underline (Ctrl-U)",
- "pad.toolbar.strikethrough.title": "Strikethrough",
+ "pad.toolbar.strikethrough.title": "Strikethrough (Ctrl-5)",
"pad.toolbar.ol.title": "Ordered list",
"pad.toolbar.ul.title": "Unordered List",
"pad.toolbar.indent.title": "Indent (TAB)",
@@ -85,7 +85,7 @@
"pad.modals.disconnected": "You have been disconnected.",
"pad.modals.disconnected.explanation": "The connection to the server was lost",
"pad.modals.disconnected.cause": "The server may be unavailable. Please notify the service administrator if this continues to happen.",
-
+
"pad.share": "Share this pad",
"pad.share.readonly": "Read only",
"pad.share.link": "Link",
diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js
index 07a9b971..ac11b2e4 100644
--- a/src/static/js/ace2_inner.js
+++ b/src/static/js/ace2_inner.js
@@ -2333,7 +2333,7 @@ function Ace2Inner(){
if(rep.selStart[1] == rep.selEnd[1] && rep.selStart[1] == rep.lines.atIndex(n).text.length){
return false; // If we're at the end of a line we treat it as having no formatting
}
- if(rep.selStart[1] == 0 && rep.selEnd[1] == 0){
+ if(rep.selStart[1] == 0 && rep.selEnd[1] == 0){
rep.selEnd[1] == 1;
}
if(rep.selEnd[1] == -1){
@@ -3741,6 +3741,14 @@ function Ace2Inner(){
toggleAttributeOnSelection('underline');
specialHandled = true;
}
+ if ((!specialHandled) && isTypeForCmdKey && String.fromCharCode(which).toLowerCase() == "5" && (evt.metaKey || evt.ctrlKey))
+ {
+ // cmd-5 (strikethrough)
+ fastIncorp(13);
+ evt.preventDefault();
+ toggleAttributeOnSelection('strikethrough');
+ specialHandled = true;
+ }
if ((!specialHandled) && isTypeForCmdKey && String.fromCharCode(which).toLowerCase() == "h" && (evt.ctrlKey))
{
// cmd-H (backspace)
@@ -3818,7 +3826,7 @@ function Ace2Inner(){
// top.console.log(caretOffsetTop, viewport.top, caretOffsetTopBottom, viewport.bottom);
var caretIsNotVisible = (caretOffsetTop < viewport.top || caretOffsetTopBottom >= viewport.bottom); // Is the Caret Visible to the user?
// Expect some weird behavior caretOffsetTopBottom is greater than viewport.bottom on a keypress down
- var offsetTopSamePlace = caretOffsetTop == viewport.top; // sometimes moving key left & up leaves the caret at the same point as the viewport.top, technically the caret is visible but it's not fully visible so we should move to it
+ var offsetTopSamePlace = caretOffsetTop == viewport.top; // sometimes moving key left & up leaves the caret at the same point as the viewport.top, technically the caret is visible but it's not fully visible so we should move to it
if(offsetTopSamePlace && (evt.which == 37 || evt.which == 38)){
var newY = caretOffsetTop;
setScrollY(newY);