mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2025-08-06 05:46:28 +00:00
1.1.6
This commit is contained in:
@@ -55,6 +55,9 @@ Part 6: Intro to Obsidian-Excalidraw: Embedding drawings (2:08)
|
||||
|
||||
# Release Notes
|
||||
|
||||
## 1.1.6
|
||||
[](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
|
||||
[](https://youtu.be/W7pWXGIe4rQ)
|
||||
|
||||
## 1.0.8 and 1.0.9 (minor fixes) update
|
||||
## 1.0.8 and 1.0.9 (minor fixes)
|
||||
[](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.
|
||||

|
||||
|
||||
## 1.0.6 and 1.0.7 update
|
||||
## 1.0.6 and 1.0.7
|
||||
[](https://youtu.be/ipZPbcP2B0M)
|
||||
|
||||
### SVG styling when embedding
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"1.1.5": "0.11.13"
|
||||
"1.1.6": "0.11.13"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user