This commit is contained in:
Zsolt Viczian
2021-05-25 22:07:19 +02:00
parent caebd71dc8
commit 6174e45c3f
5 changed files with 46 additions and 9 deletions

View File

@@ -55,6 +55,9 @@ Part 6: Intro to Obsidian-Excalidraw: Embedding drawings (2:08)
# Release Notes
## 1.1.6
[![Obsidian-Excalidraw 1.1.6 - Links](https://user-images.githubusercontent.com/14358394/119559279-bdb46580-bda2-11eb-88cb-7614dc452034.jpg)](https://youtu.be/FDsMH-aLw_I)
## 1.1.5
- The template will now restore stroke properties. This means you can set up defaults in your template for stroke color, stroke width, opacity, font family, font size, fill style, stroke style, etc. This also applies to ExcalidrawAutomate.
- Added settings to customize the autogenerated filename
@@ -81,10 +84,10 @@ I have added a Migration command to the Command Palette. When you select this, t
### QoL improvement
- I added an autosave feature. Your active drawing gets saved every 30 seconds if you've made changes to it. Drawings otherwise get saved when the window loses focus, or when you close the drawing, etc. Autosave limits the risk of accidental data loss on mobiles when you "swipe out" Obsidian to close it.
## 1.0.10 update
## 1.0.10
[![Obsidian-Excalidraw 1.0.10 update](https://user-images.githubusercontent.com/14358394/117579017-60a58800-b0f1-11eb-8553-7820964662aa.jpg)](https://youtu.be/W7pWXGIe4rQ)
## 1.0.8 and 1.0.9 (minor fixes) update
## 1.0.8 and 1.0.9 (minor fixes)
[![Obsidian-Excalidraw 1.0.8 update](https://user-images.githubusercontent.com/14358394/117492534-029e6680-af72-11eb-90a3-086e67e70c1c.jpg)](https://youtu.be/AtEhmHJjnxM)
### QoL improvements
@@ -104,7 +107,7 @@ You now have ultimate flexibility over your Excalidraw templates using Templater
- Complex use-case: Create a mindmap from a tabulated outline.
![Drawing 2021-05-05 20 52 34](https://user-images.githubusercontent.com/14358394/117194124-00a69d00-ade4-11eb-8b75-5e18a9cbc3cd.png)
## 1.0.6 and 1.0.7 update
## 1.0.6 and 1.0.7
[![1.0.6 Update](https://user-images.githubusercontent.com/14358394/116312909-58725200-a7ad-11eb-89b9-c67cb48ffebb.jpg)](https://youtu.be/ipZPbcP2B0M)
### SVG styling when embedding

View File

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

View File

@@ -3,7 +3,8 @@ import {
WorkspaceLeaf,
normalizePath,
TFile,
WorkspaceItem
WorkspaceItem,
Notice
} from "obsidian";
import * as React from "react";
import * as ReactDOM from "react-dom";
@@ -38,6 +39,7 @@ export interface ExportSettings {
export default class ExcalidrawView extends TextFileView {
private getScene: Function;
private getSelectedText: Function;
private refresh: Function;
private excalidrawRef: React.MutableRefObject<any>;
private justLoaded: boolean;
@@ -49,6 +51,7 @@ export default class ExcalidrawView extends TextFileView {
constructor(leaf: WorkspaceLeaf, plugin: ExcalidrawPlugin) {
super(leaf);
this.getScene = null;
this.getSelectedText = null;
this.refresh = null;
this.excalidrawRef = null;
this.plugin = plugin;
@@ -122,6 +125,29 @@ 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());
this.addAction("link","Open selected text as link\n(CTRL/META to open in new pane)",(ev)=>{
const text = this.getSelectedText();
if(!text) {
new Notice('Select a text element.\n'+
'If it is a web link, it will open in a new browser window.\n'+
'Else if it is a valid filename Excalidraw will handle it as an Obsidian internal link.\n'+
'Use CTRL+Click to open it in a new pane.',20000);
return;
}
if(text.match(/^\w+:\/\//)) {
window.open(text,"_blank");
return;
}
if(text.match(/[<>:"\\|?*]/g)) {
new Notice('File name cannot contain any of the following characters: * " \\  < > : | ?',4000);
return;
}
try {
this.app.workspace.openLinkText(text,this.file.path,ev.ctrlKey||ev.metaKey);
} catch (e) {
new Notice(e,4000);
}
});
//this is to solve sliding panes bug
if (this.app.workspace.layoutReady) {
(this.app.workspace.rootSplit as WorkspaceItem as WorkspaceItemExt).containerEl.addEventListener('scroll',(e)=>{if(this.refresh) this.refresh();});
@@ -243,6 +269,14 @@ export default class ExcalidrawView extends TextFileView {
return () => window.removeEventListener("resize", onResize);
}, [excalidrawWrapperRef]);
this.getSelectedText = ():string => {
if(!excalidrawRef?.current) return null;
const selectedElement = excalidrawRef.current.getSceneElements().filter((el:any)=>el.id==Object.keys(excalidrawRef.current.getAppState().selectedElementIds)[0]);
if(selectedElement.length==0) return null;
if(selectedElement[0].type != "text") return null;
return selectedElement[0].text;
};
this.getScene = () => {
if(!excalidrawRef?.current) {
return null;

View File

@@ -133,7 +133,7 @@ export default class ExcalidrawPlugin extends Plugin {
if(parts.fheight) img.setAttribute("height",parts.fheight);//img.style.setProperty('height',parts.fheight);
img.addClass(parts.style);
img.setAttribute("src","data:image/svg+xml;base64,"+btoa(svg.outerHTML));
img.setAttribute("src","data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(svg.outerHTML))));
return img;
}
@@ -168,7 +168,7 @@ export default class ExcalidrawPlugin extends Plugin {
el.onClickEvent((ev)=>{
if(ev.target instanceof Element && ev.target.tagName.toLowerCase() != "img") return;
let src = el.getAttribute("src");
if(src) this.openDrawing(this.app.vault.getAbstractFileByPath(src) as TFile,ev.ctrlKey);
if(src) this.openDrawing(this.app.vault.getAbstractFileByPath(src) as TFile,ev.ctrlKey||ev.metaKey);
});
el.addEventListener(RERENDER_EVENT, async(e) => {
e.stopPropagation;
@@ -211,7 +211,7 @@ export default class ExcalidrawPlugin extends Plugin {
this.openDialog = new OpenFileDialog(this.app, this);
this.addRibbonIcon(ICON_NAME, 'Create a new drawing in Excalidraw', async (e) => {
this.createDrawing(this.getNextDefaultFilename(), e.ctrlKey);
this.createDrawing(this.getNextDefaultFilename(), e.ctrlKey||e.metaKey);
});
const fileMenuHandler = (menu: Menu, file: TFile) => {

View File

@@ -1,3 +1,3 @@
{
"1.1.5": "0.11.13"
"1.1.6": "0.11.13"
}