-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes.html
More file actions
107 lines (100 loc) · 2.7 KB
/
notes.html
File metadata and controls
107 lines (100 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Notes</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
background: #1a1a2e;
color: #e0e0e0;
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;
}
.titlebar {
-webkit-app-region: drag;
height: 38px;
background: #16213e;
display: flex;
align-items: center;
padding: 0 76px;
font-size: 13px;
font-weight: 600;
color: #8899aa;
flex-shrink: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
textarea {
flex: 1;
background: #1a1a2e;
color: #e0e0e0;
border: none;
padding: 16px;
font-size: 14px;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
line-height: 1.6;
resize: none;
outline: none;
}
.status {
height: 24px;
background: #16213e;
display: flex;
align-items: center;
padding: 0 12px;
font-size: 11px;
color: #556;
flex-shrink: 0;
}
</style>
</head>
<body>
<div class="titlebar" id="title">Notes</div>
<textarea id="editor" autofocus></textarea>
<div class="status" id="status">Saved</div>
<script>
const { ipcRenderer } = require('electron');
let todoId = null;
let saveTimer = null;
ipcRenderer.on('load-notes', (event, data) => {
todoId = data.todoId;
document.getElementById('title').textContent = 'Notes: ' + data.todoText;
document.getElementById('editor').value = data.notes || '';
document.getElementById('editor').focus();
});
document.getElementById('editor').addEventListener('input', () => {
document.getElementById('status').textContent = 'Editing...';
if (saveTimer) clearTimeout(saveTimer);
saveTimer = setTimeout(doSave, 500);
});
// Cmd+S to save immediately
document.addEventListener('keydown', (e) => {
if (e.key === 's' && e.metaKey) {
e.preventDefault();
doSave();
}
// Escape or Cmd+W to close
if (e.key === 'Escape' || (e.key === 'w' && e.metaKey)) {
e.preventDefault();
doSave();
window.close();
}
});
function doSave() {
if (saveTimer) clearTimeout(saveTimer);
const notes = document.getElementById('editor').value;
ipcRenderer.send('save-notes', { todoId, notes });
document.getElementById('status').textContent = 'Saved';
}
// Save on close
window.addEventListener('beforeunload', () => {
doSave();
});
</script>
</body>
</html>