obsidian-typings 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +15 -0
- package/LICENSE +21 -0
- package/README.md +36 -0
- package/dummy.ts +1 -0
- package/obsidian-ex.d.ts +3217 -0
- package/package.json +32 -0
- package/tsconfig.json +110 -0
package/obsidian-ex.d.ts
ADDED
|
@@ -0,0 +1,3217 @@
|
|
|
1
|
+
import {
|
|
2
|
+
App,
|
|
3
|
+
Command,
|
|
4
|
+
Component,
|
|
5
|
+
Constructor,
|
|
6
|
+
EditorRange,
|
|
7
|
+
Events,
|
|
8
|
+
KeymapInfo,
|
|
9
|
+
Loc,
|
|
10
|
+
Plugin,
|
|
11
|
+
Reference,
|
|
12
|
+
Scope,
|
|
13
|
+
SplitDirection,
|
|
14
|
+
TAbstractFile,
|
|
15
|
+
TFile,
|
|
16
|
+
TFolder,
|
|
17
|
+
Vault,
|
|
18
|
+
View,
|
|
19
|
+
ViewState,
|
|
20
|
+
Workspace,
|
|
21
|
+
WorkspaceLeaf,
|
|
22
|
+
} from 'obsidian';
|
|
23
|
+
import { EditorView } from '@codemirror/view';
|
|
24
|
+
import { EditorState, Extension } from '@codemirror/state';
|
|
25
|
+
import * as fs from 'fs';
|
|
26
|
+
import * as fsPromises from 'fs/promises';
|
|
27
|
+
import * as path from 'path';
|
|
28
|
+
import { IpcRenderer } from 'electron';
|
|
29
|
+
|
|
30
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
31
|
+
|
|
32
|
+
interface Account {
|
|
33
|
+
/**
|
|
34
|
+
* The company associated with the activated commercial license
|
|
35
|
+
*/
|
|
36
|
+
company: string;
|
|
37
|
+
/**
|
|
38
|
+
* The email address associated with the account
|
|
39
|
+
*/
|
|
40
|
+
email: string;
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
expiry: number;
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
*/
|
|
48
|
+
key: string | undefined;
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
keyValidation: string;
|
|
53
|
+
/**
|
|
54
|
+
* The license available to the account
|
|
55
|
+
*/
|
|
56
|
+
license: '' | 'insider';
|
|
57
|
+
/**
|
|
58
|
+
* Profile name
|
|
59
|
+
*/
|
|
60
|
+
name: string;
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
*/
|
|
64
|
+
seats: number;
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
token: string;
|
|
69
|
+
|
|
70
|
+
// TODO: Add Sync and Publish API functions here
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface AppVaultConfig {
|
|
74
|
+
/**
|
|
75
|
+
* Appearance > Accent color
|
|
76
|
+
*/
|
|
77
|
+
accentColor: '' | string;
|
|
78
|
+
/**
|
|
79
|
+
* Files & Links > Automatically update internal links
|
|
80
|
+
*/
|
|
81
|
+
alwaysUpdateLinks?: false | boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Files & Links > Attachment folder path
|
|
84
|
+
*/
|
|
85
|
+
attachmentFolderPath?: '/' | string;
|
|
86
|
+
/**
|
|
87
|
+
* Editor > Auto convert HTML
|
|
88
|
+
*/
|
|
89
|
+
autoConvertHtml?: true | boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Editor > Auto pair brackets
|
|
92
|
+
*/
|
|
93
|
+
autoPairBrackets?: true | boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Editor > Auto pair Markdown syntax
|
|
96
|
+
*/
|
|
97
|
+
autoPairMarkdown?: true | boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Appearance > Font size
|
|
100
|
+
*/
|
|
101
|
+
baseFontSize?: 16 | number;
|
|
102
|
+
/**
|
|
103
|
+
* Appearance > Quick font size adjustment
|
|
104
|
+
*/
|
|
105
|
+
baseFontSizeAction?: true | boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Community Plugins > Browse > Sort order
|
|
108
|
+
*/
|
|
109
|
+
communityPluginSortOrder: 'download' | 'update' | 'release' | 'alphabetical';
|
|
110
|
+
/**
|
|
111
|
+
* Themes > Browse > Sort order
|
|
112
|
+
*/
|
|
113
|
+
communityThemeSortOrder: 'download' | 'update' | 'release' | 'alphabetical';
|
|
114
|
+
/**
|
|
115
|
+
* Appearance > Theme
|
|
116
|
+
* @remark "" is the default Obsidian theme
|
|
117
|
+
*/
|
|
118
|
+
cssTheme?: '' | string;
|
|
119
|
+
/**
|
|
120
|
+
* Editor > Default view for new tabs
|
|
121
|
+
*/
|
|
122
|
+
defaultViewMode?: 'source' | 'preview';
|
|
123
|
+
/**
|
|
124
|
+
*
|
|
125
|
+
*/
|
|
126
|
+
emacsyKeys?: true | boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Appearance > CSS snippets
|
|
129
|
+
*/
|
|
130
|
+
enabledCssSnippets?: string[];
|
|
131
|
+
/**
|
|
132
|
+
*
|
|
133
|
+
*/
|
|
134
|
+
fileSortOrder?: 'alphabetical';
|
|
135
|
+
/**
|
|
136
|
+
* Editor > Always focus new tabs
|
|
137
|
+
*/
|
|
138
|
+
focusNewTab?: true | boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Editor > Fold heading
|
|
141
|
+
*/
|
|
142
|
+
foldHeading?: true | boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Editor > Fold indent
|
|
145
|
+
*/
|
|
146
|
+
foldIndent?: true | boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Hotkeys
|
|
149
|
+
* @deprecated Likely not used anymore
|
|
150
|
+
*/
|
|
151
|
+
hotkeys?: Record<string, string>;
|
|
152
|
+
/**
|
|
153
|
+
* Appearance > Interface font
|
|
154
|
+
*/
|
|
155
|
+
interfaceFontFamily?: '' | string;
|
|
156
|
+
/**
|
|
157
|
+
* Editor > Use legacy editor
|
|
158
|
+
*/
|
|
159
|
+
legacyEditor?: false | boolean;
|
|
160
|
+
/**
|
|
161
|
+
*
|
|
162
|
+
*/
|
|
163
|
+
livePreview?: true | boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Mobile > Configure mobile Quick Action
|
|
166
|
+
*/
|
|
167
|
+
mobilePullAction?: 'command-palette:open' | string;
|
|
168
|
+
/**
|
|
169
|
+
*
|
|
170
|
+
*/
|
|
171
|
+
mobileQuickRibbonItem?: '' | string;
|
|
172
|
+
/**
|
|
173
|
+
* Mobile > Manage toolbar options
|
|
174
|
+
*/
|
|
175
|
+
mobileToolbarCommands?: string[];
|
|
176
|
+
/**
|
|
177
|
+
*
|
|
178
|
+
*/
|
|
179
|
+
monospaceFontFamily?: '' | string;
|
|
180
|
+
/**
|
|
181
|
+
* Appearance > Native menus
|
|
182
|
+
*/
|
|
183
|
+
nativeMenus?: null | boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Files & Links > Default location for new notes | 'folder' > Folder to create new notes in
|
|
186
|
+
*/
|
|
187
|
+
newFileFolderPath?: '/' | string;
|
|
188
|
+
/**
|
|
189
|
+
* Files & Links > Default location for new notes
|
|
190
|
+
*/
|
|
191
|
+
newFileLocation?: 'root' | 'current' | 'folder';
|
|
192
|
+
/**
|
|
193
|
+
* Files & Links > New link format
|
|
194
|
+
*/
|
|
195
|
+
newLinkFormat?: 'shortest' | 'relative' | 'absolute';
|
|
196
|
+
/**
|
|
197
|
+
* Saved on executing 'Export to PDF' command
|
|
198
|
+
*/
|
|
199
|
+
pdfExportSettings?: {
|
|
200
|
+
pageSize: 'letter' | string;
|
|
201
|
+
landscape: false | boolean;
|
|
202
|
+
margin: '0' | string;
|
|
203
|
+
downscalePercent: 100 | number;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Files & Links > Confirm line deletion
|
|
207
|
+
*/
|
|
208
|
+
promptDelete?: true | boolean;
|
|
209
|
+
/**
|
|
210
|
+
* Editor > Properties in document
|
|
211
|
+
*/
|
|
212
|
+
propertiesInDocument?: 'visible' | 'hidden' | 'source'
|
|
213
|
+
/**
|
|
214
|
+
* Editor > Readable line length
|
|
215
|
+
*/
|
|
216
|
+
readableLineLength?: true | boolean;
|
|
217
|
+
/**
|
|
218
|
+
* Editor > Right-to-left (RTL)
|
|
219
|
+
*/
|
|
220
|
+
rightToLeft?: false | boolean;
|
|
221
|
+
/**
|
|
222
|
+
* @deprecated Removed as of version 1.4.3
|
|
223
|
+
*/
|
|
224
|
+
showFrontmatter?: false | boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Editor > Show indentation guides
|
|
227
|
+
*/
|
|
228
|
+
showIndentGuide?: true | boolean;
|
|
229
|
+
/**
|
|
230
|
+
* Editor > Show inline title
|
|
231
|
+
*/
|
|
232
|
+
showInlineTitle?: true | boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Editor > Show line numbers
|
|
235
|
+
*/
|
|
236
|
+
showLineNumber?: false | boolean;
|
|
237
|
+
/**
|
|
238
|
+
* Files & Links > Detect all file extensions
|
|
239
|
+
*/
|
|
240
|
+
showUnsupportedFiles?: false | boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Appearance > Show tab title bar
|
|
243
|
+
*/
|
|
244
|
+
showViewHeader?: false | boolean;
|
|
245
|
+
/**
|
|
246
|
+
* Editor > Smart indent lists
|
|
247
|
+
*/
|
|
248
|
+
smartIndentList?: true | boolean;
|
|
249
|
+
/**
|
|
250
|
+
* Editor > Spellcheck
|
|
251
|
+
*/
|
|
252
|
+
spellcheck?: false | boolean;
|
|
253
|
+
/**
|
|
254
|
+
* @deprecated
|
|
255
|
+
*/
|
|
256
|
+
spellcheckDictionary?: [] | string[];
|
|
257
|
+
/**
|
|
258
|
+
* Editor > Spellcheck languages
|
|
259
|
+
*/
|
|
260
|
+
spellcheckLanguages?: null | string[];
|
|
261
|
+
/**
|
|
262
|
+
* Editor > Strict line breaks
|
|
263
|
+
*/
|
|
264
|
+
strictLineBreaks?: false | boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Editor > Tab indent size
|
|
267
|
+
*/
|
|
268
|
+
tabSize?: 4 | number;
|
|
269
|
+
/**
|
|
270
|
+
* Appearance > Text font
|
|
271
|
+
*/
|
|
272
|
+
textFontFamily?: '' | string;
|
|
273
|
+
/**
|
|
274
|
+
* Appearance > Base color scheme
|
|
275
|
+
* @remark Not be confused with cssTheme, this setting is for the light/dark mode
|
|
276
|
+
* @remark "moonstone" is light theme, "obsidian" is dark theme
|
|
277
|
+
*/
|
|
278
|
+
theme?: 'moonstone' | 'obsidian';
|
|
279
|
+
/**
|
|
280
|
+
* Appearance > Translucent window
|
|
281
|
+
*/
|
|
282
|
+
translucency?: false | boolean;
|
|
283
|
+
/**
|
|
284
|
+
* Files & Links > Deleted files
|
|
285
|
+
*/
|
|
286
|
+
trashOption?: 'system' | 'local' | 'none';
|
|
287
|
+
/**
|
|
288
|
+
* @deprecated Probably left-over code from old properties type storage
|
|
289
|
+
*/
|
|
290
|
+
types: object;
|
|
291
|
+
/**
|
|
292
|
+
* Files & Links > Use [[Wikilinks]]
|
|
293
|
+
*/
|
|
294
|
+
useMarkdownLinks?: false | boolean;
|
|
295
|
+
/**
|
|
296
|
+
* Editor > Indent using tabs
|
|
297
|
+
*/
|
|
298
|
+
useTab?: true | boolean;
|
|
299
|
+
/**
|
|
300
|
+
* Files & Links > Excluded files
|
|
301
|
+
*/
|
|
302
|
+
userIgnoreFilters?: null | string[];
|
|
303
|
+
/**
|
|
304
|
+
* Editor > Vim key bindings
|
|
305
|
+
*/
|
|
306
|
+
vimMode?: false | boolean;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
interface BlockCache {
|
|
310
|
+
/**
|
|
311
|
+
* Reference to App
|
|
312
|
+
*/
|
|
313
|
+
app: App;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* @internal
|
|
317
|
+
*/
|
|
318
|
+
cache: any;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
interface CMState extends EditorState {
|
|
322
|
+
vim: {
|
|
323
|
+
inputState: {
|
|
324
|
+
changeQueue: null,
|
|
325
|
+
keyBuffer: [],
|
|
326
|
+
motion: null,
|
|
327
|
+
motionArgs: null,
|
|
328
|
+
motionRepeat: [],
|
|
329
|
+
operator: null,
|
|
330
|
+
operatorArgs: null,
|
|
331
|
+
prefixRepeat: [],
|
|
332
|
+
registerName: null,
|
|
333
|
+
},
|
|
334
|
+
insertMode: false,
|
|
335
|
+
insertModeRepeat: undefined,
|
|
336
|
+
lastEditActionCommand: undefined,
|
|
337
|
+
lastEditInputState: undefined,
|
|
338
|
+
lastHPos: number,
|
|
339
|
+
lastHSPos: number,
|
|
340
|
+
lastMotion: {
|
|
341
|
+
name?: string,
|
|
342
|
+
},
|
|
343
|
+
lastPastedText: null,
|
|
344
|
+
lastSelection: null,
|
|
345
|
+
},
|
|
346
|
+
vimPlugin: {
|
|
347
|
+
lastKeydown: string,
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
interface CMView extends EditorView {
|
|
352
|
+
state: CMState;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
interface Commands {
|
|
356
|
+
/**
|
|
357
|
+
* Reference to App
|
|
358
|
+
*/
|
|
359
|
+
app: App;
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Commands *without* editor callback, will always be available in the command palette
|
|
363
|
+
* @example `app:open-vault` or `app:reload`
|
|
364
|
+
*/
|
|
365
|
+
commands: Record<string, Command>;
|
|
366
|
+
/**
|
|
367
|
+
* Commands *with* editor callback, will only be available when editor is active and callback returns true
|
|
368
|
+
* @example `editor:fold-all` or `command-palette:open`
|
|
369
|
+
*/
|
|
370
|
+
editorCommands: Record<string, Command>;
|
|
371
|
+
/**
|
|
372
|
+
* Add a command to the command registry
|
|
373
|
+
* @param command Command to add
|
|
374
|
+
*/
|
|
375
|
+
addCommand(command: Command): void;
|
|
376
|
+
/**
|
|
377
|
+
* Execute a command by reference
|
|
378
|
+
* @param command Command to execute
|
|
379
|
+
*/
|
|
380
|
+
executeCommand(command: Command): boolean;
|
|
381
|
+
/**
|
|
382
|
+
* Execute a command by ID
|
|
383
|
+
* @param commandId ID of command to execute
|
|
384
|
+
*/
|
|
385
|
+
executeCommandById(commandId: string): boolean;
|
|
386
|
+
/**
|
|
387
|
+
* Find a command by ID
|
|
388
|
+
* @param commandId
|
|
389
|
+
*/
|
|
390
|
+
findCommand(commandId: string): Command | undefined;
|
|
391
|
+
/**
|
|
392
|
+
* Lists **all** commands, both with and without editor callback
|
|
393
|
+
*/
|
|
394
|
+
listCommands(): Command[];
|
|
395
|
+
/**
|
|
396
|
+
* Remove a command from the command registry
|
|
397
|
+
* @param commandId Command to remove
|
|
398
|
+
*/
|
|
399
|
+
removeCommand(commandId: string): void;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
type ConfigItem = 'accentColor'
|
|
403
|
+
| 'alwaysUpdateLinks'
|
|
404
|
+
| 'attachmentFolderPath'
|
|
405
|
+
| 'autoConvertHtml'
|
|
406
|
+
| 'autoPairBrackets'
|
|
407
|
+
| 'autoPairMarkdown'
|
|
408
|
+
| 'baseFontSize'
|
|
409
|
+
| 'baseFontSizeAction'
|
|
410
|
+
| 'cssTheme'
|
|
411
|
+
| 'defaultViewMode'
|
|
412
|
+
| 'emacsyKeys'
|
|
413
|
+
| 'enabledCssSnippets'
|
|
414
|
+
| 'fileSortOrder'
|
|
415
|
+
| 'focusNewTab'
|
|
416
|
+
| 'foldHeading'
|
|
417
|
+
| 'foldIndent'
|
|
418
|
+
| 'hotkeys'
|
|
419
|
+
| 'interfaceFontFamily'
|
|
420
|
+
| 'legacyEditor'
|
|
421
|
+
| 'livePreview'
|
|
422
|
+
| 'mobilePullAction'
|
|
423
|
+
| 'mobileQuickRibbonItem'
|
|
424
|
+
| 'mobileToolbarCommands'
|
|
425
|
+
| 'monospaceFontFamily'
|
|
426
|
+
| 'nativeMenus'
|
|
427
|
+
| 'newFileFolderPath'
|
|
428
|
+
| 'newFileLocation'
|
|
429
|
+
| 'newLinkFormat'
|
|
430
|
+
| 'pdfExportSettings'
|
|
431
|
+
| 'promptDelete'
|
|
432
|
+
| 'propertiesInDocument'
|
|
433
|
+
| 'readableLineLength'
|
|
434
|
+
| 'rightToLeft'
|
|
435
|
+
| 'showIndentGuide'
|
|
436
|
+
| 'showInlineTitle'
|
|
437
|
+
| 'showLineNumber'
|
|
438
|
+
| 'showUnsupportedFiles'
|
|
439
|
+
| 'showViewHeader'
|
|
440
|
+
| 'smartIndentList'
|
|
441
|
+
| 'spellcheck'
|
|
442
|
+
| 'spellcheckLanguages'
|
|
443
|
+
| 'strictLineBreaks'
|
|
444
|
+
| 'tabSize'
|
|
445
|
+
| 'textFontFamily'
|
|
446
|
+
| 'theme'
|
|
447
|
+
| 'translucency'
|
|
448
|
+
| 'trashOption'
|
|
449
|
+
| 'types'
|
|
450
|
+
| 'useMarkdownLinks'
|
|
451
|
+
| 'useTab'
|
|
452
|
+
| 'userIgnoreFilters'
|
|
453
|
+
| 'vimMode';
|
|
454
|
+
|
|
455
|
+
interface CustomArrayDict<T> {
|
|
456
|
+
data: Record<string, T[]>;
|
|
457
|
+
|
|
458
|
+
add(key: string, value: T): void;
|
|
459
|
+
remove(key: string, value: T): void;
|
|
460
|
+
removeKey(key: string): void;
|
|
461
|
+
get(key: string): T[] | null;
|
|
462
|
+
keys(): string[];
|
|
463
|
+
clear(key: string): void;
|
|
464
|
+
clearAll(): void;
|
|
465
|
+
contains(key: string, value: T): boolean;
|
|
466
|
+
count(): number;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
interface CustomCSS extends Component {
|
|
470
|
+
/**
|
|
471
|
+
* Reference to App
|
|
472
|
+
*/
|
|
473
|
+
app: App;
|
|
474
|
+
/**
|
|
475
|
+
* @internal
|
|
476
|
+
*/
|
|
477
|
+
boundRaw(): void;
|
|
478
|
+
/**
|
|
479
|
+
* @internal Cache of CSS snippet filepath (relative to vault root) to CSS snippet contents
|
|
480
|
+
*/
|
|
481
|
+
csscache: Map<string, string>;
|
|
482
|
+
/**
|
|
483
|
+
* Set of enabled snippet, given by filenames
|
|
484
|
+
*/
|
|
485
|
+
enabledSnippets: Set<string>;
|
|
486
|
+
/**
|
|
487
|
+
* @internal
|
|
488
|
+
* Contains references to Style elements containing custom CSS snippets
|
|
489
|
+
*/
|
|
490
|
+
extraStyleEls: HTMLStyleElement[];
|
|
491
|
+
/**
|
|
492
|
+
* List of theme names not fully updated to post v1.0.0 theme guidelines
|
|
493
|
+
*/
|
|
494
|
+
oldThemes: string[];
|
|
495
|
+
/**
|
|
496
|
+
* @internal
|
|
497
|
+
*/
|
|
498
|
+
queue: WeakMap<any, any>;
|
|
499
|
+
/**
|
|
500
|
+
* @internal
|
|
501
|
+
*/
|
|
502
|
+
requestLoadSnippets(): void;
|
|
503
|
+
/**
|
|
504
|
+
* @internal
|
|
505
|
+
*/
|
|
506
|
+
requestLoadTheme(): void;
|
|
507
|
+
/**
|
|
508
|
+
* @internal
|
|
509
|
+
*/
|
|
510
|
+
requestReadThemes(): void;
|
|
511
|
+
/**
|
|
512
|
+
* List of snippets detected by Obsidian, given by their filenames
|
|
513
|
+
*/
|
|
514
|
+
snippets: string[];
|
|
515
|
+
/**
|
|
516
|
+
* Currently active theme, given by its name
|
|
517
|
+
* @remark "" is the default Obsidian theme
|
|
518
|
+
*/
|
|
519
|
+
theme: '' | string;
|
|
520
|
+
/**
|
|
521
|
+
* Mapping of theme names to their manifest
|
|
522
|
+
*/
|
|
523
|
+
themes: Record<string, ThemeManifest>;
|
|
524
|
+
/**
|
|
525
|
+
* @internal
|
|
526
|
+
*/
|
|
527
|
+
updates: Record<string, any>;
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Check whether a specific theme can be updated
|
|
531
|
+
* @param themeName - Name of the theme to check
|
|
532
|
+
*/
|
|
533
|
+
checkForUpdate(themeName: string): void;
|
|
534
|
+
/**
|
|
535
|
+
* Check all themes for updates
|
|
536
|
+
*/
|
|
537
|
+
checkForUpdates(): void;
|
|
538
|
+
/**
|
|
539
|
+
* Disable translucency of application background
|
|
540
|
+
*/
|
|
541
|
+
disableTranslucency(): void;
|
|
542
|
+
/**
|
|
543
|
+
* Fetch legacy theme CSS using the pre-v1.0.0 theme download pipeline
|
|
544
|
+
* @returns string obsidian.css contents
|
|
545
|
+
*/
|
|
546
|
+
downloadLegacyTheme({ repo: string }): Promise<string>;
|
|
547
|
+
/**
|
|
548
|
+
* Enable translucency of application background
|
|
549
|
+
*/
|
|
550
|
+
enableTranslucency(): void;
|
|
551
|
+
/**
|
|
552
|
+
* Fetch a theme's manifest using repository URL
|
|
553
|
+
* @remark Do **not** include github prefix, only `username/repo`
|
|
554
|
+
*/
|
|
555
|
+
getManifest(repoUrl: string): Promise<ThemeManifest>;
|
|
556
|
+
/**
|
|
557
|
+
* Convert snippet name to its corresponding filepath (relative to vault root)
|
|
558
|
+
* @returns string `.obsidian/snippets/${snippetName}.css`
|
|
559
|
+
*/
|
|
560
|
+
getSnippetPath(snippetName: string): string;
|
|
561
|
+
/**
|
|
562
|
+
* Returns the folder path where snippets are stored (relative to vault root)
|
|
563
|
+
*/
|
|
564
|
+
getSnippetsFolder(): string;
|
|
565
|
+
/**
|
|
566
|
+
* Returns the folder path where themes are stored (relative to vault root)
|
|
567
|
+
*/
|
|
568
|
+
getThemesFolder(): string;
|
|
569
|
+
/**
|
|
570
|
+
* Convert theme name to its corresponding filepath (relative to vault root)
|
|
571
|
+
* @returns string `.obsidian/themes/${themeName}/theme.css`
|
|
572
|
+
*/
|
|
573
|
+
getThemePath(themeName: string): string;
|
|
574
|
+
/**
|
|
575
|
+
* Returns whether there are themes that can be updated
|
|
576
|
+
*/
|
|
577
|
+
hasUpdates(): boolean;
|
|
578
|
+
/**
|
|
579
|
+
* Install a legacy theme using the pre-v1.0.0 theme download pipeline<br>
|
|
580
|
+
* Will create a corresponding dummy manifest for the theme
|
|
581
|
+
* @remark Name will be used as the folder name for the theme
|
|
582
|
+
*/
|
|
583
|
+
installLegacyTheme(arg: { name: string, repo: string, author: string }): Promise<void>;
|
|
584
|
+
/**
|
|
585
|
+
* Install a theme using the regular theme download pipeline
|
|
586
|
+
*/
|
|
587
|
+
installTheme(arg: { name: string, repo: string, author: string }, version: string): Promise<void>;
|
|
588
|
+
/**
|
|
589
|
+
* Check whether a specific theme is installed by theme name
|
|
590
|
+
*/
|
|
591
|
+
isThemeInstalled(themeName: string): boolean;
|
|
592
|
+
/**
|
|
593
|
+
* @internal
|
|
594
|
+
*/
|
|
595
|
+
onRaw(e: any): void;
|
|
596
|
+
/**
|
|
597
|
+
* @internal
|
|
598
|
+
*/
|
|
599
|
+
onload(): void;
|
|
600
|
+
/**
|
|
601
|
+
* @todo
|
|
602
|
+
* @internal
|
|
603
|
+
*/
|
|
604
|
+
readSnippets(): void;
|
|
605
|
+
/**
|
|
606
|
+
* @todo
|
|
607
|
+
* @internal
|
|
608
|
+
*/
|
|
609
|
+
readThemes(): void;
|
|
610
|
+
/**
|
|
611
|
+
* Remove a theme by theme name
|
|
612
|
+
*/
|
|
613
|
+
removeTheme(themeName: string): Promise<void>;
|
|
614
|
+
/**
|
|
615
|
+
* Set the activation status of a snippet by snippet name
|
|
616
|
+
*/
|
|
617
|
+
setCssEnabledStatus(snippetName: string, enabled: boolean): void;
|
|
618
|
+
/**
|
|
619
|
+
* Set the active theme by theme name
|
|
620
|
+
*/
|
|
621
|
+
setTheme(themeName: string): void;
|
|
622
|
+
/**
|
|
623
|
+
* Set the translucency of application background
|
|
624
|
+
*/
|
|
625
|
+
setTranslucency(translucency: boolean): void;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
interface EditorViewI extends EditorView {
|
|
629
|
+
cm?: CMView;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
interface FileCacheEntry {
|
|
633
|
+
/**
|
|
634
|
+
* Hash of file contents
|
|
635
|
+
*/
|
|
636
|
+
hash: string;
|
|
637
|
+
/**
|
|
638
|
+
* Last modified time of file
|
|
639
|
+
*/
|
|
640
|
+
mtime: number;
|
|
641
|
+
/**
|
|
642
|
+
* Size of file in bytes
|
|
643
|
+
*/
|
|
644
|
+
size: number;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
interface FileEntry {
|
|
648
|
+
/**
|
|
649
|
+
* Creation time (if file)
|
|
650
|
+
*/
|
|
651
|
+
ctime?: number;
|
|
652
|
+
/**
|
|
653
|
+
* Modification time (if file)
|
|
654
|
+
*/
|
|
655
|
+
mtime?: number;
|
|
656
|
+
/**
|
|
657
|
+
* Full path to file or folder
|
|
658
|
+
* @remark Might be used for resolving symlinks
|
|
659
|
+
*/
|
|
660
|
+
realpath: string;
|
|
661
|
+
/**
|
|
662
|
+
* Size in bytes (if file)
|
|
663
|
+
*/
|
|
664
|
+
size?: number;
|
|
665
|
+
/**
|
|
666
|
+
* Type of entry
|
|
667
|
+
*/
|
|
668
|
+
type: 'file' | 'folder';
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
interface FileExplorerLeaf extends WorkspaceLeaf {
|
|
672
|
+
view: FileExplorerView;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
interface FileExplorerPlugin extends InternalPlugin {
|
|
676
|
+
revealInFolder(folder: TFolder): Promise<void>;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
interface FileExplorerView extends View {
|
|
680
|
+
files: WeakMapWrapper<HTMLElement, TAbstractFile>;
|
|
681
|
+
|
|
682
|
+
openFileContextMenu(event: Event, fileItemElement: HTMLElement): void;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
interface HotkeyManager {
|
|
686
|
+
/**
|
|
687
|
+
* Reference to App
|
|
688
|
+
*/
|
|
689
|
+
app: App;
|
|
690
|
+
/**
|
|
691
|
+
* @internal Whether hotkeys have been baked (checks completed)
|
|
692
|
+
*/
|
|
693
|
+
baked: boolean;
|
|
694
|
+
/**
|
|
695
|
+
* Assigned hotkeys
|
|
696
|
+
*/
|
|
697
|
+
bakedHotkeys: KeymapInfo[];
|
|
698
|
+
/**
|
|
699
|
+
* Array of hotkey index to command ID
|
|
700
|
+
*/
|
|
701
|
+
bakedIds: string[];
|
|
702
|
+
/**
|
|
703
|
+
* Custom (non-Obsidian default) hotkeys, one to many mapping of command ID to assigned hotkey
|
|
704
|
+
*/
|
|
705
|
+
customKeys: Record<string, KeymapInfo[]>;
|
|
706
|
+
/**
|
|
707
|
+
* Default hotkeys, one to many mapping of command ID to assigned hotkey
|
|
708
|
+
*/
|
|
709
|
+
defaultKeys: Record<string, KeymapInfo[]>;
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Add a hotkey to the default hotkeys
|
|
713
|
+
* @param command - Command ID to add hotkey to
|
|
714
|
+
* @param keys - Hotkeys to add
|
|
715
|
+
*/
|
|
716
|
+
addDefaultHotkeys(command: string, keys: KeymapInfo[]): void;
|
|
717
|
+
/**
|
|
718
|
+
* Get hotkey associated with command ID
|
|
719
|
+
* @param command - Command ID to get hotkey for
|
|
720
|
+
*/
|
|
721
|
+
getDefaultHotkeys(command: string): KeymapInfo[];
|
|
722
|
+
/**
|
|
723
|
+
* Remove a hotkey from the default hotkeys
|
|
724
|
+
* @param command - Command ID to remove hotkey from
|
|
725
|
+
*/
|
|
726
|
+
removeDefaultHotkeys(command: string): void;
|
|
727
|
+
/**
|
|
728
|
+
* Add a hotkey to the custom hotkeys (overrides default hotkeys)
|
|
729
|
+
* @param command - Command ID to add hotkey to
|
|
730
|
+
* @param keys - Hotkeys to add
|
|
731
|
+
*/
|
|
732
|
+
setHotkeys(command: string, keys: KeymapInfo[]): void;
|
|
733
|
+
/**
|
|
734
|
+
* Get hotkey associated with command ID
|
|
735
|
+
* @param command - Command ID to get hotkey for
|
|
736
|
+
*/
|
|
737
|
+
getHotkeys(command: string): KeymapInfo[];
|
|
738
|
+
/**
|
|
739
|
+
* Remove a hotkey from the custom hotkeys
|
|
740
|
+
* @param command - Command ID to remove hotkey from
|
|
741
|
+
*/
|
|
742
|
+
removeHotkeys(command: string): void;
|
|
743
|
+
/**
|
|
744
|
+
* Pretty-print hotkey of a command
|
|
745
|
+
* @param command
|
|
746
|
+
*/
|
|
747
|
+
printHotkeyForCommand(command: string): string;
|
|
748
|
+
/**
|
|
749
|
+
* Trigger a command by keyboard event
|
|
750
|
+
* @param event - Keyboard event to trigger command with
|
|
751
|
+
* @param keypress - Pressed key information
|
|
752
|
+
*/
|
|
753
|
+
onTrigger(event: KeyboardEvent, keypress: KeymapInfo): boolean;
|
|
754
|
+
/**
|
|
755
|
+
* @internal Bake hotkeys (create mapping of pressed key to command ID)
|
|
756
|
+
*/
|
|
757
|
+
bake(): void;
|
|
758
|
+
/**
|
|
759
|
+
* @internal Load hotkeys from storage
|
|
760
|
+
*/
|
|
761
|
+
load(): void;
|
|
762
|
+
/**
|
|
763
|
+
* @internal Save custom hotkeys to storage
|
|
764
|
+
*/
|
|
765
|
+
save(): void;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
interface HoverLinkSource {
|
|
769
|
+
display: string;
|
|
770
|
+
defaultMod: boolean;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
interface ImportedAttachments {
|
|
774
|
+
data: Promise<ArrayBuffer>;
|
|
775
|
+
extension: string;
|
|
776
|
+
filename: string;
|
|
777
|
+
name: string;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
interface InternalPlugin extends Plugin {
|
|
781
|
+
disable(): void;
|
|
782
|
+
enable(): void;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
type InternalPluginName = 'audio-recorder' |
|
|
786
|
+
'backlink' |
|
|
787
|
+
'bookmarks' |
|
|
788
|
+
'canvas' |
|
|
789
|
+
'command-palette' |
|
|
790
|
+
'daily-notes' |
|
|
791
|
+
'editor-status' |
|
|
792
|
+
'file-explorer' |
|
|
793
|
+
'file-recovery' |
|
|
794
|
+
'global-search' |
|
|
795
|
+
'graph' |
|
|
796
|
+
'markdown-importer' |
|
|
797
|
+
'note-composer' |
|
|
798
|
+
'outgoing-link' |
|
|
799
|
+
'outline' |
|
|
800
|
+
'page-preview' |
|
|
801
|
+
'properties' |
|
|
802
|
+
'publish' |
|
|
803
|
+
'random-note' |
|
|
804
|
+
'slash-command' |
|
|
805
|
+
'slides' |
|
|
806
|
+
'starred' |
|
|
807
|
+
'switcher' |
|
|
808
|
+
'sync' |
|
|
809
|
+
'tag-pane' |
|
|
810
|
+
'templates' |
|
|
811
|
+
'word-count' |
|
|
812
|
+
'workspaces' |
|
|
813
|
+
'zk-prefixer';
|
|
814
|
+
|
|
815
|
+
interface InternalPlugins extends Events {
|
|
816
|
+
/**
|
|
817
|
+
* Reference to App
|
|
818
|
+
*/
|
|
819
|
+
app: App;
|
|
820
|
+
/**
|
|
821
|
+
* Mapping of whether an internal plugin is enabled
|
|
822
|
+
*/
|
|
823
|
+
config: Record<InternalPluginName, boolean>;
|
|
824
|
+
/**
|
|
825
|
+
* @internal
|
|
826
|
+
*/
|
|
827
|
+
migration: boolean;
|
|
828
|
+
/**
|
|
829
|
+
* Plugin configs for internal plugins
|
|
830
|
+
*/
|
|
831
|
+
plugins: Record<InternalPluginName, InternalPlugin>;
|
|
832
|
+
/**
|
|
833
|
+
* @internal Request save of plugin configs
|
|
834
|
+
*/
|
|
835
|
+
requestSaveConfig(): void;
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* Get an enabled internal plugin by ID
|
|
839
|
+
* @param id - ID of the plugin to get
|
|
840
|
+
*/
|
|
841
|
+
getEnabledPluginById(id: InternalPluginName): InternalPlugin | null;
|
|
842
|
+
getEnabledPluginById(id: 'file-explorer'): FileExplorerPlugin | null;
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Get all enabled internal plugins
|
|
846
|
+
*/
|
|
847
|
+
getEnabledPlugins(): InternalPlugin[];
|
|
848
|
+
/**
|
|
849
|
+
* Get an internal plugin by ID
|
|
850
|
+
* @param id - ID of the plugin to get
|
|
851
|
+
*/
|
|
852
|
+
getPluginById(id: InternalPluginName): InternalPlugin;
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* @internal - Load plugin configs and enable plugins
|
|
856
|
+
*/
|
|
857
|
+
enable(): Promise<void>;
|
|
858
|
+
/**
|
|
859
|
+
* @internal
|
|
860
|
+
*/
|
|
861
|
+
loadPlugin(arg: { id: string, name: string }): string;
|
|
862
|
+
/**
|
|
863
|
+
* @internal
|
|
864
|
+
*/
|
|
865
|
+
onRaw(cb1: any, cb2: any): void;
|
|
866
|
+
/**
|
|
867
|
+
* @internal - Save current plugin configs
|
|
868
|
+
*/
|
|
869
|
+
saveConfig(): Promise<void>;
|
|
870
|
+
/**
|
|
871
|
+
* @internal
|
|
872
|
+
*/
|
|
873
|
+
trigger(arg: string): void;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
interface KeyScope {
|
|
877
|
+
/**
|
|
878
|
+
* Callback of function to execute when key is pressed
|
|
879
|
+
*/
|
|
880
|
+
func(): void;
|
|
881
|
+
/**
|
|
882
|
+
* Key to match
|
|
883
|
+
*/
|
|
884
|
+
key: string | null;
|
|
885
|
+
/**
|
|
886
|
+
* Modifiers to match
|
|
887
|
+
*/
|
|
888
|
+
modifiers: string | null;
|
|
889
|
+
/**
|
|
890
|
+
* Scope where the key interceptor is registered
|
|
891
|
+
*/
|
|
892
|
+
scope: Scope;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
interface LeafEntry {
|
|
896
|
+
children?: LeafEntry[];
|
|
897
|
+
direction?: SplitDirection;
|
|
898
|
+
id: string;
|
|
899
|
+
state?: ViewState;
|
|
900
|
+
type: string;
|
|
901
|
+
width?: number;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
interface LinkUpdate {
|
|
905
|
+
/**
|
|
906
|
+
* Reference to App
|
|
907
|
+
*/
|
|
908
|
+
app: App;
|
|
909
|
+
/**
|
|
910
|
+
* Link position in the file
|
|
911
|
+
*/
|
|
912
|
+
reference: PositionedReference;
|
|
913
|
+
/**
|
|
914
|
+
* File that was resolved
|
|
915
|
+
*/
|
|
916
|
+
resolvedFile: TFile;
|
|
917
|
+
/**
|
|
918
|
+
* Paths the file could have been resolved to
|
|
919
|
+
*/
|
|
920
|
+
resolvedPaths: string[];
|
|
921
|
+
/**
|
|
922
|
+
* File that contains the link
|
|
923
|
+
*/
|
|
924
|
+
sourceFile: TFile;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
interface MetadataTypeManager extends Events {
|
|
928
|
+
/**
|
|
929
|
+
* Reference to App
|
|
930
|
+
*/
|
|
931
|
+
app: App;
|
|
932
|
+
/**
|
|
933
|
+
* Registered properties of the vault
|
|
934
|
+
*/
|
|
935
|
+
properties: Record<string, PropertyInfo>;
|
|
936
|
+
/**
|
|
937
|
+
* @internal Registered type widgets
|
|
938
|
+
*/
|
|
939
|
+
registeredTypeWidgets: Record<PropertyWidgetType, PropertyWidget>;
|
|
940
|
+
/**
|
|
941
|
+
* Associated widget types for each property
|
|
942
|
+
*/
|
|
943
|
+
types: Record<string, PropertyWidgetType>;
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* Get all registered properties of the vault
|
|
947
|
+
*/
|
|
948
|
+
getAllProperties(): Record<string, PropertyInfo>;
|
|
949
|
+
/**
|
|
950
|
+
* Get assigned widget type for property
|
|
951
|
+
*/
|
|
952
|
+
getAssignedType(property: string): PropertyWidgetType | null;
|
|
953
|
+
/**
|
|
954
|
+
* Get info for property
|
|
955
|
+
*/
|
|
956
|
+
getPropertyInfo(property: string): PropertyInfo;
|
|
957
|
+
/**
|
|
958
|
+
* @internal Get expected widget type for property and the one inferred from the property value
|
|
959
|
+
*/
|
|
960
|
+
getTypeInfo: (arg: { key: string, type: string, value: any }) => { inferred: PropertyWidget, expected: PropertyWidget }
|
|
961
|
+
/**
|
|
962
|
+
* Get all properties with an assigned widget type
|
|
963
|
+
*/
|
|
964
|
+
getTypes(): string[];
|
|
965
|
+
/**
|
|
966
|
+
* @internal Load property types from config
|
|
967
|
+
*/
|
|
968
|
+
loadData(): Promise<void>;
|
|
969
|
+
/**
|
|
970
|
+
* @internal Save property types to config
|
|
971
|
+
*/
|
|
972
|
+
save(): Promise<void>;
|
|
973
|
+
/**
|
|
974
|
+
* @internal Get all properties from metadata cache
|
|
975
|
+
*/
|
|
976
|
+
savePropertyInfo(): void;
|
|
977
|
+
/**
|
|
978
|
+
* @internal Set widget type for property
|
|
979
|
+
*/
|
|
980
|
+
setType(property: string, type: PropertyWidgetType): void;
|
|
981
|
+
/**
|
|
982
|
+
* @internal
|
|
983
|
+
*/
|
|
984
|
+
trigger(e: any): void;
|
|
985
|
+
/**
|
|
986
|
+
* @internal Unset widget type for property
|
|
987
|
+
*/
|
|
988
|
+
unsetType(property: string): void;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
interface ObsidianDOM {
|
|
992
|
+
/**
|
|
993
|
+
* Root element of the application
|
|
994
|
+
*/
|
|
995
|
+
appContainerEl: HTMLElement;
|
|
996
|
+
/**
|
|
997
|
+
* Child of `appContainerEl` containing the main content of the application
|
|
998
|
+
*/
|
|
999
|
+
horizontalMainContainerEl: HTMLElement;
|
|
1000
|
+
/**
|
|
1001
|
+
* Status bar element containing word count among other things
|
|
1002
|
+
*/
|
|
1003
|
+
statusBarEl: HTMLElement;
|
|
1004
|
+
/**
|
|
1005
|
+
* Child of `horizontalMainContainerEl` containing the workspace DOM
|
|
1006
|
+
*/
|
|
1007
|
+
workspaceEl: HTMLElement;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
interface PluginManifest {
|
|
1011
|
+
/**
|
|
1012
|
+
* Name of the author of the plugin
|
|
1013
|
+
*/
|
|
1014
|
+
author: string;
|
|
1015
|
+
/**
|
|
1016
|
+
* URL to the author's website
|
|
1017
|
+
*/
|
|
1018
|
+
authorUrl?: string;
|
|
1019
|
+
/**
|
|
1020
|
+
* Description of the plugin's functionality
|
|
1021
|
+
*/
|
|
1022
|
+
description: string;
|
|
1023
|
+
/**
|
|
1024
|
+
* Storage location of the plugin relative to the vault root
|
|
1025
|
+
*/
|
|
1026
|
+
dir: string;
|
|
1027
|
+
/**
|
|
1028
|
+
* URL for funding the author
|
|
1029
|
+
*/
|
|
1030
|
+
fundingUrl?: string;
|
|
1031
|
+
/**
|
|
1032
|
+
* Unique identifier of the plugin
|
|
1033
|
+
*/
|
|
1034
|
+
id: string;
|
|
1035
|
+
/**
|
|
1036
|
+
* Whether the plugin is designed for desktop use only
|
|
1037
|
+
*/
|
|
1038
|
+
isDesktopOnly: boolean;
|
|
1039
|
+
/**
|
|
1040
|
+
* Minimum Obsidian version compatible with the plugin
|
|
1041
|
+
*/
|
|
1042
|
+
minAppVersion: string;
|
|
1043
|
+
/**
|
|
1044
|
+
* Name of the plugin
|
|
1045
|
+
*/
|
|
1046
|
+
name: string;
|
|
1047
|
+
/**
|
|
1048
|
+
* Version of the plugin
|
|
1049
|
+
*/
|
|
1050
|
+
version: string;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
interface Plugins {
|
|
1054
|
+
/**
|
|
1055
|
+
* Reference to App
|
|
1056
|
+
*/
|
|
1057
|
+
app: App;
|
|
1058
|
+
/**
|
|
1059
|
+
* Set of enabled plugin IDs
|
|
1060
|
+
*/
|
|
1061
|
+
enabledPlugins: Set<string>;
|
|
1062
|
+
/**
|
|
1063
|
+
* @internal Plugin ID that is currently being enabled
|
|
1064
|
+
*/
|
|
1065
|
+
loadingPluginId: string | null;
|
|
1066
|
+
/**
|
|
1067
|
+
* Manifests of all the plugins
|
|
1068
|
+
*/
|
|
1069
|
+
manifests: Record<string, PluginManifest>;
|
|
1070
|
+
/**
|
|
1071
|
+
* Mapping of plugin ID to plugin instance
|
|
1072
|
+
*/
|
|
1073
|
+
plugins: Record<string, Plugin>;
|
|
1074
|
+
/**
|
|
1075
|
+
* Mapping of plugin ID to available updates
|
|
1076
|
+
*/
|
|
1077
|
+
updates: Map<string, PluginUpdateManifest>;
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* @internal Check online list for deprecated plugins to automatically disable
|
|
1081
|
+
*/
|
|
1082
|
+
checkForDeprecations(): Promise<void>;
|
|
1083
|
+
/**
|
|
1084
|
+
* Check for plugin updates
|
|
1085
|
+
*/
|
|
1086
|
+
checkForUpdates(): Promise<void>;
|
|
1087
|
+
/**
|
|
1088
|
+
* Unload a plugin by ID
|
|
1089
|
+
*/
|
|
1090
|
+
disablePlugin(id: string): Promise<void>;
|
|
1091
|
+
/**
|
|
1092
|
+
* Unload a plugin by ID and save config for persistence
|
|
1093
|
+
*/
|
|
1094
|
+
disablePluginAndSave(id: string): Promise<void>;
|
|
1095
|
+
/**
|
|
1096
|
+
* Enable a plugin by ID
|
|
1097
|
+
*/
|
|
1098
|
+
enablePlugin(id: string): Promise<void>;
|
|
1099
|
+
/**
|
|
1100
|
+
* Enable a plugin by ID and save config for persistence
|
|
1101
|
+
*/
|
|
1102
|
+
enablePluginAndSave(id: string): Promise<void>;
|
|
1103
|
+
/**
|
|
1104
|
+
* Get a plugin by ID
|
|
1105
|
+
*/
|
|
1106
|
+
getPlugin(id: string): Plugin | null;
|
|
1107
|
+
/**
|
|
1108
|
+
* Get the folder where plugins are stored
|
|
1109
|
+
*/
|
|
1110
|
+
getPluginFolder(): string;
|
|
1111
|
+
/**
|
|
1112
|
+
* @internal Load plugin manifests and enable plugins from config
|
|
1113
|
+
*/
|
|
1114
|
+
initialize(): Promise<void>;
|
|
1115
|
+
/**
|
|
1116
|
+
* Install a plugin from a given URL
|
|
1117
|
+
*/
|
|
1118
|
+
installPlugin(repo: string, version: string, manifest: PluginManifest): Promise<void>;
|
|
1119
|
+
/**
|
|
1120
|
+
* Check whether a plugin is deprecated
|
|
1121
|
+
*/
|
|
1122
|
+
isDeprecated(id: string): boolean;
|
|
1123
|
+
/**
|
|
1124
|
+
* Check whether community plugins are enabled
|
|
1125
|
+
*/
|
|
1126
|
+
isEnabled(): boolean;
|
|
1127
|
+
/**
|
|
1128
|
+
* Load a specific plugin's manifest by its folder path
|
|
1129
|
+
*/
|
|
1130
|
+
loadManifest(path: string): Promise<void>;
|
|
1131
|
+
/**
|
|
1132
|
+
* @internal Load all plugin manifests from plugin folder
|
|
1133
|
+
*/
|
|
1134
|
+
loadManifests(): Promise<void>;
|
|
1135
|
+
/**
|
|
1136
|
+
*Load a plugin by its ID
|
|
1137
|
+
*/
|
|
1138
|
+
loadPlugin(id: string): Promise<Plugin>;
|
|
1139
|
+
/**
|
|
1140
|
+
* @internal
|
|
1141
|
+
*/
|
|
1142
|
+
onRaw(e: any): void;
|
|
1143
|
+
/**
|
|
1144
|
+
* @internal - Save current plugin configs
|
|
1145
|
+
*/
|
|
1146
|
+
saveConfig(): Promise<void>;
|
|
1147
|
+
/**
|
|
1148
|
+
* @internal Toggle whether community plugins are enabled
|
|
1149
|
+
*/
|
|
1150
|
+
setEnable(enabled: boolean): Promise<void>;
|
|
1151
|
+
/**
|
|
1152
|
+
* Uninstall a plugin by ID
|
|
1153
|
+
*/
|
|
1154
|
+
uninstallPlugin(id: string): Promise<void>;
|
|
1155
|
+
/**
|
|
1156
|
+
* Unload a plugin by ID
|
|
1157
|
+
*/
|
|
1158
|
+
unloadPlugin(id: string): Promise<void>;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
interface PluginUpdateManifest {
|
|
1162
|
+
/**
|
|
1163
|
+
* Manifest of the plugin
|
|
1164
|
+
*/
|
|
1165
|
+
manifest: PluginManifest;
|
|
1166
|
+
/**
|
|
1167
|
+
* Repository of the plugin
|
|
1168
|
+
*/
|
|
1169
|
+
repo: string;
|
|
1170
|
+
/**
|
|
1171
|
+
* New version of the plugin
|
|
1172
|
+
*/
|
|
1173
|
+
version: string;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
interface PositionedReference extends Reference {
|
|
1177
|
+
/**
|
|
1178
|
+
* Position of the reference in the file
|
|
1179
|
+
*/
|
|
1180
|
+
position: {
|
|
1181
|
+
start: Loc;
|
|
1182
|
+
end: Loc;
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
interface PropertyInfo {
|
|
1187
|
+
/**
|
|
1188
|
+
* Name of property
|
|
1189
|
+
*/
|
|
1190
|
+
name: string;
|
|
1191
|
+
/**
|
|
1192
|
+
* Type of property
|
|
1193
|
+
*/
|
|
1194
|
+
type: string;
|
|
1195
|
+
/**
|
|
1196
|
+
* Usage count of property
|
|
1197
|
+
*/
|
|
1198
|
+
count: number;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
interface PropertyWidget {
|
|
1202
|
+
/**
|
|
1203
|
+
* @internal
|
|
1204
|
+
*/
|
|
1205
|
+
default(): void;
|
|
1206
|
+
/**
|
|
1207
|
+
* Lucide-dev icon associated with the widget
|
|
1208
|
+
*/
|
|
1209
|
+
icon: string;
|
|
1210
|
+
/**
|
|
1211
|
+
* @internal Name proxy
|
|
1212
|
+
*/
|
|
1213
|
+
name: any;
|
|
1214
|
+
/**
|
|
1215
|
+
* @internal Render function for the widget
|
|
1216
|
+
*/
|
|
1217
|
+
render(element: HTMLElement, metadataField: any, property: PropertyInfo): void;
|
|
1218
|
+
/**
|
|
1219
|
+
* @internal Reserved keys for the widget
|
|
1220
|
+
*/
|
|
1221
|
+
reservedKeys: string[];
|
|
1222
|
+
/**
|
|
1223
|
+
* Widget type
|
|
1224
|
+
*/
|
|
1225
|
+
type: string;
|
|
1226
|
+
/**
|
|
1227
|
+
* @internal Validate correctness of property input with respects to the widget
|
|
1228
|
+
*/
|
|
1229
|
+
validate(value: any): boolean;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
type PropertyWidgetType = 'aliases'
|
|
1233
|
+
| 'checkbox'
|
|
1234
|
+
| 'date'
|
|
1235
|
+
| 'datetime'
|
|
1236
|
+
| 'multitext'
|
|
1237
|
+
| 'number'
|
|
1238
|
+
| 'tags'
|
|
1239
|
+
| 'text';
|
|
1240
|
+
|
|
1241
|
+
interface ReadViewRenderer {
|
|
1242
|
+
addBottomPadding: boolean;
|
|
1243
|
+
lastRender: number;
|
|
1244
|
+
lastScroll: number;
|
|
1245
|
+
lastText: string;
|
|
1246
|
+
previewEl: HTMLElement;
|
|
1247
|
+
pusherEl: HTMLElement;
|
|
1248
|
+
clear(): void;
|
|
1249
|
+
queueRender(): void;
|
|
1250
|
+
parseSync(): void;
|
|
1251
|
+
parseAsync(): void;
|
|
1252
|
+
set(text: string): void;
|
|
1253
|
+
text: string;
|
|
1254
|
+
sections: RendererSection[];
|
|
1255
|
+
asyncSections: any[];
|
|
1256
|
+
recycledSections: any[];
|
|
1257
|
+
rendered: any[];
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
interface RecentFileTracker {
|
|
1261
|
+
/**
|
|
1262
|
+
* List of last opened file paths, limited to 50
|
|
1263
|
+
*/
|
|
1264
|
+
lastOpenFiles: string[];
|
|
1265
|
+
/**
|
|
1266
|
+
* Reference to Vault
|
|
1267
|
+
*/
|
|
1268
|
+
vault: Vault;
|
|
1269
|
+
/**
|
|
1270
|
+
* Reference to Workspace
|
|
1271
|
+
*/
|
|
1272
|
+
workspace: Workspace;
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* @internal
|
|
1276
|
+
*/
|
|
1277
|
+
collect(file: TFile): void;
|
|
1278
|
+
/**
|
|
1279
|
+
* Returns the last 10 opened files
|
|
1280
|
+
*/
|
|
1281
|
+
getLastOpenFiles(): string[];
|
|
1282
|
+
/**
|
|
1283
|
+
* Get last n files of type (defaults to 10)
|
|
1284
|
+
*/
|
|
1285
|
+
getRecentFiles(arg?: { showMarkdown: boolean, showCanvas: boolean, showNonImageAttachments: boolean, showImages: boolean, maxCount: number }): string[];
|
|
1286
|
+
/**
|
|
1287
|
+
* Set the last opened files
|
|
1288
|
+
*/
|
|
1289
|
+
load(savedFiles: string[]): void;
|
|
1290
|
+
/**
|
|
1291
|
+
* @internal On file create, save file to last opened files
|
|
1292
|
+
*/
|
|
1293
|
+
onFileCreated(file: TFile): void;
|
|
1294
|
+
/**
|
|
1295
|
+
* @internal On file open, save file to last opened files
|
|
1296
|
+
*/
|
|
1297
|
+
onFileOpen(prevFile: TFile, file: TFile): void;
|
|
1298
|
+
/**
|
|
1299
|
+
* @internal On file rename, update file path in last opened files
|
|
1300
|
+
*/
|
|
1301
|
+
onRename(file: TFile, oldPath: string): void;
|
|
1302
|
+
/**
|
|
1303
|
+
* @internal Get last opened files
|
|
1304
|
+
*/
|
|
1305
|
+
serialize(): string[];
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
interface RendererSection {
|
|
1309
|
+
el: HTMLElement;
|
|
1310
|
+
html: string;
|
|
1311
|
+
rendered: boolean;
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
interface SerializedWorkspace {
|
|
1315
|
+
/**
|
|
1316
|
+
* Last active leaf
|
|
1317
|
+
*/
|
|
1318
|
+
active: string;
|
|
1319
|
+
/**
|
|
1320
|
+
* Last opened files
|
|
1321
|
+
*/
|
|
1322
|
+
lastOpenFiles: string[];
|
|
1323
|
+
/**
|
|
1324
|
+
* Left opened leaf
|
|
1325
|
+
*/
|
|
1326
|
+
left: LeafEntry;
|
|
1327
|
+
/**
|
|
1328
|
+
* Left ribbon
|
|
1329
|
+
*/
|
|
1330
|
+
leftRibbon: { hiddenItems: Record<string, boolean> };
|
|
1331
|
+
/**
|
|
1332
|
+
* Main (center) workspace leaf
|
|
1333
|
+
*/
|
|
1334
|
+
main: LeafEntry;
|
|
1335
|
+
/**
|
|
1336
|
+
* Right opened leaf
|
|
1337
|
+
*/
|
|
1338
|
+
right: LeafEntry;
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
interface StateHistory {
|
|
1342
|
+
/**
|
|
1343
|
+
* Ephemeral cursor state within Editor of leaf
|
|
1344
|
+
*/
|
|
1345
|
+
eState: {
|
|
1346
|
+
cursor: EditorRange;
|
|
1347
|
+
scroll: number;
|
|
1348
|
+
};
|
|
1349
|
+
/**
|
|
1350
|
+
* Icon of the leaf
|
|
1351
|
+
*/
|
|
1352
|
+
icon?: string;
|
|
1353
|
+
/**
|
|
1354
|
+
* History of previous and future states of leaf
|
|
1355
|
+
*/
|
|
1356
|
+
leafHistory?: {
|
|
1357
|
+
backHistory: StateHistory[];
|
|
1358
|
+
forwardHistory: StateHistory[];
|
|
1359
|
+
};
|
|
1360
|
+
/**
|
|
1361
|
+
* Id of parent to which the leaf belonged
|
|
1362
|
+
*/
|
|
1363
|
+
parentId?: string;
|
|
1364
|
+
/**
|
|
1365
|
+
* Id of root to which the leaf belonged
|
|
1366
|
+
*/
|
|
1367
|
+
rootId?: string;
|
|
1368
|
+
/**
|
|
1369
|
+
* Last state of the leaf
|
|
1370
|
+
*/
|
|
1371
|
+
state: ViewState;
|
|
1372
|
+
/**
|
|
1373
|
+
* Title of the leaf
|
|
1374
|
+
*/
|
|
1375
|
+
title?: string;
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
interface ThemeManifest {
|
|
1379
|
+
/**
|
|
1380
|
+
* Name of the author of the theme
|
|
1381
|
+
*/
|
|
1382
|
+
author: string;
|
|
1383
|
+
/**
|
|
1384
|
+
* URL to the author's website
|
|
1385
|
+
*/
|
|
1386
|
+
authorUrl?: string;
|
|
1387
|
+
/**
|
|
1388
|
+
* Storage location of the theme relative to the vault root
|
|
1389
|
+
*/
|
|
1390
|
+
dir: string;
|
|
1391
|
+
/**
|
|
1392
|
+
* URL for funding the author
|
|
1393
|
+
*/
|
|
1394
|
+
fundingUrl?: string;
|
|
1395
|
+
/**
|
|
1396
|
+
* Minimum Obsidian version compatible with the theme
|
|
1397
|
+
*/
|
|
1398
|
+
minAppVersion: string;
|
|
1399
|
+
/**
|
|
1400
|
+
* Name of the theme
|
|
1401
|
+
*/
|
|
1402
|
+
name: string;
|
|
1403
|
+
/**
|
|
1404
|
+
* Version of the theme
|
|
1405
|
+
* @remark Defaults to "0.0.0" if no theme manifest was provided in the repository
|
|
1406
|
+
*/
|
|
1407
|
+
version: '0.0.0' | string;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
interface ViewRegistry extends Events {
|
|
1411
|
+
/**
|
|
1412
|
+
* Mapping of file extensions to view type
|
|
1413
|
+
*/
|
|
1414
|
+
typeByExtension: Record<string, string>;
|
|
1415
|
+
/**
|
|
1416
|
+
* Mapping of view type to view constructor
|
|
1417
|
+
*/
|
|
1418
|
+
viewByType: Record<string, (leaf: WorkspaceLeaf) => View>;
|
|
1419
|
+
|
|
1420
|
+
/**
|
|
1421
|
+
* Get the view type associated with a file extension
|
|
1422
|
+
* @param extension File extension
|
|
1423
|
+
*/
|
|
1424
|
+
getTypeByExtension(extension: string): string;
|
|
1425
|
+
/**
|
|
1426
|
+
* Get the view constructor associated with a view type
|
|
1427
|
+
*/
|
|
1428
|
+
getViewCreatorByType(type: string): (leaf: WorkspaceLeaf) => View;
|
|
1429
|
+
/**
|
|
1430
|
+
* Check whether a view type is registered
|
|
1431
|
+
*/
|
|
1432
|
+
isExtensionRegistered(extension: string): boolean;
|
|
1433
|
+
/**
|
|
1434
|
+
* Register a view type for a file extension
|
|
1435
|
+
* @param extension File extension
|
|
1436
|
+
* @param type View type
|
|
1437
|
+
* @remark Prefer registering the extension via the Plugin class
|
|
1438
|
+
*/
|
|
1439
|
+
registerExtensions(extension: string[], type: string): void;
|
|
1440
|
+
/**
|
|
1441
|
+
* Register a view constructor for a view type
|
|
1442
|
+
*/
|
|
1443
|
+
registerView(type: string, viewCreator: (leaf: WorkspaceLeaf) => View): void;
|
|
1444
|
+
/**
|
|
1445
|
+
* Register a view and its associated file extensions
|
|
1446
|
+
*/
|
|
1447
|
+
registerViewWithExtensions(extensions: string[], type: string, viewCreator: (leaf: WorkspaceLeaf) => View): void;
|
|
1448
|
+
/**
|
|
1449
|
+
* @internal
|
|
1450
|
+
*/
|
|
1451
|
+
trigger(type: string): void;
|
|
1452
|
+
/**
|
|
1453
|
+
* Unregister extensions for a view type
|
|
1454
|
+
*/
|
|
1455
|
+
unregisterExtensions(extension: string[]): void;
|
|
1456
|
+
/**
|
|
1457
|
+
* Unregister a view type
|
|
1458
|
+
*/
|
|
1459
|
+
unregisterView(type: string): void;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
interface WeakMapWrapper<K extends WeakKey, V> extends WeakMap<K, V> {
|
|
1463
|
+
map: WeakMap<K, V>;
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
interface WindowSelection {
|
|
1467
|
+
focusEl: HTMLElement;
|
|
1468
|
+
range: Range;
|
|
1469
|
+
win: Window;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
declare module 'obsidian' {
|
|
1473
|
+
interface App {
|
|
1474
|
+
/**
|
|
1475
|
+
* The account signed in to Obsidian
|
|
1476
|
+
*/
|
|
1477
|
+
account: Account;
|
|
1478
|
+
/**
|
|
1479
|
+
* ID that uniquely identifies the vault
|
|
1480
|
+
* @tutorial Used for implementing device *and* vault-specific data storage using LocalStorage or IndexedDB
|
|
1481
|
+
*/
|
|
1482
|
+
appId: string;
|
|
1483
|
+
// /**
|
|
1484
|
+
// * @internal
|
|
1485
|
+
// */
|
|
1486
|
+
// appMenuBarManager: AppMenuBarManager;
|
|
1487
|
+
/**
|
|
1488
|
+
* Contains all registered commands
|
|
1489
|
+
* @tutorial Can be used to manually invoke the functionality of a specific command
|
|
1490
|
+
*/
|
|
1491
|
+
commands: Commands;
|
|
1492
|
+
/**
|
|
1493
|
+
* Custom CSS (snippets/themes) applied to the application
|
|
1494
|
+
* @tutorial Can be used to view which snippets are enabled or available, or inspect loaded-in theme manifests
|
|
1495
|
+
*/
|
|
1496
|
+
customCss: CustomCSS;
|
|
1497
|
+
/** References to important DOM elements of the application */
|
|
1498
|
+
dom: ObsidianDOM;
|
|
1499
|
+
// /**
|
|
1500
|
+
// * @internal
|
|
1501
|
+
// */
|
|
1502
|
+
// dragManager: any;
|
|
1503
|
+
// /**
|
|
1504
|
+
// * @internal
|
|
1505
|
+
// */
|
|
1506
|
+
// embedRegistry: EmbedRegistry;
|
|
1507
|
+
/**
|
|
1508
|
+
* Manage the creation, deletion and renaming of files from the UI.
|
|
1509
|
+
* @remark Prefer using the `vault` API for programmatic file management
|
|
1510
|
+
*/
|
|
1511
|
+
fileManager: FileManager;
|
|
1512
|
+
// /**
|
|
1513
|
+
// * @internal
|
|
1514
|
+
// */
|
|
1515
|
+
// foldManager: any;
|
|
1516
|
+
/**
|
|
1517
|
+
* Manages global hotkeys
|
|
1518
|
+
* @tutorial Can be used for manually invoking a command, or finding which hotkey is assigned to a specific key input
|
|
1519
|
+
* @remark This should not be used for adding hotkeys to your custom commands, this can easily be done via the official API
|
|
1520
|
+
*/
|
|
1521
|
+
hotkeyManager: HotkeyManager;
|
|
1522
|
+
/**
|
|
1523
|
+
* Manager of internal 'core' plugins
|
|
1524
|
+
* @tutorial Can be used to check whether a specific internal plugin is enabled, or grab specific parts from its config for simplifying your own plugin's settings
|
|
1525
|
+
*/
|
|
1526
|
+
internalPlugins: InternalPlugins;
|
|
1527
|
+
/**
|
|
1528
|
+
* Whether the application is currently running on mobile
|
|
1529
|
+
* @remark Prefer usage of `Platform.isMobile`
|
|
1530
|
+
* @remark Will be true if `app.emulateMobile()` was enabled
|
|
1531
|
+
*/
|
|
1532
|
+
isMobile: boolean;
|
|
1533
|
+
// /**
|
|
1534
|
+
// * @internal
|
|
1535
|
+
// */
|
|
1536
|
+
// keymap: KeymapManager;
|
|
1537
|
+
// /**
|
|
1538
|
+
// * @internal
|
|
1539
|
+
// */
|
|
1540
|
+
// loadProgress: LoadProgress;
|
|
1541
|
+
/**
|
|
1542
|
+
* Manages the gathering and updating of metadata for all files in the vault
|
|
1543
|
+
* @tutorial Use for finding tags and backlinks for specific files, grabbing frontmatter properties, ...
|
|
1544
|
+
*/
|
|
1545
|
+
metadataCache: MetadataCache;
|
|
1546
|
+
/**
|
|
1547
|
+
* Manages the frontmatter properties of the vault and the rendering of the properties
|
|
1548
|
+
* @tutorial Fetching properties used in all frontmatter fields, may potentially be used for adding custom frontmatter widgets
|
|
1549
|
+
*/
|
|
1550
|
+
metadataTypeManager: MetadataTypeManager;
|
|
1551
|
+
|
|
1552
|
+
// /**
|
|
1553
|
+
// * @internal
|
|
1554
|
+
// */
|
|
1555
|
+
// mobileNavbar?: MobileNavbar;
|
|
1556
|
+
// /**
|
|
1557
|
+
// * @internal
|
|
1558
|
+
// */
|
|
1559
|
+
// mobileToolbar?: MobileToolbar;
|
|
1560
|
+
|
|
1561
|
+
// /**
|
|
1562
|
+
// * @internal Events to execute on the next frame
|
|
1563
|
+
// */
|
|
1564
|
+
// nextFrameEvents: any[];
|
|
1565
|
+
// /**
|
|
1566
|
+
// * @internal Timer for the next frame
|
|
1567
|
+
// */
|
|
1568
|
+
// nextFrameTimer: number;
|
|
1569
|
+
|
|
1570
|
+
/**
|
|
1571
|
+
* Manages loading and enabling of community (non-core) plugins
|
|
1572
|
+
* @tutorial Can be used to communicate with other plugins, custom plugin management, ...
|
|
1573
|
+
* @remark Be careful when overriding loading logic, as this may result in other plugins not loading
|
|
1574
|
+
*/
|
|
1575
|
+
plugins: Plugins;
|
|
1576
|
+
/**
|
|
1577
|
+
* @internal Root keyscope of the application
|
|
1578
|
+
*/
|
|
1579
|
+
scope: Scope;
|
|
1580
|
+
/**
|
|
1581
|
+
* Manages the settings modal and its tabs
|
|
1582
|
+
* @tutorial Can be used to open the settings modal to a specific tab, extend the settings modal functionality, ...
|
|
1583
|
+
* @remark Do not use this to get settings values from other plugins, it is better to do this via `app.plugins.getPlugin(ID)?.settings` (check how the plugin stores its settings)
|
|
1584
|
+
*/
|
|
1585
|
+
setting: Setting;
|
|
1586
|
+
// /**
|
|
1587
|
+
// * @internal
|
|
1588
|
+
// */
|
|
1589
|
+
// shareReceiver: { app: App }
|
|
1590
|
+
// /**
|
|
1591
|
+
// * @internal Status bar of the application
|
|
1592
|
+
// */
|
|
1593
|
+
// statusBar: { app: App , containerEl: HTMLElement }
|
|
1594
|
+
/**
|
|
1595
|
+
* Name of the vault with version suffix
|
|
1596
|
+
* @remark Formatted as 'NAME - Obsidian vX.Y.Z'
|
|
1597
|
+
*/
|
|
1598
|
+
title: string;
|
|
1599
|
+
/**
|
|
1600
|
+
* Manages all file operations for the vault, contains hooks for file changes, and an adapter
|
|
1601
|
+
* for low-level file system operations
|
|
1602
|
+
* @tutorial Used for creating your own files and folders, renaming, ...
|
|
1603
|
+
* @tutorial Use `app.vault.adapter` for accessing files outside the vault (desktop-only)
|
|
1604
|
+
* @remark Prefer using the regular `vault` whenever possible
|
|
1605
|
+
*/
|
|
1606
|
+
vault: Vault;
|
|
1607
|
+
/**
|
|
1608
|
+
* Manages the construction of appropriate views when opening a file of a certain type
|
|
1609
|
+
* @remark Prefer usage of view registration via the Plugin class
|
|
1610
|
+
*/
|
|
1611
|
+
viewRegistry: ViewRegistry;
|
|
1612
|
+
/**
|
|
1613
|
+
* Manages the workspace layout, construction, rendering and manipulation of leaves
|
|
1614
|
+
* @tutorial Used for accessing the active editor leaf, grabbing references to your views, ...
|
|
1615
|
+
*/
|
|
1616
|
+
workspace: Workspace;
|
|
1617
|
+
|
|
1618
|
+
/**
|
|
1619
|
+
* Sets the accent color of the application to the OS preference
|
|
1620
|
+
*/
|
|
1621
|
+
adaptToSystemTheme(): void;
|
|
1622
|
+
/**
|
|
1623
|
+
* Sets the accent color of the application (light/dark mode)
|
|
1624
|
+
*/
|
|
1625
|
+
changeTheme(theme: 'moonstone' | 'obsidian'): void;
|
|
1626
|
+
/**
|
|
1627
|
+
* Copies Obsidian URI of given file to clipboard
|
|
1628
|
+
* @param file File to generate URI for
|
|
1629
|
+
*/
|
|
1630
|
+
copyObsidianUrl(file: TFile): void;
|
|
1631
|
+
/**
|
|
1632
|
+
* Disables all CSS transitions in the vault (until manually re-enabled)
|
|
1633
|
+
*/
|
|
1634
|
+
disableCssTransition(): void;
|
|
1635
|
+
/**
|
|
1636
|
+
* Restarts Obsidian and renders workspace in mobile mode
|
|
1637
|
+
* @tutorial Very useful for testing the rendering of your plugin on mobile devices
|
|
1638
|
+
*/
|
|
1639
|
+
emulateMobile(emulate: boolean): void;
|
|
1640
|
+
/**
|
|
1641
|
+
* Enables all CSS transitions in the vault
|
|
1642
|
+
*/
|
|
1643
|
+
enableCssTransition(): void;
|
|
1644
|
+
/**
|
|
1645
|
+
* Manually fix all file links pointing towards image/audio/video resources in element
|
|
1646
|
+
* @param element Element to fix links in
|
|
1647
|
+
*/
|
|
1648
|
+
fixFileLinks(element: HTMLElement): void;
|
|
1649
|
+
/**
|
|
1650
|
+
* Applies an obfuscation font to all text characters in the vault
|
|
1651
|
+
* @tutorial Useful for hiding sensitive information or sharing pretty screenshots of your vault
|
|
1652
|
+
* @remark Uses the `Flow Circular` font
|
|
1653
|
+
* @remark You will have to restart the app to get normal text back
|
|
1654
|
+
*/
|
|
1655
|
+
garbleText(): void;
|
|
1656
|
+
/**
|
|
1657
|
+
* Get the accent color of the application
|
|
1658
|
+
* @remark Often a better alternative than `app.vault.getConfig('accentColor')` as it returns an empty string if no accent color was set
|
|
1659
|
+
*/
|
|
1660
|
+
getAccentColor(): string;
|
|
1661
|
+
/**
|
|
1662
|
+
* Get the current title of the application
|
|
1663
|
+
* @remark The title is based on the currently active leaf
|
|
1664
|
+
*/
|
|
1665
|
+
getAppTitle(): string;
|
|
1666
|
+
/**
|
|
1667
|
+
* Get the URI for opening specified file in Obsidian
|
|
1668
|
+
*/
|
|
1669
|
+
getObsidianUrl(file: TFile): string;
|
|
1670
|
+
/**
|
|
1671
|
+
* Get currently active spellcheck languages
|
|
1672
|
+
* @deprecated Originally spellcheck languages were stored in app settings,
|
|
1673
|
+
* languages are now stored in `localStorage.getItem(spellcheck-languages)`
|
|
1674
|
+
*/
|
|
1675
|
+
getSpellcheckLanguages(): string[];
|
|
1676
|
+
/**
|
|
1677
|
+
* Get the current color scheme of the application
|
|
1678
|
+
* @remark Identical to `app.vault.getConfig('theme')`
|
|
1679
|
+
*/
|
|
1680
|
+
getTheme(): 'moonstone' | 'obsidian';
|
|
1681
|
+
/**
|
|
1682
|
+
* Import attachments into specified folder
|
|
1683
|
+
*/
|
|
1684
|
+
importAttachments(imports: ImportedAttachments[], folder: TFolder): Promise<void>;
|
|
1685
|
+
/**
|
|
1686
|
+
* @internal Initialize the entire application using the provided FS adapter
|
|
1687
|
+
*/
|
|
1688
|
+
initializeWithAdapter(adapter: DataAdapter): Promise<void>;
|
|
1689
|
+
/**
|
|
1690
|
+
* Load a value from the localstorage given key
|
|
1691
|
+
* @param key Key of value to load
|
|
1692
|
+
* @remark This method is device *and* vault specific
|
|
1693
|
+
* @tutorial Use load/saveLocalStorage for saving configuration data that needs to be unique to the current vault
|
|
1694
|
+
*/
|
|
1695
|
+
loadLocalStorage(key: string): string;
|
|
1696
|
+
/**
|
|
1697
|
+
* @internal Add callback to execute on next frame
|
|
1698
|
+
*/
|
|
1699
|
+
nextFrame(callback: () => void): void;
|
|
1700
|
+
/**
|
|
1701
|
+
* @internal Add callback to execute on next frame, and remove after execution
|
|
1702
|
+
*/
|
|
1703
|
+
nextFrameOnceCallback(callback: () => void): void;
|
|
1704
|
+
/**
|
|
1705
|
+
* @internal Add callback to execute on next frame with promise
|
|
1706
|
+
*/
|
|
1707
|
+
nextFramePromise(callback: () => Promise<void>): Promise<void>;
|
|
1708
|
+
/**
|
|
1709
|
+
* @internal
|
|
1710
|
+
*/
|
|
1711
|
+
onMouseEvent(evt: MouseEvent): void;
|
|
1712
|
+
/**
|
|
1713
|
+
* @internal Execute all logged callback (called when next frame is loaded)
|
|
1714
|
+
*/
|
|
1715
|
+
onNextFrame(callback: () => void): void;
|
|
1716
|
+
/**
|
|
1717
|
+
* Open the help vault (or site if mobile)
|
|
1718
|
+
*/
|
|
1719
|
+
openHelp(): void;
|
|
1720
|
+
/**
|
|
1721
|
+
* Open the vault picker
|
|
1722
|
+
*/
|
|
1723
|
+
openVaultChooser(): void;
|
|
1724
|
+
/**
|
|
1725
|
+
* Open the file with OS defined default file browser application
|
|
1726
|
+
*/
|
|
1727
|
+
openWithDefaultApp(path: string): void;
|
|
1728
|
+
/**
|
|
1729
|
+
* @internal Register all basic application commands
|
|
1730
|
+
*/
|
|
1731
|
+
registerCommands(): void;
|
|
1732
|
+
/**
|
|
1733
|
+
* @internal Register a hook for saving workspace data before unload
|
|
1734
|
+
*/
|
|
1735
|
+
registerQuitHook(): void;
|
|
1736
|
+
/**
|
|
1737
|
+
* @internal Save attachment at default attachments location
|
|
1738
|
+
*/
|
|
1739
|
+
saveAttachment(path: string, extension: string, data: ArrayBuffer): Promise<void>;
|
|
1740
|
+
/**
|
|
1741
|
+
* Save a value to the localstorage given key
|
|
1742
|
+
* @param key Key of value to save
|
|
1743
|
+
* @param value Value to save
|
|
1744
|
+
* @remark This method is device *and* vault specific
|
|
1745
|
+
* @tutorial Use load/saveLocalStorage for saving configuration data that needs to be unique to the current vault
|
|
1746
|
+
*/
|
|
1747
|
+
saveLocalStorage(key: string, value: any): void;
|
|
1748
|
+
/**
|
|
1749
|
+
* Set the accent color of the application
|
|
1750
|
+
* @remark Also updates the CSS `--accent` variables
|
|
1751
|
+
*/
|
|
1752
|
+
setAccentColor(color: string): void;
|
|
1753
|
+
/**
|
|
1754
|
+
* Set the path where attachments should be stored
|
|
1755
|
+
*/
|
|
1756
|
+
setAttachmentFolder(path: string): void;
|
|
1757
|
+
/**
|
|
1758
|
+
* Set the spellcheck languages
|
|
1759
|
+
*/
|
|
1760
|
+
setSpellcheckLanguages(languages: string[]): void;
|
|
1761
|
+
/**
|
|
1762
|
+
* Set the current color scheme of the application and reload the CSS
|
|
1763
|
+
*/
|
|
1764
|
+
setTheme(theme: 'moonstone' | 'obsidian'): void;
|
|
1765
|
+
/**
|
|
1766
|
+
* Open the OS file picker at path location
|
|
1767
|
+
*/
|
|
1768
|
+
showInFolder(path: string): void;
|
|
1769
|
+
/**
|
|
1770
|
+
* Show the release notes for provided version as a new leaf
|
|
1771
|
+
* @param version Version to show release notes for (defaults to current version)
|
|
1772
|
+
*/
|
|
1773
|
+
showReleaseNotes(version?: string): void;
|
|
1774
|
+
/**
|
|
1775
|
+
* Updates the accent color and reloads the CSS
|
|
1776
|
+
*/
|
|
1777
|
+
updateAccentColor(): void;
|
|
1778
|
+
/**
|
|
1779
|
+
* Update the font family of the application and reloads the CSS
|
|
1780
|
+
*/
|
|
1781
|
+
updateFontFamily(): void;
|
|
1782
|
+
/**
|
|
1783
|
+
* Update the font size of the application and reloads the CSS
|
|
1784
|
+
*/
|
|
1785
|
+
updateFontSize(): void;
|
|
1786
|
+
/**
|
|
1787
|
+
* Update the inline title rendering in notes
|
|
1788
|
+
*/
|
|
1789
|
+
updateInlineTitleDisplay(): void;
|
|
1790
|
+
/**
|
|
1791
|
+
* Update the color scheme of the application and reloads the CSS
|
|
1792
|
+
*/
|
|
1793
|
+
updateTheme(): void;
|
|
1794
|
+
/**
|
|
1795
|
+
* Update the view header display in notes
|
|
1796
|
+
*/
|
|
1797
|
+
updateViewHeaderDisplay(): void;
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
interface DataAdapter {
|
|
1801
|
+
/**
|
|
1802
|
+
* Base OS path for the vault (e.g. /home/user/vault, or C:\Users\user\documents\vault)
|
|
1803
|
+
*/
|
|
1804
|
+
basePath: string;
|
|
1805
|
+
/**
|
|
1806
|
+
* @internal
|
|
1807
|
+
*/
|
|
1808
|
+
btime: { btime(path: string, btime: number): void };
|
|
1809
|
+
/**
|
|
1810
|
+
* Mapping of file/folder path to vault entry, includes non-MD files
|
|
1811
|
+
*/
|
|
1812
|
+
files: Record<string, FileEntry>;
|
|
1813
|
+
/**
|
|
1814
|
+
* Reference to node fs module
|
|
1815
|
+
*/
|
|
1816
|
+
fs?: typeof fs;
|
|
1817
|
+
/**
|
|
1818
|
+
* Reference to node fs:promises module
|
|
1819
|
+
*/
|
|
1820
|
+
fsPromises?: typeof fsPromises;
|
|
1821
|
+
/**
|
|
1822
|
+
* @internal
|
|
1823
|
+
*/
|
|
1824
|
+
insensitive: boolean;
|
|
1825
|
+
/**
|
|
1826
|
+
* Reference to electron ipcRenderer module
|
|
1827
|
+
*/
|
|
1828
|
+
ipcRenderer?: IpcRenderer;
|
|
1829
|
+
/**
|
|
1830
|
+
* Reference to node path module
|
|
1831
|
+
*/
|
|
1832
|
+
path: typeof path;
|
|
1833
|
+
/**
|
|
1834
|
+
* @internal
|
|
1835
|
+
*/
|
|
1836
|
+
promise: Promise<any>;
|
|
1837
|
+
/**
|
|
1838
|
+
* Reference to node URL module
|
|
1839
|
+
*/
|
|
1840
|
+
url: URL;
|
|
1841
|
+
/**
|
|
1842
|
+
* @internal
|
|
1843
|
+
*/
|
|
1844
|
+
watcher: any;
|
|
1845
|
+
/**
|
|
1846
|
+
* @internal
|
|
1847
|
+
*/
|
|
1848
|
+
watchers: Record<string, { resolvedPath: string, watcher: any }>;
|
|
1849
|
+
|
|
1850
|
+
/**
|
|
1851
|
+
* @internal Apply data write options to file
|
|
1852
|
+
* @param normalizedPath Path to file
|
|
1853
|
+
* @param options Data write options
|
|
1854
|
+
*/
|
|
1855
|
+
applyWriteOptions(normalizedPath: string, options: DataWriteOptions): Promise<void>;
|
|
1856
|
+
/**
|
|
1857
|
+
* Get base path of vault (OS path)
|
|
1858
|
+
*/
|
|
1859
|
+
getBasePath(): string;
|
|
1860
|
+
/**
|
|
1861
|
+
* Get full path of file (OS path)
|
|
1862
|
+
* @param normalizedPath Path to file
|
|
1863
|
+
* @return URL path to file
|
|
1864
|
+
*/
|
|
1865
|
+
getFilePath(normalizedPath: string): string;
|
|
1866
|
+
/**
|
|
1867
|
+
* Get full path of file (OS path)
|
|
1868
|
+
* @param normalizedPath Path to file
|
|
1869
|
+
* @return string full path to file
|
|
1870
|
+
*/
|
|
1871
|
+
getFullPath(normalizedPath: string): string;
|
|
1872
|
+
/**
|
|
1873
|
+
* Get full path of file (OS path)
|
|
1874
|
+
* @param normalizedPath Path to file
|
|
1875
|
+
* @return string full path to file
|
|
1876
|
+
*/
|
|
1877
|
+
getFullRealPath(normalizedPath: string): string;
|
|
1878
|
+
/**
|
|
1879
|
+
* @internal Get resource path of file (URL path)
|
|
1880
|
+
* @param normalizedPath Path to file
|
|
1881
|
+
* @return string URL of form: app://FILEHASH/path/to/file
|
|
1882
|
+
*/
|
|
1883
|
+
getResourcePath(normalizedPath: string): string;
|
|
1884
|
+
/**
|
|
1885
|
+
* @internal Handles vault events
|
|
1886
|
+
*/
|
|
1887
|
+
handler(): void;
|
|
1888
|
+
/**
|
|
1889
|
+
* @internal Kill file system action due to timeout
|
|
1890
|
+
*/
|
|
1891
|
+
kill(): void;
|
|
1892
|
+
/**
|
|
1893
|
+
* @internal
|
|
1894
|
+
*/
|
|
1895
|
+
killLastAction(): void;
|
|
1896
|
+
/**
|
|
1897
|
+
* @internal Generates `this.files` from the file system
|
|
1898
|
+
*/
|
|
1899
|
+
listAll(): Promise<void>;
|
|
1900
|
+
/**
|
|
1901
|
+
* @internal Generates `this.files` for specific directory of the vault
|
|
1902
|
+
*/
|
|
1903
|
+
listRecursive(normalizedPath: string): Promise<void>;
|
|
1904
|
+
/**
|
|
1905
|
+
* @internal Helper function for `listRecursive` reads children of directory
|
|
1906
|
+
* @param normalizedPath Path to directory
|
|
1907
|
+
*/
|
|
1908
|
+
listRecursiveChild(normalizedPath: string): Promise<void>;
|
|
1909
|
+
/**
|
|
1910
|
+
* @internal
|
|
1911
|
+
*/
|
|
1912
|
+
onFileChange(normalizedPath: string): void;
|
|
1913
|
+
/**
|
|
1914
|
+
* @internal
|
|
1915
|
+
*/
|
|
1916
|
+
queue(cb: any): Promise<void>;
|
|
1917
|
+
|
|
1918
|
+
/**
|
|
1919
|
+
* @internal
|
|
1920
|
+
*/
|
|
1921
|
+
reconcileDeletion(normalizedPath: string, normalizedNewPath: string, option: boolean): Promise<void>;
|
|
1922
|
+
/**
|
|
1923
|
+
* @internal
|
|
1924
|
+
*/
|
|
1925
|
+
reconcileFile(normalizedPath: string, normalizedNewPath: string, option: boolean): Promise<void>;
|
|
1926
|
+
/**
|
|
1927
|
+
* @internal
|
|
1928
|
+
*/
|
|
1929
|
+
reconcileFileCreation(normalizedPath: string, normalizedNewPath: string, option: boolean): Promise<void>;
|
|
1930
|
+
/**
|
|
1931
|
+
* @internal
|
|
1932
|
+
*/
|
|
1933
|
+
reconcileFileInternal(normalizedPath: string, normalizedNewPath: string): Promise<void>;
|
|
1934
|
+
/**
|
|
1935
|
+
* @internal
|
|
1936
|
+
*/
|
|
1937
|
+
reconcileFolderCreation(normalizedPath: string, normalizedNewPath: string): Promise<void>;
|
|
1938
|
+
/**
|
|
1939
|
+
* @internal
|
|
1940
|
+
*/
|
|
1941
|
+
reconcileInternalFile(normalizedPath: string): Promise<void>;
|
|
1942
|
+
/**
|
|
1943
|
+
* @internal
|
|
1944
|
+
*/
|
|
1945
|
+
reconcileSymbolicLinkCreation(normalizedPath: string, normalizedNewPath: string): Promise<void>;
|
|
1946
|
+
/**
|
|
1947
|
+
* @internal Remove file from files listing and trigger deletion event
|
|
1948
|
+
*/
|
|
1949
|
+
removeFile(normalizedPath: string): void;
|
|
1950
|
+
/**
|
|
1951
|
+
* @internal
|
|
1952
|
+
*/
|
|
1953
|
+
startWatchpath(normalizedPath: string): Promise<void>;
|
|
1954
|
+
/**
|
|
1955
|
+
* @internal Remove all listeners
|
|
1956
|
+
*/
|
|
1957
|
+
stopWatch(): void;
|
|
1958
|
+
/**
|
|
1959
|
+
* @internal Remove listener on specific path
|
|
1960
|
+
*/
|
|
1961
|
+
stopWatchPath(normalizedPath: string): void;
|
|
1962
|
+
/**
|
|
1963
|
+
* @internal Set whether OS is insensitive to case
|
|
1964
|
+
*/
|
|
1965
|
+
testInsensitive(): void;
|
|
1966
|
+
/**
|
|
1967
|
+
* @internal
|
|
1968
|
+
*/
|
|
1969
|
+
thingsHappening(): void;
|
|
1970
|
+
/**
|
|
1971
|
+
* @internal Trigger an event on handler
|
|
1972
|
+
*/
|
|
1973
|
+
trigger(e: unknown, t: unknown, n: unknown, i: unknown): void;
|
|
1974
|
+
/**
|
|
1975
|
+
* @internal
|
|
1976
|
+
*/
|
|
1977
|
+
update(normalizedPath: string): any;
|
|
1978
|
+
/**
|
|
1979
|
+
* @internal Add change watcher to path
|
|
1980
|
+
*/
|
|
1981
|
+
watch(normalizedPath: string): Promise<void>;
|
|
1982
|
+
/**
|
|
1983
|
+
* @internal Watch recursively for changes
|
|
1984
|
+
*/
|
|
1985
|
+
watchHiddenRecursive(normalizedPath: string): Promise<void>;
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
interface Editor {
|
|
1989
|
+
/**
|
|
1990
|
+
* CodeMirror editor instance
|
|
1991
|
+
*/
|
|
1992
|
+
cm: EditorViewI;
|
|
1993
|
+
/**
|
|
1994
|
+
* HTML instance the CM editor is attached to
|
|
1995
|
+
*/
|
|
1996
|
+
containerEl: HTMLElement;
|
|
1997
|
+
|
|
1998
|
+
/**
|
|
1999
|
+
* Make ranges of text highlighted within the editor given specified class (style)
|
|
2000
|
+
*/
|
|
2001
|
+
addHighlights(ranges: { from: EditorPosition, to: EditorPosition }[], style: 'is-flashing' | 'obsidian-search-match-highlight', remove_previous: boolean, x: boolean): void;
|
|
2002
|
+
/**
|
|
2003
|
+
* Convert editor position to screen position
|
|
2004
|
+
* @param pos Editor position
|
|
2005
|
+
* @param mode Relative to the editor or the application window
|
|
2006
|
+
*/
|
|
2007
|
+
coordsAtPos(pos: EditorPosition, relative_to_editor: boolean): { left: number, top: number, bottom: number, right: number };
|
|
2008
|
+
/**
|
|
2009
|
+
* Unfolds all folded lines one level up
|
|
2010
|
+
* @remark If level 1 and 2 headings are folded, level 2 headings will be unfolded
|
|
2011
|
+
*/
|
|
2012
|
+
foldLess(): void;
|
|
2013
|
+
/**
|
|
2014
|
+
* Folds all the blocks that are of the lowest unfolded level
|
|
2015
|
+
* @remark If there is a document with level 1 and 2 headings, level 2 headings will be folded
|
|
2016
|
+
*/
|
|
2017
|
+
foldMore(): void;
|
|
2018
|
+
/**
|
|
2019
|
+
* Get all ranges that can be folded away in the editor
|
|
2020
|
+
*/
|
|
2021
|
+
getAllFoldableLines(): { from: number, to: number }[];
|
|
2022
|
+
/**
|
|
2023
|
+
* Get a clickable link - if it exists - at specified position
|
|
2024
|
+
*/
|
|
2025
|
+
getClickableTokenAt(pos: EditorPosition): { start: EditorPosition, end: EditorPosition, text: string, type: string } | null;
|
|
2026
|
+
/**
|
|
2027
|
+
* Get all blocks that were folded by their starting character position
|
|
2028
|
+
*/
|
|
2029
|
+
getFoldOffsets(): Set<number>;
|
|
2030
|
+
/**
|
|
2031
|
+
* Checks whether the editor has a highlight of specified class
|
|
2032
|
+
* @remark If no style is specified, checks whether the editor has any highlights
|
|
2033
|
+
*/
|
|
2034
|
+
hasHighlight(style?: string): boolean;
|
|
2035
|
+
/**
|
|
2036
|
+
* Wraps current line around specified characters
|
|
2037
|
+
* @remark Was added in a recent Obsidian update (1.4.0 update cycle)
|
|
2038
|
+
**/
|
|
2039
|
+
insertBlock(start: string, end: string): void;
|
|
2040
|
+
/**
|
|
2041
|
+
* Get the closest character position to the specified coordinates
|
|
2042
|
+
*/
|
|
2043
|
+
posAtCoords(coords: { left: number, top: number }): EditorPosition;
|
|
2044
|
+
/**
|
|
2045
|
+
* Removes all highlights of specified class
|
|
2046
|
+
*/
|
|
2047
|
+
removeHighlights(style: string): void;
|
|
2048
|
+
/**
|
|
2049
|
+
* Adds a search cursor to the editor
|
|
2050
|
+
*/
|
|
2051
|
+
searchCursor: (searchString: string) => {
|
|
2052
|
+
current(): { from: EditorPosition, to: EditorPosition };
|
|
2053
|
+
findAll(): { from: EditorPosition, to: EditorPosition }[];
|
|
2054
|
+
findNext(): { from: EditorPosition, to: EditorPosition };
|
|
2055
|
+
findPrevious(): { from: EditorPosition, to: EditorPosition };
|
|
2056
|
+
replace(replacement: string, origin: string): void;
|
|
2057
|
+
replaceAll(replacement: string, origin: string): void;
|
|
2058
|
+
}
|
|
2059
|
+
/**
|
|
2060
|
+
* Applies specified markdown syntax to selected text or word under cursor
|
|
2061
|
+
*/
|
|
2062
|
+
toggleMarkdownFormatting(syntax: 'bold' | 'italic' | 'strikethrough' | 'highlight' | 'code' | 'math' | 'comment'): void;
|
|
2063
|
+
|
|
2064
|
+
/**
|
|
2065
|
+
* Clean-up function executed after indenting lists
|
|
2066
|
+
*/
|
|
2067
|
+
afterIndent(): void;
|
|
2068
|
+
/**
|
|
2069
|
+
* Expand text
|
|
2070
|
+
* @internal
|
|
2071
|
+
*/
|
|
2072
|
+
expandText(): void;
|
|
2073
|
+
/**
|
|
2074
|
+
* Indents a list by one level
|
|
2075
|
+
*/
|
|
2076
|
+
indentList(): void;
|
|
2077
|
+
/**
|
|
2078
|
+
* Insert a template callout at the current cursor position
|
|
2079
|
+
*/
|
|
2080
|
+
insertCallout(): void;
|
|
2081
|
+
/**
|
|
2082
|
+
* Insert a template code block at the current cursor position
|
|
2083
|
+
*/
|
|
2084
|
+
insertCodeblock(): void;
|
|
2085
|
+
/**
|
|
2086
|
+
* Insert a markdown link at the current cursor position
|
|
2087
|
+
*/
|
|
2088
|
+
insertLink(): void;
|
|
2089
|
+
/**
|
|
2090
|
+
* Insert a mathjax equation block at the current cursor position
|
|
2091
|
+
*/
|
|
2092
|
+
insertMathJax(): void;
|
|
2093
|
+
/**
|
|
2094
|
+
* Insert specified text at the current cursor position
|
|
2095
|
+
* @remark Might be broken, inserts at the end of the document
|
|
2096
|
+
*/
|
|
2097
|
+
insertText(text: string): void;
|
|
2098
|
+
/**
|
|
2099
|
+
* Inserts a new line and continues a markdown bullet point list at the same level
|
|
2100
|
+
*/
|
|
2101
|
+
newlineAndIndentContinueMarkdownList(): void;
|
|
2102
|
+
/**
|
|
2103
|
+
* Inserts a new line at the same indent level
|
|
2104
|
+
*/
|
|
2105
|
+
newlineAndIndentOnly(): void;
|
|
2106
|
+
/**
|
|
2107
|
+
* Get the character position at a mouse event
|
|
2108
|
+
*/
|
|
2109
|
+
posAtMouse(e: MouseEvent): EditorPosition;
|
|
2110
|
+
/**
|
|
2111
|
+
* Toggles blockquote syntax on paragraph under cursor
|
|
2112
|
+
*/
|
|
2113
|
+
toggleBlockquote(): void;
|
|
2114
|
+
/**
|
|
2115
|
+
* Toggle bullet point list syntax on paragraph under cursor
|
|
2116
|
+
*/
|
|
2117
|
+
toggleBulletList(): void;
|
|
2118
|
+
/**
|
|
2119
|
+
* Toggle checkbox syntax on paragraph under cursor
|
|
2120
|
+
*/
|
|
2121
|
+
toggleCheckList(): void;
|
|
2122
|
+
/**
|
|
2123
|
+
* Toggle numbered list syntax on paragraph under cursor
|
|
2124
|
+
*/
|
|
2125
|
+
toggleNumberList(): void;
|
|
2126
|
+
/**
|
|
2127
|
+
* Convert word under cursor into a wikilink
|
|
2128
|
+
* @param embed Whether to embed the link or not
|
|
2129
|
+
*/
|
|
2130
|
+
triggerWikiLink(embed: boolean): void;
|
|
2131
|
+
/**
|
|
2132
|
+
* Unindents a list by one level
|
|
2133
|
+
*/
|
|
2134
|
+
unindentList(): void;
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
interface EventRef {
|
|
2138
|
+
/**
|
|
2139
|
+
* Context applied to the event callback
|
|
2140
|
+
*/
|
|
2141
|
+
ctx?: any;
|
|
2142
|
+
|
|
2143
|
+
/**
|
|
2144
|
+
* Events object the event was registered on
|
|
2145
|
+
*/
|
|
2146
|
+
e: Events;
|
|
2147
|
+
|
|
2148
|
+
/**
|
|
2149
|
+
* Function to be called on event trigger on the events object
|
|
2150
|
+
*/
|
|
2151
|
+
fn(...arg: any[]): void;
|
|
2152
|
+
|
|
2153
|
+
/**
|
|
2154
|
+
* Event name the event was registered on
|
|
2155
|
+
*/
|
|
2156
|
+
name: string;
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
interface FileManager {
|
|
2160
|
+
/**
|
|
2161
|
+
* Reference to App
|
|
2162
|
+
*/
|
|
2163
|
+
app: App;
|
|
2164
|
+
/**
|
|
2165
|
+
* Creates a new Markdown file in specified location and opens it in a new view
|
|
2166
|
+
* @param path - Path to the file to create (missing folders will be created)
|
|
2167
|
+
* @param manner - Where to open the view containing the new file
|
|
2168
|
+
*/
|
|
2169
|
+
createAndOpenMarkdownFile(path: string, location: PaneType): Promise<void>;
|
|
2170
|
+
/**
|
|
2171
|
+
* Create a new file in the vault at specified location
|
|
2172
|
+
* @param location - Location to create the file in, defaults to root
|
|
2173
|
+
* @param filename - Name of the file to create, defaults to "Untitled" (incremented if file already exists)
|
|
2174
|
+
* @param extension - Extension of the file to create, defaults to "md"
|
|
2175
|
+
* @param contents - Contents of the file to create, defaults to empty string
|
|
2176
|
+
*/
|
|
2177
|
+
createNewFile(location: TFolder, filename: string, extension: string, contents: string): Promise<TFile>;
|
|
2178
|
+
/**
|
|
2179
|
+
* Creates a new untitled folder in the vault at specified location
|
|
2180
|
+
* @param location - Location to create the folder in, defaults to root
|
|
2181
|
+
*/
|
|
2182
|
+
createNewFolder(location: TFolder): Promise<TFolder>;
|
|
2183
|
+
/**
|
|
2184
|
+
* Creates a new Markdown file in the vault at specified location
|
|
2185
|
+
*/
|
|
2186
|
+
createNewMarkdownFile(location: TFolder, filename: string, contents: string): Promise<TFile>;
|
|
2187
|
+
/**
|
|
2188
|
+
* Creates a new Markdown file based on linktext and path
|
|
2189
|
+
* @param filename - Name of the file to create
|
|
2190
|
+
* @param path - Path to where the file should be created
|
|
2191
|
+
*/
|
|
2192
|
+
createNewMarkdownFileFromLinktext(filename: string, path: string): Promise<TFile>;
|
|
2193
|
+
/**
|
|
2194
|
+
* @internal
|
|
2195
|
+
*/
|
|
2196
|
+
getAllLinkResolutions(): [];
|
|
2197
|
+
/**
|
|
2198
|
+
* Gets the folder that new markdown files should be saved to, based on the current settings
|
|
2199
|
+
* @param path - The path of the current opened/focused file, used when the user wants new files to be created in the same folder as the current file
|
|
2200
|
+
*/
|
|
2201
|
+
getMarkdownNewFileParent(path: string): TFolder;
|
|
2202
|
+
/**
|
|
2203
|
+
* Insert text into a file
|
|
2204
|
+
* @param file - File to insert text into
|
|
2205
|
+
* @param primary_text - Text to insert (will not be inserted if secondary_text exists)
|
|
2206
|
+
* @param basename - ???
|
|
2207
|
+
* @param secondary_text - Text to insert (always inserted)
|
|
2208
|
+
* @param atStart - Whether to insert text at the start or end of the file
|
|
2209
|
+
*/
|
|
2210
|
+
insertTextIntoFile(file: TFile, primary_text: string, basename: string, secondary_text: string, atStart: boolean): Promise<void>;
|
|
2211
|
+
/**
|
|
2212
|
+
* Iterate over all links in the vault with callback
|
|
2213
|
+
* @param callback - Callback to execute for each link
|
|
2214
|
+
*/
|
|
2215
|
+
iterateAllRefs(callback: (path: string, link: PositionedReference) => void): void;
|
|
2216
|
+
/**
|
|
2217
|
+
* Merge two files
|
|
2218
|
+
* @param file - File to merge to
|
|
2219
|
+
* @param otherFile - File to merge from
|
|
2220
|
+
* @param override - If not empty, will override the contents of the file with this string
|
|
2221
|
+
* @param atStart - Whether to insert text at the start or end of the file
|
|
2222
|
+
*/
|
|
2223
|
+
mergeFile(file: TFile, otherFile: TFile, override: string, atStart: boolean): Promise<void>;
|
|
2224
|
+
/**
|
|
2225
|
+
* Prompt the user to delete a file
|
|
2226
|
+
*/
|
|
2227
|
+
promptForDeletion(file: TFile): Promise<void>;
|
|
2228
|
+
/**
|
|
2229
|
+
* Prompt the user to rename a file
|
|
2230
|
+
*/
|
|
2231
|
+
promptForFileRename(file: TFile): Promise<void>;
|
|
2232
|
+
/**
|
|
2233
|
+
* @internal
|
|
2234
|
+
* Register an extension to be the parent for a specific file type
|
|
2235
|
+
*/
|
|
2236
|
+
registerFileParentCreator(extension: string, location: TFolder): void;
|
|
2237
|
+
/**
|
|
2238
|
+
* @internal
|
|
2239
|
+
* @param callback - Callback to execute for each link
|
|
2240
|
+
*/
|
|
2241
|
+
runAsyncLinkUpdate(callback: (link: LinkUpdate) => any): void;
|
|
2242
|
+
/**
|
|
2243
|
+
* @internal
|
|
2244
|
+
* @param path
|
|
2245
|
+
* @param data
|
|
2246
|
+
*/
|
|
2247
|
+
storeTextFileBackup(path: string, data: string): void;
|
|
2248
|
+
/**
|
|
2249
|
+
* Remove a file and put it in the trash (no confirmation modal)
|
|
2250
|
+
*/
|
|
2251
|
+
trashFile(file: TFile): Promise<void>;
|
|
2252
|
+
/**
|
|
2253
|
+
* @internal: Unregister extension as root input directory for file type
|
|
2254
|
+
*/
|
|
2255
|
+
unregisterFileCreator(extension: string): void;
|
|
2256
|
+
/**
|
|
2257
|
+
* @internal
|
|
2258
|
+
*/
|
|
2259
|
+
updateAllLinks(links: any[]): Promise<void>;
|
|
2260
|
+
/**
|
|
2261
|
+
* @internal
|
|
2262
|
+
*/
|
|
2263
|
+
updateInternalLinks(data: any): any;
|
|
2264
|
+
|
|
2265
|
+
/**
|
|
2266
|
+
* @internal
|
|
2267
|
+
*/
|
|
2268
|
+
fileParentCreatorByType: Map<string, (path: string) => TFolder>;
|
|
2269
|
+
/**
|
|
2270
|
+
* @internal
|
|
2271
|
+
*/
|
|
2272
|
+
inProgressUpdates: null | any[];
|
|
2273
|
+
/**
|
|
2274
|
+
* @internal
|
|
2275
|
+
*/
|
|
2276
|
+
linkUpdaters: {
|
|
2277
|
+
canvas: {
|
|
2278
|
+
app: App,
|
|
2279
|
+
canvas: unknown
|
|
2280
|
+
}
|
|
2281
|
+
};
|
|
2282
|
+
/**
|
|
2283
|
+
* @internal
|
|
2284
|
+
*/
|
|
2285
|
+
updateQueue: {
|
|
2286
|
+
promise: Promise<void>
|
|
2287
|
+
}
|
|
2288
|
+
/**
|
|
2289
|
+
* Reference to Vault
|
|
2290
|
+
*/
|
|
2291
|
+
vault: Vault;
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
interface FileSystemAdapter extends DataAdapter {
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2297
|
+
interface MarkdownPreviewView {
|
|
2298
|
+
renderer: ReadViewRenderer;
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
interface Menu {
|
|
2302
|
+
dom: HTMLElement;
|
|
2303
|
+
items: MenuItem[];
|
|
2304
|
+
onMouseOver(evt: MouseEvent): void;
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
interface MenuItem {
|
|
2308
|
+
callback: () => void;
|
|
2309
|
+
dom: HTMLElement;
|
|
2310
|
+
setSubmenu(): Menu;
|
|
2311
|
+
disabled: boolean;
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
interface MetadataCache {
|
|
2315
|
+
/**
|
|
2316
|
+
* Reference to App
|
|
2317
|
+
*/
|
|
2318
|
+
app: App;
|
|
2319
|
+
/**
|
|
2320
|
+
* @internal
|
|
2321
|
+
*/
|
|
2322
|
+
blockCache: BlockCache;
|
|
2323
|
+
/**
|
|
2324
|
+
* @internal IndexedDB database
|
|
2325
|
+
*/
|
|
2326
|
+
db: IDBDatabase
|
|
2327
|
+
/**
|
|
2328
|
+
* @internal File contents cache
|
|
2329
|
+
*/
|
|
2330
|
+
fileCache: Record<string, FileCacheEntry>;
|
|
2331
|
+
/**
|
|
2332
|
+
* @internal Amount of tasks currently in progress
|
|
2333
|
+
*/
|
|
2334
|
+
inProgressTaskCount: number;
|
|
2335
|
+
/**
|
|
2336
|
+
* @internal Whether the cache is fully loaded
|
|
2337
|
+
*/
|
|
2338
|
+
initialized: boolean;
|
|
2339
|
+
/**
|
|
2340
|
+
* @internal
|
|
2341
|
+
*/
|
|
2342
|
+
linkResolverQueue: any;
|
|
2343
|
+
/**
|
|
2344
|
+
* @internal File hash to metadata cache entry mapping
|
|
2345
|
+
*/
|
|
2346
|
+
metadataCache: Record<string, CachedMetadata>;
|
|
2347
|
+
/**
|
|
2348
|
+
* @internal Callbacks to execute on cache clean
|
|
2349
|
+
*/
|
|
2350
|
+
onCleanCacheCallbacks: any[];
|
|
2351
|
+
/**
|
|
2352
|
+
* @internal Mapping of filename to collection of files that share the same name
|
|
2353
|
+
*/
|
|
2354
|
+
uniqueFileLookup: CustomArrayDict<TFile>;
|
|
2355
|
+
/**
|
|
2356
|
+
* @internal
|
|
2357
|
+
*/
|
|
2358
|
+
userIgnoreFilterCache: any;
|
|
2359
|
+
/**
|
|
2360
|
+
* @internal
|
|
2361
|
+
*/
|
|
2362
|
+
userIgnoreFilters: any;
|
|
2363
|
+
/**
|
|
2364
|
+
* @internal
|
|
2365
|
+
*/
|
|
2366
|
+
userIgnoreFiltersString: string;
|
|
2367
|
+
/**
|
|
2368
|
+
* Reference to Vault
|
|
2369
|
+
*/
|
|
2370
|
+
vault: Vault;
|
|
2371
|
+
/**
|
|
2372
|
+
* @internal
|
|
2373
|
+
*/
|
|
2374
|
+
workQueue: any;
|
|
2375
|
+
/**
|
|
2376
|
+
* @internal
|
|
2377
|
+
*/
|
|
2378
|
+
worker: Worker;
|
|
2379
|
+
/**
|
|
2380
|
+
* @internal
|
|
2381
|
+
*/
|
|
2382
|
+
workerResolve: any;
|
|
2383
|
+
|
|
2384
|
+
/**
|
|
2385
|
+
* Get all property infos of the vault
|
|
2386
|
+
*/
|
|
2387
|
+
getAllPropertyInfos(): Record<string, PropertyInfo>
|
|
2388
|
+
/**
|
|
2389
|
+
* Get all backlink information for a file
|
|
2390
|
+
*/
|
|
2391
|
+
getBacklinksForFile: (file?: TFile) => CustomArrayDict<LinkCache>
|
|
2392
|
+
/**
|
|
2393
|
+
* Get paths of all files cached in the vault
|
|
2394
|
+
*/
|
|
2395
|
+
getCachedFiles(): string[];
|
|
2396
|
+
/**
|
|
2397
|
+
* Get an entry from the file cache
|
|
2398
|
+
*/
|
|
2399
|
+
getFileInfo(path: string): FileCacheEntry;
|
|
2400
|
+
/**
|
|
2401
|
+
* Get property values for frontmatter property key
|
|
2402
|
+
*/
|
|
2403
|
+
getFrontmatterPropertyValuesForKey(key: string): string[];
|
|
2404
|
+
/**
|
|
2405
|
+
* Get all links (resolved or unresolved) in the vault
|
|
2406
|
+
*/
|
|
2407
|
+
getLinkSuggestions(): { file: TFile | null, path: string }[];
|
|
2408
|
+
/**
|
|
2409
|
+
* Get destination of link path
|
|
2410
|
+
*/
|
|
2411
|
+
getLinkpathDest(origin: string, path: string): TFile[];
|
|
2412
|
+
/**
|
|
2413
|
+
* Get all links within the vault per file
|
|
2414
|
+
*/
|
|
2415
|
+
getLinks(): Record<string, Reference[]>;
|
|
2416
|
+
/**
|
|
2417
|
+
* Get all tags within the vault and their usage count
|
|
2418
|
+
*/
|
|
2419
|
+
getTags(): Record<string, number>;
|
|
2420
|
+
|
|
2421
|
+
/**
|
|
2422
|
+
* @internal Clear all caches to null values
|
|
2423
|
+
*/
|
|
2424
|
+
cleanupDeletedCache(): void;
|
|
2425
|
+
/**
|
|
2426
|
+
* @internal
|
|
2427
|
+
*/
|
|
2428
|
+
clear(): any;
|
|
2429
|
+
/**
|
|
2430
|
+
* @internal
|
|
2431
|
+
*/
|
|
2432
|
+
computeMetadataAsync(e: any): Promise<any>;
|
|
2433
|
+
/**
|
|
2434
|
+
* @internal Remove all entries that contain deleted path
|
|
2435
|
+
*/
|
|
2436
|
+
deletePath(path: string): void;
|
|
2437
|
+
/**
|
|
2438
|
+
* @internal Initialize Database connection and load up caches
|
|
2439
|
+
*/
|
|
2440
|
+
initialize(): Promise<void>;
|
|
2441
|
+
/**
|
|
2442
|
+
* @internal Check whether there are no cache tasks in progress
|
|
2443
|
+
*/
|
|
2444
|
+
isCacheClean(): boolean;
|
|
2445
|
+
/**
|
|
2446
|
+
* @internal Check whether file can support metadata (by checking extension support)
|
|
2447
|
+
*/
|
|
2448
|
+
isSupportedFile(file: TFile): boolean;
|
|
2449
|
+
/**
|
|
2450
|
+
* @internal Check whether string is part of the user ignore filters
|
|
2451
|
+
*/
|
|
2452
|
+
isUserIgnored(filter: any): boolean;
|
|
2453
|
+
/**
|
|
2454
|
+
* Iterate over all link references in the vault with callback
|
|
2455
|
+
*/
|
|
2456
|
+
iterateReferences(callback: (path: string) => void): void;
|
|
2457
|
+
/**
|
|
2458
|
+
* @internal
|
|
2459
|
+
*/
|
|
2460
|
+
linkResolver(): void;
|
|
2461
|
+
/**
|
|
2462
|
+
* @internal Execute onCleanCache callbacks if cache is clean
|
|
2463
|
+
*/
|
|
2464
|
+
onCleanCache(): void;
|
|
2465
|
+
/**
|
|
2466
|
+
* @internal On creation of the cache: update metadata cache
|
|
2467
|
+
*/
|
|
2468
|
+
onCreate(file: TFile): void;
|
|
2469
|
+
/**
|
|
2470
|
+
* @internal On creation or modification of the cache: update metadata cache
|
|
2471
|
+
*/
|
|
2472
|
+
onCreateOrModify(file: TFile): void;
|
|
2473
|
+
/**
|
|
2474
|
+
* @internal On deletion of the cache: update metadata cache
|
|
2475
|
+
*/
|
|
2476
|
+
onDelete(file: TFile): void;
|
|
2477
|
+
/**
|
|
2478
|
+
* @internal
|
|
2479
|
+
*/
|
|
2480
|
+
onReceiveMessageFromWorker(e: any): void;
|
|
2481
|
+
/**
|
|
2482
|
+
* @internal On rename of the cache: update metadata cache
|
|
2483
|
+
*/
|
|
2484
|
+
onRename(file: TFile, oldPath: string): void;
|
|
2485
|
+
/**
|
|
2486
|
+
* @internal Check editor for unresolved links and mark these as unresolved
|
|
2487
|
+
*/
|
|
2488
|
+
resolveLinks(editor: Element): void;
|
|
2489
|
+
/**
|
|
2490
|
+
* @internal Update file cache entry and sync to indexedDB
|
|
2491
|
+
*/
|
|
2492
|
+
saveFileCache(path: string, entry: FileCacheEntry): void;
|
|
2493
|
+
/**
|
|
2494
|
+
* @internal Update metadata cache entry and sync to indexedDB
|
|
2495
|
+
*/
|
|
2496
|
+
saveMetaCache(path: string, entry: CachedMetadata): void;
|
|
2497
|
+
/**
|
|
2498
|
+
* @internal Show a notice that the cache is being rebuilt
|
|
2499
|
+
*/
|
|
2500
|
+
showIndexingNotice(): void;
|
|
2501
|
+
/**
|
|
2502
|
+
* @internal
|
|
2503
|
+
*/
|
|
2504
|
+
trigger(e: any): void;
|
|
2505
|
+
/**
|
|
2506
|
+
* @internal Re-resolve all links for changed path
|
|
2507
|
+
*/
|
|
2508
|
+
updateRelatedLinks(path: string): void;
|
|
2509
|
+
/**
|
|
2510
|
+
* @internal Update user ignore filters from settings
|
|
2511
|
+
*/
|
|
2512
|
+
updateUserIgnoreFilters(): void;
|
|
2513
|
+
/**
|
|
2514
|
+
* @internal Bind actions to listeners on vault
|
|
2515
|
+
*/
|
|
2516
|
+
watchVaultChanges(): void;
|
|
2517
|
+
/**
|
|
2518
|
+
* @internal Send message to worker to update metadata cache
|
|
2519
|
+
*/
|
|
2520
|
+
work(cacheEntry: any): void;
|
|
2521
|
+
|
|
2522
|
+
_getLinkpathDest(origin: string, path: string): TFile[];
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2525
|
+
interface Modal {
|
|
2526
|
+
/**
|
|
2527
|
+
* @internal Background applied to application to dim it
|
|
2528
|
+
*/
|
|
2529
|
+
bgEl: HTMLElement;
|
|
2530
|
+
/**
|
|
2531
|
+
* @internal Opacity percentage of the background
|
|
2532
|
+
*/
|
|
2533
|
+
bgOpacity: number;
|
|
2534
|
+
/**
|
|
2535
|
+
* @internal Whether the background is being dimmed
|
|
2536
|
+
*/
|
|
2537
|
+
dimBackground: boolean;
|
|
2538
|
+
/**
|
|
2539
|
+
* @internal Modal container element
|
|
2540
|
+
*/
|
|
2541
|
+
modalEl: HTMLElement;
|
|
2542
|
+
/**
|
|
2543
|
+
* @internal Selection logic handler
|
|
2544
|
+
*/
|
|
2545
|
+
selection: WindowSelection;
|
|
2546
|
+
/**
|
|
2547
|
+
* Reference to the global Window object
|
|
2548
|
+
*/
|
|
2549
|
+
win: Window;
|
|
2550
|
+
|
|
2551
|
+
/**
|
|
2552
|
+
* @internal On escape key press close modal
|
|
2553
|
+
*/
|
|
2554
|
+
onEscapeKey(): void;
|
|
2555
|
+
/**
|
|
2556
|
+
* @internal On closing of the modal
|
|
2557
|
+
*/
|
|
2558
|
+
onWindowClose(): void;
|
|
2559
|
+
/**
|
|
2560
|
+
* @internal Set the background opacity of the dimmed background
|
|
2561
|
+
* @param opacity Opacity percentage
|
|
2562
|
+
*/
|
|
2563
|
+
setBackgroundOpacity(opacity: string): this;
|
|
2564
|
+
/**
|
|
2565
|
+
* @internal Set the content of the modal
|
|
2566
|
+
* @param content Content to set
|
|
2567
|
+
*/
|
|
2568
|
+
setContent(content: HTMLElement | string): this;
|
|
2569
|
+
/**
|
|
2570
|
+
* @internal Set whether the background should be dimmed
|
|
2571
|
+
* @param dim Whether the background should be dimmed
|
|
2572
|
+
*/
|
|
2573
|
+
setDimBackground(dim: boolean): this;
|
|
2574
|
+
/**
|
|
2575
|
+
* @internal Set the title of the modal
|
|
2576
|
+
* @param title Title to set
|
|
2577
|
+
*/
|
|
2578
|
+
setTitle(title: string): this;
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2581
|
+
interface Scope {
|
|
2582
|
+
/**
|
|
2583
|
+
* Overridden keys that exist in this scope
|
|
2584
|
+
*/
|
|
2585
|
+
keys: KeyScope[];
|
|
2586
|
+
|
|
2587
|
+
/**
|
|
2588
|
+
* @internal Scope that this scope is a child of
|
|
2589
|
+
*/
|
|
2590
|
+
parent: Scope | undefined;
|
|
2591
|
+
/**
|
|
2592
|
+
* @internal - Callback to execute when scope is matched
|
|
2593
|
+
*/
|
|
2594
|
+
cb: (() => boolean) | undefined;
|
|
2595
|
+
/**
|
|
2596
|
+
* @internal
|
|
2597
|
+
*/
|
|
2598
|
+
tabFocusContainer: HTMLElement | null;
|
|
2599
|
+
/**
|
|
2600
|
+
* @internal Execute keypress within this scope
|
|
2601
|
+
* @param event - Keyboard event
|
|
2602
|
+
* @param keypress - Pressed key information
|
|
2603
|
+
*/
|
|
2604
|
+
handleKey(event: KeyboardEvent, keypress: KeymapInfo): any;
|
|
2605
|
+
/**
|
|
2606
|
+
* @internal
|
|
2607
|
+
* @deprecated - Executes same functionality as `Scope.register`
|
|
2608
|
+
*/
|
|
2609
|
+
registerKey(modifiers: Modifier[], key: string | null, func: KeymapEventListener): KeymapEventHandler;
|
|
2610
|
+
/**
|
|
2611
|
+
* @internal
|
|
2612
|
+
*/
|
|
2613
|
+
setTabFocusContainer(container: HTMLElement): void;
|
|
2614
|
+
}
|
|
2615
|
+
|
|
2616
|
+
interface Setting extends Modal {
|
|
2617
|
+
/**
|
|
2618
|
+
* Current active tab of the settings modal
|
|
2619
|
+
*/
|
|
2620
|
+
activateTab: SettingTab;
|
|
2621
|
+
/**
|
|
2622
|
+
* @internal Container element containing the community plugins
|
|
2623
|
+
*/
|
|
2624
|
+
communityPluginTabContainer: HTMLElement;
|
|
2625
|
+
/**
|
|
2626
|
+
* @internal Container element containing the community plugins header
|
|
2627
|
+
*/
|
|
2628
|
+
communityPluginTabHeaderGroup: HTMLElement;
|
|
2629
|
+
/**
|
|
2630
|
+
* Previously opened tab ID
|
|
2631
|
+
*/
|
|
2632
|
+
lastTabId: string;
|
|
2633
|
+
/**
|
|
2634
|
+
* List of all plugin tabs (core and community, ordered by precedence)
|
|
2635
|
+
*/
|
|
2636
|
+
pluginTabs: SettingTab[];
|
|
2637
|
+
/**
|
|
2638
|
+
* List of all core settings tabs (editor, files & links, ...)
|
|
2639
|
+
*/
|
|
2640
|
+
settingTabs: SettingTab[];
|
|
2641
|
+
/**
|
|
2642
|
+
* @internal Container element containing the core settings
|
|
2643
|
+
*/
|
|
2644
|
+
tabContainer: HTMLElement;
|
|
2645
|
+
/**
|
|
2646
|
+
* @internal Container for currently active settings tab
|
|
2647
|
+
*/
|
|
2648
|
+
tabContentContainer: HTMLElement;
|
|
2649
|
+
/**
|
|
2650
|
+
* @internal Container for all settings tabs
|
|
2651
|
+
*/
|
|
2652
|
+
tabHeadersEl: HTMLElement;
|
|
2653
|
+
|
|
2654
|
+
/**
|
|
2655
|
+
* Open a specific tab by ID
|
|
2656
|
+
* @param id ID of the tab to open
|
|
2657
|
+
*/
|
|
2658
|
+
openTabById(id: string): void;
|
|
2659
|
+
/**
|
|
2660
|
+
* @internal Add a new plugin tab to the settings modal
|
|
2661
|
+
* @param tab Tab to add
|
|
2662
|
+
*/
|
|
2663
|
+
addSettingTab(tab: SettingTab): void;
|
|
2664
|
+
/**
|
|
2665
|
+
* @internal Closes the currently active tab
|
|
2666
|
+
*/
|
|
2667
|
+
closeActiveTab(): void;
|
|
2668
|
+
/**
|
|
2669
|
+
* @internal Check whether tab is a plugin tab
|
|
2670
|
+
* @param tab Tab to check
|
|
2671
|
+
*/
|
|
2672
|
+
isPluginSettingTab(tab: SettingTab): boolean;
|
|
2673
|
+
/**
|
|
2674
|
+
* @internal Open a specific tab by tab reference
|
|
2675
|
+
* @param tab Tab to open
|
|
2676
|
+
*/
|
|
2677
|
+
openTab(tab: SettingTab): void;
|
|
2678
|
+
/**
|
|
2679
|
+
* @internal Remove a plugin tab from the settings modal
|
|
2680
|
+
* @param tab Tab to remove
|
|
2681
|
+
*/
|
|
2682
|
+
removeSettingTab(tab: SettingTab): void;
|
|
2683
|
+
/**
|
|
2684
|
+
* @internal Update the title of the modal
|
|
2685
|
+
* @param tab Tab to update the title to
|
|
2686
|
+
*/
|
|
2687
|
+
updateModalTitle(tab: SettingTab): void;
|
|
2688
|
+
/**
|
|
2689
|
+
* @internal Update a tab section
|
|
2690
|
+
*/
|
|
2691
|
+
updatePluginSection(): void;
|
|
2692
|
+
}
|
|
2693
|
+
|
|
2694
|
+
interface SettingTab {
|
|
2695
|
+
/**
|
|
2696
|
+
* Unique ID of the tab
|
|
2697
|
+
*/
|
|
2698
|
+
id: string;
|
|
2699
|
+
/**
|
|
2700
|
+
* Sidebar name of the tab
|
|
2701
|
+
*/
|
|
2702
|
+
name: string;
|
|
2703
|
+
/**
|
|
2704
|
+
* Sidebar navigation element of the tab
|
|
2705
|
+
*/
|
|
2706
|
+
navEl: HTMLElement;
|
|
2707
|
+
/**
|
|
2708
|
+
* Reference to the settings modal
|
|
2709
|
+
*/
|
|
2710
|
+
setting: Setting;
|
|
2711
|
+
/**
|
|
2712
|
+
* Reference to the plugin that initialised the tab
|
|
2713
|
+
* @if Tab is a plugin tab
|
|
2714
|
+
*/
|
|
2715
|
+
plugin?: Plugin;
|
|
2716
|
+
/**
|
|
2717
|
+
* Reference to installed plugins element
|
|
2718
|
+
* @if Tab is the community plugins tab
|
|
2719
|
+
*/
|
|
2720
|
+
installedPluginsEl?: HTMLElement;
|
|
2721
|
+
|
|
2722
|
+
// TODO: Editor, Files & Links, Appearance and About all have private properties too
|
|
2723
|
+
}
|
|
2724
|
+
|
|
2725
|
+
interface TFile {
|
|
2726
|
+
deleted: boolean;
|
|
2727
|
+
}
|
|
2728
|
+
|
|
2729
|
+
interface Vault {
|
|
2730
|
+
/**
|
|
2731
|
+
* Low-level file system adapter for read and write operations
|
|
2732
|
+
* @tutorial Can be used to read binaries, or files not located directly within the vault
|
|
2733
|
+
*/
|
|
2734
|
+
adapter: DataAdapter;
|
|
2735
|
+
/**
|
|
2736
|
+
* @internal Max size of the cache in bytes
|
|
2737
|
+
*/
|
|
2738
|
+
cacheLimit: number;
|
|
2739
|
+
/**
|
|
2740
|
+
* Object containing all config settings for the vault (editor, appearance, ... settings)
|
|
2741
|
+
* @remark Prefer usage of `app.vault.getConfig(key)` to get settings, config does not contain settings that were not changed from their default value
|
|
2742
|
+
*/
|
|
2743
|
+
config: AppVaultConfig;
|
|
2744
|
+
/**
|
|
2745
|
+
* @internal Timestamp of the last config change
|
|
2746
|
+
*/
|
|
2747
|
+
configTs: number;
|
|
2748
|
+
/**
|
|
2749
|
+
* @internal Mapping of path to Obsidian folder or file structure
|
|
2750
|
+
*/
|
|
2751
|
+
fileMap: Record<string, TAbstractFile>;
|
|
2752
|
+
|
|
2753
|
+
on(name: 'config-changed', callback: () => void, ctx?: any): EventRef;
|
|
2754
|
+
|
|
2755
|
+
/**
|
|
2756
|
+
* @internal Add file as child/parent to respective folders
|
|
2757
|
+
*/
|
|
2758
|
+
addChild(file: TAbstractFile): void;
|
|
2759
|
+
/**
|
|
2760
|
+
* @internal Check whether new file path is available
|
|
2761
|
+
*/
|
|
2762
|
+
checkForDuplicate(file: TAbstractFile, newPath: string): boolean;
|
|
2763
|
+
/**
|
|
2764
|
+
* @internal Check whether path has valid formatting (no dots/spaces at end, ...)
|
|
2765
|
+
*/
|
|
2766
|
+
checkPath(path: string): boolean;
|
|
2767
|
+
/**
|
|
2768
|
+
* @internal Remove a vault config file
|
|
2769
|
+
*/
|
|
2770
|
+
deleteConfigJson(configFile: string): Promise<void>;
|
|
2771
|
+
/**
|
|
2772
|
+
* Check whether a file exists in the vault
|
|
2773
|
+
*/
|
|
2774
|
+
exists(file: TAbstractFile, senstive?: boolean): Promise<boolean>;
|
|
2775
|
+
/**
|
|
2776
|
+
* @internal
|
|
2777
|
+
*/
|
|
2778
|
+
generateFiles(e: AsyncGenerator<TFile>, t: boolean): Promise<void>;
|
|
2779
|
+
/**
|
|
2780
|
+
* Get an abstract file by path, insensitive to case
|
|
2781
|
+
*/
|
|
2782
|
+
getAbstractFileByPathInsensitive(path: string): TAbstractFile | null;
|
|
2783
|
+
/**
|
|
2784
|
+
* @internal Get path for file that does not conflict with other existing files
|
|
2785
|
+
*/
|
|
2786
|
+
getAvailablePath(path: string, extension: string): string;
|
|
2787
|
+
/**
|
|
2788
|
+
* @internal Get path for attachment that does not conflict with other existing files
|
|
2789
|
+
*/
|
|
2790
|
+
getAvailablePathForAttachments(filename: string, file: TAbstractFile, extension: string): string;
|
|
2791
|
+
/**
|
|
2792
|
+
* Get value from config by key
|
|
2793
|
+
* @remark Default value will be selected if config value was not manually changed
|
|
2794
|
+
* @param key Key of config value
|
|
2795
|
+
*/
|
|
2796
|
+
getConfig(string: ConfigItem): any;
|
|
2797
|
+
/**
|
|
2798
|
+
* Get path to config file (relative to vault root)
|
|
2799
|
+
*/
|
|
2800
|
+
getConfigFile(configFile: string): string;
|
|
2801
|
+
/**
|
|
2802
|
+
* Get direct parent of file
|
|
2803
|
+
* @param file File to get parent of
|
|
2804
|
+
*/
|
|
2805
|
+
getDirectParent(file: TAbstractFile): TFolder | null;
|
|
2806
|
+
/**
|
|
2807
|
+
* @internal Check whether files map cache is empty
|
|
2808
|
+
*/
|
|
2809
|
+
isEmpty(): boolean;
|
|
2810
|
+
/**
|
|
2811
|
+
* @internal Iterate over the files and read them
|
|
2812
|
+
*/
|
|
2813
|
+
iterateFiles(files: TFile[], cachedRead: boolean): void;
|
|
2814
|
+
/**
|
|
2815
|
+
* @internal Load vault adapter
|
|
2816
|
+
*/
|
|
2817
|
+
load(): Promise<void>;
|
|
2818
|
+
/**
|
|
2819
|
+
* @internal Listener for all events on the vault
|
|
2820
|
+
*/
|
|
2821
|
+
onChange(eventType: string, path: string, x: any, y: any): void;
|
|
2822
|
+
/**
|
|
2823
|
+
* Read a config file from the vault and parse it as JSON
|
|
2824
|
+
* @param config Name of config file
|
|
2825
|
+
*/
|
|
2826
|
+
readConfigJson(config: string): Promise<null | object>;
|
|
2827
|
+
/**
|
|
2828
|
+
* Read a config file (full path) from the vault and parse it as JSON
|
|
2829
|
+
* @param path Full path to config file
|
|
2830
|
+
*/
|
|
2831
|
+
readJson(path: string): Promise<null | object>;
|
|
2832
|
+
/**
|
|
2833
|
+
* Read a plugin config file (full path relative to vault root) from the vault and parse it as JSON
|
|
2834
|
+
* @param path Full path to plugin config file
|
|
2835
|
+
*/
|
|
2836
|
+
readPluginData(path: string): Promise<null | object>;
|
|
2837
|
+
/**
|
|
2838
|
+
* Read a file from the vault as a string
|
|
2839
|
+
* @param path Path to file
|
|
2840
|
+
*/
|
|
2841
|
+
readRaw(path: string): Promise<string>;
|
|
2842
|
+
/**
|
|
2843
|
+
* @internal Reload all config files
|
|
2844
|
+
*/
|
|
2845
|
+
reloadConfig(): void;
|
|
2846
|
+
/**
|
|
2847
|
+
* @internal Remove file as child/parent from respective folders
|
|
2848
|
+
* @param file File to remove
|
|
2849
|
+
*/
|
|
2850
|
+
removeChild(file: TAbstractFile): void;
|
|
2851
|
+
/**
|
|
2852
|
+
* @internal Get the file by absolute path
|
|
2853
|
+
* @param path Path to file
|
|
2854
|
+
*/
|
|
2855
|
+
resolveFilePath(path: string): TAbstractFile | null;
|
|
2856
|
+
/**
|
|
2857
|
+
* @internal Get the file by Obsidian URL
|
|
2858
|
+
*/
|
|
2859
|
+
resolveFileUrl(url: string): TAbstractFile | null;
|
|
2860
|
+
/**
|
|
2861
|
+
* @internal Debounced function for saving config
|
|
2862
|
+
*/
|
|
2863
|
+
requestSaveConfig(): void;
|
|
2864
|
+
/**
|
|
2865
|
+
* @internal Save app and appearance configs to disk
|
|
2866
|
+
*/
|
|
2867
|
+
saveConfig(): Promise<void>;
|
|
2868
|
+
/**
|
|
2869
|
+
* Set value of config by key
|
|
2870
|
+
* @param key Key of config value
|
|
2871
|
+
* @param value Value to set
|
|
2872
|
+
*/
|
|
2873
|
+
setConfig(key: ConfigItem, value: any): void;
|
|
2874
|
+
/**
|
|
2875
|
+
* Set where the config files are stored (relative to vault root)
|
|
2876
|
+
* @param configDir Path to config files
|
|
2877
|
+
*/
|
|
2878
|
+
setConfigDir(configDir: string): void;
|
|
2879
|
+
/**
|
|
2880
|
+
* @internal Set file cache limit
|
|
2881
|
+
*/
|
|
2882
|
+
setFileCacheLimit(limit: number): void;
|
|
2883
|
+
/**
|
|
2884
|
+
* @internal Load all config files into memory
|
|
2885
|
+
*/
|
|
2886
|
+
setupConfig(): Promise<void>;
|
|
2887
|
+
/**
|
|
2888
|
+
* @internal Trigger an event on handler
|
|
2889
|
+
*/
|
|
2890
|
+
trigger(type: string): void;
|
|
2891
|
+
/**
|
|
2892
|
+
* Write a config file to disk
|
|
2893
|
+
* @param config Name of config file
|
|
2894
|
+
* @param data Data to write
|
|
2895
|
+
*/
|
|
2896
|
+
writeConfigJson(config: string, data: object): Promise<void>;
|
|
2897
|
+
/**
|
|
2898
|
+
* Write a config file (full path) to disk
|
|
2899
|
+
* @param path Full path to config file
|
|
2900
|
+
* @param data Data to write
|
|
2901
|
+
* @param pretty Whether to insert tabs or spaces
|
|
2902
|
+
*/
|
|
2903
|
+
writeJson(path: string, data: object, pretty?: boolean): Promise<void>;
|
|
2904
|
+
/**
|
|
2905
|
+
* Write a plugin config file (path relative to vault root) to disk
|
|
2906
|
+
*/
|
|
2907
|
+
writePluginData(path: string, data: object): Promise<void>;
|
|
2908
|
+
}
|
|
2909
|
+
|
|
2910
|
+
interface View {
|
|
2911
|
+
headerEl: HTMLElement;
|
|
2912
|
+
titleEl: HTMLElement;
|
|
2913
|
+
}
|
|
2914
|
+
|
|
2915
|
+
interface Workspace {
|
|
2916
|
+
/**
|
|
2917
|
+
* Currently active tab group
|
|
2918
|
+
*/
|
|
2919
|
+
activeTabGroup: WorkspaceTabs;
|
|
2920
|
+
/**
|
|
2921
|
+
* Reference to App
|
|
2922
|
+
*/
|
|
2923
|
+
app: App;
|
|
2924
|
+
/**
|
|
2925
|
+
* @internal
|
|
2926
|
+
*/
|
|
2927
|
+
backlinkInDocument?: any;
|
|
2928
|
+
/**
|
|
2929
|
+
* Registered CodeMirror editor extensions, to be applied to all CM instances
|
|
2930
|
+
*/
|
|
2931
|
+
editorExtensions: Extension[];
|
|
2932
|
+
/**
|
|
2933
|
+
* @internal
|
|
2934
|
+
*/
|
|
2935
|
+
editorSuggest: { currentSuggest?: EditorSuggest<any>, suggests: EditorSuggest<any>[] };
|
|
2936
|
+
/**
|
|
2937
|
+
* @internal
|
|
2938
|
+
*/
|
|
2939
|
+
floatingSplit: WorkspaceSplit;
|
|
2940
|
+
/**
|
|
2941
|
+
* @internal
|
|
2942
|
+
*/
|
|
2943
|
+
hoverLinkSources: Record<string, HoverLinkSource>;
|
|
2944
|
+
/**
|
|
2945
|
+
* Last opened file in the vault
|
|
2946
|
+
*/
|
|
2947
|
+
lastActiveFile: TFile;
|
|
2948
|
+
/**
|
|
2949
|
+
* @internal
|
|
2950
|
+
*/
|
|
2951
|
+
lastTabGroupStacked: boolean;
|
|
2952
|
+
/**
|
|
2953
|
+
* @internal
|
|
2954
|
+
*/
|
|
2955
|
+
layoutItemQueue: any[];
|
|
2956
|
+
/**
|
|
2957
|
+
* Workspace has finished loading
|
|
2958
|
+
*/
|
|
2959
|
+
layoutReady: boolean;
|
|
2960
|
+
/**
|
|
2961
|
+
* @internal
|
|
2962
|
+
*/
|
|
2963
|
+
leftSidebarToggleButtonEl: HTMLElement;
|
|
2964
|
+
/**
|
|
2965
|
+
* @internal Array of renderCallbacks
|
|
2966
|
+
*/
|
|
2967
|
+
mobileFileInfos: any[];
|
|
2968
|
+
/**
|
|
2969
|
+
* @internal
|
|
2970
|
+
*/
|
|
2971
|
+
onLayoutReadyCallbacks?: any;
|
|
2972
|
+
/**
|
|
2973
|
+
* Protocol handlers registered on the workspace
|
|
2974
|
+
*/
|
|
2975
|
+
protocolHandlers: Map<string, ObsidianProtocolHandler>;
|
|
2976
|
+
/**
|
|
2977
|
+
* Tracks last opened files in the vault
|
|
2978
|
+
*/
|
|
2979
|
+
recentFileTracker: RecentFileTracker;
|
|
2980
|
+
/**
|
|
2981
|
+
* @internal
|
|
2982
|
+
*/
|
|
2983
|
+
rightSidebarToggleButtonEl: HTMLElement;
|
|
2984
|
+
/**
|
|
2985
|
+
* @internal Keyscope registered to the vault
|
|
2986
|
+
*/
|
|
2987
|
+
scope: Scope;
|
|
2988
|
+
/**
|
|
2989
|
+
* List of states that were closed and may be reopened
|
|
2990
|
+
*/
|
|
2991
|
+
undoHistory: StateHistory[];
|
|
2992
|
+
|
|
2993
|
+
/**
|
|
2994
|
+
* @internal Change active leaf and trigger leaf change event
|
|
2995
|
+
*/
|
|
2996
|
+
activeLeafEvents(): void;
|
|
2997
|
+
/**
|
|
2998
|
+
* @internal Add file to mobile file info
|
|
2999
|
+
*/
|
|
3000
|
+
addMobileFileInfo(file: any): void;
|
|
3001
|
+
/**
|
|
3002
|
+
* @internal Clear layout of workspace and destruct all leaves
|
|
3003
|
+
*/
|
|
3004
|
+
clearLayout(): Promise<void>;
|
|
3005
|
+
/**
|
|
3006
|
+
* @internal Create a leaf in the selected tab group or last used tab group
|
|
3007
|
+
* @param tabs Tab group to create leaf in
|
|
3008
|
+
*/
|
|
3009
|
+
createLeafInTabGroup(tabs?: WorkspaceTabs): WorkspaceLeaf;
|
|
3010
|
+
/**
|
|
3011
|
+
* @internal Deserialize workspace entries into actual Leaf objects
|
|
3012
|
+
* @param leaf Leaf entry to deserialize
|
|
3013
|
+
* @param ribbon Whether the leaf belongs to the left or right ribbon
|
|
3014
|
+
*/
|
|
3015
|
+
deserializeLayout(leaf: LeafEntry, ribbon?: 'left' | 'right'): Promise<WorkspaceLeaf>;
|
|
3016
|
+
/**
|
|
3017
|
+
* @internal Reveal leaf in side ribbon with specified view type and state
|
|
3018
|
+
* @param type View type of leaf
|
|
3019
|
+
* @param ribbon Side ribbon to reveal leaf in
|
|
3020
|
+
* @param viewstate Open state of leaf
|
|
3021
|
+
*/
|
|
3022
|
+
ensureSideLeaf(type: string, ribbon: 'left' | 'right', viewstate: OpenViewState): void;
|
|
3023
|
+
/**
|
|
3024
|
+
* Get active file view if exists
|
|
3025
|
+
*/
|
|
3026
|
+
getActiveFileView(): FileView | null;
|
|
3027
|
+
/**
|
|
3028
|
+
* @deprecated Use `getActiveViewOfType` instead
|
|
3029
|
+
*/
|
|
3030
|
+
getActiveLeafOfViewType<T extends View>(type: Constructor<T>): T | null;
|
|
3031
|
+
/**
|
|
3032
|
+
* Get adjacent leaf in specified direction
|
|
3033
|
+
* @remark Potentially does not work
|
|
3034
|
+
*/
|
|
3035
|
+
getAdjacentLeafInDirection(leaf: WorkspaceLeaf, direction: 'top' | 'bottom' | 'left' | 'right'): WorkspaceLeaf | null;
|
|
3036
|
+
/**
|
|
3037
|
+
* @internal Get the direction where the leaf should be dropped on dragevent
|
|
3038
|
+
*/
|
|
3039
|
+
getDropDirection(e: DragEvent, rect: DOMRect, directions: ['left', 'right'], leaf: WorkspaceLeaf): 'left' | 'right' | 'top' | 'bottom' | 'center';
|
|
3040
|
+
/**
|
|
3041
|
+
* @internal Get the leaf where the leaf should be dropped on dragevent
|
|
3042
|
+
* @param e Drag event
|
|
3043
|
+
*/
|
|
3044
|
+
getDropLocation(e: DragEvent): WorkspaceLeaf | null;
|
|
3045
|
+
/**
|
|
3046
|
+
* Get the workspace split for the currently focused container
|
|
3047
|
+
*/
|
|
3048
|
+
getFocusedContainer(): WorkspaceSplit;
|
|
3049
|
+
|
|
3050
|
+
getLeavesOfType(viewType: 'file-explorer'): FileExplorerLeaf[];
|
|
3051
|
+
/**
|
|
3052
|
+
* Get n last opened files of type (defaults to 10)
|
|
3053
|
+
*/
|
|
3054
|
+
getRecentFiles(arg?: { showMarkdown: boolean, showCanvas: boolean, showNonImageAttachments: boolean, showImages: boolean, maxCount: number }): string[];
|
|
3055
|
+
/**
|
|
3056
|
+
* Get leaf in the side ribbon/dock and split if necessary
|
|
3057
|
+
* @param sideRibbon Side ribbon to get leaf from
|
|
3058
|
+
* @param split Whether to split the leaf if it does not exist
|
|
3059
|
+
*/
|
|
3060
|
+
getSideLeaf(sideRibbon: WorkspaceSidedock | WorkspaceMobileDrawer, split: boolean): WorkspaceLeaf;
|
|
3061
|
+
/**
|
|
3062
|
+
* @internal
|
|
3063
|
+
*/
|
|
3064
|
+
handleExternalLinkContextMenu(menu: Menu, linkText: string): void;
|
|
3065
|
+
/**
|
|
3066
|
+
* @internal
|
|
3067
|
+
*/
|
|
3068
|
+
handleLinkContextMenu(menu: Menu, linkText: string, sourcePath: string): void;
|
|
3069
|
+
/**
|
|
3070
|
+
* @internal Check if leaf has been attached to the workspace
|
|
3071
|
+
*/
|
|
3072
|
+
isAttached(leaf?: WorkspaceLeaf): boolean;
|
|
3073
|
+
/**
|
|
3074
|
+
* Iterate the leaves of a split
|
|
3075
|
+
*/
|
|
3076
|
+
iterateLeaves(split: WorkspaceSplit, callback: (leaf: WorkspaceLeaf) => any): void;
|
|
3077
|
+
/**
|
|
3078
|
+
* Iterate the tabs of a split till meeting a condition
|
|
3079
|
+
*/
|
|
3080
|
+
iterateTabs(tabs: WorkspaceSplit | WorkspaceSplit[], cb: (leaf: WorkspaceLeaf) => boolean): boolean;
|
|
3081
|
+
/**
|
|
3082
|
+
* @internal Load workspace from disk and initialize
|
|
3083
|
+
*/
|
|
3084
|
+
loadLayout(): Promise<void>;
|
|
3085
|
+
/**
|
|
3086
|
+
* @internal Handles drag event on leaf
|
|
3087
|
+
*/
|
|
3088
|
+
onDragLeaf(e: DragEvent, leaf: WorkspaceLeaf): void;
|
|
3089
|
+
/**
|
|
3090
|
+
* @internal Handles layout change and saves layout to disk
|
|
3091
|
+
*/
|
|
3092
|
+
onLayoutChange(leaf?: WorkspaceLeaf): void;
|
|
3093
|
+
/**
|
|
3094
|
+
* @internal
|
|
3095
|
+
*/
|
|
3096
|
+
onLinkContextMenu(args: any[]): void;
|
|
3097
|
+
/**
|
|
3098
|
+
* @internal
|
|
3099
|
+
*/
|
|
3100
|
+
onQuickPreview(args: any[]): void;
|
|
3101
|
+
/**
|
|
3102
|
+
* @internal
|
|
3103
|
+
*/
|
|
3104
|
+
onResize(): void;
|
|
3105
|
+
/**
|
|
3106
|
+
* @internal
|
|
3107
|
+
*/
|
|
3108
|
+
onStartLink(leaf: WorkspaceLeaf): void;
|
|
3109
|
+
/**
|
|
3110
|
+
* Open a leaf in a popup window
|
|
3111
|
+
* @remark Prefer usage of `app.workspace.openPopoutLeaf`
|
|
3112
|
+
*/
|
|
3113
|
+
openPopout(data?: WorkspaceWindowInitData): WorkspaceWindow;
|
|
3114
|
+
/**
|
|
3115
|
+
* @internal Push leaf change to history
|
|
3116
|
+
*/
|
|
3117
|
+
pushUndoHistory(leaf: WorkspaceLeaf, parentID: string, rootID: string): void;
|
|
3118
|
+
/**
|
|
3119
|
+
* @internal Get drag event target location
|
|
3120
|
+
*/
|
|
3121
|
+
recursiveGetTarget(e: DragEvent, leaf: WorkspaceLeaf): WorkspaceTabs | null;
|
|
3122
|
+
/**
|
|
3123
|
+
* @internal Register a CodeMirror editor extension
|
|
3124
|
+
* @remark Prefer registering the extension via the Plugin class
|
|
3125
|
+
*/
|
|
3126
|
+
registerEditorExtension(extension: Extension): void;
|
|
3127
|
+
/**
|
|
3128
|
+
* @internal Registers hover link source
|
|
3129
|
+
*/
|
|
3130
|
+
registerHoverLinkSource(key: string, source: HoverLinkSource): void;
|
|
3131
|
+
/**
|
|
3132
|
+
* @internal Registers Obsidian protocol handler
|
|
3133
|
+
*/
|
|
3134
|
+
registerObsidianProtocolHandler(protocol: string, handler: ObsidianProtocolHandler): void;
|
|
3135
|
+
/**
|
|
3136
|
+
* @internal Constructs hook for receiving URI actions
|
|
3137
|
+
*/
|
|
3138
|
+
registerUriHook(): void;
|
|
3139
|
+
/**
|
|
3140
|
+
* @internal Request execution of activeLeaf change events
|
|
3141
|
+
*/
|
|
3142
|
+
requestActiveLeafEvents(): void;
|
|
3143
|
+
/**
|
|
3144
|
+
* @internal Request execution of resize event
|
|
3145
|
+
*/
|
|
3146
|
+
requestResize(): void;
|
|
3147
|
+
/**
|
|
3148
|
+
* @internal Request execution of layout update event
|
|
3149
|
+
*/
|
|
3150
|
+
requestUpdateLayout(): void;
|
|
3151
|
+
/**
|
|
3152
|
+
* Save workspace layout to disk
|
|
3153
|
+
*/
|
|
3154
|
+
saveLayout(): Promise<void>;
|
|
3155
|
+
/**
|
|
3156
|
+
* @internal Use deserialized layout data to reconstruct the workspace
|
|
3157
|
+
*/
|
|
3158
|
+
setLayout(data: SerializedWorkspace): Promise<void>;
|
|
3159
|
+
/**
|
|
3160
|
+
* @internal Split leaves in specified direction
|
|
3161
|
+
*/
|
|
3162
|
+
splitLeaf(leaf: WorkspaceLeaf, newleaf: WorkspaceLeaf, direction?: SplitDirection, before?: boolean): void;
|
|
3163
|
+
/**
|
|
3164
|
+
* Split provided leaf, or active leaf if none provided
|
|
3165
|
+
*/
|
|
3166
|
+
splitLeafOrActive(leaf?: WorkspaceLeaf, direction?: SplitDirection): void;
|
|
3167
|
+
/**
|
|
3168
|
+
* @internal
|
|
3169
|
+
*/
|
|
3170
|
+
trigger(e: any): void;
|
|
3171
|
+
/**
|
|
3172
|
+
* @internal Unregister a CodeMirror editor extension
|
|
3173
|
+
*/
|
|
3174
|
+
unregisterEditorExtension(extension: Extension): void;
|
|
3175
|
+
/**
|
|
3176
|
+
* @internal Unregister hover link source
|
|
3177
|
+
*/
|
|
3178
|
+
unregisterHoverLinkSource(key: string): void;
|
|
3179
|
+
/**
|
|
3180
|
+
* @internal Unregister Obsidian protocol handler
|
|
3181
|
+
*/
|
|
3182
|
+
unregisterObsidianProtocolHandler(protocol: string): void;
|
|
3183
|
+
/**
|
|
3184
|
+
* @internal
|
|
3185
|
+
*/
|
|
3186
|
+
updateFrameless(): void;
|
|
3187
|
+
/**
|
|
3188
|
+
* @internal Invoke workspace layout update, redraw and save
|
|
3189
|
+
*/
|
|
3190
|
+
updateLayout(): void;
|
|
3191
|
+
/**
|
|
3192
|
+
* @internal Update visibility of tab group
|
|
3193
|
+
*/
|
|
3194
|
+
updateMobileVisibleTabGroup(): void;
|
|
3195
|
+
/**
|
|
3196
|
+
* Update the internal title of the application
|
|
3197
|
+
* @remark This title is shown as the application title in the OS taskbar
|
|
3198
|
+
*/
|
|
3199
|
+
updateTitle(): void;
|
|
3200
|
+
}
|
|
3201
|
+
|
|
3202
|
+
interface WorkspaceLeaf {
|
|
3203
|
+
id?: string;
|
|
3204
|
+
|
|
3205
|
+
activeTime?: number;
|
|
3206
|
+
|
|
3207
|
+
parent?: WorkspaceSplit;
|
|
3208
|
+
|
|
3209
|
+
tabHeaderEl: HTMLElement;
|
|
3210
|
+
tabHeaderInnerIconEl: HTMLElement;
|
|
3211
|
+
tabHeaderInnerTitleEl: HTMLElement;
|
|
3212
|
+
}
|
|
3213
|
+
|
|
3214
|
+
interface WorkspaceSplit {
|
|
3215
|
+
parent?: WorkspaceSplit;
|
|
3216
|
+
}
|
|
3217
|
+
}
|