@sequent-org/moodboard 1.2.38 → 1.2.40

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.38",
3
+ "version": "1.2.40",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
@@ -1993,17 +1993,26 @@ export class SelectTool extends BaseTool {
1993
1993
  // Динамически компенсируем внутренние отступы textarea, чтобы каретка оказалась ровно в точке клика
1994
1994
  let padTop = 0;
1995
1995
  let padLeft = 0;
1996
+ let lineHeightPx = 0;
1996
1997
  try {
1997
1998
  if (typeof window !== 'undefined' && window.getComputedStyle) {
1998
1999
  const cs = window.getComputedStyle(textarea);
1999
2000
  const pt = parseFloat(cs.paddingTop);
2000
2001
  const pl = parseFloat(cs.paddingLeft);
2002
+ const lh = parseFloat(cs.lineHeight);
2001
2003
  if (isFinite(pt)) padTop = pt;
2002
2004
  if (isFinite(pl)) padLeft = pl;
2005
+ if (isFinite(lh)) lineHeightPx = lh;
2003
2006
  }
2004
2007
  } catch (_) {}
2008
+ if (!isFinite(lineHeightPx) || lineHeightPx <= 0) {
2009
+ try {
2010
+ const r = textarea.getBoundingClientRect && textarea.getBoundingClientRect();
2011
+ if (r && isFinite(r.height)) lineHeightPx = r.height;
2012
+ } catch (_) {}
2013
+ }
2005
2014
  const leftPx = create ? Math.round(screenPos.x - padLeft) : Math.round(screenPos.x);
2006
- const topPx = create ? Math.round(screenPos.y - padTop) : Math.round(screenPos.y);
2015
+ const topPx = create ? Math.round(screenPos.y - padTop - (lineHeightPx / 2)) : Math.round(screenPos.y);
2007
2016
  wrapper.style.left = `${leftPx}px`;
2008
2017
  wrapper.style.top = `${topPx}px`;
2009
2018
  // Диагностика: логируем позицию инпута и вычисленные параметры позиционирования
@@ -2012,9 +2021,29 @@ export class SelectTool extends BaseTool {
2012
2021
  input: { left: leftPx, top: topPx },
2013
2022
  screenPos,
2014
2023
  padding: { top: padTop, left: padLeft },
2024
+ lineHeightPx,
2025
+ caretCenterY: create ? (topPx + padTop + (lineHeightPx / 2)) : topPx,
2015
2026
  create
2016
2027
  });
2017
2028
  } catch (_) {}
2029
+
2030
+ // Для новых текстов: синхронизируем мировую позицию объекта с фактической позицией wrapper,
2031
+ // чтобы после закрытия редактора статичный текст встал ровно туда же без сдвига
2032
+ try {
2033
+ if (create && objectId) {
2034
+ const worldLayerRef = this.textEditor.world || (this.app?.stage);
2035
+ const viewRes = (this.app?.renderer?.resolution) || (view.width && view.clientWidth ? (view.width / view.clientWidth) : 1);
2036
+ const globalPoint = new PIXI.Point(Math.round(leftPx * viewRes), Math.round(topPx * viewRes));
2037
+ const worldPoint = worldLayerRef && worldLayerRef.toLocal ? worldLayerRef.toLocal(globalPoint) : { x: position.x, y: position.y };
2038
+ const newWorldPos = { x: Math.round(worldPoint.x), y: Math.round(worldPoint.y) };
2039
+ this.eventBus.emit(Events.Object.StateChanged, {
2040
+ objectId: objectId,
2041
+ updates: { position: newWorldPos }
2042
+ });
2043
+ // Диагностика
2044
+ console.log('🧭 Text position sync', { objectId, newWorldPos, leftPx, topPx, viewRes });
2045
+ }
2046
+ } catch (_) {}
2018
2047
  }
2019
2048
  // Минимальные границы (зависят от текущего режима: новый объект или редактирование существующего)
2020
2049
  const worldLayerRef = this.textEditor.world || (this.app?.stage);