0.18.0-34 (insert image dropdown + new language strings)

This commit is contained in:
zsviczian committed 2025-08-17 15:09:36 +02:00
1 parent a0630b4719
commit 5bf7271f86
8 files changed
+84 -21

No files matched your search

+1 -1
View File
@@ -676,7 +676,7 @@ https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea
```excalidraw-script-install
https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Printable%20Layout%20Wizard.md
```
<table><tr valign='top'><td class="label">Author</td><td class="data"><a href='https://github.com/zsviczian'>@zsviczian</a></td></tr><tr valign='top'><td class="label">Source</td><td class="data"><a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/Printable%20Layout%20Wizard.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">Export Excalidraw to PDF Pages: Define printable page areas using frames, then export each frame as a separate page in a multi-page PDF. Perfect for turning your Excalidraw drawings into printable notes, handouts, or booklets. Supports standard and custom page sizes, margins, and easy frame arrangement.<br><iframe width="400" height="225" src="https://www.youtube.com/embed/29EWeglRm7s" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><br><a href='https://youtu.be/29EWeglRm7s' target='_blank'>Link to video on YouTube</a><br><br><iframe width="400" height="225" src="https://www.youtube.com/embed/DqDnzCOoYMc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><br><a href='https://youtu.be/DqDnzCOoYMc' target='_blank'>Link to video on YouTube</a><br><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-layout-wizard-01.png" style="max-width: 400px;"><br><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-layout-wizard-02.png" style="max-width: 400px;"></td></tr></table>
<table><tr valign='top'><td class="label">Author</td><td class="data"><a href='https://github.com/zsviczian'>@zsviczian</a></td></tr><tr valign='top'><td class="label">Source</td><td class="data"><a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/Printable%20Layout%20Wizard.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">Export Excalidraw to PDF Pages: Define printable page areas using frames, then export each frame as a separate page in a multi-page PDF. Perfect for turning your Excalidraw drawings into printable notes, handouts, or booklets. Supports standard and custom page sizes, margins, and easy frame arrangement.<br><iframe width="400" height="225" src="https://www.youtube.com/embed/29EWeglRm7s" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><br><a href='https://youtu.be/29EWeglRm7s' target='_blank'>Link to video on YouTube</a><br><iframe width="400" height="225" src="https://www.youtube.com/embed/DqDnzCOoYMc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><br><a href='https://youtu.be/DqDnzCOoYMc' target='_blank'>Link to video on YouTube</a><br><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-layout-wizard-01.png" style="max-width: 400px;"><br><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-layout-wizard-02.png" style="max-width: 400px;"></td></tr></table>
## Zoom to Fit Selected Elements
+1 -1
View File
@@ -24,7 +24,7 @@
"license": "MIT",
"dependencies": {
"@popperjs/core": "^2.11.8",
"@zsviczian/excalidraw": "0.18.0-33",
"@zsviczian/excalidraw": "0.18.0-34",
"chroma-js": "^3.1.2",
"clsx": "^2.0.0",
"@zsviczian/colormaster": "^1.2.2",
+34 -1
View File
@@ -40,7 +40,7 @@ import {
} from "../constants/constants";
import { ExcalidrawSettings, DEFAULT_SETTINGS, ExcalidrawSettingTab } from "./settings";
import { ExcalidrawAutomate } from "../shared/ExcalidrawAutomate";
import { initExcalidrawAutomate } from "src/utils/excalidrawAutomateUtils";
import { initExcalidrawAutomate, insertLaTeXToView } from "src/utils/excalidrawAutomateUtils";
import { around, dedupe } from "monkey-around";
import { t } from "../lang/helpers";
import {
@@ -88,6 +88,8 @@ import { PackageManager } from "./managers/PackageManager";
import ExcalidrawView from "../view/ExcalidrawView";
import { CommandManager } from "./managers/CommandManager";
import { EventManager } from "./managers/EventManager";
import { UniversalInsertFileModal } from "src/shared/Dialogs/UniversalInsertFileModal";
import en from "src/lang/locale/en";
declare const PLUGIN_VERSION:string;
declare const INITIAL_TIMESTAMP: number;
@@ -1077,6 +1079,15 @@ export default class ExcalidrawPlugin extends Plugin {
this.eventManager.setDebounceActiveLeafChangeHandler();
}
private getPathForFile(file: File) {
let path = "";
const { webUtils } = require('electron');
if(webUtils && webUtils.getPathForFile) {
path = webUtils.getPathForFile(file);
}
return path;
}
public registerHotkeyOverrides() {
//this is repeated here because the same function is called when settings is closed after hotkeys have changed
if (this.popScope) {
@@ -1446,4 +1457,26 @@ export default class ExcalidrawPlugin extends Plugin {
public updateFileCache(file: TFile, frontmatter: FrontMatterCache) {
this.fileManager.updateFileCache(file, frontmatter);
}
//used by obsidianUtils in the Excalidraw Pacakge
//aweful coding, but does the job
public runAction(action: "anyFile" | "LaTeX") {
if(!this.activeExcalidrawView) return;
switch (action) {
case "anyFile":
this.activeExcalidrawView.setCurrentPositionToCenter();
const insertFileModal = new UniversalInsertFileModal(this, this.activeExcalidrawView);
insertFileModal.open();
break;
case "LaTeX":
insertLaTeXToView(this.activeExcalidrawView);
break;
}
}
//used by obsidianUtils in the Excalidraw Pacakge
//aweful coding, but does the job
public getLabel(key: keyof typeof en): string {
return t(key);
}
}
+29
View File
@@ -138,6 +138,14 @@ export default {
"2) Then create an empty drawing in a new pane by CTRL/CMD+clicking the Excalidraw ribbon button,\n" +
"3) and paste your work to the new document with CTRL/CMD+V.",
ARIA_LABEL_TRAY_MODE: "Tray-mode offers an alternative, more spacious canvas",
TRAY_TRAY_MODE: "Toggle tray-mode",
TRAY_SCRIPT_LIBRARY: "Script Library",
TRAY_SCRIPT_LIBRARY_ARIA: "Explore the Excalidraw Script Library",
TRAY_EXPORT: "Export Image...",
TRAY_EXPORT_ARIA: "Export image as PNG, SVG, or Excalidraw file",
TRAY_SAVE: "Save",
TRAY_SWITCH_TO_MD: "Open as Markdown",
TRAY_SWITCH_TO_MD_ARIA: "Switch to markdown view",
MASK_FILE_NOTICE: "This is a mask file. It is used to crop images and mask out parts of the image. Press and hold notice to open the help video.",
INSTALL_SCRIPT_BUTTON: "Install or update Excalidraw Scripts",
OPEN_AS_MD: "Open as Markdown",
@@ -1170,4 +1178,25 @@ export default {
//exportUtils.ts
PDF_EXPORT_DESKTOP_ONLY: "PDF export is only available on desktop",
//UniversalInsertFileModal.ts
UIFM_TITLE: "Insert File From Vault",
UIFM_SECTION_HEAD: "Select section heading",
UIFM_ANCHOR: "Anchor to 100% of original size",
UIFM_ANCHOR_DESC: "This is a pro feature, use it only if you understand how it works. If enabled even if you change the size of the imported image in Excalidraw, the next time you open the drawing this image will pop back to 100% size. This is useful when embedding an atomic Excalidraw idea into another note and preserving relative sizing of text and icons.",
UIFM_BTN_EMBEDDABLE: "as Embeddable",
UIFM_BTN_PDF: "as Pdf",
UIFM_BTN_IMAGE: "as Image",
//ReleaseNotes.ts
RN_WELCOME: "Welcome to Excalidraw",
//Excalidraw component
COMP_IMG: "Image & Files",
COMP_IMG_FROM_SYSTEM: "Import from system",
COMP_IMG_ANY_FILE: "ANY file from Vault",
COMP_IMG_LaTeX: "LaTeX formula",
COMP_FRAME: "Frame Actions",
COMP_FRAME_HINT: "Toggle Marker Frame. Guide-only frames to define slides/print areas/image references. " +
"Hidden in image exports; doesn't contain elements. Hide/show frames via canvas context menu.",
};
@@ -1,5 +1,4 @@
import { App, FuzzySuggestModal, TFile } from "obsidian";
import { REG_LINKINDEX_INVALIDCHARS } from "../../constants/constants";
import { t } from "../../lang/helpers";
export class InsertCommandDialog extends FuzzySuggestModal<TFile> {
+2 -1
View File
@@ -2,6 +2,7 @@ import { App, MarkdownRenderer, Modal } from "obsidian";
import { isVersionNewerThanOther } from "src/utils/utils";
import ExcalidrawPlugin from "../../core/main";
import { FIRST_RUN, RELEASE_NOTES } from "./Messages";
import { t } from "src/lang/helpers";
declare const PLUGIN_VERSION:string;
@@ -20,7 +21,7 @@ export class ReleaseNotes extends Modal {
const { containerEl, contentEl, titleEl, headerEl } = this;
//this.contentEl.classList.add("excalidraw-release");
containerEl.classList.add("excalidraw-release");
titleEl.setText(`Welcome to Excalidraw ${this.version ?? ""}`);
titleEl.setText(`${t("RN_WELCOME")} ${this.version ?? ""}`);
this.createForm();
if(headerEl) headerEl.style.pointerEvents = "none"; // Disable pointer events on header to allow clicks through
@@ -1,4 +1,4 @@
import { ButtonComponent, DropdownComponent, TFile, ToggleComponent } from "obsidian";
import { ButtonComponent, DropdownComponent, TFile } from "obsidian";
import ExcalidrawView from "../../view/ExcalidrawView";
import ExcalidrawPlugin from "../../core/main";
import { Modal, Setting, TextComponent } from "obsidian";
@@ -10,6 +10,7 @@ import { InsertPDFModal } from "./InsertPDFModal";
import { ExcalidrawImperativeAPI } from "@zsviczian/excalidraw/types/excalidraw/types";
import { ExcalidrawAutomate } from "src/shared/ExcalidrawAutomate";
import { cleanSectionHeading } from "src/utils/obsidianUtils";
import { t } from "src/lang/helpers";
export class UniversalInsertFileModal extends Modal {
private center: { x: number, y: number } = { x: 0, y: 0 };
@@ -61,7 +62,7 @@ export class UniversalInsertFileModal extends Modal {
onOpen(): void {
this.containerEl.classList.add("excalidraw-release");
this.titleEl.setText(`Insert File From Vault`);
this.titleEl.setText(t("UIFM_TITLE"));
this.createForm();
}
@@ -155,15 +156,15 @@ export class UniversalInsertFileModal extends Modal {
});
sectionPickerSetting = new Setting(ce)
.setName("Select section heading")
.setName(t("UIFM_SECTION_HEAD"))
.addDropdown(dropdown => {
sectionPicker = dropdown;
sectionPicker.selectEl.style.width = "100%";
})
sizeToggleSetting = new Setting(ce)
.setName("Anchor to 100% of original size")
.setDesc("This is a pro feature, use it only if you understand how it works. If enabled even if you change the size of the imported image in Excalidraw, the next time you open the drawing this image will pop back to 100% size. This is useful when embedding an atomic Excalidraw idea into another note and preserving relative sizing of text and icons.")
.setName(t("UIFM_ANCHOR"))
.setDesc(t("UIFM_ANCHOR_DESC"))
.addToggle(toggle => {
toggle.setValue(anchorTo100)
.onChange((value) => {
@@ -174,7 +175,7 @@ export class UniversalInsertFileModal extends Modal {
new Setting(ce)
.addButton(button => {
button
.setButtonText("as Embeddable")
.setButtonText(t("UIFM_BTN_EMBEDDABLE"))
.onClick(async () => {
const path = this.app.metadataCache.fileToLinktext(
file,
@@ -198,7 +199,7 @@ export class UniversalInsertFileModal extends Modal {
})
.addButton(button => {
button
.setButtonText("as Pdf")
.setButtonText(t("UIFM_BTN_PDF"))
.onClick(() => {
const insertPDFModal = new InsertPDFModal(this.plugin, this.view);
insertPDFModal.open(file);
@@ -208,7 +209,7 @@ export class UniversalInsertFileModal extends Modal {
})
.addButton(button => {
button
.setButtonText("as Image")
.setButtonText(t("UIFM_BTN_IMAGE"))
.onClick(async () => {
const ea:ExcalidrawAutomate = getEA(this.view);
const isMarkdown = file && file.extension === "md" && !ea.isExcalidrawFile(file);
+8 -8
View File
@@ -5309,7 +5309,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
"aria-label": t("ARIA_LABEL_TRAY_MODE"),
onSelect: ()=> this.toggleTrayMode(),
},
"Toggle tray-mode"
t("TRAY_TRAY_MODE")
) : null,
React.createElement(
MainMenu.Item,
@@ -5318,34 +5318,34 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
"aria-label": t("FORCE_SAVE"),
onSelect: ()=> this.forceSave(),
},
"Save"
t("TRAY_SAVE")
),
React.createElement(
MainMenu.Item,
{
icon: ICONS.scriptEngine,
"aria-label": "Explore the Excalidraw Script Library",
"aria-label": t("TRAY_SCRIPT_LIBRARY_ARIA"),
onSelect: ()=> this.actionOpenScriptInstallPrompt(),
},
"Script Library"
t("TRAY_SCRIPT_LIBRARY")
),
React.createElement(
MainMenu.Item,
{
icon: ICONS.ExportImage,
"aria-label": "Export image as PNG, SVG, or Excalidraw file",
"aria-label": t("TRAY_EXPORT_ARIA"),
onSelect: ()=> this.actionOpenExportImageDialog(),
},
"Export Image..."
t("TRAY_EXPORT")
),
React.createElement(
MainMenu.Item,
{
icon: ICONS.switchToMarkdown,
"aria-label": "Switch to markdown view",
"aria-label": t("TRAY_SWITCH_TO_MD_ARIA"),
onSelect: ()=> this.openAsMarkdown(),
},
"Open as Markdown"
t("TRAY_SWITCH_TO_MD")
),
React.createElement(MainMenu.Separator),
React.createElement(MainMenu.DefaultItems.Help),