@sequent-org/moodboard 1.2.89 → 1.2.91

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.89",
3
+ "version": "1.2.91",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
@@ -235,12 +235,7 @@ export class PlacementTool extends BaseTool {
235
235
  return;
236
236
  }
237
237
 
238
- // Учитываем масштаб браузера для корректных координат
239
- const zoomFactor = this._getBrowserZoomFactor();
240
- const correctedX = event.x * zoomFactor;
241
- const correctedY = event.y * zoomFactor;
242
-
243
- const worldPoint = this._toWorld(correctedX, correctedY);
238
+ const worldPoint = this._toWorld(event.x, event.y);
244
239
  // Базовая позиция (может быть переопределена для конкретных типов)
245
240
  let position = {
246
241
  x: Math.round(worldPoint.x - (this.pending.size?.width ?? 100) / 2),
@@ -262,9 +257,7 @@ export class PlacementTool extends BaseTool {
262
257
  try {
263
258
  console.log('🧭 Text click', {
264
259
  cursor: { x: event.x, y: event.y },
265
- corrected: { x: correctedX, y: correctedY },
266
- world: { x: Math.round(worldPoint.x), y: Math.round(worldPoint.y) },
267
- zoomFactor: zoomFactor
260
+ world: { x: Math.round(worldPoint.x), y: Math.round(worldPoint.y) }
268
261
  });
269
262
  } catch (_) {}
270
263
  position = {
@@ -538,19 +531,6 @@ export class PlacementTool extends BaseTool {
538
531
  return world || this.app.stage;
539
532
  }
540
533
 
541
- /**
542
- * Получение коэффициента масштабирования браузера
543
- */
544
- _getBrowserZoomFactor() {
545
- // Определяем масштаб браузера разными способами
546
- const outerInnerRatio = window.outerWidth / window.innerWidth;
547
- const devicePixelRatio = window.devicePixelRatio || 1;
548
-
549
- // Используемый подход: соотношение размеров окна браузера
550
- const zoomFactor = outerInnerRatio;
551
-
552
- return Math.max(0.1, Math.min(5, zoomFactor)); // Ограничиваем разумными пределами
553
- }
554
534
 
555
535
  /**
556
536
  * Обработчик движения мыши для обновления позиции "призрака"
@@ -1849,13 +1849,7 @@ export class SelectTool extends BaseTool {
1849
1849
  if (!worldLayer) return { x: wx, y: wy };
1850
1850
  const global = worldLayer.toGlobal(new PIXI.Point(wx, wy));
1851
1851
  const viewRes = (this.app?.renderer?.resolution) || (view.width && view.clientWidth ? (view.width / view.clientWidth) : 1);
1852
-
1853
- // Учитываем масштаб браузера при позиционировании HTML элементов
1854
- const zoomFactor = this._getBrowserZoomFactor();
1855
- return {
1856
- x: (global.x / viewRes) / zoomFactor,
1857
- y: (global.y / viewRes) / zoomFactor
1858
- };
1852
+ return { x: global.x / viewRes, y: global.y / viewRes };
1859
1853
  };
1860
1854
  const screenPos = toScreen(position.x, position.y);
1861
1855
 
@@ -2038,10 +2032,21 @@ export class SelectTool extends BaseTool {
2038
2032
  }
2039
2033
  } catch (_) {}
2040
2034
 
2041
- const leftPx = Math.round(baseLeftPx - padLeft);
2035
+ // Учитываем масштаб браузера для позиционирования формы редактирования
2036
+ const zoomFactor = this._getBrowserZoomFactor();
2037
+ const correctedBaseLeftPx = baseLeftPx / zoomFactor;
2038
+ const correctedBaseTopPx = baseTopPx / zoomFactor;
2039
+
2040
+ console.log('🔍 Browser zoom detection:', {
2041
+ zoomFactor,
2042
+ basePos: { left: baseLeftPx, top: baseTopPx },
2043
+ correctedPos: { left: correctedBaseLeftPx, top: correctedBaseTopPx }
2044
+ });
2045
+
2046
+ const leftPx = Math.round(correctedBaseLeftPx - padLeft);
2042
2047
  const topPx = create
2043
- ? Math.round(baseTopPx - padTop - (lineHeightPx / 2)) // по клику совмещаем центр строки с точкой клика
2044
- : Math.round(baseTopPx - padTop); // при редактировании совмещаем верх контента
2048
+ ? Math.round(correctedBaseTopPx - padTop - (lineHeightPx / 2)) // по клику совмещаем центр строки с точкой клика
2049
+ : Math.round(correctedBaseTopPx - padTop); // при редактировании совмещаем верх контента
2045
2050
  wrapper.style.left = `${leftPx}px`;
2046
2051
  wrapper.style.top = `${topPx}px`;
2047
2052
  // Сохраняем CSS-позицию редактора для точной синхронизации при закрытии
@@ -2815,14 +2820,34 @@ export class SelectTool extends BaseTool {
2815
2820
  * Получение коэффициента масштабирования браузера
2816
2821
  */
2817
2822
  _getBrowserZoomFactor() {
2818
- // Определяем масштаб браузера разными способами
2819
- const outerInnerRatio = window.outerWidth / window.innerWidth;
2820
- const devicePixelRatio = window.devicePixelRatio || 1;
2821
-
2822
- // Используемый подход: соотношение размеров окна браузера
2823
- const zoomFactor = outerInnerRatio;
2823
+ // Более надежный способ определения масштаба браузера
2824
+ try {
2825
+ // Создаем тестовый элемент с фиксированными размерами
2826
+ const testEl = document.createElement('div');
2827
+ testEl.style.position = 'absolute';
2828
+ testEl.style.left = '-9999px';
2829
+ testEl.style.top = '-9999px';
2830
+ testEl.style.width = '100px';
2831
+ testEl.style.height = '100px';
2832
+ testEl.style.visibility = 'hidden';
2833
+ testEl.style.pointerEvents = 'none';
2834
+
2835
+ document.body.appendChild(testEl);
2836
+
2837
+ // Измеряем реальные размеры
2838
+ const rect = testEl.getBoundingClientRect();
2839
+ const zoomFactor = 100 / rect.width; // 100px / реальная ширина
2840
+
2841
+ document.body.removeChild(testEl);
2842
+
2843
+ // Проверяем разумность результата
2844
+ if (isFinite(zoomFactor) && zoomFactor > 0.1 && zoomFactor < 10) {
2845
+ return zoomFactor;
2846
+ }
2847
+ } catch (_) {}
2824
2848
 
2825
- return Math.max(0.1, Math.min(5, zoomFactor)); // Ограничиваем разумными пределами
2849
+ // Fallback: без коррекции
2850
+ return 1.0;
2826
2851
  }
2827
2852
 
2828
2853
  }
@@ -376,14 +376,34 @@ export class HtmlTextLayer {
376
376
  * Получение коэффициента масштабирования браузера
377
377
  */
378
378
  _getBrowserZoomFactor() {
379
- // Определяем масштаб браузера разными способами
380
- const outerInnerRatio = window.outerWidth / window.innerWidth;
381
- const devicePixelRatio = window.devicePixelRatio || 1;
382
-
383
- // Используемый подход: соотношение размеров окна браузера
384
- const zoomFactor = outerInnerRatio;
379
+ // Более надежный способ определения масштаба браузера
380
+ try {
381
+ // Создаем тестовый элемент с фиксированными размерами
382
+ const testEl = document.createElement('div');
383
+ testEl.style.position = 'absolute';
384
+ testEl.style.left = '-9999px';
385
+ testEl.style.top = '-9999px';
386
+ testEl.style.width = '100px';
387
+ testEl.style.height = '100px';
388
+ testEl.style.visibility = 'hidden';
389
+ testEl.style.pointerEvents = 'none';
390
+
391
+ document.body.appendChild(testEl);
392
+
393
+ // Измеряем реальные размеры
394
+ const rect = testEl.getBoundingClientRect();
395
+ const zoomFactor = 100 / rect.width; // 100px / реальная ширина
396
+
397
+ document.body.removeChild(testEl);
398
+
399
+ // Проверяем разумность результата
400
+ if (isFinite(zoomFactor) && zoomFactor > 0.1 && zoomFactor < 10) {
401
+ return zoomFactor;
402
+ }
403
+ } catch (_) {}
385
404
 
386
- return Math.max(0.1, Math.min(5, zoomFactor)); // Ограничиваем разумными пределами
405
+ // Fallback: без коррекции
406
+ return 1.0;
387
407
  }
388
408
  }
389
409