codemirror实现SQL代码⾃动提⽰功能使⽤codemirror使⽤SQL代码能够⾃动提⽰如 PLSQL等⼯具⼀般智能提⽰功能,you should get over me
1、引⼊show-hint.css,codemirror.css和主题样式如:
theus<link href="codemirror-5.47.0/lib/codemirror.css"/>
<link href="codemirror-5.47.0/theme/monokai.css"/>
<link href="codemirror-5.47.0/theme/eclip.css"/>
<link href="codemirror-5.47.0/theme/idea.css"/>
<link href="codemirror-5.47.0/addon/hint/show-hint.css"/>
<link href="codemirror-5.47.0/addon/display/fullscreen.css"/>
英文新闻网站
2、引⼊codemirror.js、sql.js、show-hint.js、sql-hint.js
如:
codemirror-5.47.0/lib/codemirror.js
codemirror-5.47.0/mode/sql/sql.js
codemirror-5.47.0/mode/clike/clike.js
codemirror-5.47.0/addon/display/autorefresh.js
codemirror-5.47.0/addon/edit/matchbrackets.js
晚安的日语codemirror-5.47.0/addon/lection/active-line.js
codemirror-5.47.0/addon/display/fullscreen.js
codemirror-5.47.0/addon/hint/show-hint.js
codemirror-5.47.0/addon/hint/sql-hint.js
3、设置初始化codemirror,并设置table和列数据源
/**
* codemirror集成配置⼯具类 Created by 许畅 on 2019-05-27.
*
* codemirror代码配置:
* <pre>
* solveMode("text/x-sql").keywords["left join"]=true
* solveMode("text/x-sql").keywords["left"]=true
* solveMode("text/x-sql").keywords["right join"]=true
托福出国
* solveMode("text/x-sql").keywords["right"]=true
* solveMode("text/x-sql").keywords["inner join"]=true
* solveMode("text/x-sql").keywords["inner"]=true
英语字母书写
* solveMode("text/x-sql").keywords["when"]=true
* solveMode("text/x-sql").keywords["FROM_DAYS(N)"]=true
* solveMode("text/x-sql").keywords["UPGRADE"]=true
*
* sqlCodeMirror = CodeMirror.ElementById("sqlTest"),{ * mode: "text/x-sql",
* theme : "idea",
* lineNumbers : true,
* lineWrapping: true,
* styleActiveLine: true,
* matchBrackets: true,
* autoRefresh : true,
* extraKeys: {
* "Alt-/": "autocomplete",
dustin
* "F11": function(cm) {
* cm.tOption("fullScreen", !cm.getOption("fullScreen"));
* },
* "Esc": function(cm) {
* if (cm.getOption("fullScreen")) cm.tOption("fullScreen", fal);peopledaily
* }
* }, // To invoke the auto complete
* hint: CodeMirror.hint.sql,
* hintOptions: {
* tables: {
* "t_test_login": [ "col_a", "col_B", "col_C" ],
* "t_test_employee": [ "other_columns1", "other_columns2" ]
英语四级答题技巧out* }
* }
* });
* sqlCodeMirror.tValue("lect * from t_test_login where 1=1");
*
* ("change", function(editor, change) {
* if (igin == "+input"){
* var textArray = ;
* //不提⽰
* if(!ignoreInputCode(textArray)){
* tTimeout(function() { Command("autocomplete"); }, 100);
* }
* }
* });
* </pre>
*/
更新详细配置可参考其官⽅说明,可参照其demo说明。