@signiphi/pdf-signer 0.2.0-beta.29 → 0.2.0-beta.30

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.
@@ -37,6 +37,14 @@
37
37
  overflow: visible;
38
38
  margin: 1rem auto;
39
39
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
40
+ /* The global `* { box-sizing: border-box }` reset above must not apply
41
+ here: PDF.js sizes .page/.textLayer/.annotationLayer to the same
42
+ round(--total-scale-factor * pageWidth) value but lets the canvas
43
+ wrapper fill .page's CONTENT box. With border-box, the transparent
44
+ --page-border shrinks the canvas while the annotation layer keeps the
45
+ full size, so every widget drifts down/right proportionally
46
+ (DM-1865 field shift, DM-1864 radio labels overlapping circles). */
47
+ box-sizing: content-box;
40
48
  }
41
49
 
42
50
  /* Loading indicator */
@@ -98,14 +106,31 @@
98
106
  placed annotation stays movable/resizable throughout the whole session,
99
107
  regardless of the active editor mode. Highlights/ink are intentionally
100
108
  excluded — those flows place several in a row and don't need post-place
101
- drag/resize. Review mode re-locks the resizers below. */
102
- .annotationEditorLayer.disabled .stampEditor,
103
- .annotationEditorLayer.disabled .stampEditor *,
104
- .annotationEditorLayer.disabled .freeTextEditor,
105
- .annotationEditorLayer.disabled .freeTextEditor * {
109
+ drag/resize.
110
+
111
+ Explicitly scoped OUT of review mode (body:not(...)) rather than
112
+ relying on the review re-lock rules below out-specifying this one —
113
+ both are !important, so without the :not() guard a selector tweak on
114
+ either side could silently hand the sender resize handles over the
115
+ receiver's marks. */
116
+ body:not(.signiphi-review-mode) .annotationEditorLayer.disabled .stampEditor,
117
+ body:not(.signiphi-review-mode) .annotationEditorLayer.disabled .stampEditor *,
118
+ body:not(.signiphi-review-mode) .annotationEditorLayer.disabled .freeTextEditor,
119
+ body:not(.signiphi-review-mode) .annotationEditorLayer.disabled .freeTextEditor * {
106
120
  pointer-events: auto !important;
107
121
  }
108
122
 
123
+ /* Hide the sticky-note icons PDF.js paints for /Text annotations (baked
124
+ comment notes and threaded replies at their parent's rect). The comment
125
+ text reaches the chat panel from the thread data, and clicks route
126
+ through the editor elements — the icon is purely cosmetic here. The
127
+ /Text annots stay in the PDF so Acrobat and other external viewers
128
+ still show the comment thread. The Hidden flag (F=6) does NOT suppress
129
+ the annotationLayer icon, so CSS is the reliable switch. */
130
+ .annotationLayer .textAnnotation {
131
+ display: none !important;
132
+ }
133
+
109
134
  /* Review mode (sender viewing receiver's annotations):
110
135
  - Block pointer events on the annotation editor layer itself so clicks
111
136
  on empty areas DO NOT create new editors regardless of PDF.js mode.
@@ -122,7 +147,10 @@
122
147
  }
123
148
  body.signiphi-review-mode .annotationEditorLayer :is(
124
149
  .freeTextEditor, .inkEditor, .stampEditor, .highlightEditor, .signatureEditor
125
- ) > .resizers {
150
+ ) > .resizers,
151
+ body.signiphi-review-mode .annotationEditorLayer :is(
152
+ .freeTextEditor, .inkEditor, .stampEditor, .highlightEditor, .signatureEditor
153
+ ) > .resizers * {
126
154
  pointer-events: none !important;
127
155
  }
128
156
  </style>
@@ -178,7 +206,11 @@
178
206
 
179
207
  // Resolve the parent frame's origin once, so postMessage calls don't have
180
208
  // to use the wildcard '*' target (which would let any embedding page read
181
- // annotation payloads). Falls back to '*' only as a last resort.
209
+ // annotation payloads). The host app always embeds this viewer
210
+ // same-origin, so when neither ancestorOrigins (unsupported in Firefox)
211
+ // nor the referrer is available, fall back to our own origin — a
212
+ // cross-origin embedder then receives nothing (fail closed) instead of
213
+ // everything ('*').
182
214
  var parentOrigin = (function () {
183
215
  try {
184
216
  if (window.location.ancestorOrigins && window.location.ancestorOrigins.length) {
@@ -188,7 +220,7 @@
188
220
  return new URL(document.referrer).origin;
189
221
  }
190
222
  } catch (_) {}
191
- return '*';
223
+ return window.location.origin;
192
224
  })();
193
225
 
194
226
  // Track every MutationObserver we create so they can be disconnected on
@@ -1368,6 +1400,21 @@
1368
1400
  // include bitmapUrl. HighlightEditor.serialize returns null when
1369
1401
  // isForCopying=true, so we never call (true) for non-stamps.
1370
1402
  var data = isStamp ? editor.serialize(true) : editor.serialize(false);
1403
+ if (!data && editor.annotationElementId) {
1404
+ // An UNCHANGED editor deserialized from an existing annotation dict
1405
+ // serializes to null by design (PDF.js only serializes changes to
1406
+ // existing annotations). Return a minimal sourceOnly marker so the
1407
+ // host can link the editor to its source annotation dict without
1408
+ // mistaking this for a full serialization.
1409
+ var minRect = null;
1410
+ try { minRect = editor.getRect(0, 0); } catch (_) {}
1411
+ return {
1412
+ sourceOnly: true,
1413
+ id: editor.annotationElementId,
1414
+ pageIndex: editor.pageIndex,
1415
+ rect: minRect
1416
+ };
1417
+ }
1371
1418
  if (!data) return null;
1372
1419
  if (data.isCopy) {
1373
1420
  delete data.isCopy;
@@ -1385,6 +1432,50 @@
1385
1432
  return null;
1386
1433
  };
1387
1434
 
1435
+ // Read the markup annotations that live in the SOURCE PDF bytes (sticky
1436
+ // notes, highlights, ink, stamps authored outside this session), straight
1437
+ // from the annotation dicts — no editor mode required. Used by the host to
1438
+ // hydrate the annotation tree for documents that arrive with marks baked
1439
+ // in but no stored tree. Marks already deleted through an editor session
1440
+ // are excluded.
1441
+ window.PDFViewerApplication.getSourceMarkupAnnotations = async function() {
1442
+ var MARKUP = { Highlight: 1, FreeText: 1, Ink: 1, Stamp: 1, Text: 1 };
1443
+ var out = [];
1444
+ try {
1445
+ var doc = this.pdfDocument;
1446
+ if (!doc) return out;
1447
+ var uiManager = pdfViewer._layerProperties?.annotationEditorUIManager;
1448
+ for (var p = 1; p <= doc.numPages; p++) {
1449
+ var page = await doc.getPage(p);
1450
+ var annots = await page.getAnnotations();
1451
+ for (var i = 0; i < annots.length; i++) {
1452
+ var a = annots[i];
1453
+ if (!a || !a.id || MARKUP[a.subtype] !== 1) continue;
1454
+ if (a.hidden) continue;
1455
+ if (uiManager && typeof uiManager.isDeletedAnnotationElement === 'function' &&
1456
+ uiManager.isDeletedAnnotationElement(a.id)) continue;
1457
+ out.push({
1458
+ id: a.id,
1459
+ subtype: a.subtype,
1460
+ pageIndex: p - 1,
1461
+ rect: a.rect ? Array.from(a.rect) : null,
1462
+ contents: (a.contentsObj && a.contentsObj.str) || '',
1463
+ title: (a.titleObj && a.titleObj.str) || '',
1464
+ modificationDate: a.modificationDate || a.creationDate || null,
1465
+ color: a.color ? Array.from(a.color) : null,
1466
+ opacity: (typeof a.opacity === 'number') ? a.opacity : undefined,
1467
+ inReplyToId: a.inReplyTo || null,
1468
+ replyType: a.replyType || null,
1469
+ it: a.it || null
1470
+ });
1471
+ }
1472
+ }
1473
+ } catch (e) {
1474
+ console.warn('getSourceMarkupAnnotations failed:', e);
1475
+ }
1476
+ return out;
1477
+ };
1478
+
1388
1479
  window.PDFViewerApplication.injectAnnotationEditors = async function(serializedEditors) {
1389
1480
  if (!serializedEditors || !Array.isArray(serializedEditors)) return [];
1390
1481
 
@@ -1 +1 @@
1
- {"version":3,"file":"AnnotationToolProperties.d.ts","sourceRoot":"","sources":["../../src/components/AnnotationToolProperties.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,wBAAwB,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAkClG,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,cAAc,CAAC;IACzB,UAAU,EAAE,SAAS,CAAC;IACtB,kBAAkB,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,EACR,UAAU,EACV,kBAAkB,EAClB,SAAS,GACV,EAAE,6BAA6B,kDA6G/B"}
1
+ {"version":3,"file":"AnnotationToolProperties.d.ts","sourceRoot":"","sources":["../../src/components/AnnotationToolProperties.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,wBAAwB,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAoClG,MA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