mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-29 05:38:45 +08:00
fix(editor): 修复setCodeDslById不传content引起的问题
This commit is contained in:
parent
8195a600f5
commit
13dc3ca259
@ -106,13 +106,17 @@ class CodeBlock extends BaseService {
|
|||||||
*/
|
*/
|
||||||
public async setCodeDslById(id: Id, codeConfig: CodeBlockContent): Promise<void> {
|
public async setCodeDslById(id: Id, codeConfig: CodeBlockContent): Promise<void> {
|
||||||
let codeDsl = await this.getCodeDsl();
|
let codeDsl = await this.getCodeDsl();
|
||||||
|
const codeConfigProcessed = codeConfig;
|
||||||
|
if (codeConfig.content) {
|
||||||
|
// 在保存的时候转换代码内容
|
||||||
|
// eslint-disable-next-line no-eval
|
||||||
|
codeConfigProcessed.content = eval(codeConfig.content);
|
||||||
|
}
|
||||||
if (!codeDsl) {
|
if (!codeDsl) {
|
||||||
// dsl中无代码块字段
|
// dsl中无代码块字段
|
||||||
codeDsl = {
|
codeDsl = {
|
||||||
[id]: {
|
[id]: {
|
||||||
...codeConfig,
|
...codeConfigProcessed,
|
||||||
// eslint-disable-next-line no-eval
|
|
||||||
content: eval(codeConfig.content),
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
@ -121,9 +125,7 @@ class CodeBlock extends BaseService {
|
|||||||
...codeDsl,
|
...codeDsl,
|
||||||
[id]: {
|
[id]: {
|
||||||
...existContent,
|
...existContent,
|
||||||
...codeConfig,
|
...codeConfigProcessed,
|
||||||
// eslint-disable-next-line no-eval
|
|
||||||
content: eval(codeConfig.content),
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user