X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/a6bbe4698741a5221f22fa7818a0a3037a54430a..refs/pull/1817/head:/resources/js/services/code.js diff --git a/resources/js/services/code.js b/resources/js/services/code.js index 3fcf74125..533940e3b 100644 --- a/resources/js/services/code.js +++ b/resources/js/services/code.js @@ -258,10 +258,18 @@ function setMode(cmInstance, modeSuggestion, content) { function setContent(cmInstance, codeContent) { cmInstance.setValue(codeContent); setTimeout(() => { - cmInstance.refresh(); + updateLayout(cmInstance); }, 10); } +/** + * Update the layout (codemirror refresh) of a cm instance. + * @param cmInstance + */ +function updateLayout(cmInstance) { + cmInstance.refresh(); +} + /** * Get a CodeMirror instance to use for the markdown editor. * @param {HTMLElement} elem @@ -301,6 +309,7 @@ export default { popupEditor: popupEditor, setMode: setMode, setContent: setContent, + updateLayout: updateLayout, markdownEditor: markdownEditor, getMetaKey: getMetaKey, };