nodebb-plugin-pdf-secure 1.2.17 → 1.2.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-pdf-secure",
3
- "version": "1.2.17",
3
+ "version": "1.2.18",
4
4
  "description": "Secure PDF viewer plugin for NodeBB - prevents downloading, enables canvas-only rendering with Premium group support",
5
5
  "main": "library.js",
6
6
  "repository": {
@@ -194,7 +194,9 @@
194
194
  iframe.style.top = '0';
195
195
  iframe.style.left = '0';
196
196
  iframe.style.width = '100vw';
197
+ iframe.style.width = '100dvw'; // Override: dynamic viewport (excludes browser chrome)
197
198
  iframe.style.height = '100vh';
199
+ iframe.style.height = '100dvh'; // Override: dynamic viewport (excludes address bar on mobile)
198
200
  iframe.style.zIndex = '2147483647';
199
201
 
200
202
  // Lock body scroll
@@ -2417,12 +2417,22 @@
2417
2417
  // ERGONOMIC FEATURES
2418
2418
  // ==========================================
2419
2419
 
2420
- // Fullscreen toggle function
2420
+
2421
+ // Fullscreen state (tracks both native and simulated fullscreen)
2422
+ let isFullscreen = false;
2423
+
2424
+ // Fullscreen toggle function — delegates to parent iframe handler via postMessage
2421
2425
  function toggleFullscreen() {
2422
- if (document.fullscreenElement) {
2423
- document.exitFullscreen();
2426
+ if (window.self !== window.top) {
2427
+ // Inside iframe: ask parent to handle fullscreen
2428
+ window.parent.postMessage({ type: 'pdf-secure-fullscreen-toggle' }, '*');
2424
2429
  } else {
2425
- document.documentElement.requestFullscreen().catch(() => { });
2430
+ // Standalone mode: use native fullscreen
2431
+ if (document.fullscreenElement) {
2432
+ document.exitFullscreen();
2433
+ } else {
2434
+ document.documentElement.requestFullscreen().catch(() => { });
2435
+ }
2426
2436
  }
2427
2437
  }
2428
2438
 
@@ -2430,7 +2440,7 @@
2430
2440
  function updateFullscreenIcon() {
2431
2441
  const icon = document.getElementById('fullscreenIcon');
2432
2442
  const btn = document.getElementById('fullscreenBtn');
2433
- if (document.fullscreenElement) {
2443
+ if (isFullscreen) {
2434
2444
  icon.innerHTML = '<path d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"/>';
2435
2445
  btn.classList.add('active');
2436
2446
  } else {
@@ -2439,32 +2449,36 @@
2439
2449
  }
2440
2450
  }
2441
2451
 
2442
- document.addEventListener('fullscreenchange', updateFullscreenIcon);
2443
-
2444
- // Fullscreen button click
2445
- document.getElementById('fullscreenBtn').onclick = () => toggleFullscreen();
2452
+ // Apply fullscreen CSS class and touch restrictions
2453
+ function applyFullscreenTouchRestrictions() {
2454
+ document.body.classList.toggle('viewer-fullscreen', isFullscreen);
2455
+ if (isFullscreen) {
2456
+ document.documentElement.style.touchAction = 'pan-y pinch-zoom';
2457
+ document.documentElement.style.overscrollBehavior = 'none';
2458
+ } else {
2459
+ document.documentElement.style.touchAction = '';
2460
+ document.documentElement.style.overscrollBehavior = '';
2461
+ }
2462
+ }
2446
2463
 
2447
- // Double-click on page for fullscreen
2448
- let lastClickTime = 0;
2449
- container.addEventListener('click', (e) => {
2450
- const now = Date.now();
2451
- if (now - lastClickTime < 300) {
2452
- toggleFullscreen();
2464
+ // Listen for fullscreen state from parent (simulated fullscreen)
2465
+ window.addEventListener('message', (event) => {
2466
+ if (event.data && event.data.type === 'pdf-secure-fullscreen-state') {
2467
+ isFullscreen = event.data.isFullscreen;
2468
+ updateFullscreenIcon();
2469
+ applyFullscreenTouchRestrictions();
2453
2470
  }
2454
- lastClickTime = now;
2455
2471
  });
2456
2472
 
2457
- // Auto-fullscreen when viewer loads inside iframe
2458
- if (window.self !== window.top && window.PDF_SECURE_CONFIG) {
2459
- // We're inside an iframe - request fullscreen on first user interaction
2460
- const autoFullscreen = () => {
2461
- document.documentElement.requestFullscreen().catch(() => { });
2462
- container.removeEventListener('click', autoFullscreen);
2463
- container.removeEventListener('touchstart', autoFullscreen);
2464
- };
2465
- container.addEventListener('click', autoFullscreen, { once: true });
2466
- container.addEventListener('touchstart', autoFullscreen, { once: true });
2467
- }
2473
+ // Local fullscreen events (standalone mode)
2474
+ document.addEventListener('fullscreenchange', () => {
2475
+ isFullscreen = !!(document.fullscreenElement || document.webkitFullscreenElement);
2476
+ updateFullscreenIcon();
2477
+ applyFullscreenTouchRestrictions();
2478
+ });
2479
+
2480
+ document.getElementById('fullscreenBtn').onclick = () => toggleFullscreen();
2481
+
2468
2482
 
2469
2483
  // Mouse wheel zoom with Ctrl (debounced, clamped 0.5x-5x)
2470
2484
  let zoomTimeout;
package/static/viewer.css CHANGED
@@ -1482,3 +1482,15 @@ body {
1482
1482
  height: 56px;
1483
1483
  }
1484
1484
  }
1485
+
1486
+ /* ==========================================
1487
+ FULLSCREEN STATE (simulated fullscreen on mobile)
1488
+ ========================================== */
1489
+ /* Ensure bottom toolbar is visible and viewer container makes room for it */
1490
+ body.viewer-fullscreen #bottomToolbar {
1491
+ display: block;
1492
+ }
1493
+
1494
+ body.viewer-fullscreen #viewerContainer {
1495
+ bottom: calc(var(--bottom-bar-height) + var(--safe-area-bottom));
1496
+ }
@@ -1353,6 +1353,18 @@
1353
1353
  }
1354
1354
  }
1355
1355
 
1356
+ /* ==========================================
1357
+ FULLSCREEN STATE (simulated fullscreen on mobile)
1358
+ ========================================== */
1359
+ /* Ensure bottom toolbar is visible and viewer container makes room for it */
1360
+ body.viewer-fullscreen #bottomToolbar {
1361
+ display: block;
1362
+ }
1363
+
1364
+ body.viewer-fullscreen #viewerContainer {
1365
+ bottom: calc(var(--bottom-bar-height) + var(--safe-area-bottom));
1366
+ }
1367
+
1356
1368
  /* ==========================================
1357
1369
  TABLET BREAKPOINT (600px - 1024px)
1358
1370
  ========================================== */
@@ -4463,6 +4475,7 @@
4463
4475
 
4464
4476
  // Apply touch restrictions when entering/exiting fullscreen
4465
4477
  function applyFullscreenTouchRestrictions() {
4478
+ document.body.classList.toggle('viewer-fullscreen', isFullscreen);
4466
4479
  if (isFullscreen) {
4467
4480
  document.documentElement.style.touchAction = 'pan-y pinch-zoom';
4468
4481
  document.documentElement.style.overscrollBehavior = 'none';