@sequent-org/moodboard 1.4.16 → 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
|
@@ -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 (
|
|
544
|
-
|
|
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
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
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
|
-
|
|
626
|
-
|
|
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
|
-
|
|
630
|
-
|
|
631
|
-
return
|
|
642
|
+
const fromOptions = normalize(this.toolbar.emojiBasePath);
|
|
643
|
+
if (fromOptions) {
|
|
644
|
+
return fromOptions;
|
|
632
645
|
}
|
|
633
646
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
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
|
-
|
|
643
|
-
const
|
|
644
|
-
|
|
645
|
-
|
|
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 '/
|
|
658
|
+
return '/emodji/';
|
|
654
659
|
}
|
|
655
660
|
|
|
656
661
|
toggleEmojiPopup(anchorButton) {
|