@bebranded/bb-contents 1.0.119 → 1.0.121
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 +30 -8
- 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.121
|
|
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.121');
|
|
36
36
|
|
|
37
37
|
// Configuration
|
|
38
38
|
const config = {
|
|
39
|
-
version: '1.0.
|
|
39
|
+
version: '1.0.121',
|
|
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)
|
|
@@ -1139,14 +1139,36 @@
|
|
|
1139
1139
|
}
|
|
1140
1140
|
|
|
1141
1141
|
// Comportement par défaut : analyser le contenu de la page actuelle
|
|
1142
|
-
let
|
|
1142
|
+
let sourceNodes = [];
|
|
1143
|
+
|
|
1143
1144
|
if (targetSelector) {
|
|
1144
|
-
|
|
1145
|
-
|
|
1145
|
+
// Utiliser querySelectorAll pour récupérer TOUS les éléments correspondants
|
|
1146
|
+
const foundNodes = document.querySelectorAll(targetSelector);
|
|
1147
|
+
if (foundNodes.length === 0) {
|
|
1148
|
+
sourceNodes = [element];
|
|
1149
|
+
} else {
|
|
1150
|
+
sourceNodes = Array.from(foundNodes);
|
|
1151
|
+
}
|
|
1152
|
+
} else {
|
|
1153
|
+
sourceNodes = [element];
|
|
1146
1154
|
}
|
|
1147
1155
|
|
|
1148
|
-
|
|
1149
|
-
|
|
1156
|
+
// Additionner le texte et les images de tous les éléments trouvés
|
|
1157
|
+
let totalText = '';
|
|
1158
|
+
let totalImages = [];
|
|
1159
|
+
|
|
1160
|
+
sourceNodes.forEach(function(node) {
|
|
1161
|
+
const nodeText = (node.textContent || '').trim();
|
|
1162
|
+
if (nodeText) {
|
|
1163
|
+
totalText += (totalText ? ' ' : '') + nodeText;
|
|
1164
|
+
}
|
|
1165
|
+
const nodeImages = node.querySelectorAll('img');
|
|
1166
|
+
totalImages = totalImages.concat(Array.from(nodeImages));
|
|
1167
|
+
});
|
|
1168
|
+
|
|
1169
|
+
const text = totalText.trim();
|
|
1170
|
+
const images = totalImages;
|
|
1171
|
+
|
|
1150
1172
|
const minutes = self.calculateReadingTime(text, images, wordsPerMinute, secondsPerImage);
|
|
1151
1173
|
|
|
1152
1174
|
const output = format.replace('{minutes}', String(minutes));
|