nodebb-plugin-pdf-secure 1.1.1 → 1.1.3

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.1.1",
3
+ "version": "1.1.3",
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": {
@@ -41,7 +41,7 @@ console.log('[PDF-Secure] main.js loaded');
41
41
  header.innerHTML =
42
42
  '<div class="pdf-secure-embed-title">' +
43
43
  '<svg viewBox="0 0 24 24"><path d="M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z" fill="currentColor"/></svg>' +
44
- '<span>' + escapeHtml(link.textContent || filename) + '</span>' +
44
+ '<span>' + escapeHtml(decodeURIComponent(link.textContent || filename)) + '</span>' +
45
45
  '</div>' +
46
46
  '<div class="pdf-secure-embed-actions">' +
47
47
  '<button class="pdf-secure-fullscreen-btn" title="Tam Ekran">' +
@@ -75,7 +75,56 @@ console.log('[PDF-Secure] main.js loaded');
75
75
  }
76
76
  });
77
77
 
78
- link.replaceWith(container);
78
+ // Check for NodeBB upload container and replace it instead of just the link
79
+ var uploadContainer = link.closest('.upload-container, .uploaded-file, .attachment, [data-upload], .img-responsive');
80
+ var nodebbPreview = link.closest('p, div');
81
+
82
+ // Also look for sibling image/icon that NodeBB might show
83
+ var prevSibling = link.previousElementSibling;
84
+ var parentParagraph = link.parentElement;
85
+
86
+ // If the link is inside a paragraph with just the link and maybe an icon, replace the whole paragraph
87
+ if (parentParagraph && parentParagraph.tagName === 'P') {
88
+ var textContent = parentParagraph.textContent.trim();
89
+ var linkText = link.textContent.trim();
90
+ // If paragraph only contains the link text (maybe with some whitespace), replace the whole paragraph
91
+ if (textContent === linkText || textContent === filename || textContent === decodeURIComponent(filename)) {
92
+ parentParagraph.replaceWith(container);
93
+ return;
94
+ }
95
+ }
96
+
97
+ // Hide any preceding SVG or image that looks like a file icon
98
+ if (prevSibling && (prevSibling.tagName === 'SVG' || prevSibling.tagName === 'IMG' || prevSibling.classList.contains('file-icon'))) {
99
+ prevSibling.style.display = 'none';
100
+ }
101
+
102
+ // If there's an upload container, replace it entirely
103
+ if (uploadContainer) {
104
+ uploadContainer.replaceWith(container);
105
+ } else {
106
+ link.replaceWith(container);
107
+ }
108
+ });
109
+ });
110
+
111
+ // Also hide any remaining large file preview icons that NodeBB might render
112
+ postContents.forEach(function (content) {
113
+ // Hide default NodeBB file preview containers for PDFs
114
+ var fileIcons = content.querySelectorAll('img[src*=".pdf"], svg.file-icon, .file-preview');
115
+ fileIcons.forEach(function (icon) {
116
+ // Check if this is near a pdf-secure-embed
117
+ var nearEmbed = icon.closest('.pdf-secure-embed');
118
+ if (!nearEmbed) {
119
+ // Check if there's a pdf-secure-embed nearby
120
+ var parent = icon.parentElement;
121
+ if (parent) {
122
+ var siblingEmbed = parent.querySelector('.pdf-secure-embed');
123
+ if (siblingEmbed) {
124
+ icon.style.display = 'none';
125
+ }
126
+ }
127
+ }
79
128
  });
80
129
  });
81
130
  }
package/static/style.less CHANGED
@@ -1,5 +1,21 @@
1
1
  /* PDF Secure Viewer — Inline Embed Styles for NodeBB */
2
2
 
3
+ /* AGGRESSIVE: Hide NodeBB's large file preview SVG icons */
4
+ [component="post/content"]>p>svg,
5
+ [component="post/content"]>svg,
6
+ [component="post/content"] svg[viewBox="0 0 24 24"]:not(.pdf-secure-embed svg) {
7
+ display: none !important;
8
+ }
9
+
10
+ /* Hide any standalone large SVG that looks like a file icon */
11
+ [component="post/content"]>p:has(svg[viewBox]) {
12
+
13
+ /* If paragraph only contains an SVG, hide the whole paragraph */
14
+ &:not(:has(.pdf-secure-embed)):not(:has(a)):not(:has(span)):not(:has(img)) {
15
+ display: none !important;
16
+ }
17
+ }
18
+
3
19
  /* Embedded PDF Container */
4
20
  .pdf-secure-embed {
5
21
  margin: 16px 0;
@@ -34,6 +50,8 @@
34
50
  height: 20px;
35
51
  fill: #e81224;
36
52
  flex-shrink: 0;
53
+ /* Make sure our header icon is visible */
54
+ display: inline-block !important;
37
55
  }
38
56
 
39
57
  .pdf-secure-embed-title span {
@@ -69,6 +87,7 @@
69
87
  width: 18px;
70
88
  height: 18px;
71
89
  fill: #fff;
90
+ display: inline-block !important;
72
91
  }
73
92
 
74
93
  /* Viewer Body */