diff --git a/docs/api/app.md b/docs/api/app.md index 00580c0ac84..56586ab5b2d 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -6,7 +6,8 @@ The following example shows how to quit the application when the last window is closed: ```javascript -const { app } = require('electron'); +const {app} = require('electron'); + app.on('window-all-closed', () => { app.quit(); }); diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index d4ed6c03322..e15c53cdb80 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -4,10 +4,10 @@ ```javascript // In the main process. -const { BrowserWindow } = require('electron'); +const {BrowserWindow} = require('electron'); // Or in the renderer process. -const { BrowserWindow } = require('electron').remote; +const {BrowserWindow} = require('electron').remote; let win = new BrowserWindow({ width: 800, height: 600, show: false }); win.on('closed', () => { diff --git a/docs/api/chrome-command-line-switches.md b/docs/api/chrome-command-line-switches.md index 71f669e18e8..751d9295614 100644 --- a/docs/api/chrome-command-line-switches.md +++ b/docs/api/chrome-command-line-switches.md @@ -7,7 +7,7 @@ your app's main script before the [ready][ready] event of the [app][app] module is emitted: ```javascript -const { app } = require('electron'); +const {app} = require('electron'); app.commandLine.appendSwitch('remote-debugging-port', '8315'); app.commandLine.appendSwitch('host-rules', 'MAP * 127.0.0.1'); diff --git a/docs/api/clipboard.md b/docs/api/clipboard.md index 38bd8659422..9a8c7304323 100644 --- a/docs/api/clipboard.md +++ b/docs/api/clipboard.md @@ -5,7 +5,7 @@ The following example shows how to write a string to the clipboard: ```javascript -const { clipboard } = require('electron'); +const {clipboard} = require('electron'); clipboard.writeText('Example String'); ``` diff --git a/docs/api/content-tracing.md b/docs/api/content-tracing.md index e6f6b7a0d2d..8df1ca69988 100644 --- a/docs/api/content-tracing.md +++ b/docs/api/content-tracing.md @@ -8,7 +8,7 @@ This module does not include a web interface so you need to open result. ```javascript -const { contentTracing } = require('electron'); +const {contentTracing} = require('electron'); const options = { categoryFilter: '*', diff --git a/docs/api/crash-reporter.md b/docs/api/crash-reporter.md index 4e4b49df0f7..6575bbea765 100644 --- a/docs/api/crash-reporter.md +++ b/docs/api/crash-reporter.md @@ -6,7 +6,7 @@ The following is an example of automatically submitting a crash report to a remote server: ```javascript -const { crashReporter } = require('electron'); +const {crashReporter} = require('electron'); crashReporter.start({ productName: 'YourName', diff --git a/docs/api/desktop-capturer.md b/docs/api/desktop-capturer.md index dd37d3b60aa..20e6d8625df 100644 --- a/docs/api/desktop-capturer.md +++ b/docs/api/desktop-capturer.md @@ -5,7 +5,7 @@ microphone, camera, or screen. ```javascript // In the renderer process. -var { desktopCapturer } = require('electron'); +const {desktopCapturer} = require('electron'); desktopCapturer.getSources({types: ['window', 'screen']}, (error, sources) => { if (error) throw error; diff --git a/docs/api/dialog.md b/docs/api/dialog.md index 84aac7c63bf..c5cc0227a60 100644 --- a/docs/api/dialog.md +++ b/docs/api/dialog.md @@ -6,7 +6,8 @@ An example of showing a dialog to select multiple files and directories: ```javascript var win = ...; // BrowserWindow in which to show the dialog -const { dialog } = require('electron'); +const {dialog} = require('electron'); + console.log(dialog.showOpenDialog({ properties: [ 'openFile', 'openDirectory', 'multiSelections' ]})); ``` @@ -14,7 +15,7 @@ The Dialog is opened from Electron's main thread. If you want to use the dialog object from a renderer process, remember to access it using the remote: ```javascript -const { dialog } = require('electron').remote; +const {dialog} = require('electron').remote; ``` ## Methods diff --git a/docs/api/frameless-window.md b/docs/api/frameless-window.md index 733baa5c902..fd0f5d4faef 100644 --- a/docs/api/frameless-window.md +++ b/docs/api/frameless-window.md @@ -14,7 +14,7 @@ To create a frameless window, you need to set `frame` to `false` in ```javascript -const { BrowserWindow } = require('electron'); +const {BrowserWindow} = require('electron'); let win = new BrowserWindow({ width: 800, height: 600, frame: false }); ``` diff --git a/docs/api/global-shortcut.md b/docs/api/global-shortcut.md index 6acb5201066..d611423c2a3 100644 --- a/docs/api/global-shortcut.md +++ b/docs/api/global-shortcut.md @@ -11,8 +11,7 @@ not have the keyboard focus. You should not use this module until the `ready` event of the app module is emitted. ```javascript -const electron = require('electron'); -const { app, globalShortcut } = electron; +const {app, globalShortcut} = require('electron'); app.on('ready', () => { // Register a 'CommandOrControl+X' shortcut listener. diff --git a/docs/api/ipc-main.md b/docs/api/ipc-main.md index e40e4408c07..0b7acbfefa0 100644 --- a/docs/api/ipc-main.md +++ b/docs/api/ipc-main.md @@ -23,7 +23,7 @@ processes: ```javascript // In main process. -const { ipcMain } = require('electron'); +const {ipcMain} = require('electron'); ipcMain.on('asynchronous-message', (event, arg) => { console.log(arg); // prints "ping" event.sender.send('asynchronous-reply', 'pong'); @@ -37,7 +37,7 @@ ipcMain.on('synchronous-message', (event, arg) => { ```javascript // In renderer process (web page). -const { ipcRenderer } = require('electron'); +const {ipcRenderer} = require('electron'); console.log(ipcRenderer.sendSync('synchronous-message', 'ping')); // prints "pong" ipcRenderer.on('asynchronous-reply', (event, arg) => { diff --git a/docs/api/menu.md b/docs/api/menu.md index 53ba9430a4b..133b681a337 100644 --- a/docs/api/menu.md +++ b/docs/api/menu.md @@ -15,7 +15,7 @@ the user right clicks the page: ```html @@ -53,7 +53,7 @@ As of 0.37, you can use built-in modules. ```javascript -const { app, BrowserWindow } = require('electron'); +const {app, BrowserWindow} = require('electron'); ``` If you need the entire `electron` module, you can require it and then using @@ -61,7 +61,7 @@ destructuring to access the individual modules from `electron`. ```javascript const electron = require('electron'); -const { app, BrowserWindow } = electron; +const {app, BrowserWindow} = electron; ``` This is equivalent to the following code: diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index cd4b9f23178..f5c3d386de8 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -9,7 +9,7 @@ the [`BrowserWindow`](browser-window.md) object. An example of accessing the `webContents` object: ```javascript -const { BrowserWindow } = require('electron'); +const {BrowserWindow} = require('electron'); let win = new BrowserWindow({width: 800, height: 1500}); win.loadURL('http://github.com'); @@ -673,7 +673,7 @@ By default, an empty `options` will be regarded as: ``` ```javascript -const { BrowserWindow } = require('electron'); +const {BrowserWindow} = require('electron'); const fs = require('fs'); let win = new BrowserWindow({width: 800, height: 600}); diff --git a/docs/api/web-frame.md b/docs/api/web-frame.md index e7ed05567f2..f77e2ce7eec 100644 --- a/docs/api/web-frame.md +++ b/docs/api/web-frame.md @@ -5,7 +5,7 @@ An example of zooming current page to 200%. ```javascript -const { webFrame } = require('electron'); +const {webFrame} = require('electron'); webFrame.setZoomFactor(2); ``` diff --git a/docs/api/web-view-tag.md b/docs/api/web-view-tag.md index da23658c957..481d0b2dec8 100644 --- a/docs/api/web-view-tag.md +++ b/docs/api/web-view-tag.md @@ -644,7 +644,7 @@ Fired when the guest page attempts to open a new browser window. The following example code opens the new url in system's default browser. ```javascript -const { shell } = require('electron'); +const {shell} = require('electron'); webview.addEventListener('new-window', (e) => { const protocol = require('url').parse(e.url).protocol; @@ -732,7 +732,7 @@ webview.send('ping'); ```javascript // In guest page. -var { ipcRenderer } = require('electron'); +const {ipcRenderer} = require('electron'); ipcRenderer.on('ping', () => { ipcRenderer.sendToHost('pong'); }); diff --git a/docs/tutorial/application-packaging.md b/docs/tutorial/application-packaging.md index 257119a573a..f1c100e6db9 100644 --- a/docs/tutorial/application-packaging.md +++ b/docs/tutorial/application-packaging.md @@ -71,7 +71,7 @@ require('/path/to/example.asar/dir/module.js'); You can also display a web page in an `asar` archive with `BrowserWindow`: ```javascript -const { BrowserWindow } = require('electron'); +const {BrowserWindow} = require('electron'); let win = new BrowserWindow({width: 800, height: 600}); win.loadURL('file:///path/to/example.asar/static/index.html'); ``` diff --git a/docs/tutorial/desktop-environment-integration.md b/docs/tutorial/desktop-environment-integration.md index 939da469b22..dd7826cdf0d 100644 --- a/docs/tutorial/desktop-environment-integration.md +++ b/docs/tutorial/desktop-environment-integration.md @@ -209,7 +209,7 @@ You can use [BrowserWindow.setThumbarButtons][setthumbarbuttons] to set thumbnail toolbar in your application: ```javascript -const { BrowserWindow } = require('electron'); +const {BrowserWindow} = require('electron'); const path = require('path'); let win = new BrowserWindow({ diff --git a/docs/tutorial/online-offline-events.md b/docs/tutorial/online-offline-events.md index 7e784e336e3..2b7a6d7edc6 100644 --- a/docs/tutorial/online-offline-events.md +++ b/docs/tutorial/online-offline-events.md @@ -71,7 +71,7 @@ _online-status.html_