@sequent-org/moodboard 1.2.45 → 1.2.48

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.45",
3
+ "version": "1.2.48",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
package/src/core/index.js CHANGED
@@ -1854,6 +1854,17 @@ export class CoreMoodBoard {
1854
1854
  requestData.data = this.getBoardData();
1855
1855
  });
1856
1856
 
1857
+ // Обновляем состояние board.grid при смене сетки
1858
+ this.eventBus.on(Events.Grid.BoardDataChanged, ({ grid }) => {
1859
+ try {
1860
+ if (grid) {
1861
+ if (!this.state.state.board) this.state.state.board = {};
1862
+ this.state.state.board.grid = grid;
1863
+ this.state.markDirty();
1864
+ }
1865
+ } catch (_) {}
1866
+ });
1867
+
1857
1868
  // Обработка статуса сохранения
1858
1869
  this.eventBus.on(Events.Save.StatusChanged, (data) => {
1859
1870
  // Можно добавить UI индикатор статуса сохранения
@@ -24,19 +24,28 @@ export class CrossGrid extends BaseGrid {
24
24
  */
25
25
  createVisual() {
26
26
  const g = this.graphics;
27
- // Прозрачность задаем через graphics.alpha из BaseGrid; штрих рисуем с полным альфа
28
- g.lineStyle(this.crossLineWidth, this.color, 1);
27
+ // Прозрачность через alpha графики (как у линейной сетки)
28
+ g.alpha = this.opacity;
29
+ // Тонкие чёткие линии как у линейной сетки: alignment = 0.5
30
+ try {
31
+ g.lineStyle({ width: Math.max(0.5, this.crossLineWidth), color: this.color, alpha: 1, alignment: 0.5 });
32
+ } catch (_) {
33
+ g.lineStyle(Math.max(0.5, this.crossLineWidth), this.color, 1);
34
+ }
29
35
 
30
36
  const hs = this.crossHalfSize;
31
37
 
32
38
  for (let x = 0; x <= this.width; x += this.size) {
33
39
  for (let y = 0; y <= this.height; y += this.size) {
40
+ // Выравниваем к полу-пикселю для чётких 1px линий
41
+ const px = Math.round(x) + 0.5;
42
+ const py = Math.round(y) + 0.5;
34
43
  // Горизонтальная часть креста
35
- g.moveTo(x - hs, y);
36
- g.lineTo(x + hs, y);
44
+ g.moveTo(px - hs, py);
45
+ g.lineTo(px + hs, py);
37
46
  // Вертикальная часть креста
38
- g.moveTo(x, y - hs);
39
- g.lineTo(x, y + hs);
47
+ g.moveTo(px, py - hs);
48
+ g.lineTo(px, py + hs);
40
49
  }
41
50
  }
42
51
  }
@@ -76,19 +76,19 @@ export class GridFactory {
76
76
  },
77
77
  dot: {
78
78
  enabled: true,
79
- size: 20,
79
+ size: 30,
80
80
  color: 0x6a6aff,
81
- opacity: 0.5,
82
- dotSize: 2,
81
+ opacity: 0.7,
82
+ dotSize: 1,
83
83
  dotStyle: 'circle',
84
84
  highlightIntersections: true
85
85
  },
86
86
  cross: {
87
87
  enabled: true,
88
- size: 40,
88
+ size: 90,
89
89
  color: 0x6a6aff,
90
- opacity: 0.5,
91
- crossHalfSize: 4,
90
+ opacity: 0.3,
91
+ crossHalfSize: 30,
92
92
  crossLineWidth: 1
93
93
  }
94
94
  };
@@ -16,6 +16,19 @@ export class DataManager {
16
16
 
17
17
  // Очищаем доску перед загрузкой
18
18
  this.clearBoard();
19
+
20
+ // Восстанавливаем тип сетки и её параметры до загрузки объектов
21
+ try {
22
+ const grid = data.grid || (data.board && data.board.grid);
23
+ if (grid && grid.type) {
24
+ const payload = { type: grid.type };
25
+ const opts = grid.options || null;
26
+ if (opts && typeof opts === 'object') {
27
+ payload.options = opts;
28
+ }
29
+ this.coreMoodboard.eventBus.emit(this.coreMoodboard.Events?.UI?.GridChange || 'ui:grid:change', payload);
30
+ }
31
+ } catch (_) {}
19
32
 
20
33
  // Загружаем объекты
21
34
  if (data.objects && Array.isArray(data.objects)) {
@@ -24,31 +24,51 @@ export class BoardService {
24
24
  this.grid.updateVisual();
25
25
  this.pixi.setGrid(this.grid);
26
26
  this.eventBus.emit(Events.UI.GridCurrent, { type: 'line' });
27
+ // Сообщаем о текущих данных сетки для сохранения в boardData
28
+ try {
29
+ this.eventBus.emit(Events.Grid.BoardDataChanged, {
30
+ grid: { type: 'line', options: this.grid.serialize ? this.grid.serialize() : {} }
31
+ });
32
+ } catch (_) {}
27
33
 
28
34
  this._attachEvents();
29
35
  }
30
36
 
31
37
  _attachEvents() {
32
38
  // Смена вида сетки из UI
33
- this.eventBus.on(Events.UI.GridChange, ({ type }) => {
39
+ this.eventBus.on(Events.UI.GridChange, ({ type, options: overrideOptions }) => {
34
40
  const size = this._getCanvasSize?.() || { width: 800, height: 600 };
35
41
  if (type === 'off') {
36
42
  this.grid?.setEnabled(false);
37
43
  this.grid?.updateVisual();
38
44
  this.pixi.setGrid(this.grid);
45
+ // Обновляем сохранённые данные
46
+ try {
47
+ this.eventBus.emit(Events.Grid.BoardDataChanged, {
48
+ grid: { type: 'off', options: this.grid?.serialize ? this.grid.serialize() : {} }
49
+ });
50
+ } catch (_) {}
39
51
  return;
40
52
  }
41
- const options = {
53
+ const gridOptions = {
42
54
  ...GridFactory.getDefaultOptions(type),
43
55
  enabled: true,
44
56
  width: size.width,
45
- height: size.height
57
+ height: size.height,
58
+ // Перекрываем входящими опциями (если пришли из сохранения)
59
+ ...(overrideOptions || {})
46
60
  };
47
61
  try {
48
- this.grid = GridFactory.createGrid(type, options);
62
+ this.grid = GridFactory.createGrid(type, gridOptions);
49
63
  this.grid.updateVisual();
50
64
  this.pixi.setGrid(this.grid);
51
65
  this.eventBus.emit(Events.UI.GridCurrent, { type });
66
+ // Сообщаем об обновлении данных сетки для сохранения в boardData
67
+ try {
68
+ this.eventBus.emit(Events.Grid.BoardDataChanged, {
69
+ grid: { type, options: this.grid.serialize ? this.grid.serialize() : gridOptions }
70
+ });
71
+ } catch (_) {}
52
72
  } catch (e) {
53
73
  console.warn('Unknown grid type:', type);
54
74
  }