@bebranded/bb-contents 1.0.117 → 1.0.119
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/bb-contents.js +21 -17
- package/package.json +1 -1
package/bb-contents.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BeBranded Contents
|
|
3
3
|
* Contenus additionnels français pour Webflow
|
|
4
|
-
* @version 1.0.
|
|
4
|
+
* @version 1.0.119
|
|
5
5
|
* @author BeBranded
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @website https://www.bebranded.xyz
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
window._bbContentsInitialized = true;
|
|
33
33
|
|
|
34
34
|
// Log de démarrage simple (une seule fois)
|
|
35
|
-
console.log('bb-contents | v1.0.
|
|
35
|
+
console.log('bb-contents | v1.0.119');
|
|
36
36
|
|
|
37
37
|
// Configuration
|
|
38
38
|
const config = {
|
|
39
|
-
version: '1.0.
|
|
39
|
+
version: '1.0.119',
|
|
40
40
|
debug: false, // Debug désactivé pour rendu propre
|
|
41
41
|
prefix: 'bb-', // utilisé pour générer les sélecteurs (data-bb-*)
|
|
42
42
|
youtubeEndpoint: null, // URL du worker YouTube (à définir par l'utilisateur)
|
|
@@ -419,9 +419,7 @@
|
|
|
419
419
|
img.style.objectFit = 'contain';
|
|
420
420
|
img.style.objectPosition = 'center';
|
|
421
421
|
|
|
422
|
-
//
|
|
423
|
-
img.style.width = '100%';
|
|
424
|
-
img.style.height = '100%';
|
|
422
|
+
// Contraindre les dimensions sans forcer (max-width/max-height au lieu de width/height 100%)
|
|
425
423
|
img.style.maxWidth = '100%';
|
|
426
424
|
img.style.maxHeight = '100%';
|
|
427
425
|
img.style.boxSizing = 'border-box';
|
|
@@ -436,18 +434,23 @@
|
|
|
436
434
|
img.style.webkitTransform = 'translateZ(0)';
|
|
437
435
|
img.style.transform = 'translateZ(0)';
|
|
438
436
|
|
|
439
|
-
// Conteneur parent pour contraindre et centrer
|
|
437
|
+
// Conteneur parent pour contraindre et centrer (sans forcer les dimensions)
|
|
440
438
|
const parent = img.parentElement;
|
|
441
439
|
if (parent) {
|
|
440
|
+
// Vérifier si le parent a déjà des dimensions définies
|
|
441
|
+
const parentStyles = getComputedStyle(parent);
|
|
442
|
+
const hasParentWidth = parentStyles.width && parentStyles.width !== 'auto' && parentStyles.width !== '0px';
|
|
443
|
+
const hasParentHeight = parentStyles.height && parentStyles.height !== 'auto' && parentStyles.height !== '0px';
|
|
444
|
+
|
|
442
445
|
parent.style.display = 'flex';
|
|
443
446
|
parent.style.alignItems = 'center';
|
|
444
447
|
parent.style.justifyContent = 'center';
|
|
445
448
|
parent.style.overflow = 'hidden';
|
|
446
449
|
parent.style.boxSizing = 'border-box';
|
|
447
450
|
|
|
448
|
-
//
|
|
449
|
-
if (!parent.style.width) parent.style.width = '100%';
|
|
450
|
-
if (!parent.style.height) parent.style.height = '100%';
|
|
451
|
+
// Ne forcer les dimensions que si le parent n'en a pas déjà
|
|
452
|
+
if (!hasParentWidth && !parent.style.width) parent.style.width = '100%';
|
|
453
|
+
if (!hasParentHeight && !parent.style.height) parent.style.height = '100%';
|
|
451
454
|
}
|
|
452
455
|
} else if (isSVG && isMobile) {
|
|
453
456
|
// Pour Chrome mobile, utiliser contain normalement
|
|
@@ -1056,7 +1059,8 @@
|
|
|
1056
1059
|
|
|
1057
1060
|
// Fonction pour calculer le temps de lecture
|
|
1058
1061
|
calculateReadingTime: function(text, images, wordsPerMinute, secondsPerImage) {
|
|
1059
|
-
|
|
1062
|
+
// Utiliser split(/\s+/) pour un comptage plus fiable (comme le code de référence)
|
|
1063
|
+
const wordCount = text ? text.trim().split(/\s+/).filter(function(word) { return word.length > 0; }).length : 0;
|
|
1060
1064
|
const imageCount = images ? images.length : 0;
|
|
1061
1065
|
const imageTimeInMinutes = (imageCount * secondsPerImage) / 60;
|
|
1062
1066
|
|
|
@@ -1085,15 +1089,15 @@
|
|
|
1085
1089
|
const format = bbContents._getAttr(element, 'bb-reading-time-format') || '{minutes} min';
|
|
1086
1090
|
const urlAttr = bbContents._getAttr(element, 'bb-reading-time-url');
|
|
1087
1091
|
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
// Validation des valeurs
|
|
1092
|
+
// Validation et correction des valeurs
|
|
1093
|
+
let wordsPerMinute = Number(speedAttr);
|
|
1092
1094
|
if (isNaN(wordsPerMinute) || wordsPerMinute <= 0) {
|
|
1093
|
-
|
|
1095
|
+
wordsPerMinute = 230;
|
|
1094
1096
|
}
|
|
1097
|
+
|
|
1098
|
+
let secondsPerImage = Number(imageSpeedAttr);
|
|
1095
1099
|
if (isNaN(secondsPerImage) || secondsPerImage < 0) {
|
|
1096
|
-
|
|
1100
|
+
secondsPerImage = 12;
|
|
1097
1101
|
}
|
|
1098
1102
|
|
|
1099
1103
|
// Détecter l'URL : priorité 1 = lien parent, priorité 2 = attribut
|