nodebb-plugin-pdf-secure 1.2.16 → 1.2.17

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 (2) hide show
  1. package/package.json +1 -1
  2. package/static/viewer.html +21 -46
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-pdf-secure",
3
- "version": "1.2.16",
3
+ "version": "1.2.17",
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": {
@@ -2708,63 +2708,29 @@
2708
2708
 
2709
2709
  svg.addEventListener('touchstart', (e) => {
2710
2710
  if (!currentTool || e.touches.length !== 1) return;
2711
-
2712
- // Eraser and select need immediate response
2713
- if (currentTool === 'eraser' || currentTool === 'select') {
2714
- e.preventDefault();
2715
- startDraw(e, pageNum);
2716
- touchDrawing = true;
2717
- touchDrawDecided = true;
2718
- return;
2719
- }
2720
-
2721
- // For pen/highlight/shape: wait to decide scroll vs draw
2722
- touchDrawDecided = false;
2723
- touchDrawing = false;
2711
+ // In annotation mode, always draw immediately — no direction detection.
2712
+ // Pan and pinch-zoom are blocked at the container level when a tool is active.
2713
+ e.preventDefault();
2724
2714
  touchStartX = e.touches[0].clientX;
2725
2715
  touchStartYDraw = e.touches[0].clientY;
2716
+ startDraw(e, pageNum);
2717
+ touchDrawing = true;
2718
+ touchDrawDecided = true;
2726
2719
  }, { passive: false, signal });
2727
2720
 
2728
2721
  svg.addEventListener('touchmove', (e) => {
2729
2722
  if (!currentTool || e.touches.length !== 1) return;
2730
-
2731
2723
  if (touchDrawing) {
2732
- // Already decided: drawing
2733
- e.preventDefault();
2734
- draw(e);
2735
- return;
2736
- }
2737
-
2738
- if (touchDrawDecided) return; // decided scroll, let it through
2739
-
2740
- const dx = e.touches[0].clientX - touchStartX;
2741
- const dy = e.touches[0].clientY - touchStartYDraw;
2742
-
2743
- if (Math.abs(dx) + Math.abs(dy) > 10) {
2744
- touchDrawDecided = true;
2745
-
2746
- if (Math.abs(dy) > Math.abs(dx) * 2) {
2747
- // Predominantly vertical → scroll (don't prevent default)
2748
- return;
2749
- }
2750
- // Horizontal or diagonal → drawing
2751
2724
  e.preventDefault();
2752
- // Start draw from ORIGINAL touch position (not current 10px-offset position)
2753
- const syntheticStart = {
2754
- currentTarget: svg,
2755
- touches: [{ clientX: touchStartX, clientY: touchStartYDraw }],
2756
- preventDefault: () => { }
2757
- };
2758
- startDraw(syntheticStart, pageNum);
2759
- // Then immediately draw to current position for continuity
2760
2725
  draw(e);
2761
- touchDrawing = true;
2762
2726
  }
2763
2727
  }, { passive: false, signal });
2764
2728
 
2765
2729
  svg.addEventListener('touchend', (e) => {
2766
- if (!touchDrawDecided && currentTool && currentTool !== 'eraser' && currentTool !== 'select') {
2767
- // Tap without moving > 10px → draw a dot at touch position
2730
+ if (touchDrawing) {
2731
+ stopDraw(pageNum);
2732
+ } else if (currentTool && currentTool !== 'eraser' && currentTool !== 'select') {
2733
+ // Tap without moving → draw a dot at touch position
2768
2734
  const syntheticStart = {
2769
2735
  currentTarget: svg,
2770
2736
  touches: [{ clientX: touchStartX, clientY: touchStartYDraw }],
@@ -2772,8 +2738,6 @@
2772
2738
  };
2773
2739
  startDraw(syntheticStart, pageNum);
2774
2740
  stopDraw(pageNum);
2775
- } else if (touchDrawing) {
2776
- stopDraw(pageNum);
2777
2741
  }
2778
2742
  touchDrawDecided = false;
2779
2743
  touchDrawing = false;
@@ -4651,6 +4615,11 @@
4651
4615
 
4652
4616
  container.addEventListener('touchstart', (e) => {
4653
4617
  if (e.touches.length === 2) {
4618
+ // Block pinch-zoom when an annotation tool is active
4619
+ if (annotationMode && currentTool) {
4620
+ e.preventDefault();
4621
+ return;
4622
+ }
4654
4623
  // Cancel any active drawing and clean up
4655
4624
  if (isDrawing && currentDrawingPage) {
4656
4625
  const savePage = currentDrawingPage;
@@ -4816,6 +4785,12 @@
4816
4785
  container.addEventListener('touchmove', (e) => {
4817
4786
  if (isPinching || e.touches.length !== 1) return;
4818
4787
 
4788
+ // Block all container scroll when an annotation tool is active
4789
+ if (annotationMode && currentTool) {
4790
+ e.preventDefault();
4791
+ return;
4792
+ }
4793
+
4819
4794
  const touchY = e.touches[0].clientY;
4820
4795
  const deltaY = touchStartY - touchY; // positive = scrolling down
4821
4796