diff --git a/src/SourceCodeView.ts b/src/SourceCodeView.ts index 3dcfce2..c63649b 100644 --- a/src/SourceCodeView.ts +++ b/src/SourceCodeView.ts @@ -1,9 +1,10 @@ -import {ItemView, View, WorkspaceLeaf} from "obsidian"; +import {ItemView, WorkspaceLeaf} from "obsidian"; import {initGraph} from "./Graph"; import {SOURCE_CODE_VIEW_TYPE} from "./main"; export default class SourceCodeView extends ItemView { + // 代碼塊內容 集合 codeBlocks: string[] constructor(codeBlocks: string[], leaf: WorkspaceLeaf) { @@ -12,7 +13,7 @@ export default class SourceCodeView extends ItemView { } getDisplayText(): string { - return "MySourceCodeView"; + return "Source Code View"; } getViewType(): string { @@ -20,12 +21,17 @@ export default class SourceCodeView extends ItemView { } async onOpen() { + + // 清空 容器內容 const container = this.containerEl.children[1]; container.empty(); + + // 創建 AntV 需要的容器 const div = document.createElement("div") div.id = 'container'; - this.containerEl.children[1].appendChild(div); + container.appendChild(div); + // 初始化 AntV 的 畫布 initGraph(this.codeBlocks); } diff --git a/src/main.ts b/src/main.ts index 697645b..f325a82 100644 --- a/src/main.ts +++ b/src/main.ts @@ -20,7 +20,7 @@ export default class SourceCodeViewPlugin extends Plugin { ); // 註冊 Obsidian 左側的按鈕 - this.addRibbonIcon("dice", "Activate view", () => { + this.addRibbonIcon("file-json", "Show Resource Code View", () => { this.initView() }); }