@sequent-org/moodboard 1.2.76 → 1.2.78
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/core/index.js +76 -40
- package/src/grid/GridFactory.js +4 -4
package/package.json
CHANGED
package/src/core/index.js
CHANGED
|
@@ -361,46 +361,82 @@ export class CoreMoodBoard {
|
|
|
361
361
|
this._cursor.y = y;
|
|
362
362
|
});
|
|
363
363
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
364
|
+
// Вставка изображения из буфера обмена — по курсору, если он над холстом; иначе по центру видимой области
|
|
365
|
+
this.eventBus.on(Events.UI.PasteImage, ({ src, name, imageId }) => {
|
|
366
|
+
if (!src) return;
|
|
367
|
+
const view = this.pixi.app.view;
|
|
368
|
+
const world = this.pixi.worldLayer || this.pixi.app.stage;
|
|
369
|
+
const s = world?.scale?.x || 1;
|
|
370
|
+
const hasCursor = Number.isFinite(this._cursor.x) && Number.isFinite(this._cursor.y);
|
|
371
|
+
|
|
372
|
+
let screenX, screenY;
|
|
373
|
+
if (hasCursor) {
|
|
374
|
+
// Используем позицию курсора
|
|
375
|
+
screenX = this._cursor.x;
|
|
376
|
+
screenY = this._cursor.y;
|
|
377
|
+
} else {
|
|
378
|
+
// Центр экрана
|
|
379
|
+
screenX = view.clientWidth / 2;
|
|
380
|
+
screenY = view.clientHeight / 2;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// Преобразуем экранные координаты в мировые (с учетом zoom и pan)
|
|
384
|
+
const worldX = (screenX - (world?.x || 0)) / s;
|
|
385
|
+
const worldY = (screenY - (world?.y || 0)) / s;
|
|
386
|
+
|
|
387
|
+
const placeWithAspect = (natW, natH) => {
|
|
388
|
+
let w = 300, h = 200;
|
|
389
|
+
if (natW > 0 && natH > 0) {
|
|
390
|
+
const ar = natW / natH;
|
|
391
|
+
w = 300;
|
|
392
|
+
h = Math.max(1, Math.round(w / ar));
|
|
393
|
+
}
|
|
394
|
+
const properties = { src, name, width: w, height: h };
|
|
395
|
+
const extraData = imageId ? { imageId } : {};
|
|
396
|
+
this.createObject('image', { x: Math.round(worldX - Math.round(w / 2)), y: Math.round(worldY - Math.round(h / 2)) }, properties, extraData);
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
try {
|
|
400
|
+
const img = new Image();
|
|
401
|
+
img.decoding = 'async';
|
|
402
|
+
img.onload = () => placeWithAspect(img.naturalWidth || 0, img.naturalHeight || 0);
|
|
403
|
+
img.onerror = () => placeWithAspect(0, 0);
|
|
404
|
+
img.src = src;
|
|
405
|
+
} catch (_) {
|
|
406
|
+
placeWithAspect(0, 0);
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
// Вставка изображения из буфера обмена по контекстному клику (координаты на экране)
|
|
411
|
+
this.eventBus.on(Events.UI.PasteImageAt, ({ x, y, src, name, imageId }) => {
|
|
412
|
+
if (!src) return;
|
|
413
|
+
const world = this.pixi.worldLayer || this.pixi.app.stage;
|
|
414
|
+
const s = world?.scale?.x || 1;
|
|
415
|
+
const worldX = (x - (world?.x || 0)) / s;
|
|
416
|
+
const worldY = (y - (world?.y || 0)) / s;
|
|
417
|
+
|
|
418
|
+
const placeWithAspect = (natW, natH) => {
|
|
419
|
+
let w = 300, h = 200;
|
|
420
|
+
if (natW > 0 && natH > 0) {
|
|
421
|
+
const ar = natW / natH;
|
|
422
|
+
w = 300;
|
|
423
|
+
h = Math.max(1, Math.round(w / ar));
|
|
424
|
+
}
|
|
425
|
+
const properties = { src, name, width: w, height: h };
|
|
426
|
+
const extraData = imageId ? { imageId } : {};
|
|
427
|
+
this.createObject('image', { x: Math.round(worldX - Math.round(w / 2)), y: Math.round(worldY - Math.round(h / 2)) }, properties, extraData);
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
try {
|
|
431
|
+
const img = new Image();
|
|
432
|
+
img.decoding = 'async';
|
|
433
|
+
img.onload = () => placeWithAspect(img.naturalWidth || 0, img.naturalHeight || 0);
|
|
434
|
+
img.onerror = () => placeWithAspect(0, 0);
|
|
435
|
+
img.src = src;
|
|
436
|
+
} catch (_) {
|
|
437
|
+
placeWithAspect(0, 0);
|
|
438
|
+
}
|
|
439
|
+
});
|
|
404
440
|
|
|
405
441
|
// Слойность: изменение порядка отрисовки (локальные операции)
|
|
406
442
|
const applyZOrderFromState = () => {
|
package/src/grid/GridFactory.js
CHANGED
|
@@ -85,10 +85,10 @@ export class GridFactory {
|
|
|
85
85
|
},
|
|
86
86
|
cross: {
|
|
87
87
|
enabled: true,
|
|
88
|
-
size:
|
|
89
|
-
color:
|
|
90
|
-
opacity:
|
|
91
|
-
crossHalfSize:
|
|
88
|
+
size: 65, // шаг между крестиками
|
|
89
|
+
color: 0xB8BAFF, // целевой цвет
|
|
90
|
+
opacity: 1, // непрозрачно
|
|
91
|
+
crossHalfSize: 5, // длина луча (половина креста) в px
|
|
92
92
|
crossLineWidth: 1
|
|
93
93
|
}
|
|
94
94
|
};
|