This commit is contained in:
Zsolt Viczian
2022-08-14 21:17:45 +02:00
parent 38add10053
commit 32319b2f6c
8 changed files with 70 additions and 18 deletions

View File

@@ -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",

View File

@@ -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) {

View File

@@ -17,6 +17,15 @@ I develop this plugin as a hobby, spending most of my free time doing this. If y
<div class="ex-coffee-div"><a href="https://ko-fi.com/zsolt"><img src="https://cdn.ko-fi.com/cdn/kofi3.png?v=3" height=45></a></div>
`,
"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))

View File

@@ -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();
}

View File

@@ -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"),

View File

@@ -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

View File

@@ -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 {

View File

@@ -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",