omni-viewer-core 0.5.0 → 0.7.0
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.
- package/README.md +21 -1
- package/dist/i18n/catalog.en.js +13 -0
- package/dist/i18n/catalog.ja.js +13 -1
- package/dist/i18n/catalog.ko.js +13 -0
- package/dist/i18n/catalog.zh-cn.js +10 -0
- package/dist/parsers/safetensors/index.d.ts +56 -0
- package/dist/parsers/safetensors/index.js +294 -0
- package/dist/parsers/safetensors/node.d.ts +13 -0
- package/dist/parsers/safetensors/node.js +52 -0
- package/dist/parsers/toml/model.d.ts +10 -0
- package/dist/parsers/toml/parse.js +104 -34
- package/dist/registry/index.d.ts +1 -0
- package/dist/registry/index.js +5 -1
- package/dist/styles/pdf.css +177 -0
- package/dist/styles/safetensors.css +3 -0
- package/dist/styles/toml.css +1 -1
- package/dist/styles/yaml.css +1 -1
- package/dist/viewers/pdf/controller.d.ts +8 -0
- package/dist/viewers/pdf/controller.js +4 -0
- package/dist/viewers/pdf/editing.d.ts +11 -0
- package/dist/viewers/pdf/editing.js +19 -16
- package/dist/viewers/pdf/index.d.ts +3 -2
- package/dist/viewers/pdf/index.js +195 -23
- package/dist/viewers/pdf/styles.d.ts +1 -1
- package/dist/viewers/pdf/styles.js +177 -0
- package/dist/viewers/safetensors/index.d.ts +27 -0
- package/dist/viewers/safetensors/index.js +198 -0
- package/dist/viewers/safetensors/styles.d.ts +1 -0
- package/dist/viewers/safetensors/styles.js +4 -0
- package/dist/viewers/structured-styles.d.ts +1 -1
- package/dist/viewers/structured-styles.js +1 -1
- package/dist/viewers/structured.d.ts +15 -0
- package/dist/viewers/structured.js +196 -47
- package/dist/viewers/toml/controller.d.ts +27 -1
- package/dist/viewers/toml/controller.js +64 -10
- package/package.json +13 -1
|
@@ -24,6 +24,17 @@ function parseColor(pdfLib, value) {
|
|
|
24
24
|
const hex = /^#?([0-9a-f]{6})$/i.exec(value)?.[1] ?? '000000';
|
|
25
25
|
return pdfLib.rgb(parseInt(hex.slice(0, 2), 16) / 255, parseInt(hex.slice(2, 4), 16) / 255, parseInt(hex.slice(4, 6), 16) / 255);
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* PDF-space Y for a strike-through / underline drawn over a text rect.
|
|
29
|
+
* `rect.y` is the box top measured from the page top (top-left origin, as the
|
|
30
|
+
* DOM reports it); PDF space has a bottom-left origin, so we flip through the
|
|
31
|
+
* page height. Strikeout sits at the vertical middle; underline sits just above
|
|
32
|
+
* the bottom edge to mirror the on-screen `bottom: 8%` rendering.
|
|
33
|
+
*/
|
|
34
|
+
export function markupLineY(kind, rect, pageHeight) {
|
|
35
|
+
const fromTop = kind === 'strikeout' ? rect.height * 0.5 : rect.height * 0.9;
|
|
36
|
+
return pageHeight - rect.y - fromTop;
|
|
37
|
+
}
|
|
27
38
|
function pngBytes(dataUrl) {
|
|
28
39
|
const encoded = /^data:image\/png;base64,(.*)$/i.exec(dataUrl)?.[1];
|
|
29
40
|
if (!encoded)
|
|
@@ -72,24 +83,13 @@ async function stamp(pdfLib, page, annotation) {
|
|
|
72
83
|
}
|
|
73
84
|
return;
|
|
74
85
|
}
|
|
75
|
-
if (annotation.kind === 'strikeout') {
|
|
76
|
-
const color = parseColor(pdfLib, annotation.color);
|
|
77
|
-
for (const rect of mergeHighlightRects(annotation.rects)) {
|
|
78
|
-
page.drawLine({
|
|
79
|
-
start: { x: rect.x, y: height - rect.y - rect.height / 2 },
|
|
80
|
-
end: { x: rect.x + rect.width, y: height - rect.y - rect.height / 2 },
|
|
81
|
-
thickness: Math.max(1, rect.height * 0.08),
|
|
82
|
-
color
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (annotation.kind === 'underline') {
|
|
86
|
+
if (annotation.kind === 'strikeout' || annotation.kind === 'underline') {
|
|
88
87
|
const color = parseColor(pdfLib, annotation.color);
|
|
89
88
|
for (const rect of mergeHighlightRects(annotation.rects)) {
|
|
89
|
+
const y = markupLineY(annotation.kind, rect, height);
|
|
90
90
|
page.drawLine({
|
|
91
|
-
start: { x: rect.x, y
|
|
92
|
-
end: { x: rect.x + rect.width, y
|
|
91
|
+
start: { x: rect.x, y },
|
|
92
|
+
end: { x: rect.x + rect.width, y },
|
|
93
93
|
thickness: Math.max(1, rect.height * 0.08),
|
|
94
94
|
color
|
|
95
95
|
});
|
|
@@ -239,7 +239,10 @@ function toAnnotation(raw) {
|
|
|
239
239
|
}
|
|
240
240
|
if (rects.length === 0)
|
|
241
241
|
return null;
|
|
242
|
-
return {
|
|
242
|
+
return {
|
|
243
|
+
id: a.id, kind: a.kind, page: a.page, rects, color: a.color,
|
|
244
|
+
...(typeof a.text === 'string' && a.text.length <= MAX_TEXT_LENGTH ? { text: a.text } : {})
|
|
245
|
+
};
|
|
243
246
|
}
|
|
244
247
|
return null;
|
|
245
248
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FilePickService, FileSaveResult, FileSaveService, FileWritebackService, HostContext } from '../../host/index.js';
|
|
1
|
+
import type { ClipboardService, FilePickService, FileSaveResult, FileSaveService, FileWritebackService, HostContext } from '../../host/index.js';
|
|
2
2
|
import { type MountOptions, type ViewerHandle, type ViewerInput } from '../types.js';
|
|
3
3
|
import { type PdfController, type PdfControllerOptions, type PdfViewState } from './controller.js';
|
|
4
4
|
import { type PdfLibModule } from './editing.js';
|
|
@@ -75,10 +75,11 @@ export declare const PDF_VIEWER_META: {
|
|
|
75
75
|
extensions: string[];
|
|
76
76
|
priority: number;
|
|
77
77
|
requiredServices: readonly [];
|
|
78
|
-
optionalServices: readonly ["save", "writeback", "filePick"];
|
|
78
|
+
optionalServices: readonly ["save", "writeback", "filePick", "clipboard"];
|
|
79
79
|
inputOwnership: "borrows";
|
|
80
80
|
};
|
|
81
81
|
export type PdfViewerContext = HostContext & {
|
|
82
|
+
clipboard?: ClipboardService;
|
|
82
83
|
save?: FileSaveService;
|
|
83
84
|
writeback?: FileWritebackService;
|
|
84
85
|
filePick?: FilePickService;
|
|
@@ -25,7 +25,7 @@ export const PDF_VIEWER_META = {
|
|
|
25
25
|
extensions: ['pdf'],
|
|
26
26
|
priority: 20,
|
|
27
27
|
requiredServices: [],
|
|
28
|
-
optionalServices: ['save', 'writeback', 'filePick'],
|
|
28
|
+
optionalServices: ['save', 'writeback', 'filePick', 'clipboard'],
|
|
29
29
|
inputOwnership: 'borrows'
|
|
30
30
|
};
|
|
31
31
|
const THUMB_FALLBACK_RENDER_COUNT = 10;
|
|
@@ -85,7 +85,11 @@ export async function mountPdfViewer(input, container, ctx, deps, options = {})
|
|
|
85
85
|
const body = el('div', 'omni-pdf__body');
|
|
86
86
|
const thumbs = el('div', 'omni-pdf__thumbs');
|
|
87
87
|
const pages = el('div', 'omni-pdf__pages');
|
|
88
|
-
|
|
88
|
+
// Left overlay panel listing every text-markup annotation. Absolutely
|
|
89
|
+
// positioned, so it does not claim a grid track when hidden or shown.
|
|
90
|
+
const markupList = el('div', 'omni-pdf__markup-list');
|
|
91
|
+
markupList.setAttribute('aria-label', t('pdf.markupList'));
|
|
92
|
+
body.append(thumbs, pages, markupList);
|
|
89
93
|
const status = el('div', 'omni-pdf__status', t('pdf.loading'));
|
|
90
94
|
status.setAttribute('aria-live', 'polite');
|
|
91
95
|
frame.append(header, zoomBar, body, status);
|
|
@@ -109,6 +113,9 @@ export async function mountPdfViewer(input, container, ctx, deps, options = {})
|
|
|
109
113
|
let markupKind = 'highlight';
|
|
110
114
|
let pageLayout = 'single';
|
|
111
115
|
let matchThemeColors = false;
|
|
116
|
+
let markupListOpen = false;
|
|
117
|
+
/** Swatches offered by the markup toolbar's colour control. */
|
|
118
|
+
const MARKUP_COLORS = ['#ffeb3b', '#ffc9c9', '#b2f2bb', '#a5d8ff', '#ffd8a8', '#000000'];
|
|
112
119
|
let sourceBytes = input.data;
|
|
113
120
|
const saveMode = options.saveMode ?? 'hybrid';
|
|
114
121
|
const processingMode = options.processingMode ?? 'auto';
|
|
@@ -142,7 +149,6 @@ export async function mountPdfViewer(input, container, ctx, deps, options = {})
|
|
|
142
149
|
function teardown() {
|
|
143
150
|
disposed = true;
|
|
144
151
|
document.removeEventListener('keydown', keyHandler);
|
|
145
|
-
document.removeEventListener('selectionchange', syncMarkupAvailability);
|
|
146
152
|
options.signal?.removeEventListener('abort', abortListener);
|
|
147
153
|
operationController?.abort();
|
|
148
154
|
operationController = undefined;
|
|
@@ -460,23 +466,19 @@ export async function mountPdfViewer(input, container, ctx, deps, options = {})
|
|
|
460
466
|
degrade(mergeBtn, 'pdf.noFilePick');
|
|
461
467
|
else if (!mergeAvailable)
|
|
462
468
|
degrade(mergeBtn, 'pdf.editingUnavailable');
|
|
463
|
-
|
|
464
|
-
|
|
469
|
+
// Markup buttons stay enabled at all times; the toolbar just picks which
|
|
470
|
+
// kind is active. Finishing a text selection applies it straight away.
|
|
471
|
+
function autoApplyMarkup() {
|
|
472
|
+
if (!editingAvailable || tool !== 'view')
|
|
465
473
|
return;
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
underlineBtn.disabled = !enabled;
|
|
471
|
-
strikeoutBtn.disabled = !enabled;
|
|
472
|
-
if (!enabled) {
|
|
473
|
-
markupMenu.classList.remove('is-open');
|
|
474
|
-
markupMenuBtn.setAttribute('aria-expanded', 'false');
|
|
475
|
-
}
|
|
474
|
+
if (!activeSelection())
|
|
475
|
+
return;
|
|
476
|
+
if (captureMarkup(markupKind))
|
|
477
|
+
status.textContent = '';
|
|
476
478
|
}
|
|
477
|
-
|
|
478
|
-
pages.addEventListener('mouseup',
|
|
479
|
-
|
|
479
|
+
const scheduleAutoApply = () => requestAnimationFrame(autoApplyMarkup);
|
|
480
|
+
pages.addEventListener('mouseup', scheduleAutoApply);
|
|
481
|
+
pages.addEventListener('touchend', scheduleAutoApply);
|
|
480
482
|
const zoomOutBtn = el('button', 'omni-pdf__zoom-btn', '−');
|
|
481
483
|
zoomOutBtn.type = 'button';
|
|
482
484
|
zoomOutBtn.setAttribute('aria-label', t('pdf.zoomOut'));
|
|
@@ -487,6 +489,48 @@ export async function mountPdfViewer(input, container, ctx, deps, options = {})
|
|
|
487
489
|
zoomInBtn.type = 'button';
|
|
488
490
|
zoomInBtn.setAttribute('aria-label', t('pdf.zoomIn'));
|
|
489
491
|
zoomInBtn.addEventListener('click', () => controller.dispatch({ type: 'zoom-in' }));
|
|
492
|
+
// Trackpad pinch (two-finger spread/close) reaches the page as a wheel event
|
|
493
|
+
// with `ctrlKey` set. Turn it into a continuous zoom instead of letting the
|
|
494
|
+
// browser zoom the whole document. Updates are coalesced to one per frame so
|
|
495
|
+
// a burst of wheel events triggers a single re-layout.
|
|
496
|
+
let pendingPinchZoom = null;
|
|
497
|
+
let pinchFrame = 0;
|
|
498
|
+
const onPinchZoom = (event) => {
|
|
499
|
+
if (!event.ctrlKey)
|
|
500
|
+
return;
|
|
501
|
+
event.preventDefault();
|
|
502
|
+
const base = pendingPinchZoom ?? controller.state.zoom;
|
|
503
|
+
// deltaY < 0 is a spread (zoom in); scale exponentially so the step feels
|
|
504
|
+
// even across the whole range.
|
|
505
|
+
const next = base * Math.exp(-event.deltaY * 0.01);
|
|
506
|
+
pendingPinchZoom = Math.max(controller.minZoom, Math.min(controller.maxZoom, next));
|
|
507
|
+
if (pinchFrame)
|
|
508
|
+
return;
|
|
509
|
+
pinchFrame = requestAnimationFrame(() => {
|
|
510
|
+
pinchFrame = 0;
|
|
511
|
+
const zoom = pendingPinchZoom;
|
|
512
|
+
pendingPinchZoom = null;
|
|
513
|
+
if (zoom != null)
|
|
514
|
+
controller.dispatch({ type: 'set-zoom', zoom });
|
|
515
|
+
});
|
|
516
|
+
};
|
|
517
|
+
pages.addEventListener('wheel', onPinchZoom, { passive: false });
|
|
518
|
+
customActionCleanups.push(() => {
|
|
519
|
+
pages.removeEventListener('wheel', onPinchZoom);
|
|
520
|
+
if (pinchFrame)
|
|
521
|
+
cancelAnimationFrame(pinchFrame);
|
|
522
|
+
});
|
|
523
|
+
// Clicking anywhere outside a markup box or its toolbar clears the selection
|
|
524
|
+
// so the floating toolbar goes away (page margins, gaps between pages, …).
|
|
525
|
+
pages.addEventListener('pointerdown', (event) => {
|
|
526
|
+
const target = event.target;
|
|
527
|
+
if (target instanceof Element
|
|
528
|
+
&& target.closest('.omni-pdf__annotation, .omni-pdf__markup-toolbar'))
|
|
529
|
+
return;
|
|
530
|
+
if (controller.state.selectedAnnotationId) {
|
|
531
|
+
controller.dispatch({ type: 'select-annotation', id: null });
|
|
532
|
+
}
|
|
533
|
+
});
|
|
490
534
|
const viewMenuWrap = el('div', 'omni-pdf__view-menu-wrap');
|
|
491
535
|
const viewMenuBtn = el('button', 'omni-pdf__view-menu-btn', '⌄');
|
|
492
536
|
viewMenuBtn.type = 'button';
|
|
@@ -509,7 +553,18 @@ export async function mountPdfViewer(input, container, ctx, deps, options = {})
|
|
|
509
553
|
}
|
|
510
554
|
viewMenu.append(fitWidthBtn, fitHeightBtn, separator, singlePageBtn, spreadOddBtn, spreadEvenBtn, separator2, themeBtn);
|
|
511
555
|
viewMenuWrap.append(viewMenuBtn, viewMenu);
|
|
512
|
-
|
|
556
|
+
// Thumbnail rail toggle — the rail is shown by default and can be collapsed
|
|
557
|
+
// to give the page more room.
|
|
558
|
+
const thumbsToggleBtn = el('button', 'omni-pdf__thumbs-toggle', '☰');
|
|
559
|
+
thumbsToggleBtn.type = 'button';
|
|
560
|
+
thumbsToggleBtn.setAttribute('aria-label', t('pdf.thumbnails'));
|
|
561
|
+
thumbsToggleBtn.setAttribute('aria-expanded', 'true');
|
|
562
|
+
thumbsToggleBtn.addEventListener('click', () => {
|
|
563
|
+
const collapsed = body.classList.toggle('omni-pdf__body--thumbs-collapsed');
|
|
564
|
+
thumbsToggleBtn.setAttribute('aria-expanded', String(!collapsed));
|
|
565
|
+
thumbsToggleBtn.classList.toggle('is-collapsed', collapsed);
|
|
566
|
+
});
|
|
567
|
+
zoomBar.append(thumbsToggleBtn, zoomOutBtn, zoomLevel, zoomInBtn, viewMenuWrap);
|
|
513
568
|
const closeViewMenu = () => {
|
|
514
569
|
viewMenu.classList.remove('is-open');
|
|
515
570
|
viewMenuBtn.setAttribute('aria-expanded', 'false');
|
|
@@ -809,10 +864,11 @@ export async function mountPdfViewer(input, container, ctx, deps, options = {})
|
|
|
809
864
|
ctx.logger.log('info', '[pdf highlight] selection has no PDF page rectangles');
|
|
810
865
|
return false;
|
|
811
866
|
}
|
|
867
|
+
const text = selection.toString().replace(/\s+/g, ' ').trim();
|
|
812
868
|
for (const [page, rects] of byPage) {
|
|
813
869
|
controller.dispatch({
|
|
814
870
|
type: 'add-annotation',
|
|
815
|
-
annotation: { kind, page, rects: mergeHighlightRects(rects), color }
|
|
871
|
+
annotation: { kind, page, rects: mergeHighlightRects(rects), color, text }
|
|
816
872
|
});
|
|
817
873
|
}
|
|
818
874
|
selection.removeAllRanges();
|
|
@@ -824,7 +880,7 @@ export async function mountPdfViewer(input, container, ctx, deps, options = {})
|
|
|
824
880
|
}
|
|
825
881
|
// ------------------------------------------------------- annotations UI
|
|
826
882
|
function renderOverlays(record) {
|
|
827
|
-
for (const node of record.wrapper.querySelectorAll('.omni-pdf__annotation')) {
|
|
883
|
+
for (const node of record.wrapper.querySelectorAll('.omni-pdf__annotation, .omni-pdf__markup-toolbar')) {
|
|
828
884
|
node.remove();
|
|
829
885
|
}
|
|
830
886
|
const scale = controller.state.zoom / 100;
|
|
@@ -865,7 +921,9 @@ export async function mountPdfViewer(input, container, ctx, deps, options = {})
|
|
|
865
921
|
box.addEventListener('click', (event) => {
|
|
866
922
|
event.preventDefault();
|
|
867
923
|
event.stopPropagation();
|
|
868
|
-
|
|
924
|
+
// Clicking the active markup again dismisses its toolbar.
|
|
925
|
+
const active = controller.state.selectedAnnotationId === annotation.id;
|
|
926
|
+
controller.dispatch({ type: 'select-annotation', id: active ? null : annotation.id });
|
|
869
927
|
});
|
|
870
928
|
box.addEventListener('pointerenter', () => setGroupHover(true));
|
|
871
929
|
box.addEventListener('pointerleave', (event) => {
|
|
@@ -877,7 +935,8 @@ export async function mountPdfViewer(input, container, ctx, deps, options = {})
|
|
|
877
935
|
setGroupHover(false);
|
|
878
936
|
}
|
|
879
937
|
});
|
|
880
|
-
|
|
938
|
+
const selected = controller.state.selectedAnnotationId === annotation.id;
|
|
939
|
+
if (rect === deleteRect && !selected) {
|
|
881
940
|
const deleteButton = el('button', 'omni-pdf__annotation-delete', '×');
|
|
882
941
|
deleteButton.type = 'button';
|
|
883
942
|
deleteButton.setAttribute('aria-label', t('pdf.deleteAnnotation'));
|
|
@@ -894,6 +953,9 @@ export async function mountPdfViewer(input, container, ctx, deps, options = {})
|
|
|
894
953
|
}
|
|
895
954
|
record.wrapper.appendChild(box);
|
|
896
955
|
}
|
|
956
|
+
if (controller.state.selectedAnnotationId === annotation.id) {
|
|
957
|
+
record.wrapper.appendChild(buildMarkupToolbar(annotation, rects, scale));
|
|
958
|
+
}
|
|
897
959
|
continue;
|
|
898
960
|
}
|
|
899
961
|
const overlay = el('div', 'omni-pdf__annotation');
|
|
@@ -968,6 +1030,114 @@ export async function mountPdfViewer(input, container, ctx, deps, options = {})
|
|
|
968
1030
|
record.wrapper.appendChild(overlay);
|
|
969
1031
|
}
|
|
970
1032
|
}
|
|
1033
|
+
const isMarkup = (annotation) => annotation.kind === 'highlight' || annotation.kind === 'underline' || annotation.kind === 'strikeout';
|
|
1034
|
+
/** Floating action bar shown above a selected text-markup annotation. */
|
|
1035
|
+
function buildMarkupToolbar(annotation, rects, scale) {
|
|
1036
|
+
const anchor = rects.reduce((best, rect) => rect.y < best.y || (rect.y === best.y && rect.x < best.x) ? rect : best);
|
|
1037
|
+
const toolbar = el('div', 'omni-pdf__markup-toolbar');
|
|
1038
|
+
toolbar.style.left = `${anchor.x * scale}px`;
|
|
1039
|
+
toolbar.style.top = `${anchor.y * scale}px`;
|
|
1040
|
+
// Keep interactions inside the bar from bubbling to the page, which would
|
|
1041
|
+
// clear the selection and tear the bar down mid-click.
|
|
1042
|
+
toolbar.addEventListener('pointerdown', (event) => event.stopPropagation());
|
|
1043
|
+
toolbar.addEventListener('click', (event) => event.stopPropagation());
|
|
1044
|
+
const tool = (label, aria, onClick) => {
|
|
1045
|
+
const button = el('button', 'omni-pdf__markup-tool', label);
|
|
1046
|
+
button.type = 'button';
|
|
1047
|
+
button.setAttribute('aria-label', aria);
|
|
1048
|
+
button.addEventListener('click', onClick);
|
|
1049
|
+
return button;
|
|
1050
|
+
};
|
|
1051
|
+
// 1) Open the markup list sidebar.
|
|
1052
|
+
toolbar.appendChild(tool('▤', t('pdf.markupList'), () => setMarkupListOpen(true)));
|
|
1053
|
+
// 2) Colour swatch with a small palette popover.
|
|
1054
|
+
const colorWrap = el('div', 'omni-pdf__markup-color-wrap');
|
|
1055
|
+
const colorBtn = tool('', t('pdf.changeColor'), () => {
|
|
1056
|
+
popover.classList.toggle('is-open');
|
|
1057
|
+
});
|
|
1058
|
+
colorBtn.classList.add('omni-pdf__markup-color');
|
|
1059
|
+
colorBtn.style.setProperty('--omni-hl-color', annotation.color);
|
|
1060
|
+
const popover = el('div', 'omni-pdf__markup-palette');
|
|
1061
|
+
for (const color of MARKUP_COLORS) {
|
|
1062
|
+
const swatch = el('button', 'omni-pdf__markup-swatch');
|
|
1063
|
+
swatch.type = 'button';
|
|
1064
|
+
swatch.style.setProperty('--omni-hl-color', color);
|
|
1065
|
+
swatch.setAttribute('aria-label', color);
|
|
1066
|
+
if (color.toLowerCase() === annotation.color.toLowerCase())
|
|
1067
|
+
swatch.classList.add('is-current');
|
|
1068
|
+
swatch.addEventListener('click', () => {
|
|
1069
|
+
popover.classList.remove('is-open');
|
|
1070
|
+
controller.dispatch({ type: 'set-annotation-color', id: annotation.id, color });
|
|
1071
|
+
});
|
|
1072
|
+
popover.appendChild(swatch);
|
|
1073
|
+
}
|
|
1074
|
+
colorWrap.append(colorBtn, popover);
|
|
1075
|
+
toolbar.appendChild(colorWrap);
|
|
1076
|
+
// 3) Copy the underlying text.
|
|
1077
|
+
const text = annotation.text ?? '';
|
|
1078
|
+
const copyBtn = tool('⧉', t('pdf.copyText'), () => {
|
|
1079
|
+
void ctx.clipboard?.writeText(text);
|
|
1080
|
+
});
|
|
1081
|
+
copyBtn.disabled = text.length === 0 || !ctx.clipboard;
|
|
1082
|
+
if (!ctx.clipboard)
|
|
1083
|
+
copyBtn.title = t('common.noClipboard');
|
|
1084
|
+
toolbar.appendChild(copyBtn);
|
|
1085
|
+
// 4) Delete.
|
|
1086
|
+
toolbar.appendChild(tool('🗑', t('pdf.deleteAnnotation'), () => {
|
|
1087
|
+
controller.dispatch({ type: 'remove-annotation', id: annotation.id });
|
|
1088
|
+
}));
|
|
1089
|
+
return toolbar;
|
|
1090
|
+
}
|
|
1091
|
+
// -------------------------------------------------- markup list sidebar
|
|
1092
|
+
function setMarkupListOpen(open) {
|
|
1093
|
+
markupListOpen = open;
|
|
1094
|
+
markupList.classList.toggle('is-open', open);
|
|
1095
|
+
if (open)
|
|
1096
|
+
renderMarkupList();
|
|
1097
|
+
}
|
|
1098
|
+
/** Scroll the page carrying an annotation into view. */
|
|
1099
|
+
function scrollToAnnotation(annotation) {
|
|
1100
|
+
const record = records.find((item) => item.pageNumber === annotation.page);
|
|
1101
|
+
if (record)
|
|
1102
|
+
scrollToPage(record);
|
|
1103
|
+
}
|
|
1104
|
+
function renderMarkupList() {
|
|
1105
|
+
markupList.replaceChildren();
|
|
1106
|
+
const header = el('div', 'omni-pdf__markup-list-head');
|
|
1107
|
+
header.appendChild(el('span', 'omni-pdf__markup-list-title', t('pdf.markupList')));
|
|
1108
|
+
const closeBtn = el('button', 'omni-pdf__markup-list-close', '×');
|
|
1109
|
+
closeBtn.type = 'button';
|
|
1110
|
+
closeBtn.setAttribute('aria-label', t('pdf.closeMarkupList'));
|
|
1111
|
+
closeBtn.addEventListener('click', () => setMarkupListOpen(false));
|
|
1112
|
+
header.appendChild(closeBtn);
|
|
1113
|
+
markupList.appendChild(header);
|
|
1114
|
+
const order = controller.state.pageOrder;
|
|
1115
|
+
const items = controller.state.annotations
|
|
1116
|
+
.filter(isMarkup)
|
|
1117
|
+
.sort((a, b) => order.indexOf(a.page) - order.indexOf(b.page));
|
|
1118
|
+
if (items.length === 0) {
|
|
1119
|
+
markupList.appendChild(el('div', 'omni-pdf__markup-list-empty', t('pdf.noMarkups')));
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1122
|
+
for (const annotation of items) {
|
|
1123
|
+
const row = el('button', 'omni-pdf__markup-item');
|
|
1124
|
+
row.type = 'button';
|
|
1125
|
+
if (controller.state.selectedAnnotationId === annotation.id)
|
|
1126
|
+
row.classList.add('is-selected');
|
|
1127
|
+
const dot = el('span', `omni-pdf__markup-item-dot omni-pdf__markup-item-dot--${annotation.kind}`);
|
|
1128
|
+
dot.style.setProperty('--omni-hl-color', annotation.color);
|
|
1129
|
+
const label = el('span', 'omni-pdf__markup-item-text', (annotation.text ?? '').trim() || t(annotation.kind === 'highlight'
|
|
1130
|
+
? 'pdf.highlight'
|
|
1131
|
+
: annotation.kind === 'underline' ? 'pdf.underline' : 'pdf.strikeout'));
|
|
1132
|
+
const page = el('span', 'omni-pdf__markup-item-page', String(order.indexOf(annotation.page) + 1));
|
|
1133
|
+
row.append(dot, label, page);
|
|
1134
|
+
row.addEventListener('click', () => {
|
|
1135
|
+
controller.dispatch({ type: 'select-annotation', id: annotation.id });
|
|
1136
|
+
scrollToAnnotation(annotation);
|
|
1137
|
+
});
|
|
1138
|
+
markupList.appendChild(row);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
971
1141
|
/** Mirror the page annotations onto a thumbnail as non-interactive,
|
|
972
1142
|
* scaled-down overlays so thumbs stay in sync with markup edits. */
|
|
973
1143
|
function renderThumbOverlays(thumbRecord) {
|
|
@@ -1390,6 +1560,8 @@ export async function mountPdfViewer(input, container, ctx, deps, options = {})
|
|
|
1390
1560
|
const state = controller.state;
|
|
1391
1561
|
const nextKey = JSON.stringify({ zoom: state.zoom, pageOrder: state.pageOrder });
|
|
1392
1562
|
refreshChrome();
|
|
1563
|
+
if (markupListOpen)
|
|
1564
|
+
renderMarkupList();
|
|
1393
1565
|
if (nextKey !== layoutKey) {
|
|
1394
1566
|
layoutKey = nextKey;
|
|
1395
1567
|
void rebuildLayout();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const pdfViewerCss = "\n/* Reverse-contamination guard for 'scoped' mode \u2014 see csv/styles.ts. */\n.omni-viewer--pdf {\n all: initial;\n}\n.omni-viewer--pdf :where(button, input, canvas, img, span, div) {\n all: revert;\n}\n\n:host, .omni-viewer--pdf {\n display: block;\n height: 100%;\n box-sizing: border-box;\n color: var(--omni-fg, #e8e8e8);\n background: var(--omni-bg, #1e1e1e);\n font-family: var(--omni-font, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif);\n font-size: var(--omni-font-size, 13px);\n}\n.omni-pdf, .omni-pdf * { box-sizing: border-box; }\n.omni-pdf {\n position: relative;\n display: flex;\n flex-direction: column;\n height: 100%;\n min-height: 0;\n}\n.omni-pdf__header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n padding: 8px 12px;\n background: var(--omni-bg-secondary, #252526);\n border-bottom: 1px solid var(--omni-border, #3c3c3c);\n flex: none;\n}\n.omni-pdf__title {\n font-weight: 600;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n max-width: 40%;\n}\n.omni-pdf__toolbar {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 6px;\n}\n.omni-pdf__page-info {\n color: var(--omni-fg-muted, #9d9d9d);\n margin-right: 8px;\n}\n.omni-pdf__save-mode {\n padding: 2px 6px;\n color: var(--omni-fg-muted, #9d9d9d);\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 999px;\n font-size: 11px;\n white-space: nowrap;\n}\n.omni-pdf__page-input {\n width: 52px;\n padding: 3px 5px;\n margin-right: 5px;\n color: var(--omni-fg, #e8e8e8);\n background: var(--omni-input-bg, #3c3c3c);\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 4px;\n font: inherit;\n text-align: center;\n}\n.omni-pdf__page-input:focus {\n outline: 1px solid var(--omni-accent, #0e639c);\n border-color: var(--omni-accent, #0e639c);\n}\n.omni-pdf button {\n font: inherit;\n color: var(--omni-fg, #e8e8e8);\n background: var(--omni-button-bg, #3a3d41);\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 4px;\n cursor: pointer;\n}\n.omni-pdf button:hover:not(:disabled) {\n background: var(--omni-button-hover-bg, #45494e);\n}\n.omni-pdf button:disabled {\n opacity: 0.45;\n cursor: not-allowed;\n}\n.omni-pdf button[aria-pressed=\"true\"] {\n background: var(--omni-accent, #0e639c);\n border-color: var(--omni-accent, #0e639c);\n color: var(--omni-accent-fg, #ffffff);\n}\n.omni-pdf__tool { padding: 5px 10px; }\n.omni-pdf__markup-wrap {\n position: relative;\n display: inline-flex;\n}\n.omni-pdf__markup-wrap .omni-pdf__tool {\n min-width: 34px;\n padding: 4px 8px;\n font-size: 21px;\n line-height: 1;\n border-radius: 4px 0 0 4px;\n}\n.omni-pdf__markup-menu-btn {\n min-width: 28px;\n padding: 0 6px;\n border-radius: 0 4px 4px 0;\n}\n.omni-pdf__markup-menu {\n position: absolute;\n z-index: 20;\n top: calc(100% + 4px);\n left: 0;\n display: none;\n min-width: 170px;\n padding: 7px;\n background: var(--omni-bg-secondary, #252526);\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 6px;\n box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);\n}\n.omni-pdf__markup-menu.is-open { display: block; }\n.omni-pdf__markup-choice {\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n box-sizing: border-box;\n min-height: 32px;\n padding: 2px 0;\n}\n.omni-pdf__markup-menu button {\n flex: 1;\n min-height: 32px;\n padding: 5px 8px;\n color: inherit;\n font: inherit;\n}\n.omni-pdf__markup-menu button {\n text-align: left;\n background: transparent;\n border-color: transparent;\n}\n.omni-pdf__markup-menu button:hover,\n.omni-pdf__markup-menu button[aria-checked=\"true\"] { background: var(--omni-button-hover-bg, #45494e); }\n.omni-pdf__markup-menu button[aria-checked=\"true\"]::before { content: \"\u2713 \"; }\n.omni-pdf__highlight-color {\n width: 30px;\n height: 28px;\n padding: 2px;\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 4px;\n background: var(--omni-button-bg, #3a3d41);\n cursor: pointer;\n}\n.omni-pdf__highlight-color:disabled {\n opacity: 0.45;\n cursor: not-allowed;\n}\n.omni-pdf__zoom {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 6px;\n background: var(--omni-bg-secondary, #252526);\n border-bottom: 1px solid var(--omni-border, #3c3c3c);\n flex: none;\n}\n.omni-pdf__zoom-btn {\n width: 28px;\n height: 28px;\n padding: 0;\n font-size: 18px;\n line-height: 1;\n}\n.omni-pdf__zoom-level {\n min-width: 56px;\n text-align: center;\n}\n.omni-pdf__view-menu-wrap { position: relative; }\n.omni-pdf__view-menu-btn {\n width: 30px;\n height: 28px;\n padding: 0;\n font-size: 22px;\n line-height: 1;\n}\n.omni-pdf__view-menu {\n position: absolute;\n z-index: 20;\n top: calc(100% + 4px);\n right: 0;\n display: none;\n min-width: 210px;\n padding: 6px;\n background: var(--omni-bg-secondary, #252526);\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 6px;\n box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);\n}\n.omni-pdf__view-menu.is-open { display: block; }\n.omni-pdf__view-menu button {\n display: block;\n width: 100%;\n padding: 7px 10px;\n text-align: left;\n background: transparent;\n border-color: transparent;\n}\n.omni-pdf__view-menu button:hover,\n.omni-pdf__view-menu button[aria-checked=\"true\"] {\n background: var(--omni-button-hover-bg, #45494e);\n}\n.omni-pdf__view-menu button[aria-checked=\"true\"]::before {\n content: \"\u2713 \";\n}\n.omni-pdf__view-menu hr {\n height: 1px;\n margin: 5px 2px;\n border: 0;\n background: var(--omni-border, #3c3c3c);\n}\n.omni-pdf__body {\n flex: 1;\n min-height: 0;\n display: grid;\n grid-template-columns: 160px minmax(0, 1fr);\n overflow: hidden;\n}\n.omni-pdf__thumbs {\n overflow: auto;\n min-height: 0;\n background: var(--omni-bg-secondary, #252526);\n border-right: 1px solid var(--omni-border, #3c3c3c);\n padding: 8px;\n}\n.omni-pdf__thumb {\n position: relative;\n display: flex;\n width: 100%;\n min-height: 130px;\n margin: 0 0 8px;\n padding: 6px;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n gap: 4px;\n background: transparent;\n}\n.omni-pdf__thumb:hover,\n.omni-pdf__thumb[aria-current] {\n background: var(--omni-button-hover-bg, #45494e);\n border-color: var(--omni-accent, #0e639c);\n}\n.omni-pdf__thumb.is-dragging { opacity: 0.5; }\n.omni-pdf__thumb.drop-before::before,\n.omni-pdf__thumb.drop-after::after {\n content: \"\";\n position: absolute;\n left: -4px;\n right: -4px;\n height: 3px;\n background: var(--omni-accent, #0e639c);\n border-radius: 2px;\n z-index: 4;\n}\n.omni-pdf__thumb.drop-before::before { top: -6px; }\n.omni-pdf__thumb.drop-after::after { bottom: -6px; }\n.omni-pdf__thumb canvas {\n display: block;\n max-width: 100%;\n background: #ffffff;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);\n}\n.omni-pdf__thumb-page {\n position: relative;\n max-width: 100%;\n}\n.omni-pdf__thumb-annotation {\n position: absolute;\n z-index: 1;\n overflow: hidden;\n pointer-events: none;\n color: #111111; /* ink on paper */\n white-space: nowrap;\n}\n.omni-pdf__thumb-annotation img { display: block; }\n.omni-pdf__thumb-annotation.omni-pdf__underline::after,\n.omni-pdf__thumb-annotation.omni-pdf__strikeout::after {\n height: 1px;\n}\n.omni-pdf__thumb-label {\n font-family: var(--omni-font-mono, Monaco, Menlo, monospace);\n font-size: 10px;\n color: var(--omni-fg-muted, #9d9d9d);\n}\n.omni-pdf__thumb-remove {\n position: absolute;\n top: 2px;\n right: 2px;\n width: 22px;\n height: 22px;\n padding: 0;\n border-radius: 50%;\n}\n.omni-pdf__pages {\n overflow: auto;\n position: relative;\n padding: 20px;\n min-width: 0;\n min-height: 0;\n}\n.omni-pdf__pages--spread {\n display: grid;\n grid-template-columns: repeat(2, max-content);\n align-content: start;\n justify-content: center;\n column-gap: 16px;\n}\n.omni-pdf__spread-blank {\n min-width: 1px;\n}\n.omni-pdf__pages--theme .omni-pdf__page {\n background: var(--omni-bg-secondary, #252526);\n}\n.omni-pdf__pages--theme .omni-pdf__page canvas {\n filter: invert(0.92) hue-rotate(180deg);\n}\n.omni-pdf__page {\n position: relative;\n margin: 0 auto 16px;\n background: #ffffff; /* paper */\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);\n}\n.omni-pdf__page canvas {\n display: block;\n max-width: 100%;\n height: auto;\n}\n.omni-pdf__placeholder {\n display: flex;\n width: 100%;\n height: 100%;\n align-items: center;\n justify-content: center;\n color: var(--omni-fg-muted, #9d9d9d);\n}\n.omni-pdf__text-layer {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: clip;\n opacity: 1;\n line-height: 1;\n text-align: initial;\n text-size-adjust: none;\n forced-color-adjust: none;\n transform-origin: 0 0;\n caret-color: CanvasText;\n pointer-events: auto;\n user-select: text;\n -webkit-user-select: text;\n}\n.omni-pdf__text-layer span,\n.omni-pdf__text-layer br {\n position: absolute;\n white-space: pre;\n color: transparent;\n cursor: text;\n transform-origin: 0 0;\n user-select: text;\n -webkit-user-select: text;\n}\n.omni-pdf__text-layer ::selection {\n background: rgba(14, 99, 156, 0.35);\n}\n/* While placing text/signature, let clicks fall through to the canvas. */\n.omni-pdf__pages--placing .omni-pdf__text-layer {\n pointer-events: none;\n user-select: none;\n}\n.omni-pdf__annotation {\n position: absolute;\n z-index: 2;\n padding: 0;\n color: #111111; /* ink on paper */\n cursor: move;\n touch-action: none;\n}\n.omni-pdf button.omni-pdf__annotation {\n background: transparent;\n border: 0;\n font: inherit;\n}\n.omni-pdf__annotation img {\n display: block;\n pointer-events: none;\n}\n.omni-pdf__annotation.is-selected,\n.omni-pdf__annotation:hover,\n.omni-pdf__annotation.is-hovered,\n.omni-pdf__annotation:focus-visible,\n.omni-pdf__annotation:focus-within {\n outline: 1px solid var(--omni-accent, #0e639c);\n outline-offset: 2px;\n}\n.omni-pdf__annotation-delete {\n position: absolute;\n top: -10px;\n right: -10px;\n z-index: 1;\n display: none;\n width: 18px;\n height: 18px;\n padding: 0;\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 50%;\n background: var(--omni-bg-secondary, #252526);\n color: var(--omni-fg, #e8e8e8);\n font-size: 15px;\n line-height: 14px;\n cursor: pointer;\n}\n.omni-pdf__annotation.is-selected .omni-pdf__annotation-delete,\n.omni-pdf__annotation:hover .omni-pdf__annotation-delete,\n.omni-pdf__annotation:focus-visible .omni-pdf__annotation-delete,\n.omni-pdf__annotation:focus-within .omni-pdf__annotation-delete {\n display: block;\n}\n.omni-pdf__highlight {\n background: var(--omni-hl-color, #ffeb3b);\n mix-blend-mode: multiply;\n cursor: pointer;\n}\n.omni-pdf__strikeout {\n background: transparent;\n cursor: pointer;\n}\n.omni-pdf__strikeout::after {\n position: absolute;\n top: calc(50% - 1px);\n left: 0;\n width: 100%;\n height: 2px;\n content: '';\n background: var(--omni-hl-color, #ffeb3b);\n}\n.omni-pdf__underline {\n background: transparent;\n cursor: pointer;\n}\n.omni-pdf__underline::after {\n position: absolute;\n bottom: 8%;\n left: 0;\n width: 100%;\n height: 2px;\n content: '';\n background: var(--omni-hl-color, #ffeb3b);\n}\n.omni-pdf__text-editor {\n position: absolute;\n z-index: 3;\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 3px;\n background: var(--omni-bg-secondary, #252526);\n border: 1px solid var(--omni-accent, #0e639c);\n border-radius: 3px;\n}\n.omni-pdf__text-input {\n min-width: 160px;\n font: inherit;\n color: #111111;\n background: #ffffff;\n border: 0;\n border-radius: 2px;\n padding: 2px 4px;\n}\n.omni-pdf__text-size-input {\n width: 52px;\n font: inherit;\n}\n.omni-pdf__color-input {\n width: 28px;\n height: 24px;\n padding: 0;\n border: 0;\n background: transparent;\n cursor: pointer;\n}\n.omni-pdf__status {\n padding: 8px 12px;\n color: var(--omni-fg-muted, #9d9d9d);\n border-top: 1px solid var(--omni-border, #3c3c3c);\n flex: none;\n}\n.omni-pdf__status--error {\n color: var(--omni-error-fg, #f48771);\n font-weight: 600;\n}\n.omni-pdf__modal {\n /* A dialog must be positioned against the visible viewport. Anchoring it\n to the flex viewer made it drift when the host or page list scrolled. */\n position: fixed;\n inset: 0;\n z-index: 1000;\n display: none;\n align-items: center;\n justify-content: center;\n background: rgba(0, 0, 0, 0.55);\n}\n.omni-pdf__modal.is-open { display: flex; }\n.omni-pdf__panel {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 18px;\n background: var(--omni-bg-secondary, #252526);\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 8px;\n}\n.omni-pdf__panel input {\n font: inherit;\n color: var(--omni-fg, #e8e8e8);\n background: var(--omni-input-bg, #3c3c3c);\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 4px;\n padding: 6px 8px;\n}\n.omni-pdf__field {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n}\n.omni-pdf__field input[type=\"color\"] {\n width: 40px;\n height: 26px;\n padding: 0;\n background: transparent;\n cursor: pointer;\n}\n.omni-pdf__panel button { padding: 5px 12px; }\n.omni-pdf__panel-actions {\n display: flex;\n justify-content: flex-end;\n gap: 8px;\n}\n.omni-pdf__error {\n color: var(--omni-error-fg, #f48771);\n}\n.omni-pdf__signature-pad {\n display: block;\n width: min(480px, 80vw);\n height: auto;\n background: #ffffff;\n touch-action: none;\n}\n@media (max-width: 720px) {\n .omni-pdf__body {\n grid-template-columns: minmax(0, 1fr);\n grid-template-rows: minmax(120px, 30vh) minmax(0, 1fr);\n }\n .omni-pdf__thumbs {\n border-right: 0;\n border-bottom: 1px solid var(--omni-border, #3c3c3c);\n }\n .omni-pdf__pages { grid-row: 2; }\n}\n";
|
|
1
|
+
export declare const pdfViewerCss = "\n/* Reverse-contamination guard for 'scoped' mode \u2014 see csv/styles.ts. */\n.omni-viewer--pdf {\n all: initial;\n}\n.omni-viewer--pdf :where(button, input, canvas, img, span, div) {\n all: revert;\n}\n\n:host, .omni-viewer--pdf {\n display: block;\n height: 100%;\n box-sizing: border-box;\n color: var(--omni-fg, #e8e8e8);\n background: var(--omni-bg, #1e1e1e);\n font-family: var(--omni-font, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif);\n font-size: var(--omni-font-size, 13px);\n}\n.omni-pdf, .omni-pdf * { box-sizing: border-box; }\n.omni-pdf {\n position: relative;\n display: flex;\n flex-direction: column;\n height: 100%;\n min-height: 0;\n}\n.omni-pdf__header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n padding: 8px 12px;\n background: var(--omni-bg-secondary, #252526);\n border-bottom: 1px solid var(--omni-border, #3c3c3c);\n flex: none;\n}\n.omni-pdf__title {\n font-weight: 600;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n max-width: 40%;\n}\n.omni-pdf__toolbar {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 6px;\n}\n.omni-pdf__page-info {\n color: var(--omni-fg-muted, #9d9d9d);\n margin-right: 8px;\n}\n.omni-pdf__save-mode {\n padding: 2px 6px;\n color: var(--omni-fg-muted, #9d9d9d);\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 999px;\n font-size: 11px;\n white-space: nowrap;\n}\n.omni-pdf__page-input {\n width: 52px;\n padding: 3px 5px;\n margin-right: 5px;\n color: var(--omni-fg, #e8e8e8);\n background: var(--omni-input-bg, #3c3c3c);\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 4px;\n font: inherit;\n text-align: center;\n}\n.omni-pdf__page-input:focus {\n outline: 1px solid var(--omni-accent, #0e639c);\n border-color: var(--omni-accent, #0e639c);\n}\n.omni-pdf button {\n font: inherit;\n color: var(--omni-fg, #e8e8e8);\n background: var(--omni-button-bg, #3a3d41);\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 4px;\n cursor: pointer;\n}\n.omni-pdf button:hover:not(:disabled) {\n background: var(--omni-button-hover-bg, #45494e);\n}\n.omni-pdf button:disabled {\n opacity: 0.45;\n cursor: not-allowed;\n}\n.omni-pdf button[aria-pressed=\"true\"] {\n background: var(--omni-accent, #0e639c);\n border-color: var(--omni-accent, #0e639c);\n color: var(--omni-accent-fg, #ffffff);\n}\n.omni-pdf__tool { padding: 5px 10px; }\n.omni-pdf__markup-wrap {\n position: relative;\n display: inline-flex;\n}\n.omni-pdf__markup-wrap .omni-pdf__tool {\n min-width: 34px;\n padding: 4px 8px;\n font-size: 21px;\n line-height: 1;\n border-radius: 4px 0 0 4px;\n}\n.omni-pdf__markup-menu-btn {\n min-width: 28px;\n padding: 0 6px;\n border-radius: 0 4px 4px 0;\n}\n.omni-pdf__markup-menu {\n position: absolute;\n z-index: 20;\n top: calc(100% + 4px);\n left: 0;\n display: none;\n min-width: 170px;\n padding: 7px;\n background: var(--omni-bg-secondary, #252526);\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 6px;\n box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);\n}\n.omni-pdf__markup-menu.is-open { display: block; }\n.omni-pdf__markup-choice {\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n box-sizing: border-box;\n min-height: 32px;\n padding: 2px 0;\n}\n.omni-pdf__markup-menu button {\n flex: 1;\n min-height: 32px;\n padding: 5px 8px;\n color: inherit;\n font: inherit;\n}\n.omni-pdf__markup-menu button {\n text-align: left;\n background: transparent;\n border-color: transparent;\n}\n.omni-pdf__markup-menu button:hover,\n.omni-pdf__markup-menu button[aria-checked=\"true\"] { background: var(--omni-button-hover-bg, #45494e); }\n.omni-pdf__markup-menu button[aria-checked=\"true\"]::before { content: \"\u2713 \"; }\n.omni-pdf__highlight-color {\n width: 30px;\n height: 28px;\n padding: 2px;\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 4px;\n background: var(--omni-button-bg, #3a3d41);\n cursor: pointer;\n}\n.omni-pdf__highlight-color:disabled {\n opacity: 0.45;\n cursor: not-allowed;\n}\n.omni-pdf__zoom {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 6px;\n background: var(--omni-bg-secondary, #252526);\n border-bottom: 1px solid var(--omni-border, #3c3c3c);\n flex: none;\n}\n.omni-pdf__zoom-btn {\n width: 28px;\n height: 28px;\n padding: 0;\n font-size: 18px;\n line-height: 1;\n}\n.omni-pdf__zoom-level {\n min-width: 56px;\n text-align: center;\n}\n.omni-pdf__thumbs-toggle {\n width: 30px;\n height: 28px;\n padding: 0;\n margin-right: auto;\n font-size: 16px;\n line-height: 1;\n}\n.omni-pdf__thumbs-toggle.is-collapsed {\n opacity: 0.6;\n}\n.omni-pdf__view-menu-wrap { position: relative; }\n.omni-pdf__view-menu-btn {\n width: 30px;\n height: 28px;\n padding: 0;\n font-size: 22px;\n line-height: 1;\n}\n.omni-pdf__view-menu {\n position: absolute;\n z-index: 20;\n top: calc(100% + 4px);\n right: 0;\n display: none;\n min-width: 210px;\n padding: 6px;\n background: var(--omni-bg-secondary, #252526);\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 6px;\n box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);\n}\n.omni-pdf__view-menu.is-open { display: block; }\n.omni-pdf__view-menu button {\n display: block;\n width: 100%;\n padding: 7px 10px;\n text-align: left;\n background: transparent;\n border-color: transparent;\n}\n.omni-pdf__view-menu button:hover,\n.omni-pdf__view-menu button[aria-checked=\"true\"] {\n background: var(--omni-button-hover-bg, #45494e);\n}\n.omni-pdf__view-menu button[aria-checked=\"true\"]::before {\n content: \"\u2713 \";\n}\n.omni-pdf__view-menu hr {\n height: 1px;\n margin: 5px 2px;\n border: 0;\n background: var(--omni-border, #3c3c3c);\n}\n.omni-pdf__body {\n position: relative;\n flex: 1;\n min-height: 0;\n display: grid;\n grid-template-columns: 160px minmax(0, 1fr);\n overflow: hidden;\n}\n.omni-pdf__body--thumbs-collapsed {\n grid-template-columns: minmax(0, 1fr);\n}\n.omni-pdf__body--thumbs-collapsed .omni-pdf__thumbs {\n display: none;\n}\n.omni-pdf__thumbs {\n overflow: auto;\n min-height: 0;\n background: var(--omni-bg-secondary, #252526);\n border-right: 1px solid var(--omni-border, #3c3c3c);\n padding: 8px;\n}\n.omni-pdf__thumb {\n position: relative;\n display: flex;\n width: 100%;\n min-height: 130px;\n margin: 0 0 8px;\n padding: 6px;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n gap: 4px;\n background: transparent;\n}\n.omni-pdf__thumb:hover,\n.omni-pdf__thumb[aria-current] {\n background: var(--omni-button-hover-bg, #45494e);\n border-color: var(--omni-accent, #0e639c);\n}\n.omni-pdf__thumb.is-dragging { opacity: 0.5; }\n.omni-pdf__thumb.drop-before::before,\n.omni-pdf__thumb.drop-after::after {\n content: \"\";\n position: absolute;\n left: -4px;\n right: -4px;\n height: 3px;\n background: var(--omni-accent, #0e639c);\n border-radius: 2px;\n z-index: 4;\n}\n.omni-pdf__thumb.drop-before::before { top: -6px; }\n.omni-pdf__thumb.drop-after::after { bottom: -6px; }\n.omni-pdf__thumb canvas {\n display: block;\n max-width: 100%;\n background: #ffffff;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);\n}\n.omni-pdf__thumb-page {\n position: relative;\n max-width: 100%;\n}\n.omni-pdf__thumb-annotation {\n position: absolute;\n z-index: 1;\n overflow: hidden;\n pointer-events: none;\n color: #111111; /* ink on paper */\n white-space: nowrap;\n}\n.omni-pdf__thumb-annotation img { display: block; }\n.omni-pdf__thumb-annotation.omni-pdf__underline::after,\n.omni-pdf__thumb-annotation.omni-pdf__strikeout::after {\n height: 1px;\n}\n.omni-pdf__thumb-label {\n font-family: var(--omni-font-mono, Monaco, Menlo, monospace);\n font-size: 10px;\n color: var(--omni-fg-muted, #9d9d9d);\n}\n.omni-pdf__thumb-remove {\n position: absolute;\n top: 2px;\n right: 2px;\n width: 22px;\n height: 22px;\n padding: 0;\n border-radius: 50%;\n}\n.omni-pdf__pages {\n overflow: auto;\n position: relative;\n padding: 20px;\n min-width: 0;\n min-height: 0;\n}\n.omni-pdf__pages--spread {\n display: grid;\n grid-template-columns: repeat(2, max-content);\n align-content: start;\n justify-content: center;\n column-gap: 16px;\n}\n.omni-pdf__spread-blank {\n min-width: 1px;\n}\n.omni-pdf__pages--theme .omni-pdf__page {\n background: var(--omni-bg-secondary, #252526);\n}\n.omni-pdf__pages--theme .omni-pdf__page canvas {\n filter: invert(0.92) hue-rotate(180deg);\n}\n.omni-pdf__page {\n position: relative;\n margin: 0 auto 16px;\n background: #ffffff; /* paper */\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);\n}\n.omni-pdf__page canvas {\n display: block;\n max-width: 100%;\n height: auto;\n}\n.omni-pdf__placeholder {\n display: flex;\n width: 100%;\n height: 100%;\n align-items: center;\n justify-content: center;\n color: var(--omni-fg-muted, #9d9d9d);\n}\n.omni-pdf__text-layer {\n position: absolute;\n inset: 0;\n z-index: 1;\n overflow: clip;\n opacity: 1;\n line-height: 1;\n text-align: initial;\n text-size-adjust: none;\n forced-color-adjust: none;\n transform-origin: 0 0;\n caret-color: CanvasText;\n pointer-events: auto;\n user-select: text;\n -webkit-user-select: text;\n}\n.omni-pdf__text-layer span,\n.omni-pdf__text-layer br {\n position: absolute;\n white-space: pre;\n color: transparent;\n cursor: text;\n transform-origin: 0 0;\n user-select: text;\n -webkit-user-select: text;\n}\n.omni-pdf__text-layer ::selection {\n background: rgba(14, 99, 156, 0.35);\n}\n/* While placing text/signature, let clicks fall through to the canvas. */\n.omni-pdf__pages--placing .omni-pdf__text-layer {\n pointer-events: none;\n user-select: none;\n}\n.omni-pdf__annotation {\n position: absolute;\n z-index: 2;\n padding: 0;\n color: #111111; /* ink on paper */\n cursor: move;\n touch-action: none;\n}\n.omni-pdf button.omni-pdf__annotation {\n background: transparent;\n border: 0;\n font: inherit;\n}\n.omni-pdf__annotation img {\n display: block;\n pointer-events: none;\n}\n.omni-pdf__annotation.is-selected,\n.omni-pdf__annotation:hover,\n.omni-pdf__annotation.is-hovered,\n.omni-pdf__annotation:focus-visible,\n.omni-pdf__annotation:focus-within {\n outline: 1px solid var(--omni-accent, #0e639c);\n outline-offset: 2px;\n}\n.omni-pdf__annotation-delete {\n position: absolute;\n top: -10px;\n right: -10px;\n z-index: 1;\n display: none;\n width: 18px;\n height: 18px;\n padding: 0;\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 50%;\n background: var(--omni-bg-secondary, #252526);\n color: var(--omni-fg, #e8e8e8);\n font-size: 15px;\n line-height: 14px;\n cursor: pointer;\n}\n.omni-pdf__annotation.is-selected .omni-pdf__annotation-delete,\n.omni-pdf__annotation:hover .omni-pdf__annotation-delete,\n.omni-pdf__annotation:focus-visible .omni-pdf__annotation-delete,\n.omni-pdf__annotation:focus-within .omni-pdf__annotation-delete {\n display: block;\n}\n.omni-pdf__highlight {\n background: var(--omni-hl-color, #ffeb3b);\n mix-blend-mode: multiply;\n cursor: pointer;\n}\n.omni-pdf__strikeout {\n background: transparent;\n cursor: pointer;\n}\n.omni-pdf__strikeout::after {\n position: absolute;\n top: calc(50% - 1px);\n left: 0;\n width: 100%;\n height: 2px;\n content: '';\n background: var(--omni-hl-color, #ffeb3b);\n}\n.omni-pdf__underline {\n background: transparent;\n cursor: pointer;\n}\n.omni-pdf__underline::after {\n position: absolute;\n bottom: 8%;\n left: 0;\n width: 100%;\n height: 2px;\n content: '';\n background: var(--omni-hl-color, #ffeb3b);\n}\n/* Floating action bar shown above a selected text-markup annotation. */\n.omni-pdf__markup-toolbar {\n position: absolute;\n z-index: 5;\n display: flex;\n align-items: center;\n gap: 2px;\n padding: 4px;\n transform: translateY(calc(-100% - 8px));\n background: var(--omni-bg-secondary, #252526);\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 10px;\n box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);\n cursor: default;\n}\n.omni-pdf button.omni-pdf__markup-tool {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 30px;\n height: 30px;\n padding: 0;\n border: 0;\n border-radius: 8px;\n background: transparent;\n color: var(--omni-fg, #e8e8e8);\n font-size: 15px;\n line-height: 1;\n cursor: pointer;\n}\n.omni-pdf button.omni-pdf__markup-tool:hover:not(:disabled) { background: var(--omni-button-hover-bg, #45494e); }\n.omni-pdf button.omni-pdf__markup-tool:disabled { opacity: 0.4; cursor: default; }\n.omni-pdf__markup-color::before {\n content: '';\n width: 18px;\n height: 18px;\n border-radius: 5px;\n background: var(--omni-hl-color, #ffeb3b);\n border: 1px solid rgba(0, 0, 0, 0.25);\n}\n.omni-pdf__markup-color-wrap { position: relative; display: inline-flex; }\n.omni-pdf__markup-palette {\n position: absolute;\n top: calc(100% + 6px);\n left: 50%;\n transform: translateX(-50%);\n display: none;\n grid-template-columns: repeat(3, auto);\n gap: 6px;\n padding: 8px;\n background: var(--omni-bg-secondary, #252526);\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 8px;\n box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);\n z-index: 6;\n}\n.omni-pdf__markup-palette.is-open { display: grid; }\n.omni-pdf button.omni-pdf__markup-swatch,\n.omni-pdf button.omni-pdf__markup-swatch:hover:not(:disabled) {\n width: 22px;\n height: 22px;\n padding: 0;\n border-radius: 5px;\n border: 1px solid rgba(255, 255, 255, 0.25);\n background: var(--omni-hl-color, #ffeb3b);\n cursor: pointer;\n}\n.omni-pdf button.omni-pdf__markup-swatch.is-current {\n outline: 2px solid var(--omni-accent, #0e639c);\n outline-offset: 1px;\n}\n/* Left overlay panel listing every text-markup annotation. */\n.omni-pdf__markup-list {\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n z-index: 6;\n display: none;\n flex-direction: column;\n width: min(280px, 70%);\n background: var(--omni-bg-secondary, #252526);\n border-right: 1px solid var(--omni-border, #3c3c3c);\n box-shadow: 2px 0 12px rgba(0, 0, 0, 0.35);\n overflow-y: auto;\n}\n.omni-pdf__markup-list.is-open { display: flex; }\n.omni-pdf__markup-list-head {\n position: sticky;\n top: 0;\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 10px 12px;\n background: var(--omni-bg-secondary, #252526);\n border-bottom: 1px solid var(--omni-border, #3c3c3c);\n}\n.omni-pdf__markup-list-title { font-weight: 600; }\n.omni-pdf button.omni-pdf__markup-list-close {\n width: 26px;\n height: 26px;\n padding: 0;\n border: 0;\n border-radius: 6px;\n background: transparent;\n color: var(--omni-fg, #e8e8e8);\n font-size: 18px;\n line-height: 1;\n cursor: pointer;\n}\n.omni-pdf button.omni-pdf__markup-list-close:hover:not(:disabled) { background: var(--omni-button-hover-bg, #45494e); }\n.omni-pdf__markup-list-empty {\n padding: 16px 12px;\n color: var(--omni-fg-muted, #9d9d9d);\n font-size: 13px;\n}\n.omni-pdf button.omni-pdf__markup-item {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n padding: 10px 12px;\n border: 0;\n border-bottom: 1px solid var(--omni-border, #3c3c3c);\n background: transparent;\n color: var(--omni-fg, #e8e8e8);\n text-align: left;\n cursor: pointer;\n}\n.omni-pdf button.omni-pdf__markup-item:hover:not(:disabled) { background: var(--omni-button-hover-bg, #45494e); }\n.omni-pdf button.omni-pdf__markup-item.is-selected {\n background: var(--omni-button-hover-bg, #45494e);\n box-shadow: inset 3px 0 0 var(--omni-accent, #0e639c);\n}\n.omni-pdf__markup-item-dot {\n flex: none;\n width: 14px;\n height: 14px;\n border-radius: 3px;\n border: 1px solid rgba(255, 255, 255, 0.25);\n background: var(--omni-hl-color, #ffeb3b);\n}\n.omni-pdf__markup-item-text {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n font-size: 13px;\n}\n.omni-pdf__markup-item-page {\n flex: none;\n color: var(--omni-fg-muted, #9d9d9d);\n font-size: 12px;\n}\n.omni-pdf__text-editor {\n position: absolute;\n z-index: 3;\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 3px;\n background: var(--omni-bg-secondary, #252526);\n border: 1px solid var(--omni-accent, #0e639c);\n border-radius: 3px;\n}\n.omni-pdf__text-input {\n min-width: 160px;\n font: inherit;\n color: #111111;\n background: #ffffff;\n border: 0;\n border-radius: 2px;\n padding: 2px 4px;\n}\n.omni-pdf__text-size-input {\n width: 52px;\n font: inherit;\n}\n.omni-pdf__color-input {\n width: 28px;\n height: 24px;\n padding: 0;\n border: 0;\n background: transparent;\n cursor: pointer;\n}\n.omni-pdf__status {\n padding: 8px 12px;\n color: var(--omni-fg-muted, #9d9d9d);\n border-top: 1px solid var(--omni-border, #3c3c3c);\n flex: none;\n}\n.omni-pdf__status--error {\n color: var(--omni-error-fg, #f48771);\n font-weight: 600;\n}\n.omni-pdf__modal {\n /* A dialog must be positioned against the visible viewport. Anchoring it\n to the flex viewer made it drift when the host or page list scrolled. */\n position: fixed;\n inset: 0;\n z-index: 1000;\n display: none;\n align-items: center;\n justify-content: center;\n background: rgba(0, 0, 0, 0.55);\n}\n.omni-pdf__modal.is-open { display: flex; }\n.omni-pdf__panel {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 18px;\n background: var(--omni-bg-secondary, #252526);\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 8px;\n}\n.omni-pdf__panel input {\n font: inherit;\n color: var(--omni-fg, #e8e8e8);\n background: var(--omni-input-bg, #3c3c3c);\n border: 1px solid var(--omni-border, #3c3c3c);\n border-radius: 4px;\n padding: 6px 8px;\n}\n.omni-pdf__field {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n}\n.omni-pdf__field input[type=\"color\"] {\n width: 40px;\n height: 26px;\n padding: 0;\n background: transparent;\n cursor: pointer;\n}\n.omni-pdf__panel button { padding: 5px 12px; }\n.omni-pdf__panel-actions {\n display: flex;\n justify-content: flex-end;\n gap: 8px;\n}\n.omni-pdf__error {\n color: var(--omni-error-fg, #f48771);\n}\n.omni-pdf__signature-pad {\n display: block;\n width: min(480px, 80vw);\n height: auto;\n background: #ffffff;\n touch-action: none;\n}\n@media (max-width: 720px) {\n .omni-pdf__body {\n grid-template-columns: minmax(0, 1fr);\n grid-template-rows: minmax(120px, 30vh) minmax(0, 1fr);\n }\n .omni-pdf__body--thumbs-collapsed {\n grid-template-rows: minmax(0, 1fr);\n }\n .omni-pdf__thumbs {\n border-right: 0;\n border-bottom: 1px solid var(--omni-border, #3c3c3c);\n }\n .omni-pdf__pages { grid-row: 2; }\n .omni-pdf__body--thumbs-collapsed .omni-pdf__pages { grid-row: 1; }\n}\n";
|