import * as React from "react";
import {
Editor,
supportLanguage,
CompletionItemKind,
init
} from "bravo-editor";
import * as monaco from "monaco-editor";
/**
* @description 资源加载逻辑,用于构建worker,添加在项目入口处
* @param prefix string型,资源前缀,默认为cdn,专有云场景下需要修改
*/
init();
//封网阶段
init(`https://dev.g.alicdn.com/nel/bravo-editor/${npmVersion}`);
const CompletionTypesEnum = {
SAMPLE_TYPE_ONE: {
text: "样例类型1",
kind: CompletionItemKind.Method
},
SAMPLE_TYPE_TWO: {
text: "样例类型2",
kind: CompletionItemKind.Method
},
KEYWORD: {
text: "关键词",
kind: CompletionItemKind.Keyword
},
CONSTS: {
text: "常量",
kind: CompletionItemKind.Snippet
},
FUNCTION: {
text: "函数",
kind: CompletionItemKind.Function
},
TABLE: {
text: "表名",
kind: CompletionItemKind.Method
},
TABLEALIAS: {
text: "表别名",
kind: CompletionItemKind.Method
},
FIELD: {
text: "表字段",
kind: CompletionItemKind.Field
},
FIELDALIAS: {
text: "表字段别名",
kind: CompletionItemKind.Field
},
SNIPPET: {
text: "代码块",
kind: CompletionItemKind.Snippet
},
STREAM_FUNCTION: {
text: "函数",
kind: CompletionItemKind.Function
},
STREAM_TABLE_FIELD: {
text: "表字段",
kind: CompletionItemKind.Field
}
};
export class Demo extends React.Component {
render() {
return (
<div style={{ height: 400 }}>
<Editor
onChange={null}
onEditorCreated={() => console.log("created")}
operation={true}
onCopy={value => console.log("copy success:", value)}
options={{
theme: `dark`,
value: "select * from a",
language: "ODPSSQL"
}}
completionTypes={CompletionTypesEnum}
onSuggestTables={(keyword, options) => {
return [
{
label: "sample_one_table1",
type: "SAMPLE_TYPE_ONE",
insertText: "LD.sample_one_table1",
kind: CompletionItemKind.Method,
sortText: "a"
}
];
}}
onSuggestFields={(keyword, options) => {
console.log("keyword==", keyword);
return Promise.resolve([
{
label: "age",
type: "SAMPLE_TYPE_ONE",
insertText: "age",
kind: CompletionItemKind.Field,
sortText: "b"
},
{
label: "banana",
type: "SAMPLE_TYPE_ONE",
insertText: "banana",
kind: CompletionItemKind.Field,
sortText: "b"
}
]);
}}
sorter={type => {
switch (type) {
case "TABLEALIAS":
case "TABLE":
return "c";
case "FIELD":
case "FIELDALIAS":
return "d";
case "KEYWORD":
case "CONSTS":
return "e";
case "FUNCTION":
return "f";
default:
}
}}
/>
// diff editor
<DiffEditor
languageId="ODPSSQL"
data={["current data", "original data"]}
/>
</div>
);
}
}
bravo-editor
0.0.104 • Public • PublishedVersions
Current Tags
- VersionDownloads (Last 7 Days)
- Tag
- 1.4.20-beta0
- beta
- 0.0.1040
- latest
Version History
- VersionDownloads (Last 7 Days)
- Published
- 0.0.1040
- 0.0.1030
- 0.0.1020
- 0.0.1010
- 0.0.990
- 0.0.980
- 0.0.970
- 0.0.960
- 0.0.950
- 0.0.940
- 0.0.930
- 0.0.920
- 0.0.910
- 0.0.900
- 0.0.890
- 0.0.880
- 0.0.870
- 0.0.860
- 0.0.830
- 0.0.820
- 0.0.800
- 0.0.790
- 0.0.780
- 0.0.770
- 0.0.750
- 0.0.730
- 0.0.720
- 0.0.710
- 0.0.700
- 0.0.690
- 0.0.680
- 0.0.670
- 0.0.660
- 0.0.650
- 0.0.640
- 0.0.630
- 0.0.620
- 0.0.610
- 0.0.600
- 0.0.590
- 0.0.580
- 0.0.570
- 0.0.560
- 1.6.20
- 1.5.510
- 1.6.10
- 1.5.500
- 1.5.490
- 1.5.480
- 1.5.470
- 1.5.460
- 1.5.450
- 1.5.440
- 1.5.430
- 1.5.420
- 1.5.410
- 1.5.400
- 1.5.390
- 1.5.380
- 1.5.370
- 1.5.360
- 1.5.350
- 1.5.340
- 1.5.330
- 1.5.320
- 1.5.310
- 1.5.300
- 1.5.290
- 1.5.280
- 1.5.270
- 1.5.260
- 1.5.250
- 1.5.240
- 1.5.230
- 1.5.220
- 1.5.210
- 1.5.200
- 1.5.190
- 1.4.210
- 1.5.180
- 1.5.170
- 1.5.160
- 1.5.150
- 1.5.140
- 1.5.130
- 1.5.120
- 1.5.110
- 1.5.100
- 1.5.90
- 1.5.80
- 1.5.50
- 1.5.40
- 1.5.30
- 1.5.20
- 1.5.10
- 1.4.20-beta0
- 1.4.190
- 1.4.180
- 1.4.170
- 1.4.160
- 1.4.150
- 1.4.130
- 1.4.12-beta0
- 1.4.110
- 1.4.100
- 1.4.90
- 1.4.80
- 1.4.70
- 1.4.60
- 1.4.50
- 1.4.40
- 1.4.30
- 1.4.10
- 1.3.120
- 1.3.110
- 1.3.11-beta0
- 1.3.90
- 1.3.80
- 1.3.70
- 1.3.60
- 1.3.50
- 1.3.40
- 1.3.30
- 1.3.2-beta0
- 1.3.1-beta0
- 1.2.30
- 1.3.0-beta0
- 1.2.20
- 1.2.10
- 1.1.10
- 1.0.530
- 1.0.520
- 1.0.510
- 1.0.500
- 1.0.490
- 1.0.480
- 1.0.470
- 1.0.460
- 1.0.450
- 1.0.44-beta0
- 1.0.420
- 1.0.410
- 1.0.400
- 1.0.390
- 1.0.380
- 1.0.370
- 1.0.360
- 1.0.350
- 1.0.340
- 1.0.33-beta0
- 1.0.320
- 1.0.310
- 1.0.30-beta0
- 1.0.29-beta0
- 1.0.280
- 1.0.270
- 1.0.260
- 1.0.250
- 1.0.240
- 1.0.220
- 1.0.210
- 1.0.200
- 1.0.20-beta0
- 1.0.190
- 1.0.180
- 1.0.170
- 1.0.160
- 1.0.150
- 1.0.140
- 1.0.130
Package Sidebar
Install
npm i bravo-editor
Weekly Downloads
0
Version
0.0.104
License
MIT
Unpacked Size
2.52 MB
Total Files
248