mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2025-08-06 05:46:28 +00:00
Register ribbon icon during onLoad
This commit is contained in:
16
src/main.ts
16
src/main.ts
@@ -199,7 +199,6 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
//if set, the next time this file is opened it will be opened as markdown
|
||||
public forceToOpenInMarkdownFilepath: string = null;
|
||||
//private slob:string;
|
||||
private ribbonIcon:HTMLElement;
|
||||
public loadTimestamp:number;
|
||||
private isLocalCJKFontAvailabe:boolean = undefined
|
||||
public isReady = false;
|
||||
@@ -365,6 +364,11 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
//Compatibility mode with .excalidraw files
|
||||
this.registerExtensions(["excalidraw"], VIEW_TYPE_EXCALIDRAW);
|
||||
|
||||
addIcon(ICON_NAME, EXCALIDRAW_ICON);
|
||||
addIcon(SCRIPTENGINE_ICON_NAME, SCRIPTENGINE_ICON);
|
||||
addIcon(EXPORT_IMG_ICON_NAME, EXPORT_IMG_ICON);
|
||||
this.addRibbonIcon(ICON_NAME, t("CREATE_NEW"), this.actionRibbonClick.bind(this));
|
||||
|
||||
try {
|
||||
await this.loadSettings({reEnableAutosave:true});
|
||||
const updateSettings = !this.settings.onceOffCompressFlagReset || !this.settings.onceOffGPTVersionReset;
|
||||
@@ -421,9 +425,6 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
}
|
||||
|
||||
this.loadTimestamp = Date.now();
|
||||
addIcon(ICON_NAME, EXCALIDRAW_ICON);
|
||||
addIcon(SCRIPTENGINE_ICON_NAME, SCRIPTENGINE_ICON);
|
||||
addIcon(EXPORT_IMG_ICON_NAME, EXPORT_IMG_ICON);
|
||||
|
||||
try {
|
||||
this.excalidrawConfig = new ExcalidrawConfig(this);
|
||||
@@ -1083,8 +1084,6 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
this.importSVGDialog = new ImportSVGDialog(this);
|
||||
this.insertMDDialog = new InsertMDDialog(this);
|
||||
|
||||
this.ribbonIcon = this.addRibbonIcon(ICON_NAME, t("CREATE_NEW"), this.actionRibbonClick.bind(this));
|
||||
|
||||
const createNewAction = (e: MouseEvent | KeyboardEvent, file: TFile) => {
|
||||
let folderpath = file.path;
|
||||
if (file instanceof TFile) {
|
||||
@@ -3496,11 +3495,6 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
window.clearTimeout(versionUpdateCheckTimer);
|
||||
}
|
||||
|
||||
if(this.ribbonIcon) {
|
||||
this.ribbonIcon.remove();
|
||||
this.ribbonIcon = null;
|
||||
}
|
||||
|
||||
if(this.scriptEngine) {
|
||||
this.scriptEngine.destroy();
|
||||
this.scriptEngine = null;
|
||||
|
||||
Reference in New Issue
Block a user