From 596a9acf4e47449fc7990cbbc842742415d141a0 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Mon, 15 Apr 2019 10:18:11 +0100 Subject: Editor: TOC insert correctly places on previous line rather than next line --- pydis_site/static/js/wiki/load_editor.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'pydis_site/static') diff --git a/pydis_site/static/js/wiki/load_editor.js b/pydis_site/static/js/wiki/load_editor.js index 1837c7fd..69730b14 100644 --- a/pydis_site/static/js/wiki/load_editor.js +++ b/pydis_site/static/js/wiki/load_editor.js @@ -19,23 +19,23 @@ const TOCAction = { name: "toc", - action: inserTOC, + action: insertTOC, className: "fa fa-stream", title: "Insert Table of Contents" }; let elements = document.getElementsByClassName("simple-mde"); - function inserTOC(editor) { + function insertTOC(editor) { let doc = editor.codemirror.getDoc(), cursor = doc.getCursor(), line = doc.getLine(cursor.line), - position = {"line": cursor.line}; + position = {"line": cursor.line, "ch": 0}; if (line.length === 0) { doc.replaceRange(TOCText, position); } else { - doc.replaceRange("\n" + TOCText, position) + doc.replaceRange(TOCText + "\n", position) } } -- cgit v1.2.3