import {paramsInterfaceValidKey} from '../../../script/index' /** * 右键菜单项格式 * @example * contextmenu: [ * { * label: '插入字段', * method: (editor) => { editor.session.insert(editor.getCursorPosition(), 'field_name') } * }, * { * label: '格式化', * disabled: () => false, * method: (editor) => { ... } * } * ] */ export interface AceEditorContextMenuItem { /** 菜单项显示文字 */ label: string /** 是否禁用,返回 true 则禁用该菜单项 */ disabled?: () => boolean /** 点击回调,接收原生 ace editor 实例 */ method: (editor: any) => void } export interface AceEditorInterface { model: string height: string disabled?: Function sqlFormatter?: boolean deepData?: number lang?: string placeholder?: Function /** 自定义右键菜单项列表,不传则不启用右键菜单 */ contextmenu?: AceEditorContextMenuItem[] } export interface AceOptionsInterface { useSoftTabs: boolean, tabSize: number, showLineNumbers: boolean, showPrintMargin: boolean, fontSize: number, enableLiveAutocompletion: boolean, wrap: boolean } export class AceEditorConfig implements AceEditorInterface { model = 'sql' height = '200px' deepData: number | undefined sqlFormatter = true disabled = (): boolean => false lang = 'sql' constructor (params: AceEditorInterface) { paramsInterfaceValidKey(this, params) } }