vanduo-framework 1.1.8 → 1.2.0
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/README.md +42 -31
- package/dist/build-info.json +3 -3
- package/dist/vanduo.cjs.js +720 -111
- package/dist/vanduo.cjs.js.map +3 -3
- package/dist/vanduo.cjs.min.js +11 -11
- package/dist/vanduo.cjs.min.js.map +3 -3
- package/dist/vanduo.css +285 -1
- package/dist/vanduo.css.map +1 -1
- package/dist/vanduo.esm.js +720 -111
- package/dist/vanduo.esm.js.map +3 -3
- package/dist/vanduo.esm.min.js +11 -11
- package/dist/vanduo.esm.min.js.map +3 -3
- package/dist/vanduo.js +720 -111
- package/dist/vanduo.js.map +3 -3
- package/dist/vanduo.min.css +1 -1
- package/dist/vanduo.min.js +11 -11
- package/dist/vanduo.min.js.map +3 -3
- package/js/components/code-snippet.js +5 -3
- package/js/components/doc-search.js +90 -73
- package/js/components/grid.js +22 -22
- package/js/components/theme-customizer.js +20 -4
- package/js/components/tooltips.js +1 -1
- package/js/utils/helpers.js +24 -12
- package/js/vanduo.js +7 -7
- package/package.json +1 -1
package/js/utils/helpers.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Vanduo Framework - Utility Helpers
|
|
3
5
|
* Common utility functions used across the framework
|
|
@@ -86,7 +88,11 @@ function on(target, event, handlerOrSelector, handler) {
|
|
|
86
88
|
element.addEventListener(event, function (e) {
|
|
87
89
|
const delegateTarget = e.target.closest(handlerOrSelector);
|
|
88
90
|
if (delegateTarget && element.contains(delegateTarget)) {
|
|
89
|
-
|
|
91
|
+
try {
|
|
92
|
+
handler.call(delegateTarget, e);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.warn('[Vanduo Helpers] Delegated handler error:', error);
|
|
95
|
+
}
|
|
90
96
|
}
|
|
91
97
|
});
|
|
92
98
|
}
|
|
@@ -238,7 +244,7 @@ function getPosition(element) {
|
|
|
238
244
|
*/
|
|
239
245
|
function escapeHtml(str) {
|
|
240
246
|
if (!str) return '';
|
|
241
|
-
|
|
247
|
+
const div = document.createElement('div');
|
|
242
248
|
div.appendChild(document.createTextNode(str));
|
|
243
249
|
return div.innerHTML;
|
|
244
250
|
}
|
|
@@ -252,24 +258,30 @@ function escapeHtml(str) {
|
|
|
252
258
|
*/
|
|
253
259
|
function sanitizeHtml(input) {
|
|
254
260
|
if (!input) return '';
|
|
255
|
-
|
|
256
|
-
|
|
261
|
+
let doc;
|
|
262
|
+
try {
|
|
263
|
+
doc = new DOMParser().parseFromString(input, 'text/html');
|
|
264
|
+
} catch (_error) {
|
|
265
|
+
// Fail closed to plain escaped text if parser is unavailable/fails.
|
|
266
|
+
return escapeHtml(input);
|
|
267
|
+
}
|
|
268
|
+
const allowed = ['B', 'STRONG', 'I', 'EM', 'BR', 'A', 'SPAN', 'U', 'SVG', 'PATH', 'LINE', 'CIRCLE', 'POLYLINE', 'RECT', 'G'];
|
|
257
269
|
|
|
258
|
-
|
|
259
|
-
|
|
270
|
+
const sanitizeNode = function (node) {
|
|
271
|
+
const children = Array.from(node.childNodes);
|
|
260
272
|
children.forEach(function (child) {
|
|
261
273
|
if (child.nodeType === Node.TEXT_NODE) return;
|
|
262
274
|
|
|
263
275
|
if (!allowed.includes(child.nodeName)) {
|
|
264
|
-
|
|
276
|
+
const text = document.createTextNode(child.textContent);
|
|
265
277
|
node.replaceChild(text, child);
|
|
266
278
|
return;
|
|
267
279
|
}
|
|
268
280
|
|
|
269
281
|
if (child.nodeName === 'A') {
|
|
270
|
-
|
|
282
|
+
const href = child.getAttribute('href') || '';
|
|
271
283
|
try {
|
|
272
|
-
|
|
284
|
+
const url = new URL(href, location.href);
|
|
273
285
|
if (!['http:', 'https:', 'mailto:'].includes(url.protocol)) {
|
|
274
286
|
child.removeAttribute('href');
|
|
275
287
|
}
|
|
@@ -280,17 +292,17 @@ function sanitizeHtml(input) {
|
|
|
280
292
|
child.removeAttribute('rel');
|
|
281
293
|
} else if (child.nodeName === 'SVG' || child.closest && child.closest('svg')) {
|
|
282
294
|
// Allow safe SVG presentation attributes only
|
|
283
|
-
|
|
295
|
+
const safeSvgAttrs = ['xmlns', 'width', 'height', 'viewBox', 'fill', 'stroke', 'stroke-width',
|
|
284
296
|
'stroke-linecap', 'stroke-linejoin', 'd', 'cx', 'cy', 'r', 'x1', 'y1', 'x2', 'y2', 'points',
|
|
285
297
|
'transform', 'class'];
|
|
286
|
-
|
|
298
|
+
const attrs = Array.from(child.attributes || []);
|
|
287
299
|
attrs.forEach(function (a) {
|
|
288
300
|
if (!safeSvgAttrs.includes(a.name)) {
|
|
289
301
|
child.removeAttribute(a.name);
|
|
290
302
|
}
|
|
291
303
|
});
|
|
292
304
|
} else {
|
|
293
|
-
|
|
305
|
+
const otherAttrs = Array.from(child.attributes || []);
|
|
294
306
|
otherAttrs.forEach(function (a) { child.removeAttribute(a.name); });
|
|
295
307
|
}
|
|
296
308
|
|
package/js/vanduo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Vanduo Framework - Main JavaScript File
|
|
3
|
-
* v1.
|
|
3
|
+
* v1.2.0
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
(function() {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* Vanduo Framework Object
|
|
11
11
|
*/
|
|
12
12
|
const Vanduo = {
|
|
13
|
-
version: '1.
|
|
13
|
+
version: '1.2.0',
|
|
14
14
|
components: {},
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
console.log('Vanduo Framework v1.
|
|
54
|
+
console.log('Vanduo Framework v1.2.0 initialized');
|
|
55
55
|
},
|
|
56
56
|
|
|
57
57
|
/**
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
* @param {string} name - Component name
|
|
71
71
|
*/
|
|
72
72
|
reinit: function(name) {
|
|
73
|
-
|
|
73
|
+
const component = this.components[name];
|
|
74
74
|
if (component && component.init && typeof component.init === 'function') {
|
|
75
75
|
try {
|
|
76
76
|
component.init();
|
|
@@ -86,9 +86,9 @@
|
|
|
86
86
|
*/
|
|
87
87
|
destroyAll: function() {
|
|
88
88
|
// First, destroy components that have their own destroyAll
|
|
89
|
-
|
|
90
|
-
for (
|
|
91
|
-
|
|
89
|
+
const names = Object.keys(this.components);
|
|
90
|
+
for (let i = 0; i < names.length; i++) {
|
|
91
|
+
const component = this.components[names[i]];
|
|
92
92
|
if (component && component.destroyAll && typeof component.destroyAll === 'function') {
|
|
93
93
|
try {
|
|
94
94
|
component.destroyAll();
|