]> git.joonet.de Git - adminer.git/commitdiff
Syntax highlighting: Hook AJAX
authorJakub Vrana <jakub@vrana.cz>
Tue, 1 Apr 2025 07:52:04 +0000 (09:52 +0200)
committerJakub Vrana <jakub@vrana.cz>
Tue, 1 Apr 2025 07:52:04 +0000 (09:52 +0200)
adminer/static/editing.js
adminer/static/functions.js
plugins/codemirror.php

index d520449575683b6eab1c4c2f41e048c6fe7a1129..a356c4969de95bfbc275f0e10a5160400756e888 100644 (file)
@@ -41,6 +41,7 @@ function syntaxHighlighting(version, vendor) {
                        jush.custom_links = jushLinks;
                }
                jush.highlight_tag('code', 0);
+               adminerHighlighter = els => jush.highlight_tag(els, 0);
                for (const tag of qsa('textarea')) {
                        if (/(^|\s)jush-/.test(tag.className)) {
                                const pre = jush.textarea(tag);
index 6d6012a04f14976cda0fb4586b474b25eaddd03e..4b69484eecb380e79ffc26abfc27ce065c370d21 100644 (file)
@@ -618,6 +618,7 @@ function ajaxSetHtml(url) {
 }
 
 let editChanged; // used by plugins
+let adminerHighlighter = els => {}; // overwritten by syntax highlighters
 
 /** Save form contents through AJAX
 * @param HTMLFormElement
@@ -650,9 +651,7 @@ function ajaxForm(form, message, button) {
                if (qs('.message', ajaxstatus)) { // success
                        editChanged = null;
                }
-               if (window.jush) {
-                       jush.highlight_tag(qsa('code', ajaxstatus), 0);
-               }
+               adminerHighlighter(qsa('code', ajaxstatus));
                messagesPrint(ajaxstatus);
        }, data, message);
 }
index 8f5adf4e8d8677bb89e083a087017e26ce8fccb0..56cdb6887264a69be2492ce302e0fa12bf19279e 100644 (file)
@@ -56,13 +56,15 @@ function getCmMode(el) {
        }
 }
 
-for (const el of qsa('code')) {
+adminerHighlighter = els => els.forEach(el => {
        const mode = getCmMode(el);
        if (mode) {
                el.classList.add('cm-s-default');
                CodeMirror.runMode(el.textContent, mode, el);
        }
-}
+});
+
+adminerHighlighter(qsa('code'));
 
 for (const el of qsa('textarea')) {
        const mode = getCmMode(el);