]> BookStack Code Mirror - bookstack/blobdiff - resources/assets/js/components/markdown-editor.js
Wrap images inserted with markdown editor with anchor tag to original file ref #1062
[bookstack] / resources / assets / js / components / markdown-editor.js
index 9e2bb3915e4dc3a985b8a2e88da58cc7aa047847..88b61f0beeac9c871910b87063fa22b708793661 100644 (file)
@@ -8,6 +8,7 @@ class MarkdownEditor {
 
     constructor(elem) {
         this.elem = elem;
+        this.textDirection = document.getElementById('page-editor').getAttribute('text-direction');
         this.markdown = new MarkdownIt({html: true});
         this.markdown.use(mdTasksLists, {label: true});
 
@@ -98,6 +99,9 @@ class MarkdownEditor {
 
     codeMirrorSetup() {
         let cm = this.cm;
+        // Text direction
+        // cm.setOption('direction', this.textDirection);
+        cm.setOption('direction', 'ltr'); // Will force to remain as ltr for now due to issues when HTML is in editor.
         // Custom key commands
         let metaKey = code.getMetaKey();
         const extraKeys = {};
@@ -300,7 +304,7 @@ class MarkdownEditor {
         let cursorPos = this.cm.getCursor('from');
         window.ImageManager.show(image => {
             let selectedText = this.cm.getSelection();
-            let newText = "![" + (selectedText || image.name) + "](" + image.thumbs.display + ")";
+            let newText = "[![" + (selectedText || image.name) + "](" + image.thumbs.display + ")](" + image.url + ")";
             this.cm.focus();
             this.cm.replaceSelection(newText);
             this.cm.setCursor(cursorPos.line, cursorPos.ch + newText.length);
@@ -423,4 +427,4 @@ class MarkdownEditor {
 
 }
 
-module.exports = MarkdownEditor ;
\ No newline at end of file
+module.exports = MarkdownEditor ;