From 3134922c55e11983b6a5e6fe30fbe0a833f8a62e Mon Sep 17 00:00:00 2001 From: syntaxbullet Date: Thu, 1 May 2025 12:38:41 +0200 Subject: [PATCH] docs: [Electron Demo] - update documentation to include information about file type associations. --- docz/docs/03-demos/19-desktop/01-electron.md | 39 +++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/docz/docs/03-demos/19-desktop/01-electron.md b/docz/docs/03-demos/19-desktop/01-electron.md index 344803e..8c3c2f2 100644 --- a/docz/docs/03-demos/19-desktop/01-electron.md +++ b/docz/docs/03-demos/19-desktop/01-electron.md @@ -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)