Skip to content

Commit 4270310

Browse files
committed
wiki - editor - add buttons 'inline code', 'add empty checkbox', 'add checked checkbox'
affects go-gitea#5436 Signed-off-by: Michael Gnehr <[email protected]>
1 parent 2d09765 commit 4270310

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

public/js/index.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,37 @@ function initWikiForm() {
11601160
spellChecker: false,
11611161
toolbar: ["bold", "italic", "strikethrough", "|",
11621162
"heading-1", "heading-2", "heading-3", "heading-bigger", "heading-smaller", "|",
1163-
"code", "quote", "|",
1163+
{
1164+
name: "code-inline",
1165+
action: function(e){
1166+
let cm = e.codemirror;
1167+
var selection = cm.getSelection();
1168+
cm.replaceSelection("`" + selection + "`");
1169+
if (!selection) {
1170+
var cursorPos = cm.getCursor();
1171+
cm.setCursor(cursorPos.line, cursorPos.ch - 1);
1172+
}
1173+
},
1174+
className: "fa fa-angle-right",
1175+
title: "Add Inline Code",
1176+
},"code", "quote", "|", {
1177+
name: "checkbox-empty",
1178+
action: function(e){
1179+
let cm = e.codemirror;
1180+
cm.replaceSelection("\n- [ ] " + cm.getSelection());
1181+
},
1182+
className: "fa fa-square-o",
1183+
title: "Add Checkbox (empty)",
1184+
},
1185+
{
1186+
name: "checkbox-checked",
1187+
action: function(e){
1188+
let cm = e.codemirror;
1189+
cm.replaceSelection("\n- [x] " + cm.getSelection());
1190+
},
1191+
className: "fa fa-check-square-o",
1192+
title: "Add Checkbox (checked)",
1193+
}, "|",
11641194
"unordered-list", "ordered-list", "|",
11651195
"link", "image", "table", "horizontal-rule", "|",
11661196
"clean-block", "preview", "fullscreen"]

0 commit comments

Comments
 (0)