This commit is contained in:
Zsolt Viczian
2021-05-06 23:15:07 +02:00
parent 660f6e03b1
commit c962168c52
3 changed files with 15 additions and 2 deletions

View File

@@ -3,7 +3,7 @@ import {
WorkspaceLeaf,
normalizePath,
TFile,
Menu,
WorkspaceItem
} from "obsidian";
import * as React from "react";
import * as ReactDOM from "react-dom";
@@ -26,6 +26,10 @@ import {
} from './constants';
import ExcalidrawPlugin from './main';
interface WorkspaceItemExt extends WorkspaceItem {
containerEl: HTMLElement;
}
export interface ExportSettings {
withBackground: boolean,
withTheme: boolean
@@ -107,6 +111,11 @@ export default class ExcalidrawView extends TextFileView {
});
this.addAction(PNG_ICON_NAME,"Export as PNG",async (ev)=>this.savePNG());
this.addAction(SVG_ICON_NAME,"Export as SVG",async (ev)=>this.saveSVG());
if (this.app.workspace.layoutReady) {
(this.app.workspace.rootSplit as WorkspaceItem as WorkspaceItemExt).containerEl.addEventListener('scroll',(e)=>{if(this.refresh) this.refresh();});
} else {
this.registerEvent(this.app.workspace.on('layout-ready', async () => (this.app.workspace.rootSplit as WorkspaceItem as WorkspaceItemExt).containerEl.addEventListener('scroll',(e)=>{if(this.refresh) this.refresh();})));
}
}
//save current drawing when user closes workspace leaf

View File

@@ -185,7 +185,7 @@ export default class ExcalidrawPlugin extends Plugin {
item.setTitle("Create Excalidraw drawing")
.setIcon(ICON_NAME)
.onClick(evt => {
this.createDrawing(file.path+this.getNextDefaultFilename(),false,file.path);
this.createDrawing(this.getNextDefaultFilename(),false,file.path);
})
});
}

View File

@@ -37,4 +37,8 @@ div.excalidraw-svg-right {
div.excalidraw-svg-left {
text-align: left;
}
button.ToolIcon_type_button[title="Export"] {
display:none;
}