generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathTokenEvaluatorContext.ts
More file actions
203 lines (168 loc) · 3.43 KB
/
TokenEvaluatorContext.ts
File metadata and controls
203 lines (168 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import type {
App,
FileStats
} from 'obsidian';
/**
* An action context.
*/
export enum ActionContext {
/**
* Collect attachments.
*/
CollectAttachments = 'CollectAttachments',
/**
* Delete note.
*/
DeleteNote = 'DeleteNote',
/**
* Import files.
*/
ImportFiles = 'ImportFiles',
/**
* Move attachment to proper folder.
*/
MoveAttachmentToProperFolder = 'MoveAttachmentToProperFolder',
/**
* Open file.
*/
OpenFile = 'OpenFile',
/**
* Rename note.
*/
RenameNote = 'RenameNote',
/**
* Save attachment.
*/
SaveAttachment = 'SaveAttachment',
/**
* Unknown.
*/
Unknown = 'Unknown',
/**
* Validate tokens.
*/
ValidateTokens = 'ValidateTokens'
}
/**
* Context passed to token evaluators.
*/
export interface TokenEvaluatorContext {
/**
* An abort signal to control the execution of the function.
*/
abortSignal: AbortSignal;
/**
* An action context.
*/
actionContext: ActionContext;
/**
* An Obsidian app instance.
*/
app: App;
/**
* A content of the attachment file.
*
* `undefined` if the attachment file content is not known.
*/
attachmentFileContent: ArrayBuffer | undefined;
/**
* Stats of the attachment file.
*
* `undefined` if the attachment file stats is not known.
*
* @remark It may be initialized only partially. Uninitialized {@link FileStats.ctime} and {@link FileStats.mtime} will be `0`.
*/
attachmentFileStat: FileStats | undefined;
/**
* Fills a template with the current context.
*/
fillTemplate(template: string): Promise<string>;
/**
* The format of the token.
*/
format: string;
/**
* A full template string.
*/
fullTemplate: string;
/**
* A generated attachment file name.
*
* Empty string if the attachment file name is not fully generated yet.
*/
generatedAttachmentFileName: string;
/**
* A generated attachment file path.
*
* Empty string if the attachment file path is not fully generated yet.
*/
generatedAttachmentFilePath: string;
/**
* A name of the note file.
*/
noteFileName: string;
/**
* A path of the note file.
*/
noteFilePath: string;
/**
* A name of the note folder.
*/
noteFolderName: string;
/**
* A path of the note folder.
*/
noteFolderPath: string;
/**
* An Obsidian API.
*
* {@link https://github.com/obsidianmd/obsidian-api/blob/master/obsidian.d.ts}
*/
obsidian: typeof import('obsidian');
/**
* A name of the old note file.
*/
oldNoteFileName: string;
/**
* A path of the old note file.
*/
oldNoteFilePath: string;
/**
* A name of the old note folder.
*/
oldNoteFolderName: string;
/**
* A path of the old note folder.
*/
oldNoteFolderPath: string;
/**
* An extension of the original attachment file.
*/
originalAttachmentFileExtension: string;
/**
* A name of the original attachment file.
*/
originalAttachmentFileName: string;
/**
* A sequence number of the attachment file.
*
* `0` if the sequence number is not known.
*/
sequenceNumber: number;
/**
* A token being evaluated.
*/
token: string;
/**
* An end offset of the token within the full template.
*/
tokenEndOffset: number;
/**
* A start offset of the token within the full template.
*/
tokenStartOffset: number;
/**
* A token with the format.
*/
tokenWithFormat: string;
}