kingkont 0.7.43 → 0.7.44

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": "kingkont",
3
- "version": "0.7.43",
3
+ "version": "0.7.44",
4
4
  "description": "KingKont \u00b7 Chatium \u2014 \u043d\u043e\u0434-\u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u0441\u0446\u0435\u043d \u0441 AI-\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439 (\u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438/\u0432\u0438\u0434\u0435\u043e/\u0433\u043e\u043b\u043e\u0441/SFX/\u043c\u0443\u0437\u044b\u043a\u0430/\u0442\u0435\u043a\u0441\u0442)",
5
5
  "main": "main.js",
6
6
  "bin": {
@@ -492,9 +492,42 @@ function attachResize(el, node, handle) {
492
492
  e.stopPropagation();
493
493
  const startX = e.clientX, startY = e.clientY;
494
494
  const startW = el.offsetWidth, startH = el.offsetHeight;
495
+
496
+ // Aspect-lock для image/video: соблюдаем ratio оригинала. Берём nat-
497
+ // ural размеры media-элемента, считаем chrome (header + footer + padding)
498
+ // как разницу высоты ноды и высоты media. На этапе resize меняем ту ось,
499
+ // куда юзер двигает сильнее, вторая подстраивается. Если media ещё не
500
+ // загружена (naturalW/H = 0) — fallback на свободный resize как раньше.
501
+ let aspect = null, chromeH = 0;
502
+ if (node.type === 'image' || node.type === 'video') {
503
+ const mediaEl = el.querySelector('.node-body img, .node-body video');
504
+ const natW = mediaEl?.naturalWidth || mediaEl?.videoWidth || 0;
505
+ const natH = mediaEl?.naturalHeight || mediaEl?.videoHeight || 0;
506
+ const mediaH = mediaEl?.offsetHeight || 0;
507
+ if (natW && natH && mediaH > 0) {
508
+ aspect = natW / natH;
509
+ chromeH = Math.max(0, startH - mediaH);
510
+ }
511
+ }
512
+
495
513
  const onMove = ev => {
496
- const w = Math.max(180, startW + (ev.clientX - startX) / state.zoom);
497
- const h = Math.max(80, startH + (ev.clientY - startY) / state.zoom);
514
+ let w = Math.max(180, startW + (ev.clientX - startX) / state.zoom);
515
+ let h = Math.max(80, startH + (ev.clientY - startY) / state.zoom);
516
+ if (aspect) {
517
+ const dx = Math.abs(ev.clientX - startX);
518
+ const dy = Math.abs(ev.clientY - startY);
519
+ if (dx >= dy) {
520
+ // Ширина — ведущая, высота под неё.
521
+ h = w / aspect + chromeH;
522
+ } else {
523
+ // Высота — ведущая, ширина под неё.
524
+ const mediaH = h - chromeH;
525
+ if (mediaH > 0) w = mediaH * aspect;
526
+ }
527
+ // Заново соблюдаем минимумы после aspect-clamp.
528
+ if (w < 180) { w = 180; h = w / aspect + chromeH; }
529
+ if (h < 80) { h = 80; w = Math.max(180, (h - chromeH) * aspect); }
530
+ }
498
531
  node.width = w;
499
532
  node.height = h;
500
533
  el.style.width = w + 'px';