X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/fca69643db409c028e3f09c8dcdf2cb0f572d824..8b4bfa4d780a3d586d0ad3dc64ff11822a0c3fbf:/resources/js/services/code.js diff --git a/resources/js/services/code.js b/resources/js/services/code.js index f92752109..70355643d 100644 --- a/resources/js/services/code.js +++ b/resources/js/services/code.js @@ -105,6 +105,7 @@ function highlightElem(elem) { value: content, mode: mode, lineNumbers: true, + lineWrapping: false, theme: getTheme(), readOnly: true }); @@ -191,6 +192,7 @@ function wysiwygView(elem) { value: content, mode: getMode(lang), lineNumbers: true, + lineWrapping: false, theme: getTheme(), readOnly: true }); @@ -216,8 +218,8 @@ function popupEditor(elem, modeSuggestion) { value: content, mode: getMode(modeSuggestion), lineNumbers: true, - theme: getTheme(), - lineWrapping: true + lineWrapping: false, + theme: getTheme() }); } @@ -243,24 +245,27 @@ function setContent(cmInstance, codeContent) { } /** - * Get a CodeMirror instace to use for the markdown editor. + * Get a CodeMirror instance to use for the markdown editor. * @param {HTMLElement} elem * @returns {*} */ function markdownEditor(elem) { - let content = elem.textContent; - - return CodeMirror(function (elt) { - elem.parentNode.insertBefore(elt, elem); - elem.style.display = 'none'; - }, { + const content = elem.textContent; + const config = { value: content, mode: "markdown", lineNumbers: true, - theme: getTheme(), lineWrapping: true, + theme: getTheme(), scrollPastEnd: true, - }); + }; + + window.$events.emitPublic(elem, 'editor-markdown-cm::pre-init', {config}); + + return CodeMirror(function (elt) { + elem.parentNode.insertBefore(elt, elem); + elem.style.display = 'none'; + }, config); } /**