nodebb-plugin-pdf-secure 1.2.6 → 1.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,1050 +3,18 @@
3
3
 
4
4
  <head>
5
5
  <meta charset="UTF-8">
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <meta name="viewport"
7
+ content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
7
8
  <title>PDF Viewer</title>
8
9
 
9
10
  <!-- PDF.js -->
10
- <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.min.js"></script>
11
+ <script defer src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.min.js"></script>
11
12
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf_viewer.min.css">
12
- <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf_viewer.min.js"></script>
13
+ <script defer src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf_viewer.min.js"></script>
13
14
 
14
- <style>
15
- /* Microsoft Edge / Dark Theme */
16
- :root {
17
- --bg-primary: #1f1f1f;
18
- --bg-secondary: #2d2d2d;
19
- --bg-tertiary: #3d3d3d;
20
- --text-primary: #ffffff;
21
- --text-secondary: #a0a0a0;
22
- --accent: #0078d4;
23
- --accent-hover: #1a86d9;
24
- --border-color: #404040;
25
- --toolbar-height: 48px;
26
- --sidebar-width: 200px;
27
- }
15
+ <!-- Viewer styles -->
16
+ <link rel="stylesheet" href="viewer.css">
28
17
 
29
- * {
30
- margin: 0;
31
- padding: 0;
32
- box-sizing: border-box;
33
- }
34
-
35
- html,
36
- body {
37
- height: 100%;
38
- background: var(--bg-primary);
39
- font-family: "Segoe UI", system-ui, sans-serif;
40
- font-size: 14px;
41
- overflow: hidden;
42
- color: var(--text-primary);
43
- /* Security: prevent text selection globally */
44
- -webkit-user-select: none;
45
- -moz-user-select: none;
46
- -ms-user-select: none;
47
- user-select: none;
48
- }
49
-
50
- /* Print Protection - hide everything when printing */
51
- @media print {
52
-
53
- html,
54
- body,
55
- #viewerContainer,
56
- #viewer,
57
- .pdfViewer,
58
- .page {
59
- display: none !important;
60
- visibility: hidden !important;
61
- }
62
-
63
- body::before {
64
- content: 'Bu içeriğin yazdırılması engellenmiştir.' !important;
65
- display: block !important;
66
- font-size: 24px;
67
- padding: 50px;
68
- text-align: center;
69
- color: #666;
70
- }
71
- }
72
-
73
- /* Loading Spinner Animation */
74
- @keyframes spin {
75
- from {
76
- transform: rotate(0deg);
77
- }
78
-
79
- to {
80
- transform: rotate(360deg);
81
- }
82
- }
83
-
84
- .spin {
85
- animation: spin 1s linear infinite;
86
- }
87
-
88
- .dropzone svg.spin {
89
- fill: var(--accent);
90
- }
91
-
92
- /* Toolbar - Edge Style */
93
- #toolbar {
94
- position: fixed;
95
- top: 0;
96
- left: 0;
97
- right: 0;
98
- height: var(--toolbar-height);
99
- background: var(--bg-secondary);
100
- border-bottom: 1px solid var(--border-color);
101
- display: flex;
102
- align-items: center;
103
- padding: 0 12px;
104
- gap: 4px;
105
- z-index: 100;
106
- }
107
-
108
- .toolbarGroup {
109
- display: flex;
110
- align-items: center;
111
- gap: 2px;
112
- }
113
-
114
- .toolbarBtn {
115
- width: 36px;
116
- height: 36px;
117
- border: none;
118
- background: transparent;
119
- color: var(--text-primary);
120
- border-radius: 4px;
121
- cursor: pointer;
122
- display: flex;
123
- align-items: center;
124
- justify-content: center;
125
- transition: background 0.1s;
126
- }
127
-
128
- .toolbarBtn:hover {
129
- background: var(--bg-tertiary);
130
- }
131
-
132
- .toolbarBtn.active {
133
- background: var(--accent);
134
- }
135
-
136
- .toolbarBtn svg {
137
- width: 18px;
138
- height: 18px;
139
- fill: currentColor;
140
- }
141
-
142
- .separator {
143
- width: 1px;
144
- height: 24px;
145
- background: var(--border-color);
146
- margin: 0 8px;
147
- }
148
-
149
- /* Enhanced Tooltips */
150
- .toolbarBtn {
151
- position: relative;
152
- }
153
-
154
- .toolbarBtn::after {
155
- content: attr(data-tooltip);
156
- position: absolute;
157
- top: 100%;
158
- left: 50%;
159
- transform: translateX(-50%);
160
- background: #1a1a1a;
161
- color: #fff;
162
- padding: 6px 10px;
163
- border-radius: 6px;
164
- font-size: 12px;
165
- white-space: nowrap;
166
- opacity: 0;
167
- visibility: hidden;
168
- transition: opacity 0.2s, visibility 0.2s;
169
- z-index: 1000;
170
- margin-top: 8px;
171
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
172
- pointer-events: none;
173
- }
174
-
175
- .toolbarBtn::before {
176
- content: '';
177
- position: absolute;
178
- top: 100%;
179
- left: 50%;
180
- transform: translateX(-50%);
181
- border: 6px solid transparent;
182
- border-bottom-color: #1a1a1a;
183
- opacity: 0;
184
- visibility: hidden;
185
- transition: opacity 0.2s, visibility 0.2s;
186
- z-index: 1001;
187
- margin-top: -4px;
188
- }
189
-
190
- .toolbarBtn:hover::after,
191
- .toolbarBtn:hover::before {
192
- opacity: 1;
193
- visibility: visible;
194
- }
195
-
196
- .toolbarBtn .shortcut {
197
- display: inline;
198
- opacity: 0.6;
199
- margin-left: 8px;
200
- padding: 2px 5px;
201
- background: rgba(255, 255, 255, 0.15);
202
- border-radius: 3px;
203
- font-size: 10px;
204
- }
205
-
206
- /* Context Menu */
207
- .contextMenu {
208
- position: fixed;
209
- background: #2d2d2d;
210
- border: 1px solid var(--border-color);
211
- border-radius: 8px;
212
- padding: 6px 0;
213
- min-width: 180px;
214
- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
215
- z-index: 2000;
216
- display: none;
217
- }
218
-
219
- .contextMenu.visible {
220
- display: block;
221
- }
222
-
223
- .contextMenuItem {
224
- padding: 10px 16px;
225
- cursor: pointer;
226
- display: flex;
227
- align-items: center;
228
- gap: 12px;
229
- color: var(--text-primary);
230
- font-size: 13px;
231
- transition: background 0.1s;
232
- }
233
-
234
- .contextMenuItem:hover {
235
- background: var(--bg-tertiary);
236
- }
237
-
238
- .contextMenuItem svg {
239
- width: 16px;
240
- height: 16px;
241
- fill: currentColor;
242
- opacity: 0.8;
243
- }
244
-
245
- .contextMenuItem .shortcutHint {
246
- margin-left: auto;
247
- opacity: 0.5;
248
- font-size: 11px;
249
- }
250
-
251
- .contextMenuDivider {
252
- height: 1px;
253
- background: var(--border-color);
254
- margin: 6px 0;
255
- }
256
-
257
- /* Tool Dropdown Panel - Microsoft Edge Style */
258
- .toolDropdown {
259
- position: absolute;
260
- top: calc(var(--toolbar-height) + 4px);
261
- background: #2d2d2d;
262
- border-radius: 8px;
263
- padding: 16px;
264
- min-width: 240px;
265
- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
266
- display: none;
267
- z-index: 200;
268
- }
269
-
270
- .toolDropdown.visible {
271
- display: block;
272
- }
273
-
274
- .dropdownSection {
275
- margin-bottom: 16px;
276
- }
277
-
278
- .dropdownSection:last-child {
279
- margin-bottom: 0;
280
- }
281
-
282
- .dropdownLabel {
283
- font-size: 13px;
284
- font-weight: 600;
285
- color: var(--text-primary);
286
- margin-bottom: 12px;
287
- display: flex;
288
- align-items: center;
289
- gap: 6px;
290
- }
291
-
292
- .dropdownLabel svg {
293
- width: 14px;
294
- height: 14px;
295
- fill: var(--text-secondary);
296
- }
297
-
298
- /* Color Grid */
299
- .colorGrid {
300
- display: grid;
301
- grid-template-columns: repeat(6, 1fr);
302
- gap: 8px;
303
- }
304
-
305
- .colorDot {
306
- width: 28px;
307
- height: 28px;
308
- border-radius: 50%;
309
- border: 2px solid transparent;
310
- cursor: pointer;
311
- transition: transform 0.1s, border-color 0.1s;
312
- }
313
-
314
- .colorDot:hover {
315
- transform: scale(1.1);
316
- }
317
-
318
- .colorDot.active {
319
- border-color: var(--text-primary);
320
- }
321
-
322
- /* Stroke Preview Wave */
323
- .strokePreview {
324
- height: 50px;
325
- background: #1f1f1f;
326
- border-radius: 8px;
327
- display: flex;
328
- align-items: center;
329
- justify-content: center;
330
- margin-bottom: 16px;
331
- overflow: hidden;
332
- }
333
-
334
- .strokePreview svg {
335
- width: 100%;
336
- height: 100%;
337
- }
338
-
339
- /* Thickness Slider */
340
- .thicknessSlider {
341
- width: 100%;
342
- display: flex;
343
- flex-direction: column;
344
- gap: 8px;
345
- }
346
-
347
- .thicknessSlider input[type="range"] {
348
- -webkit-appearance: none;
349
- appearance: none;
350
- width: 100%;
351
- height: 4px;
352
- background: #555;
353
- border-radius: 2px;
354
- outline: none;
355
- }
356
-
357
- .thicknessSlider input[type="range"]::-webkit-slider-thumb {
358
- -webkit-appearance: none;
359
- appearance: none;
360
- width: 16px;
361
- height: 16px;
362
- background: #fff;
363
- border-radius: 50%;
364
- cursor: pointer;
365
- box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
366
- }
367
-
368
- .thicknessSlider input[type="range"]::-moz-range-thumb {
369
- width: 16px;
370
- height: 16px;
371
- background: #fff;
372
- border-radius: 50%;
373
- cursor: pointer;
374
- border: none;
375
- }
376
-
377
- .thicknessLabels {
378
- display: flex;
379
- justify-content: space-between;
380
- font-size: 12px;
381
- color: var(--text-secondary);
382
- }
383
-
384
- /* Tool button with dropdown arrow */
385
- .toolbarBtnWithDropdown {
386
- position: relative;
387
- display: flex;
388
- align-items: center;
389
- }
390
-
391
- .toolbarBtnWithDropdown .toolbarBtn {
392
- border-radius: 4px 0 0 4px;
393
- }
394
-
395
- .dropdownArrow {
396
- width: 20px;
397
- height: 36px;
398
- border: none;
399
- background: transparent;
400
- color: var(--text-primary);
401
- border-radius: 0 4px 4px 0;
402
- cursor: pointer;
403
- display: flex;
404
- align-items: center;
405
- justify-content: center;
406
- }
407
-
408
- .dropdownArrow:hover {
409
- background: var(--bg-tertiary);
410
- }
411
-
412
- .toolbarBtnWithDropdown.active .toolbarBtn,
413
- .toolbarBtnWithDropdown.active .dropdownArrow {
414
- background: var(--accent);
415
- }
416
-
417
- .dropdownArrow svg {
418
- width: 12px;
419
- height: 12px;
420
- fill: currentColor;
421
- }
422
-
423
- /* Shape Grid */
424
- .shapeGrid {
425
- display: grid;
426
- grid-template-columns: repeat(4, 1fr);
427
- gap: 8px;
428
- }
429
-
430
- .shapeBtn {
431
- width: 48px;
432
- height: 48px;
433
- background: #1f1f1f;
434
- border: 2px solid transparent;
435
- border-radius: 8px;
436
- cursor: pointer;
437
- display: flex;
438
- align-items: center;
439
- justify-content: center;
440
- color: var(--text-primary);
441
- transition: border-color 0.1s, background 0.1s;
442
- }
443
-
444
- .shapeBtn:hover {
445
- background: #3d3d3d;
446
- }
447
-
448
- .shapeBtn.active {
449
- border-color: var(--accent);
450
- background: #3d3d3d;
451
- }
452
-
453
- .shapeBtn svg {
454
- width: 28px;
455
- height: 28px;
456
- }
457
-
458
- /* Page Info */
459
- .pageInfo {
460
- display: flex;
461
- align-items: center;
462
- gap: 8px;
463
- margin-left: auto;
464
- }
465
-
466
- #pageInput {
467
- width: 40px;
468
- height: 28px;
469
- background: var(--bg-tertiary);
470
- border: 1px solid var(--border-color);
471
- border-radius: 4px;
472
- color: var(--text-primary);
473
- text-align: center;
474
- font-size: 13px;
475
- }
476
-
477
- #pageCount {
478
- color: var(--text-secondary);
479
- font-size: 13px;
480
- }
481
-
482
- /* Sidebar - Thumbnails */
483
- #sidebar {
484
- position: fixed;
485
- top: var(--toolbar-height);
486
- left: 0;
487
- bottom: 0;
488
- width: var(--sidebar-width);
489
- background: var(--bg-secondary);
490
- border-right: 1px solid var(--border-color);
491
- overflow-y: auto;
492
- display: none;
493
- z-index: 50;
494
- }
495
-
496
- #sidebar.open {
497
- display: block;
498
- }
499
-
500
- .sidebarHeader {
501
- padding: 12px 16px;
502
- font-size: 13px;
503
- font-weight: 600;
504
- border-bottom: 1px solid var(--border-color);
505
- display: flex;
506
- justify-content: space-between;
507
- align-items: center;
508
- }
509
-
510
- .closeBtn {
511
- background: none;
512
- border: none;
513
- color: var(--text-primary);
514
- cursor: pointer;
515
- font-size: 18px;
516
- }
517
-
518
- #thumbnailContainer {
519
- padding: 12px;
520
- display: flex;
521
- flex-direction: column;
522
- gap: 12px;
523
- }
524
-
525
- .thumbnail {
526
- background: var(--bg-tertiary);
527
- border: 2px solid transparent;
528
- border-radius: 4px;
529
- cursor: pointer;
530
- padding: 4px;
531
- transition: border-color 0.15s;
532
- }
533
-
534
- .thumbnail:hover {
535
- border-color: var(--accent);
536
- }
537
-
538
- .thumbnail.active {
539
- border-color: var(--accent);
540
- }
541
-
542
- .thumbnail canvas {
543
- width: 100%;
544
- display: block;
545
- }
546
-
547
- .thumbnailNum {
548
- text-align: center;
549
- font-size: 11px;
550
- color: var(--text-secondary);
551
- margin-top: 4px;
552
- }
553
-
554
- /* Viewer Container */
555
- #viewerContainer {
556
- position: fixed;
557
- top: var(--toolbar-height);
558
- left: 0;
559
- right: 0;
560
- bottom: 0;
561
- overflow: auto;
562
- background: #525659;
563
- }
564
-
565
- #viewerContainer.withSidebar {
566
- left: var(--sidebar-width);
567
- }
568
-
569
- .pdfViewer .page {
570
- margin: 8px auto;
571
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
572
- position: relative;
573
- transition: filter 0.3s ease;
574
- }
575
-
576
- /* Sepia Reading Mode */
577
- .pdfViewer.sepia .page canvas {
578
- filter: sepia(40%) brightness(0.95) contrast(0.9);
579
- }
580
-
581
- .pdfViewer.sepia .page {
582
- background: #f4ecd8 !important;
583
- }
584
-
585
- #viewerContainer.sepia {
586
- background: #d4c9a8;
587
- }
588
-
589
- /* Annotation Layer */
590
- .annotationLayer {
591
- position: absolute;
592
- top: 0;
593
- left: 0;
594
- right: 0;
595
- bottom: 0;
596
- pointer-events: none;
597
- z-index: 10;
598
- }
599
-
600
- .annotationLayer.active {
601
- pointer-events: auto;
602
- cursor: crosshair;
603
- }
604
-
605
- .annotationLayer path {
606
- fill: none;
607
- stroke-linecap: round;
608
- stroke-linejoin: round;
609
- }
610
-
611
- /* Select tool cursor */
612
- .annotationLayer.select-mode {
613
- cursor: default;
614
- }
615
-
616
- .annotationLayer.select-mode path,
617
- .annotationLayer.select-mode rect,
618
- .annotationLayer.select-mode ellipse,
619
- .annotationLayer.select-mode line,
620
- .annotationLayer.select-mode text {
621
- cursor: grab;
622
- pointer-events: all;
623
- transition: transform 0.1s ease, opacity 0.1s ease;
624
- }
625
-
626
- /* Invisible hit area for easier selection */
627
- .annotationLayer.select-mode path,
628
- .annotationLayer.select-mode line {
629
- stroke-linecap: round;
630
- }
631
-
632
- .annotationLayer.select-mode path:hover,
633
- .annotationLayer.select-mode rect:hover,
634
- .annotationLayer.select-mode ellipse:hover,
635
- .annotationLayer.select-mode line:hover,
636
- .annotationLayer.select-mode text:hover {
637
- opacity: 0.8;
638
- cursor: grab;
639
- }
640
-
641
- /* Selected annotation element - use filter for SVG compatibility */
642
- .annotation-selected {
643
- filter: drop-shadow(0 0 4px #0078d4) drop-shadow(0 0 8px rgba(0, 120, 212, 0.6)) !important;
644
- opacity: 1 !important;
645
- }
646
-
647
- /* Touch feedback */
648
- .annotation-dragging {
649
- opacity: 0.6;
650
- cursor: grabbing !important;
651
- filter: drop-shadow(0 4px 12px rgba(0, 120, 212, 0.5));
652
- }
653
-
654
- /* Tablet/Touch optimizations for select mode */
655
- @media (pointer: coarse),
656
- (max-width: 1024px) {
657
-
658
- .annotationLayer.select-mode path,
659
- .annotationLayer.select-mode rect,
660
- .annotationLayer.select-mode ellipse,
661
- .annotationLayer.select-mode line,
662
- .annotationLayer.select-mode text {
663
- /* Ensure touch-friendly interaction */
664
- cursor: pointer;
665
- }
666
-
667
- /* Bigger toolbar buttons for touch */
668
- .toolbarBtn {
669
- width: 44px;
670
- height: 44px;
671
- min-width: 44px;
672
- }
673
- }
674
-
675
- /* Touch selection ring animation */
676
- @keyframes selectionPulse {
677
- 0% {
678
- outline-color: rgba(0, 120, 212, 1);
679
- }
680
-
681
- 50% {
682
- outline-color: rgba(0, 120, 212, 0.5);
683
- }
684
-
685
- 100% {
686
- outline-color: rgba(0, 120, 212, 1);
687
- }
688
- }
689
-
690
- .annotation-selected.just-selected {
691
- animation: selectionPulse 0.6s ease-out;
692
- }
693
-
694
- /* Move handle for touch devices */
695
- .annotation-move-handle {
696
- position: absolute;
697
- width: 36px;
698
- height: 36px;
699
- background: rgba(0, 120, 212, 0.9);
700
- border-radius: 50%;
701
- display: none;
702
- align-items: center;
703
- justify-content: center;
704
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
705
- cursor: grab;
706
- z-index: 100;
707
- touch-action: none;
708
- }
709
-
710
- .annotation-move-handle svg {
711
- width: 20px;
712
- height: 20px;
713
- fill: white;
714
- }
715
-
716
- @media (pointer: coarse) {
717
- .annotation-move-handle {
718
- display: flex;
719
- }
720
- }
721
-
722
- /* Ghost element while dragging */
723
- .annotation-ghost {
724
- opacity: 0.3;
725
- pointer-events: none;
726
- }
727
-
728
- /* Selection toolbar for touch - action buttons */
729
- .selection-toolbar {
730
- position: fixed;
731
- bottom: 24px;
732
- left: 50%;
733
- transform: translateX(-50%) translateY(100px);
734
- background: linear-gradient(135deg, #363636 0%, #2d2d2d 100%);
735
- border: 1px solid rgba(255, 255, 255, 0.1);
736
- border-radius: 16px;
737
- padding: 12px 16px;
738
- display: flex;
739
- align-items: center;
740
- gap: 12px;
741
- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
742
- z-index: 2000;
743
- opacity: 0;
744
- transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
745
- pointer-events: none;
746
- }
747
-
748
- .selection-toolbar.visible {
749
- transform: translateX(-50%) translateY(0);
750
- opacity: 1;
751
- pointer-events: auto;
752
- }
753
-
754
- .selection-toolbar::before {
755
- content: 'Seçili Öğe';
756
- position: absolute;
757
- top: -28px;
758
- left: 50%;
759
- transform: translateX(-50%);
760
- font-size: 11px;
761
- color: rgba(255, 255, 255, 0.6);
762
- white-space: nowrap;
763
- text-transform: uppercase;
764
- letter-spacing: 0.5px;
765
- }
766
-
767
- .selection-toolbar button {
768
- width: 52px;
769
- height: 52px;
770
- border: none;
771
- background: rgba(255, 255, 255, 0.08);
772
- color: white;
773
- border-radius: 12px;
774
- cursor: pointer;
775
- display: flex;
776
- flex-direction: column;
777
- align-items: center;
778
- justify-content: center;
779
- gap: 4px;
780
- transition: all 0.15s ease;
781
- position: relative;
782
- }
783
-
784
- .selection-toolbar button:hover {
785
- background: rgba(255, 255, 255, 0.15);
786
- transform: translateY(-2px);
787
- }
788
-
789
- .selection-toolbar button:active {
790
- transform: translateY(0);
791
- background: rgba(255, 255, 255, 0.2);
792
- }
793
-
794
- .selection-toolbar button.delete {
795
- background: rgba(196, 43, 28, 0.8);
796
- }
797
-
798
- .selection-toolbar button.delete:hover {
799
- background: #e03e2f;
800
- transform: translateY(-2px);
801
- }
802
-
803
- .selection-toolbar button svg {
804
- width: 22px;
805
- height: 22px;
806
- fill: currentColor;
807
- }
808
-
809
- .selection-toolbar button span {
810
- font-size: 9px;
811
- opacity: 0.8;
812
- text-transform: uppercase;
813
- letter-spacing: 0.3px;
814
- }
815
-
816
- /* Toast notification for copy/paste */
817
- .toast-notification {
818
- position: fixed;
819
- bottom: 80px;
820
- left: 50%;
821
- transform: translateX(-50%);
822
- background: #323232;
823
- color: white;
824
- padding: 12px 24px;
825
- border-radius: 8px;
826
- font-size: 14px;
827
- z-index: 3000;
828
- animation: toastIn 0.3s ease, toastOut 0.3s ease 1.7s forwards;
829
- box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
830
- }
831
-
832
- @keyframes toastIn {
833
- from {
834
- opacity: 0;
835
- transform: translateX(-50%) translateY(20px);
836
- }
837
-
838
- to {
839
- opacity: 1;
840
- transform: translateX(-50%) translateY(0);
841
- }
842
- }
843
-
844
- @keyframes toastOut {
845
- from {
846
- opacity: 1;
847
- transform: translateX(-50%) translateY(0);
848
- }
849
-
850
- to {
851
- opacity: 0;
852
- transform: translateX(-50%) translateY(-20px);
853
- }
854
- }
855
-
856
- /* Text Selection Highlight */
857
- .textHighlight {
858
- position: absolute;
859
- pointer-events: none;
860
- border-radius: 2px;
861
- }
862
-
863
- /* Selection Popup Button */
864
- .highlightPopup {
865
- position: absolute;
866
- background: var(--bg-secondary);
867
- border: 1px solid var(--border-color);
868
- border-radius: 8px;
869
- padding: 6px;
870
- display: flex;
871
- gap: 4px;
872
- box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
873
- z-index: 500;
874
- }
875
-
876
- .highlightPopup button {
877
- width: 28px;
878
- height: 28px;
879
- border: none;
880
- border-radius: 50%;
881
- cursor: pointer;
882
- transition: transform 0.1s;
883
- }
884
-
885
- .highlightPopup button:hover {
886
- transform: scale(1.15);
887
- }
888
-
889
- /* Upload Overlay */
890
- #uploadOverlay {
891
- position: fixed;
892
- top: var(--toolbar-height);
893
- left: 0;
894
- right: 0;
895
- bottom: 0;
896
- background: var(--bg-primary);
897
- display: flex;
898
- align-items: center;
899
- justify-content: center;
900
- z-index: 40;
901
- }
902
-
903
- .dropzone {
904
- width: 400px;
905
- padding: 60px 40px;
906
- background: var(--bg-secondary);
907
- border: 2px dashed var(--border-color);
908
- border-radius: 12px;
909
- text-align: center;
910
- cursor: pointer;
911
- transition: all 0.2s;
912
- }
913
-
914
- .dropzone:hover {
915
- border-color: var(--accent);
916
- background: var(--bg-tertiary);
917
- }
918
-
919
- .dropzone svg {
920
- width: 64px;
921
- height: 64px;
922
- fill: var(--text-secondary);
923
- margin-bottom: 16px;
924
- }
925
-
926
- .dropzone h2 {
927
- font-size: 18px;
928
- font-weight: 500;
929
- margin-bottom: 8px;
930
- }
931
-
932
- .dropzone p {
933
- color: var(--text-secondary);
934
- font-size: 13px;
935
- }
936
-
937
- /* Inline Text Editor */
938
- .textEditorOverlay {
939
- position: fixed;
940
- top: 0;
941
- left: 0;
942
- right: 0;
943
- bottom: 0;
944
- z-index: 1000;
945
- }
946
-
947
- .textEditorBox {
948
- position: absolute;
949
- background: white;
950
- border: 2px solid var(--accent);
951
- border-radius: 4px;
952
- box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
953
- min-width: 200px;
954
- max-width: 400px;
955
- }
956
-
957
- .textEditorInput {
958
- padding: 12px 16px;
959
- font-size: 14px;
960
- font-family: 'Segoe UI', system-ui, sans-serif;
961
- color: #333;
962
- outline: none;
963
- min-height: 40px;
964
- word-wrap: break-word;
965
- }
966
-
967
- .textEditorInput:empty:before {
968
- content: 'Buraya yazmaya başla...';
969
- color: #999;
970
- }
971
-
972
- .textEditorToolbar {
973
- display: flex;
974
- align-items: center;
975
- gap: 4px;
976
- padding: 8px 12px;
977
- border-top: 1px solid #e0e0e0;
978
- background: #f5f5f5;
979
- }
980
-
981
- .textEditorBtn {
982
- width: 28px;
983
- height: 28px;
984
- border: none;
985
- background: transparent;
986
- border-radius: 4px;
987
- cursor: pointer;
988
- display: flex;
989
- align-items: center;
990
- justify-content: center;
991
- color: #333;
992
- font-size: 12px;
993
- font-weight: 600;
994
- }
995
-
996
- .textEditorBtn:hover {
997
- background: #e0e0e0;
998
- }
999
-
1000
- .textEditorBtn.delete {
1001
- color: #d32f2f;
1002
- margin-left: auto;
1003
- }
1004
-
1005
- .textEditorColorDot {
1006
- width: 20px;
1007
- height: 20px;
1008
- border-radius: 50%;
1009
- border: 2px solid transparent;
1010
- cursor: pointer;
1011
- }
1012
-
1013
- .textEditorColorDot.active {
1014
- border-color: var(--accent);
1015
- }
1016
-
1017
- /* Draggable text annotations */
1018
- .annotationLayer svg text {
1019
- cursor: move;
1020
- user-select: none;
1021
- }
1022
-
1023
- .annotationLayer svg text.dragging {
1024
- opacity: 0.7;
1025
- }
1026
-
1027
- .hidden {
1028
- display: none !important;
1029
- }
1030
-
1031
- /* Scrollbar */
1032
- ::-webkit-scrollbar {
1033
- width: 8px;
1034
- height: 8px;
1035
- }
1036
-
1037
- ::-webkit-scrollbar-track {
1038
- background: var(--bg-secondary);
1039
- }
1040
-
1041
- ::-webkit-scrollbar-thumb {
1042
- background: var(--bg-tertiary);
1043
- border-radius: 4px;
1044
- }
1045
-
1046
- ::-webkit-scrollbar-thumb:hover {
1047
- background: #555;
1048
- }
1049
- </style>
1050
18
  </head>
1051
19
 
1052
20
  <body>
@@ -1183,6 +151,30 @@
1183
151
  <path d="M7 2l12 11.2-5.8.5 3.3 7.3-2.2 1-3.2-7.4L7 18.5V2z" />
1184
152
  </svg>
1185
153
  </button>
154
+
155
+ <div class="separator"></div>
156
+
157
+ <!-- Undo / Redo / Clear All -->
158
+ <button class="toolbarBtn" id="undoBtn" data-tooltip="Geri Al (Ctrl+Z)" disabled>
159
+ <svg viewBox="0 0 24 24">
160
+ <path
161
+ d="M12.5 8c-2.65 0-5.05 1.04-6.83 2.73L2.5 7.5v9h9l-3.19-3.19c1.29-1.25 3.04-2.02 5-2.02 3.24 0 5.97 2.13 6.89 5.07l2.36-.78C21.19 11.79 17.22 8 12.5 8z" />
162
+ </svg>
163
+ </button>
164
+ <button class="toolbarBtn" id="redoBtn" data-tooltip="Yinele (Ctrl+Y)" disabled>
165
+ <svg viewBox="0 0 24 24">
166
+ <path
167
+ d="M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13.5 16.5h9v-9l-4.1 3.1z" />
168
+ </svg>
169
+ </button>
170
+ <button class="toolbarBtn" id="clearAllBtn" data-tooltip="Tümünü Temizle">
171
+ <svg viewBox="0 0 24 24">
172
+ <path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z" />
173
+ </svg>
174
+ </button>
175
+
176
+ <div class="separator"></div>
177
+
1186
178
  <button class="toolbarBtn" id="textBtn" data-tooltip="Metin Ekle (T)">
1187
179
  <svg viewBox="0 0 24 24">
1188
180
  <path d="M5 4v3h5.5v12h3V7H19V4H5z" />
@@ -1295,6 +287,42 @@
1295
287
  d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z" />
1296
288
  </svg>
1297
289
  </button>
290
+
291
+ <div class="separator"></div>
292
+
293
+ <!-- Fullscreen Toggle -->
294
+ <button class="toolbarBtn" id="fullscreenBtn" data-tooltip="Tam Ekran (F)">
295
+ <svg viewBox="0 0 24 24" id="fullscreenIcon">
296
+ <path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" />
297
+ </svg>
298
+ </button>
299
+
300
+ <div class="separator overflowSep"></div>
301
+
302
+ <div class="toolbarBtnWithDropdown" id="overflowWrapper">
303
+ <button class="toolbarBtn" id="overflowBtn" title="Daha Fazla">
304
+ <svg viewBox="0 0 24 24">
305
+ <circle cx="12" cy="5" r="2"/>
306
+ <circle cx="12" cy="12" r="2"/>
307
+ <circle cx="12" cy="19" r="2"/>
308
+ </svg>
309
+ </button>
310
+ <div class="toolDropdown" id="overflowDropdown">
311
+ <button class="overflowItem" id="overflowRotateLeft">
312
+ <svg viewBox="0 0 24 24"><path d="M7.11 8.53L5.7 7.11C4.8 8.27 4.24 9.61 4.07 11h2.02c.14-.87.49-1.72 1.02-2.47zM6.09 13H4.07c.17 1.39.72 2.73 1.62 3.89l1.41-1.42c-.52-.75-.87-1.59-1.01-2.47zm1.01 5.32c1.16.9 2.51 1.44 3.9 1.61V17.9c-.87-.15-1.71-.49-2.46-1.03L7.1 18.32zM13 4.07V1L8.45 5.55 13 10V6.09c2.84.48 5 2.94 5 5.91s-2.16 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93s-3.05-7.44-7-7.93z"/></svg>
313
+ <span>Sola Döndür</span>
314
+ </button>
315
+ <button class="overflowItem" id="overflowRotateRight">
316
+ <svg viewBox="0 0 24 24"><path d="M15.55 5.55L11 1v3.07C7.06 4.56 4 7.92 4 12s3.05 7.44 7 7.93v-2.02c-2.84-.48-5-2.94-5-5.91s2.16-5.43 5-5.91V10l4.55-4.45zM19.93 11c-.17-1.39-.72-2.73-1.62-3.89l-1.42 1.42c.54.75.88 1.6 1.02 2.47h2.02zM13 17.9v2.02c1.39-.17 2.74-.71 3.9-1.61l-1.44-1.44c-.75.54-1.59.89-2.46 1.03zm3.89-2.42l1.42 1.41c.9-1.16 1.45-2.5 1.62-3.89h-2.02c-.14.87-.48 1.72-1.02 2.48z"/></svg>
317
+ <span>Sağa Döndür</span>
318
+ </button>
319
+ <div class="overflowDivider"></div>
320
+ <button class="overflowItem" id="overflowSepia">
321
+ <svg viewBox="0 0 24 24"><path d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"/></svg>
322
+ <span>Okuma Modu</span>
323
+ </button>
324
+ </div>
325
+ </div>
1298
326
  </div>
1299
327
 
1300
328
  <div class="pageInfo">
@@ -1303,6 +331,16 @@
1303
331
  </div>
1304
332
  </div>
1305
333
 
334
+ <!-- Bottom Toolbar (Mobile Only) -->
335
+ <div id="bottomToolbar">
336
+ <div class="bottomToolbarInner" id="bottomToolbarInner">
337
+ <!-- Annotation tool buttons will be moved here on mobile via JS -->
338
+ </div>
339
+ </div>
340
+
341
+ <!-- Dropdown Backdrop (Mobile) -->
342
+ <div id="dropdownBackdrop"></div>
343
+
1306
344
  <!-- Sidebar - Thumbnails -->
1307
345
  <div id="sidebar">
1308
346
  <div class="sidebarHeader">
@@ -1329,1962 +367,7 @@
1329
367
  <div id="viewer" class="pdfViewer"></div>
1330
368
  </div>
1331
369
 
1332
- <script>
1333
- // IIFE to prevent global access to pdfDoc, pdfViewer
1334
- (function () {
1335
- 'use strict';
1336
-
1337
- // ============================================
1338
- // CANVAS EXPORT PROTECTION
1339
- // Block toDataURL/toBlob for PDF render canvas only
1340
- // Allows: thumbnails, annotations, other canvases
1341
- // ============================================
1342
- const originalToDataURL = HTMLCanvasElement.prototype.toDataURL;
1343
- const originalToBlob = HTMLCanvasElement.prototype.toBlob;
1344
-
1345
- HTMLCanvasElement.prototype.toDataURL = function () {
1346
- // Block only main PDF page canvases (inside .page elements in #viewerContainer)
1347
- if (this.closest && this.closest('.page') && this.closest('#viewerContainer')) {
1348
- console.warn('[Security] Canvas toDataURL blocked for PDF page');
1349
- return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=='; // 1x1 transparent
1350
- }
1351
- return originalToDataURL.apply(this, arguments);
1352
- };
1353
-
1354
- HTMLCanvasElement.prototype.toBlob = function (callback) {
1355
- // Block only main PDF page canvases
1356
- if (this.closest && this.closest('.page') && this.closest('#viewerContainer')) {
1357
- console.warn('[Security] Canvas toBlob blocked for PDF page');
1358
- // Return empty blob
1359
- if (callback) callback(new Blob([], { type: 'image/png' }));
1360
- return;
1361
- }
1362
- return originalToBlob.apply(this, arguments);
1363
- };
1364
-
1365
- pdfjsLib.GlobalWorkerOptions.workerSrc = '';
1366
-
1367
- // State - now private, not accessible from console
1368
- let pdfDoc = null;
1369
- let pdfViewer = null;
1370
- let annotationMode = false;
1371
- let currentTool = null; // null, 'pen', 'highlight', 'eraser'
1372
- let currentColor = '#e81224';
1373
- let currentWidth = 2;
1374
- let isDrawing = false;
1375
- let currentPath = null;
1376
- let currentDrawingPage = null;
1377
-
1378
- // Annotation persistence - stores SVG innerHTML per page
1379
- const annotationsStore = new Map();
1380
-
1381
- // Store base dimensions (scale=1.0) for each page - ensures consistent coordinates
1382
- const pageBaseDimensions = new Map();
1383
-
1384
- // Current SVG reference for drawing
1385
- let currentSvg = null;
1386
-
1387
- // Elements
1388
- const container = document.getElementById('viewerContainer');
1389
- const uploadOverlay = document.getElementById('uploadOverlay');
1390
- const fileInput = document.getElementById('fileInput');
1391
- const sidebar = document.getElementById('sidebar');
1392
- const thumbnailContainer = document.getElementById('thumbnailContainer');
1393
-
1394
- // Initialize PDFViewer
1395
- const eventBus = new pdfjsViewer.EventBus();
1396
- const linkService = new pdfjsViewer.PDFLinkService({ eventBus });
1397
-
1398
- pdfViewer = new pdfjsViewer.PDFViewer({
1399
- container: container,
1400
- eventBus: eventBus,
1401
- linkService: linkService,
1402
- removePageBorders: true,
1403
- textLayerMode: 2
1404
- });
1405
- linkService.setViewer(pdfViewer);
1406
-
1407
- // Track first page render for queue system
1408
- let firstPageRendered = false;
1409
- eventBus.on('pagerendered', function (evt) {
1410
- if (!firstPageRendered && evt.pageNumber === 1) {
1411
- firstPageRendered = true;
1412
- // Notify parent that PDF is fully rendered (for queue system)
1413
- if (window.parent && window.parent !== window) {
1414
- const config = window.PDF_SECURE_CONFIG || {};
1415
- window.parent.postMessage({ type: 'pdf-secure-ready', filename: config.filename }, '*');
1416
- console.log('[PDF-Secure] First page rendered, notifying parent');
1417
- }
1418
- }
1419
- });
1420
-
1421
- // File Handling
1422
- document.getElementById('dropzone').onclick = () => fileInput.click();
1423
-
1424
- fileInput.onchange = async (e) => {
1425
- const file = e.target.files[0];
1426
- if (file) await loadPDF(file);
1427
- };
1428
-
1429
- uploadOverlay.ondragover = (e) => e.preventDefault();
1430
- uploadOverlay.ondrop = async (e) => {
1431
- e.preventDefault();
1432
- const file = e.dataTransfer.files[0];
1433
- if (file?.type === 'application/pdf') await loadPDF(file);
1434
- };
1435
-
1436
- async function loadPDF(file) {
1437
- uploadOverlay.classList.add('hidden');
1438
-
1439
- const data = await file.arrayBuffer();
1440
- pdfDoc = await pdfjsLib.getDocument({ data }).promise;
1441
-
1442
- pdfViewer.setDocument(pdfDoc);
1443
- linkService.setDocument(pdfDoc);
1444
-
1445
- ['zoomIn', 'zoomOut', 'pageInput', 'rotateLeft', 'rotateRight'].forEach(id => {
1446
- document.getElementById(id).disabled = false;
1447
- });
1448
-
1449
- // Thumbnails will be generated on-demand when sidebar opens
1450
- }
1451
-
1452
- // Load PDF from ArrayBuffer (for secure nonce-based loading)
1453
- async function loadPDFFromBuffer(arrayBuffer) {
1454
- uploadOverlay.classList.add('hidden');
1455
-
1456
- pdfDoc = await pdfjsLib.getDocument({ data: arrayBuffer }).promise;
1457
-
1458
- pdfViewer.setDocument(pdfDoc);
1459
- linkService.setDocument(pdfDoc);
1460
-
1461
- ['zoomIn', 'zoomOut', 'pageInput', 'rotateLeft', 'rotateRight'].forEach(id => {
1462
- document.getElementById(id).disabled = false;
1463
- });
1464
-
1465
- // Thumbnails will be generated on-demand when sidebar opens
1466
- }
1467
-
1468
- // Partial XOR decoder - must match backend encoding
1469
- function partialXorDecode(encodedData, keyBase64) {
1470
- const key = Uint8Array.from(atob(keyBase64), c => c.charCodeAt(0));
1471
- const data = new Uint8Array(encodedData);
1472
- const keyLen = key.length;
1473
-
1474
- // Decrypt first 10KB fully
1475
- const fullDecryptLen = Math.min(10240, data.length);
1476
- for (let i = 0; i < fullDecryptLen; i++) {
1477
- data[i] = data[i] ^ key[i % keyLen];
1478
- }
1479
-
1480
- // Decrypt every 50th byte after that
1481
- for (let i = fullDecryptLen; i < data.length; i += 50) {
1482
- data[i] = data[i] ^ key[i % keyLen];
1483
- }
1484
-
1485
- return data.buffer;
1486
- }
1487
-
1488
- // Auto-load PDF if config is present (injected by NodeBB plugin)
1489
- async function autoLoadSecurePDF() {
1490
- if (!window.PDF_SECURE_CONFIG || !window.PDF_SECURE_CONFIG.filename) {
1491
- console.log('[PDF-Secure] No config found, showing file picker');
1492
- return;
1493
- }
1494
-
1495
- const config = window.PDF_SECURE_CONFIG;
1496
- console.log('[PDF-Secure] Auto-loading:', config.filename);
1497
-
1498
- // Show loading state
1499
- const dropzone = document.getElementById('dropzone');
1500
- if (dropzone) {
1501
- dropzone.innerHTML = `
1502
- <svg viewBox="0 0 24 24" class="spin">
1503
- <path d="M12 4V2A10 10 0 0 0 2 12h2a8 8 0 0 1 8-8z" />
1504
- </svg>
1505
- <h2>PDF Yükleniyor...</h2>
1506
- <p>${config.filename}</p>
1507
- `;
1508
- }
1509
-
1510
- try {
1511
- // Nonce and key are embedded in HTML config (not fetched from API)
1512
- // This improves security - key is ONLY in HTML source, not in any network response
1513
- const nonce = config.nonce;
1514
- const xorKey = config.dk;
1515
-
1516
- // Fetch encrypted PDF binary
1517
- const pdfUrl = config.relativePath + '/api/v3/plugins/pdf-secure/pdf-data?nonce=' + encodeURIComponent(nonce);
1518
- const pdfRes = await fetch(pdfUrl, { credentials: 'same-origin' });
1519
-
1520
- if (!pdfRes.ok) {
1521
- throw new Error('PDF yüklenemedi (' + pdfRes.status + ')');
1522
- }
1523
-
1524
- const encodedBuffer = await pdfRes.arrayBuffer();
1525
-
1526
- console.log('[PDF-Secure] Encrypted data received:', encodedBuffer.byteLength, 'bytes');
1527
-
1528
- // Step 3: Decode XOR encrypted data
1529
- let pdfBuffer;
1530
- if (xorKey) {
1531
- console.log('[PDF-Secure] Decoding XOR encrypted data...');
1532
- pdfBuffer = partialXorDecode(encodedBuffer, xorKey);
1533
- } else {
1534
- // Fallback for backward compatibility
1535
- pdfBuffer = encodedBuffer;
1536
- }
1537
-
1538
- console.log('[PDF-Secure] PDF decoded successfully');
1539
-
1540
- // Step 4: Load into viewer
1541
- await loadPDFFromBuffer(pdfBuffer);
1542
-
1543
- // Step 5: Moved to pagerendered event for proper timing
1544
-
1545
- // Step 6: Security - clear references to prevent extraction
1546
- pdfBuffer = null;
1547
-
1548
- // Security: Delete config containing sensitive data (nonce, key)
1549
- delete window.PDF_SECURE_CONFIG;
1550
-
1551
- // Security: Remove PDF.js globals to prevent console manipulation
1552
- delete window.pdfjsLib;
1553
- delete window.pdfjsViewer;
1554
-
1555
- // Security: Block dangerous PDF.js methods
1556
- if (pdfDoc) {
1557
- pdfDoc.getData = function () {
1558
- console.warn('[Security] getData() is blocked');
1559
- return Promise.reject(new Error('Access denied'));
1560
- };
1561
- pdfDoc.saveDocument = function () {
1562
- console.warn('[Security] saveDocument() is blocked');
1563
- return Promise.reject(new Error('Access denied'));
1564
- };
1565
- }
1566
-
1567
- console.log('[PDF-Secure] PDF fully loaded and ready');
1568
-
1569
- } catch (err) {
1570
- console.error('[PDF-Secure] Auto-load error:', err);
1571
- if (dropzone) {
1572
- dropzone.innerHTML = `
1573
- <svg viewBox="0 0 24 24" style="fill: #e81224;">
1574
- <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"/>
1575
- </svg>
1576
- <h2>Hata</h2>
1577
- <p>${err.message}</p>
1578
- `;
1579
- }
1580
- }
1581
- }
1582
-
1583
- // Run auto-load on page ready
1584
- autoLoadSecurePDF();
1585
-
1586
- // Generate Thumbnails (deferred - only when sidebar opens)
1587
- let thumbnailsGenerated = false;
1588
- async function generateThumbnails() {
1589
- if (thumbnailsGenerated) return;
1590
- thumbnailsGenerated = true;
1591
- thumbnailContainer.innerHTML = '';
1592
-
1593
- for (let i = 1; i <= pdfDoc.numPages; i++) {
1594
- const page = await pdfDoc.getPage(i);
1595
- const viewport = page.getViewport({ scale: 0.2 });
1596
-
1597
- const canvas = document.createElement('canvas');
1598
- canvas.width = viewport.width;
1599
- canvas.height = viewport.height;
1600
-
1601
- await page.render({
1602
- canvasContext: canvas.getContext('2d'),
1603
- viewport: viewport
1604
- }).promise;
1605
-
1606
- const thumb = document.createElement('div');
1607
- thumb.className = 'thumbnail' + (i === 1 ? ' active' : '');
1608
- thumb.dataset.page = i;
1609
- thumb.innerHTML = `<div class="thumbnailNum">${i}</div>`;
1610
- thumb.insertBefore(canvas, thumb.firstChild);
1611
-
1612
- thumb.onclick = () => {
1613
- pdfViewer.currentPageNumber = i;
1614
- document.querySelectorAll('.thumbnail').forEach(t => t.classList.remove('active'));
1615
- thumb.classList.add('active');
1616
- };
1617
-
1618
- thumbnailContainer.appendChild(thumb);
1619
- }
1620
- }
1621
-
1622
- // Events
1623
- eventBus.on('pagesinit', () => {
1624
- pdfViewer.currentScaleValue = 'page-width';
1625
- document.getElementById('pageCount').textContent = `/ ${pdfViewer.pagesCount}`;
1626
- });
1627
-
1628
- eventBus.on('pagechanging', (evt) => {
1629
- document.getElementById('pageInput').value = evt.pageNumber;
1630
- // Update active thumbnail
1631
- document.querySelectorAll('.thumbnail').forEach(t => {
1632
- t.classList.toggle('active', parseInt(t.dataset.page) === evt.pageNumber);
1633
- });
1634
- });
1635
-
1636
- eventBus.on('pagerendered', (evt) => {
1637
- if (annotationMode) injectAnnotationLayer(evt.pageNumber);
1638
- });
1639
-
1640
- // Page Navigation
1641
- document.getElementById('pageInput').onchange = (e) => {
1642
- const num = parseInt(e.target.value);
1643
- if (num >= 1 && num <= pdfViewer.pagesCount) {
1644
- pdfViewer.currentPageNumber = num;
1645
- }
1646
- };
1647
-
1648
- // Zoom
1649
- document.getElementById('zoomIn').onclick = () => pdfViewer.currentScale += 0.25;
1650
- document.getElementById('zoomOut').onclick = () => pdfViewer.currentScale -= 0.25;
1651
-
1652
- // Sidebar toggle (deferred thumbnail generation)
1653
- const sidebarEl = document.getElementById('sidebar');
1654
- const sidebarBtnEl = document.getElementById('sidebarBtn');
1655
- const closeSidebarBtn = document.getElementById('closeSidebar');
1656
-
1657
- sidebarBtnEl.onclick = () => {
1658
- const isOpening = !sidebarEl.classList.contains('open');
1659
- sidebarEl.classList.toggle('open');
1660
- sidebarBtnEl.classList.toggle('active');
1661
-
1662
- // Generate thumbnails on first open (deferred loading)
1663
- if (isOpening && pdfDoc) {
1664
- generateThumbnails();
1665
- }
1666
- };
1667
-
1668
- closeSidebarBtn.onclick = () => {
1669
- sidebarEl.classList.remove('open');
1670
- sidebarBtnEl.classList.remove('active');
1671
- };
1672
-
1673
- // Sepia Reading Mode
1674
- let sepiaMode = false;
1675
- document.getElementById('sepiaBtn').onclick = () => {
1676
- sepiaMode = !sepiaMode;
1677
- document.getElementById('viewer').classList.toggle('sepia', sepiaMode);
1678
- container.classList.toggle('sepia', sepiaMode);
1679
- document.getElementById('sepiaBtn').classList.toggle('active', sepiaMode);
1680
- };
1681
-
1682
- // Page Rotation
1683
- const pageRotations = new Map(); // Store rotation per page
1684
-
1685
- function rotatePage(delta) {
1686
- const pageNum = pdfViewer.currentPageNumber;
1687
- const currentRotation = pageRotations.get(pageNum) || 0;
1688
- const newRotation = (currentRotation + delta + 360) % 360;
1689
- pageRotations.set(pageNum, newRotation);
1690
-
1691
- // Apply rotation only to the canvas (not the whole page div)
1692
- const pageView = pdfViewer.getPageView(pageNum - 1);
1693
- if (pageView?.div) {
1694
- const canvas = pageView.div.querySelector('canvas');
1695
- const textLayer = pageView.div.querySelector('.textLayer');
1696
- const annotationLayer = pageView.div.querySelector('.annotationLayer');
1697
-
1698
- if (canvas) {
1699
- canvas.style.transform = `rotate(${newRotation}deg)`;
1700
- canvas.style.transformOrigin = 'center center';
1701
- }
1702
- if (textLayer) {
1703
- textLayer.style.transform = `rotate(${newRotation}deg)`;
1704
- textLayer.style.transformOrigin = 'center center';
1705
- }
1706
- if (annotationLayer) {
1707
- annotationLayer.style.transform = `rotate(${newRotation}deg)`;
1708
- annotationLayer.style.transformOrigin = 'center center';
1709
- }
1710
-
1711
- // Also rotate text highlight container
1712
- const textHighlightContainer = pageView.div.querySelector('.textHighlightContainer');
1713
- if (textHighlightContainer) {
1714
- textHighlightContainer.style.transform = `rotate(${newRotation}deg)`;
1715
- textHighlightContainer.style.transformOrigin = 'center center';
1716
- }
1717
- }
1718
- }
1719
-
1720
- document.getElementById('rotateLeft').onclick = () => rotatePage(-90);
1721
- document.getElementById('rotateRight').onclick = () => rotatePage(90);
1722
-
1723
- // Sidebar Toggle
1724
- document.getElementById('sidebarBtn').onclick = () => {
1725
- sidebar.classList.toggle('open');
1726
- container.classList.toggle('withSidebar', sidebar.classList.contains('open'));
1727
- document.getElementById('sidebarBtn').classList.toggle('active', sidebar.classList.contains('open'));
1728
- };
1729
-
1730
- document.getElementById('closeSidebar').onclick = () => {
1731
- sidebar.classList.remove('open');
1732
- container.classList.remove('withSidebar');
1733
- document.getElementById('sidebarBtn').classList.remove('active');
1734
- };
1735
-
1736
-
1737
- // Tool settings - separate for each tool
1738
- let highlightColor = '#fff100';
1739
- let highlightWidth = 4;
1740
- let drawColor = '#e81224';
1741
- let drawWidth = 2;
1742
- let shapeColor = '#e81224';
1743
- let shapeWidth = 2;
1744
- let currentShape = 'rectangle'; // rectangle, circle, line, arrow
1745
-
1746
- // Dropdown Panel Logic
1747
- const highlightDropdown = document.getElementById('highlightDropdown');
1748
- const drawDropdown = document.getElementById('drawDropdown');
1749
- const shapesDropdown = document.getElementById('shapesDropdown');
1750
- const highlightWrapper = document.getElementById('highlightWrapper');
1751
- const drawWrapper = document.getElementById('drawWrapper');
1752
- const shapesWrapper = document.getElementById('shapesWrapper');
1753
-
1754
- function closeAllDropdowns() {
1755
- highlightDropdown.classList.remove('visible');
1756
- drawDropdown.classList.remove('visible');
1757
- shapesDropdown.classList.remove('visible');
1758
- }
1759
-
1760
- function toggleDropdown(dropdown, e) {
1761
- e.stopPropagation();
1762
- const isVisible = dropdown.classList.contains('visible');
1763
- closeAllDropdowns();
1764
- if (!isVisible) {
1765
- dropdown.classList.add('visible');
1766
- }
1767
- }
1768
-
1769
- // Arrow buttons toggle dropdowns
1770
- document.getElementById('highlightArrow').onclick = (e) => toggleDropdown(highlightDropdown, e);
1771
- document.getElementById('drawArrow').onclick = (e) => toggleDropdown(drawDropdown, e);
1772
- document.getElementById('shapesArrow').onclick = (e) => toggleDropdown(shapesDropdown, e);
1773
-
1774
- // Close dropdowns when clicking outside
1775
- document.addEventListener('click', (e) => {
1776
- if (!e.target.closest('.toolDropdown') && !e.target.closest('.dropdownArrow')) {
1777
- closeAllDropdowns();
1778
- }
1779
- });
1780
-
1781
- // Prevent dropdown from closing when clicking inside
1782
- highlightDropdown.onclick = (e) => e.stopPropagation();
1783
- drawDropdown.onclick = (e) => e.stopPropagation();
1784
- shapesDropdown.onclick = (e) => e.stopPropagation();
1785
-
1786
- // Drawing Tools - Toggle Behavior
1787
- async function setTool(tool) {
1788
- // If same tool clicked again, deactivate
1789
- if (currentTool === tool) {
1790
- currentTool = null;
1791
- annotationMode = false;
1792
- document.querySelectorAll('.annotationLayer').forEach(el => el.classList.remove('active'));
1793
- } else {
1794
- currentTool = tool;
1795
- annotationMode = true;
1796
-
1797
- // Set color and width based on tool
1798
- if (tool === 'highlight') {
1799
- currentColor = highlightColor;
1800
- currentWidth = highlightWidth;
1801
- } else if (tool === 'pen') {
1802
- currentColor = drawColor;
1803
- currentWidth = drawWidth;
1804
- } else if (tool === 'shape') {
1805
- currentColor = shapeColor;
1806
- currentWidth = shapeWidth;
1807
- }
1808
-
1809
- // BUGFIX: Save current annotation state BEFORE re-injecting layers
1810
- // This prevents deleted content from being restored when switching tools
1811
- for (let i = 0; i < pdfViewer.pagesCount; i++) {
1812
- const pageView = pdfViewer.getPageView(i);
1813
- const svg = pageView?.div?.querySelector('.annotationLayer');
1814
- if (svg) {
1815
- const pageNum = i + 1;
1816
- if (svg.innerHTML.trim()) {
1817
- annotationsStore.set(pageNum, svg.innerHTML);
1818
- } else {
1819
- // Clear from store if empty (all content deleted)
1820
- annotationsStore.delete(pageNum);
1821
- }
1822
- }
1823
- }
1824
-
1825
- // Inject annotation layers (await all)
1826
- const promises = [];
1827
- for (let i = 0; i < pdfViewer.pagesCount; i++) {
1828
- const pageView = pdfViewer.getPageView(i);
1829
- if (pageView?.div) {
1830
- promises.push(injectAnnotationLayer(i + 1));
1831
- }
1832
- }
1833
- await Promise.all(promises);
1834
- }
1835
-
1836
- // Update button states
1837
- highlightWrapper.classList.toggle('active', currentTool === 'highlight');
1838
- drawWrapper.classList.toggle('active', currentTool === 'pen');
1839
- shapesWrapper.classList.toggle('active', currentTool === 'shape');
1840
- document.getElementById('eraserBtn').classList.toggle('active', currentTool === 'eraser');
1841
- document.getElementById('textBtn').classList.toggle('active', currentTool === 'text');
1842
- document.getElementById('selectBtn').classList.toggle('active', currentTool === 'select');
1843
-
1844
- // Toggle select-mode class on annotation layers
1845
- document.querySelectorAll('.annotationLayer').forEach(layer => {
1846
- layer.classList.toggle('select-mode', currentTool === 'select');
1847
- });
1848
-
1849
- // Clear selection when switching tools
1850
- if (currentTool !== 'select') {
1851
- clearAnnotationSelection();
1852
- }
1853
- }
1854
-
1855
- document.getElementById('drawBtn').onclick = () => setTool('pen');
1856
- document.getElementById('highlightBtn').onclick = () => setTool('highlight');
1857
- document.getElementById('shapesBtn').onclick = () => setTool('shape');
1858
- document.getElementById('eraserBtn').onclick = () => setTool('eraser');
1859
- document.getElementById('textBtn').onclick = () => setTool('text');
1860
- document.getElementById('selectBtn').onclick = () => setTool('select');
1861
-
1862
- // Highlighter Colors
1863
- document.querySelectorAll('#highlightColors .colorDot').forEach(dot => {
1864
- dot.onclick = (e) => {
1865
- e.stopPropagation();
1866
- document.querySelectorAll('#highlightColors .colorDot').forEach(d => d.classList.remove('active'));
1867
- dot.classList.add('active');
1868
- highlightColor = dot.dataset.color;
1869
- if (currentTool === 'highlight') currentColor = highlightColor;
1870
- // Update preview
1871
- document.getElementById('highlightWave').setAttribute('stroke', highlightColor);
1872
- };
1873
- });
1874
-
1875
- // Pen Colors
1876
- document.querySelectorAll('#drawColors .colorDot').forEach(dot => {
1877
- dot.onclick = (e) => {
1878
- e.stopPropagation();
1879
- document.querySelectorAll('#drawColors .colorDot').forEach(d => d.classList.remove('active'));
1880
- dot.classList.add('active');
1881
- drawColor = dot.dataset.color;
1882
- if (currentTool === 'pen') currentColor = drawColor;
1883
- // Update preview
1884
- document.getElementById('drawWave').setAttribute('stroke', drawColor);
1885
- };
1886
- });
1887
-
1888
- // Highlighter Thickness Slider
1889
- document.getElementById('highlightThickness').oninput = (e) => {
1890
- highlightWidth = parseInt(e.target.value);
1891
- if (currentTool === 'highlight') currentWidth = highlightWidth;
1892
- // Update preview - highlighter uses width * 2 for display
1893
- document.getElementById('highlightWave').setAttribute('stroke-width', highlightWidth * 2);
1894
- };
1895
-
1896
- // Pen Thickness Slider
1897
- document.getElementById('drawThickness').oninput = (e) => {
1898
- drawWidth = parseInt(e.target.value);
1899
- if (currentTool === 'pen') currentWidth = drawWidth;
1900
- // Update preview
1901
- document.getElementById('drawWave').setAttribute('stroke-width', drawWidth);
1902
- };
1903
-
1904
- // Shape Selection
1905
- document.querySelectorAll('.shapeBtn').forEach(btn => {
1906
- btn.onclick = (e) => {
1907
- e.stopPropagation();
1908
- document.querySelectorAll('.shapeBtn').forEach(b => b.classList.remove('active'));
1909
- btn.classList.add('active');
1910
- currentShape = btn.dataset.shape;
1911
- };
1912
- });
1913
-
1914
- // Shape Colors
1915
- document.querySelectorAll('#shapeColors .colorDot').forEach(dot => {
1916
- dot.onclick = (e) => {
1917
- e.stopPropagation();
1918
- document.querySelectorAll('#shapeColors .colorDot').forEach(d => d.classList.remove('active'));
1919
- dot.classList.add('active');
1920
- shapeColor = dot.dataset.color;
1921
- if (currentTool === 'shape') currentColor = shapeColor;
1922
- };
1923
- });
1924
-
1925
- // Shape Thickness Slider
1926
- document.getElementById('shapeThickness').oninput = (e) => {
1927
- shapeWidth = parseInt(e.target.value);
1928
- if (currentTool === 'shape') currentWidth = shapeWidth;
1929
- };
1930
-
1931
- // Annotation Layer with Persistence
1932
- async function injectAnnotationLayer(pageNum) {
1933
- const pageView = pdfViewer.getPageView(pageNum - 1);
1934
- if (!pageView?.div) return;
1935
-
1936
- // Remove old SVG if exists (may have stale reference)
1937
- const oldSvg = pageView.div.querySelector('.annotationLayer');
1938
- if (oldSvg) oldSvg.remove();
1939
-
1940
- // Get or calculate base dimensions (scale=1.0) - FIXED reference
1941
- let baseDims = pageBaseDimensions.get(pageNum);
1942
- if (!baseDims) {
1943
- const page = await pdfDoc.getPage(pageNum);
1944
- const baseViewport = page.getViewport({ scale: 1.0 });
1945
- baseDims = { width: baseViewport.width, height: baseViewport.height };
1946
- pageBaseDimensions.set(pageNum, baseDims);
1947
- }
1948
-
1949
- // Create fresh SVG with FIXED viewBox (always scale=1.0 dimensions)
1950
- const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
1951
- svg.setAttribute('class', 'annotationLayer');
1952
- svg.setAttribute('viewBox', `0 0 ${baseDims.width} ${baseDims.height}`);
1953
- svg.setAttribute('preserveAspectRatio', 'none');
1954
- svg.style.width = '100%';
1955
- svg.style.height = '100%';
1956
- svg.dataset.page = pageNum;
1957
- svg.dataset.viewboxWidth = baseDims.width;
1958
- svg.dataset.viewboxHeight = baseDims.height;
1959
- svg.dataset.viewboxHeight = baseDims.height;
1960
- pageView.div.appendChild(svg);
1961
-
1962
-
1963
-
1964
- // Restore saved annotations for this page
1965
- if (annotationsStore.has(pageNum)) {
1966
- svg.innerHTML = annotationsStore.get(pageNum);
1967
- }
1968
-
1969
- svg.addEventListener('mousedown', (e) => startDraw(e, pageNum));
1970
- svg.addEventListener('mousemove', draw);
1971
- svg.addEventListener('mouseup', () => stopDraw(pageNum));
1972
- svg.addEventListener('mouseleave', () => stopDraw(pageNum));
1973
-
1974
- // Touch support for tablets
1975
- svg.addEventListener('touchstart', (e) => {
1976
- // Prevent default to avoid scroll while drawing/selecting
1977
- if (currentTool) e.preventDefault();
1978
- startDraw(e, pageNum);
1979
- }, { passive: false });
1980
- svg.addEventListener('touchmove', (e) => {
1981
- if (currentTool) e.preventDefault();
1982
- draw(e);
1983
- }, { passive: false });
1984
- svg.addEventListener('touchend', () => stopDraw(pageNum));
1985
- svg.addEventListener('touchcancel', () => stopDraw(pageNum));
1986
-
1987
- svg.classList.toggle('active', annotationMode);
1988
- }
1989
-
1990
- // Save annotations for a page
1991
- function saveAnnotations(pageNum) {
1992
- const pageView = pdfViewer.getPageView(pageNum - 1);
1993
- const svg = pageView?.div?.querySelector('.annotationLayer');
1994
- if (svg && svg.innerHTML.trim()) {
1995
- annotationsStore.set(pageNum, svg.innerHTML);
1996
- }
1997
- }
1998
-
1999
- function startDraw(e, pageNum) {
2000
- if (!annotationMode || !currentTool) return;
2001
-
2002
- e.preventDefault(); // Prevent text selection
2003
-
2004
- const svg = e.currentTarget;
2005
- if (!svg || !svg.dataset.viewboxWidth) return; // Defensive check
2006
-
2007
- // Handle select tool separately
2008
- if (currentTool === 'select') {
2009
- if (handleSelectMouseDown(e, svg, pageNum)) {
2010
- return; // Select tool handled the event
2011
- }
2012
- }
2013
-
2014
- isDrawing = true;
2015
- currentDrawingPage = pageNum;
2016
- currentSvg = svg; // Store reference
2017
-
2018
- const rect = svg.getBoundingClientRect();
2019
-
2020
- // Convert screen coords to viewBox coords
2021
- const viewBoxWidth = parseFloat(svg.dataset.viewboxWidth);
2022
- const viewBoxHeight = parseFloat(svg.dataset.viewboxHeight);
2023
- const scaleX = viewBoxWidth / rect.width;
2024
- const scaleY = viewBoxHeight / rect.height;
2025
-
2026
- // Get coordinates from mouse or touch event
2027
- const coords = getEventCoords(e);
2028
- const x = (coords.clientX - rect.left) * scaleX;
2029
- const y = (coords.clientY - rect.top) * scaleY;
2030
-
2031
- if (currentTool === 'eraser') {
2032
- eraseAt(svg, x, y, scaleX);
2033
- saveAnnotations(pageNum);
2034
- return;
2035
- }
2036
-
2037
- // Text tool - create/edit/drag text
2038
- if (currentTool === 'text') {
2039
- // Check if clicked on existing text element
2040
- const elementsUnderClick = document.elementsFromPoint(e.clientX, e.clientY);
2041
- const existingText = elementsUnderClick.find(el => el.tagName === 'text' && el.closest('.annotationLayer'));
2042
-
2043
- if (existingText) {
2044
- // Start dragging (double-click will edit via separate handler)
2045
- startTextDrag(e, existingText, svg, scaleX, scaleY, pageNum);
2046
- } else {
2047
- // Create new text
2048
- showTextEditor(e.clientX, e.clientY, svg, x, y, scaleX, pageNum);
2049
- }
2050
- return;
2051
- }
2052
-
2053
- // Shape tool - create shapes
2054
- if (currentTool === 'shape') {
2055
- isDrawing = true;
2056
- // Store start position for shape drawing
2057
- svg.dataset.shapeStartX = x;
2058
- svg.dataset.shapeStartY = y;
2059
- svg.dataset.shapeScaleX = scaleX;
2060
- svg.dataset.shapeScaleY = scaleY;
2061
-
2062
- let shapeEl;
2063
- if (currentShape === 'rectangle') {
2064
- shapeEl = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
2065
- shapeEl.setAttribute('x', x);
2066
- shapeEl.setAttribute('y', y);
2067
- shapeEl.setAttribute('width', 0);
2068
- shapeEl.setAttribute('height', 0);
2069
- } else if (currentShape === 'circle') {
2070
- shapeEl = document.createElementNS('http://www.w3.org/2000/svg', 'ellipse');
2071
- shapeEl.setAttribute('cx', x);
2072
- shapeEl.setAttribute('cy', y);
2073
- shapeEl.setAttribute('rx', 0);
2074
- shapeEl.setAttribute('ry', 0);
2075
- } else if (currentShape === 'line' || currentShape === 'arrow') {
2076
- shapeEl = document.createElementNS('http://www.w3.org/2000/svg', 'line');
2077
- shapeEl.setAttribute('x1', x);
2078
- shapeEl.setAttribute('y1', y);
2079
- shapeEl.setAttribute('x2', x);
2080
- shapeEl.setAttribute('y2', y);
2081
- }
2082
-
2083
- shapeEl.setAttribute('stroke', currentColor);
2084
- shapeEl.setAttribute('stroke-width', currentWidth * scaleX);
2085
- shapeEl.setAttribute('fill', 'none');
2086
- shapeEl.classList.add('current-shape');
2087
- svg.appendChild(shapeEl);
2088
- return;
2089
- }
2090
-
2091
- currentPath = document.createElementNS('http://www.w3.org/2000/svg', 'path');
2092
- currentPath.setAttribute('stroke', currentColor);
2093
- currentPath.setAttribute('fill', 'none');
2094
-
2095
- if (currentTool === 'highlight') {
2096
- // Highlighter uses stroke size * 5 for thicker strokes
2097
- currentPath.setAttribute('stroke-width', String(currentWidth * 5 * scaleX));
2098
- currentPath.setAttribute('stroke-opacity', '0.35');
2099
- } else {
2100
- currentPath.setAttribute('stroke-width', String(currentWidth * scaleX));
2101
- currentPath.setAttribute('stroke-opacity', '1');
2102
- }
2103
-
2104
- currentPath.setAttribute('d', `M${x.toFixed(2)},${y.toFixed(2)}`);
2105
- svg.appendChild(currentPath);
2106
- }
2107
-
2108
- function draw(e) {
2109
- if (!isDrawing || !currentSvg) return;
2110
-
2111
- e.preventDefault(); // Prevent text selection
2112
-
2113
- const svg = currentSvg; // Use stored reference
2114
- if (!svg || !svg.dataset.viewboxWidth) return;
2115
-
2116
- const rect = svg.getBoundingClientRect();
2117
-
2118
- // Convert screen coords to viewBox coords
2119
- const viewBoxWidth = parseFloat(svg.dataset.viewboxWidth);
2120
- const viewBoxHeight = parseFloat(svg.dataset.viewboxHeight);
2121
- const scaleX = viewBoxWidth / rect.width;
2122
- const scaleY = viewBoxHeight / rect.height;
2123
-
2124
- // Get coordinates from mouse or touch event
2125
- const coords = getEventCoords(e);
2126
- const x = (coords.clientX - rect.left) * scaleX;
2127
- const y = (coords.clientY - rect.top) * scaleY;
2128
-
2129
- if (currentTool === 'eraser') {
2130
- eraseAt(svg, x, y, scaleX);
2131
- return;
2132
- }
2133
-
2134
- // Shape tool - update shape size
2135
- if (currentTool === 'shape') {
2136
- const shapeEl = svg.querySelector('.current-shape');
2137
- if (!shapeEl) return;
2138
-
2139
- const startX = parseFloat(svg.dataset.shapeStartX);
2140
- const startY = parseFloat(svg.dataset.shapeStartY);
2141
-
2142
- if (currentShape === 'rectangle') {
2143
- const width = Math.abs(x - startX);
2144
- const height = Math.abs(y - startY);
2145
- shapeEl.setAttribute('x', Math.min(x, startX));
2146
- shapeEl.setAttribute('y', Math.min(y, startY));
2147
- shapeEl.setAttribute('width', width);
2148
- shapeEl.setAttribute('height', height);
2149
- } else if (currentShape === 'circle') {
2150
- const rx = Math.abs(x - startX) / 2;
2151
- const ry = Math.abs(y - startY) / 2;
2152
- shapeEl.setAttribute('cx', (startX + x) / 2);
2153
- shapeEl.setAttribute('cy', (startY + y) / 2);
2154
- shapeEl.setAttribute('rx', rx);
2155
- shapeEl.setAttribute('ry', ry);
2156
- } else if (currentShape === 'line' || currentShape === 'arrow' || currentShape === 'callout') {
2157
- shapeEl.setAttribute('x2', x);
2158
- shapeEl.setAttribute('y2', y);
2159
- }
2160
- return;
2161
- }
2162
-
2163
- if (currentPath) {
2164
- currentPath.setAttribute('d', currentPath.getAttribute('d') + ` L${x.toFixed(2)},${y.toFixed(2)}`);
2165
- }
2166
- }
2167
-
2168
- function stopDraw(pageNum) {
2169
- // Handle arrow marker
2170
- if (currentTool === 'shape' && currentShape === 'arrow' && currentSvg) {
2171
- const shapeEl = currentSvg.querySelector('.current-shape');
2172
- if (shapeEl && shapeEl.tagName === 'line') {
2173
- // Create arrow head as a group
2174
- const x1 = parseFloat(shapeEl.getAttribute('x1'));
2175
- const y1 = parseFloat(shapeEl.getAttribute('y1'));
2176
- const x2 = parseFloat(shapeEl.getAttribute('x2'));
2177
- const y2 = parseFloat(shapeEl.getAttribute('y2'));
2178
-
2179
- // Calculate arrow head
2180
- const angle = Math.atan2(y2 - y1, x2 - x1);
2181
- const headLength = 15 * parseFloat(currentSvg.dataset.shapeScaleX || 1);
2182
-
2183
- const arrowHead = document.createElementNS('http://www.w3.org/2000/svg', 'path');
2184
- const p1x = x2 - headLength * Math.cos(angle - Math.PI / 6);
2185
- const p1y = y2 - headLength * Math.sin(angle - Math.PI / 6);
2186
- const p2x = x2 - headLength * Math.cos(angle + Math.PI / 6);
2187
- const p2y = y2 - headLength * Math.sin(angle + Math.PI / 6);
2188
-
2189
- arrowHead.setAttribute('d', `M${x2},${y2} L${p1x},${p1y} M${x2},${y2} L${p2x},${p2y}`);
2190
- arrowHead.setAttribute('stroke', shapeEl.getAttribute('stroke'));
2191
- arrowHead.setAttribute('stroke-width', shapeEl.getAttribute('stroke-width'));
2192
- arrowHead.setAttribute('fill', 'none');
2193
- currentSvg.appendChild(arrowHead);
2194
- }
2195
- }
2196
-
2197
- // Handle callout - arrow with text at the start, pointing to end
2198
- // UX: Click where you want text box, drag to point at something
2199
- if (currentTool === 'shape' && currentShape === 'callout' && currentSvg) {
2200
- const shapeEl = currentSvg.querySelector('.current-shape');
2201
- if (shapeEl && shapeEl.tagName === 'line') {
2202
- const x1 = parseFloat(shapeEl.getAttribute('x1')); // Start - where text box goes
2203
- const y1 = parseFloat(shapeEl.getAttribute('y1'));
2204
- const x2 = parseFloat(shapeEl.getAttribute('x2')); // End - where arrow points
2205
- const y2 = parseFloat(shapeEl.getAttribute('y2'));
2206
-
2207
- // Only create callout if line has been drawn (not just a click)
2208
- if (Math.abs(x2 - x1) > 5 || Math.abs(y2 - y1) > 5) {
2209
- const scaleX = parseFloat(currentSvg.dataset.shapeScaleX || 1);
2210
-
2211
- // Arrow head points TO the end (x2,y2) - where user wants to point at
2212
- const angle = Math.atan2(y2 - y1, x2 - x1);
2213
- const headLength = 12 * scaleX;
2214
-
2215
- const arrowHead = document.createElementNS('http://www.w3.org/2000/svg', 'path');
2216
- const p1x = x2 - headLength * Math.cos(angle - Math.PI / 6);
2217
- const p1y = y2 - headLength * Math.sin(angle - Math.PI / 6);
2218
- const p2x = x2 - headLength * Math.cos(angle + Math.PI / 6);
2219
- const p2y = y2 - headLength * Math.sin(angle + Math.PI / 6);
2220
-
2221
- arrowHead.setAttribute('d', `M${x2},${y2} L${p1x},${p1y} M${x2},${y2} L${p2x},${p2y}`);
2222
- arrowHead.setAttribute('stroke', shapeEl.getAttribute('stroke'));
2223
- arrowHead.setAttribute('stroke-width', shapeEl.getAttribute('stroke-width'));
2224
- arrowHead.setAttribute('fill', 'none');
2225
- arrowHead.classList.add('callout-arrow');
2226
- currentSvg.appendChild(arrowHead);
2227
-
2228
- // Store references for text editor
2229
- const svg = currentSvg;
2230
- const currentPageNum = currentDrawingPage;
2231
- const arrowColor = shapeEl.getAttribute('stroke');
2232
-
2233
- // Calculate screen position for text editor at START of arrow (x1,y1)
2234
- // This is where the user clicked first - where they want the text
2235
- const rect = svg.getBoundingClientRect();
2236
- const viewBoxWidth = parseFloat(svg.dataset.viewboxWidth);
2237
- const viewBoxHeight = parseFloat(svg.dataset.viewboxHeight);
2238
- const screenX = rect.left + (x1 / viewBoxWidth) * rect.width;
2239
- const screenY = rect.top + (y1 / viewBoxHeight) * rect.height;
2240
-
2241
- // Remove the current-shape class before showing editor
2242
- shapeEl.classList.remove('current-shape');
2243
-
2244
- // Save first, then open text editor
2245
- saveAnnotations(currentPageNum);
2246
-
2247
- // Open text editor at the START of the arrow (where user clicked)
2248
- setTimeout(() => {
2249
- showTextEditor(screenX, screenY, svg, x1, y1, scaleX, currentPageNum, null, arrowColor);
2250
- }, 50);
2251
-
2252
- // Reset state
2253
- isDrawing = false;
2254
- currentPath = null;
2255
- currentSvg = null;
2256
- currentDrawingPage = null;
2257
- return; // Exit early, text editor will handle the rest
2258
- }
2259
- }
2260
- }
2261
-
2262
- // Remove the current-shape class
2263
- if (currentSvg) {
2264
- const shapeEl = currentSvg.querySelector('.current-shape');
2265
- if (shapeEl) shapeEl.classList.remove('current-shape');
2266
- }
2267
-
2268
- if (isDrawing && currentDrawingPage) {
2269
- saveAnnotations(currentDrawingPage);
2270
- }
2271
- isDrawing = false;
2272
- currentPath = null;
2273
- currentSvg = null;
2274
- currentDrawingPage = null;
2275
- }
2276
-
2277
- // Text Drag-and-Drop
2278
- let draggedText = null;
2279
- let dragStartX = 0;
2280
- let dragStartY = 0;
2281
- let textOriginalX = 0;
2282
- let textOriginalY = 0;
2283
- let hasDragged = false;
2284
-
2285
- function startTextDrag(e, textEl, svg, scaleX, scaleY, pageNum) {
2286
- e.preventDefault();
2287
- e.stopPropagation();
2288
-
2289
- draggedText = textEl;
2290
- textEl.classList.add('dragging');
2291
- hasDragged = false;
2292
-
2293
- const rect = svg.getBoundingClientRect();
2294
- dragStartX = e.clientX;
2295
- dragStartY = e.clientY;
2296
- textOriginalX = parseFloat(textEl.getAttribute('x'));
2297
- textOriginalY = parseFloat(textEl.getAttribute('y'));
2298
-
2299
- function onMouseMove(ev) {
2300
- const dx = (ev.clientX - dragStartX) * scaleX;
2301
- const dy = (ev.clientY - dragStartY) * scaleY;
2302
-
2303
- if (Math.abs(dx) > 2 || Math.abs(dy) > 2) {
2304
- hasDragged = true;
2305
- }
2306
-
2307
- textEl.setAttribute('x', (textOriginalX + dx).toFixed(2));
2308
- textEl.setAttribute('y', (textOriginalY + dy).toFixed(2));
2309
- }
2310
-
2311
- function onMouseUp(ev) {
2312
- document.removeEventListener('mousemove', onMouseMove);
2313
- document.removeEventListener('mouseup', onMouseUp);
2314
- textEl.classList.remove('dragging');
2315
-
2316
- if (hasDragged) {
2317
- // Moved - save position
2318
- saveAnnotations(pageNum);
2319
- } else {
2320
- // Not moved - short click = edit
2321
- const viewBoxWidth = parseFloat(svg.dataset.viewboxWidth);
2322
- const viewBoxHeight = parseFloat(svg.dataset.viewboxHeight);
2323
- const svgX = parseFloat(textEl.getAttribute('x'));
2324
- const svgY = parseFloat(textEl.getAttribute('y'));
2325
- // Note: showTextEditor needs scaleX for font scaling logic, which we still have from arguments
2326
- showTextEditor(ev.clientX, ev.clientY, svg, svgX, svgY, scaleX, pageNum, textEl);
2327
- }
2328
-
2329
- draggedText = null;
2330
- }
2331
-
2332
- document.addEventListener('mousemove', onMouseMove);
2333
- document.addEventListener('mouseup', onMouseUp);
2334
- }
2335
-
2336
- // Inline Text Editor
2337
- let textFontSize = 14;
2338
-
2339
- function showTextEditor(screenX, screenY, svg, svgX, svgY, scale, pageNum, existingTextEl = null, overrideColor = null) {
2340
- // Remove existing editor if any
2341
- const existingOverlay = document.querySelector('.textEditorOverlay');
2342
- if (existingOverlay) existingOverlay.remove();
2343
-
2344
- // Use override color (for callout) or current color
2345
- const textColor = overrideColor || currentColor;
2346
-
2347
- // If editing existing text, get its properties
2348
- let editingText = null;
2349
- if (existingTextEl && typeof existingTextEl === 'object' && existingTextEl.textContent !== undefined) {
2350
- editingText = existingTextEl.textContent;
2351
- textFontSize = parseFloat(existingTextEl.getAttribute('font-size')) / scale || 14;
2352
- }
2353
-
2354
- // Create overlay
2355
- const overlay = document.createElement('div');
2356
- overlay.className = 'textEditorOverlay';
2357
-
2358
- // Create editor box
2359
- const box = document.createElement('div');
2360
- box.className = 'textEditorBox';
2361
- box.style.left = screenX + 'px';
2362
- box.style.top = screenY + 'px';
2363
-
2364
- // Input area
2365
- const input = document.createElement('div');
2366
- input.className = 'textEditorInput';
2367
- input.contentEditable = true;
2368
- input.style.color = textColor;
2369
- input.style.fontSize = textFontSize + 'px';
2370
- if (editingText) {
2371
- input.textContent = editingText;
2372
- }
2373
-
2374
- // Toolbar
2375
- const toolbar = document.createElement('div');
2376
- toolbar.className = 'textEditorToolbar';
2377
-
2378
- // Color indicator
2379
- const colorDot = document.createElement('div');
2380
- colorDot.className = 'textEditorColorDot active';
2381
- colorDot.style.background = textColor;
2382
-
2383
- // Font size decrease
2384
- const decreaseBtn = document.createElement('button');
2385
- decreaseBtn.className = 'textEditorBtn';
2386
- decreaseBtn.innerHTML = 'A<sup>-</sup>';
2387
- decreaseBtn.onclick = (e) => {
2388
- e.stopPropagation();
2389
- if (textFontSize > 10) {
2390
- textFontSize -= 2;
2391
- input.style.fontSize = textFontSize + 'px';
2392
- }
2393
- };
2394
-
2395
- // Font size increase
2396
- const increaseBtn = document.createElement('button');
2397
- increaseBtn.className = 'textEditorBtn';
2398
- increaseBtn.innerHTML = 'A<sup>+</sup>';
2399
- increaseBtn.onclick = (e) => {
2400
- e.stopPropagation();
2401
- if (textFontSize < 32) {
2402
- textFontSize += 2;
2403
- input.style.fontSize = textFontSize + 'px';
2404
- }
2405
- };
2406
-
2407
- // Delete button - also deletes existing element if editing
2408
- const deleteBtn = document.createElement('button');
2409
- deleteBtn.className = 'textEditorBtn delete';
2410
- deleteBtn.innerHTML = '🗑️';
2411
- deleteBtn.onclick = (e) => {
2412
- e.stopPropagation();
2413
- if (existingTextEl) {
2414
- existingTextEl.remove();
2415
- saveAnnotations(pageNum);
2416
- }
2417
- overlay.remove();
2418
- };
2419
-
2420
- toolbar.appendChild(colorDot);
2421
- toolbar.appendChild(decreaseBtn);
2422
- toolbar.appendChild(increaseBtn);
2423
- toolbar.appendChild(deleteBtn);
2424
-
2425
- box.appendChild(input);
2426
- box.appendChild(toolbar);
2427
- overlay.appendChild(box);
2428
- document.body.appendChild(overlay);
2429
-
2430
- // Focus input and select all if editing
2431
- setTimeout(() => {
2432
- input.focus();
2433
- if (editingText) {
2434
- const range = document.createRange();
2435
- range.selectNodeContents(input);
2436
- const sel = window.getSelection();
2437
- sel.removeAllRanges();
2438
- sel.addRange(range);
2439
- }
2440
- }, 50);
2441
-
2442
- // Confirm on click outside or Enter
2443
- function confirmText() {
2444
- const text = input.textContent.trim();
2445
- if (text) {
2446
- if (existingTextEl) {
2447
- // Update existing text element
2448
- existingTextEl.textContent = text;
2449
- existingTextEl.setAttribute('fill', textColor);
2450
- existingTextEl.setAttribute('font-size', String(textFontSize * scale));
2451
- } else {
2452
- // Create new text element
2453
- const textEl = document.createElementNS('http://www.w3.org/2000/svg', 'text');
2454
- textEl.setAttribute('x', svgX.toFixed(2));
2455
- textEl.setAttribute('y', svgY.toFixed(2));
2456
- textEl.setAttribute('fill', textColor);
2457
- textEl.setAttribute('font-size', String(textFontSize * scale));
2458
- textEl.setAttribute('font-family', 'Segoe UI, Arial, sans-serif');
2459
- textEl.textContent = text;
2460
- svg.appendChild(textEl);
2461
- }
2462
- saveAnnotations(pageNum);
2463
- } else if (existingTextEl) {
2464
- // Empty text = delete existing
2465
- existingTextEl.remove();
2466
- saveAnnotations(pageNum);
2467
- }
2468
- overlay.remove();
2469
- }
2470
-
2471
- overlay.addEventListener('click', (e) => {
2472
- if (e.target === overlay) confirmText();
2473
- });
2474
-
2475
- input.addEventListener('keydown', (e) => {
2476
- if (e.key === 'Enter' && !e.shiftKey) {
2477
- e.preventDefault();
2478
- confirmText();
2479
- }
2480
- if (e.key === 'Escape') {
2481
- overlay.remove();
2482
- }
2483
- });
2484
- }
2485
-
2486
- function eraseAt(svg, x, y, scale = 1) {
2487
- const hitRadius = 15 * scale; // Scale hit radius with viewBox
2488
- // Erase paths, text, and shape elements (rect, ellipse, line)
2489
- svg.querySelectorAll('path, text, rect, ellipse, line').forEach(el => {
2490
- const bbox = el.getBBox();
2491
- if (x >= bbox.x - hitRadius && x <= bbox.x + bbox.width + hitRadius &&
2492
- y >= bbox.y - hitRadius && y <= bbox.y + bbox.height + hitRadius) {
2493
- el.remove();
2494
- }
2495
- });
2496
-
2497
- // Also erase text highlights (in separate container)
2498
- const pageDiv = svg.closest('.page');
2499
- if (pageDiv) {
2500
- const highlightContainer = pageDiv.querySelector('.textHighlightContainer');
2501
- if (highlightContainer) {
2502
- const pageRect = pageDiv.getBoundingClientRect();
2503
- const svgRect = svg.getBoundingClientRect();
2504
- // Convert viewBox coords to screen coords, then to percentages
2505
- const screenX = (x / scale) + svgRect.left - pageRect.left;
2506
- const screenY = (y / scale) + svgRect.top - pageRect.top;
2507
- const screenXPercent = (screenX / pageRect.width) * 100;
2508
- const screenYPercent = (screenY / pageRect.height) * 100;
2509
-
2510
- highlightContainer.querySelectorAll('.textHighlight').forEach(el => {
2511
- const left = parseFloat(el.style.left); // Already in %
2512
- const top = parseFloat(el.style.top);
2513
- const width = parseFloat(el.style.width);
2514
- const height = parseFloat(el.style.height);
2515
-
2516
- if (screenXPercent >= left - 2 && screenXPercent <= left + width + 2 &&
2517
- screenYPercent >= top - 2 && screenYPercent <= top + height + 2) {
2518
- el.remove();
2519
- // Save changes
2520
- const pageNum = parseInt(pageDiv.dataset.pageNumber);
2521
- saveTextHighlights(pageNum, pageDiv);
2522
- }
2523
- });
2524
- }
2525
- }
2526
- }
2527
-
2528
- // ==========================================
2529
- // TEXT SELECTION HIGHLIGHTING (Adobe/Edge style)
2530
- // ==========================================
2531
- let highlightPopup = null;
2532
-
2533
- function removeHighlightPopup() {
2534
- if (highlightPopup) {
2535
- highlightPopup.remove();
2536
- highlightPopup = null;
2537
- }
2538
- }
2539
-
2540
- function getSelectionRects() {
2541
- const selection = window.getSelection();
2542
- if (!selection || selection.isCollapsed || !selection.rangeCount) return null;
2543
-
2544
- const range = selection.getRangeAt(0);
2545
- const rects = range.getClientRects();
2546
- if (rects.length === 0) return null;
2547
-
2548
- // Find which page the selection is in
2549
- const startNode = range.startContainer.parentElement;
2550
- const textLayer = startNode?.closest('.textLayer');
2551
- if (!textLayer) return null;
2552
-
2553
- const pageDiv = textLayer.closest('.page');
2554
- if (!pageDiv) return null;
2555
-
2556
- const pageNum = parseInt(pageDiv.dataset.pageNumber);
2557
- const pageRect = pageDiv.getBoundingClientRect();
2558
-
2559
- // Convert rects to page-relative coordinates
2560
- const relativeRects = [];
2561
- for (let i = 0; i < rects.length; i++) {
2562
- const rect = rects[i];
2563
- relativeRects.push({
2564
- x: rect.left - pageRect.left,
2565
- y: rect.top - pageRect.top,
2566
- width: rect.width,
2567
- height: rect.height
2568
- });
2569
- }
2570
-
2571
- return { pageNum, pageDiv, relativeRects, lastRect: rects[rects.length - 1] };
2572
- }
2573
-
2574
- function createTextHighlights(pageDiv, rects, color) {
2575
- // Find or create highlight container
2576
- let highlightContainer = pageDiv.querySelector('.textHighlightContainer');
2577
- if (!highlightContainer) {
2578
- highlightContainer = document.createElement('div');
2579
- highlightContainer.className = 'textHighlightContainer';
2580
- highlightContainer.style.cssText = 'position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;z-index:5;';
2581
- pageDiv.insertBefore(highlightContainer, pageDiv.firstChild);
2582
- }
2583
-
2584
- // Get page dimensions for percentage calculation
2585
- const pageRect = pageDiv.getBoundingClientRect();
2586
- const pageWidth = pageRect.width;
2587
- const pageHeight = pageRect.height;
2588
-
2589
- // Add highlight rectangles with percentage positioning
2590
- rects.forEach(rect => {
2591
- const div = document.createElement('div');
2592
- div.className = 'textHighlight';
2593
-
2594
- // Convert to percentages for zoom-independent positioning
2595
- const leftPercent = (rect.x / pageWidth) * 100;
2596
- const topPercent = (rect.y / pageHeight) * 100;
2597
- const widthPercent = (rect.width / pageWidth) * 100;
2598
- const heightPercent = (rect.height / pageHeight) * 100;
2599
-
2600
- div.style.cssText = `
2601
- left: ${leftPercent}%;
2602
- top: ${topPercent}%;
2603
- width: ${widthPercent}%;
2604
- height: ${heightPercent}%;
2605
- background: ${color};
2606
- opacity: 0.35;
2607
- `;
2608
- highlightContainer.appendChild(div);
2609
- });
2610
-
2611
- // Save to annotations store
2612
- const pageNum = parseInt(pageDiv.dataset.pageNumber);
2613
- saveTextHighlights(pageNum, pageDiv);
2614
- }
2615
-
2616
- function saveTextHighlights(pageNum, pageDiv) {
2617
- const container = pageDiv.querySelector('.textHighlightContainer');
2618
- if (container) {
2619
- const key = `textHighlight_${pageNum}`;
2620
- localStorage.setItem(key, container.innerHTML);
2621
- }
2622
- }
2623
-
2624
- function loadTextHighlights(pageNum, pageDiv) {
2625
- const key = `textHighlight_${pageNum}`;
2626
- const saved = localStorage.getItem(key);
2627
- if (saved) {
2628
- let container = pageDiv.querySelector('.textHighlightContainer');
2629
- if (!container) {
2630
- container = document.createElement('div');
2631
- container.className = 'textHighlightContainer';
2632
- container.style.cssText = 'position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none;z-index:5;';
2633
- pageDiv.insertBefore(container, pageDiv.firstChild);
2634
- }
2635
- container.innerHTML = saved;
2636
- }
2637
- }
2638
-
2639
- function showHighlightPopup(x, y, pageDiv, rects) {
2640
- removeHighlightPopup();
2641
-
2642
- highlightPopup = document.createElement('div');
2643
- highlightPopup.className = 'highlightPopup';
2644
- highlightPopup.style.left = x + 'px';
2645
- highlightPopup.style.top = (y + 10) + 'px';
2646
-
2647
- const colors = ['#fff100', '#16c60c', '#00b7c3', '#0078d4', '#886ce4', '#e81224'];
2648
- colors.forEach(color => {
2649
- const btn = document.createElement('button');
2650
- btn.style.background = color;
2651
- btn.title = 'Vurgula';
2652
- btn.onclick = (e) => {
2653
- e.stopPropagation();
2654
- createTextHighlights(pageDiv, rects, color);
2655
- window.getSelection().removeAllRanges();
2656
- removeHighlightPopup();
2657
- };
2658
- highlightPopup.appendChild(btn);
2659
- });
2660
-
2661
- document.body.appendChild(highlightPopup);
2662
- }
2663
-
2664
- // Listen for text selection
2665
- document.addEventListener('mouseup', (e) => {
2666
- // Small delay to let selection finalize
2667
- setTimeout(() => {
2668
- const selData = getSelectionRects();
2669
- if (selData && selData.relativeRects.length > 0) {
2670
- const lastRect = selData.lastRect;
2671
- showHighlightPopup(lastRect.right, lastRect.bottom, selData.pageDiv, selData.relativeRects);
2672
- } else {
2673
- removeHighlightPopup();
2674
- }
2675
- }, 10);
2676
- });
2677
-
2678
- // Remove popup on click elsewhere
2679
- document.addEventListener('mousedown', (e) => {
2680
- if (highlightPopup && !highlightPopup.contains(e.target)) {
2681
- removeHighlightPopup();
2682
- }
2683
- });
2684
-
2685
- // Load text highlights when pages render
2686
- eventBus.on('pagerendered', (evt) => {
2687
- const pageDiv = pdfViewer.getPageView(evt.pageNumber - 1)?.div;
2688
- if (pageDiv) {
2689
- loadTextHighlights(evt.pageNumber, pageDiv);
2690
- }
2691
- });
2692
-
2693
- // ==========================================
2694
- // SELECT/MOVE TOOL (Fixed + Touch Support)
2695
- // ==========================================
2696
- let selectedAnnotation = null;
2697
- let selectedSvg = null;
2698
- let selectedPageNum = null;
2699
- let copiedAnnotation = null;
2700
- let copiedPageNum = null;
2701
- let isDraggingAnnotation = false;
2702
- let annotationDragStartX = 0;
2703
- let annotationDragStartY = 0;
2704
-
2705
- // Create selection toolbar for touch devices
2706
- const selectionToolbar = document.createElement('div');
2707
- selectionToolbar.className = 'selection-toolbar';
2708
- selectionToolbar.innerHTML = `
2709
- <button data-action="copy" title="Kopyala (Ctrl+C)">
2710
- <svg viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>
2711
- <span>Kopyala</span>
2712
- </button>
2713
- <button data-action="duplicate" title="Çoğalt">
2714
- <svg viewBox="0 0 24 24"><path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10h-4v4h-2v-4H7v-2h4V7h2v4h4v2z"/></svg>
2715
- <span>Çoğalt</span>
2716
- </button>
2717
- <button data-action="delete" class="delete" title="Sil (Del)">
2718
- <svg viewBox="0 0 24 24"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/></svg>
2719
- <span>Sil</span>
2720
- </button>
2721
- `;
2722
- document.body.appendChild(selectionToolbar);
2723
-
2724
- // Selection toolbar event handlers
2725
- selectionToolbar.addEventListener('click', (e) => {
2726
- const btn = e.target.closest('button');
2727
- if (!btn) return;
2728
-
2729
- const action = btn.dataset.action;
2730
- if (action === 'copy') {
2731
- copySelectedAnnotation();
2732
- showToast('Kopyalandı!');
2733
- } else if (action === 'duplicate') {
2734
- copySelectedAnnotation();
2735
- pasteAnnotation();
2736
- showToast('Çoğaltıldı!');
2737
- } else if (action === 'delete') {
2738
- deleteSelectedAnnotation();
2739
- showToast('Silindi!');
2740
- }
2741
- });
2742
-
2743
- function showToast(message) {
2744
- const existingToast = document.querySelector('.toast-notification');
2745
- if (existingToast) existingToast.remove();
2746
-
2747
- const toast = document.createElement('div');
2748
- toast.className = 'toast-notification';
2749
- toast.textContent = message;
2750
- document.body.appendChild(toast);
2751
- setTimeout(() => toast.remove(), 2000);
2752
- }
2753
-
2754
- function updateSelectionToolbar() {
2755
- if (selectedAnnotation && currentTool === 'select') {
2756
- selectionToolbar.classList.add('visible');
2757
- } else {
2758
- selectionToolbar.classList.remove('visible');
2759
- }
2760
- }
2761
-
2762
- function clearAnnotationSelection() {
2763
- if (selectedAnnotation) {
2764
- selectedAnnotation.classList.remove('annotation-selected', 'annotation-dragging', 'just-selected');
2765
- }
2766
- selectedAnnotation = null;
2767
- selectedSvg = null;
2768
- selectedPageNum = null;
2769
- isDraggingAnnotation = false;
2770
- updateSelectionToolbar();
2771
- }
2772
-
2773
- function selectAnnotation(element, svg, pageNum) {
2774
- clearAnnotationSelection();
2775
- selectedAnnotation = element;
2776
- selectedSvg = svg;
2777
- selectedPageNum = pageNum;
2778
- element.classList.add('annotation-selected', 'just-selected');
2779
-
2780
- // Remove pulse animation after it completes
2781
- setTimeout(() => {
2782
- element.classList.remove('just-selected');
2783
- }, 600);
2784
-
2785
- updateSelectionToolbar();
2786
- }
2787
-
2788
- function deleteSelectedAnnotation() {
2789
- if (selectedAnnotation && selectedSvg) {
2790
- selectedAnnotation.remove();
2791
- saveAnnotations(selectedPageNum);
2792
- clearAnnotationSelection();
2793
- }
2794
- }
2795
-
2796
- function copySelectedAnnotation() {
2797
- if (selectedAnnotation) {
2798
- copiedAnnotation = selectedAnnotation.cloneNode(true);
2799
- copiedAnnotation.classList.remove('annotation-selected', 'annotation-dragging', 'just-selected');
2800
- copiedPageNum = selectedPageNum;
2801
- }
2802
- }
2803
-
2804
- function pasteAnnotation() {
2805
- if (!copiedAnnotation || !pdfViewer) return;
2806
-
2807
- // Paste to current page
2808
- const currentPage = pdfViewer.currentPageNumber;
2809
- const pageView = pdfViewer.getPageView(currentPage - 1);
2810
- const svg = pageView?.div?.querySelector('.annotationLayer');
2811
-
2812
- if (svg) {
2813
- const cloned = copiedAnnotation.cloneNode(true);
2814
- const offset = 30; // Offset amount for pasted elements
2815
-
2816
- // Offset pasted element slightly
2817
- if (cloned.tagName === 'path') {
2818
- // For paths, add/update transform translate
2819
- const currentTransform = cloned.getAttribute('transform') || '';
2820
- const match = currentTransform.match(/translate\(([^,]+),([^)]+)\)/);
2821
- let tx = offset, ty = offset;
2822
- if (match) {
2823
- tx = parseFloat(match[1]) + offset;
2824
- ty = parseFloat(match[2]) + offset;
2825
- }
2826
- cloned.setAttribute('transform', `translate(${tx}, ${ty})`);
2827
- } else if (cloned.tagName === 'rect') {
2828
- cloned.setAttribute('x', parseFloat(cloned.getAttribute('x')) + offset);
2829
- cloned.setAttribute('y', parseFloat(cloned.getAttribute('y')) + offset);
2830
- } else if (cloned.tagName === 'ellipse') {
2831
- cloned.setAttribute('cx', parseFloat(cloned.getAttribute('cx')) + offset);
2832
- cloned.setAttribute('cy', parseFloat(cloned.getAttribute('cy')) + offset);
2833
- } else if (cloned.tagName === 'line') {
2834
- cloned.setAttribute('x1', parseFloat(cloned.getAttribute('x1')) + offset);
2835
- cloned.setAttribute('y1', parseFloat(cloned.getAttribute('y1')) + offset);
2836
- cloned.setAttribute('x2', parseFloat(cloned.getAttribute('x2')) + offset);
2837
- cloned.setAttribute('y2', parseFloat(cloned.getAttribute('y2')) + offset);
2838
- } else if (cloned.tagName === 'text') {
2839
- cloned.setAttribute('x', parseFloat(cloned.getAttribute('x')) + offset);
2840
- cloned.setAttribute('y', parseFloat(cloned.getAttribute('y')) + offset);
2841
- }
2842
-
2843
- svg.appendChild(cloned);
2844
- saveAnnotations(currentPage);
2845
- selectAnnotation(cloned, svg, currentPage);
2846
- }
2847
- }
2848
-
2849
- // Get coordinates from mouse or touch event
2850
- function getEventCoords(e) {
2851
- if (e.touches && e.touches.length > 0) {
2852
- return { clientX: e.touches[0].clientX, clientY: e.touches[0].clientY };
2853
- }
2854
- if (e.changedTouches && e.changedTouches.length > 0) {
2855
- return { clientX: e.changedTouches[0].clientX, clientY: e.changedTouches[0].clientY };
2856
- }
2857
- return { clientX: e.clientX, clientY: e.clientY };
2858
- }
2859
-
2860
- // Handle select tool events (both mouse and touch)
2861
- function handleSelectPointerDown(e, svg, pageNum) {
2862
- if (currentTool !== 'select') return false;
2863
-
2864
- const coords = getEventCoords(e);
2865
- const target = e.target;
2866
-
2867
- if (target === svg || target.tagName === 'svg') {
2868
- // Clicked on empty area - deselect
2869
- clearAnnotationSelection();
2870
- return true;
2871
- }
2872
-
2873
- // Check if clicked on an annotation element
2874
- if (target.closest('.annotationLayer') && target !== svg) {
2875
- e.preventDefault();
2876
- e.stopPropagation();
2877
-
2878
- selectAnnotation(target, svg, pageNum);
2879
-
2880
- // Start drag
2881
- const rect = svg.getBoundingClientRect();
2882
- const viewBoxWidth = parseFloat(svg.dataset.viewboxWidth);
2883
- const viewBoxHeight = parseFloat(svg.dataset.viewboxHeight);
2884
- const scaleX = viewBoxWidth / rect.width;
2885
- const scaleY = viewBoxHeight / rect.height;
2886
-
2887
- isDraggingAnnotation = true;
2888
- annotationDragStartX = coords.clientX;
2889
- annotationDragStartY = coords.clientY;
2890
-
2891
- target.classList.add('annotation-dragging');
2892
-
2893
- function onMove(ev) {
2894
- if (!isDraggingAnnotation) return;
2895
- ev.preventDefault();
2896
-
2897
- const moveCoords = getEventCoords(ev);
2898
- const dx = (moveCoords.clientX - annotationDragStartX) * scaleX;
2899
- const dy = (moveCoords.clientY - annotationDragStartY) * scaleY;
2900
-
2901
- // Move the element
2902
- moveAnnotation(target, dx, dy);
2903
-
2904
- // Update start position for next move (CRITICAL FIX)
2905
- annotationDragStartX = moveCoords.clientX;
2906
- annotationDragStartY = moveCoords.clientY;
2907
- }
2908
-
2909
- function onEnd(ev) {
2910
- document.removeEventListener('mousemove', onMove);
2911
- document.removeEventListener('mouseup', onEnd);
2912
- document.removeEventListener('touchmove', onMove);
2913
- document.removeEventListener('touchend', onEnd);
2914
- document.removeEventListener('touchcancel', onEnd);
2915
-
2916
- target.classList.remove('annotation-dragging');
2917
- isDraggingAnnotation = false;
2918
- saveAnnotations(pageNum);
2919
- }
2920
-
2921
- document.addEventListener('mousemove', onMove, { passive: false });
2922
- document.addEventListener('mouseup', onEnd);
2923
- document.addEventListener('touchmove', onMove, { passive: false });
2924
- document.addEventListener('touchend', onEnd);
2925
- document.addEventListener('touchcancel', onEnd);
2926
-
2927
- return true;
2928
- }
2929
-
2930
- return false;
2931
- }
2932
-
2933
- // moveAnnotation - applies delta movement to an annotation element
2934
- function moveAnnotation(element, dx, dy) {
2935
- if (element.tagName === 'path') {
2936
- // Transform path using translate
2937
- const currentTransform = element.getAttribute('transform') || '';
2938
- const match = currentTransform.match(/translate\(([^,]+),\s*([^)]+)\)/);
2939
- let tx = 0, ty = 0;
2940
- if (match) {
2941
- tx = parseFloat(match[1]);
2942
- ty = parseFloat(match[2]);
2943
- }
2944
- element.setAttribute('transform', `translate(${tx + dx}, ${ty + dy})`);
2945
- } else if (element.tagName === 'rect') {
2946
- element.setAttribute('x', parseFloat(element.getAttribute('x')) + dx);
2947
- element.setAttribute('y', parseFloat(element.getAttribute('y')) + dy);
2948
- } else if (element.tagName === 'ellipse') {
2949
- element.setAttribute('cx', parseFloat(element.getAttribute('cx')) + dx);
2950
- element.setAttribute('cy', parseFloat(element.getAttribute('cy')) + dy);
2951
- } else if (element.tagName === 'line') {
2952
- element.setAttribute('x1', parseFloat(element.getAttribute('x1')) + dx);
2953
- element.setAttribute('y1', parseFloat(element.getAttribute('y1')) + dy);
2954
- element.setAttribute('x2', parseFloat(element.getAttribute('x2')) + dx);
2955
- element.setAttribute('y2', parseFloat(element.getAttribute('y2')) + dy);
2956
- } else if (element.tagName === 'text') {
2957
- element.setAttribute('x', parseFloat(element.getAttribute('x')) + dx);
2958
- element.setAttribute('y', parseFloat(element.getAttribute('y')) + dy);
2959
- }
2960
- }
2961
-
2962
- // Legacy function for backwards compatibility (used elsewhere)
2963
- function handleSelectMouseDown(e, svg, pageNum) {
2964
- return handleSelectPointerDown(e, svg, pageNum);
2965
- }
2966
-
2967
- // ==========================================
2968
- // KEYBOARD SHORTCUTS
2969
- // ==========================================
2970
- document.addEventListener('keydown', (e) => {
2971
- // Ignore if typing in input
2972
- if (e.target.tagName === 'INPUT' || e.target.contentEditable === 'true') return;
2973
-
2974
- const key = e.key.toLowerCase();
2975
-
2976
- // Tool shortcuts
2977
- if (key === 'h') { setTool('highlight'); e.preventDefault(); }
2978
- if (key === 'p') { setTool('pen'); e.preventDefault(); }
2979
- if (key === 'e') { setTool('eraser'); e.preventDefault(); }
2980
- if (key === 't') { setTool('text'); e.preventDefault(); }
2981
- if (key === 'r') { setTool('shape'); e.preventDefault(); }
2982
- if (key === 'v') { setTool('select'); e.preventDefault(); }
2983
-
2984
- // Delete selected annotation
2985
- if ((key === 'delete' || key === 'backspace') && selectedAnnotation) {
2986
- deleteSelectedAnnotation();
2987
- e.preventDefault();
2988
- }
2989
-
2990
- // Copy/Paste annotations
2991
- if ((e.ctrlKey || e.metaKey) && key === 'c' && selectedAnnotation) {
2992
- copySelectedAnnotation();
2993
- e.preventDefault();
2994
- }
2995
- if ((e.ctrlKey || e.metaKey) && key === 'v' && copiedAnnotation) {
2996
- pasteAnnotation();
2997
- e.preventDefault();
2998
- }
2999
-
3000
- // Navigation
3001
- if (key === 's') {
3002
- document.getElementById('sidebarBtn').click();
3003
- e.preventDefault();
3004
- }
3005
-
3006
- // Arrow key navigation
3007
- if (key === 'arrowleft' || key === 'arrowup') {
3008
- if (pdfViewer && pdfViewer.currentPageNumber > 1) {
3009
- pdfViewer.currentPageNumber--;
3010
- }
3011
- e.preventDefault();
3012
- }
3013
- if (key === 'arrowright' || key === 'arrowdown') {
3014
- if (pdfViewer && pdfViewer.currentPageNumber < pdfViewer.pagesCount) {
3015
- pdfViewer.currentPageNumber++;
3016
- }
3017
- e.preventDefault();
3018
- }
3019
-
3020
- // Home/End
3021
- if (key === 'home') {
3022
- if (pdfViewer) pdfViewer.currentPageNumber = 1;
3023
- e.preventDefault();
3024
- }
3025
- if (key === 'end') {
3026
- if (pdfViewer) pdfViewer.currentPageNumber = pdfViewer.pagesCount;
3027
- e.preventDefault();
3028
- }
3029
-
3030
- // Zoom shortcuts - prevent browser zoom
3031
- if ((e.ctrlKey || e.metaKey) && (key === '=' || key === '+' || e.code === 'Equal')) {
3032
- e.preventDefault();
3033
- e.stopPropagation();
3034
- pdfViewer.currentScale += 0.25;
3035
- return;
3036
- }
3037
- if ((e.ctrlKey || e.metaKey) && (key === '-' || e.code === 'Minus')) {
3038
- e.preventDefault();
3039
- e.stopPropagation();
3040
- pdfViewer.currentScale -= 0.25;
3041
- return;
3042
- }
3043
- if ((e.ctrlKey || e.metaKey) && (key === '0' || e.code === 'Digit0')) {
3044
- e.preventDefault();
3045
- e.stopPropagation();
3046
- pdfViewer.currentScaleValue = 'page-width';
3047
- return;
3048
- }
3049
-
3050
- // Escape to deselect tool
3051
- if (key === 'escape') {
3052
- if (currentTool) {
3053
- setTool(currentTool); // Toggle off
3054
- }
3055
- closeAllDropdowns();
3056
- }
3057
-
3058
- // Sepia mode
3059
- if (key === 'm') {
3060
- document.getElementById('sepiaBtn').click();
3061
- e.preventDefault();
3062
- }
3063
- });
3064
-
3065
- // ==========================================
3066
- // CONTEXT MENU (Right-click)
3067
- // ==========================================
3068
- const contextMenu = document.createElement('div');
3069
- contextMenu.className = 'contextMenu';
3070
- contextMenu.innerHTML = `
3071
- <div class="contextMenuItem" data-action="highlight">
3072
- <svg viewBox="0 0 24 24"><path d="M3 21h18v-2H3v2zM5 16h14l-3-10H8l-3 10z"/></svg>
3073
- Vurgula
3074
- <span class="shortcutHint">H</span>
3075
- </div>
3076
- <div class="contextMenuItem" data-action="pen">
3077
- <svg viewBox="0 0 24 24"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg>
3078
- Kalem
3079
- <span class="shortcutHint">P</span>
3080
- </div>
3081
- <div class="contextMenuItem" data-action="text">
3082
- <svg viewBox="0 0 24 24"><path d="M5 4v3h5.5v12h3V7H19V4H5z"/></svg>
3083
- Metin Ekle
3084
- <span class="shortcutHint">T</span>
3085
- </div>
3086
- <div class="contextMenuDivider"></div>
3087
- <div class="contextMenuItem" data-action="zoomIn">
3088
- <svg viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
3089
- Yakınlaştır
3090
- <span class="shortcutHint">Ctrl++</span>
3091
- </div>
3092
- <div class="contextMenuItem" data-action="zoomOut">
3093
- <svg viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z"/></svg>
3094
- Uzaklaştır
3095
- <span class="shortcutHint">Ctrl+-</span>
3096
- </div>
3097
- <div class="contextMenuDivider"></div>
3098
- <div class="contextMenuItem" data-action="sepia">
3099
- <svg viewBox="0 0 24 24"><path d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"/></svg>
3100
- Okuma Modu
3101
- <span class="shortcutHint">M</span>
3102
- </div>
3103
- `;
3104
- document.body.appendChild(contextMenu);
3105
-
3106
- // Show context menu on right-click in viewer
3107
- container.addEventListener('contextmenu', (e) => {
3108
- e.preventDefault();
3109
- contextMenu.style.left = e.clientX + 'px';
3110
- contextMenu.style.top = e.clientY + 'px';
3111
- contextMenu.classList.add('visible');
3112
- });
3113
-
3114
- // Hide context menu on click
3115
- document.addEventListener('click', () => {
3116
- contextMenu.classList.remove('visible');
3117
- });
3118
-
3119
- // Context menu actions
3120
- contextMenu.addEventListener('click', (e) => {
3121
- const item = e.target.closest('.contextMenuItem');
3122
- if (!item) return;
3123
-
3124
- const action = item.dataset.action;
3125
- switch (action) {
3126
- case 'highlight': setTool('highlight'); break;
3127
- case 'pen': setTool('pen'); break;
3128
- case 'text': setTool('text'); break;
3129
- case 'zoomIn': pdfViewer.currentScale += 0.25; break;
3130
- case 'zoomOut': pdfViewer.currentScale -= 0.25; break;
3131
- case 'sepia': document.getElementById('sepiaBtn').click(); break;
3132
- }
3133
- contextMenu.classList.remove('visible');
3134
- });
3135
-
3136
- // ==========================================
3137
- // ERGONOMIC FEATURES
3138
- // ==========================================
3139
-
3140
- // Double-click on page for fullscreen
3141
- let lastClickTime = 0;
3142
- container.addEventListener('click', (e) => {
3143
- const now = Date.now();
3144
- if (now - lastClickTime < 300) {
3145
- // Double click detected
3146
- if (document.fullscreenElement) {
3147
- document.exitFullscreen();
3148
- } else {
3149
- container.requestFullscreen().catch(() => { });
3150
- }
3151
- }
3152
- lastClickTime = now;
3153
- });
3154
-
3155
- // Mouse wheel zoom with Ctrl
3156
- container.addEventListener('wheel', (e) => {
3157
- if (e.ctrlKey) {
3158
- e.preventDefault();
3159
- if (e.deltaY < 0) {
3160
- pdfViewer.currentScale += 0.1;
3161
- } else {
3162
- pdfViewer.currentScale -= 0.1;
3163
- }
3164
- }
3165
- }, { passive: false });
3166
-
3167
- console.log('PDF Viewer Ready');
3168
- console.log('Keyboard Shortcuts: H=Highlight, P=Pen, E=Eraser, T=Text, R=Shapes, S=Sidebar, M=ReadingMode, Arrows=Navigate');
3169
-
3170
- // ==========================================
3171
- // SECURITY FEATURES
3172
- // ==========================================
3173
-
3174
- (function initSecurityFeatures() {
3175
- console.log('[Security] Initializing protection features...');
3176
-
3177
- // 1. Block dangerous keyboard shortcuts
3178
- document.addEventListener('keydown', function (e) {
3179
- // Ctrl+S (Save)
3180
- if (e.ctrlKey && e.key === 's') {
3181
- e.preventDefault();
3182
- console.log('[Security] Ctrl+S blocked');
3183
- return false;
3184
- }
3185
- // Ctrl+P (Print)
3186
- if (e.ctrlKey && e.key === 'p') {
3187
- e.preventDefault();
3188
- console.log('[Security] Ctrl+P blocked');
3189
- return false;
3190
- }
3191
- // Ctrl+Shift+S (Save As)
3192
- if (e.ctrlKey && e.shiftKey && e.key === 'S') {
3193
- e.preventDefault();
3194
- return false;
3195
- }
3196
- // F12 (DevTools)
3197
- if (e.key === 'F12') {
3198
- e.preventDefault();
3199
- console.log('[Security] F12 blocked');
3200
- return false;
3201
- }
3202
- // Ctrl+Shift+I (DevTools)
3203
- if (e.ctrlKey && e.shiftKey && e.key === 'I') {
3204
- e.preventDefault();
3205
- return false;
3206
- }
3207
- // Ctrl+Shift+J (Console)
3208
- if (e.ctrlKey && e.shiftKey && e.key === 'J') {
3209
- e.preventDefault();
3210
- return false;
3211
- }
3212
- // Ctrl+U (View Source)
3213
- if (e.ctrlKey && e.key === 'u') {
3214
- e.preventDefault();
3215
- return false;
3216
- }
3217
- // Ctrl+Shift+C (Inspect Element)
3218
- if (e.ctrlKey && e.shiftKey && e.key === 'C') {
3219
- e.preventDefault();
3220
- return false;
3221
- }
3222
- }, true);
3223
-
3224
- // 2. Block context menu (right-click) - EVERYWHERE
3225
- document.addEventListener('contextmenu', function (e) {
3226
- e.preventDefault();
3227
- e.stopPropagation();
3228
- return false;
3229
- }, true);
3230
-
3231
- // 3. Block copy/cut/paste
3232
- document.addEventListener('copy', function (e) {
3233
- e.preventDefault();
3234
- console.log('[Security] Copy blocked');
3235
- return false;
3236
- }, true);
3237
-
3238
- document.addEventListener('cut', function (e) {
3239
- e.preventDefault();
3240
- return false;
3241
- }, true);
3242
-
3243
- // 4. Block drag events (prevent dragging content out)
3244
- document.addEventListener('dragstart', function (e) {
3245
- e.preventDefault();
3246
- return false;
3247
- }, true);
3248
-
3249
- // 5. Block Print via window.print override
3250
- window.print = function () {
3251
- console.log('[Security] Print function blocked');
3252
- alert('Yazdırma bu belgede engellenmiştir.');
3253
- return false;
3254
- };
3255
-
3256
- // 6. Disable beforeprint event
3257
- window.addEventListener('beforeprint', function (e) {
3258
- e.preventDefault();
3259
- document.body.style.display = 'none';
3260
- });
3261
-
3262
- window.addEventListener('afterprint', function () {
3263
- document.body.style.display = '';
3264
- });
3265
-
3266
- // 7. Block screenshot keyboard shortcuts
3267
- document.addEventListener('keyup', function (e) {
3268
- // PrintScreen key
3269
- if (e.key === 'PrintScreen') {
3270
- navigator.clipboard.writeText('');
3271
- console.log('[Security] PrintScreen clipboard cleared');
3272
- }
3273
- }, true);
3274
-
3275
- // 8. Visibility change detection (tab switching for screenshots)
3276
- document.addEventListener('visibilitychange', function () {
3277
- if (document.hidden) {
3278
- console.log('[Security] Tab hidden');
3279
- }
3280
- });
3281
-
3282
- console.log('[Security] All protection features initialized');
3283
- })();
3284
-
3285
- // End of main IIFE - pdfDoc, pdfViewer not accessible from console
3286
- })();
3287
- </script>
370
+ <script defer src="viewer-app.js"></script>
3288
371
  </body>
3289
372
 
3290
- </html>
373
+ </html>