Skip to content

Commit 6434a6e

Browse files
committed
2.13.1
1 parent 68180db commit 6434a6e

8 files changed

Lines changed: 71 additions & 8 deletions

File tree

manifest-beta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"id": "obsidian-excalidraw-plugin",
33
"name": "Excalidraw",
4-
"version": "2.13.0",
5-
"minAppVersion": "1.5.7",
4+
"version": "2.13.1",
5+
"minAppVersion": "1.5.7",
66
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
77
"author": "Zsolt Viczian",
88
"authorUrl": "https://excalidraw-obsidian.online",

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian-excalidraw-plugin",
33
"name": "Excalidraw",
4-
"version": "2.13.0",
4+
"version": "2.13.1",
55
"minAppVersion": "1.5.7",
66
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
77
"author": "Zsolt Viczian",

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lang/locale/en.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,8 +921,12 @@ FILENAME_HEAD: "Filename",
921921

922922
//IFrameActionsMenu.tsx
923923
NARROW_TO_HEADING: "Narrow to heading...",
924+
PIN_VIEW: "Pin view",
925+
DO_NOT_PIN_VIEW: "Do not pin view",
924926
NARROW_TO_BLOCK: "Narrow to block...",
925927
SHOW_ENTIRE_FILE: "Show entire file",
928+
SELECT_SECTION: "Select section from document",
929+
SELECT_VIEW: "Select view from base",
926930
ZOOM_TO_FIT: "Zoom to fit",
927931
RELOAD: "Reload original link",
928932
OPEN_IN_BROWSER: "Open current link in browser",

src/shared/Dialogs/Messages.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ I build this plugin in my free time, as a labor of love. Curious about the philo
1717
1818
<div class="ex-coffee-div"><a href="https://ko-fi.com/zsolt"><img src="https://storage.ko-fi.com/cdn/kofi6.png?v=6" border="0" alt="Buy Me a Coffee at ko-fi.com" height=45></a></div>
1919
`,
20+
"2.13.1":`
21+
## New
22+
- Support for Obsidian bases as embeddables in Excalidraw.
23+
- **Note:** The feature is only available to Insiders who have Obsidian 1.9.4 or later installed.
24+
- If your base includes multiple views you can pin the desired view similar to filtering to a section (click top left # button; \`[[my.base|my view]]\`).
25+
26+
## Fixed
27+
- Cannot type in embedded web forms. In certain cases, typing within these embeds would trigger Excalidraw hotkeys instead of interacting with the embedded content. [#2403](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2403)
28+
`,
2029
"2.13.0":`
2130
<div class="excalidraw-videoWrapper"><div>
2231
<iframe src="https://www.youtube.com/embed/QzhyQb4JF3Q" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

src/view/ExcalidrawView.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,9 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
17081708
if(!this.excalidrawAPI || !this.excalidrawData.loaded || !this.isDirty()) {
17091709
return;
17101710
}
1711-
if((this.excalidrawAPI as ExcalidrawImperativeAPI).getAppState().activeTool.type !== "image") {
1711+
const api = this.excalidrawAPI as ExcalidrawImperativeAPI;
1712+
const st = api.getAppState();
1713+
if(st.activeTool.type !== "image" && st.activeEmbeddable?.state !== "active") {
17121714
this.forceSave(true);
17131715
}
17141716
};

src/view/components/CustomEmbeddable.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { ObsidianCanvasNode } from "src/view/managers/CanvasNodeFactory";
99
import { processLinkText, patchMobileView, setFileToLocalGraph } from "src/utils/customEmbeddableUtils";
1010
import { EmbeddableMDCustomProps } from "src/shared/Dialogs/EmbeddableSettings";
1111

12+
const CANVAS_VIEWTYPES = new Set(["markdown", "bases"]);
13+
1214
declare module "obsidian" {
1315
interface Workspace {
1416
floatingSplit: any;
@@ -223,7 +225,7 @@ function RenderObsidianView(
223225
if(viewType === "canvas") {
224226
leafRef.current.leaf.view.canvas?.setReadonly(true);
225227
}
226-
if ((viewType === "markdown") && view.canvasNodeFactory.isInitialized()) {
228+
if (CANVAS_VIEWTYPES.has(viewType) && view.canvasNodeFactory.isInitialized()) {
227229
setKeepOnTop();
228230
//I haven't found a better way of deciding if an .md file has its own view (e.g., kanban) or not
229231
//This runs only when the file is added, thus should not be a major performance issue
@@ -295,6 +297,22 @@ function RenderObsidianView(
295297
canvasNode?.style.setProperty("--background-primary", color);
296298
canvasNodeContainer?.style.setProperty("background-color", color);
297299
}
300+
canvasNode?.style.setProperty("--bases-cards-container-background","var(--background-primary)");
301+
canvasNode?.style.setProperty("--bases-embed-border-color","var(--background-modifier-border)");
302+
canvasNode?.style.setProperty("--bases-table-header-color","var(--text-muted)");
303+
canvasNode?.style.setProperty("--bases-table-header-background","var(--background-primary)");
304+
canvasNode?.style.setProperty("--bases-table-header-background-hover","var(--background-modifier-hover)");
305+
canvasNode?.style.setProperty("--bases-table-header-sort-mask","linear-gradient(to left, transparent var(--size-4-6), black var(--size-4-6))");
306+
canvasNode?.style.setProperty("--bases-table-border-color","var(--table-border-color)");
307+
canvasNode?.style.setProperty("--bases-table-row-background-hover","var(--table-row-background-hover)");
308+
canvasNode?.style.setProperty("--bases-table-cell-shadow-active","0 0 0 2px var(--interactive-accent)");
309+
canvasNode?.style.setProperty("--bases-table-cell-background-active","var(--background-primary)");
310+
canvasNode?.style.setProperty("--bases-table-cell-background-disabled","var(--background-primary-alt)");
311+
canvasNode?.style.setProperty("--bases-cards-container-background","var(--background-primary)");
312+
canvasNode?.style.setProperty("--bases-cards-background","var(--background-primary)");
313+
canvasNode?.style.setProperty("--bases-cards-cover-background","var(--background-primary-alt)");
314+
canvasNode?.style.setProperty("--bases-cards-shadow","0 0 0 1px var(--background-modifier-border)");
315+
canvasNode?.style.setProperty("--bases-cards-shadow-hover","0 0 0 1px var(--background-modifier-border-hover)");
298316

299317
if(mdProps.borderMatchElement) {
300318
const opacity = (mdProps?.borderOpacity ?? 50)/100;

src/view/components/menu/EmbeddableActionsMenu.tsx

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,28 @@ export class EmbeddableMenu {
7070
}, 5000);
7171
};
7272

73+
private async actionBaseViewSelection (file: TFile, subpath: string, element: ExcalidrawEmbeddableElement) {
74+
this.view.updateScene({appState: {activeEmbeddable: null}, captureUpdate: CaptureUpdateAction.NEVER});
75+
const views = Array.from(
76+
(await this.view.app.vault.read(file)).matchAll(/\s*name\: (.*)$/gm)
77+
).map(x=>x?.[1]);
78+
let values, display;
79+
values = [""].concat(
80+
views.map((b: string) => `#${cleanSectionHeading(b)}`)
81+
);
82+
display = [t("DO_NOT_PIN_VIEW")].concat(
83+
views.map((b: string) => b)
84+
);
85+
86+
const newSubpath = await ScriptEngine.suggester(
87+
this.view.app, display, values, t("SELECT_VIEW")
88+
);
89+
if(!newSubpath && newSubpath!=="") return;
90+
if (newSubpath !== subpath) {
91+
this.updateElement(newSubpath, element, file);
92+
}
93+
}
94+
7395
private async actionMarkdownSelection (file: TFile, isExcalidrawFile: boolean, subpath: string, element: ExcalidrawEmbeddableElement) {
7496
this.view.updateScene({appState: {activeEmbeddable: null}, captureUpdate: CaptureUpdateAction.NEVER});
7597
const sections = (await this.view.app.metadataCache.blockCache
@@ -89,7 +111,7 @@ export class EmbeddableMenu {
89111
);
90112
}
91113
const newSubpath = await ScriptEngine.suggester(
92-
this.view.app, display, values, "Select section from document"
114+
this.view.app, display, values, t("SELECT_SECTION")
93115
);
94116
if(!newSubpath && newSubpath!=="") return;
95117
if (newSubpath !== subpath) {
@@ -110,7 +132,7 @@ export class EmbeddableMenu {
110132
paragraphs.map((b: any) => `${b.node?.id ? `#^${b.node.id}: ` : ``}${b.display.trim()}`));
111133

112134
const selectedBlock = await ScriptEngine.suggester(
113-
this.view.app, display, values, "Select section from document"
135+
this.view.app, display, values, t("SELECT_SECTION")
114136
);
115137
if(!selectedBlock) return;
116138

@@ -212,6 +234,7 @@ export class EmbeddableMenu {
212234
const { subpath, file } = processLinkText(link, view);
213235
if(!file) return;
214236
const isMD = file.extension==="md";
237+
const isBase = file.extension==="base";
215238
const isExcalidrawFile = view.plugin.isExcalidrawFile(file);
216239
const isPDF = file.extension==="pdf";
217240
const { x, y } = sceneCoordsToViewportCoords( { sceneX: element.x, sceneY: element.y }, appState);
@@ -238,6 +261,14 @@ export class EmbeddableMenu {
238261
display: "block",
239262
}}
240263
>
264+
{isBase && (
265+
<ActionButton
266+
key={"MarkdownSection"}
267+
title={t("PIN_VIEW")}
268+
action={async () => this.actionBaseViewSelection(file, subpath, element)}
269+
icon={ICONS.ZoomToSection}
270+
/>
271+
)}
241272
{isMD && (
242273
<ActionButton
243274
key={"MarkdownSection"}

0 commit comments

Comments
 (0)