@sequent-org/moodboard 1.2.43 → 1.2.45
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
package/src/tools/ToolManager.js
CHANGED
|
@@ -176,7 +176,17 @@ export class ToolManager {
|
|
|
176
176
|
}
|
|
177
177
|
});
|
|
178
178
|
this.container.addEventListener('dblclick', (e) => this.handleDoubleClick(e));
|
|
179
|
-
|
|
179
|
+
// wheel должен быть non-passive, чтобы preventDefault работал корректно
|
|
180
|
+
this.container.addEventListener('wheel', (e) => this.handleMouseWheel(e), { passive: false });
|
|
181
|
+
// Блокируем системный зум браузера (Ctrl + колесо) над рабочей областью
|
|
182
|
+
this._onWindowWheel = (e) => {
|
|
183
|
+
try {
|
|
184
|
+
if (e && e.ctrlKey && this.isMouseOverContainer) {
|
|
185
|
+
e.preventDefault();
|
|
186
|
+
}
|
|
187
|
+
} catch (_) {}
|
|
188
|
+
};
|
|
189
|
+
window.addEventListener('wheel', this._onWindowWheel, { passive: false });
|
|
180
190
|
|
|
181
191
|
// События клавиатуры (на document)
|
|
182
192
|
document.addEventListener('keydown', (e) => this.handleKeyDown(e));
|
|
@@ -599,5 +609,10 @@ export class ToolManager {
|
|
|
599
609
|
|
|
600
610
|
document.removeEventListener('keydown', this.handleKeyDown);
|
|
601
611
|
document.removeEventListener('keyup', this.handleKeyUp);
|
|
612
|
+
// Снимаем глобальный блокировщик Ctrl+колесо
|
|
613
|
+
if (this._onWindowWheel) {
|
|
614
|
+
try { window.removeEventListener('wheel', this._onWindowWheel); } catch (_) {}
|
|
615
|
+
this._onWindowWheel = null;
|
|
616
|
+
}
|
|
602
617
|
}
|
|
603
618
|
}
|
|
@@ -473,6 +473,10 @@ export class SelectTool extends BaseTool {
|
|
|
473
473
|
type: 'text',
|
|
474
474
|
position: posData.position,
|
|
475
475
|
properties: { content: textContent },
|
|
476
|
+
caretClick: {
|
|
477
|
+
clientX: event?.originalEvent?.clientX,
|
|
478
|
+
clientY: event?.originalEvent?.clientY
|
|
479
|
+
},
|
|
476
480
|
create: false
|
|
477
481
|
});
|
|
478
482
|
return;
|
|
@@ -2180,6 +2184,59 @@ export class SelectTool extends BaseTool {
|
|
|
2180
2184
|
document.head.appendChild(styleEl);
|
|
2181
2185
|
this.textEditor = { active: true, objectId, textarea, wrapper, world: this.textEditor.world, position, properties: { fontSize }, objectType, _phStyle: styleEl };
|
|
2182
2186
|
|
|
2187
|
+
// Если переходим в редактирование существующего текста по двойному клику,
|
|
2188
|
+
// устанавливаем каретку по координате клика между буквами
|
|
2189
|
+
try {
|
|
2190
|
+
const click = (object && object.caretClick) ? object.caretClick : null;
|
|
2191
|
+
if (!create && objectId && click && typeof window !== 'undefined') {
|
|
2192
|
+
setTimeout(() => {
|
|
2193
|
+
try {
|
|
2194
|
+
const el = window.moodboardHtmlTextLayer ? window.moodboardHtmlTextLayer.idToEl.get(objectId) : null;
|
|
2195
|
+
const fullText = (typeof textarea.value === 'string') ? textarea.value : '';
|
|
2196
|
+
if (!el || !fullText || !el.firstChild) return;
|
|
2197
|
+
const textNode = el.firstChild;
|
|
2198
|
+
const len = textNode.textContent.length;
|
|
2199
|
+
if (len === 0) {
|
|
2200
|
+
textarea.selectionStart = textarea.selectionEnd = 0;
|
|
2201
|
+
return;
|
|
2202
|
+
}
|
|
2203
|
+
const doc = el.ownerDocument || document;
|
|
2204
|
+
let bestIdx = 0;
|
|
2205
|
+
let bestDist = Infinity;
|
|
2206
|
+
for (let i = 0; i <= len; i++) {
|
|
2207
|
+
const range = doc.createRange();
|
|
2208
|
+
range.setStart(textNode, i);
|
|
2209
|
+
range.setEnd(textNode, i);
|
|
2210
|
+
const rects = range.getClientRects();
|
|
2211
|
+
const rect = rects && rects.length > 0 ? rects[0] : range.getBoundingClientRect();
|
|
2212
|
+
if (rect && isFinite(rect.left) && isFinite(rect.top)) {
|
|
2213
|
+
if (click.clientX >= rect.left && click.clientX <= rect.right &&
|
|
2214
|
+
click.clientY >= rect.top && click.clientY <= rect.bottom) {
|
|
2215
|
+
bestIdx = i;
|
|
2216
|
+
bestDist = 0;
|
|
2217
|
+
break;
|
|
2218
|
+
}
|
|
2219
|
+
const cx = Math.max(rect.left, Math.min(click.clientX, rect.right));
|
|
2220
|
+
const cy = Math.max(rect.top, Math.min(click.clientY, rect.bottom));
|
|
2221
|
+
const dx = click.clientX - cx;
|
|
2222
|
+
const dy = click.clientY - cy;
|
|
2223
|
+
const d2 = dx * dx + dy * dy;
|
|
2224
|
+
if (d2 < bestDist) {
|
|
2225
|
+
bestDist = d2;
|
|
2226
|
+
bestIdx = i;
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
const clamp = (v, a, b) => Math.max(a, Math.min(b, v));
|
|
2231
|
+
const caret = clamp(bestIdx, 0, fullText.length);
|
|
2232
|
+
textarea.selectionStart = textarea.selectionEnd = caret;
|
|
2233
|
+
if (typeof textarea.scrollTop === 'number') textarea.scrollTop = 0;
|
|
2234
|
+
console.log('🧭 Text caret set', { objectId, caret, len: fullText.length });
|
|
2235
|
+
} catch (_) {}
|
|
2236
|
+
}, 0);
|
|
2237
|
+
}
|
|
2238
|
+
} catch (_) {}
|
|
2239
|
+
|
|
2183
2240
|
// Если редактируем записку — скрываем PIXI-текст записки (чтобы не было дублирования)
|
|
2184
2241
|
if (objectType === 'note' && objectId) {
|
|
2185
2242
|
try {
|