@yft-design/engine 0.0.17 → 0.0.18
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/README.md +23 -11
- package/dist/EngineCanvas.d.ts +0 -255
- package/dist/core/color.d.ts +0 -11
- package/dist/core/distanceField.d.ts +0 -13
- package/dist/core/events.d.ts +0 -25
- package/dist/core/gradient.d.ts +0 -47
- package/dist/core/homography.d.ts +0 -20
- package/dist/core/imageFilters.d.ts +0 -31
- package/dist/core/mat2d.d.ts +0 -62
- package/dist/core/pathData.d.ts +0 -36
- package/dist/core/pattern.d.ts +0 -14
- package/dist/core/point.d.ts +0 -14
- package/dist/core/psdEffects.d.ts +0 -48
- package/dist/core/roundedRect.d.ts +0 -48
- package/dist/core/shadow.d.ts +0 -23
- package/dist/core/snap.d.ts +0 -103
- package/dist/core/stroke.d.ts +0 -13
- package/dist/core/triangulate.d.ts +0 -31
- package/dist/core/warpMesh.d.ts +0 -38
- package/dist/debug/canvasInspection.d.ts +0 -20
- package/dist/debug/pixelDiff.d.ts +0 -7
- package/dist/debug/pixelDiff.js +1 -64
- package/dist/debug/seed.d.ts +0 -426
- package/dist/debug/seed.js +28 -3806
- package/dist/decoders/webp2sprite.d.ts +0 -16
- package/dist/engineFlag.d.ts +0 -76
- package/dist/export/SceneExporter.d.ts +0 -58
- package/dist/export/glExport.d.ts +0 -41
- package/dist/export/svgExport.d.ts +0 -181
- package/dist/index.d.ts +0 -13
- package/dist/index.js +1060 -64
- package/dist/interact/animationPlayback.d.ts +0 -62
- package/dist/interact/canvasInteractions.d.ts +1 -38
- package/dist/interact/cropSession.d.ts +0 -68
- package/dist/interact/dblClick.d.ts +0 -32
- package/dist/interact/expandSession.d.ts +0 -46
- package/dist/interact/hotkeyActions.d.ts +0 -12
- package/dist/interact/pageTransfer.d.ts +0 -2
- package/dist/interact/pathSession.d.ts +0 -42
- package/dist/interact/pointer.d.ts +0 -87
- package/dist/interact/pointerTablePuzzle.d.ts +0 -60
- package/dist/interact/pointerTransform.d.ts +0 -48
- package/dist/interact/pointerTypes.d.ts +6 -148
- package/dist/interact/snapGuide.d.ts +0 -68
- package/dist/interact/tableCellEditing.d.ts +0 -34
- package/dist/interact/tableInteraction.d.ts +0 -31
- package/dist/interact/textEditing.d.ts +0 -44
- package/dist/interact/warpFacade.d.ts +0 -5
- package/dist/interact/warpSession.d.ts +0 -55
- package/dist/interact/wheelScroll.d.ts +0 -42
- package/dist/model/alphaHit.d.ts +0 -51
- package/dist/model/animation.d.ts +0 -99
- package/dist/model/arcLayout.d.ts +0 -33
- package/dist/model/arcTextTransform.d.ts +0 -4
- package/dist/model/compatEvents.d.ts +0 -72
- package/dist/model/compatObject.d.ts +0 -360
- package/dist/model/cropEdit.d.ts +0 -60
- package/dist/model/document.d.ts +0 -167
- package/dist/model/elementTypes.d.ts +0 -47
- package/dist/model/expandEdit.d.ts +0 -36
- package/dist/model/fabricPrimitives.d.ts +0 -24
- package/dist/model/filler.d.ts +0 -12
- package/dist/model/groupAssemble.d.ts +0 -5
- package/dist/model/groupChildMove.d.ts +0 -37
- package/dist/model/groupResize.d.ts +0 -42
- package/dist/model/handles.d.ts +0 -24
- package/dist/model/imageMaskBake.d.ts +0 -50
- package/dist/model/lineConstruct.d.ts +0 -8
- package/dist/model/maskCropEdit.d.ts +0 -34
- package/dist/model/pathBackground.d.ts +0 -33
- package/dist/model/pathConstruct.d.ts +0 -24
- package/dist/model/pathEdit.d.ts +0 -55
- package/dist/model/puzzleEdit.d.ts +0 -66
- package/dist/model/puzzleLayout.d.ts +0 -31
- package/dist/model/scene.d.ts +0 -603
- package/dist/model/schema.d.ts +0 -48
- package/dist/model/shapePath.d.ts +0 -5
- package/dist/model/smartObjectBake.d.ts +0 -6
- package/dist/model/tableEdit.d.ts +0 -90
- package/dist/model/tableFacade.d.ts +0 -5
- package/dist/model/tableLayout.d.ts +0 -40
- package/dist/model/textAlign.d.ts +0 -22
- package/dist/model/textLayout.d.ts +0 -213
- package/dist/render/GLBlend.d.ts +0 -24
- package/dist/render/GLContext.d.ts +0 -11
- package/dist/render/GLIsolate.d.ts +0 -25
- package/dist/render/GLTextureCache.d.ts +0 -72
- package/dist/render/GlyphAtlas.d.ts +0 -98
- package/dist/render/MeshBatch.d.ts +0 -71
- package/dist/render/QuadBatch.d.ts +0 -87
- package/dist/render/SceneRenderer.d.ts +0 -137
- package/dist/render/SourceManager.d.ts +0 -82
- package/dist/render/TextRenderer.d.ts +0 -120
- package/dist/render/arcText.d.ts +0 -28
- package/dist/render/bakeGate.d.ts +0 -35
- package/dist/render/batchOrder.d.ts +0 -60
- package/dist/render/blendMode.d.ts +0 -27
- package/dist/render/clipMaskPainter.d.ts +0 -42
- package/dist/render/fontInvalidation.d.ts +0 -18
- package/dist/render/fontInvalidationController.d.ts +0 -52
- package/dist/render/frameOverlay.d.ts +0 -32
- package/dist/render/framePipeline.d.ts +0 -27
- package/dist/render/gpuFilterPasses.d.ts +0 -15
- package/dist/render/gpuFx.d.ts +0 -82
- package/dist/render/gpuImageFilters.d.ts +0 -41
- package/dist/render/gpuShadow.d.ts +0 -38
- package/dist/render/gradientRamp.d.ts +0 -14
- package/dist/render/imageEffects.d.ts +0 -99
- package/dist/render/lineDecorationSdf.d.ts +0 -32
- package/dist/render/maskRender.d.ts +0 -60
- package/dist/render/multiPage.d.ts +0 -91
- package/dist/render/progressiveLoad.d.ts +0 -27
- package/dist/render/psdEffectPainter.d.ts +0 -25
- package/dist/render/psdWarpText.d.ts +0 -19
- package/dist/render/puzzleClamp.d.ts +0 -15
- package/dist/render/renderEpoch.d.ts +0 -21
- package/dist/render/retainedFrame.d.ts +0 -36
- package/dist/render/ruler.d.ts +0 -36
- package/dist/render/screenClip.d.ts +0 -31
- package/dist/render/scrollText.d.ts +0 -46
- package/dist/render/segmentTable.d.ts +0 -30
- package/dist/render/selectionOverlay.d.ts +0 -203
- package/dist/render/settleScheduler.d.ts +0 -24
- package/dist/render/shaders.d.ts +4 -24
- package/dist/render/shadowBake.d.ts +0 -28
- package/dist/render/shadowPainter.d.ts +0 -8
- package/dist/render/sharedGpuPainters.d.ts +0 -13
- package/dist/render/sourceHydration.d.ts +0 -8
- package/dist/render/strokeBake.d.ts +0 -59
- package/dist/render/strokeMiterOutline.d.ts +0 -29
- package/dist/render/strokePainter.d.ts +0 -31
- package/dist/render/strokeSdf.d.ts +0 -52
- package/dist/render/svgRaster.d.ts +0 -34
- package/dist/render/tableOverlay.d.ts +0 -35
- package/dist/render/textHighlight.d.ts +0 -67
- package/dist/render/textureUpload.d.ts +0 -13
- package/dist/render/verticalText.d.ts +0 -21
- package/dist/render/warpText.d.ts +0 -48
- package/dist/render/workspaceBackdrop.d.ts +0 -22
- package/dist/render/workspaceChecker.d.ts +0 -34
- package/dist/render/workspaceGlow.d.ts +0 -38
- package/package.json +4 -3
- package/dist/EngineCanvas.js +0 -1202
- package/dist/core/canvasPerf.js +0 -170
- package/dist/core/color.js +0 -107
- package/dist/core/distanceField.js +0 -92
- package/dist/core/events.js +0 -80
- package/dist/core/gradient.js +0 -175
- package/dist/core/homography.js +0 -123
- package/dist/core/imageFilters.js +0 -330
- package/dist/core/mat2d.js +0 -241
- package/dist/core/pathData.js +0 -926
- package/dist/core/pattern.js +0 -40
- package/dist/core/point.js +0 -119
- package/dist/core/psdEffects.js +0 -158
- package/dist/core/roundedRect.js +0 -164
- package/dist/core/shadow.js +0 -47
- package/dist/core/snap.js +0 -793
- package/dist/core/stroke.js +0 -45
- package/dist/core/triangulate.js +0 -194
- package/dist/core/warpMesh.js +0 -469
- package/dist/debug/canvasInspection.js +0 -113
- package/dist/decoders/gif2sprite.js +0 -84
- package/dist/decoders/webp2sprite.js +0 -133
- package/dist/engineFlag.js +0 -104
- package/dist/export/SceneExporter.js +0 -286
- package/dist/export/glExport.js +0 -79
- package/dist/export/svgExport.js +0 -1803
- package/dist/interact/animationPlayback.js +0 -358
- package/dist/interact/canvasInteractions.js +0 -174
- package/dist/interact/cropSession.js +0 -527
- package/dist/interact/dblClick.js +0 -120
- package/dist/interact/expandSession.js +0 -282
- package/dist/interact/hotkeyActions.js +0 -42
- package/dist/interact/pageTransfer.js +0 -56
- package/dist/interact/pathSession.js +0 -480
- package/dist/interact/pointer.js +0 -1692
- package/dist/interact/pointerTablePuzzle.js +0 -358
- package/dist/interact/pointerTransform.js +0 -441
- package/dist/interact/pointerTypes.js +0 -96
- package/dist/interact/snapGuide.js +0 -377
- package/dist/interact/tableCellEditing.js +0 -207
- package/dist/interact/tableInteraction.js +0 -219
- package/dist/interact/textEditing.js +0 -423
- package/dist/interact/warpFacade.js +0 -51
- package/dist/interact/warpSession.js +0 -583
- package/dist/interact/wheelScroll.js +0 -100
- package/dist/model/alphaHit.js +0 -267
- package/dist/model/animation.js +0 -510
- package/dist/model/arcLayout.js +0 -308
- package/dist/model/arcTextTransform.js +0 -87
- package/dist/model/compatEvents.js +0 -96
- package/dist/model/compatObject.js +0 -1583
- package/dist/model/cropEdit.js +0 -497
- package/dist/model/document.js +0 -590
- package/dist/model/elementTypes.js +0 -119
- package/dist/model/expandEdit.js +0 -161
- package/dist/model/fabricPrimitives.js +0 -9
- package/dist/model/filler.js +0 -1
- package/dist/model/groupAssemble.js +0 -98
- package/dist/model/groupChildMove.js +0 -145
- package/dist/model/groupResize.js +0 -109
- package/dist/model/handles.js +0 -29
- package/dist/model/imageMaskBake.js +0 -136
- package/dist/model/lineConstruct.js +0 -79
- package/dist/model/maskCropEdit.js +0 -90
- package/dist/model/pathBackground.js +0 -196
- package/dist/model/pathConstruct.js +0 -55
- package/dist/model/pathEdit.js +0 -378
- package/dist/model/puzzleEdit.js +0 -742
- package/dist/model/puzzleLayout.js +0 -143
- package/dist/model/scene.js +0 -2930
- package/dist/model/schema.js +0 -13
- package/dist/model/shapePath.js +0 -137
- package/dist/model/smartObjectBake.js +0 -295
- package/dist/model/tableEdit.js +0 -751
- package/dist/model/tableFacade.js +0 -808
- package/dist/model/tableLayout.js +0 -194
- package/dist/model/textAlign.js +0 -36
- package/dist/model/textLayout.js +0 -842
- package/dist/render/GLBlend.js +0 -270
- package/dist/render/GLContext.js +0 -48
- package/dist/render/GLIsolate.js +0 -188
- package/dist/render/GLTextureCache.js +0 -224
- package/dist/render/GlyphAtlas.js +0 -412
- package/dist/render/MeshBatch.js +0 -416
- package/dist/render/QuadBatch.js +0 -561
- package/dist/render/SceneRenderer.js +0 -753
- package/dist/render/SourceManager.js +0 -523
- package/dist/render/TextRenderer.js +0 -854
- package/dist/render/arcText.js +0 -187
- package/dist/render/bakeGate.js +0 -32
- package/dist/render/batchOrder.js +0 -168
- package/dist/render/blendMode.js +0 -142
- package/dist/render/clipMaskPainter.js +0 -244
- package/dist/render/fontInvalidation.js +0 -77
- package/dist/render/fontInvalidationController.js +0 -119
- package/dist/render/frameOverlay.js +0 -124
- package/dist/render/framePipeline.js +0 -96
- package/dist/render/gpuFilterPasses.js +0 -883
- package/dist/render/gpuFx.js +0 -673
- package/dist/render/gpuImageFilters.js +0 -295
- package/dist/render/gpuShadow.js +0 -327
- package/dist/render/gradientRamp.js +0 -74
- package/dist/render/imageEffects.js +0 -415
- package/dist/render/lineDecorationSdf.js +0 -189
- package/dist/render/maskRender.js +0 -217
- package/dist/render/multiPage.js +0 -420
- package/dist/render/progressiveLoad.js +0 -86
- package/dist/render/psdEffectPainter.js +0 -333
- package/dist/render/psdWarpText.js +0 -212
- package/dist/render/puzzleClamp.js +0 -30
- package/dist/render/renderEpoch.js +0 -35
- package/dist/render/renderViewport.js +0 -18
- package/dist/render/retainedFrame.js +0 -192
- package/dist/render/ruler.js +0 -287
- package/dist/render/screenClip.js +0 -67
- package/dist/render/scrollText.js +0 -266
- package/dist/render/segmentTable.js +0 -117
- package/dist/render/selectionOverlay.js +0 -1008
- package/dist/render/settleScheduler.js +0 -51
- package/dist/render/shaders.js +0 -450
- package/dist/render/shadowBake.js +0 -203
- package/dist/render/shadowPainter.js +0 -93
- package/dist/render/sharedGpuPainters.js +0 -42
- package/dist/render/sourceHydration.js +0 -48
- package/dist/render/strokeBake.js +0 -516
- package/dist/render/strokeMiterOutline.js +0 -224
- package/dist/render/strokePainter.js +0 -207
- package/dist/render/strokeSdf.js +0 -262
- package/dist/render/svgRaster.js +0 -71
- package/dist/render/tableOverlay.js +0 -233
- package/dist/render/textHighlight.js +0 -380
- package/dist/render/textureUpload.js +0 -26
- package/dist/render/verticalText.js +0 -63
- package/dist/render/warpText.js +0 -384
- package/dist/render/workspaceBackdrop.js +0 -60
- package/dist/render/workspaceChecker.js +0 -170
- package/dist/render/workspaceGlow.js +0 -198
package/dist/interact/pointer.js
DELETED
|
@@ -1,1692 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 指针交互控制器(main-webgl2 Phase 1;批次 12 拆分后骨架):down/move/up
|
|
3
|
-
* 手势分发、会话吞没分支、命中与悬停光标。类型/共享数学在 pointerTypes,
|
|
4
|
-
* 变换手势数学(缩放/旋转/文本三烘焙)在 pointerTransform,表格/拼图手势
|
|
5
|
-
* (边框拖拽/边中点调宽高/指示器插入/容器与分割线缩放)在 pointerTablePuzzle。
|
|
6
|
-
*
|
|
7
|
-
* 状态机:idle →(down)→ handle 命中:scale/rotate|对象命中:move(未选中先选)|
|
|
8
|
-
* 空白命中:marquee(shift 追加)。中键拖拽留给宿主的平移。
|
|
9
|
-
* 文本例外(对齐 main 分支):角点不落 scale,缩放烘焙进 fontSize
|
|
10
|
-
* (changeObjectFontSize,见 applyFontBake);textbox 的 ml/mr 烘焙进盒宽、
|
|
11
|
-
* 排版重排换行(changeTextWidth,见 applyWidthBake);mt/mb 烘焙进盒高、
|
|
12
|
-
* 排版不动(changeObjectHeight,见 applyHeightBake)。
|
|
13
|
-
*
|
|
14
|
-
* 手势数学(缩放)按「锚点固定」推导:拖拽 handle 的本地坐标 u、锚点本地
|
|
15
|
-
* 坐标 a 在手势期不变,指针 p 与锚点场景坐标 A 反解 sx/sy:
|
|
16
|
-
* R(-angle)·(p − A) = (sx·(u.x−a.x), sy·(u.y−a.y))
|
|
17
|
-
* 中心 = A − R·(sx·a.x, sy·a.y),再由中心反解 left/top(origin 语义)。
|
|
18
|
-
*
|
|
19
|
-
* 多选变换(fabric ActiveSelection 等价):选区框(AABB 或保留姿态框)当
|
|
20
|
-
* 虚拟对象套同一套锚点固定数学——缩放比值乘进成员 scale、成员中心按本地
|
|
21
|
-
* 坐标×比值重定位(成员角度不变;文本不烘焙字号/盒宽盒高——fabric 组缩放
|
|
22
|
-
* 对文本同样只乘 scale,changeObjectFontSize 等是单对象手势专属语义);
|
|
23
|
-
* 旋转绕框中心刚体转动(成员角度 += delta、中心绕枢轴转)。fabric 的 AS
|
|
24
|
-
* 在手势期不重写成员坐标(渲染复合 AS 矩阵),引擎每帧烘焙成员世界坐标,
|
|
25
|
-
* 选区姿态由 document.selectionFrame 承载(见其注释)——旋转/缩放/移动
|
|
26
|
-
* 手势同步维护,选框刚性跟随而非按成员 AABB 重新拟合。
|
|
27
|
-
*/
|
|
28
|
-
import { createNode, createReferenceLineRaw, GroupNode, isReferenceLineNode, PuzzleNode, TableNode } from '../model/scene';
|
|
29
|
-
import { CompatHistoryActions } from '../model/compatEvents';
|
|
30
|
-
import { RULER_SIZE } from '../render/ruler';
|
|
31
|
-
import { buildSelectionRange, getBorderCursor, selectionBounds } from '../model/tableEdit';
|
|
32
|
-
import { CORNER_ROTATE_CURSOR_OFFSET, CORNER_ROTATE_ZONE_PX, cornerOffsetToRadius, getActiveChildHandles, getAdaptiveSelectionHandles, getCornerRotateZones, HANDLE_HIT_PX, isImageRadiusHandleNode, isRadiusHandleNode, isUserLockedNode, MOVE_CONTROL_HIT_PX, moveControlPosition, moveControlTarget, radiusHandleTarget, rectCornerMaxRadius, rotateControlSpecByAngle, selectionQuadCoords } from '../render/selectionOverlay';
|
|
33
|
-
import { EDGE_HANDLE_AXIS, isEdgeHandle, isRadiusHandle, RADIUS_HANDLE_CORNER } from '../model/handles';
|
|
34
|
-
import { CLICK_THRESHOLD, CORNER_HANDLES, deg, DRAG_START_THRESHOLD, HANDLE_BASE_ANGLE, quadCenter, quadDims, SCALE_CURSORS } from './pointerTypes';
|
|
35
|
-
import { applyMultiRotate, applyMultiScale, applyScale, buildMultiScaleSnapshot, buildScaleSnapshot } from './pointerTransform';
|
|
36
|
-
import { ancestorChainTo, childSceneDeltaMapper, refitGroupShells } from '../model/groupChildMove';
|
|
37
|
-
import { applyIndicatorInsert, applyPuzzleEdgeResize, applyPuzzleMaskEdgeResize, applyTableBorderDrag, applyTableEdgeResize, buildPuzzleEdgeResizeGesture, buildPuzzleMaskEdgeResizeGesture, buildTableBorderDragGesture, buildTableEdgeResizeGesture, hitMaskEditHandle, hitPuzzleSeamBar } from './pointerTablePuzzle';
|
|
38
|
-
/** TableStripHit → 悬停高亮态形状(TableNode.hoveredStrip 消费) */
|
|
39
|
-
const stripHoverOf = (hit) => (hit.kind === 'col-strip' ? { kind: 'col', index: hit.col } : { kind: 'row', index: hit.row });
|
|
40
|
-
/** 圆角拖拽的指针→radius 求值(批次 100;app changeRectCornerRadius 逐式):
|
|
41
|
-
* 屏幕坐标经节点逆矩阵反算本地系(避免控制点 offset 抖动),按角位取两轴
|
|
42
|
-
* 距离×scale 的视觉值,min 后经 cornerOffsetToRadius 逆映射(减 gap 还原)
|
|
43
|
-
* +钳制 [0, maxRadius];变化 <0.001 返回 null(app 同门限——跳过空写) */
|
|
44
|
-
const radiusFromPointer = (node, corner, p) => {
|
|
45
|
-
const raw = node.raw;
|
|
46
|
-
// 尺寸读 node.dims(批次 113 同口径——rect 基类 dims=raw.width??0 行为不变;
|
|
47
|
-
// 见 imageRadiusPropsFromPointer 头注)
|
|
48
|
-
const { x: width, y: height } = node.dims;
|
|
49
|
-
if (!width || !height)
|
|
50
|
-
return null;
|
|
51
|
-
const sx = Math.max(Math.abs(raw.scaleX ?? 1) || 1, 1e-4);
|
|
52
|
-
const sy = Math.max(Math.abs(raw.scaleY ?? 1) || 1, 1e-4);
|
|
53
|
-
const local = node.localPoint(p.x, p.y);
|
|
54
|
-
const halfW = width / 2;
|
|
55
|
-
const halfH = height / 2;
|
|
56
|
-
let radiusX;
|
|
57
|
-
let radiusY;
|
|
58
|
-
if (corner === 'tl') {
|
|
59
|
-
radiusX = (local.x + halfW) * sx;
|
|
60
|
-
radiusY = (local.y + halfH) * sy;
|
|
61
|
-
}
|
|
62
|
-
else if (corner === 'tr') {
|
|
63
|
-
radiusX = (halfW - local.x) * sx;
|
|
64
|
-
radiusY = (local.y + halfH) * sy;
|
|
65
|
-
}
|
|
66
|
-
else if (corner === 'bl') {
|
|
67
|
-
radiusX = (local.x + halfW) * sx;
|
|
68
|
-
radiusY = (halfH - local.y) * sy;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
radiusX = (halfW - local.x) * sx;
|
|
72
|
-
radiusY = (halfH - local.y) * sy;
|
|
73
|
-
}
|
|
74
|
-
const maxRadius = rectCornerMaxRadius(node);
|
|
75
|
-
const next = Math.max(0, Math.min(maxRadius, cornerOffsetToRadius(Math.min(radiusX, radiusY), maxRadius)));
|
|
76
|
-
const prev = raw.radius ?? 0;
|
|
77
|
-
return Math.abs(next - prev) < 0.001 ? null : next;
|
|
78
|
-
};
|
|
79
|
-
/** 圆角拖拽的指针→图片 rx/ry 求值(批次 101;app changeImageCornerRadius 逐式):
|
|
80
|
-
* 与矩形同几何骨架但全**本地系**(距离不乘 scale、上限 min(半宽,半高)),写
|
|
81
|
-
* rx=ry=nextRadius(图片数据模型);nextRadius>0 且未开逐像素命中时连写
|
|
82
|
-
* perPixelTargetFind=true(app 同款——圆角后命中区与视觉区一致)。返回写入
|
|
83
|
-
* props(null=无变化跳过) */
|
|
84
|
-
const imageRadiusPropsFromPointer = (node, corner, p) => {
|
|
85
|
-
const raw = node.raw;
|
|
86
|
-
// 尺寸读 node.dims(批次 135):创建链直构(批次 110+115 起左栏/拖放建图)raw
|
|
87
|
-
// 不带 width/height——直读 raw 得 0 半宽恒 return null,手柄可见(批次 113 布
|
|
88
|
-
// 局已改 dims)但拖拽写不进 rx(用户报「圆角controls不生效」)。dims 兜位图
|
|
89
|
-
// 原宽/crop 窗口径=fabric 可见尺寸,与 selectionOverlay 三处同源
|
|
90
|
-
const { x: width, y: height } = node.dims;
|
|
91
|
-
if (!width || !height)
|
|
92
|
-
return null;
|
|
93
|
-
const local = node.localPoint(p.x, p.y);
|
|
94
|
-
const halfW = width / 2;
|
|
95
|
-
const halfH = height / 2;
|
|
96
|
-
let radiusX;
|
|
97
|
-
let radiusY;
|
|
98
|
-
if (corner === 'tl') {
|
|
99
|
-
radiusX = local.x + halfW;
|
|
100
|
-
radiusY = local.y + halfH;
|
|
101
|
-
}
|
|
102
|
-
else if (corner === 'tr') {
|
|
103
|
-
radiusX = halfW - local.x;
|
|
104
|
-
radiusY = local.y + halfH;
|
|
105
|
-
}
|
|
106
|
-
else if (corner === 'bl') {
|
|
107
|
-
radiusX = local.x + halfW;
|
|
108
|
-
radiusY = halfH - local.y;
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
radiusX = halfW - local.x;
|
|
112
|
-
radiusY = halfH - local.y;
|
|
113
|
-
}
|
|
114
|
-
const maxRadius = Math.min(halfW, halfH);
|
|
115
|
-
const next = Math.max(0, Math.min(maxRadius, cornerOffsetToRadius(Math.min(radiusX, radiusY), maxRadius)));
|
|
116
|
-
const prev = Math.max(raw.rx ?? 0, raw.ry ?? 0);
|
|
117
|
-
if (Math.abs(next - prev) < 0.001)
|
|
118
|
-
return null;
|
|
119
|
-
const props = { rx: next, ry: next };
|
|
120
|
-
if (next > 0 && raw.perPixelTargetFind === false)
|
|
121
|
-
props.perPixelTargetFind = true;
|
|
122
|
-
return props;
|
|
123
|
-
};
|
|
124
|
-
/** 标尺带命中(批次 72;app FabricRuler.getPointHover 同判序):左带(垂直,
|
|
125
|
-
* 产竖线)优先于上带(水平,产横线)——角块归左带;null = 不在带内 */
|
|
126
|
-
const rulerBandAt = (cssX, cssY) => {
|
|
127
|
-
if (cssX < RULER_SIZE)
|
|
128
|
-
return 'vertical';
|
|
129
|
-
if (cssY < RULER_SIZE)
|
|
130
|
-
return 'horizontal';
|
|
131
|
-
return null;
|
|
132
|
-
};
|
|
133
|
-
/** 旋转柄光标(app controls/common rotateIcon 同款 data-URI):双层箭头
|
|
134
|
-
* (白衬黑芯)随手势角度转动,热点 12,12——mtr 悬停/拖拽中共用,拖拽中
|
|
135
|
-
* 逐帧随 angle 更新(app actionHandler 每 move setCursor 同构) */
|
|
136
|
-
const rotateCursorIcon = (angle) => {
|
|
137
|
-
return `url("data:image/svg+xml,<svg height='20' width='20' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'><g fill='none' transform='rotate(${angle} 16 16)'><path fill='white' d='M18.24 5.37C11.41 6.04 5.98 11.46 5.32 18.26L0 18.26L7.8 26L15.61 18.27L10.6 18.27C11.21 14.35 14.31 11.25 18.24 10.64L18.24 15.55L26 7.78L18.24 0L18.24 5.37Z'></path><path fill='black' d='M19.5463 6.61441C12.4063 6.68441 6.61632 12.4444 6.56632 19.5644L3.17632 19.5644L7.80632 24.1444L12.4363 19.5644L9.18632 19.5644C9.24632 13.8844 13.8563 9.28441 19.5463 9.22441L19.5463 12.3844L24.1463 7.78441L19.5463 3.16441L19.5463 6.61441Z'></path></g></svg>") 12 12,auto`;
|
|
138
|
-
};
|
|
139
|
-
/** P5-4:手势起点的历史快照(以 modified 收尾的手势在 down 时一次性捕获,
|
|
140
|
-
* up 提交时随 detail 下发——应用层折叠成 fabric transform.original) */
|
|
141
|
-
const captureHistoryBefore = (nodes) => {
|
|
142
|
-
const map = new Map();
|
|
143
|
-
for (const node of nodes)
|
|
144
|
-
map.set(node, node.toObject());
|
|
145
|
-
return map;
|
|
146
|
-
};
|
|
147
|
-
export class PointerController {
|
|
148
|
-
host;
|
|
149
|
-
el;
|
|
150
|
-
gesture = { type: 'none' };
|
|
151
|
-
/** 本手势是否「执行过」变换(fabric transform.actionPerformed 同语义):
|
|
152
|
-
* 变换手势内发生过 pointermove 才置位,pointerup 据此决定是否发
|
|
153
|
-
* object:modified——纯点击不发,否则每次点选都成一条伪历史提交 */
|
|
154
|
-
performed = false;
|
|
155
|
-
/** 悬停中的表格(P4-4b 悬停态生命周期:换目标/离场时清旧态并重绘) */
|
|
156
|
-
hoveredTable = null;
|
|
157
|
-
/** 悬停路由页(批次 409 D-3):hover 逐点路由可落非活动页——跨页时清旧页
|
|
158
|
-
* hovered 防陈旧边框(该页再激活时复活);离场清理同源 */
|
|
159
|
-
lastHoverDoc = null;
|
|
160
|
-
/** 多选成员点击的延迟切换目标(ActiveSelection 态点成员,应用 fabric 时代
|
|
161
|
-
* _deferredClickThroughTarget 的同源时机原则——docs/2026-04-28 组点击穿透:
|
|
162
|
-
* mousedown 先保持当前选中态便于拖动/框选,mouseup 确认是 click 才切换):
|
|
163
|
-
* 多选态点成员 mousedown 不动选区(拖动=整组移动的快照/虚拟框语义不变),
|
|
164
|
-
* up 判定纯点击(手势未执行)才切换单选被点成员。down 开头重置、up 末尾
|
|
165
|
-
* 统一清;表格单元格手势转 move(拖动意图明确)时提前作废 */
|
|
166
|
-
deferredClickSwitch = null;
|
|
167
|
-
detach = null;
|
|
168
|
-
/** 交互/静态模式(静态画布监听整体不挂——CSS pointer-events 拦不住
|
|
169
|
-
* window 级 pointermove 的悬停命中,须源头不挂才断根;dispose 恒安全) */
|
|
170
|
-
interactive;
|
|
171
|
-
constructor(el, host, interactive = true) {
|
|
172
|
-
this.el = el;
|
|
173
|
-
this.host = host;
|
|
174
|
-
this.interactive = interactive;
|
|
175
|
-
this.attach();
|
|
176
|
-
}
|
|
177
|
-
get active() {
|
|
178
|
-
return this.gesture.type !== 'none';
|
|
179
|
-
}
|
|
180
|
-
/** 当前命中的缩放/旋转手柄(屏幕空间半径内),供宿主设光标。手柄集与渲染
|
|
181
|
-
* 同源走 getAdaptiveSelectionHandles——小对象被裁剪的手柄不可命中(app
|
|
182
|
-
* adaptiveControlVisibility 渲染/命中一体的同语义) */
|
|
183
|
-
hitHandle(cssX, cssY) {
|
|
184
|
-
const layout = selectionQuadCoords(this.host.document);
|
|
185
|
-
if (!layout)
|
|
186
|
-
return null;
|
|
187
|
-
// 锁定单选手柄全不可命中(批次 67):渲染侧锁定不画手柄(app fabricControls
|
|
188
|
-
// 对锁定对象 render=noop),命中同源短路——锁图标走 hitLockControl 专属通道
|
|
189
|
-
if (this.host.document.selection.length === 1 && isUserLockedNode(this.host.document.selection[0]))
|
|
190
|
-
return null;
|
|
191
|
-
for (const h of getAdaptiveSelectionHandles(this.host.document, layout.quad, layout.angle, this.host.zoom, radiusHandleTarget(this.host.document))) {
|
|
192
|
-
const screen = this.host.toScreen(h.x, h.y);
|
|
193
|
-
if (Math.hypot(screen.x - cssX, screen.y - cssY) <= HANDLE_HIT_PX)
|
|
194
|
-
return h.id;
|
|
195
|
-
}
|
|
196
|
-
return null;
|
|
197
|
-
}
|
|
198
|
-
/** 激活子手柄命中(批次 311 二补,与渲染 getActiveChildHandles 同源):组内
|
|
199
|
-
* 编辑**会话**(groupEditing——唯一入口=应用层「组内移动」按钮,五补)下子
|
|
200
|
-
* 全套手柄(缩放/旋转)优先于顶组手柄——重叠区子赢(渲染上层同序);未开
|
|
201
|
-
* 会话的单击激活态不命中(子无 controls)。批次 346 勘正:锁定子手柄照常
|
|
202
|
-
* 命中——PSD 解析对组内每个子写全套锁(handlePSD parseGroup setLock,
|
|
203
|
-
* 94a415f66),会话=显式编辑意图,锁键不否决(渲染侧 selectionOverlay 的
|
|
204
|
-
* 子手柄分支本就不设锁门——两自此同源) */
|
|
205
|
-
hitActiveChildHandle(cssX, cssY) {
|
|
206
|
-
const doc = this.host.document;
|
|
207
|
-
const child = doc.activeGroupChild;
|
|
208
|
-
if (!child || !doc.groupEditing)
|
|
209
|
-
return null;
|
|
210
|
-
for (const h of getActiveChildHandles(child, this.host.zoom)) {
|
|
211
|
-
const screen = this.host.toScreen(h.x, h.y);
|
|
212
|
-
if (Math.hypot(screen.x - cssX, screen.y - cssY) <= HANDLE_HIT_PX)
|
|
213
|
-
return h.id;
|
|
214
|
-
}
|
|
215
|
-
return null;
|
|
216
|
-
}
|
|
217
|
-
/** 锁定单选的右下角锁图标命中(批次 67):渲染/命中同源——buildSelectionOverlay
|
|
218
|
-
* 锁定分支的 quad.br(app getHornControl 锁图标分支:br 且非组内),半径沿
|
|
219
|
-
* 用 HANDLE_HIT_PX。命中即返回锁定节点供 fire unlock 事件 */
|
|
220
|
-
hitLockControl(cssX, cssY) {
|
|
221
|
-
const doc = this.host.document;
|
|
222
|
-
if (doc.selection.length !== 1 || !isUserLockedNode(doc.selection[0]))
|
|
223
|
-
return null;
|
|
224
|
-
const layout = selectionQuadCoords(doc);
|
|
225
|
-
if (!layout)
|
|
226
|
-
return null;
|
|
227
|
-
const screen = this.host.toScreen(layout.quad.br.x, layout.quad.br.y);
|
|
228
|
-
return Math.hypot(screen.x - cssX, screen.y - cssY) <= HANDLE_HIT_PX ? doc.selection[0] : null;
|
|
229
|
-
}
|
|
230
|
-
/** 移动端移动控件命中(批次 354;app moveControls 的 move 控件引擎面):
|
|
231
|
-
* 宿主 mobileControls 门 + moveControlTarget 族判定(单选常规族/未锁),
|
|
232
|
-
* 位置与渲染共源 moveControlPosition(选区右中 +24 屏幕px 随姿态),命中
|
|
233
|
-
* 半径 MOVE_CONTROL_HIT_PX(finger 友好目标)。桌面态(mobileControls 缺席
|
|
234
|
-
* /false)恒 false——既有命中链零扰动 */
|
|
235
|
-
hitMoveControl(cssX, cssY) {
|
|
236
|
-
if (this.host.mobileControls !== true)
|
|
237
|
-
return false;
|
|
238
|
-
if (!moveControlTarget(this.host.document))
|
|
239
|
-
return false;
|
|
240
|
-
const layout = selectionQuadCoords(this.host.document);
|
|
241
|
-
if (!layout)
|
|
242
|
-
return false;
|
|
243
|
-
const pos = moveControlPosition(layout.quad, layout.angle, this.host.zoom);
|
|
244
|
-
const screen = this.host.toScreen(pos.x, pos.y);
|
|
245
|
-
return Math.hypot(screen.x - cssX, screen.y - cssY) <= MOVE_CONTROL_HIT_PX;
|
|
246
|
-
}
|
|
247
|
-
/** 四角隐形旋转区命中(批次 88;fabric baseControls tlr/trr/brr/blr +
|
|
248
|
-
* Control.calcCornerCoords):每区=角点沿本地对角外偏 4 屏幕px 的中心、
|
|
249
|
-
* 16×16 方形命中盒随对象角度旋转(point-in-polygon 的逆旋转回盒本地系
|
|
250
|
-
* 等价式)。单选专属——ActiveSelection 走 fabric 原生控件集无四角区、
|
|
251
|
-
* TableNode 的 tableControls 自制集同样无;锁定单选渲染侧 render=noop
|
|
252
|
-
* 命中同源短路;小对象(屏幕宽或高 ≤50px)adaptiveControlVisibility 隐藏。
|
|
253
|
-
* 与缩放手柄的重叠归属:调用方先判 hitHandle(fabric findControl 倒序——
|
|
254
|
-
* key 序靠后的 tl/tr/bl/br 先判赢重叠区,四角区只吃手柄覆盖外的外圈) */
|
|
255
|
-
hitCornerRotateZone(cssX, cssY) {
|
|
256
|
-
const doc = this.host.document;
|
|
257
|
-
if (doc.selection.length !== 1)
|
|
258
|
-
return null;
|
|
259
|
-
const node = doc.selection[0];
|
|
260
|
-
if (node instanceof TableNode)
|
|
261
|
-
return null;
|
|
262
|
-
if (isUserLockedNode(node))
|
|
263
|
-
return null;
|
|
264
|
-
const layout = selectionQuadCoords(doc);
|
|
265
|
-
if (!layout)
|
|
266
|
-
return null;
|
|
267
|
-
const r = (layout.angle * Math.PI) / 180;
|
|
268
|
-
const cos = Math.cos(r);
|
|
269
|
-
const sin = Math.sin(r);
|
|
270
|
-
const half = CORNER_ROTATE_ZONE_PX / 2;
|
|
271
|
-
for (const zone of getCornerRotateZones(layout.quad, layout.angle, this.host.zoom)) {
|
|
272
|
-
const s = this.host.toScreen(zone.x, zone.y);
|
|
273
|
-
const dx = cssX - s.x;
|
|
274
|
-
const dy = cssY - s.y;
|
|
275
|
-
const lx = dx * cos + dy * sin;
|
|
276
|
-
const ly = -dx * sin + dy * cos;
|
|
277
|
-
if (Math.abs(lx) <= half && Math.abs(ly) <= half)
|
|
278
|
-
return zone.id;
|
|
279
|
-
}
|
|
280
|
-
return null;
|
|
281
|
-
}
|
|
282
|
-
/** 旋转手势覆盖态写入:mtr 锚定规格按手势起始姿态快照进 host.rotateDrag
|
|
283
|
-
* ——渲染层选区 overlay 每帧把规格经**当前**框姿态变换到屏幕(fabric 手势
|
|
284
|
-
* 起始把控件规格快照进 _currentTransform.__rotateControlPosition、手势期
|
|
285
|
-
* positionHandler 恒用快照规格但仍乘当前 finalMatrix:柄贴着框的同一条边
|
|
286
|
-
* 随框转、不换边),中心承载角度气泡(旋转中元素中心显示当前角度,
|
|
287
|
-
* renderRotateControl isRotating 分支) */
|
|
288
|
-
freezeRotateHandle(angle, center, onChild = false) {
|
|
289
|
-
if (this.host.rotateDrag === undefined)
|
|
290
|
-
return;
|
|
291
|
-
// onChild 仅 true 时落键(rotateDrag 既有 toEqual 严格断言不受扰)
|
|
292
|
-
this.host.rotateDrag = onChild
|
|
293
|
-
? { spec: rotateControlSpecByAngle(angle), center: { x: center.x, y: center.y }, onChild: true }
|
|
294
|
-
: { spec: rotateControlSpecByAngle(angle), center: { x: center.x, y: center.y } };
|
|
295
|
-
}
|
|
296
|
-
/** 空闲态悬停光标:表外指示器 → 行/列选择条与拖动把手 → 手柄 → 表格边框/指示器 → 对象 move;空白默认。
|
|
297
|
-
* 手柄光标单选/多选都生效(与 onPointerDown 手柄命中同口径;多选角度恒 0) */
|
|
298
|
-
hoverCursor(cssX, cssY, p, doc = this.host.document) {
|
|
299
|
-
// 标尺带(批次 72):带内 ns/ew-resize(app FabricRuler.mouseMove
|
|
300
|
-
// getPointHover 同判序同光标——上带产横线 ns-resize / 左带产竖线 ew-resize)
|
|
301
|
-
if (this.host.rulerVisible) {
|
|
302
|
-
const band = rulerBandAt(cssX, cssY);
|
|
303
|
-
if (band)
|
|
304
|
-
return band === 'horizontal' ? 'ns-resize' : 'ew-resize';
|
|
305
|
-
}
|
|
306
|
-
// B2 裁剪会话:吞没一切命中(手柄 pointer / 整图内 move / 框外默认)
|
|
307
|
-
const crop = this.host.cropSession;
|
|
308
|
-
if (crop)
|
|
309
|
-
return crop.hoverCursor(cssX, cssY, p);
|
|
310
|
-
// B3 扩图会话:手柄 pointer / 框内 move(可拖动图片)/ 框外默认
|
|
311
|
-
const expand = this.host.expandSession;
|
|
312
|
-
if (expand)
|
|
313
|
-
return expand.hoverCursor(cssX, cssY, p.x, p.y);
|
|
314
|
-
// P4-7 路径锚点编辑会话:手柄 crosshair / 锚点 default / 插点候选 copy(含
|
|
315
|
-
// 预览点更新——候选变化触发重绘在会话内)/ 本体 move / 空白默认
|
|
316
|
-
const pathSession = this.host.pathSession;
|
|
317
|
-
if (pathSession)
|
|
318
|
-
return pathSession.hoverCursor(cssX, cssY, p);
|
|
319
|
-
// 批次 66 图片扭曲会话:锚点 pointer / 其余 default
|
|
320
|
-
const warpHoverSession = this.host.warpSession;
|
|
321
|
-
if (warpHoverSession)
|
|
322
|
-
return warpHoverSession.hoverCursor(cssX, cssY);
|
|
323
|
-
// 蒙版会话分割线手柄(P4-5b(3/3)):优先于其它命中;未命中继续走到下方
|
|
324
|
-
// 手柄光标(批次 51 起会话中组手柄渲染且可拖——renderTopGroupControls 同态)
|
|
325
|
-
const selPuzzle = doc.selection.length === 1 && doc.selection[0] instanceof PuzzleNode ? doc.selection[0] : null;
|
|
326
|
-
if (selPuzzle?.editingMask) {
|
|
327
|
-
// toScreen 依赖 host 的 this.vpt——箭头包装绑定,裸传会 TypeError 中断命中
|
|
328
|
-
const h = hitMaskEditHandle((x, y) => this.host.toScreen(x, y), selPuzzle, cssX, cssY);
|
|
329
|
-
if (h)
|
|
330
|
-
return EDGE_HANDLE_AXIS[h] === 'x' ? 'ew-resize' : 'ns-resize';
|
|
331
|
-
// 批次 305 补③:会话态其余缝的行杠光标(编辑块柄位 miss 后)
|
|
332
|
-
const sessionBar = hitPuzzleSeamBar((x, y) => this.host.toScreen(x, y), selPuzzle, cssX, cssY);
|
|
333
|
-
if (sessionBar)
|
|
334
|
-
return EDGE_HANDLE_AXIS[sessionBar.handle] === 'x' ? 'ew-resize' : 'ns-resize';
|
|
335
|
-
}
|
|
336
|
-
else if (selPuzzle) {
|
|
337
|
-
// 批次 305:选中态分割线行杠光标(未进会话——渲染侧 frameOverlay 常驻
|
|
338
|
-
// 行杠,光标随命中带切换出双向箭头)
|
|
339
|
-
const bar = hitPuzzleSeamBar((x, y) => this.host.toScreen(x, y), selPuzzle, cssX, cssY);
|
|
340
|
-
if (bar)
|
|
341
|
-
return EDGE_HANDLE_AXIS[bar.handle] === 'x' ? 'ew-resize' : 'ns-resize';
|
|
342
|
-
}
|
|
343
|
-
// 加号指示器圆在表格外(上/左外偏)且只在选中态可点(应用 controls 同语义);
|
|
344
|
-
// 优先于手柄——mtr 旋转柄恰与居中列指示器同域,指示器是表格专属 UI
|
|
345
|
-
const selTable = doc.selection.length === 1 && doc.selection[0] instanceof TableNode ? doc.selection[0] : null;
|
|
346
|
-
if (selTable && !doc.findTarget(p.x, p.y)) {
|
|
347
|
-
const ind = selTable.borderOrIndicatorHit(p.x, p.y, this.host.zoom);
|
|
348
|
-
if (ind?.inCircle) {
|
|
349
|
-
this.updateTableHover(selTable, ind, false);
|
|
350
|
-
return 'pointer';
|
|
351
|
-
}
|
|
352
|
-
// 行/列选择条 + 左上角拖动把手(同为选中态表外专属 UI;应用 controls 逆序
|
|
353
|
-
// 命中里条带/把手排指示器之后)。把手光标 'move'(应用 cursorStyleHandler)
|
|
354
|
-
const strip = selTable.stripHit(p.x, p.y, this.host.zoom);
|
|
355
|
-
if (strip) {
|
|
356
|
-
this.updateTableHover(selTable, null, false, { strip: stripHoverOf(strip) });
|
|
357
|
-
return 'pointer';
|
|
358
|
-
}
|
|
359
|
-
if (selTable.dragHandleHit(p.x, p.y, this.host.zoom)) {
|
|
360
|
-
this.updateTableHover(selTable, null, false, { dragHandle: true });
|
|
361
|
-
return 'move';
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
// 选区右下角扩展柄(引擎侧增强):优先于组手柄光标(onPointerDown 0.75 的
|
|
365
|
-
// 对称口径——选区延伸至表格右下时与 br 手柄同域;须点在表格本体上,柄恒在
|
|
366
|
-
// 表内;编辑态/无选区/全选 rangeHandleHit 恒 false)
|
|
367
|
-
if (selTable && doc.findTarget(p.x, p.y) === selTable && selTable.rangeHandleHit(p.x, p.y, this.host.zoom)) {
|
|
368
|
-
this.updateTableHover(selTable, null, true, { rangeHandle: true });
|
|
369
|
-
return 'crosshair';
|
|
370
|
-
}
|
|
371
|
-
// 锁定态锁图标 pointer(批次 67;app getHornControl cursorStyleHandler 的
|
|
372
|
-
// br 分支),其余手柄域锁定时 hitHandle 恒 null → 落回对象/默认光标
|
|
373
|
-
if (this.hitLockControl(cssX, cssY))
|
|
374
|
-
return 'pointer';
|
|
375
|
-
// 激活子手柄光标(批次 311 二补):子自身角度(含父组旋转链)定向——
|
|
376
|
-
// 命中序与 onPointerDown 一致(子手柄优先)
|
|
377
|
-
const childHandle = this.hitActiveChildHandle(cssX, cssY);
|
|
378
|
-
if (childHandle === 'mtr') {
|
|
379
|
-
const child = doc.activeGroupChild;
|
|
380
|
-
return rotateCursorIcon(child.worldAngle + 225);
|
|
381
|
-
}
|
|
382
|
-
if (childHandle) {
|
|
383
|
-
const child = doc.activeGroupChild;
|
|
384
|
-
// 子手柄集不产圆角族(radiusNode 恒 null)——窄化防御,理论不可达分支落默认
|
|
385
|
-
const base = HANDLE_BASE_ANGLE[childHandle];
|
|
386
|
-
if (typeof base === 'number') {
|
|
387
|
-
const a = base + child.worldAngle;
|
|
388
|
-
return SCALE_CURSORS[((Math.round(a / 45) % 4) + 4) % 4];
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
// 移动端移动控件光标(批次 354;app moveControls cursorStyleHandler 'move')
|
|
392
|
-
// ——命中序与 onPointerDown 一致(先于普通手柄;桌面态恒不命中)
|
|
393
|
-
if (this.hitMoveControl(cssX, cssY))
|
|
394
|
-
return 'move';
|
|
395
|
-
const handle = this.hitHandle(cssX, cssY);
|
|
396
|
-
// mtr 悬停光标 = 随对象角度转动的旋转箭头(app rotateControl
|
|
397
|
-
// cursorStyleHandler 的 rotateIcon(angle+225);多选取合并框角度 = fabric AS 角度)
|
|
398
|
-
if (handle === 'mtr')
|
|
399
|
-
return rotateCursorIcon((selectionQuadCoords(doc)?.angle ?? 0) + 225);
|
|
400
|
-
// 圆角手柄光标(批次 100;app rectControls cursorStyleHandler 恒定值——
|
|
401
|
-
// 不随对象角度换向,fabric 同款固定 nwse/nesw)
|
|
402
|
-
if (handle && isRadiusHandle(handle))
|
|
403
|
-
return handle === 'tlS' || handle === 'brS' ? 'nwse-resize' : 'nesw-resize';
|
|
404
|
-
if (handle) {
|
|
405
|
-
const a = HANDLE_BASE_ANGLE[handle] + (selectionQuadCoords(doc)?.angle ?? 0);
|
|
406
|
-
return SCALE_CURSORS[((Math.round(a / 45) % 4) + 4) % 4];
|
|
407
|
-
}
|
|
408
|
-
// 四角隐形旋转区悬停光标(批次 88):hitHandle 先归零=缩放手柄赢重叠区
|
|
409
|
-
//(fabric findControl 倒序同优先);光标=随对象角度转动的旋转箭头(app
|
|
410
|
-
// getRotateControl cursorStyleHandler 的 rotateIcon(angle+方位角)——
|
|
411
|
-
// tlr→0/trr→90/brr→180/blr→270;多选/表格/锁定 hitCornerRotateZone 恒 null)
|
|
412
|
-
const zone = this.hitCornerRotateZone(cssX, cssY);
|
|
413
|
-
if (zone)
|
|
414
|
-
return rotateCursorIcon((selectionQuadCoords(doc)?.angle ?? 0) + CORNER_ROTATE_CURSOR_OFFSET[zone]);
|
|
415
|
-
const target = doc.findTarget(p.x, p.y);
|
|
416
|
-
// 编辑目标上的悬停光标 = 文本光标(批次 315 补):编辑区域语义——悬停
|
|
417
|
-
// 边框已在 updateHover 让位,光标不落 'move'(fabric 编辑期对象域 text)
|
|
418
|
-
if (target && target === doc.editingNode)
|
|
419
|
-
return 'text';
|
|
420
|
-
if (target instanceof TableNode) {
|
|
421
|
-
// 扩展柄悬停已在上面的 selTable 块(优先于组手柄)处理;此处继续边框/指示器
|
|
422
|
-
const hit = target.borderOrIndicatorHit(p.x, p.y, this.host.zoom);
|
|
423
|
-
let cursor = 'move';
|
|
424
|
-
if (hit?.inCircle)
|
|
425
|
-
cursor = 'pointer';
|
|
426
|
-
else if (hit?.border && doc.selection.includes(target))
|
|
427
|
-
cursor = getBorderCursor(target.tableAngle, hit.border.type);
|
|
428
|
-
this.updateTableHover(target, hit, true);
|
|
429
|
-
return cursor;
|
|
430
|
-
}
|
|
431
|
-
this.updateTableHover(null, null, false);
|
|
432
|
-
// 参考线悬停 = 轴向光标(批次 72;app ReferenceLine 构造器 hoverCursor 同值)。
|
|
433
|
-
// 专用扫描——索引包围盒不含线距容差(同 onPointerDown 1.4 勘注)
|
|
434
|
-
if (!this.host.cropSession && !this.host.expandSession && !this.host.pathSession && !this.host.warpSession) {
|
|
435
|
-
const line = doc.nodes.find((n) => isReferenceLineNode(n) && n.visible && n.raw.visible !== false && n.containsPoint(p.x, p.y));
|
|
436
|
-
if (line)
|
|
437
|
-
return line.dims.y === 0 ? 'ns-resize' : 'ew-resize';
|
|
438
|
-
}
|
|
439
|
-
return target ? 'move' : '';
|
|
440
|
-
}
|
|
441
|
-
/** 表格悬停态生命周期(P4-4b):换目标/离场清旧态并重绘;边框高亮/指示器
|
|
442
|
-
* 圆高亮/指示器可见性/选择条与把手高亮变化时重绘(overlay 消费这些态) */
|
|
443
|
-
updateTableHover(table, hit, inside, extras = {}) {
|
|
444
|
-
if (this.hoveredTable && this.hoveredTable !== table) {
|
|
445
|
-
this.hoveredTable.clearHoverState();
|
|
446
|
-
this.hoveredTable = null;
|
|
447
|
-
this.host.requestRenderAll();
|
|
448
|
-
}
|
|
449
|
-
if (!table)
|
|
450
|
-
return;
|
|
451
|
-
const prevBorder = table.hoveredBorder;
|
|
452
|
-
const prevIndicator = table.hoveredIndicator;
|
|
453
|
-
const prevVisible = table.indicatorVisible;
|
|
454
|
-
const prevStrip = table.hoveredStrip;
|
|
455
|
-
const prevDrag = table.hoveredDragHandle;
|
|
456
|
-
const prevRange = table.hoveredRangeHandle;
|
|
457
|
-
table.hoveredBorder = hit && !hit.inCircle ? hit.border : null;
|
|
458
|
-
table.hoveredIndicator = hit?.inCircle ? hit.border : null;
|
|
459
|
-
table.indicatorVisible = inside || !!hit;
|
|
460
|
-
table.hoveredStrip = extras.strip ?? null;
|
|
461
|
-
table.hoveredDragHandle = extras.dragHandle ?? false;
|
|
462
|
-
table.hoveredRangeHandle = extras.rangeHandle ?? false;
|
|
463
|
-
this.hoveredTable = table;
|
|
464
|
-
const stripChanged = prevStrip?.kind !== table.hoveredStrip?.kind || prevStrip?.index !== table.hoveredStrip?.index;
|
|
465
|
-
if (prevBorder !== table.hoveredBorder ||
|
|
466
|
-
prevIndicator !== table.hoveredIndicator ||
|
|
467
|
-
prevVisible !== table.indicatorVisible ||
|
|
468
|
-
stripChanged ||
|
|
469
|
-
prevDrag !== table.hoveredDragHandle ||
|
|
470
|
-
prevRange !== table.hoveredRangeHandle)
|
|
471
|
-
this.host.requestRenderAll();
|
|
472
|
-
}
|
|
473
|
-
/** 空闲态悬停解析(P5-3 hover 边框片)。目标 = findTarget 顶组口径;激活组
|
|
474
|
-
* 等价 app 的 group.interactive——悬停下钻组内叶子(命中激活子本身则抑制,
|
|
475
|
-
* app target === activeObject)。抑制:会话(crop/expand/path/蒙版)激活、
|
|
476
|
-
* 手柄命中、悬停选中成员。变化时重绘。
|
|
477
|
-
* 批次 305 补:同程解析分割线行杠 hover(选中态拼图+指针在缝带内——用户
|
|
478
|
-
* 要求行杠只在 hover 到两格之间时显示;存身份渲染现算,拖杠期间不清——
|
|
479
|
-
* 行杠跟缝走,抬手后下一拍 move 重算)。
|
|
480
|
-
* 批次 305 补③:蒙版会话态(选中了格)行杠照常——编辑块自身的柄位让位
|
|
481
|
-
* (0.7 命中域),其余缝照出(gap 全域被行杠带覆盖,会话期点 gap 不再退
|
|
482
|
-
* 出——与柄点击同款无操作,退出走点外/Esc) */
|
|
483
|
-
updateHover(cssX, cssY, p, doc = this.host.document) {
|
|
484
|
-
// 跨页清旧(批次 409 D-3):hover 路由页切换时清旧页 hovered + 表格悬停态
|
|
485
|
-
if (doc !== this.lastHoverDoc) {
|
|
486
|
-
this.lastHoverDoc?.setHovered(null);
|
|
487
|
-
this.hoveredTable = null;
|
|
488
|
-
this.lastHoverDoc = doc;
|
|
489
|
-
this.host.requestRenderAll();
|
|
490
|
-
}
|
|
491
|
-
let next = null;
|
|
492
|
-
let seamNext = null;
|
|
493
|
-
// 会话整体取代选区 UI——悬停边框不参与(app isCropping 同语义域;
|
|
494
|
-
// 蒙版会话是引擎侧选择:分割线手柄域不叠对象边框)
|
|
495
|
-
const maskSession = doc.nodes.find((n) => n instanceof PuzzleNode && n.editingMask) ?? null;
|
|
496
|
-
const sessionActive = !!this.host.cropSession || !!this.host.expandSession || !!this.host.pathSession || !!this.host.warpSession || !!maskSession;
|
|
497
|
-
// 手柄/移动控件命中域不进悬停(app fabric findControl 命中即 target=活动
|
|
498
|
-
// 对象——其它对象 hover 边框不出;批次 354 move 控件并入同门)
|
|
499
|
-
const handleFree = !this.hitHandle(cssX, cssY) && !this.hitMoveControl(cssX, cssY);
|
|
500
|
-
if (!sessionActive && handleFree) {
|
|
501
|
-
const target = doc.findTarget(p.x, p.y);
|
|
502
|
-
if (target instanceof GroupNode && !(target instanceof TableNode) && !(target instanceof PuzzleNode)) {
|
|
503
|
-
// 组命中:未激活 → 顶组边框(app getHoverTarget 的 !interactive 分支);
|
|
504
|
-
// 激活组(activeGroupChild 隐含单选该组)→ 下钻叶子,命中激活子抑制
|
|
505
|
-
const activeChild = doc.activeGroupChild;
|
|
506
|
-
const ownerActive = activeChild !== null && doc.selection.length === 1 && doc.selection[0] === target;
|
|
507
|
-
if (!ownerActive) {
|
|
508
|
-
if (!doc.selection.includes(target))
|
|
509
|
-
next = target;
|
|
510
|
-
}
|
|
511
|
-
else {
|
|
512
|
-
const child = target.childAtPoint(p.x, p.y);
|
|
513
|
-
next = child && child !== activeChild ? child : null;
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
else if (target && !doc.selection.includes(target)) {
|
|
517
|
-
next = target;
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
// 编辑目标不进悬停态(批次 315 补):常规文本编辑节点在选区内已按「悬停
|
|
521
|
-
// 选中成员」抑制;transient 格编辑 overlay(选区钉表)与组内子文本(激活
|
|
522
|
-
// 子 ≠ 编辑节点)不在该抑制面内——鼠标扫过正在编辑的文本会误出 hover
|
|
523
|
-
// 边框(用户报「格内编辑时鼠标移上去出现 hover 状态」)。编辑中悬停
|
|
524
|
-
// 「其它对象」保持(P5-3 既有语义)
|
|
525
|
-
if (next && next === doc.editingNode)
|
|
526
|
-
next = null;
|
|
527
|
-
// 行杠 hover:选中态拼图指针落在缝带内(hitPuzzleSeamBar 与 0.75 按下/
|
|
528
|
-
// 悬停光标同源);会话态编辑块的 0.7 柄位让位(点柄不带杠)
|
|
529
|
-
if (handleFree && !(maskSession && hitMaskEditHandle((x, y) => this.host.toScreen(x, y), maskSession, cssX, cssY))) {
|
|
530
|
-
const selPuzzle = doc.selection.length === 1 && doc.selection[0] instanceof PuzzleNode ? doc.selection[0] : null;
|
|
531
|
-
if (selPuzzle) {
|
|
532
|
-
const bar = hitPuzzleSeamBar((x, y) => this.host.toScreen(x, y), selPuzzle, cssX, cssY);
|
|
533
|
-
if (bar)
|
|
534
|
-
seamNext = { puzzle: selPuzzle, mask: bar.mask, handle: bar.handle };
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
const prev = doc.hovered;
|
|
538
|
-
doc.setHovered(next);
|
|
539
|
-
const seamPrev = doc.seamHover;
|
|
540
|
-
doc.setSeamHover(seamNext);
|
|
541
|
-
if (doc.hovered !== prev || doc.seamHover !== seamPrev)
|
|
542
|
-
this.host.requestRenderAll();
|
|
543
|
-
}
|
|
544
|
-
attach() {
|
|
545
|
-
// 静态画布:监听整体不挂(手势/悬停命中全让位);dispose 的 detach 空置安全
|
|
546
|
-
if (!this.interactive)
|
|
547
|
-
return;
|
|
548
|
-
const el = this.el;
|
|
549
|
-
const onDown = (e) => {
|
|
550
|
-
if (e.button !== 0)
|
|
551
|
-
return;
|
|
552
|
-
// 外部绘制会话(compat 绘制桥)挂起期不启新手势——指针归宿主外工具接管
|
|
553
|
-
if (this.host.interactionSuspended)
|
|
554
|
-
return;
|
|
555
|
-
// 编辑态焦点保护:落光标分支的 setSelection 会同步 refocus IME textarea,
|
|
556
|
-
// 但 mousedown 默认焦点迁移在事件分发之后执行,会把焦点再摘给 body——
|
|
557
|
-
// 光标插入态键入全部失联(双击链因 dblclick 在默认动作后派发而幸免)。
|
|
558
|
-
// cancel pointerdown 只抑制 mousedown 默认行为,click/dblclick 照常派发
|
|
559
|
-
if (this.host.document.editingNode)
|
|
560
|
-
e.preventDefault();
|
|
561
|
-
const rect = el.getBoundingClientRect();
|
|
562
|
-
const cssX = e.clientX - rect.left;
|
|
563
|
-
const cssY = e.clientY - rect.top;
|
|
564
|
-
this.onPointerDown(cssX, cssY, e.shiftKey);
|
|
565
|
-
};
|
|
566
|
-
const onMove = (e) => {
|
|
567
|
-
// 挂起期放行进行中手势的 move(收尾用),空闲态不跑悬停命中;
|
|
568
|
-
// 中键平移期(批次 83)悬停解析整体让位——光标归 pan 的 grab 手掌
|
|
569
|
-
// (本监听 window 级且注册晚于 pan 写点,不守卫每次 move 都会覆盖)
|
|
570
|
-
if ((this.host.interactionSuspended && this.gesture.type === 'none') || this.host.panning)
|
|
571
|
-
return;
|
|
572
|
-
const rect = el.getBoundingClientRect();
|
|
573
|
-
this.onPointerMove(e.clientX - rect.left, e.clientY - rect.top);
|
|
574
|
-
};
|
|
575
|
-
const onUp = (e) => {
|
|
576
|
-
if (this.host.interactionSuspended && this.gesture.type === 'none')
|
|
577
|
-
return;
|
|
578
|
-
const rect = el.getBoundingClientRect();
|
|
579
|
-
this.onPointerUp(e.clientX - rect.left, e.clientY - rect.top);
|
|
580
|
-
};
|
|
581
|
-
// 指针离场清悬停(app upperCanvasEl mouseout → clear 同语义——window 级
|
|
582
|
-
// pointermove 离窗后不再触发,靠 leave 兜底)
|
|
583
|
-
const onLeave = () => {
|
|
584
|
-
const doc = this.host.document;
|
|
585
|
-
const prev = doc.hovered;
|
|
586
|
-
doc.setHovered(null);
|
|
587
|
-
// 多页:hover 可能落在非活动页(批次 409 D-3 路由)——离场一并清
|
|
588
|
-
if (this.lastHoverDoc && this.lastHoverDoc !== doc)
|
|
589
|
-
this.lastHoverDoc.setHovered(null);
|
|
590
|
-
this.lastHoverDoc = null;
|
|
591
|
-
this.el.style.cursor = '';
|
|
592
|
-
if (doc.hovered !== prev)
|
|
593
|
-
this.host.requestRenderAll();
|
|
594
|
-
};
|
|
595
|
-
el.addEventListener('pointerdown', onDown);
|
|
596
|
-
window.addEventListener('pointermove', onMove);
|
|
597
|
-
window.addEventListener('pointerup', onUp);
|
|
598
|
-
el.addEventListener('pointerleave', onLeave);
|
|
599
|
-
this.detach = () => {
|
|
600
|
-
el.removeEventListener('pointerdown', onDown);
|
|
601
|
-
window.removeEventListener('pointermove', onMove);
|
|
602
|
-
window.removeEventListener('pointerup', onUp);
|
|
603
|
-
el.removeEventListener('pointerleave', onLeave);
|
|
604
|
-
};
|
|
605
|
-
}
|
|
606
|
-
onPointerDown(cssX, cssY, shift) {
|
|
607
|
-
// 多页路由(批次 409 D-3):命中页自动激活(Canva 点哪页哪页激活——吸附
|
|
608
|
-
// 候选/会话发现/选区/overlay 经 document 天然落手势页;激活后 toScene 即
|
|
609
|
-
// 手势页页内坐标,手势全程活动页冻结)。页间 gap = 点空收尾(清选区、
|
|
610
|
-
// 不框选不拖拽)。单页态(宿主无路由面)行为逐位不变。吞没性会话期宿主
|
|
611
|
-
// 自锁活动页(resolvePointerTarget 的会话模态形态——点外退出语义保持)
|
|
612
|
-
if (this.host.resolvePointerTarget) {
|
|
613
|
-
const abs = this.host.toSceneAbs ? this.host.toSceneAbs(cssX, cssY) : this.host.toScene(cssX, cssY);
|
|
614
|
-
const entry = this.host.resolvePointerTarget(abs.x, abs.y);
|
|
615
|
-
if (!entry) {
|
|
616
|
-
this.host.document.clearSelection();
|
|
617
|
-
this.host.requestRenderAll();
|
|
618
|
-
return;
|
|
619
|
-
}
|
|
620
|
-
if (entry.doc !== this.host.document)
|
|
621
|
-
this.host.activateRoutedDocument?.(entry.doc);
|
|
622
|
-
}
|
|
623
|
-
const doc = this.host.document;
|
|
624
|
-
const p = this.host.toScene(cssX, cssY);
|
|
625
|
-
this.performed = false;
|
|
626
|
-
this.deferredClickSwitch = null;
|
|
627
|
-
// 按下即清悬停边框(app isMouseDown 抑制 drawBorder 同语义——拖拽/框选
|
|
628
|
-
// 全程与任何按下期都不画)
|
|
629
|
-
doc.setHovered(null);
|
|
630
|
-
// −1) 裁剪会话(B2):吞没一切(应用 isolateObjectForEdit + findTarget
|
|
631
|
-
// 吞没)——手柄命中 → 拖拽;裁剪窗内 → 框内拖图(应用 canvasMouseDown
|
|
632
|
-
// containsPoint(calcOCoords) 同语义;窗外 ghost 区走退出通道——含
|
|
633
|
-
// 幽灵区起拖会让内容滑而非预期,手感「飘」);框外 → 确认退出
|
|
634
|
-
const crop = this.host.cropSession;
|
|
635
|
-
if (crop) {
|
|
636
|
-
const handle = crop.hitHandle(cssX, cssY);
|
|
637
|
-
if (handle) {
|
|
638
|
-
this.gesture = { type: 'crop-handle', handle };
|
|
639
|
-
}
|
|
640
|
-
else if (crop.hitRect(p.x, p.y)) {
|
|
641
|
-
this.gesture = { type: 'crop-move', last: p };
|
|
642
|
-
}
|
|
643
|
-
else {
|
|
644
|
-
crop.exitByOutsideClick();
|
|
645
|
-
}
|
|
646
|
-
this.host.requestRenderAll();
|
|
647
|
-
return;
|
|
648
|
-
}
|
|
649
|
-
// −0.5) 扩图会话(B3):吞没一切——手柄命中 → 拖框;框内 → 拖动图片
|
|
650
|
-
// (应用框内 targetless 拖拽 + 'moving' 双通道汇 applyExpandClamp,
|
|
651
|
-
// 扩图余项子件补齐——第一子件的「框内无操作」与应用行为不符);
|
|
652
|
-
// 框外 → 确认退出
|
|
653
|
-
const expand = this.host.expandSession;
|
|
654
|
-
if (expand) {
|
|
655
|
-
const handle = expand.hitHandle(cssX, cssY);
|
|
656
|
-
if (handle) {
|
|
657
|
-
this.gesture = { type: 'expand-handle', handle };
|
|
658
|
-
}
|
|
659
|
-
else if (expand.hitRect(p.x, p.y)) {
|
|
660
|
-
this.gesture = { type: 'expand-image-drag', last: p };
|
|
661
|
-
}
|
|
662
|
-
else {
|
|
663
|
-
expand.exitByOutsideClick();
|
|
664
|
-
}
|
|
665
|
-
this.host.requestRenderAll();
|
|
666
|
-
return;
|
|
667
|
-
}
|
|
668
|
-
// −0.25) 路径族锚点编辑会话(P4-7):锚点/手柄命中 → 拖点;段上插点候选 →
|
|
669
|
-
// 点击插入并转拖新锚点(fabric _insertAnchorAtCandidate 后
|
|
670
|
-
// _setupCurrentTransform 同序);本体 → 移动对象;点外 → 退出但
|
|
671
|
-
// **不吞没本击**(应用 _maybeExitEditingPath 同击换选语义——与
|
|
672
|
-
// crop/expand 的整击吞没不同),后续常规命中/选区照常
|
|
673
|
-
const pathSession = this.host.pathSession;
|
|
674
|
-
if (pathSession) {
|
|
675
|
-
const anchorKey = pathSession.hitAnchor(cssX, cssY);
|
|
676
|
-
if (anchorKey && pathSession.startAnchorDrag(anchorKey)) {
|
|
677
|
-
this.gesture = { type: 'path-anchor-drag', key: anchorKey };
|
|
678
|
-
this.host.requestRenderAll();
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
681
|
-
const candidate = pathSession.findInsertCandidate(p.x, p.y);
|
|
682
|
-
if (candidate) {
|
|
683
|
-
const newKey = pathSession.insertAnchor(candidate);
|
|
684
|
-
if (newKey) {
|
|
685
|
-
this.gesture = { type: 'path-anchor-drag', key: newKey };
|
|
686
|
-
this.host.requestRenderAll();
|
|
687
|
-
return;
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
if (pathSession.hitBody(p.x, p.y)) {
|
|
691
|
-
this.gesture = { type: 'path-body-drag', last: p };
|
|
692
|
-
this.host.requestRenderAll();
|
|
693
|
-
return;
|
|
694
|
-
}
|
|
695
|
-
pathSession.exitByOutsideClick();
|
|
696
|
-
}
|
|
697
|
-
// −0.2) 图片扭曲会话(批次 66):锚点命中 → 拖拽;点外吞没不退出
|
|
698
|
-
// (fabric warp 退出只走 ESC/工具条按钮,画布点击不退会话)
|
|
699
|
-
const warpSession = this.host.warpSession;
|
|
700
|
-
if (warpSession) {
|
|
701
|
-
const anchor = warpSession.hitAnchor(cssX, cssY);
|
|
702
|
-
if (anchor) {
|
|
703
|
-
this.gesture = { type: 'warp-anchor-drag', anchor };
|
|
704
|
-
warpSession.applyAnchorDrag(anchor, p);
|
|
705
|
-
}
|
|
706
|
-
this.host.requestRenderAll();
|
|
707
|
-
return;
|
|
708
|
-
}
|
|
709
|
-
// −0.1) 标尺带拖出参考线(批次 72;app FabricRuler.mouseDown 同构):带内
|
|
710
|
-
// 按下即建线(visible:false,首 move 才显示——fabric 同序防 ruler 边
|
|
711
|
-
// 闪现)+ 拖拽;轴=带方位(上带横线/左带竖线,左带优先=fabric
|
|
712
|
-
// getPointHover 判序)。带命中吞没本击——不选对象不起框选。
|
|
713
|
-
// 纯点击(无 move)up 时撤销建线(fabric 此径会留 invisible 幽灵线
|
|
714
|
-
// 对象进序列化,引擎按更优口径不留)。
|
|
715
|
-
if (this.host.rulerVisible) {
|
|
716
|
-
const band = rulerBandAt(cssX, cssY);
|
|
717
|
-
if (band) {
|
|
718
|
-
const raw = createReferenceLineRaw(band, band === 'horizontal' ? p.y : p.x);
|
|
719
|
-
const node = createNode(raw);
|
|
720
|
-
if (node) {
|
|
721
|
-
doc.add(node);
|
|
722
|
-
doc.clearSelection();
|
|
723
|
-
this.gesture = { type: 'reference-line', node, axis: band, creating: true, historyBefore: captureHistoryBefore([node]) };
|
|
724
|
-
}
|
|
725
|
-
this.host.requestRenderAll();
|
|
726
|
-
return;
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
// 0) 编辑态:点文本内 → 置光标并进入文本选区拖拽;点外面 → 退出编辑,
|
|
730
|
-
// 同一击继续按对象/空白命中处理(退出+选中新目标一次完成,不需要
|
|
731
|
-
// 第二次点击)。手柄分支跳过:编辑态不渲染手柄,这一击不该命中
|
|
732
|
-
// 看不见的手柄(fabric 编辑期 hasControls=false 同语义)。
|
|
733
|
-
// 含点判定用编辑节点自身盒而非 findTarget——findTarget 是顶层语义
|
|
734
|
-
// (组命中返回组),组内子文本恒不等,点下即被误判「点外」退出编辑、
|
|
735
|
-
// 拖动落成整组移动;fabric 编辑期 textarea 全权接管对象盒内指针同语义
|
|
736
|
-
const editing = doc.editingNode;
|
|
737
|
-
let exitedEditing = false;
|
|
738
|
-
if (editing) {
|
|
739
|
-
if (editing.containsPoint(p.x, p.y)) {
|
|
740
|
-
const local = editing.localPoint(p.x, p.y);
|
|
741
|
-
const idx = editing.cursorIndexAt(local.x, local.y);
|
|
742
|
-
this.host.setEditingSelection(idx, idx);
|
|
743
|
-
this.gesture = { type: 'text-select', anchorIdx: idx };
|
|
744
|
-
return;
|
|
745
|
-
}
|
|
746
|
-
doc.exitEditing();
|
|
747
|
-
exitedEditing = true;
|
|
748
|
-
}
|
|
749
|
-
// 0.5) 单选表格的表外指示器圆(P4-4b):优先于手柄命中——mtr 旋转柄与居中
|
|
750
|
-
// 列指示器同域(上外偏 15px vs 24px,命中半径重叠),指示器是表格专属 UI。
|
|
751
|
-
// 行/列选择条同属表外 UI(应用 createInsertRow/ColumnControl 的
|
|
752
|
-
// mouseUpHandler → selectRow/selectColumn),排指示器之后
|
|
753
|
-
if (!exitedEditing && doc.selection.length === 1 && doc.selection[0] instanceof TableNode) {
|
|
754
|
-
const sel = doc.selection[0];
|
|
755
|
-
const ind = !doc.findTarget(p.x, p.y) ? sel.borderOrIndicatorHit(p.x, p.y, this.host.zoom) : null;
|
|
756
|
-
if (ind?.inCircle) {
|
|
757
|
-
this.gesture = { type: 'table-indicator-click', node: sel, border: ind.border };
|
|
758
|
-
return;
|
|
759
|
-
}
|
|
760
|
-
const strip = !doc.findTarget(p.x, p.y) ? sel.stripHit(p.x, p.y, this.host.zoom) : null;
|
|
761
|
-
if (strip) {
|
|
762
|
-
this.gesture = strip.kind === 'col-strip' ? { type: 'table-strip-click', node: sel, kind: 'col', index: strip.col } : { type: 'table-strip-click', node: sel, kind: 'row', index: strip.row };
|
|
763
|
-
return;
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
// 0.75) 单选表格的选区右下角扩展柄(引擎侧增强):优先于组手柄——选区
|
|
767
|
-
// 延伸至表格右下角(行/列选/接近全选)时与 br 缩放手柄同域,单元格
|
|
768
|
-
// 选区是表格专属 UI,同 0.5) 指示器优先于 mtr 的口径。须点在表格本体
|
|
769
|
-
// 上(柄骑在格右下角,恒在表内);编辑态/无选区/全选时 rangeHandleHit
|
|
770
|
-
// 恒 false(与渲染侧同条件)。锚 = 展开后选区左上角(合并区域并入,
|
|
771
|
-
// 与渲染同一口径),拖动重定义 (r1,c1)→当前格的矩形(buildSelectionRange
|
|
772
|
-
// 内部解析主格)。纯选区变化无历史提交
|
|
773
|
-
if (!exitedEditing && doc.selection.length === 1 && doc.selection[0] instanceof TableNode) {
|
|
774
|
-
const sel = doc.selection[0];
|
|
775
|
-
if (doc.findTarget(p.x, p.y) === sel && sel.rangeHandleHit(p.x, p.y, this.host.zoom)) {
|
|
776
|
-
const range = sel.expandedCellRange;
|
|
777
|
-
if (range) {
|
|
778
|
-
this.gesture = { type: 'table-range-drag', node: sel, anchor: { row: range.r1, col: range.c1 } };
|
|
779
|
-
return;
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
// 0.7) 拼图蒙版编辑会话(P4-5b(3/3)):会话分割线手柄优先于一切组手柄——
|
|
784
|
-
// 组手柄批次 51 起会话中照常渲染与命中(渲染侧 selectionOverlay、
|
|
785
|
-
// 命中侧 1) 的 groupHandlesLive),此优先序不变。
|
|
786
|
-
// 会话发现按节点扫描而非 selection——parityCheck 等会清选区,挂在
|
|
787
|
-
// selection 上的会话会变孤儿(选区丢了但 editingMask 残留,下次选中
|
|
788
|
-
// 拼图直接回到块手柄)
|
|
789
|
-
const maskSession = !exitedEditing ? doc.nodes.find((n) => n instanceof PuzzleNode && n.editingMask) ?? null : null;
|
|
790
|
-
const maskSessionActive = !!maskSession;
|
|
791
|
-
if (maskSessionActive && maskSession) {
|
|
792
|
-
// toScreen 依赖 host 的 this.vpt——箭头包装绑定(同 hoverCursor 处),裸传
|
|
793
|
-
// 会 TypeError 令 pointerdown 在 0.7 崩掉,1.8 的点选切换永远到不了
|
|
794
|
-
const h = hitMaskEditHandle((x, y) => this.host.toScreen(x, y), maskSession, cssX, cssY);
|
|
795
|
-
if (h && maskSession.editingMask) {
|
|
796
|
-
const puzzleGesture = buildPuzzleMaskEdgeResizeGesture(maskSession, maskSession.editingMask, h);
|
|
797
|
-
if (puzzleGesture)
|
|
798
|
-
this.gesture = puzzleGesture;
|
|
799
|
-
return;
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
// 0.75) 批次 305(gaoding 同款):拼图选中态分割线行杠——不拖块柄直接拖
|
|
803
|
-
// 分割线重摆布局;渲染/命中共源 getPuzzleSeamBars(hover 门控见
|
|
804
|
-
// updateHover)。先于组手柄/对象命中(内层亲和性优先,行杠带 12px
|
|
805
|
-
// 与组手柄等宽——拼图边缘外缘边不出杠,与组 ml/mr 无叠域)。
|
|
806
|
-
// 批次 305 补③:蒙版会话态照常(用户要求选中格后行杠也可用)——
|
|
807
|
-
// 0.7 编辑块柄位优先(贴块边的柄是块级锚定),杠落间隙正中互补;
|
|
808
|
-
// 会话期点 gap 全域被行杠带覆盖=无操作(不再退出,退出走点外/Esc)
|
|
809
|
-
{
|
|
810
|
-
const seamPuzzle = doc.selection.length === 1 && doc.selection[0] instanceof PuzzleNode ? doc.selection[0] : null;
|
|
811
|
-
if (seamPuzzle) {
|
|
812
|
-
const bar = hitPuzzleSeamBar((x, y) => this.host.toScreen(x, y), seamPuzzle, cssX, cssY);
|
|
813
|
-
if (bar) {
|
|
814
|
-
const puzzleGesture = buildPuzzleMaskEdgeResizeGesture(seamPuzzle, bar.mask, bar.handle);
|
|
815
|
-
if (puzzleGesture)
|
|
816
|
-
this.gesture = puzzleGesture;
|
|
817
|
-
return;
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
// 0.85) 锁定单选的锁图标点击(批次 67):app getHornControl mouseUpHandler
|
|
822
|
-
// (br 命中且非组内)→ canvas.setUnlock 的引擎面——引擎只发事实事件,
|
|
823
|
-
// 锁键族清写归应用桥接层(compat setUnlock → setNodeProps 单点)。
|
|
824
|
-
// fabric 在 mouseup 触发且中途移开不取消(transform 不因移动中断),
|
|
825
|
-
// 此处按下即发同效且免手势态
|
|
826
|
-
const lockTarget = !exitedEditing ? this.hitLockControl(cssX, cssY) : null;
|
|
827
|
-
if (lockTarget) {
|
|
828
|
-
this.host.document.events.fire('lock:unlock-requested', lockTarget);
|
|
829
|
-
return;
|
|
830
|
-
}
|
|
831
|
-
// 1) 手柄命中:单选 = 对象自身变换;多选 = ActiveSelection 等价变换(合并框)
|
|
832
|
-
//(蒙版会话(批次 51 起):选区=会话拼图时组手柄照常命中——会话分割线手柄
|
|
833
|
-
// 已在 0.7 优先接管,落这里的是顶组容器缩放/角点缩放/旋转(app fabric 鼠标
|
|
834
|
-
// 悬停 topGroup 控件即换 activeObject=顶组的同语义);孤儿会话(选区不在
|
|
835
|
-
// 拼图上)保持不命中)
|
|
836
|
-
const groupHandlesLive = !maskSessionActive || (maskSession != null && doc.selection.length === 1 && doc.selection[0] === maskSession);
|
|
837
|
-
// 激活子手柄(批次 311 二补):组内编辑态下子全套手柄优先于顶组手柄——
|
|
838
|
-
// mtr=子级旋转、角点/边中点=子级缩放(数学按节点自治:snapshot.node=子,
|
|
839
|
-
// 文本 ml/mr 改宽、角点字号烘焙随类型自动生效;抬手 fit 组壳联动)。
|
|
840
|
-
// 表格/拼图顶组不进(自制控件集域);锁定子手柄照常命中(批次 346 勘正:
|
|
841
|
-
// 会话=显式编辑意图,PSD 全锁组内子不再被锁键否决)
|
|
842
|
-
if (groupHandlesLive && !exitedEditing) {
|
|
843
|
-
const childHandle = this.hitActiveChildHandle(cssX, cssY);
|
|
844
|
-
const child = doc.activeGroupChild;
|
|
845
|
-
const topGroup = doc.selection.length === 1 ? doc.selection[0] : null;
|
|
846
|
-
if (childHandle && child && topGroup instanceof GroupNode && !(topGroup instanceof TableNode) && !(topGroup instanceof PuzzleNode)) {
|
|
847
|
-
const shells = ancestorChainTo(topGroup, child);
|
|
848
|
-
if (shells.length) {
|
|
849
|
-
const commitNodes = [child, ...shells, ...shells.flatMap((g) => g.children)];
|
|
850
|
-
if (childHandle === 'mtr') {
|
|
851
|
-
const a = child.aCoords;
|
|
852
|
-
const centerScene = { x: (a.tl.x + a.br.x) / 2, y: (a.tl.y + a.br.y) / 2 };
|
|
853
|
-
this.freezeRotateHandle(child.raw.angle ?? 0, centerScene, true);
|
|
854
|
-
this.gesture = {
|
|
855
|
-
type: 'rotate',
|
|
856
|
-
center: centerScene,
|
|
857
|
-
startAngle: Math.atan2(p.y - centerScene.y, p.x - centerScene.x),
|
|
858
|
-
snapshot: { node: child, angle0: child.raw.angle ?? 0 },
|
|
859
|
-
cursorOffset: 225,
|
|
860
|
-
childTransform: { child, shells, pivotLocal: { ...child.center } },
|
|
861
|
-
historyBefore: captureHistoryBefore(commitNodes)
|
|
862
|
-
};
|
|
863
|
-
}
|
|
864
|
-
else if (!isRadiusHandle(childHandle)) {
|
|
865
|
-
this.gesture = {
|
|
866
|
-
type: 'scale',
|
|
867
|
-
handle: childHandle,
|
|
868
|
-
snapshot: buildScaleSnapshot(child, childHandle, doc),
|
|
869
|
-
freeScale: shift && CORNER_HANDLES.has(childHandle),
|
|
870
|
-
childTransform: { child, shells },
|
|
871
|
-
historyBefore: captureHistoryBefore(commitNodes)
|
|
872
|
-
};
|
|
873
|
-
}
|
|
874
|
-
else {
|
|
875
|
-
return;
|
|
876
|
-
}
|
|
877
|
-
this.host.requestRenderAll();
|
|
878
|
-
return;
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
// 1.01) 移动端移动控件(批次 354;app baseControls 的 moveControls——
|
|
883
|
-
// fabricConf hasMobile 门注入的常规族控件):单选常规族选区右中
|
|
884
|
-
// +24 屏幕px 的圆形移动图标柄,按下即起整选区 move 手势(app
|
|
885
|
-
// actionHandler=dragHandler 同语义——拖它=拖本体;move 手势自带
|
|
886
|
-
// 启动阈值+performed 门,纯点击零位移无提交)。命中先于普通手柄:
|
|
887
|
-
// fabric findControl 倒序里 move 排在缩放手柄后、mtr 前——mtr 与
|
|
888
|
-
// move 同位冲突(对象角 45°~135° 时 mtr 吸附到本地右缘=move 同位)
|
|
889
|
-
// move 赢(此处先判即同效);与 mr 的贴边 4px 重叠带(两心距 24、
|
|
890
|
-
// 半径和 28)引擎取 move——控件视觉在框外,让 mr 半径内贴边点
|
|
891
|
-
// 仍可拖本体语义无损。激活子手柄优先不变(1) 子柄块在前)
|
|
892
|
-
if (!exitedEditing && groupHandlesLive && this.hitMoveControl(cssX, cssY)) {
|
|
893
|
-
const node = doc.selection[0];
|
|
894
|
-
const snapshot = new Map();
|
|
895
|
-
snapshot.set(node, { left: node.raw.left ?? 0, top: node.raw.top ?? 0 });
|
|
896
|
-
this.gesture = { type: 'move', start: p, startCss: { x: cssX, y: cssY }, snapshot, historyBefore: captureHistoryBefore([node]) };
|
|
897
|
-
this.host.requestRenderAll();
|
|
898
|
-
return;
|
|
899
|
-
}
|
|
900
|
-
const handle = exitedEditing || !groupHandlesLive ? null : this.hitHandle(cssX, cssY);
|
|
901
|
-
if (handle) {
|
|
902
|
-
if (doc.selection.length === 1) {
|
|
903
|
-
const node = doc.selection[0];
|
|
904
|
-
if (handle === 'mtr') {
|
|
905
|
-
const center = node.center;
|
|
906
|
-
this.freezeRotateHandle(node.raw.angle ?? 0, center);
|
|
907
|
-
this.gesture = {
|
|
908
|
-
type: 'rotate',
|
|
909
|
-
center,
|
|
910
|
-
startAngle: Math.atan2(p.y - center.y, p.x - center.x),
|
|
911
|
-
snapshot: { node, angle0: node.raw.angle ?? 0 },
|
|
912
|
-
cursorOffset: 225,
|
|
913
|
-
historyBefore: captureHistoryBefore([node])
|
|
914
|
-
};
|
|
915
|
-
}
|
|
916
|
-
else if (isRadiusHandle(handle) && (isRadiusHandleNode(node) || isImageRadiusHandleNode(node))) {
|
|
917
|
-
// 圆角拖拽(批次 100 矩形/批次 101 图片;app rectControls/imageControls
|
|
918
|
-
// 的 changeRectCornerRadius/changeImageCornerRadius 引擎面):快照含旧
|
|
919
|
-
// 圆角值供撤销回放(app 手动记录同位)
|
|
920
|
-
this.gesture = { type: 'cornerRadius', node, corner: RADIUS_HANDLE_CORNER[handle], model: isImageRadiusHandleNode(node) ? 'image' : 'rect', historyBefore: captureHistoryBefore([node]) };
|
|
921
|
-
}
|
|
922
|
-
else if (node instanceof TableNode && isEdgeHandle(handle)) {
|
|
923
|
-
// 表格边中点手柄:应用 createEdgeControl 把拖拽烘焙进边缘列宽/行高
|
|
924
|
-
// (createEdgeResizeHandler 'single' 模式)+ 布局重排,不落通用 scale
|
|
925
|
-
// (scaleX/Y 改写会丢布局语义);角点/mtr 仍走通用缩放/旋转
|
|
926
|
-
const g = buildTableEdgeResizeGesture(node, handle);
|
|
927
|
-
g.historyBefore = captureHistoryBefore([node]);
|
|
928
|
-
this.gesture = g;
|
|
929
|
-
}
|
|
930
|
-
else if (node instanceof PuzzleNode && isEdgeHandle(handle)) {
|
|
931
|
-
// 拼图边中点手柄(P4-5b(2/2)):应用 puzzleControls 的 changePuzzleWidth/Height
|
|
932
|
-
// ——容器比例缩放烘焙进布局参数与逐块几何(resizeByContainer),不落 scale;
|
|
933
|
-
// 角点/mtr 仍走通用缩放/旋转(应用 baseControls 语义)
|
|
934
|
-
const g = buildPuzzleEdgeResizeGesture(node, handle);
|
|
935
|
-
g.historyBefore = captureHistoryBefore([node]);
|
|
936
|
-
this.gesture = g;
|
|
937
|
-
}
|
|
938
|
-
else {
|
|
939
|
-
// doc 传入供顶层蒙版边柄判定(批次 129 勘正——buildScaleSnapshot 挂 bakeMask*)
|
|
940
|
-
this.gesture = { type: 'scale', handle, snapshot: buildScaleSnapshot(node, handle, doc), freeScale: shift && CORNER_HANDLES.has(handle), historyBefore: captureHistoryBefore([node]) };
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
else {
|
|
944
|
-
const layout = selectionQuadCoords(doc);
|
|
945
|
-
// 锁定成员不随多选变换(批次 67):fabric AS 手势对 lockMovement/Scale/
|
|
946
|
-
// Rotation 成员逐键短路——快照按成员过滤,框姿态仍取全选区(视觉框
|
|
947
|
-
// 不变,app AS 手柄不受成员锁影响)。全锁成员 → members 空 = 手势空转
|
|
948
|
-
const movable = doc.selection.filter((n) => !isUserLockedNode(n));
|
|
949
|
-
if (handle === 'mtr') {
|
|
950
|
-
const center = quadCenter(layout.quad);
|
|
951
|
-
// 空转手势(全锁成员)不写覆盖态——mtr 不定格、无角度气泡(视觉不撒谎,
|
|
952
|
-
// 与下方 multi-rotate 空转守卫同口径)
|
|
953
|
-
if (movable.length)
|
|
954
|
-
this.freezeRotateHandle(layout.angle, center);
|
|
955
|
-
this.gesture = {
|
|
956
|
-
type: 'multi-rotate',
|
|
957
|
-
center,
|
|
958
|
-
startAngle: Math.atan2(p.y - center.y, p.x - center.x),
|
|
959
|
-
// 框姿态随手势累计(连续二次旋转从已旋转框续转,fabric AS 语义)
|
|
960
|
-
frameAngle0: layout.angle,
|
|
961
|
-
frame: quadDims(layout.quad),
|
|
962
|
-
snapshot: { members: movable.map((node) => ({ node, angle0: node.raw.angle ?? 0, center0: { ...node.center } })) },
|
|
963
|
-
historyBefore: captureHistoryBefore(doc.selection)
|
|
964
|
-
};
|
|
965
|
-
}
|
|
966
|
-
else {
|
|
967
|
-
this.gesture = {
|
|
968
|
-
type: 'multi-scale',
|
|
969
|
-
snapshot: buildMultiScaleSnapshot(movable, handle, layout),
|
|
970
|
-
freeScale: shift && CORNER_HANDLES.has(handle),
|
|
971
|
-
historyBefore: captureHistoryBefore(doc.selection)
|
|
972
|
-
};
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
return;
|
|
976
|
-
}
|
|
977
|
-
// 1.05) 四角隐形旋转区(批次 88;fabric baseControls tlr/trr/brr/blr):角点
|
|
978
|
-
// 对角外偏 4px 的 16×16 隐形命中盒,抓到即旋转(render=noop——控件
|
|
979
|
-
// 无任何视觉,只有光标与手势语义)。命中序在缩放手柄之后(fabric
|
|
980
|
-
// findControl 倒序:key 序靠后的 tl/tr/bl/br 赢重叠区)。单选专属——
|
|
981
|
-
// AS 走 fabric 原生控件集、TableNode 走 tableControls 自制集均无四角区
|
|
982
|
-
// (hitCornerRotateZone 内判)。起转后 mtr 不锚定(fabric
|
|
983
|
-
// __rotateControlPosition 只由 mtr actionHandler 写——四角区起转时
|
|
984
|
-
// mtr 逐帧重吸附换边),角度气泡照常(renderRotateControl isRotating
|
|
985
|
-
// 只看 action==='rotate')
|
|
986
|
-
const zone = exitedEditing || !groupHandlesLive ? null : this.hitCornerRotateZone(cssX, cssY);
|
|
987
|
-
if (zone) {
|
|
988
|
-
const node = doc.selection[0];
|
|
989
|
-
const center = node.center;
|
|
990
|
-
if (this.host.rotateDrag !== undefined) {
|
|
991
|
-
this.host.rotateDrag = { spec: null, center: { x: center.x, y: center.y } };
|
|
992
|
-
}
|
|
993
|
-
this.gesture = {
|
|
994
|
-
type: 'rotate',
|
|
995
|
-
center,
|
|
996
|
-
startAngle: Math.atan2(p.y - center.y, p.x - center.x),
|
|
997
|
-
snapshot: { node, angle0: node.raw.angle ?? 0 },
|
|
998
|
-
cursorOffset: CORNER_ROTATE_CURSOR_OFFSET[zone],
|
|
999
|
-
historyBefore: captureHistoryBefore([node])
|
|
1000
|
-
};
|
|
1001
|
-
return;
|
|
1002
|
-
}
|
|
1003
|
-
// 1.2) 左上角拖动把手(应用 createDragControl):命中优先级在角点/边中点
|
|
1004
|
-
// 之后(应用 Table.findControl 逆序遍历,drag 在 controls 字典排最前故
|
|
1005
|
-
// 最末命中);语义 = 整表移动,复用 move 手势(逐帧 'moving'、up 一条
|
|
1006
|
-
// modified,纯点击不提交)。仅在单选表格时存在(多选渲染合并框控件)
|
|
1007
|
-
if (!exitedEditing && doc.selection.length === 1 && doc.selection[0] instanceof TableNode) {
|
|
1008
|
-
const sel = doc.selection[0];
|
|
1009
|
-
if (!doc.findTarget(p.x, p.y) && sel.dragHandleHit(p.x, p.y, this.host.zoom)) {
|
|
1010
|
-
const snapshot = new Map();
|
|
1011
|
-
for (const n of doc.selection)
|
|
1012
|
-
snapshot.set(n, { left: n.raw.left ?? 0, top: n.raw.top ?? 0 });
|
|
1013
|
-
this.gesture = { type: 'move', start: p, startCss: { x: cssX, y: cssY }, snapshot, historyBefore: captureHistoryBefore(doc.selection) };
|
|
1014
|
-
this.host.requestRenderAll();
|
|
1015
|
-
return;
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
// 1.5) 表格单元格交互(P4-4b):命中的顶层对象是表格时优先于通用对象分支——
|
|
1019
|
-
// 加号指示器(up 插入行列;低 zoom 下圆可探入内容区,故表内也复核)/
|
|
1020
|
-
// 内部边框(拖拽调宽高,须已选中——应用 alreadySelected 同口径,首击
|
|
1021
|
-
// 只选表)/ 单元格(点选、shift 框选、超阈值让位整表移动)。
|
|
1022
|
-
// 嵌套表(组内表)不在本批支持面;表外指示器已在 0.5) 提前接管
|
|
1023
|
-
// 1.4) 参考线抓取(批次 72;app ReferenceLine mousedown:before 重新激活 +
|
|
1024
|
-
// fabric 单键 lockMovement 逐轴拖同构):专用扫描不走 findTarget——
|
|
1025
|
-
// rbush 索引包围盒不含 containsPoint 的 3px 线距容差(stroke 撑开仅
|
|
1026
|
-
// ±0.5),带容差的点击永远进不了候选;不走通用 move(单键
|
|
1027
|
-
// lockMovementX/Y 是轴锁非用户锁,通用分支当全锁穿透);shift 点线
|
|
1028
|
-
// = 无操作(fabric 落定线 selectable:false 不进 AS——直接返回保持
|
|
1029
|
-
// 现选区)。线位命中容差 3px 与 LineNode.containsPoint 同源。
|
|
1030
|
-
if (!shift) {
|
|
1031
|
-
const line = doc.nodes.find((n) => isReferenceLineNode(n) && n.visible && n.raw.visible !== false && n.containsPoint(p.x, p.y));
|
|
1032
|
-
if (line) {
|
|
1033
|
-
doc.setSelection([line], 'create');
|
|
1034
|
-
this.gesture = { type: 'reference-line', node: line, axis: line.dims.y === 0 ? 'horizontal' : 'vertical', creating: false, historyBefore: captureHistoryBefore([line]) };
|
|
1035
|
-
this.host.requestRenderAll();
|
|
1036
|
-
return;
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
const tableTarget = doc.findTarget(p.x, p.y);
|
|
1040
|
-
const table = tableTarget instanceof TableNode ? tableTarget : null;
|
|
1041
|
-
if (table) {
|
|
1042
|
-
const ind = table.borderOrIndicatorHit(p.x, p.y, this.host.zoom);
|
|
1043
|
-
if (ind?.inCircle) {
|
|
1044
|
-
this.gesture = { type: 'table-indicator-click', node: table, border: ind.border };
|
|
1045
|
-
return;
|
|
1046
|
-
}
|
|
1047
|
-
// 选区右下角扩展柄的命中在 0.75)(优先于组手柄);此处继续边框/单元格
|
|
1048
|
-
const border = table.borderHit(p.x, p.y);
|
|
1049
|
-
if (border && doc.selection.includes(table)) {
|
|
1050
|
-
const g = buildTableBorderDragGesture(table, border, p);
|
|
1051
|
-
g.historyBefore = captureHistoryBefore([table]);
|
|
1052
|
-
this.gesture = g;
|
|
1053
|
-
return;
|
|
1054
|
-
}
|
|
1055
|
-
const cellPos = table.cellHit(p.x, p.y);
|
|
1056
|
-
if (cellPos) {
|
|
1057
|
-
// 首击即选表(fabric mousedown 选target 同语义);多选含表时保持多选。
|
|
1058
|
-
// 多选态点表格成员同 defer 语义(2) 分支同款):up 纯点击切换单选表格、
|
|
1059
|
-
// 不设单元格选区——多选还没解散不该选格,格交互从单选态重新开始
|
|
1060
|
-
if (!doc.selection.includes(table))
|
|
1061
|
-
doc.setSelection([table], 'create');
|
|
1062
|
-
else if (!shift && doc.selection.length > 1)
|
|
1063
|
-
this.deferredClickSwitch = table;
|
|
1064
|
-
const snapshot = new Map();
|
|
1065
|
-
// 锁定成员不随整表拖动(批次 67;锁定表格拖单元格=fabric lockMovement 短路)
|
|
1066
|
-
for (const n of doc.selection) {
|
|
1067
|
-
if (isUserLockedNode(n))
|
|
1068
|
-
continue;
|
|
1069
|
-
snapshot.set(n, { left: n.raw.left ?? 0, top: n.raw.top ?? 0 });
|
|
1070
|
-
}
|
|
1071
|
-
this.gesture = {
|
|
1072
|
-
type: 'table-cell-click',
|
|
1073
|
-
node: table,
|
|
1074
|
-
start: p,
|
|
1075
|
-
anchorCell: cellPos,
|
|
1076
|
-
shift,
|
|
1077
|
-
moveSnapshot: snapshot,
|
|
1078
|
-
frame0: doc.selection.length > 1 ? (doc.selectionFrame ? { ...doc.selectionFrame } : undefined) : undefined,
|
|
1079
|
-
historyBefore: captureHistoryBefore(doc.selection)
|
|
1080
|
-
};
|
|
1081
|
-
this.host.requestRenderAll();
|
|
1082
|
-
return;
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
// 1.8) 蒙版会话内点击(P4-5b(3/3)):命中块切换选中;命中拼图 gap 保持;
|
|
1086
|
-
// 点外(其它对象/空白)退出会话,继续正常选中流程。
|
|
1087
|
-
// 批次 304:会话与下钻合一(fabric 选中拼图内 mask 本是单态)——切块
|
|
1088
|
-
// 同步 activeGroupChild(面板 getActiveObject 映射不滞后),gap 退出
|
|
1089
|
-
// 会话+激活回整组(批次 141 paddingRect 语义,与 2.5 下钻 gap 同口径,
|
|
1090
|
-
// 此前会话期 gap 静默保持)。
|
|
1091
|
-
// 批次 304 补:命中块按下即武装整组 move 手势——app fabric 的
|
|
1092
|
-
// _promoteChildDragTransformToGroup 同语义(mask 本身 lockMovement 锁
|
|
1093
|
-
// 死,但 mousemove 链先把 transform.target 换成 topGroup 再位移,净
|
|
1094
|
-
// 效果=拖格子本体移动整个拼图)。此前本分支 return 早退把手势断了,
|
|
1095
|
-
// 下钻后拖格无操作(用户报)。纯点击零位移:move 手势自带启动阈值
|
|
1096
|
-
// + performed 门,up 不产伪历史
|
|
1097
|
-
if (maskSessionActive && maskSession) {
|
|
1098
|
-
if (tableTarget === maskSession) {
|
|
1099
|
-
const hit = maskSession.maskChildren.find((m) => m.visible && m.containsPoint(p.x, p.y));
|
|
1100
|
-
if (hit) {
|
|
1101
|
-
if (hit !== maskSession.editingMask)
|
|
1102
|
-
maskSession.editingMask = hit;
|
|
1103
|
-
doc.setActiveGroupChild(hit);
|
|
1104
|
-
const snapshot = new Map();
|
|
1105
|
-
for (const n of doc.selection) {
|
|
1106
|
-
if (isUserLockedNode(n))
|
|
1107
|
-
continue;
|
|
1108
|
-
snapshot.set(n, { left: n.raw.left ?? 0, top: n.raw.top ?? 0 });
|
|
1109
|
-
}
|
|
1110
|
-
this.gesture = {
|
|
1111
|
-
type: 'move',
|
|
1112
|
-
start: p,
|
|
1113
|
-
startCss: { x: cssX, y: cssY },
|
|
1114
|
-
snapshot,
|
|
1115
|
-
frame0: undefined,
|
|
1116
|
-
historyBefore: captureHistoryBefore(doc.selection)
|
|
1117
|
-
};
|
|
1118
|
-
}
|
|
1119
|
-
else {
|
|
1120
|
-
maskSession.exitMaskEditing();
|
|
1121
|
-
doc.setActiveGroupChild(null);
|
|
1122
|
-
}
|
|
1123
|
-
this.host.requestRenderAll();
|
|
1124
|
-
return;
|
|
1125
|
-
}
|
|
1126
|
-
maskSession.exitMaskEditing();
|
|
1127
|
-
this.host.requestRenderAll();
|
|
1128
|
-
}
|
|
1129
|
-
// 2) 对象命中:未选中则选(shift 加选/换选),已选中直接进入移动
|
|
1130
|
-
const target = tableTarget instanceof TableNode ? null : tableTarget;
|
|
1131
|
-
if (target) {
|
|
1132
|
-
// 按下时的旧选中态(fabric defer 穿透用它判:首击选中不穿透,app
|
|
1133
|
-
// fabricCanvas 3573 的 target === _activeObject 是 mousedown 时旧值)
|
|
1134
|
-
const wasSelected = doc.selection.includes(target);
|
|
1135
|
-
// 组内编辑会话位在装配处直读(批次 311 三补/四补:会话=**组合操作**开启
|
|
1136
|
-
// 的 fabric interactive 等价——engineGroupSelection 成功即进(用户拍板
|
|
1137
|
-
// 入口=组合按钮,非双击);未开会话单击下钻仅选中,拖=整组移动 P5-1)
|
|
1138
|
-
const groupEditingLive = doc.groupEditing;
|
|
1139
|
-
if (shift) {
|
|
1140
|
-
// 锁定元素不进多选(批次 67 二补):app mixin activeSelection 重写
|
|
1141
|
-
// AS.add/multiSelectAdd 的锁过滤——shift 加选被滤掉(锁定目标无操作);
|
|
1142
|
-
// 从锁定单选 shift 加选别人时锁定成员同样被踢出(AS.add(旧选中) 也走过滤)
|
|
1143
|
-
const next = (doc.selection.includes(target) ? doc.selection.filter((n) => n !== target) : [...doc.selection, target]).filter((n) => !isUserLockedNode(n));
|
|
1144
|
-
doc.setSelection(next, 'update');
|
|
1145
|
-
}
|
|
1146
|
-
else if (!doc.selection.includes(target)) {
|
|
1147
|
-
doc.setSelection([target], 'create');
|
|
1148
|
-
}
|
|
1149
|
-
else if (doc.selection.length > 1) {
|
|
1150
|
-
// ActiveSelection 态点已选成员:defer 到 up——mousedown 保持多选(下方
|
|
1151
|
-
// move 快照=全员,拖动=整组移动语义不变),up 判定纯点击才切换单选该
|
|
1152
|
-
// 成员(应用组点击穿透的时机原则同款,docs/2026-04-28:按下即切会让
|
|
1153
|
-
// 多选态的整体拖动做不成——手落点常恰在成员上)
|
|
1154
|
-
this.deferredClickSwitch = target;
|
|
1155
|
-
}
|
|
1156
|
-
// 2.5) 组内点选下钻(P5-1 组交互片,应用 searchNonGroupTarget + topGroup
|
|
1157
|
-
// 同语义):多层组合仍点选组内叶子元素——selection/拖动/变换框保持
|
|
1158
|
-
// 整组(应用 promote 拖组的等价物,拖动即整组移动),激活子供事件/
|
|
1159
|
-
// 面板消费。组已选中不重设选区,下钻须无条件执行(再点同组其它子
|
|
1160
|
-
// 即切换激活)。Table/Mask 走各自会话层不穿透(应用侧 type!=='group'
|
|
1161
|
-
// 同口径);多选形成时 setActiveGroupChild 校验自动退出。
|
|
1162
|
-
if (target instanceof GroupNode && !(target instanceof TableNode) && !(target instanceof PuzzleNode)) {
|
|
1163
|
-
doc.setActiveGroupChild(target.childAtPoint(p.x, p.y));
|
|
1164
|
-
}
|
|
1165
|
-
else if (target instanceof PuzzleNode && wasSelected && doc.selection.length === 1) {
|
|
1166
|
-
// 批次 138:拼图二次点击下钻(应用 fabricCanvas.searchPossibleTargets 的
|
|
1167
|
-
// PUZZLE 分支同语义——isActivePuzzleScope 时放行到子目标):首击选拼图
|
|
1168
|
-
// 本体不穿透(wasSelected=按下前已选中);再点 → 下钻激活命中格 mask
|
|
1169
|
-
// (selection/拖动/变换框保持整组=应用 _promoteChildDragTransformToGroup
|
|
1170
|
-
// 同义,激活子供事件/面板/应用蒙版工具栏消费)。命中组内空洞(gap)→
|
|
1171
|
-
// null 退出激活回整组。蒙版会话激活期 1.8 已接管 return,到不了这。
|
|
1172
|
-
// 批次 304:下钻即入蒙版会话(fabric 单态 parity——选中格 mask 的控件面
|
|
1173
|
-
// (块级分割线手柄+块边框+顶组虚线控件)随下钻出现;此前只有双击进会话
|
|
1174
|
-
// 才有,用户报「拼图内 FabricMask 选中 controls 没出现」)。gap 退出时
|
|
1175
|
-
// 会话一并退出(1.8 的 gap 同口径)。
|
|
1176
|
-
// 单选限定:多选态点拼图成员 editingMask 直写会绕过 setActiveGroupChild
|
|
1177
|
-
// 的单选校验(蒙版会话开了但选区仍多选的乱态)——与组下钻同款先退多选:
|
|
1178
|
-
// defer 到 up 单选拼图,第二次点击才下钻
|
|
1179
|
-
const drillHit = target.maskChildren.find((m) => m.visible && m.containsPoint(p.x, p.y)) ?? null;
|
|
1180
|
-
doc.setActiveGroupChild(drillHit);
|
|
1181
|
-
if (drillHit)
|
|
1182
|
-
target.editingMask = drillHit;
|
|
1183
|
-
else
|
|
1184
|
-
target.exitMaskEditing();
|
|
1185
|
-
}
|
|
1186
|
-
else if (doc.activeGroupChild) {
|
|
1187
|
-
doc.setActiveGroupChild(null);
|
|
1188
|
-
}
|
|
1189
|
-
if (doc.selection.includes(target)) {
|
|
1190
|
-
// 按下前已选中的锁定单选:按下穿透(批次 67;app fabricCanvas 3573 的
|
|
1191
|
-
// defer 语义——纯点击保留选中,拖动起框选穿透锁定对象)。首击选中的
|
|
1192
|
-
// 锁定对象不穿透(fabric mousedown 判旧 activeObject,首击拖动只是
|
|
1193
|
-
// 短路无位移);多选含锁定成员走下方快照过滤
|
|
1194
|
-
if (isUserLockedNode(target) && wasSelected && doc.selection.length === 1 && doc.selection[0] === target) {
|
|
1195
|
-
this.gesture = { type: 'marquee', anchor: p, additive: shift, hold: true };
|
|
1196
|
-
}
|
|
1197
|
-
else {
|
|
1198
|
-
// 组内移动(批次 311 三补):**组内编辑会话**(groupEditing——双击
|
|
1199
|
-
// 开启)下命中组内子(2.5 刚刷新 doc.activeGroupChild)——拖动只移
|
|
1200
|
-
// 该子(场景位移换算组本地,抬手 fit 重摆组壳);未开会话(单击下钻
|
|
1201
|
-
// 仅选中)拖=整组移动。拼图顶组不进(批次 304 拖格=整组的布局锁定
|
|
1202
|
-
// 语义);表格顶组 2.5 不下钻天然不进;多选(shift)不进。
|
|
1203
|
-
const activeChild = doc.activeGroupChild;
|
|
1204
|
-
const chain = groupEditingLive &&
|
|
1205
|
-
activeChild &&
|
|
1206
|
-
target instanceof GroupNode &&
|
|
1207
|
-
!(target instanceof TableNode) &&
|
|
1208
|
-
!(target instanceof PuzzleNode) &&
|
|
1209
|
-
doc.selection.length === 1 &&
|
|
1210
|
-
doc.selection[0] === target
|
|
1211
|
-
? ancestorChainTo(target, activeChild)
|
|
1212
|
-
: [];
|
|
1213
|
-
const childMove = chain.length && activeChild ? { child: activeChild, toLocal: childSceneDeltaMapper(activeChild), shells: chain } : null;
|
|
1214
|
-
if (childMove) {
|
|
1215
|
-
// 批次 346 勘正:会话内锁定子照常入快照——PSD 解析对组内每个子写
|
|
1216
|
-
// 全套锁(handlePSD parseGroup setLock,94a415f66 fabric 时代「组合
|
|
1217
|
-
// 内元素不能移动」),旧「锁定子空快照=空转」(批次 67/69 同语义)
|
|
1218
|
-
// 与该事实相乘=PSD 组内子全会话不可移动(用户报障)。会话唯一入口
|
|
1219
|
-
// =应用层「组内移动」按钮(五补用户拍板)=显式编辑意图,锁键不自
|
|
1220
|
-
// 此否决;会话外的锁语义不变(P5-1 整组移动与子锁键本就无交集)
|
|
1221
|
-
const snapshot = new Map();
|
|
1222
|
-
snapshot.set(childMove.child, { left: childMove.child.raw.left ?? 0, top: childMove.child.raw.top ?? 0 });
|
|
1223
|
-
// 历史面 = 子 + fit 将触碰的全部节点(组壳与其直接子——重摆写它们)
|
|
1224
|
-
const commitNodes = [childMove.child, ...childMove.shells, ...childMove.shells.flatMap((g) => g.children)];
|
|
1225
|
-
this.gesture = {
|
|
1226
|
-
type: 'move',
|
|
1227
|
-
start: p,
|
|
1228
|
-
startCss: { x: cssX, y: cssY },
|
|
1229
|
-
snapshot,
|
|
1230
|
-
childMove,
|
|
1231
|
-
historyBefore: captureHistoryBefore(commitNodes)
|
|
1232
|
-
};
|
|
1233
|
-
}
|
|
1234
|
-
else {
|
|
1235
|
-
const snapshot = new Map();
|
|
1236
|
-
// 锁定成员不随拖动(批次 67):fabric lockMovementX/Y 在 _transformObject
|
|
1237
|
-
// 逐成员短路;全锁成员 → 空快照 = move 手势空转(up 无提交)
|
|
1238
|
-
for (const n of doc.selection) {
|
|
1239
|
-
if (isUserLockedNode(n))
|
|
1240
|
-
continue;
|
|
1241
|
-
snapshot.set(n, { left: n.raw.left ?? 0, top: n.raw.top ?? 0 });
|
|
1242
|
-
}
|
|
1243
|
-
// 多选整体移动时虚拟框随成员平移(姿态角保留)
|
|
1244
|
-
this.gesture = {
|
|
1245
|
-
type: 'move',
|
|
1246
|
-
start: p,
|
|
1247
|
-
startCss: { x: cssX, y: cssY },
|
|
1248
|
-
snapshot,
|
|
1249
|
-
frame0: doc.selection.length > 1 ? (doc.selectionFrame ? { ...doc.selectionFrame } : undefined) : undefined,
|
|
1250
|
-
historyBefore: captureHistoryBefore(doc.selection)
|
|
1251
|
-
};
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
|
-
this.host.requestRenderAll();
|
|
1256
|
-
return;
|
|
1257
|
-
}
|
|
1258
|
-
// 3) 空白:开始框选(shift 追加保留现选区)
|
|
1259
|
-
this.gesture = { type: 'marquee', anchor: p, additive: shift };
|
|
1260
|
-
if (!shift)
|
|
1261
|
-
doc.clearSelection();
|
|
1262
|
-
this.host.requestRenderAll();
|
|
1263
|
-
}
|
|
1264
|
-
onPointerMove(cssX, cssY) {
|
|
1265
|
-
const doc = this.host.document;
|
|
1266
|
-
const p = this.host.toScene(cssX, cssY);
|
|
1267
|
-
const g = this.gesture;
|
|
1268
|
-
if (g.type === 'none') {
|
|
1269
|
-
// 空闲态更新光标提示 + 悬停边框(P5-3)。多页路由(批次 409 D-3):
|
|
1270
|
-
// hover 逐点路由到指针所在页(不激活——切页只在 down),页内坐标喂
|
|
1271
|
-
// 命中/边框;gap = 清悬停默认光标。单页态回退原行为
|
|
1272
|
-
if (this.host.resolvePointerTarget) {
|
|
1273
|
-
const abs = this.host.toSceneAbs ? this.host.toSceneAbs(cssX, cssY) : this.host.toScene(cssX, cssY);
|
|
1274
|
-
const entry = this.host.resolvePointerTarget(abs.x, abs.y);
|
|
1275
|
-
if (!entry) {
|
|
1276
|
-
if (this.lastHoverDoc) {
|
|
1277
|
-
this.lastHoverDoc.setHovered(null);
|
|
1278
|
-
this.lastHoverDoc = null;
|
|
1279
|
-
this.host.requestRenderAll();
|
|
1280
|
-
}
|
|
1281
|
-
this.el.style.cursor = 'default';
|
|
1282
|
-
return;
|
|
1283
|
-
}
|
|
1284
|
-
this.el.style.cursor = this.hoverCursor(cssX, cssY, entry.local, entry.doc);
|
|
1285
|
-
this.updateHover(cssX, cssY, entry.local, entry.doc);
|
|
1286
|
-
return;
|
|
1287
|
-
}
|
|
1288
|
-
this.el.style.cursor = this.hoverCursor(cssX, cssY, p);
|
|
1289
|
-
this.updateHover(cssX, cssY, p);
|
|
1290
|
-
return;
|
|
1291
|
-
}
|
|
1292
|
-
if (g.type === 'move') {
|
|
1293
|
-
// 空快照 = 手势空转(批次 69):全锁选区拖动(首击锁定/表格单元格路径)
|
|
1294
|
-
// 不置 performed(up 无提交)、不动虚拟框——成员没动框不能单独平移;
|
|
1295
|
-
// moving 由 applyTransform 空目标早退兜底不发
|
|
1296
|
-
if (g.snapshot.size) {
|
|
1297
|
-
// 拖动启动阈值(批次 79):点选的指针抖动不位移、不置 performed——
|
|
1298
|
-
// 真实点击自带 1~4 屏幕 px 抖动,低缩放档被 1/zoom 放大成可见场景位移
|
|
1299
|
-
// 且 up 落一条伪 drag 历史条目;超阈值后按手势全程位移连续应用(含
|
|
1300
|
-
// 阈值内行程,抓取偏移保持——与按住即拖的旧手感无缝衔接)。performed
|
|
1301
|
-
// 即 armed 态(手势周期内仅本分支置位):点亮后指针回摆到阈值内也
|
|
1302
|
-
// 恒跟随,不冻结
|
|
1303
|
-
if (!this.performed && Math.hypot(cssX - g.startCss.x, cssY - g.startCss.y) <= DRAG_START_THRESHOLD)
|
|
1304
|
-
return;
|
|
1305
|
-
this.performed = true;
|
|
1306
|
-
const dx = p.x - g.start.x;
|
|
1307
|
-
const dy = p.y - g.start.y;
|
|
1308
|
-
if (g.childMove) {
|
|
1309
|
-
// 组内移动(批次 311):场景位移经 toLocal 换算组本地(逆祖先链线性)
|
|
1310
|
-
// 写子 left/top;无 frame0(单子不维护虚拟框)
|
|
1311
|
-
const d = g.childMove.toLocal(dx, dy);
|
|
1312
|
-
doc.applyTransform([...g.snapshot.keys()], (target) => {
|
|
1313
|
-
const s = g.snapshot.get(target);
|
|
1314
|
-
return { left: s.left + d.x, top: s.top + d.y };
|
|
1315
|
-
}, 'moving');
|
|
1316
|
-
}
|
|
1317
|
-
else {
|
|
1318
|
-
doc.applyTransform([...g.snapshot.keys()], (target) => {
|
|
1319
|
-
const s = g.snapshot.get(target);
|
|
1320
|
-
return { left: s.left + dx, top: s.top + dy };
|
|
1321
|
-
}, 'moving');
|
|
1322
|
-
// 虚拟框随整体移动平移(从手势起始快照累计,避免逐帧叠加)
|
|
1323
|
-
if (g.frame0)
|
|
1324
|
-
doc.setSelectionFrame({ ...g.frame0, center: { x: g.frame0.center.x + dx, y: g.frame0.center.y + dy } });
|
|
1325
|
-
}
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
else if (g.type === 'reference-line') {
|
|
1329
|
-
// 参考线拖拽(批次 72):首 move 显线(fabric mouseMove set visible 同序),
|
|
1330
|
-
// 轴锁定逐帧落位——横线只写 top / 竖线只写 left(零厚度线 top/left 即线位,
|
|
1331
|
-
// 与 origin 取法无关);moving 照发(吸附订阅 registerMove 照常、辅助线
|
|
1332
|
-
// 由 snapGuide activeType='ReferenceLine' 抑制——既有口径);标尺数值
|
|
1333
|
-
// 气泡状态写宿主(ruler overlay 消费,up 清)
|
|
1334
|
-
this.performed = true;
|
|
1335
|
-
const horizontal = g.axis === 'horizontal';
|
|
1336
|
-
doc.applyTransform([g.node], () => ({ visible: true, ...(horizontal ? { top: p.y } : { left: p.x }) }), 'moving');
|
|
1337
|
-
if (this.host.referenceLineDrag !== undefined) {
|
|
1338
|
-
this.host.referenceLineDrag = { axis: g.axis, position: horizontal ? p.y : p.x };
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
else if (g.type === 'scale') {
|
|
1342
|
-
this.performed = true;
|
|
1343
|
-
applyScale(doc, g.snapshot, p, g.freeScale);
|
|
1344
|
-
doc.applyTransform([g.snapshot.node], () => ({}), 'scaling');
|
|
1345
|
-
// P5-2 缩放辅助线:纯 fabric 缩放手势才画(main objectScaling 挂在 fabric
|
|
1346
|
-
// transform 上);字号/盒宽/盒高烘焙是应用自定义控制点,不触发 object:scaling
|
|
1347
|
-
//(组改宽再分配批次 104 同族——fabric 组合本无 ml/mr,无辅助线参照)
|
|
1348
|
-
if (!g.snapshot.bakeFont && !g.snapshot.bakeWidth && !g.snapshot.bakeHeight && !g.snapshot.bakeGroup)
|
|
1349
|
-
this.host.registerScalingSnap?.(g.snapshot.node, g.handle);
|
|
1350
|
-
}
|
|
1351
|
-
else if (g.type === 'cornerRadius') {
|
|
1352
|
-
// 圆角拖拽(批次 100 矩形/批次 101 图片):rect 模型经 set 归一链路写视觉
|
|
1353
|
-
// radius(反算 rx/ry);image 模型直接写本地 rx=ry(含 perPixelTargetFind
|
|
1354
|
-
// 联动)。phase 逐帧 fire object:cornerRadius(矩形面板跟随用;图片侧
|
|
1355
|
-
// fabric 不 fire——引擎统一通道多发一个无消费者事件,无害)
|
|
1356
|
-
if (g.model === 'image') {
|
|
1357
|
-
const props = imageRadiusPropsFromPointer(g.node, g.corner, p);
|
|
1358
|
-
if (props) {
|
|
1359
|
-
this.performed = true;
|
|
1360
|
-
doc.applyTransform([g.node], () => props, 'cornerRadius');
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
else {
|
|
1364
|
-
const next = radiusFromPointer(g.node, g.corner, p);
|
|
1365
|
-
if (next !== null) {
|
|
1366
|
-
this.performed = true;
|
|
1367
|
-
doc.applyTransform([g.node], () => ({ radius: next }), 'cornerRadius');
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1371
|
-
else if (g.type === 'multi-scale') {
|
|
1372
|
-
// 空成员 = 手势空转(批次 69):全锁多选拖合并框手柄——不置 performed
|
|
1373
|
-
//(up 无提交)、不画缩放辅助线(手势无实效,画线是视觉撒谎)
|
|
1374
|
-
if (g.snapshot.members.length) {
|
|
1375
|
-
this.performed = true;
|
|
1376
|
-
applyMultiScale(doc, g.snapshot, p, g.freeScale);
|
|
1377
|
-
this.host.registerScalingSnap?.(doc.selection[0], g.snapshot.handle);
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
else if (g.type === 'rotate') {
|
|
1381
|
-
this.performed = true;
|
|
1382
|
-
const a = Math.atan2(p.y - g.center.y, p.x - g.center.x);
|
|
1383
|
-
let angle = g.snapshot.angle0 + deg(a - g.startAngle);
|
|
1384
|
-
angle = ((angle % 360) + 360) % 360;
|
|
1385
|
-
// 枢轴固定为手势起始中心(=元素中心,fabric centeredRotation / wrapWithFixedAnchor 语义):
|
|
1386
|
-
// 只写 angle 时实际枢轴由 origin 决定——origin 非 center/center 的节点会绕 left/top 转、
|
|
1387
|
-
// 中心被带走,手柄跟不住指针。rotateAroundCenter 按新 angle 反解 left/top 把中心钉住。
|
|
1388
|
-
// 组内子(批次 311 二补):g.center 是世界系(指针数学),rotateAroundCenter
|
|
1389
|
-
// 的枢轴是 left/top 同系(组本地)——pivotLocal 承载,缺省=center(顶层同系)
|
|
1390
|
-
const pivot = g.childTransform?.pivotLocal ?? g.center;
|
|
1391
|
-
doc.applyTransform([g.snapshot.node], (n) => n.rotateAroundCenter(angle, pivot), 'rotating');
|
|
1392
|
-
// 光标逐帧随手势角度转动(app actionHandler 每 move setCursor 同构;
|
|
1393
|
-
// 方位角 mtr=225、四角隐形旋转区=0/90/180/270——批次 88 cursorOffset)
|
|
1394
|
-
this.el.style.cursor = rotateCursorIcon((g.snapshot.node.raw.angle ?? 0) + (g.cursorOffset ?? 225));
|
|
1395
|
-
}
|
|
1396
|
-
else if (g.type === 'multi-rotate') {
|
|
1397
|
-
// 空成员 = 手势空转(批次 69):applyMultiRotate 无条件重设虚拟框姿态——
|
|
1398
|
-
// 全锁多选拖 mtr 时框不能单独转
|
|
1399
|
-
if (g.snapshot.members.length) {
|
|
1400
|
-
this.performed = true;
|
|
1401
|
-
applyMultiRotate(doc, g, p);
|
|
1402
|
-
this.el.style.cursor = rotateCursorIcon((doc.selectionFrame?.angle ?? 0) + 225);
|
|
1403
|
-
}
|
|
1404
|
-
}
|
|
1405
|
-
else if (g.type === 'marquee') {
|
|
1406
|
-
// hold(锁定穿透,批次 67):未超点击阈值不动选区——纯点击保留原选中
|
|
1407
|
-
//(app defer 语义),超阈值才起框选(穿透锁定对象)
|
|
1408
|
-
if (g.hold && Math.hypot(p.x - g.anchor.x, p.y - g.anchor.y) <= CLICK_THRESHOLD)
|
|
1409
|
-
return;
|
|
1410
|
-
this.host.marquee = { left: g.anchor.x, top: g.anchor.y, right: p.x, bottom: p.y };
|
|
1411
|
-
// 锁定元素不进多选(批次 67 二补):框选命中与 additive 合并统一过滤——
|
|
1412
|
-
// 与 shift 加选同一口径(app mixin AS.add/multiSelectAdd 锁过滤;fabric 原生
|
|
1413
|
-
// 框选 groupInit 直装 _objects 绕过 mixin 不过滤,属应用口径有意加强——
|
|
1414
|
-
// 单选锁定仍可选中显示锁 UI,框住纯锁定 → 选区清空)
|
|
1415
|
-
const hits = doc.objectsIntersectingRect(g.anchor.x, g.anchor.y, p.x, p.y).filter((n) => !isUserLockedNode(n));
|
|
1416
|
-
const next = (g.additive ? [...new Set([...doc.selection, ...hits])] : hits).filter((n) => !isUserLockedNode(n));
|
|
1417
|
-
doc.setSelection(next, 'update');
|
|
1418
|
-
}
|
|
1419
|
-
else if (g.type === 'text-select') {
|
|
1420
|
-
const node = doc.editingNode;
|
|
1421
|
-
if (node) {
|
|
1422
|
-
const local = node.localPoint(p.x, p.y);
|
|
1423
|
-
const idx = node.cursorIndexAt(local.x, local.y);
|
|
1424
|
-
this.host.setEditingSelection(Math.min(g.anchorIdx, idx), Math.max(g.anchorIdx, idx));
|
|
1425
|
-
}
|
|
1426
|
-
}
|
|
1427
|
-
else if (g.type === 'table-border-drag') {
|
|
1428
|
-
this.performed = true;
|
|
1429
|
-
applyTableBorderDrag(g, p);
|
|
1430
|
-
}
|
|
1431
|
-
else if (g.type === 'table-edge-resize') {
|
|
1432
|
-
this.performed = true;
|
|
1433
|
-
applyTableEdgeResize(doc, g, p);
|
|
1434
|
-
}
|
|
1435
|
-
else if (g.type === 'puzzle-edge-resize') {
|
|
1436
|
-
this.performed = true;
|
|
1437
|
-
applyPuzzleEdgeResize(doc, g, p);
|
|
1438
|
-
}
|
|
1439
|
-
else if (g.type === 'puzzle-mask-edge-resize') {
|
|
1440
|
-
this.performed = true;
|
|
1441
|
-
applyPuzzleMaskEdgeResize(g, p);
|
|
1442
|
-
}
|
|
1443
|
-
else if (g.type === 'crop-handle') {
|
|
1444
|
-
// B2 裁剪手柄逐帧(拒绝帧不写——应用 return false 同语义);
|
|
1445
|
-
// 不发 moving/scaling(应用裁剪写直改 + 历史层跳过 crop 动作)
|
|
1446
|
-
this.performed = true;
|
|
1447
|
-
this.host.cropSession?.applyHandle(g.handle, p);
|
|
1448
|
-
}
|
|
1449
|
-
else if (g.type === 'expand-handle') {
|
|
1450
|
-
this.performed = true;
|
|
1451
|
-
this.host.expandSession?.applyHandle(g.handle, p);
|
|
1452
|
-
}
|
|
1453
|
-
else if (g.type === 'expand-image-drag') {
|
|
1454
|
-
// 扩图框内拖图:增量进图片中心(钳制在会话层 applyExpandClamp 数学),
|
|
1455
|
-
// 帧位置/扩图框冻结——与 crop-move(增量进 cropX/cropY)同构
|
|
1456
|
-
this.performed = true;
|
|
1457
|
-
this.host.expandSession?.moveImageBy({ x: p.x - g.last.x, y: p.y - g.last.y });
|
|
1458
|
-
g.last = p;
|
|
1459
|
-
}
|
|
1460
|
-
else if (g.type === 'crop-move') {
|
|
1461
|
-
// B2 框内拖图:增量进 cropX/cropY(钳制在纯函数层),帧位置冻结
|
|
1462
|
-
this.performed = true;
|
|
1463
|
-
this.host.cropSession?.moveImageBy({ x: p.x - g.last.x, y: p.y - g.last.y });
|
|
1464
|
-
g.last = p;
|
|
1465
|
-
}
|
|
1466
|
-
else if (g.type === 'path-anchor-drag') {
|
|
1467
|
-
// P4-7 锚点/手柄拖拽:逐帧绝对落点(幂等);left/top 补偿在会话内
|
|
1468
|
-
this.performed = true;
|
|
1469
|
-
this.host.pathSession?.applyAnchorDrag(g.key, p);
|
|
1470
|
-
}
|
|
1471
|
-
else if (g.type === 'path-body-drag') {
|
|
1472
|
-
// P4-7 编辑态拖本体 = 移动对象(增量,同 crop-move 形态)
|
|
1473
|
-
this.performed = true;
|
|
1474
|
-
this.host.pathSession?.moveBodyBy({ x: p.x - g.last.x, y: p.y - g.last.y });
|
|
1475
|
-
g.last = p;
|
|
1476
|
-
}
|
|
1477
|
-
else if (g.type === 'warp-anchor-drag') {
|
|
1478
|
-
// 批次 66 扭曲锚点拖拽:逐帧绝对落点(源像素系换算在会话内,幂等)
|
|
1479
|
-
this.performed = true;
|
|
1480
|
-
this.host.warpSession?.applyAnchorDrag(g.anchor, p);
|
|
1481
|
-
}
|
|
1482
|
-
else if (g.type === 'table-range-drag') {
|
|
1483
|
-
// 拖扩展柄:以选区左上角为锚构建矩形(同 shift 拖拽数学);指针出表/落
|
|
1484
|
-
// spacing 缝(cellHit null)保持现选区。performed 不置位——纯选区变化
|
|
1485
|
-
// 无 object:modified(应用同口径)
|
|
1486
|
-
const cur = g.node.cellHit(p.x, p.y);
|
|
1487
|
-
if (cur) {
|
|
1488
|
-
const cells = buildSelectionRange(g.node.cellMap, g.anchor, cur);
|
|
1489
|
-
g.node.setCellSelection(cells, g.anchor, selectionBounds(cells));
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
else if (g.type === 'table-cell-click') {
|
|
1493
|
-
if (g.shift) {
|
|
1494
|
-
// shift 按住:拖拽扩展单元格选区(锚点→当前格的矩形),表格不移动
|
|
1495
|
-
const cur = g.node.cellHit(p.x, p.y);
|
|
1496
|
-
const anchor = g.node.cellAnchor ?? g.anchorCell;
|
|
1497
|
-
if (cur && anchor) {
|
|
1498
|
-
const cells = buildSelectionRange(g.node.cellMap, anchor, cur);
|
|
1499
|
-
g.node.setCellSelection(cells, anchor, selectionBounds(cells));
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1502
|
-
else if (Math.hypot(p.x - g.start.x, p.y - g.start.y) > CLICK_THRESHOLD) {
|
|
1503
|
-
// 超过点击阈值:让位整表移动——快照复用按下时捕获(多选含表时同组整体移动);
|
|
1504
|
-
// startCss 在转换点重定基(转换已证明拖动意图,不再二次计费阈值内行程);
|
|
1505
|
-
// 拖动意图明确,多选成员点击的 defer 切换作废(up 走整组拖动提交不换选)
|
|
1506
|
-
this.deferredClickSwitch = null;
|
|
1507
|
-
this.gesture = { type: 'move', start: g.start, startCss: { x: cssX, y: cssY }, snapshot: g.moveSnapshot, frame0: g.frame0, historyBefore: g.historyBefore };
|
|
1508
|
-
return this.onPointerMove(cssX, cssY);
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1511
|
-
// table-indicator-click:无移动期行为(up 才插入)
|
|
1512
|
-
this.host.requestRenderAll();
|
|
1513
|
-
}
|
|
1514
|
-
onPointerUp(cssX, cssY) {
|
|
1515
|
-
const doc = this.host.document;
|
|
1516
|
-
const g = this.gesture;
|
|
1517
|
-
this.gesture = { type: 'none' };
|
|
1518
|
-
this.host.marquee = null;
|
|
1519
|
-
// 旋转手势覆盖态清位(任意手势统一):mtr 回落常规布局、角度气泡消失
|
|
1520
|
-
if (this.host.rotateDrag !== undefined)
|
|
1521
|
-
this.host.rotateDrag = null;
|
|
1522
|
-
if (g.type === 'none')
|
|
1523
|
-
return;
|
|
1524
|
-
// P5-2 吸附收尾(main handleMouseUp 同序,任意手势统一):先结算登记中的
|
|
1525
|
-
// 移动吸附——快拖松手若本帧尚未渲染,最终落点(含下方 object:modified 的
|
|
1526
|
-
// 历史快照)也必须是吸附后的值;再清辅助线与手势缓存
|
|
1527
|
-
this.host.settleMoveSnap?.();
|
|
1528
|
-
this.host.finishSnapGesture?.();
|
|
1529
|
-
if (g.type === 'move') {
|
|
1530
|
-
// 纯点击(无 move)不提交:fabric _finalizeCurrentTransform 只在
|
|
1531
|
-
// actionPerformed 时 fire object:modified,点选不该产生历史条目
|
|
1532
|
-
if (this.performed) {
|
|
1533
|
-
if (g.childMove) {
|
|
1534
|
-
// 组内移动收尾(批次 311):先 fit-content 重摆组壳(组+直接子 raw
|
|
1535
|
-
// 直写,视觉不变),连同激活子一并提交——历史 before 在装配时已覆盖
|
|
1536
|
-
// 全部将被触碰的节点
|
|
1537
|
-
const touched = refitGroupShells(g.childMove.shells);
|
|
1538
|
-
const targets = [...new Set([g.childMove.child, ...touched])];
|
|
1539
|
-
doc.applyTransform(targets, () => ({}), 'modified', { action: CompatHistoryActions.drag, before: g.historyBefore });
|
|
1540
|
-
}
|
|
1541
|
-
else {
|
|
1542
|
-
const nodes = [...g.snapshot.keys()];
|
|
1543
|
-
if (!this.host.transferDraggedNodes?.(nodes, g.historyBefore, cssX, cssY)) {
|
|
1544
|
-
doc.applyTransform(nodes, () => ({}), 'modified', { action: CompatHistoryActions.drag, before: g.historyBefore });
|
|
1545
|
-
}
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
else if (this.deferredClickSwitch) {
|
|
1549
|
-
// 多选成员纯点击:当前活动对象切换为被点成员(选区生命周期副作用随
|
|
1550
|
-
// setSelection 内建——虚拟框清理/selection:created 桥应用面板,无历史
|
|
1551
|
-
// 条目=纯选区变化同语义)。防御:手势期间选区被外部改写(回放/并行
|
|
1552
|
-
// 操作)则放弃切换,宁可不动不乱切
|
|
1553
|
-
const t = this.deferredClickSwitch;
|
|
1554
|
-
if (doc.selection.length > 1 && doc.selection.includes(t))
|
|
1555
|
-
doc.setSelection([t], 'create');
|
|
1556
|
-
}
|
|
1557
|
-
}
|
|
1558
|
-
else if (g.type === 'reference-line') {
|
|
1559
|
-
// 参考线收尾(批次 72):拖拽态气泡清位;落回同轴标尺带 = 删除线
|
|
1560
|
-
// (fabric isPointOnRuler→canvas.remove 同口径);建线手势纯点击(无
|
|
1561
|
-
// move)撤销建线(不留 fabric 的 invisible 幽灵线);否则落定——
|
|
1562
|
-
// selectable:false(fabric mouseup 同字段)+ 一条 drag 提交入历史。
|
|
1563
|
-
// 删除路径补发一条 object:modified(fabric ReferenceLine 的 removed 监听
|
|
1564
|
-
// 同发):app 侧 object:removed 只标脏不刷新,内存模板同步收口在
|
|
1565
|
-
// modified 的 commitTemplateMemorySync——缺了它 store 残留已删线
|
|
1566
|
-
if (this.host.referenceLineDrag !== undefined)
|
|
1567
|
-
this.host.referenceLineDrag = null;
|
|
1568
|
-
const band = this.host.rulerVisible ? rulerBandAt(cssX, cssY) : null;
|
|
1569
|
-
if (band === g.axis || (g.creating && !this.performed)) {
|
|
1570
|
-
doc.remove(g.node);
|
|
1571
|
-
doc.fireObjectModified([g.node], { action: CompatHistoryActions.drag, before: g.historyBefore ? [g.historyBefore.get(g.node)].filter((s) => !!s) : undefined });
|
|
1572
|
-
}
|
|
1573
|
-
else if (this.performed) {
|
|
1574
|
-
doc.applyTransform([g.node], () => ({ selectable: false }), 'modified', { action: CompatHistoryActions.drag, before: g.historyBefore });
|
|
1575
|
-
}
|
|
1576
|
-
}
|
|
1577
|
-
else if (g.type === 'scale' || g.type === 'rotate') {
|
|
1578
|
-
if (this.performed) {
|
|
1579
|
-
if (g.childTransform) {
|
|
1580
|
-
// 组内子变换收尾(批次 311 二补):抬手 fit 组壳后随 modified 一并提交
|
|
1581
|
-
//(历史 before 装配时已覆盖子+组壳+全部直接子,同 childMove 口径)
|
|
1582
|
-
const touched = refitGroupShells(g.childTransform.shells);
|
|
1583
|
-
const targets = [...new Set([g.childTransform.child, ...touched])];
|
|
1584
|
-
doc.applyTransform(targets, () => ({}), 'modified', { action: g.type, before: g.historyBefore });
|
|
1585
|
-
}
|
|
1586
|
-
else {
|
|
1587
|
-
doc.applyTransform([g.snapshot.node], () => ({}), 'modified', { action: g.type, before: g.historyBefore });
|
|
1588
|
-
}
|
|
1589
|
-
}
|
|
1590
|
-
}
|
|
1591
|
-
else if (g.type === 'cornerRadius') {
|
|
1592
|
-
// 圆角拖拽收尾(批次 100):action='cornerRadius'(fabric transform 的
|
|
1593
|
-
// actionName 原值),before 快照含旧 radius 供撤销回放
|
|
1594
|
-
if (this.performed)
|
|
1595
|
-
doc.applyTransform([g.node], () => ({}), 'modified', { action: CompatHistoryActions.cornerRadius, before: g.historyBefore });
|
|
1596
|
-
}
|
|
1597
|
-
else if (g.type === 'multi-scale' || g.type === 'multi-rotate') {
|
|
1598
|
-
if (this.performed)
|
|
1599
|
-
doc.applyTransform(g.snapshot.members.map((m) => m.node), () => ({}), 'modified', { action: g.type === 'multi-scale' ? CompatHistoryActions.scale : CompatHistoryActions.rotate, before: g.historyBefore });
|
|
1600
|
-
}
|
|
1601
|
-
else if (g.type === 'marquee') {
|
|
1602
|
-
doc.commitGeometry();
|
|
1603
|
-
}
|
|
1604
|
-
else if (g.type === 'path-anchor-drag' || g.type === 'path-body-drag') {
|
|
1605
|
-
// P4-7 拖拽提交一条 object:modified(fabric transform 收尾同口径;纯点击
|
|
1606
|
-
// 不发——插点/类型切换的提交在操作点已发)
|
|
1607
|
-
if (this.performed)
|
|
1608
|
-
this.host.pathSession?.commit();
|
|
1609
|
-
}
|
|
1610
|
-
else if (g.type === 'warp-anchor-drag') {
|
|
1611
|
-
// 批次 66:拖拽收尾入会话内撤销栈(项目历史在会话退出时整体提交——
|
|
1612
|
-
// fabric enableHistory 同源;纯点击不入栈)
|
|
1613
|
-
if (this.performed)
|
|
1614
|
-
this.host.warpSession?.endDrag();
|
|
1615
|
-
}
|
|
1616
|
-
else if (g.type === 'table-border-drag') {
|
|
1617
|
-
// 应用 mouseup:恢复暂存选区、清边框反馈;拖拽过才重排+提交(纯点击不发历史)
|
|
1618
|
-
g.node.setCellSelection(g.savedCells, g.savedAnchor, g.savedRange);
|
|
1619
|
-
g.node.hoveredBorder = null;
|
|
1620
|
-
g.node.borderDragging = false;
|
|
1621
|
-
if (this.performed) {
|
|
1622
|
-
g.node.rebuildTable();
|
|
1623
|
-
doc.applyTransform([g.node], () => ({}), 'modified', { action: CompatHistoryActions.scale, before: g.historyBefore });
|
|
1624
|
-
}
|
|
1625
|
-
}
|
|
1626
|
-
else if (g.type === 'table-edge-resize') {
|
|
1627
|
-
// 逐帧已烘焙重排并回钉;up 只提交(纯点击不发历史)
|
|
1628
|
-
if (this.performed)
|
|
1629
|
-
doc.applyTransform([g.node], () => ({}), 'modified', { action: CompatHistoryActions.scale, before: g.historyBefore });
|
|
1630
|
-
}
|
|
1631
|
-
else if (g.type === 'puzzle-edge-resize') {
|
|
1632
|
-
// 同 table-edge-resize:逐帧已烘焙并回钉,up 只提交(纯点击不发历史)
|
|
1633
|
-
if (this.performed)
|
|
1634
|
-
doc.applyTransform([g.node], () => ({}), 'modified', { action: CompatHistoryActions.scale, before: g.historyBefore });
|
|
1635
|
-
}
|
|
1636
|
-
else if (g.type === 'puzzle-mask-edge-resize') {
|
|
1637
|
-
// 分割线拖拽逐帧已写回;up 对拼图组提交一条(应用 historyTarget=group 同口径)
|
|
1638
|
-
if (this.performed)
|
|
1639
|
-
doc.applyTransform([g.node], () => ({}), 'modified', { action: CompatHistoryActions.scale, before: g.historyBefore });
|
|
1640
|
-
}
|
|
1641
|
-
else if (g.type === 'table-indicator-click') {
|
|
1642
|
-
// up 时复核指示器命中(fabric 控件 mouseUp 在 up 命中的控件上触发,移开即不插入)
|
|
1643
|
-
const up = this.host.toScene(cssX, cssY);
|
|
1644
|
-
const re = g.node.borderOrIndicatorHit(up.x, up.y, this.host.zoom);
|
|
1645
|
-
if (re?.inCircle)
|
|
1646
|
-
applyIndicatorInsert(doc, g.node, re.border);
|
|
1647
|
-
}
|
|
1648
|
-
else if (g.type === 'table-strip-click') {
|
|
1649
|
-
// up 复核条带命中(同指示器口径——防按下后移开误触);应用 mouseUpHandler
|
|
1650
|
-
// 语义:整行/整列覆盖式选中。纯选区变化不发 object:modified(应用同口径)
|
|
1651
|
-
const up = this.host.toScene(cssX, cssY);
|
|
1652
|
-
const strip = g.node.stripHit(up.x, up.y, this.host.zoom);
|
|
1653
|
-
if (strip?.kind === 'col-strip')
|
|
1654
|
-
g.node.setColumnSelection(strip.col);
|
|
1655
|
-
else if (strip?.kind === 'row-strip')
|
|
1656
|
-
g.node.setRowSelection(strip.row);
|
|
1657
|
-
}
|
|
1658
|
-
else if (g.type === 'table-cell-click') {
|
|
1659
|
-
const up = this.host.toScene(cssX, cssY);
|
|
1660
|
-
if (Math.hypot(up.x - g.start.x, up.y - g.start.y) <= CLICK_THRESHOLD) {
|
|
1661
|
-
// 多选态点表格的纯点击(defer 消费,1.5 down 侧记录):切换单选表格、
|
|
1662
|
-
// 不设单元格选区——格交互从单选态重新开始(shift 分支不 defer,走下方
|
|
1663
|
-
// 扩展选区语义不变)
|
|
1664
|
-
if (this.deferredClickSwitch === g.node) {
|
|
1665
|
-
if (doc.selection.length > 1 && doc.selection.includes(g.node))
|
|
1666
|
-
doc.setSelection([g.node], 'create');
|
|
1667
|
-
}
|
|
1668
|
-
else {
|
|
1669
|
-
const cellPos = g.node.cellHit(up.x, up.y);
|
|
1670
|
-
if (cellPos) {
|
|
1671
|
-
if (g.shift) {
|
|
1672
|
-
const anchor = g.node.cellAnchor ?? g.anchorCell ?? cellPos;
|
|
1673
|
-
const cells = buildSelectionRange(g.node.cellMap, anchor, cellPos);
|
|
1674
|
-
g.node.setCellSelection(cells, anchor, selectionBounds(cells));
|
|
1675
|
-
}
|
|
1676
|
-
else {
|
|
1677
|
-
g.node.setCellSelection([cellPos], cellPos, { r1: cellPos.row, r2: cellPos.row, c1: cellPos.col, c2: cellPos.col });
|
|
1678
|
-
}
|
|
1679
|
-
}
|
|
1680
|
-
// cellPos 为 null(恰点在 spacing 缝里):保持原选区(应用 return 语义)
|
|
1681
|
-
}
|
|
1682
|
-
}
|
|
1683
|
-
// 单元格选区变化不是变换:不发 object:modified(应用同语义,无历史条目)
|
|
1684
|
-
}
|
|
1685
|
-
this.deferredClickSwitch = null;
|
|
1686
|
-
this.host.requestRenderAll();
|
|
1687
|
-
}
|
|
1688
|
-
dispose() {
|
|
1689
|
-
this.detach?.();
|
|
1690
|
-
this.detach = null;
|
|
1691
|
-
}
|
|
1692
|
-
}
|