This commit is contained in:
Zsolt Viczian
2021-09-10 16:16:13 +02:00
parent 5c2c1ebf5e
commit e8666797d7
6 changed files with 26 additions and 10 deletions

View File

@@ -53,7 +53,7 @@ setView(view:ExcalidrawView|"first"|"active"):ExcalidrawView;
getExcalidrawAPI():any;
getViewSelectedElement():ExcalidrawElement;
getViewSelectedElements():ExcalidrawElement[];
viewToggleFullScreen():void;
viewToggleFullScreen(forceViewMode?:boolean):void;
connectObjectWithViewSelectedElement(objectA:string,connectionA: ConnectionPoint, connectionB: ConnectionPoint, formatting?:{numberOfPoints?: number,startArrowHead?:string,endArrowHead?:string, padding?: number}):boolean;
addElementsToView(repositionToCursor:boolean, save:boolean):Promise<boolean>;
};

View File

@@ -117,10 +117,12 @@ Note: you can call `getExcalidrawAPI().getSceneElements()` to retreive all the e
#### viewToggleFullScreen()
```typescript
viewToggleFullScreen():void
viewToggleFullScreen(forceViewMode?:boolean):void;
```
Toggles targetView between fullscreen mode and normal mode.
Toggles targetView between fullscreen mode and normal mode. By setting forceViewMode to `true` will change Excalidraw mode to View mode. Default is `false`.
The function will do nothing on Obsidian Mobile.
#### connectObjectWithViewSelectedElement()
```typescript

View File

@@ -1,7 +1,7 @@
{
"id": "obsidian-excalidraw-plugin",
"name": "Excalidraw",
"version": "1.3.4",
"version": "1.3.5",
"minAppVersion": "0.12.0",
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
"author": "Zsolt Viczian",

View File

@@ -72,7 +72,7 @@ export interface ExcalidrawAutomate extends Window {
getExcalidrawAPI():any;
getViewSelectedElement():ExcalidrawElement;
getViewSelectedElements():ExcalidrawElement[];
viewToggleFullScreen():void;
viewToggleFullScreen(forceViewMode?:boolean):void;
connectObjectWithViewSelectedElement(objectA:string,connectionA: ConnectionPoint, connectionB: ConnectionPoint, formatting?:{numberOfPoints?: number,startArrowHead?:string,endArrowHead?:string, padding?: number}):boolean;
addElementsToView(repositionToCursor:boolean, save:boolean):Promise<boolean>;
};
@@ -448,15 +448,26 @@ export async function initExcalidrawAutomate(plugin: ExcalidrawPlugin) {
if(!selectedElementsKeys) return [];
return current.getSceneElements().filter((e:any)=>selectedElementsKeys.includes(e.id));
},
viewToggleFullScreen():void {
viewToggleFullScreen(forceViewMode:boolean = false):void {
if (this.plugin.app.isMobile) {
errorMessage("mobile not supported", "viewToggleFullScreen()");
return;
}
if (!this.targetView || !this.targetView?._loaded) {
errorMessage("targetView not set");
errorMessage("targetView not set", "viewToggleFullScreen()");
return;
}
}
if(forceViewMode){
const ref = this.getExcalidrawAPI();
ref.updateScene({
elements: ref.getSceneElements(),
appState: {
viewModeEnabled: true,
... ref.appState,
},
commitToHistory: false,
});
}
if(document.fullscreenElement === (this.targetView as ExcalidrawView).contentEl) {
document.exitFullscreen();
} else {

View File

@@ -111,7 +111,10 @@ export default class ExcalidrawPlugin extends Plugin {
//https://github.com/mgmeyers/obsidian-kanban/blob/44118e25661bff9ebfe54f71ae33805dc88ffa53/src/main.ts#L267
this.registerMonkeyPatches();
if(this.settings.loadCount<1) this.migrationNotice();
const electron:string = process.versions.electron;
if(electron.startsWith("8.")) {
new Notice(`You are running an older version of the electron Browser (${electron}). If Excalidraw does not start up, please reinstall Obsidian with the latest installer and try again.`,10000);
}
}
private migrationNotice(){

View File

@@ -1,3 +1,3 @@
{
"1.3.4": "0.11.13"
"1.3.5": "0.11.13"
}