Home > DMT_EditorControl > createSplitScreen
DMT_EditorControl.createSplitScreen() method
创建分屏
签名
typescript
function createSplitScreen(
splitScreenType: EDMT_EditorSplitScreenDirection,
tabId: string,
): Promise<{ sourceSplitScreenId: string; newSplitScreenId: string } | undefined>;1
2
3
4
2
3
4
参数名
参数 | 类型 | 描述 |
|---|---|---|
splitScreenType | 分屏类型, | |
tabId | string | 标签页 ID,该标签页将会被移入新的分屏中 |
返回值
Promise<{ sourceSplitScreenId: string; newSplitScreenId: string } | undefined>
分屏 ID,sourceSplitScreenId 代表源分屏,newSplitScreenId 代表新分屏
备注
请确认 tabId 对应的分屏存在两个以上的标签页,否则分屏将不会执行,并返回 undefined
示例
javascript
// 1. 归一化布局:先合并既有分屏,保证两个标签页落在同一分屏
await eda.dmt_EditorControl.mergeAllDocumentFromSplitScreen();
// 2. 打开两个文档,让当前分屏持有两个标签页
const pages = await eda.dmt_Schematic.getAllSchematicPagesInfo();
const pcbs = await eda.dmt_Pcb.getAllPcbsInfo();
await eda.dmt_EditorControl.openDocument(pages[0].uuid);
const tabPcb = await eda.dmt_EditorControl.openDocument(pcbs[0].uuid);
// 3. 把 PCB 标签页拆到一个新的水平分屏
const split = await eda.dmt_EditorControl.createSplitScreen('horizontal', tabPcb);
console.log('source split:', split?.sourceSplitScreenId);
console.log('new split:', split?.newSplitScreenId);
// 4. 回读新分屏的标签页,确认 PCB 已在其中
const tabs = await eda.dmt_EditorControl.getTabsBySplitScreenId(split.newSplitScreenId);
console.log('tabs in new split:', tabs.map(t => t.title));
// 5. 合并所有分屏,恢复单屏布局
const merged = await eda.dmt_EditorControl.mergeAllDocumentFromSplitScreen();
console.log('merged:', merged);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21