import { isUndefinedOrNull } from 'ts-toolset/dist/common/types'; import { IComponentPropEntity } from '../../../models/base'; import { EditorOptionHook } from './types'; import { KV } from 'ts-toolset'; /** 解析自定义钩子配置 */ export function parseHooks(hooks: string) { let target: KV = {}; try { eval('target=' + hooks) } catch { console.log('not valid format for hooks: ' + hooks) } return target; } /** 获取编辑器默认值 */ export function getDefaultValue(prop: IComponentPropEntity, value: any) { return isUndefinedOrNull(value) ? typeof prop.defaultValue === 'object' ? { ...prop.defaultValue } : prop.defaultValue : value; }