@sequent-org/moodboard 1.4.13 → 1.4.15
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
|
@@ -40,49 +40,6 @@ export class KeyboardClipboardImagePaste {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
async handleFileUpload(file, fileName) {
|
|
44
|
-
try {
|
|
45
|
-
if (!(this.core && this.core.fileUploadService)) {
|
|
46
|
-
alert('Сервис загрузки файлов недоступен. Файл не добавлен.');
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const uploadResult = await this.core.fileUploadService.uploadFile(file, fileName);
|
|
51
|
-
const world = this.core?.pixi?.worldLayer || this.core?.pixi?.app?.stage;
|
|
52
|
-
const view = this.core?.pixi?.app?.view;
|
|
53
|
-
const s = world?.scale?.x || 1;
|
|
54
|
-
const hasCursor = Number.isFinite(this.core?._cursor?.x) && Number.isFinite(this.core?._cursor?.y);
|
|
55
|
-
|
|
56
|
-
const screenX = hasCursor ? this.core._cursor.x : (view?.clientWidth || 0) / 2;
|
|
57
|
-
const screenY = hasCursor ? this.core._cursor.y : (view?.clientHeight || 0) / 2;
|
|
58
|
-
const worldX = (screenX - (world?.x || 0)) / s;
|
|
59
|
-
const worldY = (screenY - (world?.y || 0)) / s;
|
|
60
|
-
|
|
61
|
-
const width = 120;
|
|
62
|
-
const height = 140;
|
|
63
|
-
this.eventBus.emit(Events.UI.ToolbarAction, {
|
|
64
|
-
type: 'file',
|
|
65
|
-
id: 'file',
|
|
66
|
-
position: {
|
|
67
|
-
x: Math.round(worldX - width / 2),
|
|
68
|
-
y: Math.round(worldY - height / 2)
|
|
69
|
-
},
|
|
70
|
-
properties: {
|
|
71
|
-
fileName: uploadResult.name,
|
|
72
|
-
fileSize: uploadResult.size,
|
|
73
|
-
mimeType: uploadResult.mimeType,
|
|
74
|
-
formattedSize: uploadResult.formattedSize,
|
|
75
|
-
src: uploadResult.src,
|
|
76
|
-
width,
|
|
77
|
-
height
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
} catch (error) {
|
|
81
|
-
console.error('Ошибка загрузки файла:', error);
|
|
82
|
-
alert('Ошибка загрузки файла на сервер. Файл не добавлен.');
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
43
|
createPasteHandler() {
|
|
87
44
|
return async (e) => {
|
|
88
45
|
try {
|
|
@@ -109,12 +66,6 @@ export class KeyboardClipboardImagePaste {
|
|
|
109
66
|
await this.handleImageFileUpload(imgFile, imgFile.name || 'clipboard-image.png');
|
|
110
67
|
return;
|
|
111
68
|
}
|
|
112
|
-
const plainFile = files.find(f => !(f.type && f.type.startsWith('image/')));
|
|
113
|
-
if (plainFile) {
|
|
114
|
-
e.preventDefault();
|
|
115
|
-
await this.handleFileUpload(plainFile, plainFile.name || 'clipboard-file');
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
69
|
|
|
119
70
|
const html = cd.getData && cd.getData('text/html');
|
|
120
71
|
if (html && html.includes('<img')) {
|
|
@@ -470,10 +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
474
|
this.toolbar.eventBus.emit(Events.Keyboard.ToolSelect, { tool: 'place' });
|
|
474
475
|
this.toolbar.eventBus.emit(Events.Place.Set, {
|
|
475
476
|
type: 'image',
|
|
476
|
-
properties: { src:
|
|
477
|
+
properties: { src: placementSrc, width: targetW, height: targetH, isEmojiIcon: true },
|
|
477
478
|
size: { width: targetW, height: targetH },
|
|
478
479
|
placeOnMouseUp: true
|
|
479
480
|
});
|
|
@@ -508,11 +509,12 @@ export class ToolbarPopupsController {
|
|
|
508
509
|
const target = 64;
|
|
509
510
|
const targetW = target;
|
|
510
511
|
const targetH = target;
|
|
512
|
+
const placementSrc = this.resolveEmojiPlacementSrc(cat, emojiCode, url);
|
|
511
513
|
|
|
512
514
|
this.toolbar.eventBus.emit(Events.Place.Set, {
|
|
513
515
|
type: 'image',
|
|
514
516
|
properties: {
|
|
515
|
-
src:
|
|
517
|
+
src: placementSrc,
|
|
516
518
|
width: targetW,
|
|
517
519
|
height: targetH,
|
|
518
520
|
isEmojiIcon: true,
|
|
@@ -533,6 +535,24 @@ export class ToolbarPopupsController {
|
|
|
533
535
|
this.toolbar.container.appendChild(this.toolbar.emojiPopupEl);
|
|
534
536
|
}
|
|
535
537
|
|
|
538
|
+
resolveEmojiPlacementSrc(category, emojiCode, fallbackUrl) {
|
|
539
|
+
const basePath = this.getEmojiBasePath();
|
|
540
|
+
if (!emojiCode || !basePath) {
|
|
541
|
+
return fallbackUrl;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
const normalizeBase = basePath.endsWith('/') ? basePath : `${basePath}/`;
|
|
545
|
+
const encodedCategory = encodeURIComponent(category || 'Разное');
|
|
546
|
+
const encodedEmojiCode = encodeURIComponent(emojiCode);
|
|
547
|
+
const relativePath = `${encodedCategory}/${encodedEmojiCode}.png`;
|
|
548
|
+
|
|
549
|
+
try {
|
|
550
|
+
return new URL(relativePath, normalizeBase).href;
|
|
551
|
+
} catch (_) {
|
|
552
|
+
return `${normalizeBase}${relativePath}`;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
536
556
|
getFallbackEmojiGroups() {
|
|
537
557
|
const groups = new Map();
|
|
538
558
|
let convertedCount = 0;
|