Skip to content

Commit 74fec55

Browse files
committed
fix(capture): allow vault picker and clear stale canvas node ids
1 parent 66965a0 commit 74fec55

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/engine/CaptureChoiceEngine.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,12 @@ export class CaptureChoiceEngine extends QuickAddChoiceEngine {
314314
return null;
315315
}
316316

317-
invariant(
318-
this.choice.captureTo?.trim().length > 0,
319-
"Canvas node capture requires a target .canvas file path.",
320-
);
317+
const rawCaptureTo = this.choice.captureTo?.trim() ?? "";
318+
if (!rawCaptureTo) {
319+
return null;
320+
}
321321

322-
const targetPath = await this.formatFilePath(this.choice.captureTo);
322+
const targetPath = await this.formatFilePath(rawCaptureTo);
323323
const isCanvasTarget = CANVAS_FILE_EXTENSION_REGEX.test(targetPath);
324324
const nodeId = this.choice.captureToCanvasNodeId?.trim() ?? "";
325325

src/gui/ChoiceBuilder/captureChoiceBuilder.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,17 @@ export class CaptureChoiceBuilder extends ChoiceBuilder {
208208
(el) => new FormatSyntaxSuggester(this.app, el, this.plugin),
209209
],
210210
onChange: async (value) => {
211+
const previousCanvasPath = this.normalizeVaultPath(this.choice.captureTo);
211212
const wasCanvasTarget = this.isCanvasTargetPath(this.choice.captureTo);
212213
this.choice.captureTo = value;
214+
const nextCanvasPath = this.normalizeVaultPath(value);
213215
const isCanvasTarget = this.isCanvasTargetPath(value);
216+
const canvasPathChanged =
217+
wasCanvasTarget &&
218+
isCanvasTarget &&
219+
previousCanvasPath !== nextCanvasPath;
214220

215-
if (!isCanvasTarget) {
221+
if (!isCanvasTarget || canvasPathChanged) {
216222
this.choice.captureToCanvasNodeId = "";
217223
}
218224

@@ -222,7 +228,7 @@ export class CaptureChoiceBuilder extends ChoiceBuilder {
222228
formatDisplay.textContent = "Preview unavailable";
223229
}
224230

225-
if (wasCanvasTarget !== isCanvasTarget) {
231+
if (wasCanvasTarget !== isCanvasTarget || canvasPathChanged) {
226232
this.reload();
227233
}
228234
},

0 commit comments

Comments
 (0)