@sequent-org/moodboard 1.2.72 → 1.2.74

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequent-org/moodboard",
3
- "version": "1.2.72",
3
+ "version": "1.2.74",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
@@ -49,7 +49,8 @@ export class FileObject {
49
49
  fill: 0x333333,
50
50
  align: 'center',
51
51
  wordWrap: true,
52
- wordWrapWidth: this.width - 8,
52
+ breakWords: true,
53
+ wordWrapWidth: Math.max(1, this.width - 24), // горизонтальный padding 12px с каждой стороны
53
54
  lineHeight: 14,
54
55
  resolution: (typeof window !== 'undefined' && window.devicePixelRatio) ? window.devicePixelRatio : 1
55
56
  });
@@ -175,7 +176,9 @@ export class FileObject {
175
176
 
176
177
  // Иконка файла в верхней части
177
178
  const iconSize = Math.min(48, w * 0.4);
178
- const iconX = (w - iconSize) / 2;
179
+ // Центрируем фактическую ширину иконки (она рисуется как 80% от size)
180
+ const iconWidthDrawn = iconSize * 0.8;
181
+ const iconX = (w - iconWidthDrawn) / 2;
179
182
  const iconY = 16;
180
183
 
181
184
  // Определяем цвет иконки по расширению файла
@@ -236,21 +239,57 @@ export class FileObject {
236
239
 
237
240
  _updateTextPosition() {
238
241
  if (!this.fileNameText) return;
239
-
240
- // Обновляем стиль текста
241
- this.fileNameText.style.wordWrapWidth = this.width - 8;
242
+
243
+ // Обновляем стиль текста (ограничиваем по подложке и переносим слова, учитываем padding)
244
+ const sidePad = 12;
245
+ this.fileNameText.style.wordWrap = true;
246
+ this.fileNameText.style.breakWords = true;
247
+ this.fileNameText.style.wordWrapWidth = Math.max(1, this.width - sidePad * 2);
242
248
  this.fileNameText.updateText();
243
-
244
- // Позиционируем название файла
249
+
250
+ // Параметры иконки и отступов
251
+ const iconSize = Math.min(48, this.width * 0.4);
252
+ const iconY = 16;
253
+ const gapName = 8; // расстояние между иконкой и названием (уменьшено в 2 раза)
254
+ const gapSize = 6; // расстояние между названием и размером
255
+ const bottomPad = 10; // нижний внутренний отступ подложки
256
+
257
+ // Позиционируем название файла непосредственно под иконкой и по центру
245
258
  this.fileNameText.anchor.set(0.5, 0);
246
259
  this.fileNameText.x = this.width / 2;
247
- this.fileNameText.y = this.height - 40;
248
-
249
- // Позиционируем размер файла
260
+ this.fileNameText.y = iconY + iconSize + gapName;
261
+
262
+ // Позиционируем размер файла под названием
250
263
  if (this.fileSizeText) {
251
264
  this.fileSizeText.anchor.set(0.5, 0);
252
265
  this.fileSizeText.x = this.width / 2;
253
- this.fileSizeText.y = this.height - 20;
266
+ this.fileSizeText.y = this.fileNameText.y + this.fileNameText.height + gapSize;
267
+ }
268
+
269
+ // Адаптивная высота подложки: не даём текстам выходить за пределы
270
+ const contentBottom = this.fileSizeText
271
+ ? (this.fileSizeText.y + this.fileSizeText.height)
272
+ : (this.fileNameText.y + this.fileNameText.height);
273
+ const requiredHeight = Math.ceil(contentBottom + bottomPad);
274
+ if (requiredHeight > this.height) {
275
+ const previous = this.height;
276
+ this.height = requiredHeight;
277
+ // Перерисовываем фон и иконку под новую высоту
278
+ this._redraw();
279
+ // Повторно позиционируем тексты (одноразово)
280
+ if (this.height !== previous) {
281
+ // Предотвращаем возможную рекурсию: вторая установка не должна дальше менять высоту
282
+ this.fileNameText.style.wordWrapWidth = Math.max(1, this.width - 16);
283
+ this.fileNameText.updateText();
284
+ this.fileNameText.anchor.set(0.5, 0);
285
+ this.fileNameText.x = this.width / 2;
286
+ this.fileNameText.y = iconY + iconSize + gapName;
287
+ if (this.fileSizeText) {
288
+ this.fileSizeText.anchor.set(0.5, 0);
289
+ this.fileSizeText.x = this.width / 2;
290
+ this.fileSizeText.y = this.fileNameText.y + this.fileNameText.height + gapSize;
291
+ }
292
+ }
254
293
  }
255
294
  }
256
295
 
@@ -592,28 +592,31 @@ export class PlacementTool extends BaseTool {
592
592
  background.drawRect(0, 0, width, height);
593
593
  background.endFill();
594
594
 
595
- // Иконка-заглушка файла наверху
595
+ // Иконка-заглушка файла наверху (центрируем фактическую ширину)
596
596
  const icon = new PIXI.Graphics();
597
597
  const iconSize = Math.min(48, width * 0.4);
598
- const iconX = (width - iconSize) / 2;
598
+ const iconWidthDrawn = iconSize * 0.8;
599
+ const iconX = (width - iconWidthDrawn) / 2;
599
600
  const iconY = 16;
600
601
  icon.beginFill(0x6B7280, 1);
601
- icon.drawRect(iconX, iconY, iconSize * 0.8, iconSize);
602
+ icon.drawRect(iconX, iconY, iconWidthDrawn, iconSize);
602
603
  icon.endFill();
603
604
 
604
605
  // Текст названия файла
605
606
  const fileName = this.selectedFile.fileName || 'File';
606
- const displayName = fileName.length > 15 ? fileName.substring(0, 12) + '...' : fileName;
607
+ const displayName = fileName;
607
608
  const nameText = new PIXI.Text(displayName, {
608
609
  fontFamily: 'system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif',
609
610
  fontSize: 12,
610
611
  fill: 0x333333,
611
612
  align: 'center',
612
613
  wordWrap: true,
613
- wordWrapWidth: width - 8
614
+ breakWords: true,
615
+ wordWrapWidth: Math.max(1, width - 24) // padding 12px по бокам
614
616
  });
615
- nameText.x = (width - nameText.width) / 2;
616
- nameText.y = height - 40;
617
+ nameText.anchor.set(0.5, 0);
618
+ nameText.x = width / 2;
619
+ nameText.y = iconY + iconSize + 8;
617
620
 
618
621
  // Добавляем в контейнер в правильном порядке
619
622
  this.ghostContainer.addChild(shadow);