mirror of
https://github.com/waiting0324/obsidian-code-note.git
synced 2026-07-22 07:30:24 +00:00
35 lines
714 B
TypeScript
35 lines
714 B
TypeScript
import {ItemView, View, WorkspaceLeaf} from "obsidian";
|
|
import {indexInit} from "./index";
|
|
import {SOURCE_CODE_VIEW_TYPE} from "./main";
|
|
|
|
export default class SourceCodeView extends ItemView {
|
|
|
|
codeBlocks: string[]
|
|
|
|
constructor(codeBlocks: string[], leaf: WorkspaceLeaf) {
|
|
super(leaf);
|
|
this.codeBlocks = codeBlocks;
|
|
}
|
|
|
|
getDisplayText(): string {
|
|
return "MySourceCodeView";
|
|
}
|
|
|
|
getViewType(): string {
|
|
return SOURCE_CODE_VIEW_TYPE;
|
|
}
|
|
|
|
async onOpen() {
|
|
const container = this.containerEl.children[1];
|
|
container.empty();
|
|
const div = document.createElement("div")
|
|
div.id = 'container';
|
|
this.containerEl.children[1].appendChild(div);
|
|
|
|
indexInit(this.codeBlocks);
|
|
}
|
|
|
|
async onClose() {
|
|
}
|
|
|
|
}
|