@sequent-org/moodboard 1.2.95 → 1.2.97

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.95",
3
+ "version": "1.2.97",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
@@ -1847,9 +1847,21 @@ export class SelectTool extends BaseTool {
1847
1847
  const toScreen = (wx, wy) => {
1848
1848
  const worldLayer = this.textEditor.world || (this.app?.stage);
1849
1849
  if (!worldLayer) return { x: wx, y: wy };
1850
+
1851
+ // Используем тот же подход, что в HtmlHandlesLayer для рамки выделения
1852
+ const containerRect = view.parentElement.getBoundingClientRect();
1853
+ const viewRect = view.getBoundingClientRect();
1854
+ const offsetLeft = viewRect.left - containerRect.left;
1855
+ const offsetTop = viewRect.top - containerRect.top;
1856
+
1857
+ // Преобразуем мировые координаты в экранные через toGlobal
1850
1858
  const global = worldLayer.toGlobal(new PIXI.Point(wx, wy));
1851
- const viewRes = (this.app?.renderer?.resolution) || (view.width && view.clientWidth ? (view.width / view.clientWidth) : 1);
1852
- return { x: global.x / viewRes, y: global.y / viewRes };
1859
+
1860
+ // Возвращаем CSS координаты с учетом offset
1861
+ return {
1862
+ x: offsetLeft + global.x,
1863
+ y: offsetTop + global.y
1864
+ };
1853
1865
  };
1854
1866
  const screenPos = toScreen(position.x, position.y);
1855
1867
 
@@ -2676,21 +2688,31 @@ export class SelectTool extends BaseTool {
2676
2688
  try {
2677
2689
  const view = this.app?.view;
2678
2690
  const worldLayerRef = this.textEditor.world || (this.app?.stage);
2679
- const viewRes = (this.app?.renderer?.resolution) || (view && view.width && view.clientWidth ? (view.width / view.clientWidth) : 1);
2680
2691
  const cssLeft = this.textEditor._cssLeftPx;
2681
2692
  const cssTop = this.textEditor._cssTopPx;
2682
- if (isFinite(cssLeft) && isFinite(cssTop) && worldLayerRef) {
2693
+ if (isFinite(cssLeft) && isFinite(cssTop) && worldLayerRef && view && view.parentElement) {
2683
2694
  // Ждем один тик, чтобы HtmlTextLayer успел обновить DOM
2684
2695
  setTimeout(() => {
2685
2696
  try {
2686
- const desiredGlobal = new PIXI.Point(Math.round(cssLeft * viewRes), Math.round(cssTop * viewRes));
2687
- const desiredWorld = worldLayerRef.toLocal(desiredGlobal);
2697
+ // Используем тот же подход что в toScreen, но в обратном направлении
2698
+ const containerRect = view.parentElement.getBoundingClientRect();
2699
+ const viewRect = view.getBoundingClientRect();
2700
+ const offsetLeft = viewRect.left - containerRect.left;
2701
+ const offsetTop = viewRect.top - containerRect.top;
2702
+
2703
+ // Преобразуем CSS координаты в экранные (учитывая offset)
2704
+ const screenX = cssLeft - offsetLeft;
2705
+ const screenY = cssTop - offsetTop;
2706
+
2707
+ // Преобразуем экранные координаты в мировые
2708
+ const desiredWorld = worldLayerRef.toLocal(new PIXI.Point(screenX, screenY));
2688
2709
  const newPos = { x: Math.round(desiredWorld.x), y: Math.round(desiredWorld.y) };
2710
+
2689
2711
  this.eventBus.emit(Events.Object.StateChanged, {
2690
2712
  objectId,
2691
2713
  updates: { position: newPos }
2692
2714
  });
2693
- console.log('🧭 Text post-show align', { objectId, cssLeft, cssTop, newPos });
2715
+ console.log('🧭 Text post-show align', { objectId, cssLeft, cssTop, screenX, screenY, newPos });
2694
2716
  } catch (_) {}
2695
2717
  }, 0);
2696
2718
  }
@@ -305,14 +305,42 @@ export class HtmlTextLayer {
305
305
  el.style.lineHeight = newLH;
306
306
  }
307
307
 
308
- // Позиция и габариты в экранных координатах
309
- const left = (tx + s * x) / res;
310
- const top = (ty + s * y) / res;
311
- el.style.left = `${left}px`;
312
- el.style.top = `${top}px`;
313
- if (w && h) {
314
- el.style.width = `${Math.max(1, (w * s) / res)}px`;
315
- el.style.height = `${Math.max(1, (h * s) / res)}px`;
308
+ // Позиция и габариты в CSS координатах - используем тот же подход что в HtmlHandlesLayer
309
+ const worldLayer = this.core.pixi.worldLayer || this.core.pixi.app.stage;
310
+ const view = this.core.pixi.app.view;
311
+
312
+ if (worldLayer && view && view.parentElement) {
313
+ const containerRect = view.parentElement.getBoundingClientRect();
314
+ const viewRect = view.getBoundingClientRect();
315
+ const offsetLeft = viewRect.left - containerRect.left;
316
+ const offsetTop = viewRect.top - containerRect.top;
317
+
318
+ // Преобразуем мировые координаты в экранные через toGlobal
319
+ const tl = worldLayer.toGlobal(new PIXI.Point(x, y));
320
+ const br = worldLayer.toGlobal(new PIXI.Point(x + w, y + h));
321
+
322
+ // CSS координаты с учетом offset
323
+ const left = offsetLeft + tl.x;
324
+ const top = offsetTop + tl.y;
325
+ const width = Math.max(1, br.x - tl.x);
326
+ const height = Math.max(1, br.y - tl.y);
327
+
328
+ el.style.left = `${left}px`;
329
+ el.style.top = `${top}px`;
330
+ if (w && h) {
331
+ el.style.width = `${width}px`;
332
+ el.style.height = `${height}px`;
333
+ }
334
+ } else {
335
+ // Fallback к старому методу
336
+ const left = (tx + s * x) / res;
337
+ const top = (ty + s * y) / res;
338
+ el.style.left = `${left}px`;
339
+ el.style.top = `${top}px`;
340
+ if (w && h) {
341
+ el.style.width = `${Math.max(1, (w * s) / res)}px`;
342
+ el.style.height = `${Math.max(1, (h * s) / res)}px`;
343
+ }
316
344
  }
317
345
  // Поворот вокруг центра (как у PIXI и HTML-ручек)
318
346
  el.style.transformOrigin = 'center center';