@sequent-org/moodboard 1.3.0 → 1.3.1

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.3.0",
3
+ "version": "1.3.1",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
package/src/ui/Toolbar.js CHANGED
@@ -46,7 +46,13 @@ export class Toolbar {
46
46
  console.error('❌ Ошибка загрузки иконок:', error);
47
47
  }
48
48
 
49
- this._toolActivatedHandler = ({ tool }) => this.setActiveToolbarButton(tool);
49
+ this._toolActivatedHandler = ({ tool }) => {
50
+ this.setActiveToolbarButton(tool);
51
+ // Draw palette must stay open only while draw tool is active.
52
+ if (tool !== 'draw') {
53
+ this.closeDrawPopup();
54
+ }
55
+ };
50
56
  this.createToolbar();
51
57
  this.attachEvents();
52
58
  this.setupHistoryEvents();
@@ -133,9 +139,13 @@ export class Toolbar {
133
139
  const isDrawButton = e.target.closest && e.target.closest('.moodboard-toolbar__button--pencil');
134
140
  const isEmojiButton = e.target.closest && e.target.closest('.moodboard-toolbar__button--emoji');
135
141
  const isFrameButton = e.target.closest && e.target.closest('.moodboard-toolbar__button--frame');
142
+ const isDrawActive = !!(this.element && this.element.querySelector('.moodboard-toolbar__button--pencil.moodboard-toolbar__button--active'));
143
+
136
144
  if (!isInsideToolbar && !isInsideShapesPopup && !isShapesButton && !isInsideDrawPopup && !isDrawButton && !isInsideEmojiPopup && !isEmojiButton && !isInsideFramePopup && !isFrameButton) {
137
145
  this.closeShapesPopup();
138
- this.closeDrawPopup();
146
+ if (!isDrawActive) {
147
+ this.closeDrawPopup();
148
+ }
139
149
  this.closeEmojiPopup();
140
150
  this.closeFramePopup();
141
151
  }
@@ -232,6 +232,9 @@ export class ToolbarPopupsController {
232
232
  const row2 = document.createElement('div');
233
233
  row2.className = 'moodboard-draw__row';
234
234
  this.toolbar.drawRow2 = row2;
235
+ const clearActivePresetButtons = () => {
236
+ row2.querySelectorAll('.moodboard-draw__btn--active').forEach((el) => el.classList.remove('moodboard-draw__btn--active'));
237
+ };
235
238
 
236
239
  const pencilPresetEl = document.createElement('div');
237
240
  pencilPresetEl.className = 'moodboard-draw__row';
@@ -267,7 +270,7 @@ export class ToolbarPopupsController {
267
270
  btn.appendChild(holder);
268
271
  btn.addEventListener('click', () => {
269
272
  this.toolbar.animateButton(btn);
270
- pencilPresetEl.querySelectorAll('.moodboard-draw__btn--active').forEach((el) => el.classList.remove('moodboard-draw__btn--active'));
273
+ clearActivePresetButtons();
271
274
  btn.classList.add('moodboard-draw__btn--active');
272
275
  const width = s.width;
273
276
  const color = parseInt(s.color.replace('#', ''), 16);
@@ -291,7 +294,7 @@ export class ToolbarPopupsController {
291
294
  btn.appendChild(sw);
292
295
  btn.addEventListener('click', () => {
293
296
  this.toolbar.animateButton(btn);
294
- markerPresetEl.querySelectorAll('.moodboard-draw__btn--active').forEach((el) => el.classList.remove('moodboard-draw__btn--active'));
297
+ clearActivePresetButtons();
295
298
  btn.classList.add('moodboard-draw__btn--active');
296
299
  const color = parseInt(s.color.replace('#', ''), 16);
297
300
  this.toolbar.eventBus.emit(Events.Draw.BrushSet, { mode: 'marker', color, width: 8 });