Hi all, I do a plugin and I have an issue with the escape touch.Everytime it’s tape, obsidian change leaf/tab.
For example , I took the code from the api (same issue than in my plugin but simpler to underxtand). I just change vgetLeaf.
Here the plugin. It create a new leaf and show. BUT when I tape the esc touch, he change leaf (change tab…)
I have the same behavior in my plugin and don’t understand why; The thing is that I need the escape touch (to excape suggessionbox, and everytime, obsidian change leaf and goes to another tab. anyidea ?
to reproduce:
(after created the pklugn )
- a md file as normal
- click on the dice → open a tab with example view.
- tape escape. → goes to the md file tab…
What is the best and simple way to open registerfile (balbal.xxx) as it’s done for md file and so on?
thanks a lot for you help.
import { Plugin } from "obsidian";
export default class ExamplePlugin extends Plugin {
async onload() {
this.registerView(
VIEW_TYPE_EXAMPLE,
(leaf) => new ExampleView(leaf)
);
this.addRibbonIcon("dice", "Activate view", () => {
this.activateView();
});
}
async onunload() {
this.app.workspace.detachLeavesOfType(VIEW_TYPE_EXAMPLE);
}
async activateView() {
this.app.workspace.detachLeavesOfType(VIEW_TYPE_EXAMPLE);
await this.app.workspace.getLeaf(false).setViewState({
type: VIEW_TYPE_EXAMPLE,
active: true,
});
this.app.workspace.revealLeaf(
this.app.workspace.getLeavesOfType(VIEW_TYPE_EXAMPLE)[0]
);
}
}
import { ItemView, WorkspaceLeaf } from "obsidian";
export const VIEW_TYPE_EXAMPLE = "example-view";
export class ExampleView extends ItemView {
constructor(leaf: WorkspaceLeaf) {
super(leaf);
}
getViewType() {
return VIEW_TYPE_EXAMPLE;
}
getDisplayText() {
return "Example view";
}
async onOpen() {
const container = this.containerEl.children[1];
container.empty();
container.createEl("h4", { text: "Example view" });
}
async onClose() {
// Nothing to clean up.
}
}