diff --git a/docs/fiddles/features/drag-and-drop/index.html b/docs/fiddles/features/drag-and-drop/index.html new file mode 100644 index 00000000000..d451042521a --- /dev/null +++ b/docs/fiddles/features/drag-and-drop/index.html @@ -0,0 +1,18 @@ + + +
+ ++ We are using node , + Chrome , + and Electron . +
+ Drag me + + + diff --git a/docs/fiddles/features/drag-and-drop/main.js b/docs/fiddles/features/drag-and-drop/main.js new file mode 100644 index 00000000000..bdc28bbf450 --- /dev/null +++ b/docs/fiddles/features/drag-and-drop/main.js @@ -0,0 +1,41 @@ +const { app, BrowserWindow, ipcMain, nativeImage, NativeImage } = require('electron') +const fs = require('fs'); +const http = require('http'); + +function createWindow () { + const win = new BrowserWindow({ + width: 800, + height: 600, + webPreferences: { + nodeIntegration: true + } + }) + + win.loadFile('index.html') +} +const iconName = 'iconForDragAndDrop.png'; +const icon = fs.createWriteStream(`${process.cwd()}/${iconName}`); +http.get('http://img.icons8.com/ios/452/drag-and-drop.png', (response) => { + response.pipe(icon); +}); + +app.whenReady().then(createWindow) + +ipcMain.on('ondragstart', (event, filePath) => { + event.sender.startDrag({ + file: filePath, + icon: `${process.cwd()}/${iconName}` + }) +}) + +app.on('window-all-closed', () => { + if (process.platform !== 'darwin') { + app.quit() + } +}) + +app.on('activate', () => { + if (BrowserWindow.getAllWindows().length === 0) { + createWindow() + } +}) diff --git a/docs/fiddles/features/drag-and-drop/renderer.js b/docs/fiddles/features/drag-and-drop/renderer.js new file mode 100644 index 00000000000..33f328e30ae --- /dev/null +++ b/docs/fiddles/features/drag-and-drop/renderer.js @@ -0,0 +1,9 @@ +const { ipcRenderer } = require('electron') +const fs = require('fs') + +document.getElementById('drag').ondragstart = (event) => { + const fileName = 'drag-and-drop.md' + fs.writeFileSync(fileName, '# Test drag and drop'); + event.preventDefault() + ipcRenderer.send('ondragstart', process.cwd() + `/${fileName}`) +} diff --git a/docs/fiddles/features/keyboard-shortcuts/global/index.html b/docs/fiddles/features/keyboard-shortcuts/global/index.html new file mode 100644 index 00000000000..a3855d2640d --- /dev/null +++ b/docs/fiddles/features/keyboard-shortcuts/global/index.html @@ -0,0 +1,16 @@ + + + + ++ We are using node , + Chrome , + and Electron . +
+ + diff --git a/docs/fiddles/features/keyboard-shortcuts/global/main.js b/docs/fiddles/features/keyboard-shortcuts/global/main.js new file mode 100644 index 00000000000..5b4196f7781 --- /dev/null +++ b/docs/fiddles/features/keyboard-shortcuts/global/main.js @@ -0,0 +1,31 @@ +const { app, BrowserWindow, globalShortcut } = require('electron') + +function createWindow () { + const win = new BrowserWindow({ + width: 800, + height: 600, + webPreferences: { + nodeIntegration: true + } + }) + + win.loadFile('index.html') +} + +app.whenReady().then(() => { + globalShortcut.register('Alt+CommandOrControl+I', () => { + console.log('Electron loves global shortcuts!') + }) +}).then(createWindow) + +app.on('window-all-closed', () => { + if (process.platform !== 'darwin') { + app.quit() + } +}) + +app.on('activate', () => { + if (BrowserWindow.getAllWindows().length === 0) { + createWindow() + } +}) diff --git a/docs/fiddles/features/keyboard-shortcuts/interception-from-main/index.html b/docs/fiddles/features/keyboard-shortcuts/interception-from-main/index.html new file mode 100644 index 00000000000..6f9d1abf860 --- /dev/null +++ b/docs/fiddles/features/keyboard-shortcuts/interception-from-main/index.html @@ -0,0 +1,14 @@ + + + + ++ We are using node , + Chrome , + and Electron . +
+ + diff --git a/docs/fiddles/features/keyboard-shortcuts/local/main.js b/docs/fiddles/features/keyboard-shortcuts/local/main.js new file mode 100644 index 00000000000..d4c5006ef7e --- /dev/null +++ b/docs/fiddles/features/keyboard-shortcuts/local/main.js @@ -0,0 +1,39 @@ +const { app, BrowserWindow, Menu, MenuItem } = require('electron') + +function createWindow () { + const win = new BrowserWindow({ + width: 800, + height: 600, + webPreferences: { + nodeIntegration: true + } + }) + + win.loadFile('index.html') +} + +const menu = new Menu() +menu.append(new MenuItem({ + label: 'Electron', + submenu: [{ + role: 'help', + accelerator: process.platform === 'darwin' ? 'Alt+Cmd+I' : 'Alt+Shift+I', + click: () => { console.log('Electron rocks!') } + }] +})) + +Menu.setApplicationMenu(menu) + +app.whenReady().then(createWindow) + +app.on('window-all-closed', () => { + if (process.platform !== 'darwin') { + app.quit() + } +}) + +app.on('activate', () => { + if (BrowserWindow.getAllWindows().length === 0) { + createWindow() + } +}) diff --git a/docs/fiddles/features/macos-dark-mode/index.html b/docs/fiddles/features/macos-dark-mode/index.html new file mode 100644 index 00000000000..dfd1e075fd7 --- /dev/null +++ b/docs/fiddles/features/macos-dark-mode/index.html @@ -0,0 +1,19 @@ + + + + +Current theme source: System
+ + + + + + + +