@sequent-org/moodboard 1.4.16 → 1.4.20

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.4.16",
3
+ "version": "1.4.20",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
@@ -510,7 +510,9 @@ export function openMindmapEditor(object, create = false) {
510
510
  const sideButton = (typeof target.closest === 'function')
511
511
  ? target.closest('.mb-mindmap-side-btn')
512
512
  : null;
513
- if (sideButton?.dataset?.side === 'bottom') return;
513
+ // Allow all mindmap "+" buttons to complete their click flow
514
+ // without collapsing current selection in capture phase.
515
+ if (sideButton) return;
514
516
  finalize(true);
515
517
  if (typeof this.clearSelection === 'function') {
516
518
  this.clearSelection();
@@ -209,7 +209,10 @@ function relayoutMindmapBranchLevel({ core, eventBus, parentId, side }) {
209
209
  if (!(targetX === currentX && targetY === currentY)) {
210
210
  core.updateObjectPositionDirect(node.id, { x: targetX, y: targetY }, { snap: false });
211
211
  eventBus.emit(Events.Object.TransformUpdated, { objectId: node.id });
212
- eventBus.emit(Events.Tool.DragUpdate, { object: node.id });
212
+ eventBus.emit(Events.Tool.DragUpdate, {
213
+ object: node.id,
214
+ position: { x: targetX, y: targetY },
215
+ });
213
216
  movedPositions.set(node.id, { x: targetX, y: targetY });
214
217
 
215
218
  const dx = Math.round(targetX - currentX);
@@ -233,7 +236,10 @@ function relayoutMindmapBranchLevel({ core, eventBus, parentId, side }) {
233
236
  };
234
237
  core.updateObjectPositionDirect(descId, nextPos, { snap: false });
235
238
  eventBus.emit(Events.Object.TransformUpdated, { objectId: descId });
236
- eventBus.emit(Events.Tool.DragUpdate, { object: descId });
239
+ eventBus.emit(Events.Tool.DragUpdate, {
240
+ object: descId,
241
+ position: nextPos,
242
+ });
237
243
  movedPositions.set(descId, nextPos);
238
244
  });
239
245
  }
@@ -965,7 +971,10 @@ export class HandlesDomRenderer {
965
971
  const nextPos = { x: Math.round(Number(snap.x) + dx), y: Math.round(Number(snap.y) + dy) };
966
972
  core.updateObjectPositionDirect(nodeId, nextPos, { snap: false });
967
973
  eventBus.emit(Events.Object.TransformUpdated, { objectId: nodeId });
968
- eventBus.emit(Events.Tool.DragUpdate, { object: nodeId });
974
+ eventBus.emit(Events.Tool.DragUpdate, {
975
+ object: nodeId,
976
+ position: nextPos,
977
+ });
969
978
  });
970
979
  translatedScopeByCompound.set(compoundId, moveScopeIds);
971
980
  logMindmapCompoundDebug('layout:drag-end-translate-scope', {
@@ -994,7 +1003,10 @@ export class HandlesDomRenderer {
994
1003
  const nextPos = { x: Math.round(snap.x), y: Math.round(snap.y) };
995
1004
  core.updateObjectPositionDirect(nodeId, nextPos, { snap: false });
996
1005
  eventBus.emit(Events.Object.TransformUpdated, { objectId: nodeId });
997
- eventBus.emit(Events.Tool.DragUpdate, { object: nodeId });
1006
+ eventBus.emit(Events.Tool.DragUpdate, {
1007
+ object: nodeId,
1008
+ position: nextPos,
1009
+ });
998
1010
  });
999
1011
  logMindmapCompoundDebug('layout:drag-end-restore-compound', {
1000
1012
  compoundId,
@@ -471,6 +471,10 @@ export class ToolbarPopupsController {
471
471
  const targetW = target;
472
472
  const targetH = target;
473
473
  const placementSrc = this.resolveEmojiPlacementSrc(cat, emojiCode, url, isInline);
474
+ if (!placementSrc) {
475
+ console.warn('Emoji placement skipped: cannot resolve public src', { cat, emojiCode, url });
476
+ return;
477
+ }
474
478
  this.toolbar.eventBus.emit(Events.Keyboard.ToolSelect, { tool: 'place' });
475
479
  this.toolbar.eventBus.emit(Events.Place.Set, {
476
480
  type: 'image',
@@ -510,6 +514,10 @@ export class ToolbarPopupsController {
510
514
  const targetW = target;
511
515
  const targetH = target;
512
516
  const placementSrc = this.resolveEmojiPlacementSrc(cat, emojiCode, url, isInline);
517
+ if (!placementSrc) {
518
+ console.warn('Emoji placement skipped: cannot resolve public src', { cat, emojiCode, url });
519
+ return;
520
+ }
513
521
 
514
522
  this.toolbar.eventBus.emit(Events.Place.Set, {
515
523
  type: 'image',
@@ -536,24 +544,25 @@ export class ToolbarPopupsController {
536
544
  }
537
545
 
538
546
  resolveEmojiPlacementSrc(category, emojiCode, fallbackUrl, isInline = false) {
539
- if (isInline) {
540
- return fallbackUrl;
541
- }
542
547
  const basePath = this.getEmojiBasePath();
543
- if (!emojiCode || !basePath) {
544
- return fallbackUrl;
548
+ if (emojiCode && basePath) {
549
+ const normalizeBase = basePath.endsWith('/') ? basePath : `${basePath}/`;
550
+ const encodedCategory = encodeURIComponent(category || 'Разное');
551
+ const encodedEmojiCode = encodeURIComponent(emojiCode);
552
+ const relativePath = `${encodedCategory}/${encodedEmojiCode}.png`;
553
+
554
+ try {
555
+ return new URL(relativePath, normalizeBase).href;
556
+ } catch (_) {
557
+ return `${normalizeBase}${relativePath}`;
558
+ }
545
559
  }
546
560
 
547
- const normalizeBase = basePath.endsWith('/') ? basePath : `${basePath}/`;
548
- const encodedCategory = encodeURIComponent(category || 'Разное');
549
- const encodedEmojiCode = encodeURIComponent(emojiCode);
550
- const relativePath = `${encodedCategory}/${encodedEmojiCode}.png`;
551
-
552
- try {
553
- return new URL(relativePath, normalizeBase).href;
554
- } catch (_) {
555
- return `${normalizeBase}${relativePath}`;
556
- }
561
+ const fallback = typeof fallbackUrl === 'string' ? fallbackUrl.trim() : '';
562
+ if (!fallback) return null;
563
+ if (/^data:/i.test(fallback) || /^blob:/i.test(fallback)) return null;
564
+ if (fallback.includes('/node_modules/')) return null;
565
+ return fallback;
557
566
  }
558
567
 
559
568
  getFallbackEmojiGroups() {
@@ -622,35 +631,31 @@ export class ToolbarPopupsController {
622
631
  }
623
632
 
624
633
  getEmojiBasePath() {
625
- if (this.toolbar.emojiBasePath) {
626
- return this.toolbar.emojiBasePath.endsWith('/') ? this.toolbar.emojiBasePath : this.toolbar.emojiBasePath + '/';
627
- }
634
+ const normalize = (value) => {
635
+ if (!value || typeof value !== 'string') return null;
636
+ const trimmed = value.trim();
637
+ if (!trimmed) return null;
638
+ if (trimmed.includes('/node_modules/')) return null;
639
+ return trimmed.endsWith('/') ? trimmed : `${trimmed}/`;
640
+ };
628
641
 
629
- if (window.MOODBOARD_BASE_PATH) {
630
- const basePath = window.MOODBOARD_BASE_PATH.endsWith('/') ? window.MOODBOARD_BASE_PATH : window.MOODBOARD_BASE_PATH + '/';
631
- return `${basePath}src/assets/emodji/`;
642
+ const fromOptions = normalize(this.toolbar.emojiBasePath);
643
+ if (fromOptions) {
644
+ return fromOptions;
632
645
  }
633
646
 
634
- try {
635
- const currentModuleUrl = import.meta.url;
636
- const emojiUrl = new URL('../assets/emodji/', currentModuleUrl).href;
637
- return emojiUrl;
638
- } catch (error) {
639
- console.warn('⚠️ Не удалось определить путь через import.meta.url:', error);
647
+ const fromExplicitGlobal = normalize(window.MOODBOARD_EMOJI_BASE_PATH);
648
+ if (fromExplicitGlobal) {
649
+ return fromExplicitGlobal;
640
650
  }
641
651
 
642
- try {
643
- const currentScript = document.currentScript;
644
- if (currentScript && currentScript.src) {
645
- const scriptUrl = new URL(currentScript.src);
646
- const baseUrl = new URL('../assets/emodji/', scriptUrl).href;
647
- return baseUrl;
648
- }
649
- } catch (error) {
650
- console.warn('⚠️ Не удалось определить путь через currentScript:', error);
652
+ if (window.MOODBOARD_BASE_PATH) {
653
+ const basePath = window.MOODBOARD_BASE_PATH.endsWith('/') ? window.MOODBOARD_BASE_PATH : window.MOODBOARD_BASE_PATH + '/';
654
+ const fromGlobalBase = normalize(`${basePath}emodji/`);
655
+ if (fromGlobalBase) return fromGlobalBase;
651
656
  }
652
657
 
653
- return '/src/assets/emodji/';
658
+ return '/emodji/';
654
659
  }
655
660
 
656
661
  toggleEmojiPopup(anchorButton) {