drawui-core 0.3.4 → 0.3.6
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 +365 -6
- package/dist/index.cjs +25 -25
- package/dist/index.d.cts +356 -374
- package/dist/index.d.ts +356 -374
- package/dist/index.js +25 -25
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ interface ShapeStyle {
|
|
|
18
18
|
/** 描边色透明度(0-1),缺省为 1;与 strokeColor 叠加使用 */
|
|
19
19
|
strokeOpacity?: number;
|
|
20
20
|
}
|
|
21
|
-
type ShapeType = 'rectangle' | 'rounded-rectangle' | 'circle' | 'ellipse' | 'diamond' | 'triangle' | 'hexagon' | 'parallelogram' | 'trapezoid' | 'pentagon' | 'octagon' | 'star' | 'cylinder' | 'cloud' | 'heart' | 'block-arrow-right' | 'block-arrow-left' | 'block-arrow-up' | 'block-arrow-down' | 'block-arrow-double' | 'right-triangle' | 'cross' | 'speech-rect' | 'speech-round' | 'cube' | 'sector' | 'delay' | 'predefined-process' | 'document' | 'stadium' | 'class-catalog' | 'chevron' | 'brace-left' | 'brace-right' | 'uml-class' | 'uml-interface' | 'mind-map' | 'line' | 'arrow' | 'text' | 'draw';
|
|
21
|
+
type ShapeType = 'rectangle' | 'rounded-rectangle' | 'circle' | 'ellipse' | 'diamond' | 'triangle' | 'hexagon' | 'parallelogram' | 'trapezoid' | 'pentagon' | 'octagon' | 'star' | 'cylinder' | 'cloud' | 'heart' | 'block-arrow-right' | 'block-arrow-left' | 'block-arrow-up' | 'block-arrow-down' | 'block-arrow-double' | 'right-triangle' | 'cross' | 'speech-rect' | 'speech-round' | 'cube' | 'sector' | 'delay' | 'predefined-process' | 'document' | 'stadium' | 'class-catalog' | 'chevron' | 'brace-left' | 'brace-right' | 'envelope' | 'checkbox' | 'triangular-pyramid' | 'quadrangular-pyramid' | 'cuboid' | 'sphere' | 'ellipsoid' | 'pie' | 'hollow-pie' | 'uml-class' | 'uml-interface' | 'mind-map' | 'line' | 'arrow' | 'text' | 'draw';
|
|
22
22
|
interface BaseShape {
|
|
23
23
|
id: string;
|
|
24
24
|
type: ShapeType;
|
|
@@ -129,7 +129,7 @@ interface StadiumShape extends BaseShape {
|
|
|
129
129
|
* 轮廓定义见 `shapePaths.ts`,canvas 与 SVG 导出共用。
|
|
130
130
|
*/
|
|
131
131
|
interface PathShape extends BaseShape {
|
|
132
|
-
type: 'block-arrow-double' | 'right-triangle' | 'cross' | 'speech-rect' | 'speech-round' | 'cube' | 'sector' | 'delay' | 'predefined-process' | 'document' | 'class-catalog' | 'chevron' | 'brace-left' | 'brace-right';
|
|
132
|
+
type: 'block-arrow-double' | 'right-triangle' | 'cross' | 'speech-rect' | 'speech-round' | 'cube' | 'sector' | 'delay' | 'predefined-process' | 'document' | 'class-catalog' | 'chevron' | 'brace-left' | 'brace-right' | 'envelope' | 'checkbox' | 'triangular-pyramid' | 'quadrangular-pyramid' | 'cuboid' | 'sphere' | 'ellipsoid' | 'pie' | 'hollow-pie';
|
|
133
133
|
width: number;
|
|
134
134
|
height: number;
|
|
135
135
|
}
|
|
@@ -176,6 +176,8 @@ interface LineShape extends BaseShape {
|
|
|
176
176
|
type: 'line';
|
|
177
177
|
points: Vec2[];
|
|
178
178
|
connectionType?: ConnectionType;
|
|
179
|
+
/** 用户手工调节过的中间折点(世界坐标),见 ArrowShape.userPoints */
|
|
180
|
+
userPoints?: Vec2[];
|
|
179
181
|
}
|
|
180
182
|
type ConnectionType = 'straight' | 'polyline' | 'orthogonal' | 'curve';
|
|
181
183
|
/** 生成点位创建上下文:from 为源点(生成点位),to 为目标落点 */
|
|
@@ -242,6 +244,14 @@ interface ArrowShape extends BaseShape {
|
|
|
242
244
|
connectionType?: ConnectionType;
|
|
243
245
|
arrowHead?: ArrowHeadType;
|
|
244
246
|
dashed?: boolean;
|
|
247
|
+
/**
|
|
248
|
+
* 用户手工调节过的中间折点(**世界坐标**,不含两端)。
|
|
249
|
+
*
|
|
250
|
+
* 飞书式「选中连线 → 拖动线段上的手柄调整走线位置」写的就是它:
|
|
251
|
+
* 存在时走线 = 起点 → userPoints… → 终点(每一段仍是正交的),
|
|
252
|
+
* 两端依旧跟随绑定(拖动图形后两端自动跟上,中间保持用户摆好的位置)。
|
|
253
|
+
*/
|
|
254
|
+
userPoints?: Vec2[];
|
|
245
255
|
}
|
|
246
256
|
interface TextShape extends BaseShape {
|
|
247
257
|
type: 'text';
|
|
@@ -280,7 +290,7 @@ interface MindMapShape extends BaseShape {
|
|
|
280
290
|
root: MindMapNode;
|
|
281
291
|
}
|
|
282
292
|
type Shape = RectangleShape | RoundedRectangleShape | CircleShape | EllipseShape | DiamondShape | TriangleShape | HexagonShape | ParallelogramShape | TrapezoidShape | PentagonShape | OctagonShape | StarShape | CylinderShape | CloudShape | HeartShape | BlockArrowShape | StadiumShape | PathShape | UmlClassShape | UmlInterfaceShape | LineShape | ArrowShape | TextShape | DrawShape | MindMapShape;
|
|
283
|
-
type ToolType = 'select' | 'hand' | 'rectangle' | 'rounded-rectangle' | 'circle' | 'ellipse' | 'diamond' | 'triangle' | 'hexagon' | 'parallelogram' | 'trapezoid' | 'pentagon' | 'octagon' | 'star' | 'cylinder' | 'cloud' | 'heart' | 'block-arrow-right' | 'block-arrow-left' | 'block-arrow-up' | 'block-arrow-down' | 'block-arrow-double' | 'right-triangle' | 'cross' | 'speech-rect' | 'speech-round' | 'cube' | 'sector' | 'delay' | 'predefined-process' | 'document' | 'stadium' | 'class-catalog' | 'chevron' | 'brace-left' | 'brace-right' | 'uml-class' | 'uml-interface' | 'line' | 'arrow' | 'text' | 'draw' | 'pen' | 'highlighter' | 'eraser' | 'mind-map';
|
|
293
|
+
type ToolType = 'select' | 'hand' | 'rectangle' | 'rounded-rectangle' | 'circle' | 'ellipse' | 'diamond' | 'triangle' | 'hexagon' | 'parallelogram' | 'trapezoid' | 'pentagon' | 'octagon' | 'star' | 'cylinder' | 'cloud' | 'heart' | 'block-arrow-right' | 'block-arrow-left' | 'block-arrow-up' | 'block-arrow-down' | 'block-arrow-double' | 'right-triangle' | 'cross' | 'speech-rect' | 'speech-round' | 'cube' | 'sector' | 'delay' | 'predefined-process' | 'document' | 'stadium' | 'class-catalog' | 'chevron' | 'brace-left' | 'brace-right' | 'envelope' | 'checkbox' | 'triangular-pyramid' | 'quadrangular-pyramid' | 'cuboid' | 'sphere' | 'ellipsoid' | 'pie' | 'hollow-pie' | 'uml-class' | 'uml-interface' | 'line' | 'arrow' | 'text' | 'draw' | 'pen' | 'highlighter' | 'eraser' | 'mind-map';
|
|
284
294
|
interface CameraState {
|
|
285
295
|
x: number;
|
|
286
296
|
y: number;
|
|
@@ -401,338 +411,188 @@ declare function shadeColor(hex: string, percent: number): string;
|
|
|
401
411
|
* 国际化:框架无关的轻量字典 + 语言切换。
|
|
402
412
|
* React 侧通过 useLanguage() 订阅语言变化自动重渲染。
|
|
403
413
|
*/
|
|
404
|
-
type Language = 'zh-CN' | 'en-US';
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
readonly '
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
readonly 'tool.pentagon': "Pentagon";
|
|
585
|
-
readonly 'tool.octagon': "Octagon";
|
|
586
|
-
readonly 'tool.star': "Star";
|
|
587
|
-
readonly 'tool.cylinder': "Cylinder";
|
|
588
|
-
readonly 'tool.cloud': "Cloud";
|
|
589
|
-
readonly 'tool.heart': "Heart";
|
|
590
|
-
readonly 'tool.block-arrow-right': "Arrow right";
|
|
591
|
-
readonly 'tool.block-arrow-left': "Arrow left";
|
|
592
|
-
readonly 'tool.block-arrow-up': "Arrow up";
|
|
593
|
-
readonly 'tool.block-arrow-down': "Arrow down";
|
|
594
|
-
readonly 'tool.block-arrow-double': "Double arrow";
|
|
595
|
-
readonly 'tool.right-triangle': "Right triangle";
|
|
596
|
-
readonly 'tool.cross': "Cross";
|
|
597
|
-
readonly 'tool.speech-rect': "Speech bubble";
|
|
598
|
-
readonly 'tool.speech-round': "Round bubble";
|
|
599
|
-
readonly 'tool.cube': "Cube";
|
|
600
|
-
readonly 'tool.sector': "Sector";
|
|
601
|
-
readonly 'tool.delay': "Delay";
|
|
602
|
-
readonly 'tool.predefined-process': "Predefined process";
|
|
603
|
-
readonly 'tool.document': "Document";
|
|
604
|
-
readonly 'tool.stadium': "Stadium";
|
|
605
|
-
readonly 'tool.class-catalog': "Category";
|
|
606
|
-
readonly 'class.plain': "Class";
|
|
607
|
-
readonly 'flow.process': "Process";
|
|
608
|
-
readonly 'flow.step': "Step";
|
|
609
|
-
readonly 'flow.startEnd': "Start / End";
|
|
610
|
-
readonly 'flow.decision': "Decision";
|
|
611
|
-
readonly 'flow.data': "Data";
|
|
612
|
-
readonly 'flow.manual': "Manual operation";
|
|
613
|
-
readonly 'flow.preparation': "Preparation";
|
|
614
|
-
readonly 'flow.database': "Database";
|
|
615
|
-
readonly 'flow.delay': "Delay";
|
|
616
|
-
readonly 'shapeGroup.basic': "Basic";
|
|
617
|
-
readonly 'shapeGroup.flowchart': "Flowchart";
|
|
618
|
-
readonly 'shapeGroup.other': "Other";
|
|
619
|
-
readonly 'shapeGroup.uml': "Class diagram";
|
|
620
|
-
readonly 'shapeMenu.hint': "Hover to see name";
|
|
621
|
-
readonly 'tool.chevron': "Chevron";
|
|
622
|
-
readonly 'tool.brace-left': "Left brace";
|
|
623
|
-
readonly 'tool.brace-right': "Right brace";
|
|
624
|
-
readonly 'tool.uml-class': "UML class";
|
|
625
|
-
readonly 'tool.uml-interface': "UML interface";
|
|
626
|
-
readonly 'tool.line': "Line";
|
|
627
|
-
readonly 'tool.arrow': "Line";
|
|
628
|
-
readonly 'tool.text': "Text";
|
|
629
|
-
readonly 'tool.draw': "Pen";
|
|
630
|
-
readonly 'tool.pen': "Pen";
|
|
631
|
-
readonly 'tool.highlighter': "Highlighter";
|
|
632
|
-
readonly 'tool.eraser': "Eraser";
|
|
633
|
-
readonly 'status.none': "Nothing selected";
|
|
634
|
-
readonly 'status.selected': "{n} shapes selected";
|
|
635
|
-
readonly 'toolbar.select': "Select (V)";
|
|
636
|
-
readonly 'toolbar.hand': "Pan view (H)";
|
|
637
|
-
readonly 'toolbar.shapes': "Shapes";
|
|
638
|
-
readonly 'toolbar.grid': "Grid";
|
|
639
|
-
readonly 'toolbar.undo': "Undo (Ctrl+Z)";
|
|
640
|
-
readonly 'toolbar.redo': "Redo (Ctrl+Shift+Z)";
|
|
641
|
-
readonly 'toolbar.arrow': "Arrow";
|
|
642
|
-
readonly 'toolbar.text': "Text";
|
|
643
|
-
readonly 'toolbar.pen': "Pen";
|
|
644
|
-
readonly 'toolbar.highlighter': "Highlighter";
|
|
645
|
-
readonly 'toolbar.eraser': "Eraser";
|
|
646
|
-
readonly 'toolbar.uml-class': "UML class";
|
|
647
|
-
readonly 'toolbar.uml-interface': "UML interface";
|
|
648
|
-
readonly 'zoom.in': "Zoom in";
|
|
649
|
-
readonly 'zoom.out': "Zoom out";
|
|
650
|
-
readonly 'zoom.reset': "Reset";
|
|
651
|
-
readonly 'style.stroke': "Border";
|
|
652
|
-
readonly 'style.line': "Line";
|
|
653
|
-
readonly 'style.fill': "Fill";
|
|
654
|
-
readonly 'style.text': "Text";
|
|
655
|
-
readonly 'style.highlight': "Highlight";
|
|
656
|
-
readonly 'style.prefix': "Prefix";
|
|
657
|
-
readonly 'style.prefix.soon': "Prefix symbols are coming soon";
|
|
658
|
-
readonly 'style.none': "None";
|
|
659
|
-
readonly 'style.addColor': "Add color";
|
|
660
|
-
readonly 'style.connection': "Connection";
|
|
661
|
-
readonly 'style.arrow': "Arrow head";
|
|
662
|
-
readonly 'style.dashed': "Dashed";
|
|
663
|
-
readonly 'style.solid': "Solid";
|
|
664
|
-
readonly 'style.opacity': "Opacity";
|
|
665
|
-
readonly 'style.connection.straight': "Straight";
|
|
666
|
-
readonly 'style.connection.polyline': "Polyline";
|
|
667
|
-
readonly 'style.connection.orthogonal': "Orthogonal";
|
|
668
|
-
readonly 'style.connection.curve': "Curve";
|
|
669
|
-
readonly 'style.arrowhead.none': "None";
|
|
670
|
-
readonly 'style.arrowhead.end': "End";
|
|
671
|
-
readonly 'style.arrowhead.start': "Start";
|
|
672
|
-
readonly 'style.arrowhead.both': "Both";
|
|
673
|
-
readonly 'style.arrowhead.none-dashed': "Dashed";
|
|
674
|
-
readonly 'style.arrowhead.both-dashed': "Dashed both";
|
|
675
|
-
readonly 'style.uml': "UML";
|
|
676
|
-
readonly 'style.arrowhead.inheritance': "Inheritance";
|
|
677
|
-
readonly 'style.arrowhead.composition': "Composition";
|
|
678
|
-
readonly 'style.arrowhead.aggregation': "Aggregation";
|
|
679
|
-
readonly 'style.arrowhead.dependency': "Dependency";
|
|
680
|
-
readonly 'style.arrowhead.realization': "Realization";
|
|
681
|
-
readonly 'menu.title': "Create shape";
|
|
682
|
-
readonly 'menu.cancel': "Click empty space to cancel";
|
|
683
|
-
readonly 'shape.rectangle': "Rectangle";
|
|
684
|
-
readonly 'shape.rounded-rectangle': "Rounded";
|
|
685
|
-
readonly 'shape.circle': "Circle";
|
|
686
|
-
readonly 'shape.ellipse': "Ellipse";
|
|
687
|
-
readonly 'shape.diamond': "Diamond";
|
|
688
|
-
readonly 'shape.triangle': "Triangle";
|
|
689
|
-
readonly 'shape.hexagon': "Hexagon";
|
|
690
|
-
readonly 'shape.parallelogram': "Parallelogram";
|
|
691
|
-
readonly 'shape.trapezoid': "Trapezoid";
|
|
692
|
-
readonly 'shape.pentagon': "Pentagon";
|
|
693
|
-
readonly 'shape.octagon': "Octagon";
|
|
694
|
-
readonly 'shape.star': "Star";
|
|
695
|
-
readonly 'shape.uml-class': "Class";
|
|
696
|
-
readonly 'shape.uml-interface': "Interface";
|
|
697
|
-
readonly 'uml.drag': "Drag to reorder";
|
|
698
|
-
readonly 'uml.delete': "Delete row";
|
|
699
|
-
readonly 'uml.textColor': "Text color";
|
|
700
|
-
readonly 'uml.defaultColor': "Default color";
|
|
701
|
-
readonly 'uml.fontSize': "Font size";
|
|
702
|
-
readonly 'uml.strikethrough': "Strikethrough";
|
|
703
|
-
readonly 'uml.attribute': "Attributes";
|
|
704
|
-
readonly 'uml.method': "Methods";
|
|
705
|
-
readonly 'minimap.title': "Minimap";
|
|
706
|
-
readonly 'minimap.expand': "Expand minimap";
|
|
707
|
-
readonly 'minimap.collapse': "Collapse minimap";
|
|
708
|
-
readonly 'tool.mind-map': "Mind map";
|
|
709
|
-
readonly 'toolbar.mind-map': "Mind map";
|
|
710
|
-
readonly 'toolbar.export': "Export";
|
|
711
|
-
readonly 'toolbar.export.png': "PNG image";
|
|
712
|
-
readonly 'toolbar.export.svg': "SVG vector";
|
|
713
|
-
readonly 'toolbar.export.pdf': "PDF document";
|
|
714
|
-
readonly 'shape.mind-map': "Mind map";
|
|
715
|
-
readonly 'mindmap.defaultRoot': "Central topic";
|
|
716
|
-
readonly 'mindmap.defaultBranch': "Branch topic";
|
|
717
|
-
readonly 'mindmap.nodeText': "Node text";
|
|
718
|
-
readonly 'mindmap.addChild': "Child";
|
|
719
|
-
readonly 'mindmap.addSibling': "Sibling";
|
|
720
|
-
readonly 'mindmap.deleteNode': "Delete node";
|
|
721
|
-
readonly 'mindmap.color': "Color";
|
|
722
|
-
readonly 'mindmap.levelColor': "Default level color";
|
|
723
|
-
readonly 'mindmap.icon': "Icon";
|
|
724
|
-
readonly 'mindmap.noIcon': "No icon";
|
|
725
|
-
readonly 'mindmap.note': "Note";
|
|
726
|
-
readonly 'mindmap.notePlaceholder': "Note content (optional)";
|
|
727
|
-
readonly 'mindmap.noteColor': "Note color";
|
|
728
|
-
readonly 'mindmap.noteColorDefault': "Same as node";
|
|
729
|
-
readonly 'mindmap.collapse': "Collapse";
|
|
730
|
-
readonly 'mindmap.expand': "Expand";
|
|
731
|
-
readonly 'mindmap.close': "Close editor";
|
|
732
|
-
readonly 'mindmap.more': "More settings";
|
|
733
|
-
};
|
|
414
|
+
type Language = 'zh-CN' | 'zh-TW' | 'en-US' | 'ja-JP' | 'ko-KR' | 'de-DE' | 'fr-FR';
|
|
415
|
+
/** 已支持的语言清单(code + 本族语名称),方便宿主直接用来渲染语言切换 UI */
|
|
416
|
+
declare const LANGUAGES: {
|
|
417
|
+
code: Language;
|
|
418
|
+
label: string;
|
|
419
|
+
}[];
|
|
420
|
+
/** 简体中文为基准字典:其 key 集合即是 MessageKey 的唯一来源 */
|
|
421
|
+
declare const zhCN: {
|
|
422
|
+
readonly 'save.success': "已保存";
|
|
423
|
+
readonly 'save.fail': "保存失败";
|
|
424
|
+
readonly 'tool.select': "选择工具";
|
|
425
|
+
readonly 'tool.hand': "拖拽视口";
|
|
426
|
+
readonly 'tool.rectangle': "矩形";
|
|
427
|
+
readonly 'tool.rounded-rectangle': "圆角矩形";
|
|
428
|
+
readonly 'tool.circle': "圆形";
|
|
429
|
+
readonly 'tool.ellipse': "椭圆";
|
|
430
|
+
readonly 'tool.diamond': "菱形";
|
|
431
|
+
readonly 'tool.triangle': "三角形";
|
|
432
|
+
readonly 'tool.hexagon': "六边形";
|
|
433
|
+
readonly 'tool.parallelogram': "平行四边形";
|
|
434
|
+
readonly 'tool.trapezoid': "梯形";
|
|
435
|
+
readonly 'tool.pentagon': "五边形";
|
|
436
|
+
readonly 'tool.octagon': "八边形";
|
|
437
|
+
readonly 'tool.star': "星形";
|
|
438
|
+
readonly 'tool.cylinder': "圆柱体";
|
|
439
|
+
readonly 'tool.cloud': "云形";
|
|
440
|
+
readonly 'tool.heart': "心形";
|
|
441
|
+
readonly 'tool.block-arrow-right': "右箭头";
|
|
442
|
+
readonly 'tool.block-arrow-left': "左箭头";
|
|
443
|
+
readonly 'tool.block-arrow-up': "上箭头";
|
|
444
|
+
readonly 'tool.block-arrow-down': "下箭头";
|
|
445
|
+
readonly 'tool.block-arrow-double': "双向箭头";
|
|
446
|
+
readonly 'tool.right-triangle': "直角三角形";
|
|
447
|
+
readonly 'tool.cross': "十字";
|
|
448
|
+
readonly 'tool.speech-rect': "方形对话框";
|
|
449
|
+
readonly 'tool.speech-round': "圆形对话框";
|
|
450
|
+
readonly 'tool.cube': "立方体";
|
|
451
|
+
readonly 'tool.sector': "扇形";
|
|
452
|
+
readonly 'tool.delay': "D 形";
|
|
453
|
+
readonly 'tool.predefined-process': "预定义流程";
|
|
454
|
+
readonly 'tool.document': "文档";
|
|
455
|
+
readonly 'tool.stadium': "全圆角矩形";
|
|
456
|
+
readonly 'tool.class-catalog': "类目";
|
|
457
|
+
readonly 'tool.envelope': "信封";
|
|
458
|
+
readonly 'tool.checkbox': "复选框";
|
|
459
|
+
readonly 'tool.triangular-pyramid': "三棱锥";
|
|
460
|
+
readonly 'tool.quadrangular-pyramid': "四棱锥";
|
|
461
|
+
readonly 'tool.cuboid': "长方体";
|
|
462
|
+
readonly 'tool.sphere': "球";
|
|
463
|
+
readonly 'tool.ellipsoid': "椭球";
|
|
464
|
+
readonly 'tool.pie': "饼状";
|
|
465
|
+
readonly 'tool.hollow-pie': "空心饼状";
|
|
466
|
+
readonly 'class.plain': "类";
|
|
467
|
+
readonly 'flow.process': "处理";
|
|
468
|
+
readonly 'flow.step': "流程";
|
|
469
|
+
readonly 'flow.startEnd': "开始/结束";
|
|
470
|
+
readonly 'flow.decision': "判定";
|
|
471
|
+
readonly 'flow.data': "数据";
|
|
472
|
+
readonly 'flow.manual': "手动操作";
|
|
473
|
+
readonly 'flow.preparation': "准备";
|
|
474
|
+
readonly 'flow.database': "数据库";
|
|
475
|
+
readonly 'flow.delay': "延时";
|
|
476
|
+
readonly 'shapeGroup.basic': "基础";
|
|
477
|
+
readonly 'shapeGroup.flowchart': "流程图";
|
|
478
|
+
readonly 'shapeGroup.other': "其他";
|
|
479
|
+
readonly 'shapeGroup.solid': "立体";
|
|
480
|
+
readonly 'shapeGroup.uml': "类图";
|
|
481
|
+
readonly 'shapeMenu.hint': "悬停查看名称";
|
|
482
|
+
readonly 'tool.chevron': "尖角";
|
|
483
|
+
readonly 'tool.brace-left': "左括号";
|
|
484
|
+
readonly 'tool.brace-right': "右括号";
|
|
485
|
+
readonly 'tool.uml-class': "UML 类图";
|
|
486
|
+
readonly 'tool.uml-interface': "UML 接口";
|
|
487
|
+
readonly 'tool.line': "直线";
|
|
488
|
+
readonly 'tool.arrow': "线条";
|
|
489
|
+
readonly 'tool.text': "文本";
|
|
490
|
+
readonly 'tool.draw': "画笔";
|
|
491
|
+
readonly 'tool.pen': "画笔";
|
|
492
|
+
readonly 'tool.highlighter': "荧光笔";
|
|
493
|
+
readonly 'tool.eraser': "橡皮擦";
|
|
494
|
+
readonly 'status.none': "未选择";
|
|
495
|
+
readonly 'status.selected': "已选择 {n} 个图形";
|
|
496
|
+
readonly 'toolbar.select': "选择 (V)";
|
|
497
|
+
readonly 'toolbar.hand': "拖拽视口 (H)";
|
|
498
|
+
readonly 'toolbar.shapes': "形状";
|
|
499
|
+
readonly 'toolbar.grid': "网格";
|
|
500
|
+
readonly 'toolbar.undo': "撤销 (Ctrl+Z)";
|
|
501
|
+
readonly 'toolbar.redo': "重做 (Ctrl+Shift+Z)";
|
|
502
|
+
readonly 'toolbar.arrow': "箭头";
|
|
503
|
+
readonly 'toolbar.text': "文本";
|
|
504
|
+
readonly 'toolbar.pen': "画笔";
|
|
505
|
+
readonly 'toolbar.highlighter': "荧光笔";
|
|
506
|
+
readonly 'toolbar.eraser': "橡皮擦";
|
|
507
|
+
readonly 'toolbar.uml-class': "UML 类图";
|
|
508
|
+
readonly 'toolbar.uml-interface': "UML 接口";
|
|
509
|
+
readonly 'zoom.in': "放大";
|
|
510
|
+
readonly 'zoom.out': "缩小";
|
|
511
|
+
readonly 'zoom.reset': "重置";
|
|
512
|
+
readonly 'style.stroke': "边框";
|
|
513
|
+
readonly 'style.line': "线条";
|
|
514
|
+
readonly 'style.fill': "填充";
|
|
515
|
+
readonly 'style.text': "文字";
|
|
516
|
+
readonly 'style.highlight': "高亮";
|
|
517
|
+
readonly 'style.prefix': "前缀符号";
|
|
518
|
+
readonly 'style.prefix.soon': "前缀符号开发中,敬请期待";
|
|
519
|
+
readonly 'style.none': "无";
|
|
520
|
+
readonly 'style.addColor': "添加颜色";
|
|
521
|
+
readonly 'style.connection': "连线";
|
|
522
|
+
readonly 'style.arrow': "箭头";
|
|
523
|
+
readonly 'style.dashed': "虚线";
|
|
524
|
+
readonly 'style.solid': "实线";
|
|
525
|
+
readonly 'style.opacity': "不透明度";
|
|
526
|
+
readonly 'style.connection.straight': "直线";
|
|
527
|
+
readonly 'style.connection.polyline': "折线";
|
|
528
|
+
readonly 'style.connection.orthogonal': "直角折线";
|
|
529
|
+
readonly 'style.connection.curve': "曲线";
|
|
530
|
+
readonly 'style.arrowhead.none': "无箭头";
|
|
531
|
+
readonly 'style.arrowhead.end': "终点箭头";
|
|
532
|
+
readonly 'style.arrowhead.start': "起点箭头";
|
|
533
|
+
readonly 'style.arrowhead.both': "双箭头";
|
|
534
|
+
readonly 'style.arrowhead.none-dashed': "无箭头虚线";
|
|
535
|
+
readonly 'style.arrowhead.both-dashed': "双箭头虚线";
|
|
536
|
+
readonly 'style.uml': "UML";
|
|
537
|
+
readonly 'style.arrowhead.inheritance': "继承";
|
|
538
|
+
readonly 'style.arrowhead.composition': "组合";
|
|
539
|
+
readonly 'style.arrowhead.aggregation': "聚合";
|
|
540
|
+
readonly 'style.arrowhead.dependency': "依赖";
|
|
541
|
+
readonly 'style.arrowhead.realization': "实现";
|
|
542
|
+
readonly 'menu.title': "选择新图形";
|
|
543
|
+
readonly 'menu.cancel': "点击空白处取消";
|
|
544
|
+
readonly 'shape.rectangle': "矩形";
|
|
545
|
+
readonly 'shape.rounded-rectangle': "圆角";
|
|
546
|
+
readonly 'shape.circle': "圆形";
|
|
547
|
+
readonly 'shape.ellipse': "椭圆";
|
|
548
|
+
readonly 'shape.diamond': "菱形";
|
|
549
|
+
readonly 'shape.triangle': "三角";
|
|
550
|
+
readonly 'shape.hexagon': "六边形";
|
|
551
|
+
readonly 'shape.parallelogram': "平行";
|
|
552
|
+
readonly 'shape.trapezoid': "梯形";
|
|
553
|
+
readonly 'shape.pentagon': "五边形";
|
|
554
|
+
readonly 'shape.octagon': "八边形";
|
|
555
|
+
readonly 'shape.star': "星形";
|
|
556
|
+
readonly 'shape.uml-class': "类图";
|
|
557
|
+
readonly 'shape.uml-interface': "接口";
|
|
558
|
+
readonly 'uml.drag': "拖拽排序";
|
|
559
|
+
readonly 'uml.delete': "删除该行";
|
|
560
|
+
readonly 'uml.textColor': "文字颜色";
|
|
561
|
+
readonly 'uml.defaultColor': "默认颜色";
|
|
562
|
+
readonly 'uml.fontSize': "字号";
|
|
563
|
+
readonly 'uml.strikethrough': "删除线";
|
|
564
|
+
readonly 'uml.attribute': "属性";
|
|
565
|
+
readonly 'uml.method': "方法";
|
|
566
|
+
readonly 'minimap.title': "小地图";
|
|
567
|
+
readonly 'minimap.expand': "展开小地图";
|
|
568
|
+
readonly 'minimap.collapse': "收起小地图";
|
|
569
|
+
readonly 'tool.mind-map': "思维导图";
|
|
570
|
+
readonly 'toolbar.mind-map': "思维导图";
|
|
571
|
+
readonly 'toolbar.export': "导出";
|
|
572
|
+
readonly 'toolbar.export.png': "PNG 图片";
|
|
573
|
+
readonly 'toolbar.export.svg': "SVG 矢量图";
|
|
574
|
+
readonly 'toolbar.export.pdf': "PDF 文档";
|
|
575
|
+
readonly 'shape.mind-map': "思维导图";
|
|
576
|
+
readonly 'mindmap.defaultRoot': "中心主题";
|
|
577
|
+
readonly 'mindmap.defaultBranch': "分支主题";
|
|
578
|
+
readonly 'mindmap.nodeText': "节点文本";
|
|
579
|
+
readonly 'mindmap.addChild': "子节点";
|
|
580
|
+
readonly 'mindmap.addSibling': "兄弟节点";
|
|
581
|
+
readonly 'mindmap.deleteNode': "删除节点";
|
|
582
|
+
readonly 'mindmap.color': "颜色";
|
|
583
|
+
readonly 'mindmap.levelColor': "默认层级色";
|
|
584
|
+
readonly 'mindmap.icon': "图标";
|
|
585
|
+
readonly 'mindmap.noIcon': "无图标";
|
|
586
|
+
readonly 'mindmap.note': "属性说明";
|
|
587
|
+
readonly 'mindmap.notePlaceholder': "说明内容(可选)";
|
|
588
|
+
readonly 'mindmap.noteColor': "说明颜色";
|
|
589
|
+
readonly 'mindmap.noteColorDefault': "同节点色";
|
|
590
|
+
readonly 'mindmap.collapse': "折叠";
|
|
591
|
+
readonly 'mindmap.expand': "展开";
|
|
592
|
+
readonly 'mindmap.close': "关闭编辑";
|
|
593
|
+
readonly 'mindmap.more': "更多设置";
|
|
734
594
|
};
|
|
735
|
-
type MessageKey = keyof typeof
|
|
595
|
+
type MessageKey = keyof typeof zhCN;
|
|
736
596
|
type LanguageListener = () => void;
|
|
737
597
|
declare function setLanguage(language: Language): void;
|
|
738
598
|
declare function getLanguage(): Language;
|
|
@@ -816,6 +676,7 @@ declare class Editor {
|
|
|
816
676
|
private connectingTargetId;
|
|
817
677
|
private genPreview;
|
|
818
678
|
private hoverAnchorShapeId;
|
|
679
|
+
private hoverConnectorId;
|
|
819
680
|
private eraserPoint;
|
|
820
681
|
private mindMapEditingShapeId;
|
|
821
682
|
private mindMapSelectedNode;
|
|
@@ -878,6 +739,13 @@ declare class Editor {
|
|
|
878
739
|
private setGenerationPreview;
|
|
879
740
|
/** 设置悬停图形(画布为其绘制四边连接锚点) */
|
|
880
741
|
private setHoverAnchorShape;
|
|
742
|
+
/** 设置悬停连线(画布为整条线描一层高亮) */
|
|
743
|
+
private setHoverConnector;
|
|
744
|
+
/**
|
|
745
|
+
* 某条连线当前的真实走线(世界坐标折点)。
|
|
746
|
+
* 交给工具层做线段手柄的命中与拖动 —— 用的是渲染器同一套计算,保证「看到哪就能拖哪」。
|
|
747
|
+
*/
|
|
748
|
+
private getConnectorRoute;
|
|
881
749
|
/**
|
|
882
750
|
* 清掉所有「瞬态」的交互可视化状态:连线预览、目标高亮、对齐参考线、框选、悬停锚点。
|
|
883
751
|
* 这些状态只在一次交互过程中有效 —— 只要交互结束(或事件丢失)就必须清空,
|
|
@@ -1130,6 +998,69 @@ declare class Editor {
|
|
|
1130
998
|
dispose(): void;
|
|
1131
999
|
}
|
|
1132
1000
|
|
|
1001
|
+
/**
|
|
1002
|
+
* 连线「手工调线段」的纯几何(飞书式交互的数学部分,不含任何画布/编辑器依赖)。
|
|
1003
|
+
*
|
|
1004
|
+
* 交互模型:选中一条连线 → 在每一段(够长的)线段的**中点**画一个小手柄 →
|
|
1005
|
+
* 拖动它就把这一段沿垂直方向平移,相邻的垂直段自然伸缩,整条线始终横平竖直;
|
|
1006
|
+
* 两端的停靠点/端点**永远不动**,必要时在端点旁补一个折点(这就是飞书里
|
|
1007
|
+
* 「拖中间那段会让线在两端各拐一下」的效果)。
|
|
1008
|
+
*
|
|
1009
|
+
* 结果写回 `ArrowShape.userPoints` / `LineShape.userPoints`(世界坐标,不含两端)。
|
|
1010
|
+
*/
|
|
1011
|
+
/**
|
|
1012
|
+
* 短于这个长度的线段不生成手柄(太短的段拖不动、手柄比线还长也没意义,飞书同样会略过)。
|
|
1013
|
+
* 取 40:既排除「端点旁自动补出来的 24px 桩」,也放过那些只有几十像素、一拖就糊成一团的短段。
|
|
1014
|
+
*/
|
|
1015
|
+
declare const MIN_HANDLE_SEGMENT = 40;
|
|
1016
|
+
/**
|
|
1017
|
+
* 台阶的最小高度(磁吸半径)。
|
|
1018
|
+
*
|
|
1019
|
+
* 拖动一段时,只要平移后的位置落进相邻水平线的这个范围内,就**直接吸回那条线**
|
|
1020
|
+
* (=把台阶抹平)。于是:
|
|
1021
|
+
* - 拖不出 1~19px 的浅台阶 —— 那种「两条平行线贴在一起」的观感就是用户说的「变成两条线段」;
|
|
1022
|
+
* - 已经存在的浅台阶,往基线方向一拖就自动抹平(不会出现「拖不动、回不去」);
|
|
1023
|
+
* - 想真正折出台阶,明确拖过这个距离即可(超过就按实际位置走,不再吸附)。
|
|
1024
|
+
*/
|
|
1025
|
+
declare const MIN_JOG = 20;
|
|
1026
|
+
interface SegmentHandle {
|
|
1027
|
+
/** 线段序号:route[index] → route[index + 1] */
|
|
1028
|
+
index: number;
|
|
1029
|
+
/** 手柄中心(世界坐标)= 线段中点 */
|
|
1030
|
+
center: Vec2;
|
|
1031
|
+
/** 线段轴向:'H' 水平(可上下拖)/ 'V' 垂直(可左右拖) */
|
|
1032
|
+
axis: 'H' | 'V';
|
|
1033
|
+
/** 线段长度 */
|
|
1034
|
+
length: number;
|
|
1035
|
+
}
|
|
1036
|
+
/** 点到线段的最短距离(连线命中、手柄命中共用;SelectTool 也委托到这里) */
|
|
1037
|
+
declare function pointToSegmentDistance(point: Vec2, a: Vec2, b: Vec2): number;
|
|
1038
|
+
/** 一条走线(世界坐标折线)上所有可拖动的线段手柄 */
|
|
1039
|
+
declare function connectorSegmentHandles(route: Vec2[], minLength?: number): SegmentHandle[];
|
|
1040
|
+
/**
|
|
1041
|
+
* 命中要拖动的线段:优先「手柄中心 handleRadius 内」;没直接命中就给一次宽容 ——
|
|
1042
|
+
* 取离得最近的、够长可拖的那一段(点到该段距离 ≤ maxSegmentDist)。
|
|
1043
|
+
*
|
|
1044
|
+
* 这样「抓在选中连线的任意位置上」都能拖到最近的那段,也让「抓线段」优先于
|
|
1045
|
+
* 拖整条线/从锚点拉新线 —— 避免在连线上按一下却拉出一条新线。
|
|
1046
|
+
*/
|
|
1047
|
+
declare function pickSegmentHandle(route: Vec2[], point: Vec2, handleRadius?: number, maxSegmentDist?: number): SegmentHandle | null;
|
|
1048
|
+
/**
|
|
1049
|
+
* 把第 index 段沿其垂直方向平移 delta(水平段:>0 = 向下;垂直段:>0 = 向右),
|
|
1050
|
+
* 返回平移后的**新走线**(首尾点保持不变)。
|
|
1051
|
+
*
|
|
1052
|
+
* 传入的 route 应当始终是「按下时的那条走线」,每次移动都从它重新算 —— 因为拖首/末段
|
|
1053
|
+
* 会插入折点、段序号会变,从原始走线重算才能得到稳定(不漂移)的结果。
|
|
1054
|
+
*/
|
|
1055
|
+
declare function offsetConnectorSegment(route: Vec2[], index: number, delta: number): Vec2[];
|
|
1056
|
+
/**
|
|
1057
|
+
* 去掉连续重复点与共线冗余点,精简冗余拐点。
|
|
1058
|
+
* (唯一实现:Renderer.collapseLinePoints 与交互层写回前都调它 —— 别再各写一份)
|
|
1059
|
+
*/
|
|
1060
|
+
declare function collapseRoute(pts: Vec2[]): Vec2[];
|
|
1061
|
+
/** 走线 → 可写回 shape 的中间折点(去掉两端) */
|
|
1062
|
+
declare function routeToUserPoints(route: Vec2[]): Vec2[];
|
|
1063
|
+
|
|
1133
1064
|
interface SnapGuide {
|
|
1134
1065
|
type: 'horizontal' | 'vertical';
|
|
1135
1066
|
position: number;
|
|
@@ -1163,7 +1094,9 @@ declare class Renderer {
|
|
|
1163
1094
|
/** 导出用:非 null 时先以该颜色铺满整块画布(白底等),默认不铺(透明) */
|
|
1164
1095
|
background?: string | null,
|
|
1165
1096
|
/** 悬停的图形 id:为其绘制四边连接锚点(飞书式悬浮提示),已选中图形由选择手柄负责 */
|
|
1166
|
-
hoverAnchorShapeId?: string | null
|
|
1097
|
+
hoverAnchorShapeId?: string | null,
|
|
1098
|
+
/** 悬停的连线 id:整条线描一层浅蓝高亮(提示「这条线可点、点开能调线段」) */
|
|
1099
|
+
hoverConnectorId?: string | null): void;
|
|
1167
1100
|
/** 橡皮擦:半透明主色圆 + 主色描边,半径与笔刷命中范围一致(屏幕像素恒定) */
|
|
1168
1101
|
private drawEraserBrush;
|
|
1169
1102
|
/** 连接进行中,高亮目标图形四边中点的可连锚点 */
|
|
@@ -1206,12 +1139,8 @@ declare class Renderer {
|
|
|
1206
1139
|
private drawUmlInterface;
|
|
1207
1140
|
/** 默认拐点圆角半径(页面坐标) */
|
|
1208
1141
|
private static readonly DEFAULT_CORNER_RADIUS;
|
|
1209
|
-
/** 连线与图形之间保留的最小避障间距,避免线条贴边/粘在图形上 */
|
|
1210
|
-
private static readonly ROUTE_CLEARANCE;
|
|
1211
1142
|
/** 连接点处的垂直出线桩长度:第一段垂直脱离图形边缘,避免贴角/贴边 */
|
|
1212
1143
|
private static readonly CONNECTION_LEAD;
|
|
1213
|
-
/** 连接的源/目标图形作为障碍时使用的避让间距(足够阻挡中段折回穿过,又允许紧邻节点直连) */
|
|
1214
|
-
private static readonly CONNECTED_PAD;
|
|
1215
1144
|
/**
|
|
1216
1145
|
* 思维导图:先画连线(父右缘 → 子左缘的平滑曲线),再画节点
|
|
1217
1146
|
* (白底圆角矩形 + 层级色描边 + 图标/文本/左上角属性说明/折叠标记)。
|
|
@@ -1221,6 +1150,29 @@ declare class Renderer {
|
|
|
1221
1150
|
private drawMindMapNodes;
|
|
1222
1151
|
/** 按像素宽度截断文本并加省略号 */
|
|
1223
1152
|
private ellipsizeText;
|
|
1153
|
+
/**
|
|
1154
|
+
* 把连线两端解析成世界坐标折点 + 停靠法向(绑定落点、auto 重选、未绑定端点的轮廓吸附)。
|
|
1155
|
+
* 绘制与 getConnectorRoute 共用这一份,避免两处规则漂移。
|
|
1156
|
+
*/
|
|
1157
|
+
private resolveConnectorEnds;
|
|
1158
|
+
/**
|
|
1159
|
+
* 用户手工调过折点的连线:走线 = 起点 → 用户折点… → 终点(两端仍跟随绑定/端点)。
|
|
1160
|
+
*
|
|
1161
|
+
* ⚠️ 两端要先做和「两端点」时同样的近似对齐:用户是照着**对齐后**的那条线拖的手柄,
|
|
1162
|
+
* 折点坐标是相对对齐后的轴线算出来的;若这里用未对齐的原始端点接上,就会在两端各
|
|
1163
|
+
* 留下几像素的斜边(画布与导出还会各画各的)。对齐后手工折点与端点严格同轴。
|
|
1164
|
+
*/
|
|
1165
|
+
private withUserPoints;
|
|
1166
|
+
/**
|
|
1167
|
+
* 连线当前的真实走线(**世界坐标**折点)。
|
|
1168
|
+
* 手柄命中、手柄拖动都用它 —— 与绘制同一套计算,所以「看到手柄在哪,点它就一定命中」。
|
|
1169
|
+
*/
|
|
1170
|
+
getConnectorRoute(shape: Shape, shapeMap: Map<string, Shape>): Vec2[];
|
|
1171
|
+
/**
|
|
1172
|
+
* 选中连线时:在每段(够长的)线段中点画一个可拖动的小手柄(飞书式「拖线段调位置」)。
|
|
1173
|
+
* 拖动交互在 SelectTool 的 'dragging-segment' 状态里。
|
|
1174
|
+
*/
|
|
1175
|
+
private drawSegmentHandles;
|
|
1224
1176
|
private drawLine;
|
|
1225
1177
|
private drawArrow;
|
|
1226
1178
|
/** 选中连线 → 在线条上叠加一条高亮辅助线 */
|
|
@@ -1242,12 +1194,24 @@ declare class Renderer {
|
|
|
1242
1194
|
private static readonly GEN_GHOST_ID;
|
|
1243
1195
|
/** 与 Editor.lineStyle() 一致:预览线用最终连线的真实颜色/粗细 */
|
|
1244
1196
|
private static readonly PREVIEW_LINE_STYLE;
|
|
1197
|
+
/**
|
|
1198
|
+
* 'straight' 连线的近似对齐:**只在「就是两端点」时**把近对齐拉成一条直线。
|
|
1199
|
+
* 一旦用户手工折过点(>2 点),绝不能拉平 —— 否则用户拖出来的折弯会被
|
|
1200
|
+
* 「两端 y 取平均」整条压回原来的直线,看起来就像「拖了没反应/原来的线还在」。
|
|
1201
|
+
*/
|
|
1202
|
+
private straightAligned;
|
|
1203
|
+
/**
|
|
1204
|
+
* 实际用于绘制/命中的连线类型:**'straight' 但用户手工折过点 → 按 'polyline' 处理**。
|
|
1205
|
+
* 直线型不参与正交路由,两端停靠点又常常不在同一轴上,原样画会出现几像素的斜边;
|
|
1206
|
+
* 折线化后严格横平竖直(飞书拖过线段后同样变成折线型连接线)。
|
|
1207
|
+
*/
|
|
1208
|
+
private effectiveConnType;
|
|
1245
1209
|
/**
|
|
1246
1210
|
* 判断连线两端是否水平或垂直对齐(在容差内)。
|
|
1247
1211
|
* 若在容差内,强制将坐标对齐(避免 grid snapping 导致无法形成直线)。
|
|
1248
1212
|
*/
|
|
1249
1213
|
private getAlignedPoints;
|
|
1250
|
-
/**
|
|
1214
|
+
/** 生成路径点。近似对齐(容差内)时先拉直,再交给对应连接类型路由。 */
|
|
1251
1215
|
private buildPathPoints;
|
|
1252
1216
|
/**
|
|
1253
1217
|
* 使用 arcTo 绘制带圆角拐点的折线。
|
|
@@ -1261,48 +1225,25 @@ declare class Renderer {
|
|
|
1261
1225
|
private drawSnapGuides;
|
|
1262
1226
|
/** 折线:与orthogonal使用相同的H-V-H路由,差异仅在渲染(sharp vs rounded)。dock 法向在首/末段加一段垂直出线桩,垂直脱离图形边缘。 */
|
|
1263
1227
|
private generatePolylinePoints;
|
|
1264
|
-
/** 直角折线:与 polyline 使用相同的 H-V-H 正交路由,仅渲染方式(sharp)不同。 */
|
|
1265
|
-
private generateOrthogonalPoints;
|
|
1266
1228
|
/**
|
|
1267
1229
|
* 把折线末段掰到期望轴向('H' 水平收尾 / 'V' 垂直收尾)。
|
|
1268
|
-
* 绕行分支(A 星网格 / 退避)给出的路径末段方向不受控,这里在末点前补一个拐点,
|
|
1269
1230
|
* 保证箭头始终沿接入边法向插入(或沿出线方向收尾)。
|
|
1270
1231
|
*/
|
|
1271
1232
|
private ensureFinalAxis;
|
|
1272
|
-
/**
|
|
1233
|
+
/** 去除连续重合点与共线点,精简冗余拐点(唯一实现见 connectorEdit.collapseRoute) */
|
|
1273
1234
|
private collapseLinePoints;
|
|
1274
|
-
/** 计算单段直角路由:优先无碰撞、且符合总线轴方向的 H-V-H / V-H-V 折线,必要时绕开障碍 */
|
|
1275
|
-
private computeOrthogonalRoute;
|
|
1276
1235
|
/**
|
|
1277
|
-
*
|
|
1236
|
+
* 计算单段直角路由:最简单的正交折线(H-V-H / V-H-V / L 拐角)
|
|
1237
|
+
* —— **刻意不做避障**,允许从其它图形上穿过去。
|
|
1278
1238
|
*
|
|
1279
|
-
*
|
|
1280
|
-
*
|
|
1281
|
-
*
|
|
1282
|
-
*
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
/**
|
|
1286
|
-
* 在停靠偏好对应的总线轴上,从源侧向外逐点平移总线位置,返回第一条「垂直方向和
|
|
1287
|
-
* 末段水平分支都避开所有中间障碍」的总线折线;找不到则返回 null。
|
|
1288
|
-
* 平移的起点越靠源侧越好,这样多条同一来源的连线会用同一条紧贴源点的主干总线。
|
|
1289
|
-
*/
|
|
1290
|
-
private findClearBus;
|
|
1291
|
-
/** 收集连线绕行所需的障碍包围盒(转为 shape 本地坐标)。
|
|
1292
|
-
* 将本连线之外的所有图形(含其它连线/箭头/手绘)都作为障碍;
|
|
1293
|
-
* 连接端点所在图形使用小间距(CONNECTED_PAD),其余图形使用大间距(ROUTE_CLEARANCE)。 */
|
|
1294
|
-
private collectRoutingObstacles;
|
|
1295
|
-
private pointInRect;
|
|
1296
|
-
/** 整个折线路径是否与任一障碍相交 */
|
|
1297
|
-
private routeHitsObstacles;
|
|
1298
|
-
/** 轴对齐线段是否与任一障碍(向外扩其 pad)相交 */
|
|
1299
|
-
private segmentHitsObstacle;
|
|
1300
|
-
/**
|
|
1301
|
-
* 正交避障路由器(类飞书)。
|
|
1302
|
-
* 用「起终点坐标 + 每个障碍物扩展边界」构造一条布线网格,再用 A* 在网格上求
|
|
1303
|
-
* 最短避障折线(半径外扩 pad 保证不贴边)。返回不含 from、含 to 的拐点序列。
|
|
1239
|
+
* 为什么不做避障(2026-09-22 决定,对齐飞书):绕行会让路径在拖动时反复改形
|
|
1240
|
+
* (3 段 ↔ 6 段拐点来回跳),观感就是「绕来绕去」;而「挡路/重叠时直接穿过去、
|
|
1241
|
+
* 端点不挪窝、永远横平竖直」更可预期也更好读。实测绕行只在约 6% 的布局下触发,
|
|
1242
|
+
* 但它带来的「画布 ≠ 导出」与拖拽跳变是所有场景都在承受的。
|
|
1243
|
+
*
|
|
1244
|
+
* 规则与 export.dockRoutePoints 完全一致 → 画布所见即导出所得。
|
|
1304
1245
|
*/
|
|
1305
|
-
private
|
|
1246
|
+
private computeOrthogonalRoute;
|
|
1306
1247
|
/**
|
|
1307
1248
|
* 曲线:用三次贝塞尔拼接出平滑曲线(离散化采样)。
|
|
1308
1249
|
* 端点若停靠在图形上(dock.fromN/toN),控制点沿法向伸出,使曲线垂直脱离 / 垂直接入
|
|
@@ -1433,6 +1374,10 @@ interface ToolContext {
|
|
|
1433
1374
|
setGenerationPreview(preview: GenerationPreview | null): void;
|
|
1434
1375
|
/** 悬停图形 → 画布为其绘制四边连接锚点(null 清除) */
|
|
1435
1376
|
setHoverAnchorShape(id: string | null): void;
|
|
1377
|
+
/** 悬停连线 → 画布为整条线描一层高亮(null 清除) */
|
|
1378
|
+
setHoverConnector(id: string | null): void;
|
|
1379
|
+
/** 某条连线当前的真实走线(世界坐标折点):线段手柄的命中/拖动用它,与画布绘制同一套计算 */
|
|
1380
|
+
getConnectorRoute(shapeId: string): Vec2[];
|
|
1436
1381
|
/** 新建连线的线条样式(颜色/粗细),与最终创建的连线保持一致 */
|
|
1437
1382
|
getLineStyle(): ShapeStyle;
|
|
1438
1383
|
/** 拖动到空白处:创建一条浮动线条并弹出"选择新图形"菜单 */
|
|
@@ -1496,6 +1441,14 @@ declare class SelectTool extends Tool {
|
|
|
1496
1441
|
private hoverGenPoint;
|
|
1497
1442
|
/** 悬停(未按下)的图形 id:为其显示四边连接锚点,可直接从这里拖出连线 */
|
|
1498
1443
|
private hoverShapeId;
|
|
1444
|
+
/** 悬停(未按下)的连线 id:整条线描高亮 */
|
|
1445
|
+
private hoverConnectorId;
|
|
1446
|
+
/**
|
|
1447
|
+
* 正在拖动某条连线的第 index 段(飞书式「拖线段调位置」)。
|
|
1448
|
+
* route 是**按下那一刻**的走线:每次移动都从它重新算(拖动会插入折点、段序号会变,
|
|
1449
|
+
* 从原始走线重算才不会累积漂移)。
|
|
1450
|
+
*/
|
|
1451
|
+
private draggingSegment;
|
|
1499
1452
|
private rotatingState;
|
|
1500
1453
|
private draggingArrowId;
|
|
1501
1454
|
private draggingTerminal;
|
|
@@ -1514,6 +1467,34 @@ declare class SelectTool extends Tool {
|
|
|
1514
1467
|
onPointerDown(point: Vec2, event: PointerEvent): void;
|
|
1515
1468
|
onPointerMove(point: Vec2, event: PointerEvent): void;
|
|
1516
1469
|
onPointerUp(point: Vec2, _event: PointerEvent): void;
|
|
1470
|
+
/**
|
|
1471
|
+
* 点是否落在某条连线的**当前真实走线**上(容差 10px)。
|
|
1472
|
+
* 画布上看到的那条线、悬停高亮、点击命中、手柄命中全部用这一份几何 ——
|
|
1473
|
+
* 「看到哪就能点到哪」,不会出现悬停能亮、点击没反应。
|
|
1474
|
+
*/
|
|
1475
|
+
private isPointOnConnector;
|
|
1476
|
+
/**
|
|
1477
|
+
* 悬停命中的连线 id(未选中才有高亮提示;选中的连线由线段手柄负责显示)。
|
|
1478
|
+
* 与点击命中同一套判定(isPointOnConnector)。
|
|
1479
|
+
*/
|
|
1480
|
+
private findHoverConnector;
|
|
1481
|
+
/**
|
|
1482
|
+
* 命中已选中连线上要拖动的线段(先手柄中心 10px,再退一步「离得最近的段」14px)。
|
|
1483
|
+
* 这样在选中连线上任意位置按下都能拖到最近那一段,也就不会误触发「拖整条线 / 从锚点拉新线」。
|
|
1484
|
+
*/
|
|
1485
|
+
private hitConnectorSegmentHandle;
|
|
1486
|
+
/** 拖线段时的光标:水平段能上下拖 → 上下箭头;垂直段能左右拖 → 左右箭头 */
|
|
1487
|
+
private segmentCursor;
|
|
1488
|
+
/** 拖动线段:把这一段沿垂直方向平移(相邻段自然伸缩),两端端点永不移动 */
|
|
1489
|
+
private handleDraggingSegment;
|
|
1490
|
+
/**
|
|
1491
|
+
* 把调整后的走线写回 shape:
|
|
1492
|
+
* - 绑定连线(有 start/endBinding)只写中间折点 `userPoints`,两端继续跟随绑定;
|
|
1493
|
+
* - 自由连线(无绑定)整条走线就是它自己的 `points`。
|
|
1494
|
+
* 先把走线里的重复点/共线冗余点去掉:**如果去掉后就是一条直线(≤2 点),把 userPoints 清空**,
|
|
1495
|
+
* 交还给自动路由 —— 这样「往基线拖、把浅台阶抹平」之后,连线是真的恢复原样,而不是留着一堆零高度折点。
|
|
1496
|
+
*/
|
|
1497
|
+
private writeConnectorRoute;
|
|
1517
1498
|
hasTransientState(): boolean;
|
|
1518
1499
|
/**
|
|
1519
1500
|
* 取消一切瞬态交互(拖拽/生成/框选/旋转/连线端点拖拽)并清掉画布上的瞬态预览。
|
|
@@ -1573,6 +1554,7 @@ declare class SelectTool extends Tool {
|
|
|
1573
1554
|
private bindingPosition;
|
|
1574
1555
|
private isPointInShape;
|
|
1575
1556
|
private isPointInHexagon;
|
|
1557
|
+
/** 点到线段最短距离(唯一实现见 connectorEdit.pointToSegmentDistance) */
|
|
1576
1558
|
private pointToLineDistance;
|
|
1577
1559
|
/**
|
|
1578
1560
|
* 待新建图形与源图形重叠时,把它沿「源→目标」方向推到不重叠(留一个引线距离)。
|
|
@@ -1785,4 +1767,4 @@ declare function countMindMapNodes(root: MindMapNode): number;
|
|
|
1785
1767
|
*/
|
|
1786
1768
|
declare function layoutMindMap(root: MindMapNode): MindMapLayoutResult;
|
|
1787
1769
|
|
|
1788
|
-
export { type ArrowBinding, type ArrowHeadType, type ArrowShape, type ArrowStyle, ArrowTool, Camera, type CameraState, type CircleShape, type ConnectionType, DEFAULT_HIGHLIGHTER_COLOR, type DiamondShape, type DrawShape, type DrawuiTheme, type DrawuiThemeSelection, Editor, type EditorData, type EditorOptions, type EditorState, type EllipseShape, type ExportFormat, type ExportOptions, type FreehandMode, FreehandTool, type GenerationContext, HandTool, type HexagonShape, type Language, type LineShape, LineTool, MINDMAP_COLORS, MINDMAP_FONT_SIZE, MINDMAP_MAX_WIDTH, MINDMAP_MIN_WIDTH, MINDMAP_NODE_HEIGHT, Mat2d, type MessageKey, type MindMapLayoutResult, type MindMapNode, type MindMapNodePos, type MindMapShape, type OctagonShape, type ParallelogramShape, type PentagonShape, type Rect, type RectangleShape, Renderer, type RoundedRectangleShape, SelectTool, type Shape, type ShapeStyle, ShapeTool, type ShapeType, type SnapGuide, type StarShape, THEME, type TextShape, type ToolType, type TrapezoidShape, type TriangleShape, UML_FONT_SIZE, UML_HEADER_HEIGHT, UML_LINE_HEIGHT, UML_MIN_WIDTH, UML_PADDING_X, UML_PADDING_Y, type UiEvent, type UmlAttribute, type UmlClassShape, type UmlInterfaceShape, type UmlMethod, type UmlVisibility, Vec, type Vec2 as Vec2Type, calcUmlClassSize, cloneMindMapNode, countMindMapNodes, downloadBlob, exportToBlob, findMindMapNode, getContentBounds, getLanguage, getMindMapNodeDepth, getMindMapParent, getTheme, hexToRgba, layoutMindMap, mindMapNodeColor, mindMapNodeSize, renderSVGString, renderToCanvas, setLanguage, setTheme, shadeColor, subscribeLanguage, subscribeTheme, t };
|
|
1770
|
+
export { type ArrowBinding, type ArrowHeadType, type ArrowShape, type ArrowStyle, ArrowTool, Camera, type CameraState, type CircleShape, type ConnectionType, DEFAULT_HIGHLIGHTER_COLOR, type DiamondShape, type DrawShape, type DrawuiTheme, type DrawuiThemeSelection, Editor, type EditorData, type EditorOptions, type EditorState, type EllipseShape, type ExportFormat, type ExportOptions, type FreehandMode, FreehandTool, type GenerationContext, HandTool, type HexagonShape, LANGUAGES, type Language, type LineShape, LineTool, MINDMAP_COLORS, MINDMAP_FONT_SIZE, MINDMAP_MAX_WIDTH, MINDMAP_MIN_WIDTH, MINDMAP_NODE_HEIGHT, MIN_HANDLE_SEGMENT, MIN_JOG, Mat2d, type MessageKey, type MindMapLayoutResult, type MindMapNode, type MindMapNodePos, type MindMapShape, type OctagonShape, type ParallelogramShape, type PentagonShape, type Rect, type RectangleShape, Renderer, type RoundedRectangleShape, type SegmentHandle, SelectTool, type Shape, type ShapeStyle, ShapeTool, type ShapeType, type SnapGuide, type StarShape, THEME, type TextShape, type ToolType, type TrapezoidShape, type TriangleShape, UML_FONT_SIZE, UML_HEADER_HEIGHT, UML_LINE_HEIGHT, UML_MIN_WIDTH, UML_PADDING_X, UML_PADDING_Y, type UiEvent, type UmlAttribute, type UmlClassShape, type UmlInterfaceShape, type UmlMethod, type UmlVisibility, Vec, type Vec2 as Vec2Type, calcUmlClassSize, cloneMindMapNode, collapseRoute, connectorSegmentHandles, countMindMapNodes, downloadBlob, exportToBlob, findMindMapNode, getContentBounds, getLanguage, getMindMapNodeDepth, getMindMapParent, getTheme, hexToRgba, layoutMindMap, mindMapNodeColor, mindMapNodeSize, offsetConnectorSegment, pickSegmentHandle, pointToSegmentDistance, renderSVGString, renderToCanvas, routeToUserPoints, setLanguage, setTheme, shadeColor, subscribeLanguage, subscribeTheme, t };
|