@sequent-org/moodboard 1.2.115 → 1.2.117

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequent-org/moodboard",
3
- "version": "1.2.115",
3
+ "version": "1.2.117",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
@@ -484,6 +484,60 @@ export class ToolManager {
484
484
  return;
485
485
  }
486
486
 
487
+ const nonImageFiles = files.filter(f => !f.type || !f.type.startsWith('image/'));
488
+ if (nonImageFiles.length > 0) {
489
+ let index = 0;
490
+ for (const file of nonImageFiles) {
491
+ const offset = 25 * index++;
492
+ const position = { x: x + offset, y: y + offset };
493
+ const fallbackProps = {
494
+ fileName: file.name || 'file',
495
+ fileSize: file.size || 0,
496
+ mimeType: file.type || 'application/octet-stream',
497
+ formattedSize: null,
498
+ url: null,
499
+ width: 120,
500
+ height: 140
501
+ };
502
+ try {
503
+ if (this.core && this.core.fileUploadService) {
504
+ const uploadResult = await this.core.fileUploadService.uploadFile(file, file.name || 'file');
505
+ this.eventBus.emit(Events.UI.ToolbarAction, {
506
+ type: 'file',
507
+ id: 'file',
508
+ position,
509
+ properties: {
510
+ fileName: uploadResult.name,
511
+ fileSize: uploadResult.size,
512
+ mimeType: uploadResult.mimeType,
513
+ formattedSize: uploadResult.formattedSize,
514
+ url: uploadResult.url,
515
+ width: 120,
516
+ height: 140
517
+ },
518
+ fileId: uploadResult.fileId || uploadResult.id || null
519
+ });
520
+ } else {
521
+ this.eventBus.emit(Events.UI.ToolbarAction, {
522
+ type: 'file',
523
+ id: 'file',
524
+ position,
525
+ properties: fallbackProps
526
+ });
527
+ }
528
+ } catch (error) {
529
+ console.warn('Ошибка загрузки файла через drag-and-drop:', error);
530
+ this.eventBus.emit(Events.UI.ToolbarAction, {
531
+ type: 'file',
532
+ id: 'file',
533
+ position,
534
+ properties: fallbackProps
535
+ });
536
+ }
537
+ }
538
+ return;
539
+ }
540
+
487
541
  // 2) Перетаскивание с другой вкладки: HTML/URI/PLAIN
488
542
  const html = dt.getData('text/html');
489
543
  if (html && html.includes('<img')) {
@@ -322,6 +322,12 @@ export class DrawingTool extends BaseTool {
322
322
  return { x: local.x, y: local.y };
323
323
  }
324
324
 
325
+ _worldToGlobal(x, y) {
326
+ if (!this.world || typeof this.world.toGlobal !== 'function') return { x, y };
327
+ const global = this.world.toGlobal(new PIXI.Point(x, y));
328
+ return { x: global.x, y: global.y };
329
+ }
330
+
325
331
  _getWorldLayer() {
326
332
  if (!this.app || !this.app.stage) return null;
327
333
  const world = this.app.stage.getChildByName && this.app.stage.getChildByName('worldLayer');
@@ -333,12 +339,14 @@ export class DrawingTool extends BaseTool {
333
339
  const req = { objects: [] };
334
340
  this.emit('get:all:objects', req);
335
341
  const objects = req.objects || [];
342
+ const prevGlobal = this._worldToGlobal(prev.x, prev.y);
343
+ const currGlobal = this._worldToGlobal(p.x, p.y);
336
344
  // Радиус воздействия ластика (связан с отображаемой толщиной)
337
345
  const radius = 8;
338
- const segMinX = Math.min(prev.x, p.x) - radius;
339
- const segMaxX = Math.max(prev.x, p.x) + radius;
340
- const segMinY = Math.min(prev.y, p.y) - radius;
341
- const segMaxY = Math.max(prev.y, p.y) + radius;
346
+ const segMinX = Math.min(prevGlobal.x, currGlobal.x) - radius;
347
+ const segMaxX = Math.max(prevGlobal.x, currGlobal.x) + radius;
348
+ const segMinY = Math.min(prevGlobal.y, currGlobal.y) - radius;
349
+ const segMaxY = Math.max(prevGlobal.y, currGlobal.y) + radius;
342
350
 
343
351
  for (const item of objects) {
344
352
  const id = item.id;
@@ -368,8 +376,8 @@ export class DrawingTool extends BaseTool {
368
376
  const scaleY = baseH ? (b.height / baseH) : 1;
369
377
  const eraserThresh = Math.max(6, (props.strokeWidth || 2) / 2 + radius);
370
378
  // трансформируем сегмент ластика в локальные координаты фигуры
371
- const localPrev = pixi.toLocal(new PIXI.Point(prev.x, prev.y));
372
- const localCurr = pixi.toLocal(new PIXI.Point(p.x, p.y));
379
+ const localPrev = pixi.toLocal(new PIXI.Point(prevGlobal.x, prevGlobal.y));
380
+ const localCurr = pixi.toLocal(new PIXI.Point(currGlobal.x, currGlobal.y));
373
381
  // Проверяем пересечение с каждым отрезком рисунка
374
382
  for (let i = 0; i < pts.length - 1 && !intersects; i++) {
375
383
  const ax = pts[i].x * scaleX;