diff --git a/CHANGELOG.md b/CHANGELOG.md index c4afd3b5..e6789f3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - CSS: Hide menu on mobile - CSS: Invert icons in dark mode - Plugins: Allow changing CSP by more plugins +- New plugin: Use Monaco Editor for syntax highlighting - New plugin: Use Prism for syntax highlighting ## Adminer 5.1.0 (released 2025-03-24) diff --git a/plugins/monaco.php b/plugins/monaco.php new file mode 100644 index 00000000..9a72f745 --- /dev/null +++ b/plugins/monaco.php @@ -0,0 +1,72 @@ + +* @link https://microsoft.github.io/monaco-editor/ +* @link https://www.adminer.org/plugins/#use +* @author Jakub Vrana, https://www.vrana.cz/ +* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 +* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other) +*/ +class AdminerMonaco { + private $root; + + function __construct($root = "https://cdn.jsdelivr.net/npm/monaco-editor@0.52/min/vs") { + $this->root = $root; + } + + function syntaxHighlighting($tableStatuses) { + echo Adminer\script_src("$this->root/loader.js"); + ?> + +editorRoot; ?>/prism/languages/sql.js'; adminerHighlighter = els => els.forEach(el => { const mode = ( /jush-js/.test(el.className) ? 'json' : ( - /jush-\w*sql/.test(el.className) ? 'sql' : ( + /jush-(\w*sql|oracle|clickhouse|firebird)/.test(el.className) ? 'sql' : ( '' ))); if (mode) {