@sequent-org/moodboard 1.2.57 → 1.2.60
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
|
@@ -223,10 +223,6 @@ export class MoodBoard {
|
|
|
223
223
|
: color;
|
|
224
224
|
if (this.coreMoodboard?.pixi?.app?.renderer) {
|
|
225
225
|
this.coreMoodboard.pixi.app.renderer.backgroundColor = hex;
|
|
226
|
-
// Сигнализируем, что настройки доски изменились (для автосохранения)
|
|
227
|
-
try {
|
|
228
|
-
this.coreMoodboard.eventBus.emit(Events.Grid.BoardDataChanged, { settings: { backgroundColor: color } });
|
|
229
|
-
} catch (_) {}
|
|
230
226
|
}
|
|
231
227
|
});
|
|
232
228
|
}
|
|
@@ -32,12 +32,7 @@ export class ZoomPanController {
|
|
|
32
32
|
world.scale.set(newScale);
|
|
33
33
|
world.x = x - worldX * newScale;
|
|
34
34
|
world.y = y - worldY * newScale;
|
|
35
|
-
|
|
36
|
-
this.eventBus.emit(Events.UI.ZoomPercent, { percentage: pct });
|
|
37
|
-
// Сигнализируем об изменении настроек (чтобы сохранить текущий зум)
|
|
38
|
-
try {
|
|
39
|
-
this.eventBus.emit(Events.Grid.BoardDataChanged, { settings: { zoom: { current: newScale, percentage: pct } } });
|
|
40
|
-
} catch (_) {}
|
|
35
|
+
this.eventBus.emit(Events.UI.ZoomPercent, { percentage: Math.round(newScale * 100) });
|
|
41
36
|
});
|
|
42
37
|
|
|
43
38
|
// Кнопки зума из UI
|
package/src/ui/Topbar.js
CHANGED
|
@@ -11,7 +11,6 @@ export class Topbar {
|
|
|
11
11
|
this.theme = theme;
|
|
12
12
|
this.element = null;
|
|
13
13
|
this._paintPopover = null;
|
|
14
|
-
this._currentBoardHex = null; // фактический цвет фона доски (#rrggbb)
|
|
15
14
|
// Загружаем иконки
|
|
16
15
|
this.iconLoader = new TopbarIconLoader();
|
|
17
16
|
this.icons = this.iconLoader.icons;
|
|
@@ -37,37 +36,26 @@ export class Topbar {
|
|
|
37
36
|
|
|
38
37
|
this.createTopbar();
|
|
39
38
|
this.attachEvents();
|
|
39
|
+
// Активируем дефолтную кнопку (line) до прихода события из ядра
|
|
40
|
+
this.setActive('line');
|
|
40
41
|
|
|
41
42
|
// Синхронизация активного состояния по событию из ядра
|
|
42
43
|
this.eventBus.on(Events.UI.GridCurrent, ({ type }) => {
|
|
43
44
|
this.setActive(type);
|
|
44
45
|
});
|
|
45
46
|
|
|
46
|
-
// Обновляем цвет кнопки "краски"
|
|
47
|
-
this.eventBus.on(Events.UI.PaintPick, ({ btnHex
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (!v) return null;
|
|
51
|
-
if (typeof v === 'number') {
|
|
52
|
-
return `#${v.toString(16).padStart(6,'0')}`.toLowerCase();
|
|
53
|
-
}
|
|
54
|
-
if (typeof v === 'string') {
|
|
55
|
-
const s = v.startsWith('#') ? v : `#${v}`;
|
|
56
|
-
return s.toLowerCase();
|
|
57
|
-
}
|
|
58
|
-
return null;
|
|
59
|
-
};
|
|
60
|
-
const boardHex = normalizeHex(color);
|
|
61
|
-
if (boardHex) this._currentBoardHex = boardHex;
|
|
62
|
-
const mapped = btnHex || this.mapBoardToBtnHex(boardHex);
|
|
63
|
-
if (mapped) this.setPaintButtonHex(mapped);
|
|
47
|
+
// Обновляем цвет кнопки "краски" при выборе цвета фона
|
|
48
|
+
this.eventBus.on(Events.UI.PaintPick, ({ btnHex }) => {
|
|
49
|
+
if (!btnHex) return;
|
|
50
|
+
this.setPaintButtonHex(btnHex);
|
|
64
51
|
});
|
|
65
52
|
|
|
66
53
|
// Инициализация цвета кнопки "краска" из текущего фона доски, если доступен
|
|
67
54
|
try {
|
|
68
55
|
const bgHex = this._getCurrentBoardBackgroundHex();
|
|
69
56
|
if (bgHex) {
|
|
70
|
-
this.
|
|
57
|
+
const mapped = this.mapBoardToBtnHex(bgHex);
|
|
58
|
+
this.setPaintButtonHex(mapped);
|
|
71
59
|
}
|
|
72
60
|
} catch (_) {}
|
|
73
61
|
}
|
|
@@ -190,8 +178,7 @@ export class Topbar {
|
|
|
190
178
|
/** Возвращает текущий цвет фона канваса как hex-строку #RRGGBB */
|
|
191
179
|
_getCurrentBoardBackgroundHex() {
|
|
192
180
|
try {
|
|
193
|
-
|
|
194
|
-
const app = window?.moodboard?.coreMoodboard?.pixi?.app || window?.moodboard?.core?.pixi?.app;
|
|
181
|
+
const app = window?.moodboard?.core?.pixi?.app;
|
|
195
182
|
const colorInt = app?.renderer?.background?.color ?? app?.renderer?.backgroundColor;
|
|
196
183
|
if (typeof colorInt !== 'number') return null;
|
|
197
184
|
const hex = `#${colorInt.toString(16).padStart(6, '0')}`;
|
|
@@ -216,15 +203,6 @@ export class Topbar {
|
|
|
216
203
|
}
|
|
217
204
|
}
|
|
218
205
|
|
|
219
|
-
/** Задать текущий фактический цвет фона и синхронизировать кнопку */
|
|
220
|
-
setCurrentBoardHex(boardHex) {
|
|
221
|
-
if (!boardHex) return;
|
|
222
|
-
const v = String(boardHex).toLowerCase();
|
|
223
|
-
this._currentBoardHex = v.startsWith('#') ? v : `#${v}`;
|
|
224
|
-
const mapped = this.mapBoardToBtnHex(this._currentBoardHex) || this._currentBoardHex;
|
|
225
|
-
this.setPaintButtonHex(mapped);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
206
|
setActive(type) {
|
|
229
207
|
const buttons = this.element.querySelectorAll('.moodboard-topbar__button');
|
|
230
208
|
buttons.forEach((b) => b.classList.remove('moodboard-topbar__button--active'));
|
|
@@ -277,9 +255,8 @@ export class Topbar {
|
|
|
277
255
|
b.style.borderColor = darken(c.hex, 0.35);
|
|
278
256
|
// Цвет галочки — чёрный для максимальной видимости
|
|
279
257
|
b.style.color = '#111';
|
|
280
|
-
// Для надёжного сравнения — сохраняем
|
|
281
|
-
b.dataset.hex = String(c.hex).toLowerCase();
|
|
282
|
-
b.dataset.board = String(c.board).toLowerCase(); // фактический цвет фона доски
|
|
258
|
+
// Для надёжного сравнения — сохраняем исходный hex в dataset
|
|
259
|
+
b.dataset.hex = String(c.hex).toLowerCase();
|
|
283
260
|
// Галочка по центру
|
|
284
261
|
const tick = document.createElement('i');
|
|
285
262
|
tick.className = 'moodboard-topbar__paint-tick';
|
|
@@ -302,37 +279,11 @@ export class Topbar {
|
|
|
302
279
|
});
|
|
303
280
|
pop.appendChild(grid);
|
|
304
281
|
|
|
305
|
-
// Выделяем активный цвет галочкой
|
|
282
|
+
// Выделяем активный цвет галочкой
|
|
306
283
|
try {
|
|
307
|
-
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
let match = currentBoardHex ? grid.querySelector(`[data-board="${currentBoardHex}"]`) : null;
|
|
311
|
-
// Если точного совпадения нет — выбираем ближайший по евклидовой дистанции в RGB
|
|
312
|
-
if (!match) {
|
|
313
|
-
const hexToRgb = (hex) => {
|
|
314
|
-
try {
|
|
315
|
-
const h = hex.replace('#','');
|
|
316
|
-
return {
|
|
317
|
-
r: parseInt(h.substring(0,2), 16),
|
|
318
|
-
g: parseInt(h.substring(2,4), 16),
|
|
319
|
-
b: parseInt(h.substring(4,6), 16)
|
|
320
|
-
};
|
|
321
|
-
} catch (_) { return { r: 0, g: 0, b: 0 }; }
|
|
322
|
-
};
|
|
323
|
-
const dist2 = (a, b) => {
|
|
324
|
-
const dr = a.r - b.r, dg = a.g - b.g, db = a.b - b.b;
|
|
325
|
-
return dr*dr + dg*dg + db*db;
|
|
326
|
-
};
|
|
327
|
-
const target = hexToRgb(currentBoardHex || '#f7fbff');
|
|
328
|
-
let best = null, bestD = Infinity;
|
|
329
|
-
Array.from(grid.children).forEach((el) => {
|
|
330
|
-
const boardHex = el.dataset.board || '';
|
|
331
|
-
const d = dist2(target, hexToRgb(boardHex));
|
|
332
|
-
if (d < bestD) { bestD = d; best = el; }
|
|
333
|
-
});
|
|
334
|
-
match = best;
|
|
335
|
-
}
|
|
284
|
+
const boardHex = this._getCurrentBoardBackgroundHex();
|
|
285
|
+
const targetHex = (this.mapBoardToBtnHex(boardHex) || '#B3E5FC').toLowerCase();
|
|
286
|
+
const match = grid.querySelector(`[data-hex="${targetHex}"]`);
|
|
336
287
|
if (match) match.classList.add('is-active');
|
|
337
288
|
} catch (_) {}
|
|
338
289
|
|
|
@@ -342,7 +293,16 @@ export class Topbar {
|
|
|
342
293
|
pop.style.left = `${rect.left - this.element.getBoundingClientRect().left}px`;
|
|
343
294
|
pop.style.top = `${rect.bottom - this.element.getBoundingClientRect().top + 6}px`;
|
|
344
295
|
|
|
345
|
-
//
|
|
296
|
+
// Подсветить текущий активный кружок (с галочкой)
|
|
297
|
+
try {
|
|
298
|
+
const currentBtnHex = (this._paintBtn && getComputedStyle(this._paintBtn).getPropertyValue('--paint-btn-color')) || '';
|
|
299
|
+
const normalized = currentBtnHex.trim() || '#B3E5FC';
|
|
300
|
+
const match = Array.from(grid.children).find((el) => {
|
|
301
|
+
const bg = el && el.style && el.style.background ? el.style.background.toLowerCase() : '';
|
|
302
|
+
return bg === normalized.toLowerCase();
|
|
303
|
+
});
|
|
304
|
+
if (match) match.classList.add('is-active');
|
|
305
|
+
} catch (_) {}
|
|
346
306
|
|
|
347
307
|
this.element.appendChild(pop);
|
|
348
308
|
this._paintPopover = pop;
|