|
4 | 4 |
|
5 | 5 | import { invoke } from '@tauri-apps/api/core' |
6 | 6 |
|
| 7 | +/** |
| 8 | + * Manage the operating system recent documents list. |
| 9 | + * |
| 10 | + * @module |
| 11 | + */ |
| 12 | + |
| 13 | +/** |
| 14 | + * Adds a document to this app's recent documents list. |
| 15 | + * |
| 16 | + * #### Platform-specific |
| 17 | + * |
| 18 | + * - **Linux / Android / iOS:** Unsupported. |
| 19 | + * |
| 20 | + * @param path Local filesystem path to the document. |
| 21 | + * |
| 22 | + * @example |
| 23 | + * ```typescript |
| 24 | + * import { addRecentDocument } from '@tauri-apps/plugin-recent-doc'; |
| 25 | + * await addRecentDocument('/path/to/document.txt'); |
| 26 | + * ``` |
| 27 | + * |
| 28 | + * This function rejects when called on an unsupported platform. |
| 29 | + * On Windows, it also rejects if the native shell API fails (for example, when the path cannot be resolved). |
| 30 | + * |
| 31 | + * @since 2.0.0 |
| 32 | + */ |
7 | 33 | async function addRecentDocument(path: string): Promise<void> { |
8 | 34 | return invoke('plugin:recent-doc|add_recent_document', { path }) |
9 | 35 | } |
10 | 36 |
|
| 37 | +/** |
| 38 | + * Gets this app's recent documents list from the operating system. |
| 39 | + * |
| 40 | + * #### Platform-specific |
| 41 | + * |
| 42 | + * - **Linux / Android / iOS:** Unsupported. |
| 43 | + * |
| 44 | + * @example |
| 45 | + * ```typescript |
| 46 | + * import { getRecentDocuments } from '@tauri-apps/plugin-recent-doc'; |
| 47 | + * const recent = await getRecentDocuments(); |
| 48 | + * ``` |
| 49 | + * |
| 50 | + * This function rejects when called on an unsupported platform. |
| 51 | + * On Windows, it also rejects if the native shell API fails. |
| 52 | + * |
| 53 | + * @since 2.0.0 |
| 54 | + */ |
11 | 55 | async function getRecentDocuments(): Promise<string[]> { |
12 | 56 | return invoke<string[]>('plugin:recent-doc|get_recent_documents') |
13 | 57 | } |
14 | 58 |
|
| 59 | +/** |
| 60 | + * Clears this app's recent documents list in the operating system. |
| 61 | + * |
| 62 | + * #### Platform-specific |
| 63 | + * |
| 64 | + * - **Linux / Android / iOS:** Unsupported. |
| 65 | + * |
| 66 | + * @example |
| 67 | + * ```typescript |
| 68 | + * import { clearRecentDocuments } from '@tauri-apps/plugin-recent-doc'; |
| 69 | + * await clearRecentDocuments(); |
| 70 | + * ``` |
| 71 | + * |
| 72 | + * This function rejects when called on an unsupported platform. |
| 73 | + * On Windows, it also rejects if the native shell API fails. |
| 74 | + * |
| 75 | + * @since 2.0.0 |
| 76 | + */ |
15 | 77 | async function clearRecentDocuments(): Promise<void> { |
16 | 78 | return invoke('plugin:recent-doc|clear_recent_documents') |
17 | 79 | } |
|
0 commit comments