mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Merge pull request #456 from matthojo/Keyboard-Shortcut-Improvements
Keyboard shortcut improvements
This commit is contained in:
commit
2b0c544e3e
2 changed files with 14 additions and 3 deletions
|
@ -15,7 +15,7 @@
|
|||
self.replace();
|
||||
},
|
||||
replace: function () {
|
||||
var text = this.elem.getSelection(), pass = true, md, cursor, line, word, converter;
|
||||
var text = this.elem.getSelection(), pass = true, md, cursor, line, word, letterCount, converter;
|
||||
switch (this.style) {
|
||||
case "h1":
|
||||
cursor = this.elem.getCursor();
|
||||
|
@ -93,13 +93,18 @@
|
|||
break;
|
||||
case "copyHTML":
|
||||
converter = new Showdown.converter();
|
||||
md = converter.makeHtml(text);
|
||||
if (text) {
|
||||
md = converter.makeHtml(text);
|
||||
} else {
|
||||
md = converter.makeHtml(this.elem.getValue());
|
||||
}
|
||||
|
||||
$(".modal-copyToHTML-content").text(md).selectText();
|
||||
$(".js-modal").center();
|
||||
pass = false;
|
||||
break;
|
||||
case "list":
|
||||
md = text.replace(/^/gm, "* ");
|
||||
md = text.replace(/^(\s*)(\w\W*)/gm, "$1* $2");
|
||||
this.elem.replaceSelection(md, "end");
|
||||
pass = false;
|
||||
break;
|
||||
|
@ -113,6 +118,11 @@
|
|||
}
|
||||
if (pass && md) {
|
||||
this.elem.replaceSelection(md, "end");
|
||||
if (!text) {
|
||||
letterCount = md.length;
|
||||
cursor = this.elem.getCursor();
|
||||
this.elem.setCursor({line: cursor.line, ch: cursor.ch - (letterCount / 2)});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
{'key': 'Meta+I', 'style': 'italic'},
|
||||
{'key': 'Ctrl+Alt+U', 'style': 'strike'},
|
||||
{'key': 'Ctrl+Shift+K', 'style': 'code'},
|
||||
{'key': 'Meta+K', 'style': 'code'},
|
||||
{'key': 'Ctrl+Alt+1', 'style': 'h1'},
|
||||
{'key': 'Ctrl+Alt+2', 'style': 'h2'},
|
||||
{'key': 'Ctrl+Alt+3', 'style': 'h3'},
|
||||
|
|
Loading…
Add table
Reference in a new issue