habitica-sync/old_view.ts

34 lines
748 B
TypeScript
Raw Normal View History

2021-10-03 18:10:16 +05:30
import { ItemView,WorkspaceLeaf } from "obsidian";
2021-10-08 10:23:06 +05:30
import * as React from "react";
import * as ReactDOM from "react-dom";
2021-10-10 21:08:13 -07:00
import ReactView from "./ReactView";
import ExamplePlugin from "main";
2021-10-08 10:23:06 +05:30
2021-10-03 18:10:16 +05:30
export const VIEW_TYPE_EXAMPLE = "example-view"
export class ExampleView extends ItemView {
2021-10-10 21:08:13 -07:00
plugin: ExamplePlugin;
2021-10-03 18:10:16 +05:30
constructor(leaf: WorkspaceLeaf) {
super(leaf)
}
getViewType() {
return VIEW_TYPE_EXAMPLE
}
getDisplayText() {
return "Example View"
}
async onOpen() {
2021-10-08 10:23:06 +05:30
ReactDOM.render(
React.createElement(ReactView),
this.containerEl.children[1]
)
2021-10-03 18:10:16 +05:30
}
2021-10-08 10:23:06 +05:30
2021-10-03 18:10:16 +05:30
async onClose(){
2021-10-08 10:23:06 +05:30
ReactDOM.unmountComponentAtNode(this.containerEl.children[1]);
2021-10-03 18:10:16 +05:30
}
}