@sequent-org/moodboard 1.2.40 → 1.2.42

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.40",
3
+ "version": "1.2.42",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
@@ -2015,6 +2015,9 @@ export class SelectTool extends BaseTool {
2015
2015
  const topPx = create ? Math.round(screenPos.y - padTop - (lineHeightPx / 2)) : Math.round(screenPos.y);
2016
2016
  wrapper.style.left = `${leftPx}px`;
2017
2017
  wrapper.style.top = `${topPx}px`;
2018
+ // Сохраняем CSS-позицию редактора для точной синхронизации при закрытии
2019
+ this.textEditor._cssLeftPx = leftPx;
2020
+ this.textEditor._cssTopPx = topPx;
2018
2021
  // Диагностика: логируем позицию инпута и вычисленные параметры позиционирования
2019
2022
  try {
2020
2023
  console.log('🧭 Text input', {
@@ -2033,7 +2036,10 @@ export class SelectTool extends BaseTool {
2033
2036
  if (create && objectId) {
2034
2037
  const worldLayerRef = this.textEditor.world || (this.app?.stage);
2035
2038
  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));
2039
+ // Статичный HTML-текст не имеет верхнего внутреннего отступа (HtmlTextLayer ставит padding: 0),
2040
+ // поэтому добавляем padTop к topPx при расчёте мировых координат
2041
+ const yCssStaticTop = Math.round(topPx + padTop);
2042
+ const globalPoint = new PIXI.Point(Math.round(leftPx * viewRes), Math.round(yCssStaticTop * viewRes));
2037
2043
  const worldPoint = worldLayerRef && worldLayerRef.toLocal ? worldLayerRef.toLocal(globalPoint) : { x: position.x, y: position.y };
2038
2044
  const newWorldPos = { x: Math.round(worldPoint.x), y: Math.round(worldPoint.y) };
2039
2045
  this.eventBus.emit(Events.Object.StateChanged, {
@@ -2041,7 +2047,7 @@ export class SelectTool extends BaseTool {
2041
2047
  updates: { position: newWorldPos }
2042
2048
  });
2043
2049
  // Диагностика
2044
- console.log('🧭 Text position sync', { objectId, newWorldPos, leftPx, topPx, viewRes });
2050
+ console.log('🧭 Text position sync', { objectId, newWorldPos, leftPx, topPx, yCssStaticTop, padTop, viewRes });
2045
2051
  }
2046
2052
  } catch (_) {}
2047
2053
  }
@@ -2589,6 +2595,29 @@ export class SelectTool extends BaseTool {
2589
2595
  const el = window.moodboardHtmlTextLayer.idToEl.get(objectId);
2590
2596
  if (el) {
2591
2597
  this.eventBus.emit(Events.Tool.ShowObjectText, { objectId });
2598
+ // После отображения статичного текста — выровняем его позицию ровно под textarea
2599
+ try {
2600
+ const view = this.app?.view;
2601
+ const worldLayerRef = this.textEditor.world || (this.app?.stage);
2602
+ const viewRes = (this.app?.renderer?.resolution) || (view && view.width && view.clientWidth ? (view.width / view.clientWidth) : 1);
2603
+ const cssLeft = this.textEditor._cssLeftPx;
2604
+ const cssTop = this.textEditor._cssTopPx;
2605
+ if (isFinite(cssLeft) && isFinite(cssTop) && worldLayerRef) {
2606
+ // Ждем один тик, чтобы HtmlTextLayer успел обновить DOM
2607
+ setTimeout(() => {
2608
+ try {
2609
+ const desiredGlobal = new PIXI.Point(Math.round(cssLeft * viewRes), Math.round(cssTop * viewRes));
2610
+ const desiredWorld = worldLayerRef.toLocal(desiredGlobal);
2611
+ const newPos = { x: Math.round(desiredWorld.x), y: Math.round(desiredWorld.y) };
2612
+ this.eventBus.emit(Events.Object.StateChanged, {
2613
+ objectId,
2614
+ updates: { position: newPos }
2615
+ });
2616
+ console.log('🧭 Text post-show align', { objectId, cssLeft, cssTop, newPos });
2617
+ } catch (_) {}
2618
+ }, 0);
2619
+ }
2620
+ } catch (_) {}
2592
2621
  } else {
2593
2622
  console.warn(`❌ SelectTool: HTML-элемент для объекта ${objectId} не найден, пропускаем ShowObjectText`);
2594
2623
  }