@epam/pdf-highlighter-kit 0.0.1

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.
Files changed (77) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +219 -0
  3. package/dist/PDFHighlightViewer.d.ts +219 -0
  4. package/dist/PDFHighlightViewer.d.ts.map +1 -0
  5. package/dist/PDFHighlightViewer.js +1551 -0
  6. package/dist/PDFHighlightViewer.js.map +1 -0
  7. package/dist/api.d.ts +59 -0
  8. package/dist/api.d.ts.map +1 -0
  9. package/dist/api.js +2 -0
  10. package/dist/api.js.map +1 -0
  11. package/dist/config.d.ts +12 -0
  12. package/dist/config.d.ts.map +1 -0
  13. package/dist/config.js +32 -0
  14. package/dist/config.js.map +1 -0
  15. package/dist/core/interaction-handler.d.ts +63 -0
  16. package/dist/core/interaction-handler.d.ts.map +1 -0
  17. package/dist/core/interaction-handler.js +430 -0
  18. package/dist/core/interaction-handler.js.map +1 -0
  19. package/dist/core/pdf-engine.d.ts +37 -0
  20. package/dist/core/pdf-engine.d.ts.map +1 -0
  21. package/dist/core/pdf-engine.js +281 -0
  22. package/dist/core/pdf-engine.js.map +1 -0
  23. package/dist/core/performance-optimizer.d.ts +91 -0
  24. package/dist/core/performance-optimizer.d.ts.map +1 -0
  25. package/dist/core/performance-optimizer.js +473 -0
  26. package/dist/core/performance-optimizer.js.map +1 -0
  27. package/dist/core/style-manager.d.ts +88 -0
  28. package/dist/core/style-manager.d.ts.map +1 -0
  29. package/dist/core/style-manager.js +413 -0
  30. package/dist/core/style-manager.js.map +1 -0
  31. package/dist/core/text-segmentation.d.ts +41 -0
  32. package/dist/core/text-segmentation.d.ts.map +1 -0
  33. package/dist/core/text-segmentation.js +338 -0
  34. package/dist/core/text-segmentation.js.map +1 -0
  35. package/dist/core/unified-layer-builder.d.ts +27 -0
  36. package/dist/core/unified-layer-builder.d.ts.map +1 -0
  37. package/dist/core/unified-layer-builder.js +331 -0
  38. package/dist/core/unified-layer-builder.js.map +1 -0
  39. package/dist/core/viewport-manager.d.ts +103 -0
  40. package/dist/core/viewport-manager.d.ts.map +1 -0
  41. package/dist/core/viewport-manager.js +222 -0
  42. package/dist/core/viewport-manager.js.map +1 -0
  43. package/dist/index.d.ts +27 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +57 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/pdf-highlight-viewer.css +488 -0
  48. package/dist/types.d.ts +279 -0
  49. package/dist/types.d.ts.map +1 -0
  50. package/dist/types.js +2 -0
  51. package/dist/types.js.map +1 -0
  52. package/dist/utils/highlight-adapter.d.ts +31 -0
  53. package/dist/utils/highlight-adapter.d.ts.map +1 -0
  54. package/dist/utils/highlight-adapter.js +202 -0
  55. package/dist/utils/highlight-adapter.js.map +1 -0
  56. package/dist/utils/pdf-utils.d.ts +14 -0
  57. package/dist/utils/pdf-utils.d.ts.map +1 -0
  58. package/dist/utils/pdf-utils.js +120 -0
  59. package/dist/utils/pdf-utils.js.map +1 -0
  60. package/dist/utils/worker-loader-simple.d.ts +8 -0
  61. package/dist/utils/worker-loader-simple.d.ts.map +1 -0
  62. package/dist/utils/worker-loader-simple.js +65 -0
  63. package/dist/utils/worker-loader-simple.js.map +1 -0
  64. package/dist/vite.config.d.ts +3 -0
  65. package/dist/vite.config.d.ts.map +1 -0
  66. package/dist/vite.config.js +20 -0
  67. package/dist/vite.config.js.map +1 -0
  68. package/dist/vitest.config.d.ts +3 -0
  69. package/dist/vitest.config.d.ts.map +1 -0
  70. package/dist/vitest.config.js +24 -0
  71. package/dist/vitest.config.js.map +1 -0
  72. package/dist/vitest.setup.d.ts +2 -0
  73. package/dist/vitest.setup.d.ts.map +1 -0
  74. package/dist/vitest.setup.js +8 -0
  75. package/dist/vitest.setup.js.map +1 -0
  76. package/package.json +74 -0
  77. package/styles/pdf-highlight-viewer.css +488 -0
@@ -0,0 +1,488 @@
1
+ .pdf-highlight-viewer {
2
+ position: relative;
3
+ width: 100%;
4
+ height: 100%;
5
+ overflow: auto;
6
+ background: #f5f5f5;
7
+ contain: layout style paint;
8
+ }
9
+
10
+ .pdf-container {
11
+ position: relative;
12
+ margin: 0 auto;
13
+ padding: 20px;
14
+ contain: layout style paint;
15
+ }
16
+
17
+ .pdf-page-container {
18
+ position: relative;
19
+ margin: 0 auto 20px;
20
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
21
+ background: white;
22
+ contain: layout style paint;
23
+ }
24
+
25
+ .pdf-canvas {
26
+ position: relative;
27
+ z-index: 1;
28
+ display: block;
29
+ width: 100%;
30
+ height: auto;
31
+ user-select: none;
32
+ }
33
+
34
+ .unified-layer {
35
+ position: absolute;
36
+ top: 0;
37
+ left: 0;
38
+ width: 100%;
39
+ height: 100%;
40
+ z-index: 2;
41
+ pointer-events: none;
42
+ opacity: 0.01;
43
+ contain: layout style;
44
+ }
45
+
46
+ .unified-layer .text-segment,
47
+ .unified-layer .highlight-wrapper {
48
+ pointer-events: auto;
49
+ }
50
+
51
+ .text-segment {
52
+ position: absolute;
53
+ white-space: pre;
54
+ transform-origin: 0% 0%;
55
+ user-select: text;
56
+ color: transparent;
57
+ line-height: 1;
58
+ margin: 0;
59
+ padding: 0;
60
+ border: none;
61
+ outline: none;
62
+ background: none;
63
+ }
64
+
65
+ .text-segment.selectable {
66
+ cursor: text;
67
+ }
68
+
69
+ .highlight-wrapper {
70
+ position: absolute;
71
+ cursor: pointer;
72
+ transform-origin: 0% 0%;
73
+ transition: opacity 0.2s ease;
74
+ contain: layout style;
75
+ }
76
+
77
+ .highlight-wrapper:hover {
78
+ z-index: 3;
79
+ }
80
+
81
+ .highlight-background {
82
+ position: absolute;
83
+ inset: -2px;
84
+ z-index: -1;
85
+ border-radius: 3px;
86
+ transition:
87
+ opacity 0.2s ease,
88
+ transform 0.2s ease;
89
+ will-change: opacity, transform;
90
+ }
91
+
92
+ .highlight-wrapper:hover .highlight-background {
93
+ transform: scale(1.02);
94
+ }
95
+
96
+ .protein-highlight .highlight-background {
97
+ background: rgba(255, 200, 0, 0.3);
98
+ border: 1px solid rgba(255, 180, 0, 0.6);
99
+ }
100
+
101
+ .protein-highlight:hover .highlight-background {
102
+ background: rgba(255, 200, 0, 0.5);
103
+ border-color: rgba(255, 160, 0, 0.8);
104
+ }
105
+
106
+ .protein-highlight.selected .highlight-background {
107
+ background: rgba(255, 200, 0, 0.7);
108
+ border: 2px solid rgba(255, 140, 0, 1);
109
+ outline: 2px solid #007acc;
110
+ outline-offset: 1px;
111
+ }
112
+
113
+ .gene-highlight .highlight-background {
114
+ background: rgba(0, 200, 100, 0.3);
115
+ border: 1px solid rgba(0, 180, 90, 0.6);
116
+ }
117
+
118
+ .gene-highlight:hover .highlight-background {
119
+ background: rgba(0, 200, 100, 0.5);
120
+ border-color: rgba(0, 160, 80, 0.8);
121
+ }
122
+
123
+ .gene-highlight.selected .highlight-background {
124
+ background: rgba(0, 200, 100, 0.7);
125
+ border: 2px solid rgba(0, 140, 70, 1);
126
+ outline: 2px solid #007acc;
127
+ outline-offset: 1px;
128
+ }
129
+
130
+ .disease-highlight .highlight-background {
131
+ background: rgba(220, 50, 50, 0.3);
132
+ border: 1px solid rgba(200, 40, 40, 0.6);
133
+ }
134
+
135
+ .disease-highlight:hover .highlight-background {
136
+ background: rgba(220, 50, 50, 0.5);
137
+ border-color: rgba(180, 30, 30, 0.8);
138
+ }
139
+
140
+ .disease-highlight.selected .highlight-background {
141
+ background: rgba(220, 50, 50, 0.7);
142
+ border: 2px solid rgba(160, 20, 20, 1);
143
+ outline: 2px solid #007acc;
144
+ outline-offset: 1px;
145
+ }
146
+
147
+ .chemical-highlight .highlight-background {
148
+ background: rgba(0, 150, 255, 0.3);
149
+ border: 1px solid rgba(0, 130, 235, 0.6);
150
+ }
151
+
152
+ .chemical-highlight:hover .highlight-background {
153
+ background: rgba(0, 150, 255, 0.5);
154
+ border-color: rgba(0, 110, 215, 0.8);
155
+ }
156
+
157
+ .chemical-highlight.selected .highlight-background {
158
+ background: rgba(0, 150, 255, 0.7);
159
+ border: 2px solid rgba(0, 90, 195, 1);
160
+ outline: 2px solid #007acc;
161
+ outline-offset: 1px;
162
+ }
163
+
164
+ .species-highlight .highlight-background {
165
+ background: rgba(150, 100, 200, 0.3);
166
+ border: 1px solid rgba(130, 80, 180, 0.6);
167
+ }
168
+
169
+ .species-highlight:hover .highlight-background {
170
+ background: rgba(150, 100, 200, 0.5);
171
+ border-color: rgba(110, 60, 160, 0.8);
172
+ }
173
+
174
+ .species-highlight.selected .highlight-background {
175
+ background: rgba(150, 100, 200, 0.7);
176
+ border: 2px solid rgba(90, 40, 140, 1);
177
+ outline: 2px solid #007acc;
178
+ outline-offset: 1px;
179
+ }
180
+
181
+ .pdf-highlight-viewer.scrolling .unified-layer {
182
+ will-change: transform;
183
+ }
184
+
185
+ .pdf-highlight-viewer.scrolling .highlight-background {
186
+ transition: none;
187
+ }
188
+
189
+ .highlight-background {
190
+ transform: translateZ(0);
191
+ backface-visibility: hidden;
192
+ }
193
+
194
+ .highlight-wrapper {
195
+ contain: layout style paint;
196
+ }
197
+
198
+ .text-segment::selection {
199
+ background: rgba(0, 123, 255, 0.3);
200
+ color: transparent;
201
+ }
202
+
203
+ .text-segment::-moz-selection {
204
+ background: rgba(0, 123, 255, 0.3);
205
+ color: transparent;
206
+ }
207
+
208
+ .highlight-wrapper .text-segment::selection {
209
+ background: rgba(255, 255, 255, 0.5);
210
+ color: transparent;
211
+ }
212
+
213
+ .highlight-wrapper .text-segment::-moz-selection {
214
+ background: rgba(255, 255, 255, 0.5);
215
+ color: transparent;
216
+ }
217
+
218
+ .pdf-page-container.loading {
219
+ opacity: 0.7;
220
+ }
221
+
222
+ .pdf-page-container.loading::after {
223
+ content: '';
224
+ position: absolute;
225
+ top: 50%;
226
+ left: 50%;
227
+ width: 32px;
228
+ height: 32px;
229
+ margin: -16px 0 0 -16px;
230
+ border: 3px solid #f3f3f3;
231
+ border-top: 3px solid #007acc;
232
+ border-radius: 50%;
233
+ animation: spin 1s linear infinite;
234
+ }
235
+
236
+ @keyframes spin {
237
+ 0% {
238
+ transform: rotate(0deg);
239
+ }
240
+ 100% {
241
+ transform: rotate(360deg);
242
+ }
243
+ }
244
+
245
+ .search-result-highlight .highlight-background {
246
+ background: rgba(255, 255, 0, 0.4) !important;
247
+ border: 2px solid rgba(255, 215, 0, 0.8) !important;
248
+ animation: pulse-search 1s ease-in-out infinite alternate;
249
+ }
250
+
251
+ @keyframes pulse-search {
252
+ from {
253
+ opacity: 0.4;
254
+ }
255
+ to {
256
+ opacity: 0.8;
257
+ }
258
+ }
259
+
260
+ @media (prefers-contrast: high) {
261
+ .highlight-background {
262
+ border-width: 2px !important;
263
+ opacity: 0.8 !important;
264
+ }
265
+
266
+ .protein-highlight .highlight-background {
267
+ background: rgba(255, 200, 0, 0.6);
268
+ border-color: rgba(255, 140, 0, 1);
269
+ }
270
+
271
+ .gene-highlight .highlight-background {
272
+ background: rgba(0, 200, 100, 0.6);
273
+ border-color: rgba(0, 140, 70, 1);
274
+ }
275
+
276
+ .disease-highlight .highlight-background {
277
+ background: rgba(220, 50, 50, 0.6);
278
+ border-color: rgba(160, 20, 20, 1);
279
+ }
280
+
281
+ .chemical-highlight .highlight-background {
282
+ background: rgba(0, 150, 255, 0.6);
283
+ border-color: rgba(0, 90, 195, 1);
284
+ }
285
+
286
+ .species-highlight .highlight-background {
287
+ background: rgba(150, 100, 200, 0.6);
288
+ border-color: rgba(90, 40, 140, 1);
289
+ }
290
+ }
291
+
292
+ @media (prefers-reduced-motion: reduce) {
293
+ .highlight-background,
294
+ .highlight-wrapper {
295
+ transition: none !important;
296
+ animation: none !important;
297
+ }
298
+ }
299
+
300
+ .highlight-wrapper:focus {
301
+ outline: 2px solid #007acc;
302
+ outline-offset: 2px;
303
+ }
304
+
305
+ .highlight-wrapper:focus .highlight-background {
306
+ opacity: 0.8;
307
+ transform: scale(1.05);
308
+ }
309
+
310
+ .pdf-context-menu {
311
+ position: fixed;
312
+ background: white;
313
+ border: 1px solid #ccc;
314
+ border-radius: 4px;
315
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
316
+ z-index: 1000;
317
+ min-width: 180px;
318
+ padding: 4px 0;
319
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
320
+ font-size: 14px;
321
+ }
322
+
323
+ .pdf-context-menu-item {
324
+ padding: 8px 16px;
325
+ cursor: pointer;
326
+ border: none;
327
+ background: none;
328
+ width: 100%;
329
+ text-align: left;
330
+ color: #333;
331
+ }
332
+
333
+ .pdf-context-menu-item:hover {
334
+ background: #f0f0f0;
335
+ }
336
+
337
+ .pdf-context-menu-item:disabled {
338
+ color: #999;
339
+ cursor: not-allowed;
340
+ }
341
+
342
+ .pdf-context-menu-separator {
343
+ height: 1px;
344
+ background: #eee;
345
+ margin: 4px 0;
346
+ }
347
+
348
+ .pdf-tooltip {
349
+ position: fixed;
350
+ background: rgba(0, 0, 0, 0.8);
351
+ color: white;
352
+ padding: 8px 12px;
353
+ border-radius: 4px;
354
+ font-size: 12px;
355
+ z-index: 1001;
356
+ pointer-events: none;
357
+ max-width: 300px;
358
+ word-wrap: break-word;
359
+ }
360
+
361
+ .pdf-tooltip::after {
362
+ content: '';
363
+ position: absolute;
364
+ top: 100%;
365
+ left: 50%;
366
+ margin-left: -5px;
367
+ width: 0;
368
+ height: 0;
369
+ border: 5px solid transparent;
370
+ border-top-color: rgba(0, 0, 0, 0.8);
371
+ }
372
+
373
+ @media (max-width: 768px) {
374
+ .pdf-container {
375
+ padding: 10px;
376
+ }
377
+
378
+ .pdf-page-container {
379
+ margin-bottom: 10px;
380
+ }
381
+
382
+ .highlight-wrapper {
383
+ min-width: 44px;
384
+ min-height: 44px;
385
+ }
386
+
387
+ .pdf-context-menu {
388
+ min-width: 200px;
389
+ font-size: 16px;
390
+ }
391
+
392
+ .pdf-context-menu-item {
393
+ padding: 12px 16px;
394
+ }
395
+ }
396
+
397
+ @media print {
398
+ .pdf-highlight-viewer {
399
+ background: white;
400
+ }
401
+
402
+ .pdf-page-container {
403
+ box-shadow: none;
404
+ margin-bottom: 0;
405
+ page-break-after: always;
406
+ }
407
+
408
+ .highlight-background {
409
+ opacity: 0.6 !important;
410
+ transition: none;
411
+ }
412
+
413
+ .pdf-context-menu,
414
+ .pdf-tooltip {
415
+ display: none !important;
416
+ }
417
+ }
418
+
419
+ @media (prefers-color-scheme: dark) {
420
+ .pdf-highlight-viewer {
421
+ background: #1a1a1a;
422
+ }
423
+
424
+ .pdf-page-container {
425
+ background: #2a2a2a;
426
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
427
+ }
428
+
429
+ .pdf-context-menu {
430
+ background: #333;
431
+ border-color: #555;
432
+ color: white;
433
+ }
434
+
435
+ .pdf-context-menu-item {
436
+ color: white;
437
+ }
438
+
439
+ .pdf-context-menu-item:hover {
440
+ background: #555;
441
+ }
442
+
443
+ .pdf-context-menu-separator {
444
+ background: #555;
445
+ }
446
+ }
447
+
448
+ .highlight-enter {
449
+ opacity: 0;
450
+ transform: scale(0.8);
451
+ }
452
+
453
+ .highlight-enter-active {
454
+ opacity: 1;
455
+ transform: scale(1);
456
+ transition:
457
+ opacity 0.3s ease,
458
+ transform 0.3s ease;
459
+ }
460
+
461
+ .highlight-exit {
462
+ opacity: 1;
463
+ transform: scale(1);
464
+ }
465
+
466
+ .highlight-exit-active {
467
+ opacity: 0;
468
+ transform: scale(0.8);
469
+ transition:
470
+ opacity 0.3s ease,
471
+ transform 0.3s ease;
472
+ }
473
+
474
+ .pdf-hidden {
475
+ display: none !important;
476
+ }
477
+
478
+ .pdf-invisible {
479
+ visibility: hidden !important;
480
+ }
481
+
482
+ .pdf-no-select {
483
+ user-select: none !important;
484
+ }
485
+
486
+ .pdf-no-pointer-events {
487
+ pointer-events: none !important;
488
+ }