Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
editor.italic();
break;
+ // C - Code
+ case 67:
+ editor.code();
+ break;
+
// H - Headline
case 72:
editor.headline();
// Typography
this.parent.find("#bold").click(this.bold.bind(this));
this.parent.find("#italic").click(this.italic.bind(this));
+ this.parent.find("#code").click(this.code.bind(this));
// Headlines
this.parent.find("#headline").click(this.headline.bind(this));
this.replaceSelection("*" + this.selection.text + "*");
}
+ code() {
+ var multiline = this.selection.text.indexOf("\n");
+
+ if (multiline >= 0) {
+ this.replaceSelection("```\n" + this.selection.text + "\n```\n\n");
+ } else {
+ this.replaceSelection("`" + this.selection.text + "`");
+ }
+ }
+
// Headlines
findLevel() {
id="italic" title="{{ _("Italic") }} [{{ _("Ctrl") }}-I]">
<i class="fas fa-italic"></i>
</button>
+ <button type="button" class="btn btn-secondary"
+ id="code" title="{{ _("Code") }} [{{ _("Ctrl") }}-C]">
+ <i class="fas fa-code"></i>
+ </button>
</div>
<div class="btn-group btn-group-sm mr-2" role="group">