@sequent-org/moodboard 1.2.35 → 1.2.37

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.35",
3
+ "version": "1.2.37",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
@@ -48,11 +48,9 @@ export class PlacementTool extends BaseTool {
48
48
  this.app.view.style.cursor = (cur === 'default') ? '' : cur;
49
49
  }
50
50
 
51
- // Показываем призрак для текста, записки, эмоджи, фрейма или фигур, если они активны
51
+ // Показываем призрак для записки, эмоджи, фрейма или фигур, если они активны
52
52
  if (this.pending && this.app && this.world) {
53
- if (this.pending.type === 'text') {
54
- this.showTextGhost();
55
- } else if (this.pending.type === 'note') {
53
+ if (this.pending.type === 'note') {
56
54
  this.showNoteGhost();
57
55
  } else if (this.pending.type === 'emoji') {
58
56
  this.showEmojiGhost();
@@ -154,9 +152,7 @@ export class PlacementTool extends BaseTool {
154
152
  } else if (this.selectedImage) {
155
153
  this.showImageGhost();
156
154
  } else if (this.pending) {
157
- if (this.pending.type === 'text') {
158
- this.showTextGhost();
159
- } else if (this.pending.type === 'note') {
155
+ if (this.pending.type === 'note') {
160
156
  this.showNoteGhost();
161
157
  } else if (this.pending.type === 'emoji') {
162
158
  this.showEmojiGhost();
@@ -256,14 +252,10 @@ export class PlacementTool extends BaseTool {
256
252
  };
257
253
 
258
254
  if (isTextWithEditing) {
259
- // Для текста используем те же размеры, что и у "призрака",
260
- // чтобы позиция совпадала пиксель-в-пиксель
261
- const fontSize = props.fontSize || 18;
262
- const ghostWidth = 120;
263
- const ghostHeight = fontSize + 20;
255
+ // Для текста позиция должна совпадать с точкой клика без смещений
264
256
  position = {
265
- x: Math.round(worldPoint.x - ghostWidth / 2),
266
- y: Math.round(worldPoint.y - ghostHeight / 2)
257
+ x: Math.round(worldPoint.x),
258
+ y: Math.round(worldPoint.y)
267
259
  };
268
260
  // Слушаем событие создания объекта, чтобы получить его ID
269
261
  const handleObjectCreated = (objectData) => {
@@ -1990,8 +1990,22 @@ export class SelectTool extends BaseTool {
1990
1990
  ];
1991
1991
  } else {
1992
1992
  // Для обычного текста используем стандартное позиционирование
1993
- wrapper.style.left = `${screenPos.x}px`;
1994
- wrapper.style.top = `${screenPos.y}px`;
1993
+ // Динамически компенсируем внутренние отступы textarea, чтобы каретка оказалась ровно в точке клика
1994
+ let padTop = 0;
1995
+ let padLeft = 0;
1996
+ try {
1997
+ if (typeof window !== 'undefined' && window.getComputedStyle) {
1998
+ const cs = window.getComputedStyle(textarea);
1999
+ const pt = parseFloat(cs.paddingTop);
2000
+ const pl = parseFloat(cs.paddingLeft);
2001
+ if (isFinite(pt)) padTop = pt;
2002
+ if (isFinite(pl)) padLeft = pl;
2003
+ }
2004
+ } catch (_) {}
2005
+ 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);
2007
+ wrapper.style.left = `${leftPx}px`;
2008
+ wrapper.style.top = `${topPx}px`;
1995
2009
  }
1996
2010
  // Минимальные границы (зависят от текущего режима: новый объект или редактирование существующего)
1997
2011
  const worldLayerRef = this.textEditor.world || (this.app?.stage);