@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/model/arcLayout.js
DELETED
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 弧形/圆形文本布局(main-webgl2 Phase 4 P4-5b):ArcText/CircleText 逐字
|
|
3
|
-
* 摆位的引擎侧移植(模型层,tableLayout 同层约定)。
|
|
4
|
-
*
|
|
5
|
-
* - ArcText:curvature(度,±)→ radius = max(10000/|c|, 弧长/弧度角),逐字沿
|
|
6
|
-
* 圆弧按字符盒中心张角摆位 + 旋转(正曲率 rotate(−charAngle)、负曲率再 −π);
|
|
7
|
-
* 多行按 globalOffset 行堆叠(正曲率自内向外、负曲率自外向内)
|
|
8
|
-
* - CircleText:circleSize(椭圆长半轴)/eccentricity(ry=rx·(1−e))/startAngle/
|
|
9
|
-
* sweep/direction,多行拍平成一条字符流按全局字宽比例均匀分布;
|
|
10
|
-
* curvature 钉死 1(恒走正曲率消费分支,旋转 = 切向角 φ,horizontal 时 φ=0)
|
|
11
|
-
* - 尺寸口径:bbox 取逐行 sector 包围盒(ArcText,含首/末哨兵张角端点与圆弧
|
|
12
|
-
* 极值点)或全部字符四角(CircleText);width/height/contentOffset 照
|
|
13
|
-
* ArcText:888-899 溢出公式——渲染侧 quad = width×height 居中于对象中心,
|
|
14
|
-
* 内容按 (−contentOffsetX, −contentOffsetY) 平移(fabric _render 同构)
|
|
15
|
-
*
|
|
16
|
-
* 度量复用引擎 TextLayout(fabric IText 同构:行宽 = Σ kernedWidth、行高 =
|
|
17
|
-
* maxFontSize×1.13×lineHeight、字符盒 left 累计含 kerning)。行数组带**哨兵**
|
|
18
|
-
* 条目(left = 末盒右缘、width 0)——fabric __charBounds 每行比字符多一条,
|
|
19
|
-
* ArcText 的 sector bbox 以行末哨兵为端点、CircleText 的 bbox 含哨兵四角,
|
|
20
|
-
* 不补会系统性缺一段弧。
|
|
21
|
-
*
|
|
22
|
-
* 已知缺口(种子约定规避,同 warp/table 惯例):charSpacing(应用侧 bounds 与
|
|
23
|
-
* charSpacingOffset 双重计入,须逐式复刻后另行对拍)、deltaY 上下标、逐字
|
|
24
|
-
* styles 的 deltaY、justify(enArcLargeSpaces 与 Textbox enlargeSpaces 语义
|
|
25
|
-
* 分叉)、PSD effects/阴影(应用侧走 charTransformations 的逐字效果,引擎
|
|
26
|
-
* 分派在效果层之前返回)。
|
|
27
|
-
*/
|
|
28
|
-
import { FONT_SIZE_FRACTION } from './textLayout';
|
|
29
|
-
import { ElementTypes, typeKeyOf } from './elementTypes';
|
|
30
|
-
/** fabric Text 常量同源(ArcText BaseRadius / MIN_TEXT_WIDTH) */
|
|
31
|
-
const BASE_RADIUS = 10000;
|
|
32
|
-
const MIN_TEXT_WIDTH = 2;
|
|
33
|
-
/** utils/geometry AngularDiffSigned 的纯移植(引擎不反向依赖应用工具层) */
|
|
34
|
-
const angularDiffSigned = (theta1, theta2) => {
|
|
35
|
-
let dif = theta2 - theta1;
|
|
36
|
-
while (dif >= 2 * Math.PI)
|
|
37
|
-
dif -= 2 * Math.PI;
|
|
38
|
-
while (dif <= 0)
|
|
39
|
-
dif += 2 * Math.PI;
|
|
40
|
-
return dif;
|
|
41
|
-
};
|
|
42
|
-
const anglesInClockwiseSequence = (x, y, z) => angularDiffSigned(x, y) + angularDiffSigned(y, z) < 2 * Math.PI;
|
|
43
|
-
/** utils/geometry sectorBoundingBox 纯移植:E→F 弧段(半径 radius,圆心 C)的
|
|
44
|
-
* 包围盒——两端点 + 圆弧四向极值(顺时针跨越判定) */
|
|
45
|
-
const sectorBoundingBox = (E, F, C, radius) => {
|
|
46
|
-
let x1 = E.x;
|
|
47
|
-
let y1 = E.y;
|
|
48
|
-
let x2 = x1;
|
|
49
|
-
let y2 = y1;
|
|
50
|
-
if (F.x < x1)
|
|
51
|
-
x1 = F.x;
|
|
52
|
-
if (F.x > x2)
|
|
53
|
-
x2 = F.x;
|
|
54
|
-
if (F.y < y1)
|
|
55
|
-
y1 = F.y;
|
|
56
|
-
if (F.y > y2)
|
|
57
|
-
y2 = F.y;
|
|
58
|
-
const thetaE = Math.atan2(E.y - C.y, E.x - C.x);
|
|
59
|
-
const thetaF = Math.atan2(F.y - C.y, F.x - C.x);
|
|
60
|
-
if (anglesInClockwiseSequence(thetaE, 0, thetaF)) {
|
|
61
|
-
const x = C.x + radius;
|
|
62
|
-
if (x > x2)
|
|
63
|
-
x2 = x;
|
|
64
|
-
}
|
|
65
|
-
if (anglesInClockwiseSequence(thetaE, Math.PI / 2, thetaF)) {
|
|
66
|
-
const y = C.y + radius;
|
|
67
|
-
if (y > y2)
|
|
68
|
-
y2 = y;
|
|
69
|
-
}
|
|
70
|
-
if (anglesInClockwiseSequence(thetaE, Math.PI, thetaF)) {
|
|
71
|
-
const x = C.x - radius;
|
|
72
|
-
if (x < x1)
|
|
73
|
-
x1 = x;
|
|
74
|
-
}
|
|
75
|
-
if (anglesInClockwiseSequence(thetaE, (Math.PI * 3) / 2, thetaF)) {
|
|
76
|
-
const y = C.y - radius;
|
|
77
|
-
if (y < y1)
|
|
78
|
-
y1 = y;
|
|
79
|
-
}
|
|
80
|
-
return { x: x1, y: y1, width: x2 - x1, height: y2 - y1 };
|
|
81
|
-
};
|
|
82
|
-
/** ArcText 类型判定(curvature 任意值都走摆位机——0° 也经 radius=1e5 的近直渲染) */
|
|
83
|
-
export const arcTextKind = (raw) => {
|
|
84
|
-
if (typeKeyOf(raw) === ElementTypes.ARCTEXT)
|
|
85
|
-
return 'arc';
|
|
86
|
-
if (typeKeyOf(raw) === ElementTypes.CIRCLETEXT)
|
|
87
|
-
return 'circle';
|
|
88
|
-
return null;
|
|
89
|
-
};
|
|
90
|
-
/** 布局的每行字符盒 + 哨兵(fabric __charBounds 同构) */
|
|
91
|
-
const rowsWithSentinel = (layout) => layout.lines.map((l) => {
|
|
92
|
-
const boxes = l.boxes.map((b) => ({ left: b.left, width: b.width }));
|
|
93
|
-
const last = boxes[boxes.length - 1];
|
|
94
|
-
boxes.push(last ? { left: last.left + last.width, width: 0 } : { left: 0, width: 0 });
|
|
95
|
-
return boxes;
|
|
96
|
-
});
|
|
97
|
-
/** ArcText.initDimensions 内核(正/负曲率两分支逐式) */
|
|
98
|
-
const computeArcPlacements = (layout, lineHeight, curvature) => {
|
|
99
|
-
const rows = rowsWithSentinel(layout);
|
|
100
|
-
const textWidth = layout.width;
|
|
101
|
-
const heightOfLine = (i) => layout.lines[i].implHeight * lineHeight;
|
|
102
|
-
let textHeight = 0;
|
|
103
|
-
for (let i = 0; i < layout.lines.length; i++)
|
|
104
|
-
textHeight += heightOfLine(i);
|
|
105
|
-
const absCurvature = Math.abs(curvature);
|
|
106
|
-
const arcRadian = (absCurvature * Math.PI) / 180;
|
|
107
|
-
let arcLength = 0;
|
|
108
|
-
for (let i = 0; i < layout.lines.length; i++)
|
|
109
|
-
arcLength += layout.lines[i].width;
|
|
110
|
-
const minRadius = arcRadian > 0 ? arcLength / arcRadian : 0;
|
|
111
|
-
const radius = Math.max(BASE_RADIUS / Math.max(absCurvature, 0.1), minRadius);
|
|
112
|
-
const cx = 0;
|
|
113
|
-
const cy = curvature > 0 ? textHeight / 2 + radius : -textHeight / 2 + radius;
|
|
114
|
-
let globalOffset = curvature > 0 ? textHeight : 0;
|
|
115
|
-
let xMin = Infinity;
|
|
116
|
-
let xMax = -Infinity;
|
|
117
|
-
let yMin = Infinity;
|
|
118
|
-
let yMax = -Infinity;
|
|
119
|
-
const chars = [];
|
|
120
|
-
for (let i = 0; i < rows.length; i++) {
|
|
121
|
-
const currentLeft = -textWidth / 2 + layout.lines[i].leftOffset;
|
|
122
|
-
const h = heightOfLine(i);
|
|
123
|
-
const charOffset = h - h / lineHeight + (h * FONT_SIZE_FRACTION) / lineHeight;
|
|
124
|
-
globalOffset += curvature > 0 ? -h : h;
|
|
125
|
-
const rowOffset = Math.abs(radius) + globalOffset;
|
|
126
|
-
// 行内逐条目(含哨兵)的四角——sector bbox 端点(fabric nl/nr 用 lineRadius,
|
|
127
|
-
// 正/负曲率符号逐式:+h−h/lineHeight vs −h+h/lineHeight)
|
|
128
|
-
const lineRadius = curvature > 0 ? rowOffset + h - h / lineHeight : rowOffset - h + h / lineHeight;
|
|
129
|
-
const rowCorners = [];
|
|
130
|
-
for (let j = 0; j < rows[i].length; j++) {
|
|
131
|
-
const b = rows[i][j];
|
|
132
|
-
let bottomRadius, topRadius, charRadius, midRadius;
|
|
133
|
-
let leftAngle, rightAngle, charAngle;
|
|
134
|
-
if (curvature > 0) {
|
|
135
|
-
bottomRadius = rowOffset;
|
|
136
|
-
topRadius = rowOffset + h;
|
|
137
|
-
charRadius = rowOffset + charOffset;
|
|
138
|
-
midRadius = (bottomRadius * 3 + topRadius * 2) / 5;
|
|
139
|
-
leftAngle = -(currentLeft + b.left) / midRadius;
|
|
140
|
-
rightAngle = -(currentLeft + b.left + b.width) / midRadius;
|
|
141
|
-
charAngle = -(currentLeft + b.left + b.width / 2) / midRadius;
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
bottomRadius = rowOffset;
|
|
145
|
-
topRadius = rowOffset - h;
|
|
146
|
-
charRadius = rowOffset - charOffset;
|
|
147
|
-
midRadius = (bottomRadius * 2 + topRadius * 3) / 5;
|
|
148
|
-
leftAngle = Math.PI + (currentLeft + b.left) / midRadius;
|
|
149
|
-
rightAngle = Math.PI + (currentLeft + b.left + b.width) / midRadius;
|
|
150
|
-
charAngle = Math.PI + (currentLeft + b.left + b.width / 2) / midRadius;
|
|
151
|
-
}
|
|
152
|
-
const rsin = Math.sin(rightAngle);
|
|
153
|
-
const rcos = Math.cos(rightAngle);
|
|
154
|
-
const lsin = Math.sin(leftAngle);
|
|
155
|
-
const lcos = Math.cos(leftAngle);
|
|
156
|
-
const csin = Math.sin(charAngle);
|
|
157
|
-
const ccos = Math.cos(charAngle);
|
|
158
|
-
rowCorners.push({
|
|
159
|
-
tl: { x: cx - topRadius * lsin, y: cy - topRadius * lcos },
|
|
160
|
-
tr: { x: cx - topRadius * rsin, y: cy - topRadius * rcos },
|
|
161
|
-
nl: { x: cx - lineRadius * lsin, y: cy - lineRadius * lcos },
|
|
162
|
-
nr: { x: cx - lineRadius * rsin, y: cy - lineRadius * rcos }
|
|
163
|
-
});
|
|
164
|
-
const g = layout.lines[i].graphemes[j];
|
|
165
|
-
if (g !== undefined) {
|
|
166
|
-
chars.push({
|
|
167
|
-
char: g,
|
|
168
|
-
line: i,
|
|
169
|
-
index: j,
|
|
170
|
-
x: cx - charRadius * csin,
|
|
171
|
-
y: cy - charRadius * ccos,
|
|
172
|
-
rotation: curvature > 0 ? -charAngle : -charAngle - Math.PI
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
const cta = rowCorners[0];
|
|
177
|
-
const ctb = rowCorners[rowCorners.length - 1];
|
|
178
|
-
if (!cta || !ctb)
|
|
179
|
-
continue;
|
|
180
|
-
const center = { x: cx, y: cy };
|
|
181
|
-
// fabric ArcText:868-884 的 sector bbox(正负曲率端点/半径符号逐式)
|
|
182
|
-
const bbox = curvature > 0 ? sectorBoundingBox(cta.tl, ctb.tr, center, rowOffset + h) : sectorBoundingBox(ctb.tr, cta.tl, center, rowOffset - h);
|
|
183
|
-
const bbox2 = curvature > 0 ? sectorBoundingBox(cta.nl, ctb.nr, center, rowOffset) : sectorBoundingBox(ctb.nr, cta.nl, center, rowOffset);
|
|
184
|
-
xMin = Math.min(xMin, bbox.x, bbox2.x);
|
|
185
|
-
xMax = Math.max(xMax, bbox.x + bbox.width, bbox2.x + bbox2.width);
|
|
186
|
-
yMin = Math.min(yMin, bbox.y, bbox2.y);
|
|
187
|
-
yMax = Math.max(yMax, bbox.y + bbox.height, bbox2.y + bbox2.height);
|
|
188
|
-
}
|
|
189
|
-
if (!Number.isFinite(xMin)) {
|
|
190
|
-
xMin = xMax = yMin = yMax = 0;
|
|
191
|
-
}
|
|
192
|
-
const leftOverflow = -xMin - textWidth / 2;
|
|
193
|
-
const rightOverflow = xMax - textWidth / 2;
|
|
194
|
-
const topOverflow = -yMin - textHeight / 2;
|
|
195
|
-
const bottomOverflow = yMax - textHeight / 2;
|
|
196
|
-
return {
|
|
197
|
-
width: Math.max(textWidth + leftOverflow + rightOverflow, MIN_TEXT_WIDTH),
|
|
198
|
-
height: textHeight + topOverflow + bottomOverflow,
|
|
199
|
-
contentOffsetX: rightOverflow / 2 - leftOverflow / 2,
|
|
200
|
-
contentOffsetY: bottomOverflow / 2 - topOverflow / 2,
|
|
201
|
-
chars
|
|
202
|
-
};
|
|
203
|
-
};
|
|
204
|
-
/** CircleText.initDimensions 内核(椭圆参数化 + 全局字宽比例均匀分布) */
|
|
205
|
-
const computeCirclePlacements = (layout, lineHeight, params) => {
|
|
206
|
-
const rows = rowsWithSentinel(layout);
|
|
207
|
-
const heightOfLine = (i) => layout.lines[i].implHeight * lineHeight;
|
|
208
|
-
let textHeight = 0;
|
|
209
|
-
for (let i = 0; i < layout.lines.length; i++)
|
|
210
|
-
textHeight += heightOfLine(i);
|
|
211
|
-
const textWidth = layout.width;
|
|
212
|
-
const rx = Math.max(params.size, 1);
|
|
213
|
-
const eccentricity = Math.min(Math.max(params.eccentricity, 0), 0.95);
|
|
214
|
-
const ry = rx * (1 - eccentricity);
|
|
215
|
-
const sweepRad = Math.max(params.sweep, 1) * (Math.PI / 180);
|
|
216
|
-
const startRad = params.startAngle * (Math.PI / 180);
|
|
217
|
-
const horizontal = params.horizontal;
|
|
218
|
-
let totalWidth = 0;
|
|
219
|
-
for (let i = 0; i < layout.lines.length; i++)
|
|
220
|
-
totalWidth += layout.lines[i].width;
|
|
221
|
-
const cx = 0;
|
|
222
|
-
const cy = 0;
|
|
223
|
-
if (totalWidth <= 0 || rows.length === 0) {
|
|
224
|
-
return { width: MIN_TEXT_WIDTH, height: Math.max(textHeight, MIN_TEXT_WIDTH), contentOffsetX: 0, contentOffsetY: 0, chars: [] };
|
|
225
|
-
}
|
|
226
|
-
let xMin = Infinity;
|
|
227
|
-
let xMax = -Infinity;
|
|
228
|
-
let yMin = Infinity;
|
|
229
|
-
let yMax = -Infinity;
|
|
230
|
-
const chars = [];
|
|
231
|
-
let prefix = 0;
|
|
232
|
-
for (let i = 0; i < rows.length; i++) {
|
|
233
|
-
const h = heightOfLine(i);
|
|
234
|
-
const charOffset = h - h / lineHeight + (h * FONT_SIZE_FRACTION) / lineHeight;
|
|
235
|
-
const upFromBaseline = h - charOffset;
|
|
236
|
-
for (let j = 0; j < rows[i].length; j++) {
|
|
237
|
-
const b = rows[i][j];
|
|
238
|
-
const centerOffset = prefix + b.left + b.width / 2;
|
|
239
|
-
const f = centerOffset / totalWidth;
|
|
240
|
-
const theta = startRad - f * sweepRad;
|
|
241
|
-
const sinT = Math.sin(theta);
|
|
242
|
-
const cosT = Math.cos(theta);
|
|
243
|
-
const clx = cx - rx * sinT;
|
|
244
|
-
const cly = cy - ry * cosT;
|
|
245
|
-
let phi;
|
|
246
|
-
let ax, ay, nx, ny;
|
|
247
|
-
if (horizontal) {
|
|
248
|
-
phi = 0;
|
|
249
|
-
ax = 1;
|
|
250
|
-
ay = 0;
|
|
251
|
-
nx = 0;
|
|
252
|
-
ny = -1;
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
const tx = rx * cosT;
|
|
256
|
-
const ty = -ry * sinT;
|
|
257
|
-
const tlen = Math.hypot(tx, ty) || 1;
|
|
258
|
-
ax = tx / tlen;
|
|
259
|
-
ay = ty / tlen;
|
|
260
|
-
const nxv = -ry * sinT;
|
|
261
|
-
const nyv = -rx * cosT;
|
|
262
|
-
const nlen = Math.hypot(nxv, nyv) || 1;
|
|
263
|
-
nx = nxv / nlen;
|
|
264
|
-
ny = nyv / nlen;
|
|
265
|
-
phi = Math.atan2(ty, tx);
|
|
266
|
-
}
|
|
267
|
-
const charAngle = -phi;
|
|
268
|
-
const w2 = b.width / 2;
|
|
269
|
-
xMin = Math.min(xMin, clx - nx * charOffset - ax * w2, clx - nx * charOffset + ax * w2, clx + nx * upFromBaseline - ax * w2, clx + nx * upFromBaseline + ax * w2);
|
|
270
|
-
xMax = Math.max(xMax, clx - nx * charOffset - ax * w2, clx - nx * charOffset + ax * w2, clx + nx * upFromBaseline - ax * w2, clx + nx * upFromBaseline + ax * w2);
|
|
271
|
-
yMin = Math.min(yMin, cly - ny * charOffset - ay * w2, cly - ny * charOffset + ay * w2, cly + ny * upFromBaseline - ay * w2, cly + ny * upFromBaseline + ay * w2);
|
|
272
|
-
yMax = Math.max(yMax, cly - ny * charOffset - ay * w2, cly - ny * charOffset + ay * w2, cly + ny * upFromBaseline - ay * w2, cly + ny * upFromBaseline + ay * w2);
|
|
273
|
-
const g = layout.lines[i].graphemes[j];
|
|
274
|
-
if (g !== undefined) {
|
|
275
|
-
chars.push({ char: g, line: i, index: j, x: clx, y: cly, rotation: -charAngle });
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
prefix += layout.lines[i].width;
|
|
279
|
-
}
|
|
280
|
-
if (!Number.isFinite(xMin)) {
|
|
281
|
-
xMin = xMax = yMin = yMax = 0;
|
|
282
|
-
}
|
|
283
|
-
const leftOverflow = -xMin - textWidth / 2;
|
|
284
|
-
const rightOverflow = xMax - textWidth / 2;
|
|
285
|
-
const topOverflow = -yMin - textHeight / 2;
|
|
286
|
-
const bottomOverflow = yMax - textHeight / 2;
|
|
287
|
-
return {
|
|
288
|
-
width: Math.max(xMax - xMin, MIN_TEXT_WIDTH),
|
|
289
|
-
height: Math.max(yMax - yMin, MIN_TEXT_WIDTH),
|
|
290
|
-
contentOffsetX: rightOverflow / 2 - leftOverflow / 2,
|
|
291
|
-
contentOffsetY: bottomOverflow / 2 - topOverflow / 2,
|
|
292
|
-
chars
|
|
293
|
-
};
|
|
294
|
-
};
|
|
295
|
-
/** 弧形/圆形文本统一入口:参数缺省对齐应用类字段默认(curvature 300 /
|
|
296
|
-
* circleSize 40 / startAngle 0 / sweep 360 / eccentricity 0 / normal) */
|
|
297
|
-
export const computeArcTextLayout = (layout, raw, lineHeight) => {
|
|
298
|
-
if (typeKeyOf(raw) === ElementTypes.CIRCLETEXT) {
|
|
299
|
-
return computeCirclePlacements(layout, lineHeight, {
|
|
300
|
-
size: typeof raw.circleSize === 'number' ? raw.circleSize : 40,
|
|
301
|
-
startAngle: typeof raw.circleStartAngle === 'number' ? raw.circleStartAngle : 0,
|
|
302
|
-
sweep: typeof raw.circleSweep === 'number' ? raw.circleSweep : 360,
|
|
303
|
-
eccentricity: typeof raw.circleEccentricity === 'number' ? raw.circleEccentricity : 0,
|
|
304
|
-
horizontal: raw.circleDirection === 'horizontal'
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
return computeArcPlacements(layout, lineHeight, typeof raw.curvature === 'number' ? raw.curvature : 300);
|
|
308
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 弧形/圆形文本 charTransformations 出向派生(批次 288 Phase C——自主仓
|
|
3
|
-
* app/engineCompatArcText.ts verbatim 迁入;源=P4-5b 后续批,批次 111 用户报
|
|
4
|
-
* 「webgl2 编辑器导出 pdf 弧形文本没导出来」的根治件)。
|
|
5
|
-
*
|
|
6
|
-
* 病根链:fabric ArcText 构造期类字段初始化清空 super() 里算好的
|
|
7
|
-
* _charTransformations,webgl2 创建链 adoptFabric 在 add 咽喉立即 toObject
|
|
8
|
-
* 定格 raw——cts 永远空数组;下游 PDF/PPTX 导出绘制器完全依赖 cts 摆位,
|
|
9
|
-
* 为空即静默跳过。修法=序列化出口从引擎权威布局(computeArcTextLayout)
|
|
10
|
-
* 派生 cts 恒覆写——所见(引擎渲染即此布局)与所得(导出摆位)同源。
|
|
11
|
-
*
|
|
12
|
-
* 消费面锚定:PDF/PPTX 只消费 tr.char / tr.charAngle / tr.cl 与六角点全局
|
|
13
|
-
* bbox 中点作 contentOffset——本派生只保真这三类量(六角点给「锚点」:tl/br
|
|
14
|
-
* 恒为引擎 bbox 两角、其余四角与 lc 同 cl,使下游 min/max 中点恒等于引擎
|
|
15
|
-
* contentOffset)。半径/角度族字段无下游消费,置 0 占位满足类型。
|
|
16
|
-
* 已知缺口沿 arcLayout 头注登记(charSpacing 双计/deltaY/justify 随引擎布局
|
|
17
|
-
* 缺口收敛)。
|
|
18
|
-
*/
|
|
19
|
-
import { arcTextKind, computeArcTextLayout } from './arcLayout';
|
|
20
|
-
/**
|
|
21
|
-
* 引擎布局 → fabric 形态 charTransformations(每行 = 字素条目 + 行末哨兵;
|
|
22
|
-
* 哨兵无 char,下游绘制器按空字符跳过)。非弧形/圆形节点返回 null。
|
|
23
|
-
*/
|
|
24
|
-
export const deriveArcCharTransformations = (layout, raw, lineHeight) => {
|
|
25
|
-
const kind = arcTextKind(raw);
|
|
26
|
-
if (!kind)
|
|
27
|
-
return null;
|
|
28
|
-
const arc = computeArcTextLayout(layout, raw, lineHeight);
|
|
29
|
-
const signPositive = kind === 'circle' || (typeof raw.curvature === 'number' ? raw.curvature : 300) > 0;
|
|
30
|
-
// 引擎 bbox 闭盒(width/height/contentOffset 同源反解):
|
|
31
|
-
// xMin = contentOffsetX - width/2(textWidth + leftOverflow + rightOverflow = xMax - xMin)
|
|
32
|
-
const xMin = arc.contentOffsetX - arc.width / 2;
|
|
33
|
-
const xMax = arc.contentOffsetX + arc.width / 2;
|
|
34
|
-
const yMin = arc.contentOffsetY - arc.height / 2;
|
|
35
|
-
const yMax = arc.contentOffsetY + arc.height / 2;
|
|
36
|
-
// 引擎 chars 按 (line,index) 分桶成行;rotation 反解回 fabric charAngle:
|
|
37
|
-
// 引擎 rotation = signPositive ? -charAngle : -charAngle - π(arcLayout 与
|
|
38
|
-
// PDF 端消费同式),故 charAngle = signPositive ? -rotation : -(rotation + π)
|
|
39
|
-
const rows = layout.lines.map(() => []);
|
|
40
|
-
for (const c of arc.chars) {
|
|
41
|
-
const row = rows[c.line];
|
|
42
|
-
if (!row)
|
|
43
|
-
continue;
|
|
44
|
-
const entry = {
|
|
45
|
-
char: c.char,
|
|
46
|
-
charAngle: signPositive ? -c.rotation : -(c.rotation + Math.PI),
|
|
47
|
-
leftAngle: 0,
|
|
48
|
-
rightAngle: 0,
|
|
49
|
-
charRadius: 0,
|
|
50
|
-
bottomRadius: 0,
|
|
51
|
-
topRadius: 0,
|
|
52
|
-
lineRadius: 0,
|
|
53
|
-
cl: { x: c.x, y: c.y },
|
|
54
|
-
tl: { x: xMin, y: yMin },
|
|
55
|
-
br: { x: xMax, y: yMax },
|
|
56
|
-
bl: { x: c.x, y: c.y },
|
|
57
|
-
tr: { x: c.x, y: c.y },
|
|
58
|
-
nl: { x: c.x, y: c.y },
|
|
59
|
-
nr: { x: c.x, y: c.y },
|
|
60
|
-
lc: { x: c.x, y: c.y }
|
|
61
|
-
};
|
|
62
|
-
row.push(entry);
|
|
63
|
-
}
|
|
64
|
-
// 行末哨兵(fabric 形态补齐;cl 取行末字素锚点,无消费方仅保有限值)
|
|
65
|
-
for (const row of rows) {
|
|
66
|
-
const last = row[row.length - 1];
|
|
67
|
-
row.push({
|
|
68
|
-
char: '',
|
|
69
|
-
charAngle: 0,
|
|
70
|
-
leftAngle: 0,
|
|
71
|
-
rightAngle: 0,
|
|
72
|
-
charRadius: 0,
|
|
73
|
-
bottomRadius: 0,
|
|
74
|
-
topRadius: 0,
|
|
75
|
-
lineRadius: 0,
|
|
76
|
-
cl: last ? { ...last.cl } : { x: xMin, y: yMin },
|
|
77
|
-
tl: { x: xMin, y: yMin },
|
|
78
|
-
br: { x: xMax, y: yMax },
|
|
79
|
-
bl: { x: xMin, y: yMin },
|
|
80
|
-
tr: { x: xMax, y: yMax },
|
|
81
|
-
nl: { x: xMin, y: yMin },
|
|
82
|
-
nr: { x: xMax, y: yMax },
|
|
83
|
-
lc: { x: xMin, y: yMin }
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
return rows;
|
|
87
|
-
};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* compat 历史协议常量(P3 历史契约升级,2026-10-16——主仓风险册 R1/R12):
|
|
3
|
-
* - 动作名以本常量对象为**唯一事实源**——引擎内发射点一律引用成员,不再散布
|
|
4
|
-
* 裸字符串;应用侧消费判定(如 crop 族跳过录制)经主仓锁定 spec 对齐本源,
|
|
5
|
-
* 引擎侧改名/删除时主仓测试拦红(而非靠注释约定)。
|
|
6
|
-
* - protocolVersion:compat 事件契约版本。1 = 无版本位现状(≤v0.0.16);
|
|
7
|
-
* 2 = object:modified 携带 transactionId/protocolVersion。应用侧对
|
|
8
|
-
* 「事件携带版本 < 期望版本」告警;缺省(旧引擎)不告警。
|
|
9
|
-
*/
|
|
10
|
-
export const COMPAT_PROTOCOL_VERSION = 2;
|
|
11
|
-
export const CompatHistoryActions = {
|
|
12
|
-
/** 指针拖拽 / 方向键平移 */
|
|
13
|
-
drag: 'drag',
|
|
14
|
-
/** 缩放手柄族(手势类型值亦为 'scale'/'rotate',经 g.type 透出) */
|
|
15
|
-
scale: 'scale',
|
|
16
|
-
rotate: 'rotate',
|
|
17
|
-
cornerRadius: 'cornerRadius',
|
|
18
|
-
/** crop 族:应用历史层跳过录制(cropSession / expandSession 同值) */
|
|
19
|
-
crop: 'crop',
|
|
20
|
-
tableCellEdit: 'table-cell-edit',
|
|
21
|
-
warpImage: 'warpvas-image'
|
|
22
|
-
};
|
|
23
|
-
/** 把 EngineDocument 事件桥接成 compat 口径;返回解绑函数 */
|
|
24
|
-
export const attachDocumentEventBridge = (document, deps) => {
|
|
25
|
-
const { bus, wrap, syncSelection, settleSnap } = deps;
|
|
26
|
-
const ev = document.events;
|
|
27
|
-
const fireSelection = (name, targets) => {
|
|
28
|
-
const wrapped = targets.map(wrap);
|
|
29
|
-
syncSelection();
|
|
30
|
-
bus.fire(name, { selected: wrapped, deselected: [], target: wrapped[0] });
|
|
31
|
-
};
|
|
32
|
-
const fireObject = (name, node) => {
|
|
33
|
-
// 合成装饰节点(pathBackground 拆片等)对应用侧不存在——不桥接其生命周期事件
|
|
34
|
-
if (node.syntheticOwner)
|
|
35
|
-
return;
|
|
36
|
-
bus.fire(name, { target: wrap(node) });
|
|
37
|
-
};
|
|
38
|
-
const offs = [
|
|
39
|
-
ev.on('selection:created', (targets) => fireSelection('selection:created', targets)),
|
|
40
|
-
ev.on('selection:updated', (targets) => fireSelection('selection:updated', targets)),
|
|
41
|
-
ev.on('selection:cleared', () => {
|
|
42
|
-
syncSelection();
|
|
43
|
-
bus.fire('selection:cleared', { selected: [], deselected: [] });
|
|
44
|
-
}),
|
|
45
|
-
ev.on('object:added', (node) => fireObject('object:added', node)),
|
|
46
|
-
ev.on('object:removed', (node) => fireObject('object:removed', node)),
|
|
47
|
-
ev.on('object:moving', (node) => {
|
|
48
|
-
// 磁吸改位先于转发落定——应用监听者(遮罩跟随/浮动工具条等)读到吸附后位置
|
|
49
|
-
settleSnap?.();
|
|
50
|
-
fireObject('object:moving', node);
|
|
51
|
-
}),
|
|
52
|
-
ev.on('object:scaling', (node) => fireObject('object:scaling', node)),
|
|
53
|
-
ev.on('object:rotating', (node) => fireObject('object:rotating', node)),
|
|
54
|
-
ev.on('object:cornerRadius', (node) => fireObject('object:cornerRadius', node)),
|
|
55
|
-
ev.on('object:modified', (targets, detail) => {
|
|
56
|
-
// 合成装饰节点理论上不进手势 targets(选不中),若混入则与 before 快照同索引剔除
|
|
57
|
-
const keep = targets.map((t, i) => (t.syntheticOwner ? -1 : i)).filter((i) => i >= 0);
|
|
58
|
-
if (!keep.length)
|
|
59
|
-
return;
|
|
60
|
-
const wrapped = keep.map((i) => wrap(targets[i]));
|
|
61
|
-
const beforeAll = detail?.before;
|
|
62
|
-
const before = beforeAll?.length ? keep.map((i) => beforeAll[i]).filter((s) => !!s) : undefined;
|
|
63
|
-
const transform = before && (before.length > 1 || keep.length > 1) ? { original: { objects: before } } : before ? { original: before[0] } : undefined;
|
|
64
|
-
// P3 历史契约:事务锚点与协议版本随事件透出(tid 由 document 发射层统一补全)
|
|
65
|
-
bus.fire('object:modified', { target: wrapped[0], targets: wrapped, transform, action: detail?.action, transactionId: detail?.transactionId, protocolVersion: COMPAT_PROTOCOL_VERSION });
|
|
66
|
-
}),
|
|
67
|
-
ev.on('text:editing:entered', (node) => fireObject('text:editing:entered', node)),
|
|
68
|
-
ev.on('text:editing:exited', (node) => fireObject('text:editing:exited', node)),
|
|
69
|
-
ev.on('text:changed', (node) => fireObject('text:changed', node)),
|
|
70
|
-
ev.on('text:editing:committed', (node, before, after) => {
|
|
71
|
-
bus.fire('text:editing:committed', { target: wrap(node), before, after });
|
|
72
|
-
}),
|
|
73
|
-
ev.on('smartobject:open-requested', (node) => fireObject('smartobject:open-requested', node)),
|
|
74
|
-
ev.on('image:replace-requested', (node) => fireObject('image:replace-requested', node)),
|
|
75
|
-
ev.on('lock:unlock-requested', (node) => fireObject('lock:unlock-requested', node)),
|
|
76
|
-
ev.on('path:active-anchor-change', (node, key) => {
|
|
77
|
-
bus.fire('path:active-anchor-change', { target: wrap(node), key });
|
|
78
|
-
}),
|
|
79
|
-
// 组内激活子变化:选区本身不变(保持顶组),只有这两个事件反映「同组换叶子」
|
|
80
|
-
// /「退出下钻」——compat activeObject 与选区接线都靠它们重算
|
|
81
|
-
ev.on('group:child-activated', (child) => {
|
|
82
|
-
syncSelection();
|
|
83
|
-
bus.fire('group:child-activated', { target: wrap(child) });
|
|
84
|
-
}),
|
|
85
|
-
ev.on('group:child-deactivated', () => {
|
|
86
|
-
syncSelection();
|
|
87
|
-
bus.fire('group:child-deactivated');
|
|
88
|
-
}),
|
|
89
|
-
// 表格单元格选区变化(P4-4b 补):对象选区不变,仅单元格选区变——面板/工具栏
|
|
90
|
-
// refreshKey 消费面由此驱动(fabric 模式 mouseup 后应用直 bump 的等价物)
|
|
91
|
-
ev.on('table:cellselection', (node) => {
|
|
92
|
-
bus.fire('table:cellselection', { target: wrap(node) });
|
|
93
|
-
})
|
|
94
|
-
];
|
|
95
|
-
return () => offs.forEach((off) => off());
|
|
96
|
-
};
|