@bebranded/bb-contents 1.0.120 → 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 +24 -25
- 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,37 +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
1144
|
if (targetSelector) {
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
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);
|
|
1149
1151
|
}
|
|
1150
1152
|
} else {
|
|
1151
|
-
|
|
1153
|
+
sourceNodes = [element];
|
|
1152
1154
|
}
|
|
1153
1155
|
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
+
// Additionner le texte et les images de tous les éléments trouvés
|
|
1157
|
+
let totalText = '';
|
|
1158
|
+
let totalImages = [];
|
|
1156
1159
|
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
textLength: text.length,
|
|
1165
|
-
textPreview: text.substring(0, 100) + (text.length > 100 ? '...' : ''),
|
|
1166
|
-
wordCount: wordCount,
|
|
1167
|
-
imageCount: images.length,
|
|
1168
|
-
wordsPerMinute: wordsPerMinute,
|
|
1169
|
-
secondsPerImage: secondsPerImage,
|
|
1170
|
-
calculatedMinutes: Math.ceil((wordCount / wordsPerMinute) + (images.length * secondsPerImage / 60))
|
|
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));
|
|
1171
1167
|
});
|
|
1172
1168
|
|
|
1169
|
+
const text = totalText.trim();
|
|
1170
|
+
const images = totalImages;
|
|
1171
|
+
|
|
1173
1172
|
const minutes = self.calculateReadingTime(text, images, wordsPerMinute, secondsPerImage);
|
|
1174
1173
|
|
|
1175
1174
|
const output = format.replace('{minutes}', String(minutes));
|