@sequent-org/moodboard 1.4.71 → 1.4.72

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.4.71",
3
+ "version": "1.4.72",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
@@ -185,7 +185,11 @@ export function setupLayerAndViewportFlow(core) {
185
185
  settings: { pan: { x: world.x || 0, y: world.y || 0 } }
186
186
  });
187
187
  } catch (_) {}
188
- core.eventBus.emit(Events.Viewport.Changed);
188
+ // Во время pan не эмитим Viewport.Changed: все viewport-реактивные компоненты
189
+ // уже репозиционируются по Tool.PanUpdate, а повторный Viewport.Changed заставлял
190
+ // их пересчитываться дважды за одно движение. Сетка — единственный получатель
191
+ // Viewport.Changed без подписки на PanUpdate — обновляется прямым вызовом.
192
+ core.boardService?.refreshGridViewport?.();
189
193
  });
190
194
 
191
195
  core.eventBus.on(Events.UI.ZoomSelection, () => {
@@ -2090,7 +2090,38 @@ export class ChatWindow {
2090
2090
  return y;
2091
2091
  }
2092
2092
 
2093
+ _getViewportCenter() {
2094
+ const rect = this._container?.getBoundingClientRect?.();
2095
+ if (rect && rect.width > 0 && rect.height > 0) {
2096
+ return {
2097
+ x: Math.round(rect.left + rect.width / 2),
2098
+ y: Math.round(rect.top + rect.height / 2)
2099
+ };
2100
+ }
2101
+ return null;
2102
+ }
2103
+
2093
2104
  _getImageGroupAnchor() {
2105
+ // Базовый якорь — центр видимой области холста: центр заглушки (и итогового
2106
+ // изображения) должен совпадать с серединой экрана. Ряд из нескольких изображений
2107
+ // держим на общей горизонтальной оси через existingCenterY.
2108
+ const viewportCenter = this._getViewportCenter();
2109
+ if (viewportCenter) {
2110
+ const existingCenterY = this._getAiImageLaneCenterScreenY();
2111
+ const [wr, hr] = parseFormatRatio(this._formatId);
2112
+ const actualHeight = Math.round(BOARD_IMAGE_WIDTH / (wr / hr));
2113
+
2114
+ let y = existingCenterY ?? viewportCenter.y;
2115
+ if (existingCenterY == null) {
2116
+ y = this._clampImageGroupAnchorY(y, actualHeight, 0);
2117
+ }
2118
+
2119
+ return {
2120
+ x: viewportCenter.x,
2121
+ y: Math.round(y)
2122
+ };
2123
+ }
2124
+
2094
2125
  const composerRect = this._refs?.composer?.getBoundingClientRect?.();
2095
2126
  if (composerRect) {
2096
2127
  const existingCenterY = this._getAiImageLaneCenterScreenY();
@@ -260,27 +260,6 @@ function createFontControls(panelInstance, panel) {
260
260
 
261
261
  createCompactBackgroundSelector(panelInstance, panel);
262
262
 
263
- const mdSeparator = document.createElement('div');
264
- mdSeparator.style.cssText = 'width:1px;height:18px;background:#e0e0e0;margin:0 6px;flex-shrink:0;';
265
- panel.appendChild(mdSeparator);
266
-
267
- const mdId = `tpp-md-${Date.now()}`;
268
- panelInstance.markdownToggle = document.createElement('input');
269
- panelInstance.markdownToggle.type = 'checkbox';
270
- panelInstance.markdownToggle.id = mdId;
271
- panelInstance.markdownToggle.className = 'tpp-md-toggle';
272
- panelInstance.markdownToggle.style.cssText = 'width:14px;height:14px;cursor:pointer;flex-shrink:0;';
273
-
274
- const mdLabel = document.createElement('label');
275
- mdLabel.htmlFor = mdId;
276
- mdLabel.textContent = 'MD';
277
- mdLabel.title = 'Отображать как Markdown';
278
- mdLabel.className = 'tpp-label';
279
- mdLabel.style.cssText = 'cursor:pointer;user-select:none;';
280
-
281
- panel.appendChild(panelInstance.markdownToggle);
282
- panel.appendChild(mdLabel);
283
-
284
263
  createTextFormatControls(panelInstance, panel);
285
264
 
286
265
  createTextLockMoreControls(panelInstance, panel);