diff --git a/manifest.json b/manifest.json index 0dde374..608081f 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "1.7.12", + "version": "1.7.13", "minAppVersion": "0.15.6", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/src/ExcalidrawView.ts b/src/ExcalidrawView.ts index f0a7a5f..b38586b 100644 --- a/src/ExcalidrawView.ts +++ b/src/ExcalidrawView.ts @@ -1796,6 +1796,17 @@ export default class ExcalidrawView extends TextFileView { } onPaneMenu(menu: Menu, source: string): void { + if(this.excalidrawAPI && this.getViewSelectedElements().some(el=>el.type==="text")) { + menu.addItem(item => { + item + .setTitle(t("OPEN_LINK")) + .setIcon("external-link") + .setSection("pane") + .onClick(evt => { + this.handleLinkClick(this, evt as MouseEvent); + }); + }) + } // Add a menu item to force the board to markdown view if (!this.compatibilityMode) { menu @@ -1878,7 +1889,15 @@ export default class ExcalidrawView extends TextFileView { this.saveSVG(); }); }) - .addSeparator(); + .addItem(item => { + item + .setTitle(t("INSTALL_SCRIPT_BUTTON")) + .setIcon(SCRIPTENGINE_ICON_NAME) + .setSection("pane") + .onClick(()=>{ + new ScriptInstallPrompt(this.plugin).open(); + }) + }) super.onPaneMenu(menu, source); } @@ -3323,7 +3342,7 @@ export default class ExcalidrawView extends TextFileView { public getViewSelectedElements(): ExcalidrawElement[] { const api = this.excalidrawAPI; if (!api) { - return; + return []; } const selectedElements = api.getAppState()?.selectedElementIds; if (!selectedElements) { diff --git a/src/dialogs/Messages.ts b/src/dialogs/Messages.ts index e984ea5..81f1772 100644 --- a/src/dialogs/Messages.ts +++ b/src/dialogs/Messages.ts @@ -17,6 +17,15 @@ I develop this plugin as a hobby, spending most of my free time doing this. If y
`, +"1.7.13": ` +## Fix from Excalidraw.com +- Resize multiple elements from center ([#5560](https://github.com/excalidraw/excalidraw/pull/5560)) + +## Obsidian 0.16.0 compatibility (getting ready, because 0.16.0 will be available to insiders soon) +- ${String.fromCharCode(96)}Install or update Excalidraw Scripts${String.fromCharCode(96)} was only available via the page header button. Because the page header is hidden by default, the install script action is now available through the pane menu and through the command palette as well. +- ${String.fromCharCode(96)}Open selected text as link${String.fromCharCode(96)} page header button is now also available via the pane menu +- ${String.fromCharCode(96)}Open in Adjacent Pane${String.fromCharCode(96)} and ${String.fromCharCode(96)}Open in Main Workspace${String.fromCharCode(96)} Excalidraw plugin settings is fixed +`, "1.7.12": ` # New from Excalidraw.com: - Showing a mid-point for lines and arrows. By touching the mid-point you can easily add an additional point to a two-point line. This is especially helpful when working on a tablet with touch input. ([#5534](https://github.com/excalidraw/excalidraw/pull/5534)) diff --git a/src/dialogs/ReleaseNotes.ts b/src/dialogs/ReleaseNotes.ts index 187c520..6c31a19 100644 --- a/src/dialogs/ReleaseNotes.ts +++ b/src/dialogs/ReleaseNotes.ts @@ -16,8 +16,8 @@ export class ReleaseNotes extends Modal { } onOpen(): void { - this.contentEl.classList.add("excalidraw-release"); - this.containerEl.classList.add(".excalidraw-release"); + //this.contentEl.classList.add("excalidraw-release"); + this.containerEl.classList.add("excalidraw-release"); this.titleEl.setText(`Welcome to Excalidraw ${this.version ?? ""}`); this.createForm(); } diff --git a/src/main.ts b/src/main.ts index dd5e13b..1576dbc 100644 --- a/src/main.ts +++ b/src/main.ts @@ -100,6 +100,7 @@ import { ReleaseNotes } from "./dialogs/ReleaseNotes"; import { decompressFromBase64 } from "lz-string"; import { Packages } from "./types"; import * as React from "react"; +import { ScriptInstallPrompt } from "./dialogs/ScriptInstallPrompt"; declare module "obsidian" { @@ -974,6 +975,20 @@ export default class ExcalidrawPlugin extends Plugin { }, }); + this.addCommand({ + id: "scriptengine-store", + name: t("INSTALL_SCRIPT_BUTTON"), + checkCallback: (checking: boolean) => { + if (checking) { + return ( + Boolean(this.app.workspace.getActiveViewOfType(ExcalidrawView)) + ); + } + new ScriptInstallPrompt(this).open(); + return true; + }, + }); + this.addCommand({ id: "delete-file", name: t("DELETE_FILE"), diff --git a/src/utils/ObsidianUtils.ts b/src/utils/ObsidianUtils.ts index fd8f3df..152b0cc 100644 --- a/src/utils/ObsidianUtils.ts +++ b/src/utils/ObsidianUtils.ts @@ -36,14 +36,22 @@ export const getNewOrAdjacentLeaf = ( //@ts-ignore const leafId = leaf.id; const layout = app.workspace.getLayout(); + const getLeaves = (l:any)=> l.children + .filter((c:any)=>c.type!=="leaf") + .map((c:any)=>getLeaves(c)) + .flat() + .concat(l.children.filter((c:any)=>c.type==="leaf").map((c:any)=>c.id)) + + const mainLeavesIds = getLeaves(layout.main); + const leafLoc = - layout.main && layout.main.children.filter((x:any)=>x.type==="leaf" && x.id ===leafId).length > 0 + layout.main && mainLeavesIds.contains(leafId) ? "main" - : layout.floating && layout.floating.children.filter((x:any)=>x.type==="leaf" && x.id ===leafId).length > 0 + : layout.floating && getLeaves(layout.floating).contains(leafId) ? "popout" - : layout.left && layout.left.children.filter((x:any)=>x.type==="leaf" && x.id ===leafId).length > 0 + : layout.left && getLeaves(layout.left).contains(leafId) ? "left" - : layout.right && layout.right.children.filter((x:any)=>x.type==="leaf" && x.id ===leafId).length > 0 + : layout.right && getLeaves(layout.right).contains(leafId) ? "right" : "hover"; @@ -53,10 +61,9 @@ export const getNewOrAdjacentLeaf = ( return mainLeaf; } mainLeaf = null; - app.workspace.getLayout().main.children - .filter((child:any)=>child.type==="leaf") - .forEach((listItem:any)=> { - const l = app.workspace.getLeafById(listItem.id); + mainLeavesIds + .forEach((id:any)=> { + const l = app.workspace.getLeafById(id); if(mainLeaf || !l.view?.navigation || leaf === l diff --git a/styles.css b/styles.css index 6a5c449..13eda74 100644 --- a/styles.css +++ b/styles.css @@ -127,13 +127,14 @@ li[data-testid] { width: 100%; } -.modal-content.excalidraw-scriptengine-install { +.excalidraw-scriptengine-install .modal-content { max-width: 130ch; user-select: text; } .excalidraw-scriptengine-install .modal { max-height:90%; + width: auto; } .excalidraw-prompt-center { @@ -172,15 +173,16 @@ li[data-testid] { height: 100%; } -.excalidraw-release { +.excalidraw-release .modal-content{ padding-right: 5px; margin-right: -5px; - max-width: 130ch; user-select: text; } .excalidraw-release .modal { - max-height:90%; + max-height: 90%; + width: auto; + max-width: 130ch; } .excalidraw .Island .scrollbar { diff --git a/versions.json b/versions.json index 5e38eb2..af0b51e 100644 --- a/versions.json +++ b/versions.json @@ -1,5 +1,5 @@ { - "1.7.12": "0.15.6", + "1.7.13": "0.15.6", "1.7.8": "0.15.5", "1.7.7": "0.15.4", "1.7.6": "0.15.3",