From 4270310ee6f577b4f672473fbbcce0085fcf380b Mon Sep 17 00:00:00 2001 From: Michael Gnehr Date: Tue, 18 Jun 2019 19:31:48 +0200 Subject: [PATCH 1/3] wiki - editor - add buttons 'inline code', 'add empty checkbox', 'add checked checkbox' affects #5436 Signed-off-by: Michael Gnehr --- public/js/index.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/public/js/index.js b/public/js/index.js index 28023e1061bbf..304d0239657da 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1160,7 +1160,37 @@ function initWikiForm() { spellChecker: false, toolbar: ["bold", "italic", "strikethrough", "|", "heading-1", "heading-2", "heading-3", "heading-bigger", "heading-smaller", "|", - "code", "quote", "|", + { + name: "code-inline", + action: function(e){ + let cm = e.codemirror; + var selection = cm.getSelection(); + cm.replaceSelection("`" + selection + "`"); + if (!selection) { + var cursorPos = cm.getCursor(); + cm.setCursor(cursorPos.line, cursorPos.ch - 1); + } + }, + className: "fa fa-angle-right", + title: "Add Inline Code", + },"code", "quote", "|", { + name: "checkbox-empty", + action: function(e){ + let cm = e.codemirror; + cm.replaceSelection("\n- [ ] " + cm.getSelection()); + }, + className: "fa fa-square-o", + title: "Add Checkbox (empty)", + }, + { + name: "checkbox-checked", + action: function(e){ + let cm = e.codemirror; + cm.replaceSelection("\n- [x] " + cm.getSelection()); + }, + className: "fa fa-check-square-o", + title: "Add Checkbox (checked)", + }, "|", "unordered-list", "ordered-list", "|", "link", "image", "table", "horizontal-rule", "|", "clean-block", "preview", "fullscreen"] From a8ebc9a8200172806e59dd80acefc1c5199890f1 Mon Sep 17 00:00:00 2001 From: Michael Gnehr Date: Tue, 18 Jun 2019 19:40:35 +0200 Subject: [PATCH 2/3] add missing 'set focus' after insert with buttons Signed-off-by: Michael Gnehr --- public/js/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/public/js/index.js b/public/js/index.js index 304d0239657da..528bcf031f0a7 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1170,6 +1170,7 @@ function initWikiForm() { var cursorPos = cm.getCursor(); cm.setCursor(cursorPos.line, cursorPos.ch - 1); } + cm.focus(); }, className: "fa fa-angle-right", title: "Add Inline Code", @@ -1178,6 +1179,7 @@ function initWikiForm() { action: function(e){ let cm = e.codemirror; cm.replaceSelection("\n- [ ] " + cm.getSelection()); + cm.focus(); }, className: "fa fa-square-o", title: "Add Checkbox (empty)", @@ -1187,6 +1189,7 @@ function initWikiForm() { action: function(e){ let cm = e.codemirror; cm.replaceSelection("\n- [x] " + cm.getSelection()); + cm.focus(); }, className: "fa fa-check-square-o", title: "Add Checkbox (checked)", From 4217ad208dd1e17c1fea4ccd7373f887f8599c15 Mon Sep 17 00:00:00 2001 From: Cherrg Date: Sat, 29 Jun 2019 15:33:49 +0200 Subject: [PATCH 3/3] consistent usage of let/const in added code --- public/js/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/js/index.js b/public/js/index.js index 99c38c1b0a248..e40ffc2f9daf1 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1164,10 +1164,10 @@ function initWikiForm() { name: "code-inline", action: function(e){ let cm = e.codemirror; - var selection = cm.getSelection(); + let selection = cm.getSelection(); cm.replaceSelection("`" + selection + "`"); if (!selection) { - var cursorPos = cm.getCursor(); + let cursorPos = cm.getCursor(); cm.setCursor(cursorPos.line, cursorPos.ch - 1); } cm.focus();