0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-01 02:41:39 -05:00

Added the ability to copy as HTML.

This commit is contained in:
Matthew Harrison-Jones 2013-07-22 13:50:50 +01:00
parent 3fccf8ad5d
commit cd1835a3cf
2 changed files with 11 additions and 3 deletions

View file

@ -1,6 +1,6 @@
// # Surrounds given text with Markdown syntax
/*global $, CodeMirror */
/*global $, window, CodeMirror, Showdown */
(function () {
"use strict";
var Markdown = {
@ -15,7 +15,7 @@
self.replace();
},
replace: function () {
var text = this.elem.getSelection(), pass = true, md, cursor, word;
var text = this.elem.getSelection(), pass = true, md, cursor, word, converter;
switch (this.style) {
case "link":
md = this.options.syntax.link.replace('$1', text);
@ -49,6 +49,12 @@
this.elem.setSelection({line: cursor.line, ch: word.start}, {line: cursor.line, ch: word.end});
}
break;
case "copyHTML":
converter = new Showdown.converter();
md = converter.makeHtml(text);
window.prompt("Copy to clipboard: Ctrl+C, Enter", md);
pass = false;
break;
case "list":
md = text.replace(/^/gm, "* ");
this.elem.replaceSelection("\n" + md + "\n", "end");

View file

@ -28,7 +28,9 @@
{'key': 'Ctrl+Shift+U', 'style': 'lowercase'},
{'key': 'Ctrl+Alt+Shift+U', 'style': 'titlecase'},
{'key': 'Ctrl+Alt+W', 'style': 'selectword'},
{'key': 'Ctrl+L', 'style': 'list'}
{'key': 'Ctrl+L', 'style': 'list'},
{'key': 'Ctrl+Alt+C', 'style': 'copyHTML'},
{'key': 'CMD+Alt+C', 'style': 'copyHTML'}
];
// The publish bar associated with a post, which has the TagWidget and