docs: revised the recent documents feature page (#25941)
* docs: revised the recent documents feature page * docs: fixed lint errors in the recent documents feature page * docs: slightly improved consistency of steps in the recent documents feature page
This commit is contained in:
parent
4ce7ca6cfb
commit
12e3c85081
2 changed files with 36 additions and 13 deletions
BIN
docs/images/recent-documents.png
Normal file
BIN
docs/images/recent-documents.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
|
@ -1,5 +1,7 @@
|
||||||
# Recent Documents (Windows & macOS)
|
# Recent Documents (Windows & macOS)
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
Windows and macOS provide access to a list of recent documents opened by
|
Windows and macOS provide access to a list of recent documents opened by
|
||||||
the application via JumpList or dock menu, respectively.
|
the application via JumpList or dock menu, respectively.
|
||||||
|
|
||||||
|
@ -11,39 +13,58 @@ __Application dock menu:__
|
||||||
|
|
||||||
![macOS Dock Menu][dock-menu-image]
|
![macOS Dock Menu][dock-menu-image]
|
||||||
|
|
||||||
To add a file to recent documents, you can use the
|
To add a file to recent documents, you need to use the
|
||||||
[app.addRecentDocument][addrecentdocument] API:
|
[app.addRecentDocument][addrecentdocument] API.
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
### Add an item to recent documents
|
||||||
|
|
||||||
|
Starting with a working application from the
|
||||||
|
[Quick Start Guide](quick-start.md), add the following lines to the
|
||||||
|
`main.js` file:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const { app } = require('electron')
|
const { app } = require('electron')
|
||||||
|
|
||||||
app.addRecentDocument('/Users/USERNAME/Desktop/work.type')
|
app.addRecentDocument('/Users/USERNAME/Desktop/work.type')
|
||||||
```
|
```
|
||||||
|
|
||||||
And you can use [app.clearRecentDocuments][clearrecentdocuments] API to empty
|
After launching the Electron application, right click the application icon.
|
||||||
the recent documents list:
|
You should see the item you just added. In this guide, the item is a Markdown
|
||||||
|
file located in the root of the project:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Clear the list of recent documents
|
||||||
|
|
||||||
|
To clear the list of recent documents, you need to use
|
||||||
|
[app.clearRecentDocuments][clearrecentdocuments] API in the `main.js` file:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const { app } = require('electron')
|
const { app } = require('electron')
|
||||||
|
|
||||||
app.clearRecentDocuments()
|
app.clearRecentDocuments()
|
||||||
```
|
```
|
||||||
|
|
||||||
## Windows Notes
|
## Additional information
|
||||||
|
|
||||||
In order to be able to use this feature on Windows, your application has to be
|
### Windows Notes
|
||||||
registered as a handler of the file type of the document, otherwise the file
|
|
||||||
won't appear in JumpList even after you have added it. You can find everything
|
To use this feature on Windows, your application has to be registered as
|
||||||
|
a handler of the file type of the document, otherwise the file won't appear
|
||||||
|
in JumpList even after you have added it. You can find everything
|
||||||
on registering your application in [Application Registration][app-registration].
|
on registering your application in [Application Registration][app-registration].
|
||||||
|
|
||||||
When a user clicks a file from the JumpList, a new instance of your application
|
When a user clicks a file from the JumpList, a new instance of your application
|
||||||
will be started with the path of the file added as a command line argument.
|
will be started with the path of the file added as a command line argument.
|
||||||
|
|
||||||
## macOS Notes
|
### macOS Notes
|
||||||
|
|
||||||
### Adding the Recent Documents list to the application menu:
|
#### Add the Recent Documents list to the application menu
|
||||||
|
|
||||||
![macOS Recent Documents menu item][menu-item-image]
|
You can add menu items to access and clear recent documents by adding the
|
||||||
|
following code snippet to your menu template:
|
||||||
You can add menu items to access and clear recent documents by adding the following code snippet to your menu's template.
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
@ -62,6 +83,8 @@ You can add menu items to access and clear recent documents by adding the follow
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
![macOS Recent Documents menu item][menu-item-image]
|
||||||
|
|
||||||
When a file is requested from the recent documents menu, the `open-file` event
|
When a file is requested from the recent documents menu, the `open-file` event
|
||||||
of `app` module will be emitted for it.
|
of `app` module will be emitted for it.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue