diff --git a/ea-scripts/index-new.md b/ea-scripts/index-new.md index a99833f3..fdff4de7 100644 --- a/ea-scripts/index-new.md +++ b/ea-scripts/index-new.md @@ -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 ``` -
Author@zsviczian
SourceFile on GitHub
DescriptionExport 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.

Link to video on YouTube


Link to video on YouTube

+
Author@zsviczian
SourceFile on GitHub
DescriptionExport 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.

Link to video on YouTube

Link to video on YouTube

## Zoom to Fit Selected Elements diff --git a/package.json b/package.json index d4962ab1..8a3c422d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/core/main.ts b/src/core/main.ts index 83ddbaf7..aab1c6da 100644 --- a/src/core/main.ts +++ b/src/core/main.ts @@ -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); + } } \ No newline at end of file diff --git a/src/lang/locale/en.ts b/src/lang/locale/en.ts index c6760b99..8013c207 100644 --- a/src/lang/locale/en.ts +++ b/src/lang/locale/en.ts @@ -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.", }; diff --git a/src/shared/Dialogs/InsertCommandDialog.ts b/src/shared/Dialogs/InsertCommandDialog.ts index 21380d11..b7ab0dce 100644 --- a/src/shared/Dialogs/InsertCommandDialog.ts +++ b/src/shared/Dialogs/InsertCommandDialog.ts @@ -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 { diff --git a/src/shared/Dialogs/ReleaseNotes.ts b/src/shared/Dialogs/ReleaseNotes.ts index cbad805f..0fe5bb54 100644 --- a/src/shared/Dialogs/ReleaseNotes.ts +++ b/src/shared/Dialogs/ReleaseNotes.ts @@ -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 diff --git a/src/shared/Dialogs/UniversalInsertFileModal.ts b/src/shared/Dialogs/UniversalInsertFileModal.ts index d40b7fb7..6a3fcffc 100644 --- a/src/shared/Dialogs/UniversalInsertFileModal.ts +++ b/src/shared/Dialogs/UniversalInsertFileModal.ts @@ -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); diff --git a/src/view/ExcalidrawView.ts b/src/view/ExcalidrawView.ts index 234579be..d96a54ff 100644 --- a/src/view/ExcalidrawView.ts +++ b/src/view/ExcalidrawView.ts @@ -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),