MCPcopy Create free account
hub / github.com/CatMuse/HiNote / openCommentPanelInSidebar

Method openCommentPanelInSidebar

src/plugin/WindowManager.ts:16–66  ·  view source on GitHub ↗

* 在右侧侧边栏打开评论面板 * 如果面板已在主视图中打开,则移动到侧边栏

()

Source from the content-addressed store, hash-verified

14 * 如果面板已在主视图中打开,则移动到侧边栏
15 */
16 async openCommentPanelInSidebar(): Promise<void> {
17 const { workspace } = this.app;
18
19 // 检查评论面板是否已经打开
20 const existing = workspace.getLeavesOfType(VIEW_TYPE_HINOTE);
21 if (existing.length) {
22 // 如果已经打开,先检查当前视图是否在主视图区域
23 const existingLeaf = existing[0];
24 const view = existingLeaf.view;
25
26 // 如果在主视图区域,则移动到右侧侧边栏
27 if (view && view instanceof HiNoteView && view.isInMainWindowMode()) {
28 // 先分离当前叶子
29 workspace.detachLeavesOfType(VIEW_TYPE_HINOTE);
30
31 // 然后在右侧侧边栏创建新的叶子
32 const newLeaf = workspace.getRightLeaf(false);
33 if (newLeaf) {
34 await newLeaf.setViewState({
35 type: VIEW_TYPE_HINOTE,
36 active: true,
37 });
38
39 // 将视图标记为侧边栏模式
40 const newView = newLeaf.view;
41 if (newView && newView instanceof HiNoteView) {
42 await newView.setMainWindowMode(false, true);
43 }
44 }
45 } else {
46 // 如果已经在侧边栏,则直接激活它
47 await workspace.revealLeaf(existingLeaf);
48 }
49 return;
50 }
51
52 // 如果评论面板未打开,则在右侧打开评论面板
53 const leaf = workspace.getRightLeaf(false);
54 if (leaf) {
55 await leaf.setViewState({
56 type: VIEW_TYPE_HINOTE,
57 active: true,
58 });
59
60 // 确保视图标记为侧边栏模式
61 const view = leaf.view;
62 if (view && view instanceof HiNoteView) {
63 await view.setMainWindowMode(false);
64 }
65 }
66 }
67
68 /**
69 * 在主窗口打开评论面板

Callers 2

registerPluginRibbonFunction · 0.80
openCommentPanelFunction · 0.80

Calls 2

isInMainWindowModeMethod · 0.80
setMainWindowModeMethod · 0.80

Tested by

no test coverage detected