diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php
index 197bb2e5..24d1b09a 100644
--- a/adminer/include/adminer.inc.php
+++ b/adminer/include/adminer.inc.php
@@ -1018,31 +1018,7 @@ class Adminer {
$connection->select_db(DB);
$tables = table_status('', true);
}
- // this is matched by compile.php
- echo script_src("../externals/jush/modules/jush.js");
- echo script_src("../externals/jush/modules/jush-textarea.js");
- echo script_src("../externals/jush/modules/jush-txt.js");
- echo script_src("../externals/jush/modules/jush-js.js");
- if (support("sql")) {
- echo script_src("../externals/jush/modules/jush-" . JUSH . ".js");
- ?>
-
-syntaxHighlighting($tables);
$this->databasesPrint($missing);
$actions = array();
if (DB == "" || !$missing) {
@@ -1067,6 +1043,34 @@ bodyLoad('
+ * @param array result of table_status()
+ */
+ function syntaxHighlighting($tables) {
+ global $connection;
+ // this is matched by compile.php
+ echo script_src("../externals/jush/modules/jush.js");
+ echo script_src("../externals/jush/modules/jush-textarea.js");
+ echo script_src("../externals/jush/modules/jush-txt.js");
+ echo script_src("../externals/jush/modules/jush-js.js");
+ if (support("sql")) {
+ echo script_src("../externals/jush/modules/jush-" . JUSH . ".js");
+ echo "\n";
+ }
+ echo script("bodyLoad('" . (is_object($connection) ? preg_replace('~^(\d\.?\d).*~s', '\1', $connection->server_info) : "") . "'" . ($connection->maria ? ", true" : "") . ");");
+ }
+
/** Prints databases list in menu
* @param string
* @return null
diff --git a/changes.txt b/changes.txt
index a53e2dfd..1d813728 100644
--- a/changes.txt
+++ b/changes.txt
@@ -3,6 +3,7 @@ Align numbers right (bug #912)
CSS: Dark mode syntax highlighting
SQL textarea: Open help on Ctrl+click
Designs named adminer-dark.css use dark basic style
+Plugins: add method syntaxHighlighting()
Adminer 5.0.5 (released 2025-03-13):
MySQL: Display converting function for binary, bit or geometry fields
diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php
index 6ab6da82..508c7dae 100644
--- a/editor/include/adminer.inc.php
+++ b/editor/include/adminer.inc.php
@@ -627,6 +627,9 @@ qsl('div').onclick = whisperClick;", "")
}
}
+ function syntaxHighlighting($tables) {
+ }
+
function databasesPrint($missing) {
}
diff --git a/plugins/codemirror.php b/plugins/codemirror.php
new file mode 100644
index 00000000..8d55988c
--- /dev/null
+++ b/plugins/codemirror.php
@@ -0,0 +1,92 @@
+ including type-ahead of keywords and tables
+* @link https://codemirror.net/5/
+* @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 AdminerCodemirror {
+ private $root;
+
+ function __construct($root = "codemirror5") {
+ $this->root = $root;
+ }
+
+ function syntaxHighlighting($tableStatuses) {
+ $connection = Adminer\connection();
+ ?>
+
+root/lib/codemirror.js");
+ echo Adminer\script_src("$this->root/addon/runmode/runmode.js");
+ echo Adminer\script_src("$this->root/addon/hint/show-hint.js");
+ echo Adminer\script_src("$this->root/mode/javascript/javascript.js");
+ if (Adminer\support("sql")) {
+ echo Adminer\script_src("$this->root/mode/sql/sql.js");
+ echo Adminer\script_src("$this->root/addon/hint/sql-hint.js");
+ }
+ $tables = array();
+ foreach ($tableStatuses as $status) {
+ foreach (Adminer\fields($status["Name"]) as $name => $field) {
+ $tables[$status["Name"]][] = $name;
+ }
+ }
+ ?>
+
+applyPlugin(__FUNCTION__, $args);
}
+ function syntaxHighlighting($tables) {
+ $args = func_get_args();
+ return $this->applyPlugin(__FUNCTION__, $args);
+ }
+
function databasesPrint($missing) {
$args = func_get_args();
return $this->applyPlugin(__FUNCTION__, $args);