mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-12-31 21:08:11 +00:00
fix(editor): 数据源方法编辑后content变成字符串
This commit is contained in:
parent
8150f042ff
commit
03b6180a02
@ -217,9 +217,38 @@ const functionConfig = computed<FormConfig>(() => [
|
||||
},
|
||||
]);
|
||||
|
||||
const parseContent = (content: any) => {
|
||||
if (typeof content === 'string') {
|
||||
// 如果是字符串则转换为函数
|
||||
const parseDSL = getEditorConfig('parseDSL');
|
||||
return parseDSL<(..._args: any[]) => any>(content);
|
||||
}
|
||||
return content;
|
||||
};
|
||||
|
||||
const submitForm = (values: CodeBlockContent, data: ContainerChangeEventData) => {
|
||||
changedValue.value = undefined;
|
||||
emit('submit', values, data);
|
||||
|
||||
emit(
|
||||
'submit',
|
||||
{
|
||||
...values,
|
||||
content: parseContent(values.content),
|
||||
},
|
||||
{
|
||||
...data,
|
||||
changeRecords: data.changeRecords?.map((record) => {
|
||||
let { value } = record;
|
||||
if (record.propPath === 'content' && typeof value === 'string') {
|
||||
value = parseContent(value);
|
||||
}
|
||||
return {
|
||||
...record,
|
||||
value,
|
||||
};
|
||||
}),
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
const errorHandler = (error: any) => {
|
||||
|
||||
@ -31,7 +31,6 @@ import { type ColumnConfig, MagicTable } from '@tmagic/table';
|
||||
|
||||
import CodeBlockEditor from '@editor/components/CodeBlockEditor.vue';
|
||||
import type { CodeParamStatement } from '@editor/type';
|
||||
import { getEditorConfig } from '@editor/utils/config';
|
||||
|
||||
defineOptions({
|
||||
name: 'MFieldsDataSourceMethods',
|
||||
@ -119,13 +118,6 @@ const createCodeHandler = () => {
|
||||
};
|
||||
|
||||
const submitCodeHandler = (value: CodeBlockContent, data: ContainerChangeEventData) => {
|
||||
if (value.content) {
|
||||
// 在保存的时候转换代码内容
|
||||
const parseDSL = getEditorConfig('parseDSL');
|
||||
if (typeof value.content === 'string') {
|
||||
value.content = parseDSL<(..._args: any[]) => any>(value.content);
|
||||
}
|
||||
}
|
||||
if (editIndex > -1) {
|
||||
emit('change', value, {
|
||||
modifyKey: editIndex,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user