@yft-design/engine 0.0.13 → 0.0.15
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/dist/EngineCanvas.d.ts +16 -2
- package/dist/EngineCanvas.js +48 -5
- package/dist/core/events.d.ts +6 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/interact/animationPlayback.js +15 -1
- package/dist/interact/canvasInteractions.d.ts +12 -1
- package/dist/interact/canvasInteractions.js +21 -8
- package/dist/interact/dblClick.d.ts +3 -1
- package/dist/interact/dblClick.js +6 -2
- package/dist/interact/pageTransfer.d.ts +22 -0
- package/dist/interact/pageTransfer.js +56 -0
- package/dist/interact/pointer.d.ts +4 -1
- package/dist/interact/pointer.js +12 -2
- package/dist/interact/pointerTypes.d.ts +2 -0
- package/dist/interact/textEditing.js +9 -3
- package/dist/interact/wheelScroll.d.ts +21 -0
- package/dist/interact/wheelScroll.js +29 -1
- package/dist/model/scene.d.ts +13 -1
- package/dist/model/scene.js +72 -3
- package/dist/render/SceneRenderer.js +2 -1
- package/dist/render/clipMaskPainter.js +5 -3
- package/dist/render/gpuFx.js +24 -4
- package/dist/render/gpuImageFilters.js +6 -0
- package/dist/render/gpuShadow.js +5 -0
- package/dist/render/multiPage.d.ts +26 -6
- package/dist/render/multiPage.js +114 -23
- package/dist/render/renderViewport.d.ts +7 -0
- package/dist/render/renderViewport.js +18 -0
- package/dist/render/screenClip.d.ts +47 -0
- package/dist/render/screenClip.js +67 -0
- package/dist/render/strokePainter.js +3 -2
- package/package.json +2 -2
package/dist/EngineCanvas.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ import { type CropSessionInfo } from './interact/cropSession';
|
|
|
25
25
|
import { ExpandSessionController, type ExpandSessionInfo } from './interact/expandSession';
|
|
26
26
|
import { type PathSessionHandle, type PathSessionInfo } from './interact/pathSession';
|
|
27
27
|
import { WarpSessionController, type WarpExitPayload } from './interact/warpSession';
|
|
28
|
-
import type
|
|
28
|
+
import { type WheelScrollHost } from './interact/wheelScroll';
|
|
29
29
|
import { type SnapGuideInfo } from './interact/snapGuide';
|
|
30
30
|
import { type AnimationPlaybackInfo, type ScrollTextTrackInfo, type SinglePreviewInfo } from './interact/animationPlayback';
|
|
31
31
|
import { type TableCellEditingHost } from './interact/tableCellEditing';
|
|
@@ -52,6 +52,11 @@ export interface EngineCanvasOptions {
|
|
|
52
52
|
* (fabric moveControls 的 move 控件——app fabricConf hasMobile 门引擎面;
|
|
53
53
|
* 宿主按 isMobile() 判定传入,引擎零 UA 耦合) */
|
|
54
54
|
mobileControls?: boolean;
|
|
55
|
+
/** 交互/静态模式(默认 true = 交互):false = 静态画布(VideoPlay 播放预览
|
|
56
|
+
* 等纯展示面)——指针/双击/滚轮/中键平移/Esc 交互监听整体不挂,悬停命中
|
|
57
|
+
* 与手势全让位(画布 CSS pointer-events 拦不住 window 级 pointermove
|
|
58
|
+
* 监听,悬停边框须引擎侧不挂才断根);渲染/字体迟到失效/文档事件接线保持 */
|
|
59
|
+
interactive?: boolean;
|
|
55
60
|
}
|
|
56
61
|
/** 摘要类型随实现体迁至 debug/canvasInspection(批次 224),转口保持原导入路径 */
|
|
57
62
|
export type { SceneNodeSummary } from './debug/canvasInspection';
|
|
@@ -103,6 +108,9 @@ export declare class EngineCanvas implements PointerHost, TextEditingHost, Sourc
|
|
|
103
108
|
/** 移动端控件面(批次 354):public——PointerHost/OverlayTailHost 双面消费
|
|
104
109
|
* (pointer hitMoveControl + frameOverlay 选区覆盖层),构造期定死 */
|
|
105
110
|
readonly mobileControls: boolean;
|
|
111
|
+
/** 交互/静态模式位(构造期定死,见 EngineCanvasOptions.interactive):
|
|
112
|
+
* CanvasInteractionsController 按位决定交互监听挂否 */
|
|
113
|
+
readonly interactive: boolean;
|
|
106
114
|
private vpt;
|
|
107
115
|
private cssWidth;
|
|
108
116
|
private cssHeight;
|
|
@@ -199,6 +207,8 @@ export declare class EngineCanvas implements PointerHost, TextEditingHost, Sourc
|
|
|
199
207
|
* 视口预过滤/标尺刻度/compat 同步面与 toScene/toScreen 同语义;单页态
|
|
200
208
|
* 恒等原值。raw vpt(布局/GL 域)保持私有 */
|
|
201
209
|
get viewportTransform(): Mat;
|
|
210
|
+
/** 文档流滚动边界读位,坐标系与 workspaceSize 的全文档包围盒一致。 */
|
|
211
|
+
get scrollViewportTransform(): Mat;
|
|
202
212
|
get zoom(): number;
|
|
203
213
|
get gl(): WebGL2RenderingContext;
|
|
204
214
|
/** SnapGuideHost:视口 css 尺寸(吸附候选的视口预过滤用) */
|
|
@@ -218,6 +228,7 @@ export declare class EngineCanvas implements PointerHost, TextEditingHost, Sourc
|
|
|
218
228
|
x: number;
|
|
219
229
|
y: number;
|
|
220
230
|
};
|
|
231
|
+
followScrolledPage(): void;
|
|
221
232
|
get cropSession(): CropSessionHandle | null;
|
|
222
233
|
/** SceneRendererHost:裁剪会话目标(幽灵底图门控) */
|
|
223
234
|
get cropGhostNode(): SceneNode | null;
|
|
@@ -329,6 +340,7 @@ export declare class EngineCanvas implements PointerHost, TextEditingHost, Sourc
|
|
|
329
340
|
} | null;
|
|
330
341
|
/** 路由激活(down/双击命中非活动页时由指针链调用):即 setActivePage 含收口 */
|
|
331
342
|
activateRoutedDocument(doc: EngineDocument): void;
|
|
343
|
+
transferDraggedNodes(nodes: SceneNode[], before: Map<SceneNode, SerializedNode> | undefined, cssX: number, cssY: number): boolean;
|
|
332
344
|
/** 新建页并装载场景(objects 缺省空页);返回实际落位索引 */
|
|
333
345
|
insertPage(index: number, objects?: SerializedNode[]): Promise<number>;
|
|
334
346
|
/** 删除页(末页拒绝 false;活动索引随动钳制) */
|
|
@@ -351,11 +363,13 @@ export declare class EngineCanvas implements PointerHost, TextEditingHost, Sourc
|
|
|
351
363
|
ensurePageBuilt(index: number): Promise<void>;
|
|
352
364
|
/** 页绝对场景矩形(宿主滚动定位/e2e/debug 几何共源;无效页 null) */
|
|
353
365
|
pageRectAt(index: number): PageRect | null;
|
|
366
|
+
/** 以活动 doc 为锚重建页注册表(主仓 syncEnginePages 结构失配修复面——批次 413) */
|
|
367
|
+
rebuildAroundActive(count: number, activeIndex: number): void;
|
|
354
368
|
/** 分段帧宿主装配(每帧现建——vpt/cssWidth 是按值快照进字面量的,缓存会陈旧;
|
|
355
369
|
* 私有控制器不落公开 API) */
|
|
356
370
|
private multiPageFrameHost;
|
|
357
371
|
setViewportTransform(vpt: Mat): void;
|
|
358
|
-
/**
|
|
372
|
+
/** 单页光标锚定、多页画板中心缩放;屏幕恒定间隙与页偏移由布局控制器承载。 */
|
|
359
373
|
zoomAt(cssX: number, cssY: number, factor: number): void;
|
|
360
374
|
pan(dx: number, dy: number): void;
|
|
361
375
|
/** 覆盖层拖拽会话交互标记(批次 386,蒙版工具栏把手拖图「不跟手」刀一):
|
package/dist/EngineCanvas.js
CHANGED
|
@@ -25,6 +25,7 @@ import { CropSessionController } from './interact/cropSession';
|
|
|
25
25
|
import { ExpandSessionController } from './interact/expandSession';
|
|
26
26
|
import { PathSessionController } from './interact/pathSession';
|
|
27
27
|
import { WarpSessionController } from './interact/warpSession';
|
|
28
|
+
import { followScrolledPage } from './interact/wheelScroll';
|
|
28
29
|
import { SnapGuideController } from './interact/snapGuide';
|
|
29
30
|
import { AnimationPlaybackController } from './interact/animationPlayback';
|
|
30
31
|
import { TableCellEditingController } from './interact/tableCellEditing';
|
|
@@ -45,6 +46,8 @@ import { RetainedFrameController } from './render/retainedFrame';
|
|
|
45
46
|
import { SceneRenderer } from './render/SceneRenderer';
|
|
46
47
|
import { SourceManager } from './render/SourceManager';
|
|
47
48
|
import { collectFlatNodes, hydrateNodeSources } from './render/sourceHydration';
|
|
49
|
+
import { transferPageNodes } from './interact/pageTransfer';
|
|
50
|
+
import { withRenderViewport } from './render/renderViewport';
|
|
48
51
|
import { TextRenderer } from './render/TextRenderer';
|
|
49
52
|
import { SceneExporter } from './export/SceneExporter';
|
|
50
53
|
import { WorkspaceBackdrop } from './render/workspaceBackdrop';
|
|
@@ -107,6 +110,9 @@ export class EngineCanvas {
|
|
|
107
110
|
/** 移动端控件面(批次 354):public——PointerHost/OverlayTailHost 双面消费
|
|
108
111
|
* (pointer hitMoveControl + frameOverlay 选区覆盖层),构造期定死 */
|
|
109
112
|
mobileControls;
|
|
113
|
+
/** 交互/静态模式位(构造期定死,见 EngineCanvasOptions.interactive):
|
|
114
|
+
* CanvasInteractionsController 按位决定交互监听挂否 */
|
|
115
|
+
interactive;
|
|
110
116
|
vpt = [1, 0, 0, 1, 0, 0];
|
|
111
117
|
cssWidth = 300;
|
|
112
118
|
cssHeight = 150;
|
|
@@ -185,6 +191,7 @@ export class EngineCanvas {
|
|
|
185
191
|
this.glyphAtlas = new GlyphAtlas(handle.gl, () => this.requestRenderAll(), (families) => this.fontInvalidation.queueSettle(families), this.renderEpoch);
|
|
186
192
|
this.dpr = options.dpr ?? (typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1);
|
|
187
193
|
this.mobileControls = options.mobileControls ?? false;
|
|
194
|
+
this.interactive = options.interactive ?? true;
|
|
188
195
|
this.background = options.background ?? [0, 0, 0, 0];
|
|
189
196
|
this.sources = new SourceManager(this);
|
|
190
197
|
this.textRenderer = new TextRenderer(handle.gl, this.batch, this.glyphAtlas);
|
|
@@ -201,7 +208,7 @@ export class EngineCanvas {
|
|
|
201
208
|
this.pathSessionController = new PathSessionController(this);
|
|
202
209
|
this.warpSessionController = new WarpSessionController(this);
|
|
203
210
|
this.animationPlaybackController = new AnimationPlaybackController(this);
|
|
204
|
-
this.interactions = new CanvasInteractionsController(this, this.snapGuide, this.sources);
|
|
211
|
+
this.interactions = new CanvasInteractionsController(this, this.snapGuide, this.sources, this.interactive);
|
|
205
212
|
// 表格单元格选区变化通知(P4-4b 补):TableNode 静态槽 → 本文档事件总线
|
|
206
213
|
// (引擎单画布常驻,静态槽即当前文档;dispose 按归属卸载防双实例互踩)
|
|
207
214
|
this.cellSelectionSink = (node) => {
|
|
@@ -297,6 +304,10 @@ export class EngineCanvas {
|
|
|
297
304
|
get viewportTransform() {
|
|
298
305
|
return this.multiPage.pageCount > 1 ? this.multiPage.pageVpt(this.vpt, this.multiPage.activeIndex) : [...this.vpt];
|
|
299
306
|
}
|
|
307
|
+
/** 文档流滚动边界读位,坐标系与 workspaceSize 的全文档包围盒一致。 */
|
|
308
|
+
get scrollViewportTransform() {
|
|
309
|
+
return [...this.vpt];
|
|
310
|
+
}
|
|
300
311
|
get zoom() {
|
|
301
312
|
return this.vpt[0];
|
|
302
313
|
}
|
|
@@ -323,6 +334,12 @@ export class EngineCanvas {
|
|
|
323
334
|
const rect = this.canvasEl.getBoundingClientRect();
|
|
324
335
|
return { x: e.clientX - rect.left, y: e.clientY - rect.top };
|
|
325
336
|
}
|
|
337
|
+
followScrolledPage() {
|
|
338
|
+
if (this.multiPage.pageCount < 2)
|
|
339
|
+
return;
|
|
340
|
+
// 一次布局快照;逐页 pageRectAt 会重复 layout,长文档退化为 O(N²)。
|
|
341
|
+
followScrolledPage(this, this.multiPage.layout().map(({ index, rect, entry }) => ({ index, top: rect.top + entry.origin.y, height: rect.height })));
|
|
342
|
+
}
|
|
326
343
|
// PointerHost B2 裁剪会话句柄(非会话态 null——pointer 侧吞没判定)
|
|
327
344
|
get cropSession() {
|
|
328
345
|
return this.cropSessionController.active ? this.cropSessionController : null;
|
|
@@ -478,6 +495,7 @@ export class EngineCanvas {
|
|
|
478
495
|
// 播放收口(批次 411 D-5):切页前 stop——时间轴覆写清零 + 旧页自播
|
|
479
496
|
// GIF/视频元素全停 + 滚动文本归零(stop 跟随切换前的活动页;空转零成本)
|
|
480
497
|
this.animationPlaybackController.stop();
|
|
498
|
+
this.bus.fire('engine:active-page-changing', index);
|
|
481
499
|
this.multiPage.setActiveIndex(index);
|
|
482
500
|
prevDoc.setHovered(null);
|
|
483
501
|
if (prevDoc.editingNode)
|
|
@@ -499,6 +517,7 @@ export class EngineCanvas {
|
|
|
499
517
|
this.textEditing.retargetDoc(nextDoc);
|
|
500
518
|
this.tableCellEditing.retargetDoc(nextDoc);
|
|
501
519
|
this.interactions.retargetDoc(nextDoc);
|
|
520
|
+
this.bus.fire('engine:active-page-changed', index);
|
|
502
521
|
this.requestRenderAll();
|
|
503
522
|
}
|
|
504
523
|
/** 多页指针路由(批次 409 D-3;PointerHost/DblClickHost 可选面):绝对场景点
|
|
@@ -522,6 +541,18 @@ export class EngineCanvas {
|
|
|
522
541
|
if (index >= 0)
|
|
523
542
|
this.setActivePage(index);
|
|
524
543
|
}
|
|
544
|
+
transferDraggedNodes(nodes, before, cssX, cssY) {
|
|
545
|
+
const transfer = transferPageNodes(this.multiPage, nodes, before, this.toSceneAbs(cssX, cssY), (index) => {
|
|
546
|
+
void this.ensurePageBuilt(index);
|
|
547
|
+
});
|
|
548
|
+
if (!transfer)
|
|
549
|
+
return false;
|
|
550
|
+
this.setActivePage(transfer.targetIndex);
|
|
551
|
+
transfer.target.setSelection(transfer.nodes);
|
|
552
|
+
this.bus.fire('engine:page-transfer', transfer);
|
|
553
|
+
this.requestRenderAll();
|
|
554
|
+
return true;
|
|
555
|
+
}
|
|
525
556
|
/** 新建页并装载场景(objects 缺省空页);返回实际落位索引 */
|
|
526
557
|
async insertPage(index, objects = []) {
|
|
527
558
|
const at = this.multiPage.insert(index);
|
|
@@ -583,6 +614,7 @@ export class EngineCanvas {
|
|
|
583
614
|
return;
|
|
584
615
|
entry.doc.loadObjects(entry.pendingRaw);
|
|
585
616
|
this.multiPage.markBuilt(index);
|
|
617
|
+
this.bus.fire('engine:page-built', index, entry.doc);
|
|
586
618
|
await hydrateNodeSources(collectFlatNodes([...entry.doc.nodes]), this.sources, () => this.requestRenderAll());
|
|
587
619
|
this.requestRenderAll();
|
|
588
620
|
}
|
|
@@ -590,6 +622,12 @@ export class EngineCanvas {
|
|
|
590
622
|
pageRectAt(index) {
|
|
591
623
|
return this.multiPage.pageRectAt(index);
|
|
592
624
|
}
|
|
625
|
+
/** 以活动 doc 为锚重建页注册表(主仓 syncEnginePages 结构失配修复面——批次 413) */
|
|
626
|
+
rebuildAroundActive(count, activeIndex) {
|
|
627
|
+
this.retainedFrame.invalidate();
|
|
628
|
+
this.multiPage.rebuildAroundActive(count, activeIndex);
|
|
629
|
+
this.requestRenderAll();
|
|
630
|
+
}
|
|
593
631
|
/** 分段帧宿主装配(每帧现建——vpt/cssWidth 是按值快照进字面量的,缓存会陈旧;
|
|
594
632
|
* 私有控制器不落公开 API) */
|
|
595
633
|
multiPageFrameHost() {
|
|
@@ -604,6 +642,7 @@ export class EngineCanvas {
|
|
|
604
642
|
meshBatch: this.meshBatch,
|
|
605
643
|
batchOrder: this.batchOrder,
|
|
606
644
|
renderer: this.renderer,
|
|
645
|
+
withPageViewport: (viewport, render) => withRenderViewport(this, viewport, render),
|
|
607
646
|
workspaceBackdrop: this.workspaceBackdrop,
|
|
608
647
|
textures: this.textures,
|
|
609
648
|
expandUnderlay: () => {
|
|
@@ -620,20 +659,24 @@ export class EngineCanvas {
|
|
|
620
659
|
setViewportTransform(vpt) {
|
|
621
660
|
const prevZoom = this.vpt[0];
|
|
622
661
|
this.vpt = [...vpt];
|
|
662
|
+
// 单页时也同步:用户可先缩放再开启多页,首次布局即用当前 zoom 折算间距。
|
|
663
|
+
this.multiPage.viewportZoom = this.vpt[0];
|
|
623
664
|
// 视口写点统一通知(2026-10-09 扩语义:平移也触发——描边烘焙的吸附目标
|
|
624
665
|
// 随平移跨半像素界翻转同样须避开手势窗口;缩放另连 hit 带换算)
|
|
625
666
|
this.renderer.noteVptChange();
|
|
626
|
-
if (vpt[0] !== prevZoom) {
|
|
667
|
+
if (this.vpt[0] !== prevZoom) {
|
|
627
668
|
// 命中带随 zoom 换算(批次 97):同值守卫内零开销,平移不触发
|
|
628
|
-
this.doc.setViewportZoom(vpt[0]);
|
|
669
|
+
this.doc.setViewportZoom(this.vpt[0]);
|
|
629
670
|
}
|
|
630
671
|
this.requestRenderAll();
|
|
631
672
|
}
|
|
632
|
-
/**
|
|
673
|
+
/** 单页光标锚定、多页画板中心缩放;屏幕恒定间隙与页偏移由布局控制器承载。 */
|
|
633
674
|
zoomAt(cssX, cssY, factor) {
|
|
634
675
|
const next = Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, this.vpt[0] * factor));
|
|
635
676
|
const k = next / this.vpt[0];
|
|
636
|
-
|
|
677
|
+
const vpt = [next, 0, 0, next, cssX - k * (cssX - this.vpt[4]), cssY - k * (cssY - this.vpt[5])];
|
|
678
|
+
this.vpt = this.multiPage.pageCount > 1 ? this.multiPage.zoomViewportAt(this.vpt, cssX, cssY, next) : vpt;
|
|
679
|
+
this.multiPage.viewportZoom = next;
|
|
637
680
|
this.renderer.noteVptChange();
|
|
638
681
|
this.doc.setViewportZoom(next);
|
|
639
682
|
this.requestRenderAll();
|
package/dist/core/events.d.ts
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* 后续引擎可整体抽包。
|
|
8
8
|
*/
|
|
9
9
|
/** 事件参数类型:接口定义无字符串索引签名,约束放宽到 object 后按 key 取值并收窄为数组 */
|
|
10
|
+
import type { PageTransfer } from '../interact/pageTransfer';
|
|
11
|
+
import type { EngineDocument } from '../model/document';
|
|
10
12
|
type EventArgs<M, E extends keyof M> = M[E] extends unknown[] ? M[E] : never;
|
|
11
13
|
type StoredHandler = (...args: unknown[]) => void;
|
|
12
14
|
export declare class EventBus<M extends object> {
|
|
@@ -24,6 +26,10 @@ export declare class EventBus<M extends object> {
|
|
|
24
26
|
}
|
|
25
27
|
/** 引擎生命周期事件(Phase 0 仅渲染循环与上下文丢失,后续阶段扩展 fabric 等价事件) */
|
|
26
28
|
export interface EngineEvents {
|
|
29
|
+
'engine:page-built': [index: number, document: EngineDocument];
|
|
30
|
+
'engine:active-page-changing': [index: number];
|
|
31
|
+
'engine:active-page-changed': [index: number];
|
|
32
|
+
'engine:page-transfer': [transfer: PageTransfer];
|
|
27
33
|
'engine:context-lost': [];
|
|
28
34
|
'engine:context-restored': [];
|
|
29
35
|
'engine:render': [frameMs: number];
|
package/dist/index.d.ts
CHANGED
|
@@ -26,7 +26,8 @@ export { isCanvasPerfEnabled, markCanvasPerfCounter, recordCanvasPerfDuration }
|
|
|
26
26
|
export { rectCornerRadii } from './core/roundedRect';
|
|
27
27
|
export { parsePsdEffects } from './core/psdEffects';
|
|
28
28
|
export { EngineDocument, type EngineDocumentEvents, type IndexedItem, type SelectionFrame } from './model/document';
|
|
29
|
-
export {
|
|
29
|
+
export { PAGE_GAP_CSS_PX, type PageRect, type PageLayoutRow } from './render/multiPage';
|
|
30
|
+
export type { PageTransfer, PageTransferItem } from './interact/pageTransfer';
|
|
30
31
|
/** 元素类型规范词表(批次 361 主仓同源):小写键 + typeKeyOf 坍缩 + 家族集合——
|
|
31
32
|
* 主仓 @/types/elements 的 ElementNames 即本导出的别名(引擎=渲染权限守门人,
|
|
32
33
|
* 类型词汇的单一事实源在引擎,新增元素类型须先在此登记可渲染) */
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ export { isCanvasPerfEnabled, markCanvasPerfCounter, recordCanvasPerfDuration }
|
|
|
30
30
|
export { rectCornerRadii } from './core/roundedRect';
|
|
31
31
|
export { parsePsdEffects } from './core/psdEffects';
|
|
32
32
|
export { EngineDocument } from './model/document';
|
|
33
|
-
export {
|
|
33
|
+
export { PAGE_GAP_CSS_PX } from './render/multiPage';
|
|
34
34
|
/** 元素类型规范词表(批次 361 主仓同源):小写键 + typeKeyOf 坍缩 + 家族集合——
|
|
35
35
|
* 主仓 @/types/elements 的 ElementNames 即本导出的别名(引擎=渲染权限守门人,
|
|
36
36
|
* 类型词汇的单一事实源在引擎,新增元素类型须先在此登记可渲染) */
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { objectCenter } from '../core/mat2d';
|
|
14
14
|
import { AnimationPlayer, buildSequentialPlayback, buildSinglePreviewPlan, computeTotalDuration, evaluateSequentialAt, evaluateScrollTextOffset, evaluateSinglePreviewAt, getScrollTextDuration, readSerializedAnimates } from '../model/animation';
|
|
15
15
|
import { WORKSPACE_ID } from '../model/scene';
|
|
16
|
-
import { AnimatedNode, GroupNode, TextNode } from '../model/scene';
|
|
16
|
+
import { AnimatedNode, GroupNode, MaskNode, TextNode } from '../model/scene';
|
|
17
17
|
import { scrollTrackInput } from '../render/scrollText';
|
|
18
18
|
export class AnimationPlaybackController {
|
|
19
19
|
host;
|
|
@@ -55,6 +55,8 @@ export class AnimationPlaybackController {
|
|
|
55
55
|
for (const node of this.host.document.nodes) {
|
|
56
56
|
if (node instanceof AnimatedNode)
|
|
57
57
|
node.play();
|
|
58
|
+
else if (node instanceof MaskNode)
|
|
59
|
+
node.playClipMedia();
|
|
58
60
|
}
|
|
59
61
|
this.syncVideosToTime(this.player.time, true);
|
|
60
62
|
this.applyScrollTextOffsets(this.player.time);
|
|
@@ -65,6 +67,8 @@ export class AnimationPlaybackController {
|
|
|
65
67
|
for (const node of this.host.document.nodes) {
|
|
66
68
|
if (node instanceof AnimatedNode)
|
|
67
69
|
node.pause();
|
|
70
|
+
else if (node instanceof MaskNode)
|
|
71
|
+
node.pauseClipMedia();
|
|
68
72
|
}
|
|
69
73
|
this.host.requestRenderAll();
|
|
70
74
|
}
|
|
@@ -80,6 +84,8 @@ export class AnimationPlaybackController {
|
|
|
80
84
|
for (const node of this.host.document.nodes) {
|
|
81
85
|
if (node instanceof AnimatedNode)
|
|
82
86
|
node.stop();
|
|
87
|
+
else if (node instanceof MaskNode)
|
|
88
|
+
node.syncClipMediaToTime(0, false);
|
|
83
89
|
}
|
|
84
90
|
this.host.requestRenderAll();
|
|
85
91
|
}
|
|
@@ -322,6 +328,12 @@ export class AnimationPlaybackController {
|
|
|
322
328
|
for (const n of nodes) {
|
|
323
329
|
if (n instanceof AnimatedNode)
|
|
324
330
|
durations.push(n.mediaDuration);
|
|
331
|
+
else if (n instanceof MaskNode) {
|
|
332
|
+
// 蒙版动态 clip 视频(VideoPlay 预览时间轴):时长缺席则总时长 0,
|
|
333
|
+
// 播放立即 ended、进度条不可拖(用户报「视频蒙版预览不显示」的连坐面)
|
|
334
|
+
if (n.clipMediaDuration > 0)
|
|
335
|
+
durations.push(n.clipMediaDuration);
|
|
336
|
+
}
|
|
325
337
|
else if (n instanceof GroupNode)
|
|
326
338
|
collect(n.children);
|
|
327
339
|
}
|
|
@@ -335,6 +347,8 @@ export class AnimationPlaybackController {
|
|
|
335
347
|
for (const n of nodes) {
|
|
336
348
|
if (n instanceof AnimatedNode)
|
|
337
349
|
n.syncVideoToTime(time, playing);
|
|
350
|
+
else if (n instanceof MaskNode)
|
|
351
|
+
n.syncClipMediaToTime(time, playing);
|
|
338
352
|
else if (n instanceof GroupNode)
|
|
339
353
|
walk(n.children);
|
|
340
354
|
}
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
* object:removed → 动画源释放)也在此接线。EngineCanvas 只留构造一行与
|
|
10
10
|
* dispose 一行;宿主面 = 既有四个 host 接口之并(panning 让位判定走
|
|
11
11
|
* PointerHost 公共面)。
|
|
12
|
+
*
|
|
13
|
+
* 静态模式(interactive=false,EngineCanvasOptions.interactive——VideoPlay
|
|
14
|
+
* 播放预览等纯展示面):指针/双击/中键平移/滚轮/Esc 五类交互监听整体不挂
|
|
15
|
+
* (画布 CSS pointer-events 拦不住 window 级 pointermove,悬停命中须源头
|
|
16
|
+
* 不挂才断根);字体迟到失效与文档事件接线保持(渲染正确性面,与交互无关)。
|
|
12
17
|
*/
|
|
13
18
|
import type { EngineDocument } from '../model/document';
|
|
14
19
|
import { type PointerHost } from './pointer';
|
|
@@ -32,6 +37,9 @@ export declare class CanvasInteractionsController {
|
|
|
32
37
|
private readonly host;
|
|
33
38
|
private readonly snapGuide;
|
|
34
39
|
private readonly sources;
|
|
40
|
+
/** 交互/静态模式(EngineCanvasOptions.interactive,默认 true=交互):
|
|
41
|
+
* 静态时下传 Pointer/DoubleClick 不挂监听,本级 wheel/中键平移/Esc 同免 */
|
|
42
|
+
private readonly interactive;
|
|
35
43
|
/** 左键交互(选择/移动/缩放/旋转/框选);宿主自身实现 PointerHost */
|
|
36
44
|
private readonly pointer;
|
|
37
45
|
/** 表格键盘交互 + 单元格态生命周期(P4-4b) */
|
|
@@ -42,7 +50,10 @@ export declare class CanvasInteractionsController {
|
|
|
42
50
|
/** doc bus 订阅束(批次 410 D-4):切页 retarget(级联 tableInteraction) */
|
|
43
51
|
private docBus;
|
|
44
52
|
private lastPanPointer;
|
|
45
|
-
constructor(host: CanvasInteractionsHost, snapGuide: SnapGuideController, sources: SourceManager
|
|
53
|
+
constructor(host: CanvasInteractionsHost, snapGuide: SnapGuideController, sources: SourceManager,
|
|
54
|
+
/** 交互/静态模式(EngineCanvasOptions.interactive,默认 true=交互):
|
|
55
|
+
* 静态时下传 Pointer/DoubleClick 不挂监听,本级 wheel/中键平移/Esc 同免 */
|
|
56
|
+
interactive?: boolean);
|
|
46
57
|
/** 指针手势进行中(移动/缩放/框选/表格拖选/参考线等全部手势族;纯点击按下
|
|
47
58
|
* 未 move 也算——pointerup 才清)。只读面:宿主只作判据(如 compat
|
|
48
59
|
* `_currentTransform` 兼容位 → 快照防抖拖动期顺延),不得驱动行为分支 */
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
* object:removed → 动画源释放)也在此接线。EngineCanvas 只留构造一行与
|
|
10
10
|
* dispose 一行;宿主面 = 既有四个 host 接口之并(panning 让位判定走
|
|
11
11
|
* PointerHost 公共面)。
|
|
12
|
+
*
|
|
13
|
+
* 静态模式(interactive=false,EngineCanvasOptions.interactive——VideoPlay
|
|
14
|
+
* 播放预览等纯展示面):指针/双击/中键平移/滚轮/Esc 五类交互监听整体不挂
|
|
15
|
+
* (画布 CSS pointer-events 拦不住 window 级 pointermove,悬停命中须源头
|
|
16
|
+
* 不挂才断根);字体迟到失效与文档事件接线保持(渲染正确性面,与交互无关)。
|
|
12
17
|
*/
|
|
13
18
|
import { AnimatedNode, PuzzleNode } from '../model/scene';
|
|
14
19
|
import { DocBusBinder } from '../core/events';
|
|
@@ -20,6 +25,7 @@ export class CanvasInteractionsController {
|
|
|
20
25
|
host;
|
|
21
26
|
snapGuide;
|
|
22
27
|
sources;
|
|
28
|
+
interactive;
|
|
23
29
|
/** 左键交互(选择/移动/缩放/旋转/框选);宿主自身实现 PointerHost */
|
|
24
30
|
pointer;
|
|
25
31
|
/** 表格键盘交互 + 单元格态生命周期(P4-4b) */
|
|
@@ -30,12 +36,16 @@ export class CanvasInteractionsController {
|
|
|
30
36
|
/** doc bus 订阅束(批次 410 D-4):切页 retarget(级联 tableInteraction) */
|
|
31
37
|
docBus = null;
|
|
32
38
|
lastPanPointer = null;
|
|
33
|
-
constructor(host, snapGuide, sources
|
|
39
|
+
constructor(host, snapGuide, sources,
|
|
40
|
+
/** 交互/静态模式(EngineCanvasOptions.interactive,默认 true=交互):
|
|
41
|
+
* 静态时下传 Pointer/DoubleClick 不挂监听,本级 wheel/中键平移/Esc 同免 */
|
|
42
|
+
interactive = true) {
|
|
34
43
|
this.host = host;
|
|
35
44
|
this.snapGuide = snapGuide;
|
|
36
45
|
this.sources = sources;
|
|
46
|
+
this.interactive = interactive;
|
|
37
47
|
const el = host.canvasEl;
|
|
38
|
-
this.pointer = new PointerController(el, host);
|
|
48
|
+
this.pointer = new PointerController(el, host, this.interactive);
|
|
39
49
|
this.tableInteraction = new TableInteractionController(host);
|
|
40
50
|
// Esc 退出蒙版编辑会话(P4-5b(3/3);表格单元格态的 Esc 在
|
|
41
51
|
// TableInteractionController,两处按键不冲突——会话态互斥)。
|
|
@@ -50,7 +60,8 @@ export class CanvasInteractionsController {
|
|
|
50
60
|
host.requestRenderAll();
|
|
51
61
|
}
|
|
52
62
|
};
|
|
53
|
-
|
|
63
|
+
if (this.interactive)
|
|
64
|
+
window.addEventListener('keydown', onMaskSessionEsc);
|
|
54
65
|
// 文档事件(选区/变换)→ 重渲染;文本编辑事件由 TextEditingController 自订。
|
|
55
66
|
// 批次 410 D-4:DocBusBinder 束化(切页 retarget——多页态选区/吸附/源释放
|
|
56
67
|
// 事件随活动页走)
|
|
@@ -74,7 +85,7 @@ export class CanvasInteractionsController {
|
|
|
74
85
|
});
|
|
75
86
|
// 双击派发(P5-7 拆出至 DoubleClickController):表格格/拼图蒙版/文本编辑
|
|
76
87
|
// 三会话 + 图片族 smartobject:open-requested / image:replace-requested 事件边界
|
|
77
|
-
this.dblClick = new DoubleClickController(host);
|
|
88
|
+
this.dblClick = new DoubleClickController(host, this.interactive);
|
|
78
89
|
// 中键平移 + 滚轮手势(批次 73:普通滚=垂直平移/shift=水平/ctrl·cmd·alt=缩放,
|
|
79
90
|
// fabric FabricScroll 逐式——逻辑在 interact/wheelScroll,host 由装配层实现)
|
|
80
91
|
const onWheel = (e) => {
|
|
@@ -125,10 +136,12 @@ export class CanvasInteractionsController {
|
|
|
125
136
|
// 宿主/旧 jsdom 可能缺失,可选链守卫
|
|
126
137
|
const onFontsLoaded = (e) => host.handleFontsLoaded(e.fontfaces ?? []);
|
|
127
138
|
document.fonts?.addEventListener?.('loadingdone', onFontsLoaded);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
139
|
+
if (this.interactive) {
|
|
140
|
+
el.addEventListener('wheel', onWheel, { passive: false });
|
|
141
|
+
el.addEventListener('pointerdown', onPointerDown);
|
|
142
|
+
window.addEventListener('pointermove', onPointerMove);
|
|
143
|
+
window.addEventListener('pointerup', onPointerUp);
|
|
144
|
+
}
|
|
132
145
|
this.detachListeners = () => {
|
|
133
146
|
document.fonts?.removeEventListener?.('loadingdone', onFontsLoaded);
|
|
134
147
|
el.removeEventListener('wheel', onWheel);
|
|
@@ -59,7 +59,9 @@ export declare class DoubleClickController {
|
|
|
59
59
|
private readonly host;
|
|
60
60
|
private readonly onDblClick;
|
|
61
61
|
private disposed;
|
|
62
|
-
|
|
62
|
+
/** 交互/静态模式(静态画布监听不挂;dispose 的 remove 对未挂监听安全) */
|
|
63
|
+
private readonly interactive;
|
|
64
|
+
constructor(host: DblClickHost, interactive?: boolean);
|
|
63
65
|
/** 命中后派发;监听只做坐标换算与命中,分支语义的单测直入口 */
|
|
64
66
|
dispatch(target: SceneNode | null, sceneX: number, sceneY: number): void;
|
|
65
67
|
dispose(): void;
|
|
@@ -39,8 +39,11 @@ export class DoubleClickController {
|
|
|
39
39
|
host;
|
|
40
40
|
onDblClick;
|
|
41
41
|
disposed = false;
|
|
42
|
-
|
|
42
|
+
/** 交互/静态模式(静态画布监听不挂;dispose 的 remove 对未挂监听安全) */
|
|
43
|
+
interactive;
|
|
44
|
+
constructor(host, interactive = true) {
|
|
43
45
|
this.host = host;
|
|
46
|
+
this.interactive = interactive;
|
|
44
47
|
this.onDblClick = (e) => {
|
|
45
48
|
// 外部绘制会话(compat 绘制桥)挂起期不派发——绘制中双击不得进编辑会话
|
|
46
49
|
if (host.interactionSuspended)
|
|
@@ -66,7 +69,8 @@ export class DoubleClickController {
|
|
|
66
69
|
}
|
|
67
70
|
this.dispatch(target, p.x, p.y);
|
|
68
71
|
};
|
|
69
|
-
|
|
72
|
+
if (this.interactive)
|
|
73
|
+
host.canvasEl.addEventListener('dblclick', this.onDblClick);
|
|
70
74
|
}
|
|
71
75
|
/** 命中后派发;监听只做坐标换算与命中,分支语义的单测直入口 */
|
|
72
76
|
dispatch(target, sceneX, sceneY) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { EngineDocument } from '../model/document';
|
|
2
|
+
import { type SceneNode, type SerializedNode } from '../model/scene';
|
|
3
|
+
import type { MultiPageController } from '../render/multiPage';
|
|
4
|
+
export interface PageTransferItem {
|
|
5
|
+
/** Source z order, excluding derived decoration nodes. */
|
|
6
|
+
index: number;
|
|
7
|
+
before: SerializedNode;
|
|
8
|
+
after: SerializedNode;
|
|
9
|
+
}
|
|
10
|
+
export interface PageTransfer {
|
|
11
|
+
sourceIndex: number;
|
|
12
|
+
targetIndex: number;
|
|
13
|
+
source: EngineDocument;
|
|
14
|
+
target: EngineDocument;
|
|
15
|
+
nodes: SceneNode[];
|
|
16
|
+
items: PageTransferItem[];
|
|
17
|
+
}
|
|
18
|
+
/** Commit a completed root-object drag. Append in document order, never selection order. */
|
|
19
|
+
export declare function transferPageNodes(pages: MultiPageController, candidates: readonly SceneNode[], before: ReadonlyMap<SceneNode, SerializedNode> | undefined, point: {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
}, ensureBuilt: (index: number) => void): PageTransfer | null;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { GroupNode, WORKSPACE_IDS } from '../model/scene';
|
|
2
|
+
/** Commit a completed root-object drag. Append in document order, never selection order. */
|
|
3
|
+
export function transferPageNodes(pages, candidates, before, point, ensureBuilt) {
|
|
4
|
+
if (pages.pageCount < 2)
|
|
5
|
+
return null;
|
|
6
|
+
const hit = pages.route(point.x, point.y);
|
|
7
|
+
const sourceIndex = pages.activeIndex;
|
|
8
|
+
if (!hit || hit.index === sourceIndex)
|
|
9
|
+
return null;
|
|
10
|
+
const source = pages.activeDoc;
|
|
11
|
+
const selected = new Set(candidates);
|
|
12
|
+
const roots = source.nodes.filter((node) => selected.has(node) && !node.syntheticOwner && !WORKSPACE_IDS.has(node.id));
|
|
13
|
+
if (!roots.length || roots.length !== selected.size)
|
|
14
|
+
return null;
|
|
15
|
+
ensureBuilt(hit.index);
|
|
16
|
+
const target = hit.doc;
|
|
17
|
+
const sourceOrigin = pages.originAt(sourceIndex);
|
|
18
|
+
const targetOrigin = pages.originAt(hit.index);
|
|
19
|
+
const sourceOrder = source.nodes.filter((node) => !node.syntheticOwner);
|
|
20
|
+
const items = roots.map((node) => ({ index: sourceOrder.indexOf(node), before: before?.get(node) ?? node.toObject(), after: node.toObject() }));
|
|
21
|
+
// Copied pages may share IDs. Re-key collisions (including group children) without
|
|
22
|
+
// changing node identity/assets, so selecting/deleting the imported object is unambiguous.
|
|
23
|
+
const ids = new Set();
|
|
24
|
+
const visit = (node, fn) => {
|
|
25
|
+
fn(node);
|
|
26
|
+
if (node instanceof GroupNode)
|
|
27
|
+
for (const child of node.children)
|
|
28
|
+
visit(child, fn);
|
|
29
|
+
};
|
|
30
|
+
for (const node of target.nodes)
|
|
31
|
+
visit(node, (child) => {
|
|
32
|
+
if (child.id)
|
|
33
|
+
ids.add(child.id);
|
|
34
|
+
});
|
|
35
|
+
for (const node of roots) {
|
|
36
|
+
source.remove(node);
|
|
37
|
+
visit(node, (child) => {
|
|
38
|
+
if (child.id && ids.has(child.id)) {
|
|
39
|
+
const base = child.id;
|
|
40
|
+
let suffix = 1;
|
|
41
|
+
while (ids.has(`${base}-transfer-${suffix}`))
|
|
42
|
+
suffix++;
|
|
43
|
+
child.set({ id: `${base}-transfer-${suffix}` });
|
|
44
|
+
}
|
|
45
|
+
if (child.id)
|
|
46
|
+
ids.add(child.id);
|
|
47
|
+
});
|
|
48
|
+
node.set({ left: Number(node.raw.left ?? 0) + sourceOrigin.x - targetOrigin.x, top: Number(node.raw.top ?? 0) + sourceOrigin.y - targetOrigin.y });
|
|
49
|
+
target.add(node);
|
|
50
|
+
}
|
|
51
|
+
source.clearSelection();
|
|
52
|
+
roots.forEach((node, i) => {
|
|
53
|
+
items[i].after = node.toObject();
|
|
54
|
+
});
|
|
55
|
+
return { sourceIndex, targetIndex: hit.index, source, target, nodes: roots, items };
|
|
56
|
+
}
|
|
@@ -50,7 +50,10 @@ export declare class PointerController {
|
|
|
50
50
|
* 统一清;表格单元格手势转 move(拖动意图明确)时提前作废 */
|
|
51
51
|
private deferredClickSwitch;
|
|
52
52
|
private detach;
|
|
53
|
-
|
|
53
|
+
/** 交互/静态模式(静态画布监听整体不挂——CSS pointer-events 拦不住
|
|
54
|
+
* window 级 pointermove 的悬停命中,须源头不挂才断根;dispose 恒安全) */
|
|
55
|
+
private readonly interactive;
|
|
56
|
+
constructor(el: HTMLElement, host: PointerHost, interactive?: boolean);
|
|
54
57
|
get active(): boolean;
|
|
55
58
|
/** 当前命中的缩放/旋转手柄(屏幕空间半径内),供宿主设光标。手柄集与渲染
|
|
56
59
|
* 同源走 getAdaptiveSelectionHandles——小对象被裁剪的手柄不可命中(app
|
package/dist/interact/pointer.js
CHANGED
|
@@ -164,9 +164,13 @@ export class PointerController {
|
|
|
164
164
|
* 统一清;表格单元格手势转 move(拖动意图明确)时提前作废 */
|
|
165
165
|
deferredClickSwitch = null;
|
|
166
166
|
detach = null;
|
|
167
|
-
|
|
167
|
+
/** 交互/静态模式(静态画布监听整体不挂——CSS pointer-events 拦不住
|
|
168
|
+
* window 级 pointermove 的悬停命中,须源头不挂才断根;dispose 恒安全) */
|
|
169
|
+
interactive;
|
|
170
|
+
constructor(el, host, interactive = true) {
|
|
168
171
|
this.el = el;
|
|
169
172
|
this.host = host;
|
|
173
|
+
this.interactive = interactive;
|
|
170
174
|
this.attach();
|
|
171
175
|
}
|
|
172
176
|
get active() {
|
|
@@ -537,6 +541,9 @@ export class PointerController {
|
|
|
537
541
|
this.host.requestRenderAll();
|
|
538
542
|
}
|
|
539
543
|
attach() {
|
|
544
|
+
// 静态画布:监听整体不挂(手势/悬停命中全让位);dispose 的 detach 空置安全
|
|
545
|
+
if (!this.interactive)
|
|
546
|
+
return;
|
|
540
547
|
const el = this.el;
|
|
541
548
|
const onDown = (e) => {
|
|
542
549
|
if (e.button !== 0)
|
|
@@ -1531,7 +1538,10 @@ export class PointerController {
|
|
|
1531
1538
|
doc.applyTransform(targets, () => ({}), 'modified', { action: 'drag', before: g.historyBefore });
|
|
1532
1539
|
}
|
|
1533
1540
|
else {
|
|
1534
|
-
|
|
1541
|
+
const nodes = [...g.snapshot.keys()];
|
|
1542
|
+
if (!this.host.transferDraggedNodes?.(nodes, g.historyBefore, cssX, cssY)) {
|
|
1543
|
+
doc.applyTransform(nodes, () => ({}), 'modified', { action: 'drag', before: g.historyBefore });
|
|
1544
|
+
}
|
|
1535
1545
|
}
|
|
1536
1546
|
}
|
|
1537
1547
|
else if (this.deferredClickSwitch) {
|
|
@@ -123,6 +123,8 @@ export interface PointerHost {
|
|
|
123
123
|
* 哪页激活——吸附候选/会话发现/选区/overlay 经 document 天然落手势页)。
|
|
124
124
|
* 可选=单页回退(无操作) */
|
|
125
125
|
activateRoutedDocument?: (doc: EngineDocument) => void;
|
|
126
|
+
/** Completed root drag: transfer ownership to the page under the release point. */
|
|
127
|
+
transferDraggedNodes?: (nodes: SceneNode[], before: Map<SceneNode, SerializedNode> | undefined, cssX: number, cssY: number) => boolean;
|
|
126
128
|
}
|
|
127
129
|
/** B3 扩图会话在 pointer 侧的消费面(ExpandSessionController 实现) */
|
|
128
130
|
export interface ExpandSessionHandle {
|
|
@@ -102,6 +102,11 @@ export class TextEditingController {
|
|
|
102
102
|
const s = Math.min(sel.start, sel.end);
|
|
103
103
|
const e = Math.max(sel.start, sel.end);
|
|
104
104
|
const nodeMatrix = node.matrix;
|
|
105
|
+
// 屏幕恒定宽/厚的世界量除数:节点矩阵 x 向线缩放(√(m0²+m1²),旋转载荷下
|
|
106
|
+
// 仍为纯缩放长度)。表格格内编辑 overlay 继承表级 scaleX/scaleY——不除尽
|
|
107
|
+
// 时表放大 N 倍光标屏幕宽随之 N 倍(「合并格输入光标非常粗」报障根因;
|
|
108
|
+
// 合并只是把用户带进格内编辑,普通格同粗)。k=0(退化矩阵)兜 1 防除零
|
|
109
|
+
const nodeScaleX = Math.hypot(nodeMatrix[0], nodeMatrix[1]) || 1;
|
|
105
110
|
const quads = [];
|
|
106
111
|
for (const line of layout.lines) {
|
|
107
112
|
const ls = line.styleMap.flatStart;
|
|
@@ -128,8 +133,9 @@ export class TextEditingController {
|
|
|
128
133
|
const coord = node.cursorCoord(s);
|
|
129
134
|
if (coord) {
|
|
130
135
|
// 屏幕 2px 恒定宽(px/zoom,selectionOverlay 同约定)——不可设世界尺寸
|
|
131
|
-
// 下限:高倍 zoom 下 2/zoom<1 被钳位后屏幕宽 = zoom px
|
|
132
|
-
|
|
136
|
+
// 下限:高倍 zoom 下 2/zoom<1 被钳位后屏幕宽 = zoom px,光标随缩放变粗。
|
|
137
|
+
// 再除节点矩阵缩放:quad 经 nodeMatrix 入屏,缩放不除尽则屏幕宽=2×scaleX
|
|
138
|
+
const caretWidth = 2 / this.host.zoom / nodeScaleX;
|
|
133
139
|
quads.push({
|
|
134
140
|
matrix: multiply(nodeMatrix, [1, 0, 0, 1, coord.x + caretWidth / 2, coord.y + coord.height / 2]),
|
|
135
141
|
dims: { x: caretWidth, y: coord.height },
|
|
@@ -154,7 +160,7 @@ export class TextEditingController {
|
|
|
154
160
|
const underlineY = baselineY + node.textStyle.fontSize * 0.14;
|
|
155
161
|
quads.push({
|
|
156
162
|
matrix: multiply(nodeMatrix, [1, 0, 0, 1, (x0 + x1) / 2, underlineY]),
|
|
157
|
-
dims: { x: Math.max(0, x1 - x0), y: 1.5 / this.host.zoom },
|
|
163
|
+
dims: { x: Math.max(0, x1 - x0), y: 1.5 / this.host.zoom / nodeScaleX },
|
|
158
164
|
color: CARET_COLOR
|
|
159
165
|
});
|
|
160
166
|
}
|