@sequent-org/moodboard 1.0.12 → 1.0.13
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 +1 -1
- package/src/moodboard/MoodBoard.js +46 -41
- package/src/ui/ContextMenu.js +27 -0
package/package.json
CHANGED
|
@@ -346,6 +346,25 @@ export class MoodBoard {
|
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
+
/**
|
|
350
|
+
* Безопасное уничтожение объекта с проверкой наличия метода destroy
|
|
351
|
+
* @param {Object} obj - объект для уничтожения
|
|
352
|
+
* @param {string} name - имя объекта для логирования
|
|
353
|
+
*/
|
|
354
|
+
_safeDestroy(obj, name) {
|
|
355
|
+
if (obj) {
|
|
356
|
+
try {
|
|
357
|
+
if (typeof obj.destroy === 'function') {
|
|
358
|
+
obj.destroy();
|
|
359
|
+
} else {
|
|
360
|
+
console.warn(`Объект ${name} не имеет метода destroy()`);
|
|
361
|
+
}
|
|
362
|
+
} catch (error) {
|
|
363
|
+
console.error(`Ошибка при уничтожении ${name}:`, error);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
349
368
|
/**
|
|
350
369
|
* Очистка ресурсов
|
|
351
370
|
*/
|
|
@@ -359,58 +378,44 @@ export class MoodBoard {
|
|
|
359
378
|
// Устанавливаем флаг уничтожения
|
|
360
379
|
this.destroyed = true;
|
|
361
380
|
|
|
362
|
-
// Уничтожаем UI компоненты
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
this.toolbar = null;
|
|
366
|
-
}
|
|
381
|
+
// Уничтожаем UI компоненты с безопасными проверками
|
|
382
|
+
this._safeDestroy(this.toolbar, 'toolbar');
|
|
383
|
+
this.toolbar = null;
|
|
367
384
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
this.saveStatus = null;
|
|
371
|
-
}
|
|
385
|
+
this._safeDestroy(this.saveStatus, 'saveStatus');
|
|
386
|
+
this.saveStatus = null;
|
|
372
387
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
this.textPropertiesPanel = null;
|
|
376
|
-
}
|
|
388
|
+
this._safeDestroy(this.textPropertiesPanel, 'textPropertiesPanel');
|
|
389
|
+
this.textPropertiesPanel = null;
|
|
377
390
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
this.framePropertiesPanel = null;
|
|
381
|
-
}
|
|
391
|
+
this._safeDestroy(this.framePropertiesPanel, 'framePropertiesPanel');
|
|
392
|
+
this.framePropertiesPanel = null;
|
|
382
393
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
this.notePropertiesPanel = null;
|
|
386
|
-
}
|
|
394
|
+
this._safeDestroy(this.notePropertiesPanel, 'notePropertiesPanel');
|
|
395
|
+
this.notePropertiesPanel = null;
|
|
387
396
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
this.alignmentGuides = null;
|
|
391
|
-
}
|
|
397
|
+
this._safeDestroy(this.alignmentGuides, 'alignmentGuides');
|
|
398
|
+
this.alignmentGuides = null;
|
|
392
399
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
this.commentPopover = null;
|
|
396
|
-
}
|
|
400
|
+
this._safeDestroy(this.commentPopover, 'commentPopover');
|
|
401
|
+
this.commentPopover = null;
|
|
397
402
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
403
|
+
this._safeDestroy(this.contextMenu, 'contextMenu');
|
|
404
|
+
this.contextMenu = null;
|
|
405
|
+
|
|
406
|
+
this._safeDestroy(this.zoombar, 'zoombar');
|
|
407
|
+
this.zoombar = null;
|
|
408
|
+
|
|
409
|
+
this._safeDestroy(this.mapbar, 'mapbar');
|
|
410
|
+
this.mapbar = null;
|
|
402
411
|
|
|
403
412
|
// Уничтожаем ядро
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
this.coreMoodboard = null;
|
|
407
|
-
}
|
|
413
|
+
this._safeDestroy(this.coreMoodboard, 'coreMoodboard');
|
|
414
|
+
this.coreMoodboard = null;
|
|
408
415
|
|
|
409
416
|
// Уничтожаем workspace
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
this.workspaceManager = null;
|
|
413
|
-
}
|
|
417
|
+
this._safeDestroy(this.workspaceManager, 'workspaceManager');
|
|
418
|
+
this.workspaceManager = null;
|
|
414
419
|
|
|
415
420
|
// Очищаем ссылки на менеджеры
|
|
416
421
|
this.dataManager = null;
|
package/src/ui/ContextMenu.js
CHANGED
|
@@ -9,6 +9,9 @@ export class ContextMenu {
|
|
|
9
9
|
this.lastX = 0;
|
|
10
10
|
this.lastY = 0;
|
|
11
11
|
this.currentGridType = 'line';
|
|
12
|
+
|
|
13
|
+
// Флаг состояния объекта
|
|
14
|
+
this.destroyed = false;
|
|
12
15
|
|
|
13
16
|
this.createElement();
|
|
14
17
|
this.attachEvents();
|
|
@@ -335,6 +338,30 @@ export class ContextMenu {
|
|
|
335
338
|
// По умолчанию — пусто
|
|
336
339
|
this.element.innerHTML = '<div style="padding:8px 12px; color:#888;">(пусто)</div>';
|
|
337
340
|
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Уничтожение контекстного меню
|
|
344
|
+
*/
|
|
345
|
+
destroy() {
|
|
346
|
+
if (this.destroyed) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
this.destroyed = true;
|
|
351
|
+
|
|
352
|
+
// Скрываем меню
|
|
353
|
+
this.hide();
|
|
354
|
+
|
|
355
|
+
// Удаляем DOM элемент
|
|
356
|
+
if (this.element && this.element.parentNode) {
|
|
357
|
+
this.element.parentNode.removeChild(this.element);
|
|
358
|
+
this.element = null;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// Очищаем ссылки
|
|
362
|
+
this.container = null;
|
|
363
|
+
this.eventBus = null;
|
|
364
|
+
}
|
|
338
365
|
}
|
|
339
366
|
|
|
340
367
|
|