@bebranded/bb-contents 1.0.120 → 1.0.122
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 +60 -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.122
|
|
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.122');
|
|
36
36
|
|
|
37
37
|
// Configuration
|
|
38
38
|
const config = {
|
|
39
|
-
version: '1.0.
|
|
39
|
+
version: '1.0.122',
|
|
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)
|
|
@@ -310,6 +310,42 @@
|
|
|
310
310
|
|
|
311
311
|
const mainBlock = document.createElement('div');
|
|
312
312
|
mainBlock.innerHTML = originalHTML;
|
|
313
|
+
|
|
314
|
+
// Permettre le retour à la ligne pour le texte dans les items du marquee
|
|
315
|
+
// Le white-space: nowrap sur le conteneur flex empêche les items de se retourner,
|
|
316
|
+
// mais ne doit pas empêcher le texte à l'intérieur des items de faire plusieurs lignes
|
|
317
|
+
if (!isVertical) {
|
|
318
|
+
setTimeout(() => {
|
|
319
|
+
const marqueeItems = mainBlock.querySelectorAll('.bb-marquee_item, [role="listitem"]');
|
|
320
|
+
marqueeItems.forEach(item => {
|
|
321
|
+
// Préserver la largeur de l'item définie dans Webflow
|
|
322
|
+
const computedStyle = getComputedStyle(item);
|
|
323
|
+
const itemWidth = computedStyle.width;
|
|
324
|
+
if (itemWidth && itemWidth !== 'auto' && itemWidth !== '0px') {
|
|
325
|
+
item.style.minWidth = itemWidth;
|
|
326
|
+
item.style.width = itemWidth;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// Permettre le retour à la ligne pour les conteneurs de texte
|
|
330
|
+
const textContainers = item.querySelectorAll('.use-case_client, .testimonial_client-info, [class*="text"], p, span');
|
|
331
|
+
textContainers.forEach(container => {
|
|
332
|
+
const containerComputed = getComputedStyle(container);
|
|
333
|
+
// Si l'élément a une largeur définie, la préserver
|
|
334
|
+
if (containerComputed.width && containerComputed.width !== 'auto' && containerComputed.width !== '0px') {
|
|
335
|
+
container.style.width = containerComputed.width;
|
|
336
|
+
} else {
|
|
337
|
+
// Sinon, prendre 100% de la largeur du parent
|
|
338
|
+
container.style.width = '100%';
|
|
339
|
+
}
|
|
340
|
+
// Forcer le retour à la ligne
|
|
341
|
+
container.style.whiteSpace = 'normal';
|
|
342
|
+
container.style.wordWrap = 'break-word';
|
|
343
|
+
container.style.overflowWrap = 'break-word';
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
}, 0);
|
|
347
|
+
}
|
|
348
|
+
|
|
313
349
|
mainBlock.style.cssText = `
|
|
314
350
|
display: flex;
|
|
315
351
|
${isVertical ? 'flex-direction: column;' : ''}
|
|
@@ -1139,37 +1175,36 @@
|
|
|
1139
1175
|
}
|
|
1140
1176
|
|
|
1141
1177
|
// Comportement par défaut : analyser le contenu de la page actuelle
|
|
1142
|
-
let
|
|
1178
|
+
let sourceNodes = [];
|
|
1143
1179
|
|
|
1144
1180
|
if (targetSelector) {
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1181
|
+
// Utiliser querySelectorAll pour récupérer TOUS les éléments correspondants
|
|
1182
|
+
const foundNodes = document.querySelectorAll(targetSelector);
|
|
1183
|
+
if (foundNodes.length === 0) {
|
|
1184
|
+
sourceNodes = [element];
|
|
1185
|
+
} else {
|
|
1186
|
+
sourceNodes = Array.from(foundNodes);
|
|
1149
1187
|
}
|
|
1150
1188
|
} else {
|
|
1151
|
-
|
|
1189
|
+
sourceNodes = [element];
|
|
1152
1190
|
}
|
|
1153
1191
|
|
|
1154
|
-
|
|
1155
|
-
|
|
1192
|
+
// Additionner le texte et les images de tous les éléments trouvés
|
|
1193
|
+
let totalText = '';
|
|
1194
|
+
let totalImages = [];
|
|
1156
1195
|
|
|
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))
|
|
1196
|
+
sourceNodes.forEach(function(node) {
|
|
1197
|
+
const nodeText = (node.textContent || '').trim();
|
|
1198
|
+
if (nodeText) {
|
|
1199
|
+
totalText += (totalText ? ' ' : '') + nodeText;
|
|
1200
|
+
}
|
|
1201
|
+
const nodeImages = node.querySelectorAll('img');
|
|
1202
|
+
totalImages = totalImages.concat(Array.from(nodeImages));
|
|
1171
1203
|
});
|
|
1172
1204
|
|
|
1205
|
+
const text = totalText.trim();
|
|
1206
|
+
const images = totalImages;
|
|
1207
|
+
|
|
1173
1208
|
const minutes = self.calculateReadingTime(text, images, wordsPerMinute, secondsPerImage);
|
|
1174
1209
|
|
|
1175
1210
|
const output = format.replace('{minutes}', String(minutes));
|