@sequent-org/moodboard 1.2.42 → 1.2.43

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.42",
3
+ "version": "1.2.43",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
@@ -1990,7 +1990,7 @@ export class SelectTool extends BaseTool {
1990
1990
  ];
1991
1991
  } else {
1992
1992
  // Для обычного текста используем стандартное позиционирование
1993
- // Динамически компенсируем внутренние отступы textarea, чтобы каретка оказалась ровно в точке клика
1993
+ // Динамически компенсируем внутренние отступы textarea для точного совпадения со статичным текстом
1994
1994
  let padTop = 0;
1995
1995
  let padLeft = 0;
1996
1996
  let lineHeightPx = 0;
@@ -2011,8 +2011,27 @@ export class SelectTool extends BaseTool {
2011
2011
  if (r && isFinite(r.height)) lineHeightPx = r.height;
2012
2012
  } catch (_) {}
2013
2013
  }
2014
- const leftPx = create ? Math.round(screenPos.x - padLeft) : Math.round(screenPos.x);
2015
- const topPx = create ? Math.round(screenPos.y - padTop - (lineHeightPx / 2)) : Math.round(screenPos.y);
2014
+
2015
+ // Базовая точка позиционирования: для редактирования берём точные координаты статичного HTML-текста,
2016
+ // для создания — используем рассчитанные screenPos
2017
+ let baseLeftPx = screenPos.x;
2018
+ let baseTopPx = screenPos.y;
2019
+ try {
2020
+ if (!create && objectId && typeof window !== 'undefined' && window.moodboardHtmlTextLayer) {
2021
+ const el = window.moodboardHtmlTextLayer.idToEl.get(objectId);
2022
+ if (el) {
2023
+ const cssLeft = parseFloat(el.style.left || 'NaN');
2024
+ const cssTop = parseFloat(el.style.top || 'NaN');
2025
+ if (isFinite(cssLeft)) baseLeftPx = cssLeft;
2026
+ if (isFinite(cssTop)) baseTopPx = cssTop;
2027
+ }
2028
+ }
2029
+ } catch (_) {}
2030
+
2031
+ const leftPx = Math.round(baseLeftPx - padLeft);
2032
+ const topPx = create
2033
+ ? Math.round(baseTopPx - padTop - (lineHeightPx / 2)) // по клику совмещаем центр строки с точкой клика
2034
+ : Math.round(baseTopPx - padTop); // при редактировании совмещаем верх контента
2016
2035
  wrapper.style.left = `${leftPx}px`;
2017
2036
  wrapper.style.top = `${topPx}px`;
2018
2037
  // Сохраняем CSS-позицию редактора для точной синхронизации при закрытии
@@ -2023,6 +2042,7 @@ export class SelectTool extends BaseTool {
2023
2042
  console.log('🧭 Text input', {
2024
2043
  input: { left: leftPx, top: topPx },
2025
2044
  screenPos,
2045
+ baseFromStatic: (!create && objectId) ? { left: baseLeftPx, top: baseTopPx } : null,
2026
2046
  padding: { top: padTop, left: padLeft },
2027
2047
  lineHeightPx,
2028
2048
  caretCenterY: create ? (topPx + padTop + (lineHeightPx / 2)) : topPx,