nodebb-plugin-pdf-secure 1.1.0 → 1.1.1
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 +1 -1
- package/static/lib/main.js +41 -21
- package/static/style.less +73 -82
package/package.json
CHANGED
package/static/lib/main.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
console.log('[PDF-Secure] main.js loaded');
|
|
4
4
|
|
|
5
|
-
// Main plugin logic - PDF links
|
|
5
|
+
// Main plugin logic - PDF links become inline embedded viewers
|
|
6
6
|
(async function () {
|
|
7
7
|
try {
|
|
8
8
|
var hooks = await app.require('hooks');
|
|
@@ -19,7 +19,7 @@ console.log('[PDF-Secure] main.js loaded');
|
|
|
19
19
|
function interceptPdfLinks() {
|
|
20
20
|
var postContents = document.querySelectorAll('[component="post/content"]');
|
|
21
21
|
|
|
22
|
-
postContents.forEach(function (content
|
|
22
|
+
postContents.forEach(function (content) {
|
|
23
23
|
var pdfLinks = content.querySelectorAll('a[href$=".pdf"], a[href$=".PDF"]');
|
|
24
24
|
|
|
25
25
|
pdfLinks.forEach(function (link) {
|
|
@@ -29,30 +29,50 @@ console.log('[PDF-Secure] main.js loaded');
|
|
|
29
29
|
var href = link.getAttribute('href');
|
|
30
30
|
var parts = href.split('/');
|
|
31
31
|
var filename = parts[parts.length - 1];
|
|
32
|
-
console.log('[PDF-Secure]
|
|
32
|
+
console.log('[PDF-Secure] Embedding:', filename);
|
|
33
33
|
|
|
34
|
-
// Create
|
|
34
|
+
// Create inline viewer container
|
|
35
35
|
var container = document.createElement('div');
|
|
36
|
-
container.className = 'pdf-secure-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
container.className = 'pdf-secure-embed';
|
|
37
|
+
|
|
38
|
+
// Header with filename
|
|
39
|
+
var header = document.createElement('div');
|
|
40
|
+
header.className = 'pdf-secure-embed-header';
|
|
41
|
+
header.innerHTML =
|
|
42
|
+
'<div class="pdf-secure-embed-title">' +
|
|
39
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>' +
|
|
40
45
|
'</div>' +
|
|
41
|
-
'<div class="pdf-secure-
|
|
42
|
-
'<
|
|
43
|
-
'<
|
|
44
|
-
'</
|
|
45
|
-
'
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
'<div class="pdf-secure-embed-actions">' +
|
|
47
|
+
'<button class="pdf-secure-fullscreen-btn" title="Tam Ekran">' +
|
|
48
|
+
'<svg viewBox="0 0 24 24"><path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" fill="currentColor"/></svg>' +
|
|
49
|
+
'</button>' +
|
|
50
|
+
'</div>';
|
|
51
|
+
container.appendChild(header);
|
|
52
|
+
|
|
53
|
+
// Iframe for viewer
|
|
54
|
+
var iframeWrapper = document.createElement('div');
|
|
55
|
+
iframeWrapper.className = 'pdf-secure-embed-body';
|
|
56
|
+
|
|
57
|
+
var iframe = document.createElement('iframe');
|
|
58
|
+
iframe.className = 'pdf-secure-iframe';
|
|
59
|
+
iframe.src = config.relative_path + '/plugins/pdf-secure/viewer?file=' + encodeURIComponent(filename);
|
|
60
|
+
iframe.setAttribute('frameborder', '0');
|
|
61
|
+
iframe.setAttribute('allowfullscreen', 'true');
|
|
62
|
+
iframe.setAttribute('loading', 'lazy');
|
|
63
|
+
|
|
64
|
+
iframeWrapper.appendChild(iframe);
|
|
65
|
+
container.appendChild(iframeWrapper);
|
|
49
66
|
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
67
|
+
// Fullscreen button handler
|
|
68
|
+
header.querySelector('.pdf-secure-fullscreen-btn').addEventListener('click', function () {
|
|
69
|
+
if (iframe.requestFullscreen) {
|
|
70
|
+
iframe.requestFullscreen();
|
|
71
|
+
} else if (iframe.webkitRequestFullscreen) {
|
|
72
|
+
iframe.webkitRequestFullscreen();
|
|
73
|
+
} else if (iframe.msRequestFullscreen) {
|
|
74
|
+
iframe.msRequestFullscreen();
|
|
75
|
+
}
|
|
56
76
|
});
|
|
57
77
|
|
|
58
78
|
link.replaceWith(container);
|
package/static/style.less
CHANGED
|
@@ -1,132 +1,123 @@
|
|
|
1
|
-
/* PDF Secure Viewer —
|
|
1
|
+
/* PDF Secure Viewer — Inline Embed Styles for NodeBB */
|
|
2
2
|
|
|
3
|
-
/* PDF
|
|
4
|
-
.pdf-secure-
|
|
5
|
-
|
|
6
|
-
align-items: center;
|
|
7
|
-
gap: 12px;
|
|
8
|
-
padding: 12px 16px;
|
|
9
|
-
margin: 12px 0;
|
|
10
|
-
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
|
11
|
-
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
3
|
+
/* Embedded PDF Container */
|
|
4
|
+
.pdf-secure-embed {
|
|
5
|
+
margin: 16px 0;
|
|
12
6
|
border-radius: 12px;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
.pdf-secure-card:hover {
|
|
18
|
-
transform: translateY(-2px);
|
|
19
|
-
box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
background: #1f1f1f;
|
|
9
|
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
10
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
|
|
20
11
|
}
|
|
21
12
|
|
|
22
|
-
|
|
13
|
+
/* Header */
|
|
14
|
+
.pdf-secure-embed-header {
|
|
23
15
|
display: flex;
|
|
24
16
|
align-items: center;
|
|
25
|
-
justify-content:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
border-radius: 10px;
|
|
30
|
-
flex-shrink: 0;
|
|
17
|
+
justify-content: space-between;
|
|
18
|
+
padding: 10px 16px;
|
|
19
|
+
background: linear-gradient(135deg, #2d2d2d 0%, #252525 100%);
|
|
20
|
+
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
|
31
21
|
}
|
|
32
22
|
|
|
33
|
-
.pdf-secure-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
.pdf-secure-embed-title {
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
gap: 10px;
|
|
27
|
+
color: #fff;
|
|
28
|
+
font-size: 14px;
|
|
29
|
+
font-weight: 500;
|
|
37
30
|
}
|
|
38
31
|
|
|
39
|
-
.pdf-secure-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
flex:
|
|
44
|
-
min-width: 0;
|
|
32
|
+
.pdf-secure-embed-title svg {
|
|
33
|
+
width: 20px;
|
|
34
|
+
height: 20px;
|
|
35
|
+
fill: #e81224;
|
|
36
|
+
flex-shrink: 0;
|
|
45
37
|
}
|
|
46
38
|
|
|
47
|
-
.pdf-secure-
|
|
48
|
-
font-size: 14px;
|
|
49
|
-
font-weight: 600;
|
|
50
|
-
color: #fff;
|
|
39
|
+
.pdf-secure-embed-title span {
|
|
51
40
|
white-space: nowrap;
|
|
52
41
|
overflow: hidden;
|
|
53
42
|
text-overflow: ellipsis;
|
|
43
|
+
max-width: 400px;
|
|
54
44
|
}
|
|
55
45
|
|
|
56
|
-
.pdf-secure-
|
|
57
|
-
|
|
58
|
-
|
|
46
|
+
.pdf-secure-embed-actions {
|
|
47
|
+
display: flex;
|
|
48
|
+
gap: 8px;
|
|
59
49
|
}
|
|
60
50
|
|
|
61
|
-
.pdf-secure-
|
|
51
|
+
.pdf-secure-fullscreen-btn {
|
|
62
52
|
display: flex;
|
|
63
53
|
align-items: center;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
54
|
+
justify-content: center;
|
|
55
|
+
width: 32px;
|
|
56
|
+
height: 32px;
|
|
57
|
+
background: rgba(255, 255, 255, 0.08);
|
|
67
58
|
border: none;
|
|
68
|
-
border-radius:
|
|
69
|
-
color: #fff;
|
|
70
|
-
font-size: 13px;
|
|
71
|
-
font-weight: 600;
|
|
59
|
+
border-radius: 6px;
|
|
72
60
|
cursor: pointer;
|
|
73
61
|
transition: all 0.2s;
|
|
74
|
-
flex-shrink: 0;
|
|
75
62
|
}
|
|
76
63
|
|
|
77
|
-
.pdf-secure-
|
|
78
|
-
background:
|
|
79
|
-
transform: scale(1.02);
|
|
64
|
+
.pdf-secure-fullscreen-btn:hover {
|
|
65
|
+
background: rgba(255, 255, 255, 0.15);
|
|
80
66
|
}
|
|
81
67
|
|
|
82
|
-
.pdf-secure-
|
|
83
|
-
transform: scale(0.98);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.pdf-secure-card-btn svg {
|
|
68
|
+
.pdf-secure-fullscreen-btn svg {
|
|
87
69
|
width: 18px;
|
|
88
70
|
height: 18px;
|
|
89
|
-
fill:
|
|
71
|
+
fill: #fff;
|
|
90
72
|
}
|
|
91
73
|
|
|
92
|
-
/*
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
74
|
+
/* Viewer Body */
|
|
75
|
+
.pdf-secure-embed-body {
|
|
76
|
+
position: relative;
|
|
77
|
+
width: 100%;
|
|
78
|
+
height: 600px;
|
|
79
|
+
background: #525659;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.pdf-secure-iframe {
|
|
83
|
+
width: 100%;
|
|
84
|
+
height: 100%;
|
|
85
|
+
border: none;
|
|
86
|
+
display: block;
|
|
87
|
+
}
|
|
98
88
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
89
|
+
/* Responsive */
|
|
90
|
+
@media (max-width: 768px) {
|
|
91
|
+
.pdf-secure-embed-body {
|
|
92
|
+
height: 450px;
|
|
102
93
|
}
|
|
103
94
|
|
|
104
|
-
.pdf-secure-
|
|
105
|
-
width:
|
|
106
|
-
height: 22px;
|
|
95
|
+
.pdf-secure-embed-title span {
|
|
96
|
+
max-width: 200px;
|
|
107
97
|
}
|
|
98
|
+
}
|
|
108
99
|
|
|
109
|
-
|
|
110
|
-
|
|
100
|
+
@media (max-width: 480px) {
|
|
101
|
+
.pdf-secure-embed-body {
|
|
102
|
+
height: 350px;
|
|
111
103
|
}
|
|
112
104
|
|
|
113
|
-
.pdf-secure-
|
|
114
|
-
padding: 8px
|
|
115
|
-
font-size: 12px;
|
|
105
|
+
.pdf-secure-embed-header {
|
|
106
|
+
padding: 8px 12px;
|
|
116
107
|
}
|
|
117
108
|
|
|
118
|
-
.pdf-secure-
|
|
119
|
-
|
|
109
|
+
.pdf-secure-embed-title {
|
|
110
|
+
font-size: 13px;
|
|
120
111
|
}
|
|
121
112
|
|
|
122
|
-
.pdf-secure-
|
|
123
|
-
|
|
113
|
+
.pdf-secure-embed-title span {
|
|
114
|
+
max-width: 150px;
|
|
124
115
|
}
|
|
125
116
|
}
|
|
126
117
|
|
|
127
|
-
/* Anti-print
|
|
118
|
+
/* Anti-print */
|
|
128
119
|
@media print {
|
|
129
|
-
.pdf-secure-
|
|
120
|
+
.pdf-secure-embed {
|
|
130
121
|
display: none !important;
|
|
131
122
|
}
|
|
132
123
|
}
|