File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -36,10 +36,10 @@ export class JsMDRC extends MarkdownRenderChild {
3636
3737 buildExecutionContext ( ) : JsExecutionContext {
3838 // console.log(this.ctx);
39- const file = this . getExecutionFile ( ) ! ;
39+ const file = this . getExecutionFile ( ) ;
4040 return {
4141 file : file ,
42- metadata : this . plugin . app . metadataCache . getFileCache ( file ) ,
42+ metadata : file === undefined ? undefined : this . plugin . app . metadataCache . getFileCache ( file ) ?? undefined ,
4343 block : undefined ,
4444 } ;
4545 }
Original file line number Diff line number Diff line change @@ -68,6 +68,11 @@ export class InternalAPI {
6868 }
6969 }
7070
71+ /**
72+ * Gets the execution context for a specific file, throws when the file does not exist.
73+ *
74+ * @param path
75+ */
7176 public async getContextForFile ( path : string ) : Promise < JsExecutionContext > {
7277 const file = this . apiInstance . app . vault . getAbstractFileByPath ( path ) ;
7378 if ( ! file || ! ( file instanceof TFile ) ) {
@@ -78,7 +83,7 @@ export class InternalAPI {
7883
7984 return {
8085 file : file ,
81- metadata : metadata ,
86+ metadata : metadata ?? undefined ,
8287 block : undefined ,
8388 } ;
8489 }
Original file line number Diff line number Diff line change @@ -18,11 +18,11 @@ export interface JsExecutionContext {
1818 /**
1919 * The file that the execution was triggered from.
2020 */
21- file : TFile ;
21+ file : TFile | undefined ;
2222 /**
2323 * The metadata of the file that the execution was triggered from.
2424 */
25- metadata : CachedMetadata | null ;
25+ metadata : CachedMetadata | undefined ;
2626 /**
2727 * Currently unused.
2828 */
You can’t perform that action at this time.
0 commit comments