@sequent-org/moodboard 1.2.12 → 1.2.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/ui/Toolbar.js +39 -9
- package/src/utils/emojiResolver.js +14 -2
- package/src/utils/inlineSvgEmojis.js +36 -0
package/package.json
CHANGED
package/src/ui/Toolbar.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Events } from '../core/events/Events.js';
|
|
5
5
|
import { IconLoader } from '../utils/iconLoader.js';
|
|
6
|
+
import { getAvailableInlineEmojis, getInlineEmojiUrl } from '../utils/inlineSvgEmojis.js';
|
|
6
7
|
|
|
7
8
|
export class Toolbar {
|
|
8
9
|
constructor(container, eventBus, theme = 'light', options = {}) {
|
|
@@ -905,9 +906,24 @@ export class Toolbar {
|
|
|
905
906
|
this.emojiPopupEl.className = 'moodboard-toolbar__popup moodboard-toolbar__popup--emoji';
|
|
906
907
|
this.emojiPopupEl.style.display = 'none';
|
|
907
908
|
|
|
908
|
-
//
|
|
909
|
+
// ПРИОРИТЕТ 1: Добавляем встроенные SVG эмоджи
|
|
909
910
|
let groups = new Map();
|
|
910
911
|
|
|
912
|
+
console.log('🎯 Создание EmojiPopup: добавляем встроенные SVG эмоджи...');
|
|
913
|
+
const inlineEmojis = getAvailableInlineEmojis();
|
|
914
|
+
|
|
915
|
+
if (inlineEmojis.length > 0) {
|
|
916
|
+
// Добавляем встроенные эмоджи в категорию "Встроенные"
|
|
917
|
+
groups.set('Встроенные', inlineEmojis.map(emoji => ({
|
|
918
|
+
path: `inline:${emoji}`,
|
|
919
|
+
url: getInlineEmojiUrl(emoji),
|
|
920
|
+
isInline: true,
|
|
921
|
+
emoji: emoji
|
|
922
|
+
})));
|
|
923
|
+
console.log(`✅ Добавлено ${inlineEmojis.length} встроенных SVG эмоджи`);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
// ПРИОРИТЕТ 2: Дополняем файловыми эмоджи (если нужны)
|
|
911
927
|
if (typeof import.meta !== 'undefined' && import.meta.glob) {
|
|
912
928
|
// Режим с bundler (Vite) - используем import.meta.glob
|
|
913
929
|
const modules = import.meta.glob('../assets/emodji/**/*.{png,PNG,svg,SVG}', { eager: true, as: 'url' });
|
|
@@ -924,15 +940,19 @@ export class Toolbar {
|
|
|
924
940
|
category = parts.length > 1 ? parts[0] : 'Разное';
|
|
925
941
|
}
|
|
926
942
|
if (!groups.has(category)) groups.set(category, []);
|
|
927
|
-
groups.get(category).push({ path, url });
|
|
943
|
+
groups.get(category).push({ path, url, isInline: false });
|
|
928
944
|
});
|
|
929
945
|
} else {
|
|
930
946
|
// Режим без bundler - используем статичный список
|
|
931
|
-
|
|
947
|
+
const fallbackGroups = this.getFallbackEmojiGroups();
|
|
948
|
+
fallbackGroups.forEach((items, category) => {
|
|
949
|
+
if (!groups.has(category)) groups.set(category, []);
|
|
950
|
+
groups.get(category).push(...items.map(item => ({ ...item, isInline: false })));
|
|
951
|
+
});
|
|
932
952
|
}
|
|
933
953
|
|
|
934
|
-
// Задаем желаемый порядок категорий
|
|
935
|
-
const ORDER = ['Смайлики', 'Жесты', 'Женские эмоции', 'Котики', 'Разное'];
|
|
954
|
+
// Задаем желаемый порядок категорий (встроенные SVG - первые!)
|
|
955
|
+
const ORDER = ['Встроенные', 'Смайлики', 'Жесты', 'Женские эмоции', 'Котики', 'Разное'];
|
|
936
956
|
const present = [...groups.keys()];
|
|
937
957
|
const orderedFirst = ORDER.filter(name => groups.has(name));
|
|
938
958
|
const theRest = present.filter(name => !ORDER.includes(name)).sort((a, b) => a.localeCompare(b));
|
|
@@ -951,14 +971,14 @@ export class Toolbar {
|
|
|
951
971
|
const grid = document.createElement('div');
|
|
952
972
|
grid.className = 'moodboard-emoji__grid';
|
|
953
973
|
|
|
954
|
-
groups.get(cat).forEach(({ url }) => {
|
|
974
|
+
groups.get(cat).forEach(({ url, isInline, emoji }) => {
|
|
955
975
|
const btn = document.createElement('button');
|
|
956
976
|
btn.className = 'moodboard-emoji__btn';
|
|
957
|
-
btn.title = 'Добавить изображение';
|
|
977
|
+
btn.title = isInline ? `Встроенный эмоджи: ${emoji}` : 'Добавить изображение';
|
|
958
978
|
const img = document.createElement('img');
|
|
959
979
|
img.className = 'moodboard-emoji__img';
|
|
960
980
|
img.src = url;
|
|
961
|
-
img.alt = '';
|
|
981
|
+
img.alt = emoji || '';
|
|
962
982
|
btn.appendChild(img);
|
|
963
983
|
|
|
964
984
|
// Перетаскивание: начинаем только если был реальный drag (движение > 4px)
|
|
@@ -1024,9 +1044,19 @@ export class Toolbar {
|
|
|
1024
1044
|
const target = 64; // кратно 128 для лучшей четкости при даунскейле
|
|
1025
1045
|
const targetW = target;
|
|
1026
1046
|
const targetH = target;
|
|
1047
|
+
|
|
1048
|
+
console.log(`🎯 Создаем эмоджи: ${isInline ? 'встроенный SVG' : 'файл'}, url: ${url.substring(0, 50)}...`);
|
|
1049
|
+
|
|
1027
1050
|
this.eventBus.emit(Events.Place.Set, {
|
|
1028
1051
|
type: 'image',
|
|
1029
|
-
properties: {
|
|
1052
|
+
properties: {
|
|
1053
|
+
src: url,
|
|
1054
|
+
width: targetW,
|
|
1055
|
+
height: targetH,
|
|
1056
|
+
isEmojiIcon: true,
|
|
1057
|
+
isInlineSvg: isInline || false,
|
|
1058
|
+
originalEmoji: emoji || null
|
|
1059
|
+
},
|
|
1030
1060
|
size: { width: targetW, height: targetH }
|
|
1031
1061
|
});
|
|
1032
1062
|
this.closeEmojiPopup();
|
|
@@ -203,8 +203,20 @@ export function resolveEmojiAbsoluteUrl(emoji, basePath = null) {
|
|
|
203
203
|
// Формируем URL (приоритет PNG, потом SVG)
|
|
204
204
|
if (!resolvedBasePath.endsWith('/')) resolvedBasePath += '/';
|
|
205
205
|
|
|
206
|
-
//
|
|
207
|
-
|
|
206
|
+
// ПРИОРИТЕТ 2: Файлы в папках (только если нет встроенных SVG)
|
|
207
|
+
// Сначала проверяем разные папки
|
|
208
|
+
const possiblePaths = [
|
|
209
|
+
`${resolvedBasePath}Смайлики/${base}.png`,
|
|
210
|
+
`${resolvedBasePath}Жесты/${base}.png`,
|
|
211
|
+
`${resolvedBasePath}Женские эмоции/${base}.png`,
|
|
212
|
+
`${resolvedBasePath}Котики/${base}.png`,
|
|
213
|
+
`${resolvedBasePath}Разное/${base}.png`,
|
|
214
|
+
`${resolvedBasePath}Обезьянка/${base}.png`,
|
|
215
|
+
`${resolvedBasePath}${base}.png` // Прямо в корне папки эмоджи
|
|
216
|
+
];
|
|
217
|
+
|
|
218
|
+
// Возвращаем первый возможный путь (браузер сам проверит доступность)
|
|
219
|
+
return possiblePaths[0];
|
|
208
220
|
|
|
209
221
|
} catch (error) {
|
|
210
222
|
return null;
|
|
@@ -21,6 +21,23 @@ export const INLINE_SVG_EMOJIS = {
|
|
|
21
21
|
<circle fill="#F4900C" cx="18" cy="13" r="2"/>
|
|
22
22
|
</svg>`,
|
|
23
23
|
|
|
24
|
+
'😂': `<svg viewBox="0 0 36 36" xmlns="http://www.w3.org/2000/svg">
|
|
25
|
+
<circle fill="#FFCC4D" cx="18" cy="18" r="18"/>
|
|
26
|
+
<path fill="#664500" d="M10.515 23.621C10.56 23.8 11.683 28 18 28c6.318 0 7.44-4.2 7.485-4.379.055-.222-.025-.447-.204-.571-.18-.124-.403-.115-.571.024C24.629 23.145 22.112 25 18 25s-6.63-1.855-6.71-1.926c-.168-.139-.39-.148-.571-.024-.179.124-.259.349-.204.571z"/>
|
|
27
|
+
<ellipse fill="#664500" cx="12" cy="13.5" rx="2.5" ry="3.5"/>
|
|
28
|
+
<ellipse fill="#664500" cx="24" cy="13.5" rx="2.5" ry="3.5"/>
|
|
29
|
+
<path fill="#55ACEE" d="M5 17c.552 0 1 .447 1 1v1c0 .552-.448 1-1 1s-1-.448-1-1v-1c0-.553.448-1 1-1z"/>
|
|
30
|
+
<path fill="#55ACEE" d="M31 17c.553 0 1 .447 1 1v1c0 .552-.447 1-1 1-.553 0-1-.448-1-1v-1c0-.553.447-1 1-1z"/>
|
|
31
|
+
</svg>`,
|
|
32
|
+
|
|
33
|
+
'😎': `<svg viewBox="0 0 36 36" xmlns="http://www.w3.org/2000/svg">
|
|
34
|
+
<circle fill="#FFCC4D" cx="18" cy="18" r="18"/>
|
|
35
|
+
<path fill="#664500" d="M10.515 23.621C10.56 23.8 11.683 28 18 28c6.318 0 7.44-4.2 7.485-4.379.055-.222-.025-.447-.204-.571-.18-.124-.403-.115-.571.024C24.629 23.145 22.112 25 18 25s-6.63-1.855-6.71-1.926c-.168-.139-.39-.148-.571-.024-.179.124-.259.349-.204.571z"/>
|
|
36
|
+
<path fill="#292F33" d="M31 13c0-3.866-3.134-7-7-7H12c-3.866 0-7 3.134-7 7v1c0 3.866 3.134 7 7 7h12c3.866 0 7-3.134 7-7v-1z"/>
|
|
37
|
+
<circle fill="#F4900C" cx="12" cy="13.5" r="6"/>
|
|
38
|
+
<circle fill="#F4900C" cx="24" cy="13.5" r="6"/>
|
|
39
|
+
</svg>`,
|
|
40
|
+
|
|
24
41
|
'🤔': `<svg viewBox="0 0 36 36" xmlns="http://www.w3.org/2000/svg">
|
|
25
42
|
<circle fill="#FFCC4D" cx="18" cy="18" r="18"/>
|
|
26
43
|
<path fill="#664500" d="M8 19.5c0 1.381 1.119 2.5 2.5 2.5s2.5-1.119 2.5-2.5S11.881 17 10.5 17 8 18.119 8 19.5z"/>
|
|
@@ -34,8 +51,27 @@ export const INLINE_SVG_EMOJIS = {
|
|
|
34
51
|
<path fill="#FFAC33" d="M7 11c0 5.522-4.478 10-10 10s-10-4.478-10-10 4.478-10 10-10 10 4.478 10 10z"/>
|
|
35
52
|
</svg>`,
|
|
36
53
|
|
|
54
|
+
'👎': `<svg viewBox="0 0 36 36" xmlns="http://www.w3.org/2000/svg">
|
|
55
|
+
<path fill="#EF9645" d="M31.139 26.853c.629.628.63 1.657.001 2.286l-.244.244c-.628.628-1.656.63-2.285.001l-1.903-1.902c-.628-.629-.629-1.657-.001-2.286l.244-.244c.628-.628 1.656-.63 2.285-.001l1.903 1.902z"/>
|
|
56
|
+
<path fill="#FFDC5D" d="M32.032 14.108c.628-.629 1.657-.628 2.285 0l.244.244c.628.628.629 1.656.001 2.285l-1.902 1.903c-.629.628-1.657.629-2.286.001l-.244-.244c-.628-.628-.629-1.656-.001-2.285l1.903-1.904z"/>
|
|
57
|
+
<path fill="#FFAC33" d="M29 25c0-5.522 4.478-10 10-10s10 4.478 10 10-4.478 10-10 10-10-4.478-10-10z"/>
|
|
58
|
+
</svg>`,
|
|
59
|
+
|
|
37
60
|
'❤️': `<svg viewBox="0 0 36 36" xmlns="http://www.w3.org/2000/svg">
|
|
38
61
|
<path fill="#DD2E44" d="M35.885 11.833c0-5.45-4.418-9.868-9.867-9.868-3.308 0-6.227 1.633-8.018 4.129-1.791-2.496-4.71-4.129-8.017-4.129-5.45 0-9.868 4.417-9.868 9.868 0 .772.098 1.52.266 2.241C1.751 22.587 11.216 31.568 18 34.034c6.784-2.466 16.249-11.447 17.619-19.96.168-.721.266-1.469.266-2.241z"/>
|
|
62
|
+
</svg>`,
|
|
63
|
+
|
|
64
|
+
'🔥': `<svg viewBox="0 0 36 36" xmlns="http://www.w3.org/2000/svg">
|
|
65
|
+
<path fill="#DD2E44" d="M18 10c-1.105 0-2 .895-2 2v8c0 1.105.895 2 2 2s2-.895 2-2v-8c0-1.105-.895-2-2-2z"/>
|
|
66
|
+
<path fill="#F4900C" d="M18 6c-.553 0-1 .447-1 1v4c0 .553.447 1 1 1s1-.447 1-1V7c0-.553-.447-1-1-1z"/>
|
|
67
|
+
<path fill="#FFAC33" d="M18 26c3.314 0 6-2.686 6-6 0-3.314-2.686-6-6-6s-6 2.686-6 6c0 3.314 2.686 6 6 6z"/>
|
|
68
|
+
</svg>`,
|
|
69
|
+
|
|
70
|
+
'🎉': `<svg viewBox="0 0 36 36" xmlns="http://www.w3.org/2000/svg">
|
|
71
|
+
<path fill="#FFCC4D" d="M36 17c0 1.104-.896 2-2 2H2c-1.104 0-2-.896-2-2s.896-2 2-2h32c1.104 0 2 .896 2 2z"/>
|
|
72
|
+
<path fill="#DD2E44" d="M35.5 9c0 .828-.672 1.5-1.5 1.5s-1.5-.672-1.5-1.5.672-1.5 1.5-1.5 1.5.672 1.5 1.5z"/>
|
|
73
|
+
<path fill="#55ACEE" d="M3.5 27c0 .828-.672 1.5-1.5 1.5S.5 27.828.5 27s.672-1.5 1.5-1.5 1.5.672 1.5 1.5z"/>
|
|
74
|
+
<path fill="#F4900C" d="M31 25c.552 0 1 .447 1 1v4c0 .552-.448 1-1 1s-1-.448-1-1v-4c0-.553.448-1 1-1z"/>
|
|
39
75
|
</svg>`
|
|
40
76
|
};
|
|
41
77
|
|