@sequent-org/moodboard 1.2.90 → 1.2.92
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
|
@@ -2037,6 +2037,12 @@ export class SelectTool extends BaseTool {
|
|
|
2037
2037
|
const correctedBaseLeftPx = baseLeftPx / zoomFactor;
|
|
2038
2038
|
const correctedBaseTopPx = baseTopPx / zoomFactor;
|
|
2039
2039
|
|
|
2040
|
+
console.log('🔍 Browser zoom detection:', {
|
|
2041
|
+
zoomFactor,
|
|
2042
|
+
basePos: { left: baseLeftPx, top: baseTopPx },
|
|
2043
|
+
correctedPos: { left: correctedBaseLeftPx, top: correctedBaseTopPx }
|
|
2044
|
+
});
|
|
2045
|
+
|
|
2040
2046
|
const leftPx = Math.round(correctedBaseLeftPx - padLeft);
|
|
2041
2047
|
const topPx = create
|
|
2042
2048
|
? Math.round(correctedBaseTopPx - padTop - (lineHeightPx / 2)) // по клику совмещаем центр строки с точкой клика
|
|
@@ -2814,14 +2820,72 @@ export class SelectTool extends BaseTool {
|
|
|
2814
2820
|
* Получение коэффициента масштабирования браузера
|
|
2815
2821
|
*/
|
|
2816
2822
|
_getBrowserZoomFactor() {
|
|
2817
|
-
//
|
|
2818
|
-
|
|
2819
|
-
const devicePixelRatio = window.devicePixelRatio || 1;
|
|
2823
|
+
// Множественные методы определения масштаба браузера для надежности
|
|
2824
|
+
let zoomFactors = [];
|
|
2820
2825
|
|
|
2821
|
-
|
|
2822
|
-
|
|
2826
|
+
try {
|
|
2827
|
+
// Метод 1: Через window размеры
|
|
2828
|
+
const outerInnerRatio = window.outerWidth / window.innerWidth;
|
|
2829
|
+
if (isFinite(outerInnerRatio) && outerInnerRatio > 0.1 && outerInnerRatio < 10) {
|
|
2830
|
+
zoomFactors.push({ method: 'outerInner', value: outerInnerRatio });
|
|
2831
|
+
}
|
|
2832
|
+
} catch (_) {}
|
|
2833
|
+
|
|
2834
|
+
try {
|
|
2835
|
+
// Метод 2: Через visualViewport если доступно
|
|
2836
|
+
if (window.visualViewport) {
|
|
2837
|
+
const vpZoom = window.innerWidth / window.visualViewport.width;
|
|
2838
|
+
if (isFinite(vpZoom) && vpZoom > 0.1 && vpZoom < 10) {
|
|
2839
|
+
zoomFactors.push({ method: 'visualViewport', value: vpZoom });
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
} catch (_) {}
|
|
2843
|
+
|
|
2844
|
+
try {
|
|
2845
|
+
// Метод 3: Через тестовый элемент (проверяем разные единицы)
|
|
2846
|
+
const testEl = document.createElement('div');
|
|
2847
|
+
testEl.style.position = 'absolute';
|
|
2848
|
+
testEl.style.left = '-9999px';
|
|
2849
|
+
testEl.style.top = '-9999px';
|
|
2850
|
+
testEl.style.width = '100px';
|
|
2851
|
+
testEl.style.height = '100px';
|
|
2852
|
+
testEl.style.visibility = 'hidden';
|
|
2853
|
+
testEl.style.pointerEvents = 'none';
|
|
2854
|
+
|
|
2855
|
+
document.body.appendChild(testEl);
|
|
2856
|
+
|
|
2857
|
+
const rect = testEl.getBoundingClientRect();
|
|
2858
|
+
const elemZoom = 100 / rect.width;
|
|
2859
|
+
|
|
2860
|
+
document.body.removeChild(testEl);
|
|
2861
|
+
|
|
2862
|
+
if (isFinite(elemZoom) && elemZoom > 0.1 && elemZoom < 10) {
|
|
2863
|
+
zoomFactors.push({ method: 'testElement', value: elemZoom });
|
|
2864
|
+
}
|
|
2865
|
+
} catch (_) {}
|
|
2866
|
+
|
|
2867
|
+
// Логирование всех методов для диагностики
|
|
2868
|
+
console.log('🔍 Zoom detection methods:', zoomFactors);
|
|
2869
|
+
|
|
2870
|
+
// Выбираем наиболее подходящий результат
|
|
2871
|
+
if (zoomFactors.length === 0) {
|
|
2872
|
+
return 1.0; // Fallback
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
// Если есть visualViewport, предпочитаем его
|
|
2876
|
+
const vpMethod = zoomFactors.find(f => f.method === 'visualViewport');
|
|
2877
|
+
if (vpMethod) {
|
|
2878
|
+
return vpMethod.value;
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2881
|
+
// Иначе берем outerInner как наиболее стабильный
|
|
2882
|
+
const outerMethod = zoomFactors.find(f => f.method === 'outerInner');
|
|
2883
|
+
if (outerMethod) {
|
|
2884
|
+
return outerMethod.value;
|
|
2885
|
+
}
|
|
2823
2886
|
|
|
2824
|
-
|
|
2887
|
+
// Последний fallback - первый доступный метод
|
|
2888
|
+
return zoomFactors[0].value;
|
|
2825
2889
|
}
|
|
2826
2890
|
|
|
2827
2891
|
}
|
package/src/ui/HtmlTextLayer.js
CHANGED
|
@@ -376,14 +376,69 @@ export class HtmlTextLayer {
|
|
|
376
376
|
* Получение коэффициента масштабирования браузера
|
|
377
377
|
*/
|
|
378
378
|
_getBrowserZoomFactor() {
|
|
379
|
-
//
|
|
380
|
-
|
|
381
|
-
const devicePixelRatio = window.devicePixelRatio || 1;
|
|
379
|
+
// Множественные методы определения масштаба браузера для надежности
|
|
380
|
+
let zoomFactors = [];
|
|
382
381
|
|
|
383
|
-
|
|
384
|
-
|
|
382
|
+
try {
|
|
383
|
+
// Метод 1: Через window размеры
|
|
384
|
+
const outerInnerRatio = window.outerWidth / window.innerWidth;
|
|
385
|
+
if (isFinite(outerInnerRatio) && outerInnerRatio > 0.1 && outerInnerRatio < 10) {
|
|
386
|
+
zoomFactors.push({ method: 'outerInner', value: outerInnerRatio });
|
|
387
|
+
}
|
|
388
|
+
} catch (_) {}
|
|
389
|
+
|
|
390
|
+
try {
|
|
391
|
+
// Метод 2: Через visualViewport если доступно
|
|
392
|
+
if (window.visualViewport) {
|
|
393
|
+
const vpZoom = window.innerWidth / window.visualViewport.width;
|
|
394
|
+
if (isFinite(vpZoom) && vpZoom > 0.1 && vpZoom < 10) {
|
|
395
|
+
zoomFactors.push({ method: 'visualViewport', value: vpZoom });
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
} catch (_) {}
|
|
399
|
+
|
|
400
|
+
try {
|
|
401
|
+
// Метод 3: Через тестовый элемент (проверяем разные единицы)
|
|
402
|
+
const testEl = document.createElement('div');
|
|
403
|
+
testEl.style.position = 'absolute';
|
|
404
|
+
testEl.style.left = '-9999px';
|
|
405
|
+
testEl.style.top = '-9999px';
|
|
406
|
+
testEl.style.width = '100px';
|
|
407
|
+
testEl.style.height = '100px';
|
|
408
|
+
testEl.style.visibility = 'hidden';
|
|
409
|
+
testEl.style.pointerEvents = 'none';
|
|
410
|
+
|
|
411
|
+
document.body.appendChild(testEl);
|
|
412
|
+
|
|
413
|
+
const rect = testEl.getBoundingClientRect();
|
|
414
|
+
const elemZoom = 100 / rect.width;
|
|
415
|
+
|
|
416
|
+
document.body.removeChild(testEl);
|
|
417
|
+
|
|
418
|
+
if (isFinite(elemZoom) && elemZoom > 0.1 && elemZoom < 10) {
|
|
419
|
+
zoomFactors.push({ method: 'testElement', value: elemZoom });
|
|
420
|
+
}
|
|
421
|
+
} catch (_) {}
|
|
422
|
+
|
|
423
|
+
// Выбираем наиболее подходящий результат
|
|
424
|
+
if (zoomFactors.length === 0) {
|
|
425
|
+
return 1.0; // Fallback
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// Если есть visualViewport, предпочитаем его
|
|
429
|
+
const vpMethod = zoomFactors.find(f => f.method === 'visualViewport');
|
|
430
|
+
if (vpMethod) {
|
|
431
|
+
return vpMethod.value;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// Иначе берем outerInner как наиболее стабильный
|
|
435
|
+
const outerMethod = zoomFactors.find(f => f.method === 'outerInner');
|
|
436
|
+
if (outerMethod) {
|
|
437
|
+
return outerMethod.value;
|
|
438
|
+
}
|
|
385
439
|
|
|
386
|
-
|
|
440
|
+
// Последний fallback - первый доступный метод
|
|
441
|
+
return zoomFactors[0].value;
|
|
387
442
|
}
|
|
388
443
|
}
|
|
389
444
|
|