@sequent-org/moodboard 1.4.15 → 1.4.19
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
|
@@ -470,7 +470,11 @@ export class ToolbarPopupsController {
|
|
|
470
470
|
const target = 64;
|
|
471
471
|
const targetW = target;
|
|
472
472
|
const targetH = target;
|
|
473
|
-
const placementSrc = this.resolveEmojiPlacementSrc(cat, emojiCode, url);
|
|
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',
|
|
@@ -509,7 +513,11 @@ export class ToolbarPopupsController {
|
|
|
509
513
|
const target = 64;
|
|
510
514
|
const targetW = target;
|
|
511
515
|
const targetH = target;
|
|
512
|
-
const placementSrc = this.resolveEmojiPlacementSrc(cat, emojiCode, url);
|
|
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',
|
|
@@ -535,22 +543,26 @@ export class ToolbarPopupsController {
|
|
|
535
543
|
this.toolbar.container.appendChild(this.toolbar.emojiPopupEl);
|
|
536
544
|
}
|
|
537
545
|
|
|
538
|
-
resolveEmojiPlacementSrc(category, emojiCode, fallbackUrl) {
|
|
546
|
+
resolveEmojiPlacementSrc(category, emojiCode, fallbackUrl, isInline = false) {
|
|
539
547
|
const basePath = this.getEmojiBasePath();
|
|
540
|
-
if (
|
|
541
|
-
|
|
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
|
+
}
|
|
542
559
|
}
|
|
543
560
|
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
try {
|
|
550
|
-
return new URL(relativePath, normalizeBase).href;
|
|
551
|
-
} catch (_) {
|
|
552
|
-
return `${normalizeBase}${relativePath}`;
|
|
553
|
-
}
|
|
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;
|
|
554
566
|
}
|
|
555
567
|
|
|
556
568
|
getFallbackEmojiGroups() {
|
|
@@ -619,35 +631,31 @@ export class ToolbarPopupsController {
|
|
|
619
631
|
}
|
|
620
632
|
|
|
621
633
|
getEmojiBasePath() {
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
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
|
+
};
|
|
625
641
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
return
|
|
642
|
+
const fromOptions = normalize(this.toolbar.emojiBasePath);
|
|
643
|
+
if (fromOptions) {
|
|
644
|
+
return fromOptions;
|
|
629
645
|
}
|
|
630
646
|
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
return emojiUrl;
|
|
635
|
-
} catch (error) {
|
|
636
|
-
console.warn('⚠️ Не удалось определить путь через import.meta.url:', error);
|
|
647
|
+
const fromExplicitGlobal = normalize(window.MOODBOARD_EMOJI_BASE_PATH);
|
|
648
|
+
if (fromExplicitGlobal) {
|
|
649
|
+
return fromExplicitGlobal;
|
|
637
650
|
}
|
|
638
651
|
|
|
639
|
-
|
|
640
|
-
const
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
const baseUrl = new URL('../assets/emodji/', scriptUrl).href;
|
|
644
|
-
return baseUrl;
|
|
645
|
-
}
|
|
646
|
-
} catch (error) {
|
|
647
|
-
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;
|
|
648
656
|
}
|
|
649
657
|
|
|
650
|
-
return '/
|
|
658
|
+
return '/emodji/';
|
|
651
659
|
}
|
|
652
660
|
|
|
653
661
|
toggleEmojiPopup(anchorButton) {
|