1.0.25 • Published 8 months ago
@baic/code-editor v1.0.25
@baic/code-editor
基于 monaco-editor 的代码编辑器
安装
pnpm add @baic/code-editor需要 webpack 插件配合
// 以 umi 为例
import { CodeEditorWebpackPlugin } from '@baic/code-editor';
export default {
chainWebpack: (memo) => {
memo
.plugin('code-editor-webpack-plugin')
.use(new CodeEditorWebpackPlugin());
},
};配置上下文
// 以 umi 为例
import type { ReactNode } from 'react';
/**
* 因为编辑器比较重,上下文的引用最好直接引用原地址,index的export引用会造成内存过大
*/
import Provider as CodeEditorProvider from '@baic/code-editor/es/provider';
export const rootContainer = (container: ReactNode) => {
return <CodeEditorProvider monacoEditorOptions={{}}>
{container}
<CodeEditorProvider>
}基本使用
import { JSONEditor } from '@baic/code-editor';
export default () => (
<div
style={{
height: 500,
}}
>
<JSONEditor />
</div>
);新增提示词
import { Kind, SQLEditor } from '@baic/code-editor';
const hintData = {
databases: [
{
content: 'bigdata',
kind: Kind.Struct,
tables: [
{
content: 'auth',
fields: [
{
content: 'id',
kind: Kind.Field,
},
],
kind: Kind.Folder,
},
{
content: 'role',
fields: [
{
content: 'id',
kind: Kind.Field,
},
],
kind: Kind.Folder,
},
],
},
],
keywords: [
{
content: 'SELECT',
kind: Kind.Keyword,
},
{
content: 'INSERT',
kind: Kind.Keyword,
},
{
content: 'UPDATE',
kind: Kind.Keyword,
},
],
};
export default () => (
<div
style={{
height: 500,
}}
>
<SQLEditor hintData={hintData} />
</div>
);Diff 使用
import { JSONEditor } from '@baic/code-editor';
export default () => (
<div
style={{
height: 500,
}}
>
<JSONEditor mode="diff" value="{}" original="{}" />
</div>
);1.0.19
10 months ago
1.0.18
10 months ago
1.0.17
11 months ago
1.0.16
11 months ago
1.0.9
1 year ago
1.0.8
1 year ago
1.0.7
1 year ago
1.0.6
1 year ago
1.0.5
1 year ago
1.0.22
9 months ago
1.0.21
9 months ago
1.0.20
10 months ago
1.0.25
8 months ago
1.0.24
8 months ago
1.0.23
8 months ago
1.0.11
1 year ago
1.0.10
1 year ago
1.0.15
11 months ago
1.0.14
12 months ago
1.0.13
12 months ago
1.0.12
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago