X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/a6bbe4698741a5221f22fa7818a0a3037a54430a..d44acf4b:/resources/js/services/code.js diff --git a/resources/js/services/code.js b/resources/js/services/code.js index 3fcf74125..a8cede5f4 100644 --- a/resources/js/services/code.js +++ b/resources/js/services/code.js @@ -25,6 +25,7 @@ import 'codemirror/mode/sql/sql'; import 'codemirror/mode/toml/toml'; import 'codemirror/mode/xml/xml'; import 'codemirror/mode/yaml/yaml'; +import 'codemirror/mode/pascal/pascal'; // Addons import 'codemirror/addon/scroll/scrollpastend'; @@ -61,6 +62,8 @@ const modeMap = { powershell: 'powershell', properties: 'properties', ocaml: 'mllike', + pascal: 'text/x-pascal', + pas: 'text/x-pascal', php: (content) => { return content.includes('/gi ,'\n'); - const content = elem.textContent.trim(); + const content = elem.textContent.trimEnd(); let mode = ''; if (innerCodeElem !== null) { @@ -171,7 +185,7 @@ function getMode(suggestion, content) { * @returns {*|string} */ function getTheme() { - return window.codeTheme || 'base16-light'; + return window.codeTheme || 'default'; } /** @@ -258,10 +272,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 @@ -297,10 +319,12 @@ function getMetaKey() { export default { highlight: highlight, + highlightWithin: highlightWithin, wysiwygView: wysiwygView, popupEditor: popupEditor, setMode: setMode, setContent: setContent, + updateLayout: updateLayout, markdownEditor: markdownEditor, getMetaKey: getMetaKey, };