Skip to content

Commit faf88a7

Browse files
Cherrgjeffliu27
authored andcommitted
wiki - editor - add buttons 'inline code', 'empty checkbox', 'checked checkbox' (go-gitea#7243)
* wiki - editor - add buttons 'inline code', 'add empty checkbox', 'add checked checkbox' affects go-gitea#5436 Signed-off-by: Michael Gnehr <michael@gnehr.de> * add missing 'set focus' after insert with buttons Signed-off-by: Michael Gnehr <michael@gnehr.de> * consistent usage of let/const in added code
1 parent 060c57e commit faf88a7

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

Diff for: public/js/index.js

+34-1
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,40 @@ function initWikiForm() {
11581158
spellChecker: false,
11591159
toolbar: ["bold", "italic", "strikethrough", "|",
11601160
"heading-1", "heading-2", "heading-3", "heading-bigger", "heading-smaller", "|",
1161-
"code", "quote", "|",
1161+
{
1162+
name: "code-inline",
1163+
action: function(e){
1164+
let cm = e.codemirror;
1165+
let selection = cm.getSelection();
1166+
cm.replaceSelection("`" + selection + "`");
1167+
if (!selection) {
1168+
let cursorPos = cm.getCursor();
1169+
cm.setCursor(cursorPos.line, cursorPos.ch - 1);
1170+
}
1171+
cm.focus();
1172+
},
1173+
className: "fa fa-angle-right",
1174+
title: "Add Inline Code",
1175+
},"code", "quote", "|", {
1176+
name: "checkbox-empty",
1177+
action: function(e){
1178+
let cm = e.codemirror;
1179+
cm.replaceSelection("\n- [ ] " + cm.getSelection());
1180+
cm.focus();
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+
cm.focus();
1191+
},
1192+
className: "fa fa-check-square-o",
1193+
title: "Add Checkbox (checked)",
1194+
}, "|",
11621195
"unordered-list", "ordered-list", "|",
11631196
"link", "image", "table", "horizontal-rule", "|",
11641197
"clean-block", "preview", "fullscreen"]

0 commit comments

Comments
 (0)