mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
fix(editor): 代码块code-block-panel-tool slot data丢失
This commit is contained in:
parent
6340bcc04b
commit
aa12779598
@ -85,6 +85,7 @@ const codeList = computed(() =>
|
|||||||
id: target.id,
|
id: target.id,
|
||||||
name: target.name,
|
name: target.name,
|
||||||
type: 'code',
|
type: 'code',
|
||||||
|
codeBlockContent: codeBlockService?.getCodeContentById(target.id),
|
||||||
children: Object.entries(target.deps).map(([id, dep]) => ({
|
children: Object.entries(target.deps).map(([id, dep]) => ({
|
||||||
name: dep.name,
|
name: dep.name,
|
||||||
type: 'node',
|
type: 'node',
|
||||||
|
@ -39,9 +39,6 @@ class CodeBlock extends BaseService {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super([
|
super([
|
||||||
'getCodeContentById',
|
|
||||||
'getCodeDslByIds',
|
|
||||||
'getCurrentDsl',
|
|
||||||
'setCodeDslById',
|
'setCodeDslById',
|
||||||
'setCodeEditorShowStatus',
|
'setCodeEditorShowStatus',
|
||||||
'setEditStatus',
|
'setEditStatus',
|
||||||
@ -77,9 +74,9 @@ class CodeBlock extends BaseService {
|
|||||||
* @param {Id} id 代码块id
|
* @param {Id} id 代码块id
|
||||||
* @returns {CodeBlockContent | null}
|
* @returns {CodeBlockContent | null}
|
||||||
*/
|
*/
|
||||||
public async getCodeContentById(id: Id): Promise<CodeBlockContent | null> {
|
public getCodeContentById(id: Id): CodeBlockContent | null {
|
||||||
if (!id) return null;
|
if (!id) return null;
|
||||||
const totalCodeDsl = await this.getCodeDsl();
|
const totalCodeDsl = this.getCodeDsl();
|
||||||
if (!totalCodeDsl) return null;
|
if (!totalCodeDsl) return null;
|
||||||
return totalCodeDsl[id] ?? null;
|
return totalCodeDsl[id] ?? null;
|
||||||
}
|
}
|
||||||
@ -91,7 +88,7 @@ class CodeBlock extends BaseService {
|
|||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
public async setCodeDslById(id: Id, codeConfig: CodeBlockContent): Promise<void> {
|
public async setCodeDslById(id: Id, codeConfig: CodeBlockContent): Promise<void> {
|
||||||
const codeDsl = await this.getCodeDsl();
|
const codeDsl = this.getCodeDsl();
|
||||||
|
|
||||||
if (!codeDsl) {
|
if (!codeDsl) {
|
||||||
throw new Error('dsl中没有codeBlocks');
|
throw new Error('dsl中没有codeBlocks');
|
||||||
@ -119,8 +116,8 @@ class CodeBlock extends BaseService {
|
|||||||
* @param {string[]} ids 代码块id数组
|
* @param {string[]} ids 代码块id数组
|
||||||
* @returns {CodeBlockDSL}
|
* @returns {CodeBlockDSL}
|
||||||
*/
|
*/
|
||||||
public async getCodeDslByIds(ids: string[]): Promise<CodeBlockDSL> {
|
public getCodeDslByIds(ids: string[]): CodeBlockDSL {
|
||||||
const codeDsl = await this.getCodeDsl();
|
const codeDsl = this.getCodeDsl();
|
||||||
return pick(codeDsl, ids) as CodeBlockDSL;
|
return pick(codeDsl, ids) as CodeBlockDSL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,8 +154,8 @@ class CodeBlock extends BaseService {
|
|||||||
* 获取当前选中的代码块内容
|
* 获取当前选中的代码块内容
|
||||||
* @returns {CodeBlockContent | null}
|
* @returns {CodeBlockContent | null}
|
||||||
*/
|
*/
|
||||||
public async getCurrentDsl(): Promise<CodeBlockContent | null> {
|
public getCurrentDsl(): CodeBlockContent | null {
|
||||||
return await this.getCodeContentById(this.state.id);
|
return this.getCodeContentById(this.state.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user