Skip to content

Commit df6151f

Browse files
Merge pull request #95 from tolgamizrakci/development
Development
2 parents 9d33400 + e736031 commit df6151f

28 files changed

+1552
-1419
lines changed

main.js

Lines changed: 87 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
const {
2-
app, BrowserWindow, Menu, shell, dialog, ipcMain,
3-
} = require('electron');
2+
app,
3+
BrowserWindow,
4+
Menu,
5+
shell,
6+
dialog,
7+
ipcMain
8+
} = require("electron");
49

510
// Uncomment below for hot reloading during development
6-
require('electron-reload')(__dirname);
11+
require("electron-reload")(__dirname);
712

813
// const isDev = true;
9-
const isDev = process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test';
14+
const isDev =
15+
process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
1016

1117
// Keep a global reference of the window object, if you don't, the window will
1218
// be closed automatically when the JavaScript object is garbage collected.
@@ -16,81 +22,81 @@ let mainWindow;
1622
function openFile() {
1723
// Opens file dialog looking for markdown
1824
const files = dialog.showOpenDialog(mainWindow, {
19-
properties: ['openFile'],
25+
properties: ["openFile"],
2026
filters: [
2127
{
22-
name: 'Images',
23-
extensions: ['jpeg', 'jpg', 'png', 'gif', 'pdf'],
24-
},
25-
],
28+
name: "Images",
29+
extensions: ["jpeg", "jpg", "png", "gif", "pdf"]
30+
}
31+
]
2632
});
2733

2834
// if no files
2935
if (!files) return;
3036
const file = files[0];
3137

3238
// Send fileContent to renderer
33-
mainWindow.webContents.send('new-file', file);
39+
mainWindow.webContents.send("new-file", file);
3440
}
3541

3642
// export files
3743
function exportComponents() {
38-
console.log('hi from exportComponents');
44+
console.log("hi from exportComponents");
3945
}
4046

4147
// Choose directory
42-
ipcMain.on('choose_app_dir', (event) => {
48+
ipcMain.on("choose_app_dir", event => {
4349
const directory = dialog.showOpenDialog(mainWindow, {
44-
properties: ['openDirectory'],
45-
buttonLabel: 'Export',
50+
properties: ["openDirectory"],
51+
buttonLabel: "Export"
4652
});
4753

4854
if (!directory) return;
49-
event.sender.send('app_dir_selected', directory[0]);
55+
event.sender.send("app_dir_selected", directory[0]);
5056
});
5157

52-
ipcMain.on('view_app_dir', (event, appDir) => {
58+
ipcMain.on("view_app_dir", (event, appDir) => {
5359
shell.openItem(appDir);
5460
});
5561

5662
// Update file
57-
ipcMain.on('update-file', () => {
63+
ipcMain.on("update-file", () => {
5864
openFile();
5965
});
6066

6167
const createWindow = () => {
6268
// Create the browser window.
6369
// eslint-disable-next-line
64-
const { width, height } = require('electron').screen.getPrimaryDisplay().size;
70+
const { width, height } = require("electron").screen.getPrimaryDisplay().size;
6571
mainWindow = new BrowserWindow({
6672
width,
6773
height,
6874
webPreferences: {
69-
zoomFactor: 0.8,
70-
'node-Integration': false,
75+
zoomFactor: 0.9,
76+
"node-Integration": false
7177
},
72-
show: false,
78+
show: false
7379
});
7480

7581
// and load the index.html of the app.
7682
mainWindow.loadURL(`file://${__dirname}/build/index.html`);
7783
// load page once window is loaded
78-
mainWindow.once('ready-to-show', () => {
84+
mainWindow.once("ready-to-show", () => {
7985
mainWindow.show();
8086
});
8187

8288
const template = [
8389
{
84-
label: 'File',
90+
label: "File",
8591
submenu: [
8692
{
87-
label: 'Open File',
88-
accelerator: process.platform === 'darwin' ? 'Cmd+O' : 'Ctrl+Shift+O',
93+
label: "Open File",
94+
accelerator: process.platform === "darwin" ? "Cmd+O" : "Ctrl+Shift+O",
8995
click() {
9096
openFile();
91-
},
92-
},
93-
],
97+
}
98+
}
99+
]
94100
},
95101
// {
96102
// label: 'Edit',
@@ -107,89 +113,90 @@ const createWindow = () => {
107113
// ],
108114
// },
109115
{
110-
label: 'View',
116+
label: "View",
111117
submenu: [
112-
{ role: 'reload' },
113-
{ role: 'forcereload' },
114-
{ type: 'separator' },
115-
{ role: 'resetzoom' },
116-
{ role: 'zoomin' },
117-
{ role: 'zoomout' },
118-
{ type: 'separator' },
119-
{ role: 'togglefullscreen' },
120-
],
118+
{ role: "reload" },
119+
{ role: "forcereload" },
120+
{ type: "separator" },
121+
{ role: "resetzoom" },
122+
{ role: "zoomin" },
123+
{ role: "zoomout" },
124+
{ type: "separator" },
125+
{ role: "togglefullscreen" }
126+
]
121127
},
122128
{
123-
role: 'window',
124-
submenu: [{ role: 'minimize' }, { role: 'close' }],
129+
role: "window",
130+
submenu: [{ role: "minimize" }, { role: "close" }]
125131
},
126132
{
127-
role: 'help',
133+
role: "help",
128134
submenu: [
129135
{
130-
label: 'Learn More',
136+
label: "Learn More",
131137
click() {
132-
shell.openExternal('https://electronjs.org');
133-
},
134-
},
135-
],
138+
shell.openExternal("https://electronjs.org");
139+
}
140+
}
141+
]
136142
},
137143
{
138-
label: 'Developer',
144+
label: "Developer",
139145
submenu: [
140146
{
141-
label: 'Toggle Developer Tools',
142-
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
147+
label: "Toggle Developer Tools",
148+
accelerator:
149+
process.platform === "darwin" ? "Alt+Command+I" : "Ctrl+Shift+I",
143150
click() {
144151
mainWindow.webContents.toggleDevTools();
145-
},
146-
},
147-
],
148-
},
152+
}
153+
}
154+
]
155+
}
149156
];
150157

151-
if (process.platform === 'darwin') {
158+
if (process.platform === "darwin") {
152159
template.unshift({
153160
label: app.getName(),
154161
submenu: [
155-
{ role: 'about' },
156-
{ type: 'separator' },
157-
{ role: 'services', submenu: [] },
158-
{ type: 'separator' },
159-
{ role: 'hide' },
160-
{ role: 'hideothers' },
161-
{ role: 'unhide' },
162-
{ type: 'separator' },
163-
{ role: 'quit' },
164-
],
162+
{ role: "about" },
163+
{ type: "separator" },
164+
{ role: "services", submenu: [] },
165+
{ type: "separator" },
166+
{ role: "hide" },
167+
{ role: "hideothers" },
168+
{ role: "unhide" },
169+
{ type: "separator" },
170+
{ role: "quit" }
171+
]
165172
});
166173

167174
// Edit menu
168175
template[2].submenu.push(
169176
{
170-
type: 'separator',
177+
type: "separator"
171178
},
172179
{
173-
label: 'Speech',
174-
submenu: [{ role: 'startspeaking' }, { role: 'stopspeaking' }],
175-
},
180+
label: "Speech",
181+
submenu: [{ role: "startspeaking" }, { role: "stopspeaking" }]
182+
}
176183
);
177184

178185
// Window menu
179186
template[4].submenu = [
180-
{ role: 'close' },
181-
{ role: 'minimize' },
182-
{ role: 'zoom' },
183-
{ type: 'separator' },
184-
{ role: 'front' },
187+
{ role: "close" },
188+
{ role: "minimize" },
189+
{ role: "zoom" },
190+
{ type: "separator" },
191+
{ role: "front" }
185192
];
186193
}
187194

188195
const menu = Menu.buildFromTemplate(template);
189196
Menu.setApplicationMenu(menu);
190197

191198
// Emitted when the window is closed.
192-
mainWindow.on('closed', () => {
199+
mainWindow.on("closed", () => {
193200
// Dereference the window object, usually you would store windows
194201
// in an array if your app supports multi windows, this is the time
195202
// when you should delete the corresponding element.
@@ -200,13 +207,13 @@ const createWindow = () => {
200207
// This method will be called when Electron has finished
201208
// initialization and is ready to create browser windows.
202209
// Some APIs can only be used after this event occurs.
203-
app.on('ready', () => {
210+
app.on("ready", () => {
204211
if (isDev) {
205212
const {
206213
default: installExtension,
207214
REACT_DEVELOPER_TOOLS,
208-
REDUX_DEVTOOLS,
209-
} = require('electron-devtools-installer');
215+
REDUX_DEVTOOLS
216+
} = require("electron-devtools-installer");
210217

211218
installExtension([REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS])
212219
.then(() => {
@@ -219,15 +226,15 @@ app.on('ready', () => {
219226
});
220227

221228
// Quit when all windows are closed.
222-
app.on('window-all-closed', () => {
229+
app.on("window-all-closed", () => {
223230
// On OS X it is common for applications and their menu bar
224231
// to stay active until the user quits explicitly with Cmd + Q
225-
if (process.platform !== 'darwin') {
232+
if (process.platform !== "darwin") {
226233
app.quit();
227234
}
228235
});
229236

230-
app.on('activate', () => {
237+
app.on("activate", () => {
231238
// On OS X it's common to re-create a window in the app when the
232239
// dock icon is clicked and there are no other windows open.
233240
if (mainWindow === null) {

0 commit comments

Comments
 (0)