@sequent-org/moodboard 1.2.98 → 1.2.99
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
|
@@ -2688,15 +2688,23 @@ export class SelectTool extends BaseTool {
|
|
|
2688
2688
|
try {
|
|
2689
2689
|
const view = this.app?.view;
|
|
2690
2690
|
const worldLayerRef = this.textEditor.world || (this.app?.stage);
|
|
2691
|
-
const viewRes = (this.app?.renderer?.resolution) || (view && view.width && view.clientWidth ? (view.width / view.clientWidth) : 1);
|
|
2692
2691
|
const cssLeft = this.textEditor._cssLeftPx;
|
|
2693
2692
|
const cssTop = this.textEditor._cssTopPx;
|
|
2694
|
-
if (isFinite(cssLeft) && isFinite(cssTop) && worldLayerRef) {
|
|
2693
|
+
if (view && view.parentElement && isFinite(cssLeft) && isFinite(cssTop) && worldLayerRef) {
|
|
2695
2694
|
// Ждем один тик, чтобы HtmlTextLayer успел обновить DOM
|
|
2696
2695
|
setTimeout(() => {
|
|
2697
2696
|
try {
|
|
2698
|
-
|
|
2699
|
-
|
|
2697
|
+
// Инвертируем ту же трансформацию, что использует HtmlHandlesLayer/HtmlTextLayer:
|
|
2698
|
+
// world → toGlobal → offset → CSS px
|
|
2699
|
+
const containerRect = view.parentElement.getBoundingClientRect();
|
|
2700
|
+
const viewRect = view.getBoundingClientRect();
|
|
2701
|
+
const offsetLeft = viewRect.left - containerRect.left;
|
|
2702
|
+
const offsetTop = viewRect.top - containerRect.top;
|
|
2703
|
+
// CSS → экранные координаты внутри canvas
|
|
2704
|
+
const screenX = cssLeft - offsetLeft;
|
|
2705
|
+
const screenY = cssTop - offsetTop;
|
|
2706
|
+
// Экранные → мировые координаты через toLocal
|
|
2707
|
+
const desiredWorld = worldLayerRef.toLocal(new PIXI.Point(screenX, screenY));
|
|
2700
2708
|
const newPos = { x: Math.round(desiredWorld.x), y: Math.round(desiredWorld.y) };
|
|
2701
2709
|
this.eventBus.emit(Events.Object.StateChanged, {
|
|
2702
2710
|
objectId,
|
package/src/ui/HtmlTextLayer.js
CHANGED
|
@@ -259,7 +259,7 @@ export class HtmlTextLayer {
|
|
|
259
259
|
if (!el || !this.core) return;
|
|
260
260
|
|
|
261
261
|
console.log(`🔍 HtmlTextLayer: обновляю позицию для текста ${objectId}`);
|
|
262
|
-
|
|
262
|
+
|
|
263
263
|
const world = this.core.pixi.worldLayer || this.core.pixi.app.stage;
|
|
264
264
|
const s = world?.scale?.x || 1;
|
|
265
265
|
const tx = world?.x || 0;
|
|
@@ -309,7 +309,12 @@ export class HtmlTextLayer {
|
|
|
309
309
|
// Позиция и габариты в CSS координатах - используем тот же подход что в HtmlHandlesLayer
|
|
310
310
|
const worldLayer = this.core.pixi.worldLayer || this.core.pixi.app.stage;
|
|
311
311
|
const view = this.core.pixi.app.view;
|
|
312
|
-
|
|
312
|
+
// Эти переменные нужны и для лога ниже, поэтому задаём их тут
|
|
313
|
+
let logLeft = 0;
|
|
314
|
+
let logTop = 0;
|
|
315
|
+
let logWidth = 0;
|
|
316
|
+
let logHeight = 0;
|
|
317
|
+
|
|
313
318
|
if (worldLayer && view && view.parentElement) {
|
|
314
319
|
const containerRect = view.parentElement.getBoundingClientRect();
|
|
315
320
|
const viewRect = view.getBoundingClientRect();
|
|
@@ -325,13 +330,20 @@ export class HtmlTextLayer {
|
|
|
325
330
|
const top = offsetTop + tl.y;
|
|
326
331
|
const width = Math.max(1, br.x - tl.x);
|
|
327
332
|
const height = Math.max(1, br.y - tl.y);
|
|
328
|
-
|
|
333
|
+
|
|
334
|
+
// Применяем к элементу
|
|
329
335
|
el.style.left = `${left}px`;
|
|
330
336
|
el.style.top = `${top}px`;
|
|
331
337
|
if (w && h) {
|
|
332
338
|
el.style.width = `${width}px`;
|
|
333
339
|
el.style.height = `${height}px`;
|
|
334
340
|
}
|
|
341
|
+
|
|
342
|
+
// Значения для лога
|
|
343
|
+
logLeft = left;
|
|
344
|
+
logTop = top;
|
|
345
|
+
logWidth = width;
|
|
346
|
+
logHeight = height;
|
|
335
347
|
} else {
|
|
336
348
|
// Fallback к старому методу
|
|
337
349
|
const left = (tx + s * x) / res;
|
|
@@ -339,9 +351,15 @@ export class HtmlTextLayer {
|
|
|
339
351
|
el.style.left = `${left}px`;
|
|
340
352
|
el.style.top = `${top}px`;
|
|
341
353
|
if (w && h) {
|
|
342
|
-
|
|
343
|
-
|
|
354
|
+
const cssW = Math.max(1, (w * s) / res);
|
|
355
|
+
const cssH = Math.max(1, (h * s) / res);
|
|
356
|
+
el.style.width = `${cssW}px`;
|
|
357
|
+
el.style.height = `${cssH}px`;
|
|
358
|
+
logWidth = cssW;
|
|
359
|
+
logHeight = cssH;
|
|
344
360
|
}
|
|
361
|
+
logLeft = left;
|
|
362
|
+
logTop = top;
|
|
345
363
|
}
|
|
346
364
|
// Поворот вокруг центра (как у PIXI и HTML-ручек)
|
|
347
365
|
el.style.transformOrigin = 'center center';
|
|
@@ -357,15 +375,19 @@ export class HtmlTextLayer {
|
|
|
357
375
|
try {
|
|
358
376
|
el.style.height = 'auto';
|
|
359
377
|
// Добавим небольшой нижний отступ для хвостов букв, чтобы не отсекались (например, у «з»)
|
|
360
|
-
const
|
|
361
|
-
el.style.height = `${
|
|
378
|
+
const hCss = Math.max(1, Math.round(el.scrollHeight + 2));
|
|
379
|
+
el.style.height = `${hCss}px`;
|
|
380
|
+
// Обновим высоту для лога, если её ещё не устанавливали
|
|
381
|
+
if (!logHeight) {
|
|
382
|
+
logHeight = hCss;
|
|
383
|
+
}
|
|
362
384
|
} catch (_) {}
|
|
363
385
|
|
|
364
386
|
console.log(`🔍 HtmlTextLayer: позиция обновлена для ${objectId}:`, {
|
|
365
|
-
left: `${
|
|
366
|
-
top: `${
|
|
367
|
-
width: `${
|
|
368
|
-
height: `${
|
|
387
|
+
left: `${logLeft}px`,
|
|
388
|
+
top: `${logTop}px`,
|
|
389
|
+
width: `${logWidth}px`,
|
|
390
|
+
height: `${logHeight}px`,
|
|
369
391
|
fontSize: `${fontSizePx}px`,
|
|
370
392
|
content: content,
|
|
371
393
|
visibility: el.style.visibility,
|