This commit is contained in:
zsviczian committed 2026-08-31 21:43:14 +02:00
1 parent 59f655ed46
commit 052dfe3c12
3 files changed
+47 -10

No files matched your search

+1
View File
@@ -23,6 +23,7 @@ I build this plugin as a labor of love. Curious about the philosophy behind it?
- Prefer the previous experience? Turn off **Use searchable settings** at the top of Excalidraw settings and restart Obsidian. Older Obsidian versions continue using the legacy single-page layout automatically.
- Settings exposed by installed Excalidraw Automate scripts have moved to **Excalidraw Automate → Settings for installed scripts** and update when a script adds or changes its settings.
- Excalidraw Automate can optionally load and monitor JavaScript (\`.js\`) files in the Scripts folder, use an explicit \`.js\` startup script, and store Script Library downloads as either Markdown or JavaScript. Existing scripts can be moved between the two formats while updating startup and pinned-script paths. [#2901](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2901)
- Markdown notes created from unresolved links in a drawing now follow Obsidian's **Default location for new notes** setting. [#2916](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2916)
## New from Excalidraw.com
- Improved bucket tool and eyedropper support. [#11849](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/11849)
+45 -10
View File
@@ -5,6 +5,7 @@ import {
FuzzyMatch,
FuzzySuggestModal,
Instruction,
normalizePath,
TFile,
Notice,
TextAreaComponent,
@@ -1096,6 +1097,7 @@ export class NewFileActions extends Modal {
private openNewFile: boolean;
private parentFile: TFile;
private sourceElement: ExcalidrawElement;
private followObsidianNewNoteLocation: boolean;
constructor({
plugin,
@@ -1105,6 +1107,7 @@ export class NewFileActions extends Modal {
openNewFile = true,
parentFile,
sourceElement,
followObsidianNewNoteLocation = false,
}: {
plugin: ExcalidrawPlugin;
path: string;
@@ -1113,6 +1116,7 @@ export class NewFileActions extends Modal {
openNewFile?: boolean;
parentFile?: TFile;
sourceElement?: ExcalidrawElement;
followObsidianNewNoteLocation?: boolean;
}) {
super(plugin.app);
this.plugin = plugin;
@@ -1122,6 +1126,7 @@ export class NewFileActions extends Modal {
this.openNewFile = openNewFile;
this.sourceElement = sourceElement;
this.parentFile = parentFile ?? view.file;
this.followObsidianNewNoteLocation = followObsidianNewNoteLocation;
this.waitForClose = new Promise<TFile | null>((resolve, reject) => {
this.resolvePromise = resolve;
this.rejectPromise = reject;
@@ -1183,15 +1188,42 @@ export class NewFileActions extends Modal {
return true;
};
const createFile = async (data: string): Promise<TFile> => {
if (!this.path.includes("/")) {
const re = new RegExp(`${escapeRegExp(this.parentFile.name)}$`, "g");
this.path = this.parentFile.path.replace(re, this.path);
const createFile = async (
data: string,
useObsidianNewNoteLocation: boolean,
): Promise<TFile> => {
let path = this.path;
if (!path.match(/\.md$/)) {
path = `${path}.md`;
}
if (!this.path.match(/\.md$/)) {
this.path = `${this.path}.md`;
if (!path.includes("/")) {
if (
useObsidianNewNoteLocation &&
this.followObsidianNewNoteLocation
) {
const newFileLocation = this.app.vault.getConfig("newFileLocation");
let targetFolder = this.parentFile.parent?.path ?? "";
if (newFileLocation === "root") {
targetFolder = "";
} else if (newFileLocation === "folder") {
const configuredFolder = this.app.vault.getConfig(
"newFileFolderPath",
);
targetFolder =
typeof configuredFolder === "string" ? configuredFolder : "";
}
path = normalizePath(
targetFolder ? `${targetFolder}/${path}` : path,
);
} else {
const re = new RegExp(
`${escapeRegExp(this.parentFile.name)}$`,
"g",
);
path = this.parentFile.path.replace(re, path);
}
}
return await createOrOverwriteFile(this.app, this.path, data);
return await createOrOverwriteFile(this.app, path, data);
};
if (this.sourceElement) {
@@ -1203,7 +1235,7 @@ export class NewFileActions extends Modal {
if (!checks) {
return;
}
const f = await createFile("");
const f = await createFile("", true);
if (f) {
const ea: ExcalidrawAutomate = getEA(this.view);
ea.copyViewElementsToEAforEditing([this.sourceElement]);
@@ -1231,7 +1263,7 @@ export class NewFileActions extends Modal {
if (!checks) {
return;
}
const f = await createFile("");
const f = await createFile("", true);
this.openFile(f);
this.close();
};
@@ -1244,7 +1276,10 @@ export class NewFileActions extends Modal {
if (!checks) {
return;
}
const f = await createFile(await this.plugin.getBlankDrawing());
const f = await createFile(
await this.plugin.getBlankDrawing(),
false,
);
await sleep(200); //wait for metadata cache to update, so file opens as excalidraw
this.openFile(f);
this.close();
@@ -565,6 +565,7 @@ export class ViewLinkNavigationManager {
keys,
view: this.view,
sourceElement: el,
followObsidianNewNoteLocation: true,
}).open();
return;
}