]> BookStack Code Mirror - bookstack/commitdiff
Fixed markdown callout tags and cursor pos
authorDan Brown <redacted>
Sat, 9 Sep 2017 18:41:11 +0000 (19:41 +0100)
committerDan Brown <redacted>
Sat, 9 Sep 2017 18:41:11 +0000 (19:41 +0100)
Closes #470

resources/assets/js/directives.js

index 1f28673e1d080f0a9ad34e9e319ba0e2652397ef..7436a75a0399f816ea7e213e04009c69fbcd41b1 100644 (file)
@@ -99,7 +99,7 @@ module.exports = function (ngApp, events) {
                 extraKeys[`${metaKey}-7`] = function(cm) {wrapSelection('\n```\n', '\n```');};
                 extraKeys[`${metaKey}-8`] = function(cm) {wrapSelection('`', '`');};
                 extraKeys[`Shift-${metaKey}-E`] = function(cm) {wrapSelection('`', '`');};
-                extraKeys[`${metaKey}-9`] = function(cm) {wrapSelection('<p class="callout info">', '</div>');};
+                extraKeys[`${metaKey}-9`] = function(cm) {wrapSelection('<p class="callout info">', '</p>');};
                 cm.setOption('extraKeys', extraKeys);
 
                 // Update data on content change
@@ -193,12 +193,13 @@ module.exports = function (ngApp, events) {
                     }
 
                     cm.replaceRange(newLineContent, {line: cursor.line, ch: 0}, {line: cursor.line, ch: lineLen});
-                    cm.setCursor({line: cursor.line, ch: cursor.ch + (newLineContent.length - lineLen)});
+                    cm.setCursor({line: cursor.line, ch: cursor.ch + start.length});
                 }
 
                 function wrapSelection(start, end) {
                     let selection = cm.getSelection();
                     if (selection === '') return wrapLine(start, end);
+
                     let newSelection = selection;
                     let frontDiff = 0;
                     let endDiff = 0;