Compare commits

...
13 Commits
Author SHA1 Message Date
zsviczian ccb5590f0c 2.15.1 2025-08-25 21:32:11 +02:00
zsviczian 524c33a7e5 2.15.1-beta-3, 0.18.0-37; hide raw mode, pinch zoom PDF on iPad, scroll webpage on mobile, insert LatTex and PDF page image to center 2025-08-25 20:34:19 +02:00
zsviczian 09bb5c5486 2.15.1-beta-2 2025-08-24 19:33:42 +02:00
zsviczian 434f61653d fixed Area link rendering, fixed external video autoplay 2025-08-24 17:45:10 +02:00
zsviczian 613b86e9d0 Merge branch 'master' of https://github.com/zsviczian/obsidian-excalidraw-plugin 2025-08-24 17:23:55 +02:00
zsviczian a6cad5010e Merge pull request #2455 from PlayerMiller109/master
Update zh-cn.ts to 425d830
2025-08-24 17:23:43 +02:00
zsviczian 49cf799f66 pdf stying tweaks. Added snapshot and bookmark, fixed crop, added back-of-the-note card to insert image menu 2025-08-24 15:57:06 +02:00
zsviczian 662737436a carved out setupPdfViewEnhancements to its own function 2025-08-24 12:51:11 +02:00
zsviczian 887651a4bc moved PDF view to node, resolved mobile blackout 2025-08-24 12:31:34 +02:00
PlayerMiller109 c0a40c69a1 Update zh-cn.ts to 425d830 2025-08-24 11:04:34 +08:00
PlayerMiller109 e69676f461 Correct 'ES_FILENAME_VISIBLE': '文件名' to '页内标题'
This option corresponds to Obsidian "Appearance - Show inline title" option.
When enabled in Excalidraw, if "Show inline title" is disabled in Obsidian, it will not be shown.
This differs from Canvas, where the filename floats at the top-left corner of the card.
Important to note this distinction.
2025-08-24 11:04:34 +08:00
PlayerMiller109 9582758483 [squash] Update zh-cn.ts to 89f2a3b 2025-08-24 11:03:50 +08:00
PlayerMiller109 a227c746a2 Unify '查看模式' to follow the upstream default
as it is inherited from upstream (e.g. in the right-click context menu) and cannot be changed by the plugin.
2025-08-23 18:28:55 +08:00
22 changed files with 784 additions and 518 deletions

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{
"id": "obsidian-excalidraw-plugin",
"name": "Excalidraw",
"version": "2.15.beta-1",
"version": "2.15.1",
"minAppVersion": "1.5.7",
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
"author": "Zsolt Viczian",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"id": "obsidian-excalidraw-plugin",
"name": "Excalidraw",
"version": "2.15.0",
"version": "2.15.1",
"minAppVersion": "1.5.7",
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
"author": "Zsolt Viczian",
+1 -1
View File
@@ -24,7 +24,7 @@
"license": "MIT",
"dependencies": {
"@popperjs/core": "^2.11.8",
"@zsviczian/excalidraw": "0.18.0-35",
"@zsviczian/excalidraw": "0.18.0-37",
"chroma-js": "^3.1.2",
"clsx": "^2.0.0",
"@zsviczian/colormaster": "^1.2.2",
+3 -1
View File
@@ -1,4 +1,4 @@
import { Copy, Crop, Globe, RotateCcw, Scan, Settings, TextSelect } from "lucide-react";
import { Bookmark, Camera, Copy, Crop, Globe, RotateCcw, Scan, Settings, TextSelect } from "lucide-react";
import * as React from "react";
import { PenStyle } from "src/types/penTypes";
@@ -31,6 +31,8 @@ export const ICONS = {
Copy: (<Copy /> ),
Globe: (<Globe />),
Crop: (<Crop />),
Bookmark: (<Bookmark />),
Camera: (<Camera />),
ZoomToSelectedElement: (<Scan />),
Properties: (<Settings />),
ZoomToSection: (
+2
View File
@@ -234,6 +234,8 @@ export const IMAGE_TYPES = ["jpeg", "jpg", "png", "gif", "svg", "webp", "bmp", "
export const ANIMATED_IMAGE_TYPES = ["gif", "webp", "apng", "svg"];
export const EXPORT_TYPES = ["svg", "dark.svg", "light.svg", "png", "dark.png", "light.png"];
export const MAX_IMAGE_SIZE = 500;
export const CARD_WIDTH = 400;
export const CARD_HEIGHT = 500;
export const VIDEO_TYPES = ["mp4", "webm", "ogv", "mov", "mkv"];
export const AUDIO_TYPES = ["mp3", "wav", "m4a", "3gp", "flac", "ogg", "oga", "opus"];
+5 -2
View File
@@ -1460,7 +1460,7 @@ export default class ExcalidrawPlugin extends Plugin {
//used by obsidianUtils in the Excalidraw Pacakge
//aweful coding, but does the job
public runAction(action: "anyFile" | "LaTeX") {
public runAction(action: "anyFile" | "LaTeX" | "card") {
if(!this.activeExcalidrawView) return;
switch (action) {
case "anyFile":
@@ -1469,7 +1469,10 @@ export default class ExcalidrawPlugin extends Plugin {
insertFileModal.open();
break;
case "LaTeX":
insertLaTeXToView(this.activeExcalidrawView);
insertLaTeXToView(this.activeExcalidrawView, true);
break;
case "card":
this.activeExcalidrawView.insertBackOfTheNoteCard(true);
break;
}
}
+22 -19
View File
@@ -781,20 +781,19 @@ export class CommandManager {
checkCallback: (checking:boolean) => this.plugin.forceSaveActiveView(checking),
})
//removing raw mode. Not required. I never use it. Raw mode can still be enabled
//via document properties. Only showing command palette action if raw mode is enabled
this.addCommand({
id: "toggle-lock",
name: t("TOGGLE_LOCK"),
checkCallback: (checking: boolean) => {
const view = this.app.workspace.getActiveViewOfType(ExcalidrawView);
if (checking) {
if (
Boolean(this.app.workspace.getActiveViewOfType(ExcalidrawView))
) {
return !(this.app.workspace.getActiveViewOfType(ExcalidrawView))
.compatibilityMode;
if (view) {
return !view.compatibilityMode && view.textMode === TextMode.raw;
}
return false;
}
const view = this.app.workspace.getActiveViewOfType(ExcalidrawView);
if (view && !view.compatibilityMode) {
view.changeTextMode(
view.textMode === TextMode.parsed ? TextMode.raw : TextMode.parsed,
@@ -1281,7 +1280,7 @@ export class CommandManager {
if(!excalidrawView.excalidrawAPI) return false;
const embeddables = excalidrawView.getViewSelectedElements().filter(el=>el.type==="embeddable");
const imageEls = excalidrawView.getViewSelectedElements().filter(el=>el.type==="image");
const isPDF = (imageEls.length === 0 && embeddables.length === 1 && excalidrawView.getEmbeddableLeafElementById(embeddables[0].id)?.leaf?.view?.getViewType() === "pdf")
const isPDF = (imageEls.length === 0 && embeddables.length === 1 && excalidrawView.getEmbeddableLeafElementById(embeddables[0].id)?.node?.child?.file?.extension === "pdf")
const isImage = (imageEls.length === 1 && embeddables.length === 0)
if(!isPDF && !isImage) {
@@ -1290,7 +1289,7 @@ export class CommandManager {
return false;
}
const page = isPDF ? getActivePDFPageNumberFromPDFView(excalidrawView.getEmbeddableLeafElementById(embeddables[0].id)?.leaf?.view) : undefined;
const page = isPDF ? getActivePDFPageNumberFromPDFView(excalidrawView.getEmbeddableLeafElementById(embeddables[0].id)?.node?.child) : undefined;
if(isPDF && !page) {
return false;
}
@@ -1300,8 +1299,8 @@ export class CommandManager {
if(isPDF) {
const embeddableEl = embeddables[0] as ExcalidrawEmbeddableElement;
const ea = new ExcalidrawAutomate(this.plugin,excalidrawView);
const view = excalidrawView.getEmbeddableLeafElementById(embeddableEl.id)?.leaf?.view;
const pdfFile: TFile = view && (view instanceof FileView) ? view.file : undefined;
const view = excalidrawView.getEmbeddableLeafElementById(embeddableEl.id)?.node?.child;
const pdfFile: TFile = view?.file;
carveOutPDF(ea, embeddableEl, `${pdfFile?.path}#page=${page}`, pdfFile);
return;
}
@@ -1707,15 +1706,19 @@ export class CommandManager {
const PDFLink = this.plugin.getLastActivePDFPageLink(view.file);
if(!PDFLink) return false;
if(checking) return true;
const ea = getEA(view);
insertImageToView(
ea,
view.currentPosition,
PDFLink,
undefined,
undefined,
true,
);
(async()=>{
const ea = getEA(view) as ExcalidrawAutomate;
const id = await insertImageToView(
ea,
view.currentPosition,
PDFLink,
undefined,
undefined,
true,
);
ea.selectElementsInView([id]);
ea.destroy()
})();
},
});
+4
View File
@@ -1206,4 +1206,8 @@ export default {
NOTICE_PDF_THEME: "PDF theme overridden.\n" +
"Control via this file's 'excalidraw-embeddable-theme' document property (overrides plugin).\n\n" +
"Values: dark, light, auto=Excalidraw, default=Obsidian.",
//EmbeddableActionsMenu.tsx
BOOKMARK_PAGE: "Save current position in document",
CAPTURE_PAGE: "Capture current page as image",
};
+315 -310
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -50,7 +50,7 @@ export class EmbeddableSettings extends Modal {
this.zoomValue = element.scale[0];
this.isYouTube = isYouTube(this.element.link);
this.notExcalidrawIsInternal = this.file && !this.view.plugin.isExcalidrawFile(this.file)
this.isMDFile = this.file && this.file.extension === "md"; // && !this.view.plugin.isExcalidrawFile(this.file);
this.isMDFile = this.file && this.file.extension.toLowerCase() === "md"; // && !this.view.plugin.isExcalidrawFile(this.file);
this.isLocalURI = this.element.link.startsWith("file://");
if(isYouTube) this.youtubeStart = getYouTubeStartAt(this.element.link);
+24 -4
View File
@@ -27,12 +27,32 @@ I build this plugin in my free time, as a labor of love. Curious about the philo
- default: follows Obsidian theme (regardless of Excalidraw theme)
- dark: always displays the PDF in dark mode (regardless of Excalidraw and Obsidian themes)
- light: always displays the PDF in light mode (regardless of Excalidraw and Obsidian themes)
- Pasting an oversized image resulted in an error message and Excalidraw dumping the scene. [#2453](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2453), [#9878](https://github.com/excalidraw/excalidraw/issues/9878)
- Insert Any File now supports adding Audio files.
- New embeddable-menu buttons:
- Snapshot: inserts an image of the current active page to the scene
- Bookmark: updates the embed link to the current page
- Pasting an oversized image triggered an error and caused Excalidraw to discard the scene. [#2453](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2453), [#9878](https://github.com/excalidraw/excalidraw/issues/9878)
- Video with local URI will no longer autoplay when the scene loads
- Error creating link to element when element is a sticky note
- Area link embeds hide the content of the objects within the area [#2461](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2461)
- On Obsidian Mobile 1.9.10, embeddables could cause a black/white screen (no active view) until reselecting the Excalidraw page; [#2460](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2460)
- Scrolling of embedded web pages on mobile devices is working again.
## New
- New option in settings under "Zoom and Pan". Pan with right mouse button (Miro‑style): right‑click and drag to pan the canvas. Press 'm' for the context menu (disabled while editing text). 🙏 [@mfuria](https://github.com/mfuria) for making this happen! [#2450](https://github.com/zsviczian/obsidian-excalidraw-plugin/pull/2450), [#329](https://github.com/zsviczian/excalidraw/pull/329)
- Insert image in the main toolbar now opens a dropdown menu of options: Insert from system, insert from Vault, insert LaTeX. [#2448](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2448)
- Insert Any File now supports adding Audio files.
- New option in settings under "Zoom and Pan". Pan with right mouse button (Miro-style): right-click and drag to pan the canvas. Press 'm' for the context menu (disabled while editing text). 🙏 [@mfuria](https://github.com/mfuria) for making this happen! [#2450](https://github.com/zsviczian/obsidian-excalidraw-plugin/pull/2450), [#329](https://github.com/zsviczian/excalidraw/pull/329)
- Insert image in the main toolbar now opens a dropdown menu of options: Insert from system, insert from Vault, insert Card, and insert LaTeX. [#2448](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2448)
## Deprecated
- Removed "Toggle RAW mode" from the Command Palette and the Obsidian Tools menu due to low usage. RAW mode remains available by adding \`excalidraw-plugin: raw\` to the note's YAML frontmatter/document properties.
## New in ExcalidrawAutomate
\`\`\`ts
/**
* Returns the center position of the current view in Excalidraw coordinates.
* @returns {{x:number, y:number}} The center position of the view.
*/
public getViewCenterPosition(): {x:number, y:number};
\`\`\`
`,
"2.15.0":`
<div class="excalidraw-videoWrapper"><div>
+16 -5
View File
@@ -3,10 +3,11 @@ import { t } from "../../lang/helpers";
import ExcalidrawView from "src/view/ExcalidrawView";
import { getEA } from "src/core";
import { ExcalidrawAutomate } from "src/shared/ExcalidrawAutomate";
import { MD_EX_SECTIONS } from "src/constants/constants";
import { CARD_HEIGHT, CARD_WIDTH, MD_EX_SECTIONS } from "src/constants/constants";
import { addBackOfTheNoteCard } from "src/utils/excalidrawViewUtils";
export class SelectCard extends FuzzySuggestModal<string> {
private center: boolean = false;
constructor(
public app: App,
@@ -31,7 +32,7 @@ export class SelectCard extends FuzzySuggestModal<string> {
this.close();
return;
}
addBackOfTheNoteCard(this.view, item);
addBackOfTheNoteCard(this.view, item, true, undefined, undefined, this.center);
this.close();
}
}
@@ -48,18 +49,28 @@ export class SelectCard extends FuzzySuggestModal<string> {
onChooseItem(item: string): void {
const ea = getEA(this.view) as ExcalidrawAutomate;
let x,y = 0;
if(this.center) {
const centerPos = ea.getViewCenterPosition();
if(centerPos) {
x = centerPos.x - (CARD_WIDTH / 2);
y = centerPos.y - (CARD_HEIGHT / 2);
}
}
const id = ea.addEmbeddable(
0,0,400,500,
x,y,CARD_WIDTH,CARD_HEIGHT,
`[[${this.view.file.path}#${item}]]`
);
(async () => {
await ea.addElementsToView(true, false, true);
await ea.addElementsToView(!this.center, false, true);
ea.selectElementsInView([id]);
ea.destroy();
})();
}
public start(): void {
public start(center: boolean = false): void {
this.center = center;
this.emptyStateText = t("EMPTY_SECTION_MESSAGE");
this.setPlaceholder(t("SELECT_SECTION_OR_TYPE_NEW"));
this.open();
+6
View File
@@ -832,6 +832,12 @@ export const EXCALIDRAW_AUTOMATE_INFO: SuggesterInfo[] = [
desc: "@returns the last recorded pointer position on the Excalidraw canvas",
after: "",
},
{
field: "getViewCenterPosition",
code: "getViewCenterPosition(): {x: number, y: number};",
desc: "@returns the center position of the current view in Excalidraw coordinates",
after: "",
},
{
field: "getleaf",
code: "getLeaf(origo: WorkspaceLeaf, targetPane?: PaneTarget): WorkspaceLeaf;",
+36 -9
View File
@@ -89,6 +89,7 @@ import { FrameRenderingOptions } from "src/types/utilTypes";
import { CaptureUpdateAction } from "src/constants/constants";
import { AutoexportConfig } from "src/types/excalidrawViewTypes";
import { FloatingModal } from "./Dialogs/FloatingModal";
import { patchMobileView } from "src/utils/customEmbeddableUtils";
extendPlugins([
HarmonyPlugin,
@@ -555,6 +556,25 @@ export class ExcalidrawAutomate {
return this.targetView.currentPosition;
}
/**
* Returns the center position of the current view in Excalidraw coordinates.
* @returns {{x:number, y:number}} The center position of the view.
*/
public getViewCenterPosition(): {x:number, y:number} {
if (!this.targetView || !this.targetView?._loaded) {
errorMessage("targetView not set", "getExcalidrawAPI()");
return null;
}
const st = (this.getExcalidrawAPI() as ExcalidrawImperativeAPI).getAppState();
if (!st) return null;
const zoom = st.zoom?.value ?? 1;
const x = -st.scrollX + (st.width / 2) / zoom;
const y = -st.scrollY + (st.height / 2) / zoom;
return { x, y };
}
/**
* Returns the Excalidraw API for the current view or the view provided.
* @param {ExcalidrawView} [view] - The view to get the API for.
@@ -1298,6 +1318,7 @@ export class ExcalidrawAutomate {
boundElements: [] as any,
link,
locked: false,
frameId: null as string,
...scale ? {scale} : {},
};
}
@@ -1934,10 +1955,12 @@ export class ExcalidrawAutomate {
image.size.width,
image.size.height,
);
this.elementsDict[id].fileId = fileId;
this.elementsDict[id].scale = [1, 1];
const newEl = this.elementsDict[id] as Mutable<ExcalidrawImageElement>;
newEl.fileId = fileId;
newEl.scale = [1, 1];
newEl.crop = null;
if(!scale && anchor) {
this.elementsDict[id].customData = {isAnchored: true}
newEl.customData = {isAnchored: true}
};
return id;
};
@@ -2734,8 +2757,11 @@ export class ExcalidrawAutomate {
errorMessage("targetView not set", "addElementsToView()");
return false;
}
const elements = this.getElements();
return await this.targetView.addElements({
const elements = this.getElements();
if(elements.some(el=>el.type === "embeddable")) {
patchMobileView(this.targetView);
}
const result = await this.targetView.addElements({
newElements: elements,
repositionToCursor,
save,
@@ -2743,6 +2769,7 @@ export class ExcalidrawAutomate {
newElementsOnTop,
shouldRestoreElements,
});
return result;
};
/**
@@ -3046,14 +3073,14 @@ export class ExcalidrawAutomate {
* @returns The elements within the area.
*/
getElementsInArea(
elements: NonDeletedExcalidrawElement[],
{x, y, width, height}:{
x:number; y:number; width:number; height:number;
}
elements: NonDeletedExcalidrawElement[],
element: NonDeletedExcalidrawElement,
):ExcalidrawElement[] {
const {x, y, width, height, id} = element;
return elements
.filter(el => {
if((el.type==="frame" && el.frameRole==="marker")) return false;
if(el.id === id) return true;
const {topX, topY, width:w, height:h} = this.getBoundingBox([el]);
const elLeft = topX;
const elTop = topY;
+9
View File
@@ -13,6 +13,7 @@ export const leafMap = new Map<string, WorkspaceLeaf>();
//This is definitely not the right solution, feels like sticking plaster
//patch disappearing content on mobile
//based on obsidian app.js, obsidian is looking for activeEditor, but active editor is in a leaf that is disconnected from root
export const patchMobileView = (view: ExcalidrawView) => {
if(DEVICE.isDesktop) return;
console.log("patching mobile view");
@@ -21,6 +22,14 @@ export const patchMobileView = (view: ExcalidrawView) => {
if(!parent.hasClass("mod-visible")) {
parent.addClass("mod-visible");
}
//create observer here
const observer = new MutationObserver(() => {
if(!parent.hasClass("mod-visible")) {
parent.addClass("mod-visible");
}
});
observer.observe(parent, { attributes: true, attributeFilter: ["class"] });
window.setTimeout(() => observer.disconnect(), 500);
}
}
+16 -9
View File
@@ -42,6 +42,7 @@ import { SVGColorInfo } from "src/types/excalidrawAutomateTypes";
import { ExcalidrawData, getExcalidrawMarkdownHeaderSection, REGEX_LINK } from "src/shared/ExcalidrawData";
import { getFrameBasedOnFrameNameOrId } from "./excalidrawViewUtils";
import { ScriptEngine } from "src/shared/Scripts";
import { getEA } from "src/core";
declare const PLUGIN_VERSION:string;
@@ -290,7 +291,7 @@ export async function getTemplate(
if(filenameParts.hasArearef) {
const el=scene.elements.find((el: ExcalidrawElement)=>el.id===filenameParts.blockref);
if(el) {
groupElements = plugin.ea.getElementsInArea(scene.elements, el).concat(el);
groupElements = plugin.ea.getElementsInArea(scene.elements, el);
}
}
@@ -643,9 +644,9 @@ export function repositionElementsToCursor(
return restore({elements}, null, null).elements;
}
export const insertLaTeXToView = (view: ExcalidrawView) => {
export const insertLaTeXToView = (view: ExcalidrawView, center: boolean = false) => {
const app = view.plugin.app;
const ea = view.plugin.ea;
const ea = getEA(view) as ExcalidrawAutomate;
GenericInputPrompt.Prompt(
view,
view.plugin,
@@ -656,13 +657,19 @@ export const insertLaTeXToView = (view: ExcalidrawView) => {
undefined,
3
).then(async (formula: string) => {
if (!formula) {
return;
if (formula) {
const id = await ea.addLaTex(0, 0, formula);
if(center) {
const el = ea.getElement(id);
let {width, height} = el;
let {x, y} = ea.getViewCenterPosition();
el.x = x - width / 2;
el.y = y - height / 2;
}
await ea.addElementsToView(!center, false, true);
ea.selectElementsInView([id]);
}
ea.reset();
await ea.addLaTex(0, 0, formula);
ea.setView(view);
ea.addElementsToView(true, false, true);
ea.destroy();
});
};
+17 -4
View File
@@ -1,5 +1,5 @@
import { MAX_IMAGE_SIZE, IMAGE_TYPES, ANIMATED_IMAGE_TYPES, MD_EX_SECTIONS, AUDIO_TYPES } from "src/constants/constants";
import { MAX_IMAGE_SIZE, IMAGE_TYPES, ANIMATED_IMAGE_TYPES, MD_EX_SECTIONS, AUDIO_TYPES, CARD_WIDTH, CARD_HEIGHT } from "src/constants/constants";
import { App, Modal, Notice, TFile } from "obsidian";
import { ExcalidrawAutomate } from "src/shared/ExcalidrawAutomate";
import { REGEX_LINK, REG_LINKINDEX_HYPERLINK, getExcalidrawMarkdownHeaderSection, REGEX_TAGS, getExcalidrawMarkdownHeader } from "../shared/ExcalidrawData";
@@ -67,7 +67,10 @@ export async function insertEmbeddableToView (
return await insertImageToView(ea, position, link??file, undefined, shouldInsertToView);
} else {
let height = MAX_IMAGE_SIZE;
if (file && AUDIO_TYPES.contains(file.extension.toLowerCase())) {
if (
(file && AUDIO_TYPES.contains(file.extension.toLowerCase())) ||
(link && AUDIO_TYPES.contains(link.match(/\[\[[^\]]+?\.([^\.\]]+)]]/)?.[1]?.toLocaleLowerCase()))
) {
ea.style.strokeColor = "transparent";
ea.style.backgroundColor = "transparent";
height = getAudioElementHeight();
@@ -230,6 +233,7 @@ export async function addBackOfTheNoteCard(
activate: boolean = true,
cardBody?: string,
embeddableCustomData?: EmbeddableMDCustomProps,
center: boolean = false,
):Promise<string> {
const data = view.data;
const header = getExcalidrawMarkdownHeaderSection(data);
@@ -259,13 +263,22 @@ export async function addBackOfTheNoteCard(
}
const ea = getEA(view) as ExcalidrawAutomate;
let x,y = 0;
if(center) {
const centerPos = ea.getViewCenterPosition();
if(centerPos) {
x = centerPos.x - (CARD_WIDTH / 2);
y = centerPos.y - (CARD_HEIGHT / 2);
}
}
const id = ea.addEmbeddable(
0,0,400,500,
x,y,CARD_WIDTH,CARD_HEIGHT,
`[[${view.file.path}#${title}]]`,
undefined,
embeddableCustomData
);
await ea.addElementsToView(true, false, true);
await ea.addElementsToView(!center, false, true);
const api = view.excalidrawAPI as ExcalidrawImperativeAPI;
const el = ea.getViewElements().find(el=>el.id === id);
+7 -7
View File
@@ -1650,11 +1650,11 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
t("RAW"),
() => this.changeTextMode(TextMode.parsed),
);
this.actionButtons['isParsed'] = this.addAction(
/*this.actionButtons['isParsed'] = this.addAction(
TEXT_DISPLAY_PARSED_ICON_NAME,
t("PARSED"),
() => this.changeTextMode(TextMode.raw),
);
);*/
this.actionButtons['link'] = this.addAction("link", t("OPEN_LINK"), (ev) =>
this.handleLinkClick(ev),
@@ -1846,10 +1846,10 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
this.textMode = textMode;
if (textMode === TextMode.parsed) {
this.actionButtons['isRaw'].hide();
this.actionButtons['isParsed'].show();
//this.actionButtons['isParsed'].hide();
} else {
this.actionButtons['isRaw'].show();
this.actionButtons['isParsed'].hide();
//this.actionButtons['isParsed'].hide();
}
if (this.toolsPanelRef && this.toolsPanelRef.current) {
this.toolsPanelRef.current.setPreviewMode(textMode === TextMode.parsed);
@@ -4643,12 +4643,12 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
return {imageEl: el, embeddedFile: imageFile};
}
public async insertBackOfTheNoteCard() {
public async insertBackOfTheNoteCard(center: boolean = false) {
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.insertBackOfTheNoteCard, "ExcalidrawView.insertBackOfTheNoteCard");
await this.forceSave(true);
const sections = await this.getBackOfTheNoteSections();
const selectCardDialog = new SelectCard(this.app,this,sections);
selectCardDialog.start();
selectCardDialog.start(center);
}
public async moveBackOfTheNoteCardToFile(id?: string) {
@@ -5948,7 +5948,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
if(elements.length === 2) {
const textEl = elements.filter(el=>el.type==="text");
if(textEl.length===1 && (textEl[0] as ExcalidrawTextElement).containerId) {
const container = elements.filter(el=>el.boundElements.some(be=>be.type==="text"))
const container = elements.filter(el=>el.boundElements && el.boundElements.some(be=>be.type==="text"))
if(container.length===1) {
elementId = textEl[0].id;
}
+215 -132
View File
@@ -10,7 +10,7 @@ import { processLinkText, patchMobileView, setFileToLocalGraph } from "src/utils
import { EmbeddableMDCustomProps } from "src/shared/Dialogs/EmbeddableSettings";
import { t } from "src/lang/helpers";
const CANVAS_VIEWTYPES = new Set(["markdown", "bases", "audio", "video"]);
const CANVAS_VIEWTYPES = new Set(["markdown", "bases", "audio", "video", "pdf"]);
declare module "obsidian" {
interface Workspace {
@@ -47,22 +47,22 @@ function setPDFViewTheme(view: ExcalidrawView, pdfView: any) {
if(!pdfView) return;
if(view.excalidrawData.embeddableTheme === "auto") {
pdfView.viewer?.child?.pdfViewer?.setBackground?.(null, false);
const pdfContainerEl = pdfView.contentEl?.querySelector(".pdf-container");
const pdfContainerEl = pdfView.containerEl?.querySelector(".pdf-container");
if(pdfContainerEl) {
pdfContainerEl.classList.remove("mod-themed");
}
const thumbnailViewEl = pdfView.contentEl?.querySelector(".pdf-thumbnail-view");
const thumbnailViewEl = pdfView.containerEl?.querySelector(".pdf-thumbnail-view");
if(thumbnailViewEl) {
thumbnailViewEl.style.filter = "var(--theme-filter)";
}
} else {
const pdfViewerEl = pdfView.contentEl?.querySelector("div.pdfViewer");
const pdfViewerEl = pdfView.containerEl?.querySelector("div.pdfViewer");
if(pdfViewerEl) {
pdfViewerEl.addClass("mod-nofilter");
}
}
if(["dark", "light"].includes(view.excalidrawData.embeddableTheme)) {
const pdfContainerEl = pdfView.contentEl?.querySelector(".pdf-container");
const pdfContainerEl = pdfView.containerEl?.querySelector(".pdf-container");
if(pdfContainerEl && !pdfContainerEl.classList.contains("mod-themed")) {
pdfContainerEl.classList.add("mod-themed");
}
@@ -77,6 +77,186 @@ function setPDFViewTheme(view: ExcalidrawView, pdfView: any) {
}
}
// New: carve out PDF setup logic
function setupPdfViewEnhancements(
view: ExcalidrawView,
leafRef: React.MutableRefObject<{ leaf: WorkspaceLeaf; node?: ObsidianCanvasNode; editNode?: Function } | null>,
pdfObserverRef: React.MutableRefObject<MutationObserver | null> & { currentCleanup?: () => void },
pdfObserverDisabledRef: React.MutableRefObject<boolean>
) {
const pdfView = leafRef.current?.node?.child;
if (!pdfView) return;
const patchPDF = () => {
// Disable observer while applying the theme to avoid loops
pdfObserverDisabledRef.current = true;
setPDFViewTheme(view, pdfView);
requestAnimationFrame(() => { pdfObserverDisabledRef.current = false; });
// Observe inline height changes on the PDF root container and reset them
// this could be an obsidian bug, should be revisted later 2025-08-23
const containerEl = pdfView.containerEl as HTMLElement | null;
let prevHeight = containerEl?.style?.height || "";
let heightObserver: MutationObserver | null = null;
if (containerEl) {
heightObserver = new MutationObserver(() => {
const h = containerEl.style.height || "";
if (h !== prevHeight) {
prevHeight = h;
if (h) {
containerEl.style.height = "";
prevHeight = "";
}
}
});
heightObserver.observe(containerEl, { attributes: true, attributeFilter: ["style"] });
}
// Transform-aware MMB drag-to-scroll (bypasses Chromium autoscroll)
const scroller = pdfView.containerEl?.querySelector(".pdf-viewer-container") || null;
let active = false;
let lastX = 0, lastY = 0;
let scaleX = 1, scaleY = 1;
const getScaleFromAncestor = (target: Element | null) => {
// Read scale from the outer excalidraw embeddable container transform
const container = target?.closest(".excalidraw__embeddable-container") as HTMLElement | null;
if (!container) return { sx: 1, sy: 1 };
const t = getComputedStyle(container).transform;
// t can be "none", "matrix(a,b,c,d,tx,ty)" or "matrix3d(...)"
if (!t || t === "none") return { sx: 1, sy: 1 };
if (t.startsWith("matrix3d(")) {
// matrix3d: m11=a1, m12=b1, m21=a2, m22=b2 in the first 6 entries
const m = t.slice(9, -1).split(",").map(Number);
const a = m[0], b = m[1], c = m[4], d = m[5];
// scaleX = length of first column, scaleY = length of second column
return { sx: Math.hypot(a, b) || 1, sy: Math.hypot(c, d) || 1 };
}
if (t.startsWith("matrix(")) {
const m = t.slice(7, -1).split(",").map(Number); // [a,b,c,d,tx,ty]
const a = m[0], b = m[1], c = m[2], d = m[3];
return { sx: Math.hypot(a, b) || 1, sy: Math.hypot(c, d) || 1 };
}
return { sx: 1, sy: 1 };
};
const onPointerDownCapture = (e: PointerEvent) => {
if ((
(DEVICE.isDesktop && e.button !== 1) ||
(DEVICE.isMobile && e.button !== 0)) ||
!scroller) return;
// Start custom pan, cancel browser autoscroll and prevent Excalidraw from handling it.
e.preventDefault();
e.stopPropagation();
active = true;
lastX = e.clientX;
lastY = e.clientY;
const { sx, sy } = getScaleFromAncestor(scroller);
scaleX = sx;
scaleY = sy;
// Listen on window so we keep panning even if we leave the element.
window.addEventListener("pointermove", onPointerMove, { capture: true });
window.addEventListener("pointerup", onPointerUp, { capture: true, once: true });
window.addEventListener("pointercancel", onPointerUp, { capture: true, once: true });
try { (view.contentEl as HTMLElement).style.cursor = "grabbing"; } catch {}
};
const onPointerMove = (e: PointerEvent) => {
if (!active || !scroller) return;
// Continue only while the pointer button is held:
// - Desktop: middle mouse button (bit 3 = 4)
// - Mobile: primary/left button (bit 0 = 1)
if (
(DEVICE.isDesktop && (e.buttons & 4) === 0) ||
(DEVICE.isMobile && (e.buttons & 1) === 0)
) return;
const dx = e.clientX - lastX;
const dy = e.clientY - lastY;
lastX = e.clientX;
lastY = e.clientY;
// Convert viewport dx/dy to local CSS px by dividing on scale.
scroller.scrollLeft -= dx / (scaleX || 1);
scroller.scrollTop -= dy / (scaleY || 1);
e.preventDefault();
e.stopPropagation();
};
const onPointerUp = (_e: PointerEvent) => {
active = false;
try { (view.contentEl as HTMLElement).style.cursor = ""; } catch {}
window.removeEventListener("pointermove", onPointerMove, { capture: true } as any);
window.removeEventListener("pointerup", onPointerUp, { capture: true } as any);
window.removeEventListener("pointercancel", onPointerUp,{ capture: true } as any);
};
const root = pdfView.containerEl as HTMLElement;
root?.addEventListener("pointerdown", onPointerDownCapture, { capture: true });
const cleanupPan = () => {
root?.removeEventListener("pointerdown", onPointerDownCapture, { capture: true } as any);
window.removeEventListener("pointermove", onPointerMove, { capture: true } as any);
window.removeEventListener("pointerup", onPointerUp, { capture: true } as any);
window.removeEventListener("pointercancel", onPointerUp,{ capture: true } as any);
heightObserver?.disconnect();
heightObserver = null;
};
(pdfObserverRef as any).currentCleanup = () => { cleanupPan(); };
if (view.excalidrawData.embeddableTheme !== "default") {
const pdfContainerEl = pdfView.containerEl?.querySelector(".pdf-container") as HTMLElement | null;
if (pdfContainerEl) {
pdfObserverRef.current?.disconnect();
pdfObserverRef.current = new MutationObserver(() => {
if (pdfObserverDisabledRef.current) return;
pdfObserverDisabledRef.current = true;
try {
setPDFViewTheme(view, pdfView);
if(view.excalidrawData.embeddableTheme !== "default") {
showNoticeOnce(t("NOTICE_PDF_THEME"));
}
} finally {
requestAnimationFrame(() => { pdfObserverDisabledRef.current = false; });
}
});
pdfObserverRef.current.observe(pdfContainerEl, {
attributes: true,
attributeFilter: ["class"],
});
}
}
};
const root = leafRef?.current?.node?.child?.containerEl;
if (root) {
const selector = ".pdf-viewer-container";
const existing = root.querySelector(selector);
if (existing) {
patchPDF();
} else {
let timeoutId:number = null as any;
const mo = new MutationObserver((_, obs) => {
const el = root.querySelector(selector);
if (el) {
patchPDF();
obs.disconnect();
if (timeoutId) clearTimeout(timeoutId);
}
});
mo.observe(root as HTMLElement, { childList: true, subtree: true });
timeoutId = window.setTimeout(() => {
mo.disconnect();
}, 10000);
}
}
}
//--------------------------------------------------------------------------------
//Render webview for anything other than Vimeo and Youtube
//Vimeo and Youtube are rendered by Excalidraw because of the window messaging
@@ -92,6 +272,7 @@ export function renderWebView (src: string, view: ExcalidrawView, id: string, _:
title="Excalidraw Embedded Content"
allowFullScreen={true}
src={src}
webpreferences="autoplayPolicy=document-user-activation-required"
style={{
overflow: "hidden",
borderRadius: "var(--embeddable-radius)",
@@ -105,7 +286,7 @@ export function renderWebView (src: string, view: ExcalidrawView, id: string, _:
className="excalidraw__embeddable"
title="Excalidraw Embedded Content"
allowFullScreen={true}
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
src={isDataURL ? null : src}
style={{
overflow: "hidden",
@@ -158,7 +339,7 @@ function RenderObsidianView(
}, [element]);
//--------------------------------------------------------------------------------
//block propagation of events to the parent if the iframe element is active
//block propagation of events to the parent if the embeddable element is active
//--------------------------------------------------------------------------------
const stopPropagation = React.useCallback((event:React.PointerEvent<HTMLElement>) => {
if(isActiveRef.current) {
@@ -185,7 +366,7 @@ function RenderObsidianView(
}; //cleanup on unmount
}, []);
//blocking or not the propagation of events to the parent if the iframe is active
//blocking or not the propagation of events to the parent if the embeddable element is active
React.useEffect(() => {
EXTENDED_EVENT_TYPES.forEach((type) => containerRef.current.removeEventListener(type, stopPropagation));
if(!containerRef?.current) {
@@ -257,8 +438,9 @@ function RenderObsidianView(
editNode: null,
};
patchMobileView(view);
//if subpath is defined, create a canvas node else create a workspace leaf
if(subpath && view.canvasNodeFactory.isInitialized()) {
if(subpath && view.canvasNodeFactory.isInitialized() && file.extension.toLowerCase() === "md") {
setKeepOnTop();
leafRef.current.node = view.canvasNodeFactory.createFileNote(file, subpath, containerRef.current, element.id);
view.updateEmbeddableLeafRef(element.id, leafRef.current);
@@ -287,124 +469,16 @@ function RenderObsidianView(
containerRef.current.appendChild(rootSplit.containerEl);
setColors(containerRef.current, element, mdProps, canvasColor, viewType);
}
patchMobileView(view);
view.updateEmbeddableLeafRef(element.id, leafRef.current);
if(viewType === "pdf") {
const pdfView = leafRef.current.leaf.view;
// Disable observer while applying the theme to avoid loops
pdfObserverDisabledRef.current = true;
setPDFViewTheme(view, pdfView);
requestAnimationFrame(() => { pdfObserverDisabledRef.current = false; });
// Transform-aware MMB drag-to-scroll (bypasses Chromium autoscroll)
const scroller = pdfView.contentEl?.querySelector(".pdf-viewer-container") || null;
let active = false;
let lastX = 0, lastY = 0;
let scaleX = 1, scaleY = 1;
const getScaleFromAncestor = (target: Element | null) => {
// Read scale from the outer excalidraw embeddable container transform
const container = target?.closest(".excalidraw__embeddable-container") as HTMLElement | null;
if (!container) return { sx: 1, sy: 1 };
const t = getComputedStyle(container).transform;
// t can be "none", "matrix(a,b,c,d,tx,ty)" or "matrix3d(...)"
if (!t || t === "none") return { sx: 1, sy: 1 };
if (t.startsWith("matrix3d(")) {
// matrix3d: m11=a1, m12=b1, m21=a2, m22=b2 in the first 6 entries
const m = t.slice(9, -1).split(",").map(Number);
const a = m[0], b = m[1], c = m[4], d = m[5];
// scaleX = length of first column, scaleY = length of second column
return { sx: Math.hypot(a, b) || 1, sy: Math.hypot(c, d) || 1 };
}
if (t.startsWith("matrix(")) {
const m = t.slice(7, -1).split(",").map(Number); // [a,b,c,d,tx,ty]
const a = m[0], b = m[1], c = m[2], d = m[3];
return { sx: Math.hypot(a, b) || 1, sy: Math.hypot(c, d) || 1 };
}
return { sx: 1, sy: 1 };
};
const onPointerDownCapture = (e: PointerEvent) => {
if (e.button !== 1 || !scroller) return;
// Start custom pan, cancel browser autoscroll and prevent Excalidraw from handling it.
e.preventDefault();
e.stopPropagation();
active = true;
lastX = e.clientX;
lastY = e.clientY;
const { sx, sy } = getScaleFromAncestor(scroller);
scaleX = sx;
scaleY = sy;
// Listen on window so we keep panning even if we leave the element.
window.addEventListener("pointermove", onPointerMove, { capture: true });
window.addEventListener("pointerup", onPointerUp, { capture: true, once: true });
window.addEventListener("pointercancel", onPointerUp, { capture: true, once: true });
try { (view.contentEl as HTMLElement).style.cursor = "grabbing"; } catch {}
};
const onPointerMove = (e: PointerEvent) => {
if (!active || !scroller) return;
// Only continue while MMB is held (bit 3 = 4)
if ((e.buttons & 4) === 0) return;
const dx = e.clientX - lastX;
const dy = e.clientY - lastY;
lastX = e.clientX;
lastY = e.clientY;
// Convert viewport dx/dy to local CSS px by dividing by scale.
scroller.scrollLeft -= dx / (scaleX || 1);
scroller.scrollTop -= dy / (scaleY || 1);
e.preventDefault();
e.stopPropagation();
};
const onPointerUp = (_e: PointerEvent) => {
active = false;
try { (view.contentEl as HTMLElement).style.cursor = ""; } catch {}
window.removeEventListener("pointermove", onPointerMove, { capture: true } as any);
window.removeEventListener("pointerup", onPointerUp, { capture: true } as any);
window.removeEventListener("pointercancel", onPointerUp,{ capture: true } as any);
};
const root = pdfView.contentEl as HTMLElement;
root?.addEventListener("pointerdown", onPointerDownCapture, { capture: true });
const cleanupPan = () => {
root?.removeEventListener("pointerdown", onPointerDownCapture, { capture: true } as any);
window.removeEventListener("pointermove", onPointerMove, { capture: true } as any);
window.removeEventListener("pointerup", onPointerUp, { capture: true } as any);
window.removeEventListener("pointercancel", onPointerUp,{ capture: true } as any);
};
(pdfObserverRef as any).currentCleanup = () => { cleanupPan(); };
if (view.excalidrawData.embeddableTheme !== "default") {
const pdfContainerEl = pdfView.contentEl?.querySelector(".pdf-container") as HTMLElement | null;
if (pdfContainerEl) {
pdfObserverRef.current?.disconnect();
pdfObserverRef.current = new MutationObserver(() => {
if (pdfObserverDisabledRef.current) return;
pdfObserverDisabledRef.current = true;
try {
setPDFViewTheme(view, pdfView);
if(view.excalidrawData.embeddableTheme !== "default") {
showNoticeOnce(t("NOTICE_PDF_THEME"));
}
} finally {
requestAnimationFrame(() => { pdfObserverDisabledRef.current = false; });
}
});
pdfObserverRef.current.observe(pdfContainerEl, {
attributes: true,
attributeFilter: ["class"],
});
}
}
// Moved PDF setup logic into a helper for readability
setupPdfViewEnhancements(
view,
leafRef as React.MutableRefObject<{ leaf: WorkspaceLeaf; node?: ObsidianCanvasNode; editNode?: Function } | null>,
pdfObserverRef as unknown as React.MutableRefObject<MutationObserver | null> & { currentCleanup?: () => void },
pdfObserverDisabledRef
);
}
})();
}
@@ -559,10 +633,10 @@ function RenderObsidianView(
event?.stopPropagation();
}
if(isActiveRef.current && leafRef.current?.leaf) {
/*if(isActiveRef.current && leafRef.current?.leaf) {
setKeepOnTop();
view.app.workspace.setActiveLeaf(leafRef.current.leaf, { focus: true });
}
}*/
if (isActiveRef.current && !isEditingRef.current && leafRef.current?.leaf) {
if(leafRef.current.leaf.view?.getViewType() === "markdown") {
@@ -578,9 +652,9 @@ function RenderObsidianView(
if (!modes) {
return;
}
patchMobileView(view);
leafRef.current.leaf.view.setMode(modes['source']);
isEditingRef.current = true;
patchMobileView(view);
} else if (leafRef.current?.node) {
//Handle canvas node
const newTheme = getTheme(view, themeRef.current);
@@ -590,7 +664,15 @@ function RenderObsidianView(
}
}, [leafRef.current?.leaf, element.id, view, themeRef.current, isActiveRef.current, isEditingRef.current]);
if(leafRef.current) leafRef.current.editNode = handleClick;
const startEditing = React.useCallback(() => {
if(isActiveRef.current && isEditingRef.current) {
return;
}
isActiveRef.current = true;
handleClick();
}, [isActiveRef.current, isEditingRef.current, handleClick]);
if(leafRef.current) leafRef.current.editNode = startEditing;
// Event listener for key press
React.useEffect(() => {
const handleKeyPress = (event: KeyboardEvent) => {
@@ -603,7 +685,7 @@ function RenderObsidianView(
}
// Existing Enter behavior
if (event.key === "Enter" && !isActiveRef.current) {
handleClick(event); // Call handleClick function when Enter key is pressed
startEditing(); // Call handleClick function when Enter key is pressed
}
};
@@ -631,10 +713,10 @@ function RenderObsidianView(
return;
}
if(leafRef.current?.leaf) {
/*if(leafRef.current?.leaf) {
setKeepOnTop();
view.app.workspace.setActiveLeaf(leafRef.current.leaf, { focus: true });
}
}*/
if(file !== view.file) {
setFileToLocalGraph(view.app, file);
@@ -696,6 +778,7 @@ export const CustomEmbeddable: React.FC<{element: ExcalidrawEmbeddableElement; v
height: `100%`,
borderRadius: "var(--embeddable-radius)",
color: `var(--text-normal)`,
touchAction: "auto",
}}
className={`${theme} canvas-node ${
mdProps?.filenameVisible && !mdProps.useObsidianDefaults ? "" : "excalidraw-mdEmbed-hideFilename"}`}
@@ -10,9 +10,9 @@ import { ScriptEngine } from "../../../shared/Scripts";
import { MD_EX_SECTIONS, ROOTELEMENTSIZE, nanoid, sceneCoordsToViewportCoords } from "src/constants/constants";
import { REGEX_LINK, REG_LINKINDEX_HYPERLINK } from "../../../shared/ExcalidrawData";
import { processLinkText, useDefaultExcalidrawFrame } from "src/utils/customEmbeddableUtils";
import { cleanSectionHeading } from "src/utils/obsidianUtils";
import { cleanSectionHeading, getActivePDFPageNumberFromPDFView } from "src/utils/obsidianUtils";
import { EmbeddableSettings } from "src/shared/Dialogs/EmbeddableSettings";
import { openExternalLink } from "src/utils/excalidrawViewUtils";
import { insertImageToView, openExternalLink } from "src/utils/excalidrawViewUtils";
import { getEA } from "src/core";
import { ExcalidrawAutomate } from "src/shared/ExcalidrawAutomate";
import { CaptureUpdateAction } from "src/constants/constants";
@@ -40,7 +40,7 @@ export class EmbeddableMenu {
this.renderButtons = null;
}
private updateElement = (subpath: string, element: ExcalidrawEmbeddableElement, file: TFile) => {
private updateElement = async (subpath: string, element: ExcalidrawEmbeddableElement, file: TFile, save: boolean = true) => {
if(!element) return;
const view = this.view;
const app = view.app;
@@ -56,7 +56,8 @@ export class EmbeddableMenu {
ea.copyViewElementsToEAforEditing([element]);
ea.getElement(element.id).link = link;
view.excalidrawData.elementLinks.set(element.id, link);
ea.addElementsToView(false, true, true).then(() => ea.destroy());
await ea.addElementsToView(false, save, true);
ea.destroy();
}
private handleMouseEnter () {
@@ -119,6 +120,46 @@ export class EmbeddableMenu {
}
}
private actionBookmarkPage (element: ExcalidrawEmbeddableElement) {
if(!element) return;
const pdfView = this.view.getEmbeddableLeafElementById(element.id)?.node?.child;
if(!pdfView) return;
const page = getActivePDFPageNumberFromPDFView(pdfView);
if(!page) return;
const pdfFile: TFile = pdfView?.file;
if(!pdfFile) return;
this.updateElement(`#page=${page}`, element, pdfFile, false);
}
private async actionInsertPageAsImage (element: ExcalidrawEmbeddableElement) {
if(!element) return;
const pdfView = this.view.getEmbeddableLeafElementById(element.id)?.node?.child;
if(!pdfView) return;
const page = getActivePDFPageNumberFromPDFView(pdfView);
if(!page) return;
const pdfFile: TFile = pdfView?.file;
if(!pdfFile) return;
const ea = getEA(this.view) as ExcalidrawAutomate;
ea.selectElementsInView([]);
const x = element.x + element.width + 20;
const y = element.y;
const path = this.view.app.metadataCache.fileToLinktext(
pdfFile,
this.view.file.path,
false,
)
const id = await insertImageToView(
ea,
{x,y},
`${path}#page=${page}`,
undefined,
undefined,
false,
);
ea.selectElementsInView([id]);
ea.destroy();
}
private async actionMarkdownBlock (file: TFile, subpath: string, element: ExcalidrawEmbeddableElement) {
if(!file) return;
this.view.updateScene({appState: {activeEmbeddable: null}, captureUpdate: CaptureUpdateAction.NEVER});
@@ -298,12 +339,26 @@ export class EmbeddableMenu {
icon={ICONS.Properties}
/>
{isPDF && (
<ActionButton
key={"Crop"}
title={t("CROP_PAGE")}
action={() => this.actionCrop(element)}
icon={ICONS.Crop}
/>
<>
<ActionButton
key={"Crop"}
title={t("CROP_PAGE")}
action={() => this.actionCrop(element)}
icon={ICONS.Crop}
/>
<ActionButton
key={"Bookmark"}
title={t("BOOKMARK_PAGE")}
action={() => this.actionBookmarkPage(element)}
icon={ICONS.Bookmark}
/>
<ActionButton
key={"Camera"}
title={t("CAPTURE_PAGE")}
action={() => this.actionInsertPageAsImage(element)}
icon={ICONS.Camera}
/>
</>
)}
</div>
</div>
+4 -2
View File
@@ -498,7 +498,7 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
<fieldset>
<legend>Utility actions</legend>
<div className="buttonList buttonListIcon">
<ActionButton
<ActionButton
key={"scriptEngine"}
title={t("INSTALL_SCRIPT_BUTTON")}
action={this.actionOpenScriptInstallDialog.bind(this)}
@@ -517,7 +517,7 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
action={(this.actionConvertExcalidrawToMD.bind(this))}
icon={ICONS.convertFile}
/>
) : (
) : !this.state.isPreviewMode && (
<ActionButton
key={"viewmode"}
title={this.state.isPreviewMode ? t("PARSED") : t("RAW")}
@@ -549,6 +549,8 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
: ICONS.gotoFullScreen
}
/>
</div>
<div className="buttonList buttonListIcon">
<ActionButton
key={"search"}
title={t("SEARCH")}
+14
View File
@@ -865,4 +865,18 @@ textarea.excalidraw-wysiwyg, .excalidraw input {
.excalidraw__embeddable-container .mod-nofilter canvas {
filter: none !important;
}
.excalidraw__embeddable-container .canvas-node.is-selected .canvas-node-container,
.excalidraw__embeddable-container .canvas-node.is-focused .canvas-node-container {
border-color: inherit;
box-shadow: inherit;
}
.excalidraw__embeddable-container .pdf-toolbar-right {
display: none;
}
.excalidraw-scriptengine-install .modal-close-button {
z-index: 9999;
}