Home > LIB_Cbb > openSymbolInEditor
LIB_Cbb.openSymbolInEditor() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
在编辑器打开复用模块符号
签名
typescript
function openSymbolInEditor(
cbbUuid: string,
libraryUuid: string,
splitScreenId?: string,
): Promise<string | undefined>;1
2
3
4
5
2
3
4
5
参数名
参数 | 类型 | 描述 |
|---|---|---|
cbbUuid | string | 复用模块 UUID |
libraryUuid | string | 库 UUID,可以使用 LIB_LibrariesList 内的接口获取 |
splitScreenId | string | (可选) 分屏 ID,不填写则默认在最后输入焦点的分屏内打开,可以使用 DMT_EditorControl 内的接口获取 |
返回值
Promise<string | undefined>
标签页 ID,对应 IDMT_EditorTabItem.tabId,可使用 DMT_EditorControl.getSplitScreenIdByTabId() 获取到分屏 ID
示例
javascript
// 1. 记录当前工程,便于演示结束后恢复
const projectInfo = await eda.dmt_Project.getCurrentProjectInfo();
// 2. 复制一个系统库模块到个人库作为演示对象
const systemLib = await eda.lib_LibrariesList.getSystemLibraryUuid();
const personalLib = await eda.lib_LibrariesList.getPersonalLibraryUuid();
const results = await eda.lib_Cbb.search('', systemLib, undefined, 1);
const source = results[0];
const cbbUuid = await eda.lib_Cbb.copy(source.uuid, systemLib, personalLib, [], `嘉立创示例_打开符号_${Date.now()}`);
// 3. 先打开模块工程(openSymbolInEditor 的前置条件)
await eda.lib_Cbb.openProjectInEditor(cbbUuid, personalLib);
await new Promise(r => setTimeout(r, 1000));
// 4. 在编辑器打开模块符号,返回标签页 ID
const tabId = await eda.lib_Cbb.openSymbolInEditor(cbbUuid, personalLib);
// 5. 恢复原来打开的工程
await eda.dmt_Project.openProject(projectInfo.uuid);
console.log('source:', source.name, source.uuid);
console.log('tabId:', tabId);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22