jamis
Version:
一种支持通过JSON配置方式生成页面的组件库
81 lines (80 loc) • 3.18 kB
TypeScript
import type { SchemaExpression } from 'jamis-core';
import type { FormBaseControl, FormBaseControlSchema, FormControlProps, SchemaTokenizeableString, SizeUnit } from '../types';
/**
* Editor 代码编辑器
*
*/
export interface EditorControlSchema extends Omit<FormBaseControl, 'size'> {
type: 'editor' | 'bat-editor' | 'c-editor' | 'coffeescript-editor' | 'cpp-editor' | 'csharp-editor' | 'css-editor' | 'dockerfile-editor' | 'fsharp-editor' | 'go-editor' | 'handlebars-editor' | 'html-editor' | 'ini-editor' | 'java-editor' | 'javascript-editor' | 'json-editor' | 'less-editor' | 'lua-editor' | 'markdown-editor' | 'msdax-editor' | 'objective-c-editor' | 'php-editor' | 'plaintext-editor' | 'postiats-editor' | 'powershell-editor' | 'pug-editor' | 'python-editor' | 'r-editor' | 'razor-editor' | 'ruby-editor' | 'sb-editor' | 'scss-editor' | 'sol-editor' | 'sql-editor' | 'swift-editor' | 'typescript-editor' | 'vb-editor' | 'xml-editor' | 'yaml-editor';
/**
* 语言类型
*/
language?: 'bat' | 'c' | 'coffeescript' | 'cpp' | 'csharp' | 'css' | 'dockerfile' | 'fsharp' | 'go' | 'handlebars' | 'html' | 'ini' | 'java' | 'javascript' | 'json' | 'less' | 'lua' | 'markdown' | 'msdax' | 'objective-c' | 'php' | 'plaintext' | 'postiats' | 'powershell' | 'pug' | 'python' | 'r' | 'razor' | 'ruby' | 'sb' | 'scss' | 'shell' | 'sol' | 'sql' | 'swift' | 'typescript' | 'vb' | 'xml' | 'yaml';
/**
* 编辑器大小
*/
size?: SizeUnit | 'xxl';
sizeExpr?: SchemaExpression;
/**
* 是否展示全屏模式开关
*/
allowFullscreen?: boolean;
/**
* 获取编辑器底层实例
*/
editorDidMount?: string;
/**
* 默认打底的内容
*/
placeholder?: string;
}
export type EditorRendererEvent = 'blur' | 'focus';
export interface EditorProps extends FormControlProps, Omit<EditorControlSchema, 'className' | 'descriptionClassName' | 'inputClassName' | 'editorDidMount' | 'size'> {
options?: Record<string, any>;
}
/**
* Diff 编辑器
*
*/
export interface DiffControlSchema extends FormBaseControlSchema {
/**
* 指定为 Diff 编辑器
*/
type: 'diff-editor';
/**
* 左侧面板的值, 支持取变量。
*/
diffValue?: SchemaTokenizeableString;
/**
* 语言,参考 monaco-editor
*/
language?: string;
/**
* 编辑器配置
*/
options?: any;
}
export interface EditorComponentProps {
value?: string;
defaultValue?: string;
width?: number | string;
height?: number | string;
onChange?: (value: string, event: any) => void;
language?: string;
editorTheme?: string;
allowFullscreen?: boolean;
options: {
[propName: string]: any;
};
className?: string;
context?: any;
style?: React.CSSProperties;
isDiffEditor?: boolean;
placeholder?: string;
onFocus?: () => void;
onBlur?: () => void;
editorDidMount?: (editor: any, monaco: any) => void;
editorWillMount?: (monaco: any) => void;
editorWillUnmount?: (editor: any, monaco: any) => void;
editorFactory?: (conatainer: HTMLElement, monaco: any, options: any) => any;
}