docs: [Electron Demo] - update documentation to include information about file type associations.

This commit is contained in:
syntaxbullet 2025-05-01 12:38:41 +02:00
parent 843441893b
commit 3134922c55

@ -87,8 +87,9 @@ document.getElementById("xlf").addEventListener("change", handleFile, false);
**Drag and Drop**
The [drag and drop snippet](/docs/solutions/input#example-user-submissions)
applies to DIV elements on the page.
In the demo the [drag and drop snippet](/docs/solutions/input#example-user-submissions)
applies to the entire window via the `document.body` element. However it can easily be
applied to any element on the page.
For example, assuming a DIV on the page:
@ -307,7 +308,41 @@ When the demo was last tested on Windows ARM, the generated binary targeted x64.
The program will run on ARM64 Windows.
:::
### Working with OS level file open events.
The demo has been preconfigured to handle OS level file open events, such as the "open with" context menu or `open` CLI command for all file types SheetJS supports.
In order to register your application as a handler for any other file types, it is necessary to modify the `package.json` file as such.
```json
// ...existing content
"build": {
"appId": "com.sheetjs.electron",
"fileAssociations": [
{
"ext": [ // supported extensions to register with the OS.
"xls","xlsx","xlsm","xlsb","xml","csv","txt","dif",
"sylk","slk","prn","ods","fods","htm","html","numbers"
],
"name": "Spreadsheet / Delimited File",
"description": "Spreadsheets and delimited text files opened by SheetJS-Electron",
"role": "Editor"
}
],
"mac": { "target": "dmg" },
"win": { "target": "nsis" },
"linux": { "target": "deb" }
},
```
this snippet makes it possible to generate installers for MacOS, Windows and Linux which will automatically register the application as a handler for the specified file types.
```sh
npm run dist # generate installers for macos, windows and linux
```
:::info pass
It is also possible to open files using the "open with" context menu without registering the application as a handler for the specified file types. This however, requires manually selecting the application binary as a target to open the file with.
:::
### Testing
5) Download [the test file `pres.numbers`](https://docs.sheetjs.com/pres.numbers)