@bebranded/bb-contents 1.0.118 → 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 +11 -10
- 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)
|
|
@@ -1059,7 +1059,8 @@
|
|
|
1059
1059
|
|
|
1060
1060
|
// Fonction pour calculer le temps de lecture
|
|
1061
1061
|
calculateReadingTime: function(text, images, wordsPerMinute, secondsPerImage) {
|
|
1062
|
-
|
|
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;
|
|
1063
1064
|
const imageCount = images ? images.length : 0;
|
|
1064
1065
|
const imageTimeInMinutes = (imageCount * secondsPerImage) / 60;
|
|
1065
1066
|
|
|
@@ -1088,15 +1089,15 @@
|
|
|
1088
1089
|
const format = bbContents._getAttr(element, 'bb-reading-time-format') || '{minutes} min';
|
|
1089
1090
|
const urlAttr = bbContents._getAttr(element, 'bb-reading-time-url');
|
|
1090
1091
|
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
// Validation des valeurs
|
|
1092
|
+
// Validation et correction des valeurs
|
|
1093
|
+
let wordsPerMinute = Number(speedAttr);
|
|
1095
1094
|
if (isNaN(wordsPerMinute) || wordsPerMinute <= 0) {
|
|
1096
|
-
|
|
1095
|
+
wordsPerMinute = 230;
|
|
1097
1096
|
}
|
|
1097
|
+
|
|
1098
|
+
let secondsPerImage = Number(imageSpeedAttr);
|
|
1098
1099
|
if (isNaN(secondsPerImage) || secondsPerImage < 0) {
|
|
1099
|
-
|
|
1100
|
+
secondsPerImage = 12;
|
|
1100
1101
|
}
|
|
1101
1102
|
|
|
1102
1103
|
// Détecter l'URL : priorité 1 = lien parent, priorité 2 = attribut
|