From 9b14cc75e4df2e99dfbc8f7f94a961dcd9f78f7b Mon Sep 17 00:00:00 2001 From: Austin Peterson Date: Tue, 7 Sep 2021 19:43:05 -0600 Subject: [PATCH] Updated electron demo [ci skip] --- demos/electron/README.md | 16 ++++++++++------ demos/electron/main.js | 2 ++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/demos/electron/README.md b/demos/electron/README.md index 355bb1b..7283aa7 100644 --- a/demos/electron/README.md +++ b/demos/electron/README.md @@ -1,15 +1,19 @@ # Electron This library is compatible with Electron and should just work out of the box. -The demonstration uses Electron 9.0.5. The library is added via `require` from -the renderer process. Note that Electron now requires `nodeIntegration: true` -in order to `require('XLSX')` in the renderer process. It can also be required -from the main process, as shown in this demo to render a version string in the -About dialog on OSX. +The demonstration uses Electron 14.0.0. The library is added via `require` from +the renderer process. + +Electron 9.0.0 and later require the preference `nodeIntegration: true` in order +to `require('XLSX')` in the renderer process. Electron 12.0.0 and later also +require `worldSafeExecuteJavascript: true` and `contextIsolation: true` + +The library can also be required from the main process, as shown in this demo +to render a version string in the About dialog on OSX. The standard HTML5 `FileReader` techniques from the browser apply to Electron. This demo includes a drag-and-drop box as well as a file input box, mirroring -the [SheetJS Data Preview Live Demo](http://oss.sheetjs.com/js-xlsx/) +the [SheetJS Data Preview Live Demo](http://oss.sheetjs.com/sheetjs/) The core data in this demo is an editable HTML table. The readers build up the table using `sheet_to_html` (with `editable:true` option) and the writers scrape diff --git a/demos/electron/main.js b/demos/electron/main.js index 55ab045..be72259 100644 --- a/demos/electron/main.js +++ b/demos/electron/main.js @@ -11,6 +11,8 @@ function createWindow() { win = new electron.BrowserWindow({ width: 800, height: 600, webPreferences: { + worldSafeExecuteJavaScript: true, // required for Electron 12+ + contextIsolation: false, // required for Electron 12+ nodeIntegration: true, enableRemoteModule: true }