-
Notifications
You must be signed in to change notification settings - Fork 1
/
notes_iframe.html
466 lines (336 loc) · 14.2 KB
/
notes_iframe.html
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="user-scalable=1.0,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Notes</title>
<script src="notes.js"></script>
<!-- Editor's Dependecy Style -->
<link rel="stylesheet" href="node_modules/@toast-ui/editor/dist/toastui-editor.css" />
<link rel="stylesheet" type="text/css" href="color_styles.css" />
<style>
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
body {
zoom: calc(var(--windowScaling));
}
/* modify toast-ui general */
#editor{
margin-top: -2px /* I get scrollbars in window otherwise, because a build-in 1px border around editor. */
}
.toastui-editor-contents h1,
.toastui-editor-contents h2,
.toastui-editor-contents h3,
.toastui-editor-contents h4
{
background: var(--body-background);
color: var(--header-color);
}
.te-editor,
.toastui-editor-contents h5,
.toastui-editor-contents h6,
.toastui-editor-contents ul,
.toastui-editor-contents ol,
.toastui-editor-contents li,
.toastui-editor-contents h6,
.toastui-editor-contents p,
.toastui-editor-contents table,
.toastui-editor-contents dir,
.CodeMirror,
.te-md-container,
.tui-md-table.tui-md-marked-text,
.tui-md-list-item,
.toastui-editor-ww-container
{
background: var(--body-background);
color: var(--body-text);
}
.toastui-editor-toolbar-item-wrapper{
margin: 0px;
color: var(--header-color);
}
span{
color: var(--body-text);
}
a{
cursor: pointer; /* because Toast UI have an edit-cursor, and I have overriden the edit function */
}
img{
filter: invert( 0% );
}
/* table contextual menu, images better contrast */
.toastui-editor-context-menu .add-row-up::before,
.toastui-editor-context-menu .add-row-down::before,
.toastui-editor-context-menu .remove-row::before,
.toastui-editor-context-menu .add-column-left::before,
.toastui-editor-context-menu .add-column-right::before,
.toastui-editor-context-menu .remove-column::before,
.toastui-editor-context-menu .align-column-left::before,
.toastui-editor-context-menu .align-column-center::before,
.toastui-editor-context-menu .align-column-right::before,
.toastui-editor-context-menu .remove-table::before
{
filter: invert( 100% );
}
/* ToastUI Smaller icons and toolbar height */
:root {
--toolbarColor: #DDDDDD;
--buttonBorderColor : #AAAAAA;
}
.toastui-editor-toolbar-icons{
transform:scale(0.8);
transform-origin: top left;
background-color: var(--toolbarColor)!important;
}
.toastui-editor-defaultUI-toolbar, .toastui-editor-toolbar{
zoom: 1;
height:38px;
background-color: var(--toolbarColor);
}
.toastui-editor-defaultUI-toolbar button{
transform:scale(0.8);
border: none;
}
.toastui-editor-defaultUI-toolbar button:not(:disabled):hover {
border-color: var(--buttonBorderColor)!important;
}
/* Own smaller icons and toolbar height */
.my-img {
transform:scale(1.2);
}
.my-icon{
background-color: var(--toolbarColor)!important;
transform:scale(0.8);
border-radius: 3px;
}
/* modify toast-ui code */
.toastui-editor-contents pre,
.toastui-editor-contents code,
.tui-md-code,
.tui-md-code-block,
.tui-md-code.tui-md-marked-text,
.tui-md-code-block.CodeMirror-linebackground
{
background-color: var(--code-background);
color: var(--notes-code-text);
font-size: inherit;
}
/* markdown */
.tui-md-code,
.toastui-editor-contents .te-preview-highlight::after,
.toastui-editor-contents th.te-preview-highlight,
.toastui-editor-contents td.te-preview-highlight
{
background-color: rgba(255, 245, 131, 0.15);
}
.toastui-editor-md-heading1,
.toastui-editor-md-heading2,
.toastui-editor-md-heading3,
.toastui-editor-md-heading4,
.toastui-editor-md-heading5,
.toastui-editor-md-heading6
{
background: var(--body-background);
color: var(--header-color);
}
.toastui-editor-md-code-block
{
color: var(--notes-code-text);
background: var(--code-background);
}
.toastui-editor-ww-code-block:after:{
display:none;
}
.outer-content {
width: 100%;
height: 100%;
}
.toastui-editor-md-code-block-line-background{
background: var(--code-background);
}
.toastui-editor-md-code{
padding: 0;
color: var(--notes-code-text);
}
.toastui-editor-md-code{
color: var(--notes-code-text);
background: var(--code-background);
}
.ProseMirror{
color: var(--body-text);
font-size: inherit;
}
.task-list-item.checked::before {
background-image: none
}
/* hide button for language in code-block */
.toastui-editor-ww-code-block:after{
visibility: hidden !important;
}
.task-list-item::before {
background-image: url( 'images/unchecked.svg') !important;
-webkit-filter: var(--notes-checkbox-filter) !important;;
}
.task-list-item.checked::before {
background-image: url( 'images/checked.svg') !important;
}
/* popup dialogs */
#toastuiLinkTextInput, #toastuiLinkUrlInput,
#toastui-editor-file-name, #toastuiImageUrlInput, #toastuiAltTextInput{
color: var(--notes-input-text);
background-color: var(--notes-input-background) !important;
}
.toastui-editor-popup-add-image .toastui-editor-file-name.has-file{
color: var(--notes-input-text);
}
.toastui-editor-context-menu {
background-color: var(--body-background);
}
.toastui-editor-file-name{
color: var(--notes-input-text);
background-color: var(--notes-input-background) !important;
}
/* Hide tooltip border (hack, I suspect tooltip is solid background overwritten by unknown text css) */
.toastui-editor-tooltip {
color: var(--notes-tooltip-text);
background-color: var(--notes-tooltip-background);
}
.toastui-editor-tooltip span{
color: var(--notes-tooltip-text);
background-color: var(--notes-tooltip-background);
}
.toastui-editor-tooltip .arrow{
color: var(--notes-tooltip-background);
background-color: var(--notes-tooltip-background);
}
/* search field */
.find-in-nw-current, .find-in-nw-count, .find-in-nw-of{
background: none;
color: black;
font-size: none;
}
/* table header preview */
.toastui-editor-contents th > p:first-child,
.toastui-editor-contents table thead th
{
color: var(--table-header-color) !important;
background-color: var(--table-header-background-color) !important;
}
/* table cells preview*/
.toastui-editor-contents table td,
.toastui-editor-contents table th
{
border-color: var(--table-header-color);
font-weight: 400;
}
/* table cells markdown editor*/
.toastui-editor-md-table .toastui-editor-md-table-cell {
color: var(--body-text) !important;
}
/* tab for markdown / wysiwyg */
.tab-item.active {
border: 3px solid;
height: max-content;
}
</style>
</head>
<body class='light'>
<script>
<!-- NOTE Dark mode on/off, zoom are set in note.js (this place is only to get good background color when waiting for rest to be initiated) -->
if (global.localState.dark){
document.body.classList.remove('light');
document.body.classList.add('dark');
}
<!-- zoom -->
//window.document.body.style.zoom = global.state.zoom;
</script>
<!--
From https://nhn.github.io/tui.editor/latest/
-->
<div class="outer-content">
<div id="editor"></div>
</div>
<!--
NOTE: @toast-ui/editor/dist/toastui-editor.js fails scroll
Example01 on web works fine. Therefore, figured out that downloading toastui-editor-all.js
from "https://nhn.github.io/tui.editor/latest/tutorial-example01-editor-basic/../dist/cdn/toastui-editor-all.js"
was the solution.
DOWNLOAD latest toastui-editor-all.js like this :
--------------------------------------------------
cd ~/Documents/Projects/Pragma-git/Pragma-git/lib
wget --remote-encoding='UTF-8' 'https://nhn.github.io/tui.editor/latest/tutorial-example01-editor-basic/../dist/cdn/toastui-editor-all.js'
-->
<script src="lib/toastui-editor-all.js"></script>
<!-- Onload, call javascript file -->
<script>
const Editor = toastui.Editor;
window.addEventListener('DOMContentLoaded', (event) => {
// Start javascript
console.log('notes.html :DOM fully loaded and parsed');
injectIntoNotesJs(document);
// Events for switch between Markdown and MouseOver
document.getElementsByClassName('toastui-editor-mode-switch')[0].getElementsByClassName('tab-item')[0].addEventListener('mouseover', (event) => {
console.log('notes.html : Mouse over MD');
findInNw.clearTokens(); // Clear all <mark> inserted in html
findInNw.hideSearchBox(); // Hide search
}
);
document.getElementsByClassName('toastui-editor-mode-switch')[0].getElementsByClassName('tab-item')[1].addEventListener('mouseover', (event) => {
console.log('notes.html : Mouse over WYSIWYG');
findInNw.clearTokens(); // Clear all <mark> inserted in html
findInNw.hideSearchBox();// Hide search
}
);
// Override document-click
// - click link -> open link in browser window
// - history-button -> open/close history-menu
// - document-click -> close history-menu (if open)
document.onclick = function (e) {
e = e || window.event;
var element = e.target || e.srcElement;
// http link open in browser
if (element.tagName == 'A') {
if (element.href.startsWith('http') ){
// Open in browser
require('nw.gui').Shell.openExternal( element.href );
return false; // prevent default action and stop event propagation
}else{
// Open in system's default app
require('nw.gui').Shell.openItem( element.pathname );
return false; // prevent default action and stop event propagation
}
return false; // prevent default action and stop event propagation
}
// Show/hide history button (clicked button)
if ( e.composedPath()[1].id == 'history-icon'){
if ( parent.document.getElementById("historyMenu").style.display == 'block'){
parent.document.getElementById("historyMenu").style.display = 'none';
}else{
save(); // Has to be done before opening history menu (which blocks save)
parent.opener.commitSettingsDir(); // Commit saved file
getHistory(); // Update history with above commit
parent.document.getElementById("iframe").contentWindow.historyNumber = -1; // always open as non-historical
parent.document.getElementById("historyMenu").style.display = 'block'; // Open history menu
parent.historyButtonVisibility();
}
}
// Close history menu when clicking outside menu
if ( e.composedPath()[1].id!= 'history-icon' && parent.document.getElementById("historyMenu").style.display == 'block'){
parent.document.getElementById("historyMenu").style.display = 'none'
}
};
});
</script>
<!-- Add find -->
<script src="node_modules/findinnw/dist/find-in-nw.js"></script>
<script src="extend_find-in-nw.js"></script>
<script>
findInNw.initialize();
extendFindInNw(); // Make find-in-nw fit my purpose for graph and note
</script>
</body>
</html>