-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
3259 lines (3098 loc) · 122 KB
/
content.js
File metadata and controls
3259 lines (3098 loc) · 122 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
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
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Quick Notes v5 · floating panel (content script)
// Full-featured editor rendered into an isolated Shadow DOM on the host page.
// Injected lazily by the background worker; idempotent re-injection.
(function () {
if (window.__quickNotesInstalled) {
// Message listener from a prior injection will handle the new command.
return;
}
window.__quickNotesInstalled = true;
const HOST_ID = '__quicknotes_host__';
const STATE_KEYS = [
'notes', 'activeId', 'theme', 'history',
'settings', 'panel', 'shape', 'opacity',
'split', 'splitDir', 'pane2Id', 'paneRatio',
'fontSize', 'zen', 'images', 'customColors'
];
const MAX_HISTORY = 200;
let host = null;
let shadow = null;
let root = null;
let panel = null; // the shape frame
let textarea = null;
let previewEl = null;
let noteSelect = null;
let statusEl = null;
let counterEl = null;
let searchInput = null;
let searchResults = null;
let searchCount = null;
let historyListEl = null;
let historyCountEl = null;
let visible = false;
let saveTimer = null;
let previewOn = false;
// View management
let currentView = 'editor'; // 'editor' | 'search' | 'history'
let state = {
notes: [],
activeId: null,
theme: 'dark',
history: [],
settings: { autoPasteSites: [], floatingPanelSites: [], siteDefaults: {}, lastAutoPastedHash: '' },
panel: { top: 80, left: null, right: 24, width: 420, height: 540, collapsed: false },
shape: 'rectangle',
opacity: 1,
split: false, // on/off toggle
splitDir: 'h', // 'h' (horizontal) or 'v' (vertical) — remembered between sessions
pane2Id: null, // note id shown in pane 2
paneRatio: 0.5, // 0..1, size of pane 1 as fraction of body
fontSize: 13, // text zoom in px (textarea + preview)
zen: false, // distraction-free mode (toolbar + footer hidden)
images: {}, // { [imageId]: 'data:image/...;base64,...' } — keeps notes clean
customColors: { dark: {}, light: {} } // user-customized theme colors
};
// Guard against focus-steal echoes from our own writes.
let selfWriting = 0;
async function storageSet(obj) {
selfWriting++;
try { await chrome.storage.local.set(obj); }
finally {
setTimeout(() => { selfWriting = Math.max(0, selfWriting - 1); }, 0);
}
}
// ---------- Helpers ----------
const genId = () => Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
const activeNote = () => state.notes.find(n => n.id === state.activeId);
const deriveTitle = (c) => (c.split('\n')[0] || '').trim().slice(0, 40) || 'Untitled';
const hashStr = (s) => {
let h = 0;
for (let i = 0; i < s.length; i++) h = ((h << 5) - h + s.charCodeAt(i)) | 0;
return h.toString(36);
};
const matchPattern = (url, pattern) => {
if (!pattern || !url) return false;
try {
const re = pattern.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\\\*/g, '.*');
return new RegExp('^' + re + '$').test(url);
} catch { return false; }
};
const matchesAny = (url, pats) => !!pats && pats.some(p => matchPattern(url, p));
const escapeHtml = (s) => String(s).replace(/[&<>"']/g, c =>
({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
// ---------- Storage ----------
async function loadState() {
const d = await chrome.storage.local.get(STATE_KEYS);
state.notes = (d.notes && d.notes.length)
? d.notes
: [{ id: genId(), title: 'Untitled', content: '', updatedAt: Date.now(), pinned: false }];
state.notes.forEach(n => { if (n.pinned == null) n.pinned = false; });
state.theme = d.theme || 'dark';
state.history = d.history || [];
state.settings = Object.assign(
{ autoPasteSites: [], floatingPanelSites: [], siteDefaults: {}, lastAutoPastedHash: '' },
d.settings || {}
);
state.panel = Object.assign(state.panel, d.panel || {});
const VALID_SHAPES = ['rectangle', 'rounded', 'hexagon', 'circle'];
const raw = d.shape || 'rounded';
state.shape = VALID_SHAPES.includes(raw) ? raw : 'rounded';
const rawOp = typeof d.opacity === 'number' ? d.opacity : 1;
state.opacity = Math.max(0.3, Math.min(1, rawOp));
state.split = d.split === true;
state.splitDir = (d.splitDir === 'v') ? 'v' : 'h';
state.pane2Id = d.pane2Id || null;
state.paneRatio = (typeof d.paneRatio === 'number' && d.paneRatio > 0.15 && d.paneRatio < 0.85)
? d.paneRatio : 0.5;
const fs = Number(d.fontSize);
state.fontSize = (fs >= 10 && fs <= 28) ? fs : 13;
state.zen = d.zen === true;
state.images = (d.images && typeof d.images === 'object') ? d.images : {};
state.customColors = (d.customColors && typeof d.customColors === 'object') ? d.customColors : { dark: {}, light: {} };
// One-time migration: extract any inline `data:image/...;base64,...` URLs
// from note content and replace with qn-img:ID refs. Also strip leading
// zero-width / invisible characters that often sneak in from paste
// operations and cause the preview to show mysterious empty space at
// the top of notes.
let migrated = false;
const INLINE_IMG_RE = /!\[([^\]]*)\]\((data:image\/[a-zA-Z.+-]+;base64,[A-Za-z0-9+/=]+)\)/g;
// Matches zero-width chars and soft hyphens that trim() doesn't catch
const ZWS_RE = /[\u200B-\u200D\uFEFF\u00AD]/g;
for (const note of state.notes) {
if (!note.content) continue;
let content = note.content;
if (content.includes('data:image/')) {
content = content.replace(INLINE_IMG_RE, (_, alt, dataUrl) => {
const imgId = 'img_' + Date.now().toString(36) + '_' + Math.random().toString(36).slice(2, 6);
state.images[imgId] = dataUrl;
return ``;
});
}
// Strip zero-width chars and collapse leading blank lines so the
// note doesn't render with mystery whitespace at the top.
const cleaned = content.replace(ZWS_RE, '').replace(/^(?:[ \t]*\n)+/, '');
if (cleaned !== note.content) {
note.content = cleaned;
migrated = true;
}
}
if (migrated) {
await chrome.storage.local.set({ notes: state.notes, images: state.images });
}
// Per-site default note
const perSite = pickDefaultNoteId(location.href);
const storedActive = d.activeId && state.notes.some(n => n.id === d.activeId)
? d.activeId : state.notes[0].id;
state.activeId = perSite || storedActive;
}
function pickDefaultNoteId(url) {
if (!url) return null;
const map = state.settings.siteDefaults || {};
for (const [pat, noteId] of Object.entries(map)) {
if (matchPattern(url, pat) && state.notes.some(n => n.id === noteId)) return noteId;
}
return null;
}
// ---------- Build DOM ----------
function buildPanel() {
host = document.createElement('div');
host.id = HOST_ID;
host.style.cssText = 'all:initial; position:fixed; top:0; left:0; width:0; height:0; z-index:2147483647;';
shadow = host.attachShadow({ mode: 'closed' });
root = document.createElement('div');
root.innerHTML = `
<style>
:host, * { box-sizing: border-box; }
/* ===== Theme tokens ===== */
.qn-wrap {
--panel-alpha: 1;
}
.qn-wrap[data-theme="dark"] {
--bg-rgb: 31 31 30; /* #1F1F1E */
--bg-alt-rgb: 44 44 42; /* #2C2C2A */
--bg: rgb(var(--bg-rgb) / var(--panel-alpha));
--bg-alt: rgb(var(--bg-alt-rgb) / var(--panel-alpha));
--bg-elev: #26262410;
--fg: #e8e6e3;
--fg-dim: #c1beb8;
--muted: #8a857e;
--border: #3a3a37;
--border-strong: #4a4a46;
--btn: rgb(var(--bg-alt-rgb) / var(--panel-alpha));
--btn-hover: #373734;
--btn-active: #42423e;
--accent: #d4a85f;
--accent-soft: #d4a85f22;
--warn: #e57373;
--row-hover: #2a2a28;
--highlight: #fde047;
--highlight-fg: #111;
--shadow: 0 12px 32px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.3);
}
.qn-wrap[data-theme="light"] {
--bg-rgb: 250 250 248; /* #fafaf8 */
--bg-alt-rgb: 243 242 238; /* #f3f2ee */
--bg: rgb(var(--bg-rgb) / var(--panel-alpha));
--bg-alt: rgb(var(--bg-alt-rgb) / var(--panel-alpha));
--bg-elev: #ffffff;
--fg: #1a1a1a;
--fg-dim: #3a3a3a;
--muted: #6b7280;
--border: #e5e4de;
--border-strong: #cfcec8;
--btn: #ffffff;
--btn-hover: #ededea;
--btn-active: #dcdbd5;
--accent: #8a5a1a;
--accent-soft: #8a5a1a1a;
--warn: #dc2626;
--row-hover: #f3f2ee;
--highlight: #fde68a;
--highlight-fg: #111;
--shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
}
/* ===== Wrap ===== */
.qn-wrap {
position: fixed;
z-index: 2147483647;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
font-size: 13px;
line-height: 1.4;
color: var(--fg);
display: flex;
flex-direction: column;
pointer-events: auto;
}
/* The visible "paper" — gets shape clipping */
.qn-paper {
position: absolute;
inset: 0;
background: var(--bg);
border: 1px solid var(--border);
box-shadow: var(--shadow);
display: flex;
flex-direction: column;
overflow: hidden;
border-radius: 10px;
transition: clip-path 220ms ease, border-radius 220ms ease;
}
/* ===== Shapes (only shapes that keep all buttons reachable) ===== */
.qn-wrap[data-shape="rectangle"] .qn-paper { border-radius: 4px; }
.qn-wrap[data-shape="rounded"] .qn-paper { border-radius: 18px; }
.qn-wrap[data-shape="circle"] .qn-paper { border-radius: 50%; }
.qn-wrap[data-shape="hexagon"] .qn-paper {
clip-path: polygon(12% 0%, 88% 0%, 100% 50%, 88% 100%, 12% 100%, 0% 50%);
border-radius: 0;
}
/* Inset content for clipped shapes so the edge curves/cuts don't eat buttons */
.qn-wrap[data-shape="circle"] .qn-head,
.qn-wrap[data-shape="circle"] .qn-bar,
.qn-wrap[data-shape="circle"] .qn-foot {
padding-left: 14%;
padding-right: 14%;
flex-wrap: wrap;
justify-content: center;
}
.qn-wrap[data-shape="circle"] .qn-body,
.qn-wrap[data-shape="circle"] .qn-preview {
padding-left: 12%;
padding-right: 12%;
}
.qn-wrap[data-shape="hexagon"] .qn-head,
.qn-wrap[data-shape="hexagon"] .qn-bar,
.qn-wrap[data-shape="hexagon"] .qn-foot {
padding-left: 6%;
padding-right: 6%;
}
/* ===== Header (draggable) ===== */
.qn-head {
display: flex;
align-items: center;
gap: 4px;
padding: 7px 10px;
background: var(--bg-alt);
border-bottom: 1px solid var(--border);
cursor: grab;
user-select: none;
min-height: 38px;
overflow: hidden; /* never let buttons overflow horizontally */
}
.qn-head.dragging { cursor: grabbing; }
/* Buttons in the header should never grow but should shrink only as a
last resort — the select shrinks first because it has flex: 1. Buttons
stay at their natural icon size unless the panel becomes very narrow. */
.qn-head .qn-btn { flex: 0 0 auto; }
.qn-head .qn-bar-sep { flex: 0 0 auto; }
.qn-head .qn-brand { flex: 0 0 auto; }
/* Compact mode kicks in for narrow panels (set via JS). Hides brand text,
tightens padding and gap so all icons stay visible. */
/* Compact mode: triggered when the header would otherwise overflow
(measured dynamically in observePanelSize). Progressively tighter so
all 12 header icons remain visible at any reasonable panel width. */
.qn-wrap.qn-compact .qn-head { gap: 2px; padding: 5px 5px; }
.qn-wrap.qn-compact .qn-head .qn-brand {
/* Hide brand text; keep just the colored dot */
font-size: 0;
}
.qn-wrap.qn-compact .qn-head .qn-brand-dot { margin-right: 0; }
.qn-wrap.qn-compact .qn-head .qn-btn { padding: 2px 3px; }
.qn-wrap.qn-compact .qn-head .qn-btn svg { width: 12px; height: 12px; }
.qn-wrap.qn-compact .qn-head .qn-bar-sep { margin: 0; height: 12px; }
.qn-wrap.qn-compact .qn-head .qn-select {
padding: 3px 4px;
font-size: 10px;
/* Allow the select to shrink to its dropdown arrow when space is tight */
min-width: 24px;
}
/* Zoom label between A+/A− buttons */
.qn-zoom-label {
font-size: 10px;
color: var(--muted);
min-width: 32px;
text-align: center;
font-variant-numeric: tabular-nums;
cursor: pointer;
padding: 2px 4px;
border-radius: 4px;
user-select: none;
}
.qn-zoom-label:hover { background: var(--btn-hover); color: var(--fg-dim); }
/* Zen / distraction-free mode: hide header, toolbar, pane heads, footer */
.qn-wrap.qn-zen .qn-head,
.qn-wrap.qn-zen .qn-bar,
.qn-wrap.qn-zen .qn-pane-head,
.qn-wrap.qn-zen .qn-foot { display: none !important; }
/* Floating exit-zen button — only visible in zen mode */
.qn-zen-exit {
position: absolute;
top: 8px;
right: 10px;
z-index: 25;
background: var(--bg-alt);
border: 1px solid var(--border);
border-radius: 6px;
padding: 5px 7px;
cursor: pointer;
color: var(--fg-dim);
opacity: 0.3;
transition: opacity 180ms ease, background 120ms ease, color 120ms ease;
display: none;
}
.qn-zen-exit:hover { opacity: 1; background: var(--btn-hover); color: var(--fg); }
.qn-zen-exit svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; display: block; }
.qn-wrap.qn-zen .qn-zen-exit { display: block; }
/* Drag strip for zen mode — thin invisible grab area at the top of the
panel. Becomes visible (subtle accent line) on hover. */
.qn-zen-drag {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 10px;
z-index: 24;
cursor: grab;
display: none;
background: transparent;
transition: background 150ms ease;
}
.qn-zen-drag:hover {
background: linear-gradient(to bottom, var(--accent-soft), transparent);
}
.qn-zen-drag:active { cursor: grabbing; }
.qn-wrap.qn-zen .qn-zen-drag { display: block; }
/* When Alt is held, show a move cursor on the whole panel to hint at
Alt+drag — added/removed by JS in wireEvents. */
.qn-wrap.qn-alt-held { cursor: move; }
.qn-wrap.qn-alt-held .qn-text { cursor: move; }
.qn-brand {
display: flex;
align-items: center;
gap: 6px;
font-weight: 600;
font-size: 11px;
letter-spacing: 0.4px;
text-transform: uppercase;
color: var(--fg-dim);
white-space: nowrap;
}
.qn-brand-dot {
width: 7px; height: 7px; border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 8px var(--accent-soft);
}
.qn-select {
flex: 1;
min-width: 0;
background: var(--bg);
color: var(--fg);
border: 1px solid var(--border);
border-radius: 6px;
padding: 5px 8px;
font-size: 12px;
font-family: inherit;
cursor: pointer;
outline: none;
}
.qn-select:hover { border-color: var(--border-strong); }
.qn-select:focus { border-color: var(--accent); }
/* Inline rename input that temporarily replaces the note selector */
.qn-rename-input {
flex: 1;
min-width: 0;
background: var(--bg);
color: var(--fg);
border: 1px solid var(--accent);
border-radius: 6px;
padding: 5px 8px;
font-size: 12px;
font-family: inherit;
outline: none;
box-shadow: 0 0 0 2px var(--accent-soft);
}
/* ===== Icon buttons ===== */
.qn-btn {
background: transparent;
color: var(--fg-dim);
border: 1px solid transparent;
border-radius: 6px;
padding: 4px 6px;
cursor: pointer;
font-size: 12px;
font-family: inherit;
display: inline-flex;
align-items: center;
justify-content: center;
transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
white-space: nowrap;
}
.qn-btn:hover {
background: var(--btn-hover);
color: var(--fg);
}
.qn-btn:active { background: var(--btn-active); }
.qn-btn.qn-active {
background: var(--accent-soft);
color: var(--accent);
border-color: var(--accent);
}
.qn-btn svg {
width: 14px; height: 14px;
display: block;
pointer-events: none;
stroke: currentColor;
fill: none;
stroke-width: 1.8;
stroke-linecap: round;
stroke-linejoin: round;
}
.qn-btn.qn-text { gap: 4px; font-size: 11px; padding: 4px 8px; }
/* Text-label buttons in toolbar */
.qn-bar .qn-btn.qn-text {
background: var(--bg-elev);
border-color: var(--border);
}
.qn-bar .qn-btn.qn-text:hover {
background: var(--btn-hover);
border-color: var(--border-strong);
}
/* ===== Toolbar ===== */
.qn-bar {
display: flex;
gap: 3px;
padding: 4px 8px;
background: var(--bg-alt);
border-bottom: 1px solid var(--border);
flex-wrap: wrap;
align-items: center;
}
.qn-bar-group {
display: flex;
gap: 2px;
align-items: center;
}
.qn-bar-sep {
width: 1px;
height: 16px;
background: var(--border);
margin: 0 4px;
}
/* Responsive toolbar: two progressive compact levels applied by
observeBarSize() when content would otherwise wrap to > 2 rows. */
.qn-bar.qn-bar-compact { gap: 2px; padding: 3px 6px; }
.qn-bar.qn-bar-compact .qn-bar-group { gap: 1px; }
.qn-bar.qn-bar-compact .qn-btn { padding: 3px 4px; }
.qn-bar.qn-bar-compact .qn-btn svg { width: 12px; height: 12px; }
.qn-bar.qn-bar-compact .qn-bar-sep { margin: 0 2px; height: 14px; }
.qn-bar.qn-bar-compact .qn-range { width: 60px; }
.qn-bar.qn-bar-compact .qn-zoom-label { font-size: 9px; min-width: 22px; }
.qn-bar.qn-bar-extra-compact { gap: 1px; padding: 2px 4px; }
.qn-bar.qn-bar-extra-compact .qn-bar-group { gap: 0; }
.qn-bar.qn-bar-extra-compact .qn-btn { padding: 2px 3px; }
.qn-bar.qn-bar-extra-compact .qn-btn svg { width: 11px; height: 11px; }
.qn-bar.qn-bar-extra-compact .qn-bar-sep { margin: 0 1px; height: 12px; }
.qn-bar.qn-bar-extra-compact .qn-range { width: 44px; }
.qn-bar.qn-bar-extra-compact .qn-zoom-label { display: none; }
.qn-bar.qn-bar-extra-compact .qn-op-label { display: none; }
.qn-bar.qn-bar-extra-compact .qn-op-icon { display: none; }
/* Opacity slider in toolbar */
.qn-opacity-group {
display: flex;
align-items: center;
gap: 6px;
padding: 0 4px;
color: var(--fg-dim);
}
.qn-op-icon { display: flex; align-items: center; opacity: 0.7; }
.qn-op-icon svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.qn-range {
-webkit-appearance: none;
appearance: none;
width: 80px;
height: 4px;
border-radius: 2px;
background: var(--border);
cursor: pointer;
outline: none;
}
.qn-range::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 12px;
height: 12px;
border-radius: 50%;
background: var(--accent);
cursor: pointer;
border: 0;
box-shadow: 0 0 0 2px rgba(0,0,0,0.15);
}
.qn-range::-moz-range-thumb {
width: 12px;
height: 12px;
border-radius: 50%;
background: var(--accent);
cursor: pointer;
border: 0;
}
.qn-op-label {
font-size: 10px;
color: var(--muted);
min-width: 30px;
text-align: right;
font-variant-numeric: tabular-nums;
}
/* Tag color dot in selector */
.qn-tag-dot {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
flex-shrink: 0;
}
/* Color tag picker popup */
.qn-tag-menu {
position: absolute;
top: 44px;
left: 50%;
transform: translateX(-50%);
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
padding: 8px;
box-shadow: var(--shadow);
z-index: 30;
display: flex;
gap: 6px;
}
.qn-tag-swatch {
width: 24px;
height: 24px;
border-radius: 50%;
cursor: pointer;
border: 2px solid transparent;
transition: transform 120ms ease, border-color 120ms ease;
}
.qn-tag-swatch:hover { transform: scale(1.15); }
.qn-tag-swatch.qn-active { border-color: var(--fg); }
.qn-tag-swatch.qn-none {
background: var(--bg-alt);
color: var(--muted);
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
}
/* Active note tag-color accent on the brand dot */
.qn-brand-dot {
transition: background 200ms ease, box-shadow 200ms ease;
}
/* Color picker menu (for text color in notes) */
.qn-color-menu {
position: absolute;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
padding: 8px;
box-shadow: var(--shadow);
z-index: 30;
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 6px;
}
.qn-color-swatch {
width: 22px;
height: 22px;
border-radius: 50%;
cursor: pointer;
border: 2px solid transparent;
transition: transform 120ms ease, border-color 120ms ease;
padding: 0;
}
.qn-color-swatch:hover { transform: scale(1.15); border-color: var(--fg-dim); }
.qn-color-swatch.qn-none {
background: var(--bg-alt);
color: var(--muted);
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
}
/* Drag-and-drop visual feedback when files are dragged over the textarea */
.qn-text.qn-drag-over {
outline: 2px dashed var(--accent);
outline-offset: -4px;
background: var(--accent-soft);
}
/* ===== View layout ===== */
.qn-view {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
}
.qn-view[hidden] { display: none !important; }
/* ===== Body ===== */
.qn-body {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
background: var(--bg);
position: relative;
}
/* When split is on, body becomes a horizontal or vertical flex container
of two panes + a splitter. The preview element is pushed out / hidden. */
.qn-wrap[data-split="on"][data-split-dir="h"] .qn-body { flex-direction: row; }
.qn-wrap[data-split="on"][data-split-dir="v"] .qn-body { flex-direction: column; }
.qn-pane {
flex: 1 1 50%;
min-width: 0;
min-height: 0;
display: flex;
flex-direction: column;
overflow: hidden;
}
.qn-pane-head {
display: flex;
align-items: center;
gap: 4px;
padding: 4px 8px;
background: var(--bg-alt);
border-bottom: 1px solid var(--border);
min-height: 28px;
flex-shrink: 0;
}
/* Hide pane 1's head when split is off to preserve the classic look. */
.qn-wrap:not([data-split="on"]) #pane1Head { display: none; }
/* Hide pane 2 entirely when split is off */
.qn-wrap:not([data-split="on"]) #pane2,
.qn-wrap:not([data-split="on"]) #splitter { display: none !important; }
.qn-pane-label {
flex: 1;
font-size: 11px;
font-weight: 600;
letter-spacing: 0.3px;
color: var(--fg-dim);
cursor: text;
padding: 2px 4px;
border-radius: 4px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.qn-pane-label:hover { background: var(--btn-hover); }
.qn-pane-label.editing {
background: var(--bg);
border: 1px solid var(--accent);
outline: none;
padding: 1px 4px;
}
.qn-pane-select {
flex: 1;
min-width: 0;
font-size: 11px;
padding: 3px 6px;
}
.qn-pane-btn { padding: 3px 5px; }
.qn-pane-btn svg { width: 12px; height: 12px; }
/* Splitter */
.qn-splitter {
flex: 0 0 4px;
background: var(--border);
transition: background 120ms ease;
}
.qn-splitter:hover { background: var(--accent); }
.qn-wrap[data-split="on"][data-split-dir="h"] .qn-splitter { cursor: col-resize; width: 4px; height: auto; }
.qn-wrap[data-split="on"][data-split-dir="v"] .qn-splitter { cursor: row-resize; height: 4px; width: auto; }
.qn-wrap[data-split="on"][data-split-dir="h"] .qn-pane { height: 100%; }
.qn-wrap[data-split="on"][data-split-dir="v"] .qn-pane { width: 100%; }
/* Preview still inside body but absolute-style — hide when split is on */
.qn-wrap[data-split="on"] .qn-preview { display: none !important; }
/* When preview mode is active, hide the pane containers so the preview
gets the full body height (otherwise flex-basis: 50% on .qn-pane
leaves empty space above the preview). */
.qn-wrap.qn-preview-on .qn-pane,
.qn-wrap.qn-preview-on .qn-splitter { display: none !important; }
.qn-text {
flex: 1;
min-height: 0;
border: 0;
outline: 0;
resize: none;
padding: 14px 16px;
background: transparent;
color: var(--fg);
font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
font-size: 13px;
line-height: 1.6;
caret-color: var(--accent);
}
.qn-text::placeholder { color: var(--muted); }
.qn-text::-webkit-scrollbar,
.qn-preview::-webkit-scrollbar,
.qn-list::-webkit-scrollbar { width: 10px; height: 10px; }
.qn-text::-webkit-scrollbar-thumb,
.qn-preview::-webkit-scrollbar-thumb,
.qn-list::-webkit-scrollbar-thumb {
background: var(--border-strong);
border-radius: 4px;
cursor: pointer;
}
.qn-text::-webkit-scrollbar-thumb:hover,
.qn-preview::-webkit-scrollbar-thumb:hover,
.qn-list::-webkit-scrollbar-thumb:hover {
background: var(--accent);
cursor: pointer;
}
.qn-text::-webkit-scrollbar-track,
.qn-preview::-webkit-scrollbar-track,
.qn-list::-webkit-scrollbar-track { background: transparent; cursor: default; }
.qn-preview {
flex: 1;
overflow-y: auto;
padding: 14px 16px;
font-size: 13px;
line-height: 1.6;
color: var(--fg);
}
.qn-preview h1, .qn-preview h2, .qn-preview h3 {
margin: 0.9em 0 0.4em;
font-weight: 600;
letter-spacing: -0.01em;
}
.qn-preview h1 { font-size: 18px; }
.qn-preview h2 { font-size: 15px; }
.qn-preview h3 { font-size: 13px; color: var(--fg-dim); }
.qn-preview p { margin: 0.45em 0; }
.qn-preview ul, .qn-preview ol { margin: 0.4em 0; padding-left: 20px; }
.qn-preview li { margin: 2px 0; }
.qn-preview code {
background: var(--bg-alt);
padding: 1px 5px;
border-radius: 3px;
font-family: ui-monospace, monospace;
font-size: 12px;
border: 1px solid var(--border);
}
.qn-preview pre {
background: var(--bg-alt);
padding: 10px 12px;
border-radius: 6px;
overflow-x: auto;
border: 1px solid var(--border);
margin: 0.6em 0;
}
.qn-preview pre code { background: transparent; border: 0; padding: 0; font-size: 12px; line-height: 1.55; }
.qn-preview blockquote {
border-left: 3px solid var(--accent);
margin: 0.6em 0;
padding: 2px 12px;
color: var(--fg-dim);
font-style: italic;
}
.qn-preview a { color: var(--accent); text-decoration: none; border-bottom: 1px dotted var(--accent); }
.qn-preview a:hover { border-bottom-style: solid; }
.qn-preview hr {
border: 0;
border-top: 1px solid var(--border);
margin: 1em 0;
}
.qn-preview strong { font-weight: 600; color: var(--fg); }
.qn-preview em { font-style: italic; }
.qn-preview .qn-img {
max-width: 100%;
max-height: 400px;
height: auto;
width: auto;
object-fit: contain;
display: block;
margin: 0.6em 0;
border-radius: 6px;
border: 1px solid var(--border);
}
.qn-preview .qn-img-missing {
display: inline-block;
padding: 2px 8px;
background: var(--bg-alt);
border: 1px dashed var(--border);
border-radius: 4px;
color: var(--muted);
font-size: 11px;
font-family: ui-monospace, monospace;
}
/* Tables */
.qn-preview .qn-tbl-wrap {
overflow-x: auto;
margin: 0.7em 0;
border: 1px solid var(--border);
border-radius: 6px;
}
.qn-preview .qn-tbl {
width: 100%;
border-collapse: collapse;
font-size: 12px;
}
.qn-preview .qn-tbl th,
.qn-preview .qn-tbl td {
border-bottom: 1px solid var(--border);
border-right: 1px solid var(--border);
padding: 6px 10px;
text-align: left;
vertical-align: top;
}
.qn-preview .qn-tbl th:last-child,
.qn-preview .qn-tbl td:last-child { border-right: 0; }
.qn-preview .qn-tbl tbody tr:last-child td { border-bottom: 0; }
.qn-preview .qn-tbl thead th {
background: var(--bg-alt);
font-weight: 600;
color: var(--fg);
letter-spacing: 0.2px;
}
.qn-preview .qn-tbl tbody tr:nth-child(even) td {
background: var(--bg-elev);
}
.qn-preview .qn-tbl tbody tr:hover td {
background: var(--row-hover);
}
/* Table-size picker (Excel-style click-grid) */
.qn-tbl-picker {
position: absolute;
z-index: 30;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
padding: 8px;
box-shadow: var(--shadow);
user-select: none;
}
.qn-tbl-picker-label {
text-align: center;
font-size: 11px;
color: var(--fg-dim);
margin-bottom: 6px;
font-variant-numeric: tabular-nums;
}
.qn-tbl-picker-grid {
display: grid;
gap: 2px;
}
.qn-tbl-picker-cell {
width: 16px;
height: 16px;
border: 1px solid var(--border);
border-radius: 2px;
background: var(--bg-alt);
cursor: pointer;
transition: background 80ms ease, border-color 80ms ease;
}
.qn-tbl-picker-cell:hover { border-color: var(--border-strong); }
.qn-tbl-picker-cell.qn-active {
background: var(--accent-soft);
border-color: var(--accent);
}
.qn-preview .chk-line {
display: flex;
align-items: flex-start;
gap: 8px;
padding: 4px 6px;
margin: 1px -6px;
border-radius: 4px;
cursor: pointer;
user-select: none;
}
.qn-preview .chk-line:hover { background: var(--row-hover); }
.qn-preview .chk-line input {
margin-top: 4px;
cursor: pointer;
accent-color: var(--accent);
}
.qn-preview .chk-line.done .txt {
text-decoration: line-through;
color: var(--muted);
}
/* ===== Footer ===== */
.qn-foot {
display: flex;
justify-content: space-between;
align-items: center;
padding: 5px 12px;
background: var(--bg-alt);
border-top: 1px solid var(--border);
font-size: 10.5px;
color: var(--muted);
letter-spacing: 0.2px;
min-height: 26px;
}
.qn-foot .qn-status { color: var(--fg-dim); }
.qn-foot .qn-status.qn-ok { color: var(--accent); }
/* ===== Search + History views ===== */
.qn-search-head {
padding: 7px 10px;
background: var(--bg-alt);
border-bottom: 1px solid var(--border);
display: flex;
gap: 6px;
align-items: center;
}
.qn-input {
flex: 1;
background: var(--bg);
color: var(--fg);
border: 1px solid var(--border);
border-radius: 6px;
padding: 5px 10px;
font-size: 12px;
font-family: inherit;
outline: none;
}