@bebranded/bb-contents 1.0.119 → 1.0.120
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 +29 -6
- 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.120
|
|
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.120');
|
|
36
36
|
|
|
37
37
|
// Configuration
|
|
38
38
|
const config = {
|
|
39
|
-
version: '1.0.
|
|
39
|
+
version: '1.0.120',
|
|
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,37 @@
|
|
|
1139
1139
|
}
|
|
1140
1140
|
|
|
1141
1141
|
// Comportement par défaut : analyser le contenu de la page actuelle
|
|
1142
|
-
let sourceNode =
|
|
1142
|
+
let sourceNode = null;
|
|
1143
|
+
|
|
1143
1144
|
if (targetSelector) {
|
|
1144
|
-
|
|
1145
|
-
if (
|
|
1145
|
+
sourceNode = document.querySelector(targetSelector);
|
|
1146
|
+
if (!sourceNode) {
|
|
1147
|
+
console.warn('bb-reading-time: sélecteur non trouvé:', targetSelector);
|
|
1148
|
+
sourceNode = element;
|
|
1149
|
+
}
|
|
1150
|
+
} else {
|
|
1151
|
+
sourceNode = element;
|
|
1146
1152
|
}
|
|
1147
1153
|
|
|
1148
1154
|
const text = (sourceNode.textContent || '').trim();
|
|
1149
1155
|
const images = sourceNode.querySelectorAll('img');
|
|
1156
|
+
|
|
1157
|
+
// Debug pour comprendre le problème
|
|
1158
|
+
const wordCount = text ? text.trim().split(/\s+/).filter(function(word) { return word.length > 0; }).length : 0;
|
|
1159
|
+
console.log('bb-reading-time DEBUG:', {
|
|
1160
|
+
selector: targetSelector,
|
|
1161
|
+
sourceNodeFound: !!sourceNode,
|
|
1162
|
+
sourceNodeTag: sourceNode ? sourceNode.tagName : 'null',
|
|
1163
|
+
sourceNodeClass: sourceNode ? (sourceNode.className || sourceNode.id || 'no class/id') : 'null',
|
|
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))
|
|
1171
|
+
});
|
|
1172
|
+
|
|
1150
1173
|
const minutes = self.calculateReadingTime(text, images, wordsPerMinute, secondsPerImage);
|
|
1151
1174
|
|
|
1152
1175
|
const output = format.replace('{minutes}', String(minutes));
|