update index.ts

This commit is contained in:
frostime 2023-09-16 16:21:00 +08:00
parent 57e50e1ca8
commit 2fa17e4a7b

View file

@ -11,7 +11,7 @@ import {
IModel, IModel,
Setting, Setting,
fetchPost, fetchPost,
Protyle Protyle, openWindow
} from "siyuan"; } from "siyuan";
import "@/index.scss"; import "@/index.scss";
@ -105,7 +105,7 @@ export default class PluginSample extends Plugin {
this.addCommand({ this.addCommand({
langKey: "showDialog", langKey: "showDialog",
hotkey: "⇧⌘M", hotkey: "⇧⌘O",
callback: () => { callback: () => {
this.showDialog(); this.showDialog();
}, },
@ -119,6 +119,13 @@ export default class PluginSample extends Plugin {
console.log(element, "dockCallback"); console.log(element, "dockCallback");
}, },
}); });
this.addCommand({
langKey: "getTab",
hotkey: "⇧⌘M",
globalCallback: () => {
console.log(this.getOpenedTab());
},
});
this.addDock({ this.addDock({
config: { config: {
@ -267,7 +274,7 @@ export default class PluginSample extends Plugin {
}); });
if (!this.isMobile) { if (!this.isMobile) {
menu.addItem({ menu.addItem({
icon: "iconLayoutBottom", icon: "iconFace",
label: "Open Custom Tab", label: "Open Custom Tab",
click: () => { click: () => {
const tab = openTab({ const tab = openTab({
@ -278,14 +285,14 @@ export default class PluginSample extends Plugin {
data: { data: {
text: "This is my custom tab", text: "This is my custom tab",
}, },
fn: this.customTab id: this.name + TAB_TYPE
}, },
}); });
console.log(tab); console.log(tab);
} }
}); });
menu.addItem({ menu.addItem({
icon: "iconLayoutBottom", icon: "iconImage",
label: "Open Asset Tab(open help first)", label: "Open Asset Tab(open help first)",
click: () => { click: () => {
const tab = openTab({ const tab = openTab({
@ -298,7 +305,7 @@ export default class PluginSample extends Plugin {
} }
}); });
menu.addItem({ menu.addItem({
icon: "iconLayoutBottom", icon: "iconFile",
label: "Open Doc Tab(open help first)", label: "Open Doc Tab(open help first)",
click: async () => { click: async () => {
const tab = await openTab({ const tab = await openTab({
@ -311,7 +318,7 @@ export default class PluginSample extends Plugin {
} }
}); });
menu.addItem({ menu.addItem({
icon: "iconLayoutBottom", icon: "iconSearch",
label: "Open Search Tab", label: "Open Search Tab",
click: () => { click: () => {
const tab = openTab({ const tab = openTab({
@ -324,7 +331,7 @@ export default class PluginSample extends Plugin {
} }
}); });
menu.addItem({ menu.addItem({
icon: "iconLayoutBottom", icon: "iconRiffCard",
label: "Open Card Tab", label: "Open Card Tab",
click: () => { click: () => {
const tab = openTab({ const tab = openTab({
@ -348,6 +355,15 @@ export default class PluginSample extends Plugin {
}); });
} }
}); });
menu.addItem({
icon: "iconOpenWindow",
label: "Open Doc Window(open help first)",
click: () => {
openWindow({
doc: {id: "20200812220555-lj3enxa"}
});
}
});
} }
menu.addItem({ menu.addItem({
icon: "iconScrollHoriz", icon: "iconScrollHoriz",
@ -431,6 +447,30 @@ export default class PluginSample extends Plugin {
click: () => { click: () => {
this.eventBus.on("loaded-protyle", this.eventBusLog); this.eventBus.on("loaded-protyle", this.eventBusLog);
} }
}, {
icon: "iconSelect",
label: "On loaded-protyle-dynamic",
click: () => {
this.eventBus.on("loaded-protyle-dynamic", this.eventBusLog);
}
}, {
icon: "iconClose",
label: "Off loaded-protyle-dynamic",
click: () => {
this.eventBus.off("loaded-protyle-dynamic", this.eventBusLog);
}
}, {
icon: "iconSelect",
label: "On destroy-protyle",
click: () => {
this.eventBus.on("destroy-protyle", this.eventBusLog);
}
}, {
icon: "iconClose",
label: "Off destroy-protyle",
click: () => {
this.eventBus.off("destroy-protyle", this.eventBusLog);
}
}, { }, {
icon: "iconClose", icon: "iconClose",
label: "Off loaded-protyle", label: "Off loaded-protyle",