@flowgram.ai/fixed-layout-core 0.1.29 → 0.1.31
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/esm/index.js +280 -23
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +279 -38
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/esm/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
FlowScrollLimitLayer
|
|
28
28
|
} from "@flowgram.ai/renderer";
|
|
29
29
|
import {
|
|
30
|
-
FlowNodeRenderData as
|
|
30
|
+
FlowNodeRenderData as FlowNodeRenderData4,
|
|
31
31
|
FlowNodeTransformData as FlowNodeTransformData3,
|
|
32
32
|
FlowNodeTransitionData
|
|
33
33
|
} from "@flowgram.ai/document";
|
|
@@ -166,8 +166,8 @@ var BlockRegistry = {
|
|
|
166
166
|
const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
|
|
167
167
|
if (hasBranchDraggingAdder) {
|
|
168
168
|
if (isVertical) {
|
|
169
|
-
const currentOffsetRightX = currentTransform.firstChild
|
|
170
|
-
const nextOffsetLeftX = currentTransform.next?.firstChild?.bounds?.left || 0;
|
|
169
|
+
const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
|
|
170
|
+
const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
|
|
171
171
|
const currentInputPointY = currentTransform.inputPoint.y;
|
|
172
172
|
if (currentTransform?.next) {
|
|
173
173
|
lines.push({
|
|
@@ -181,8 +181,8 @@ var BlockRegistry = {
|
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
183
|
} else {
|
|
184
|
-
const
|
|
185
|
-
const
|
|
184
|
+
const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
|
|
185
|
+
const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
|
|
186
186
|
const currentInputPointX = currentTransform.inputPoint.x;
|
|
187
187
|
if (currentTransform?.next) {
|
|
188
188
|
lines.push({
|
|
@@ -190,7 +190,7 @@ var BlockRegistry = {
|
|
|
190
190
|
from: currentTransform.parent.inputPoint,
|
|
191
191
|
to: {
|
|
192
192
|
x: currentInputPointX,
|
|
193
|
-
y: (
|
|
193
|
+
y: (currentOffsetBottomX + nextOffsetTopX) / 2
|
|
194
194
|
},
|
|
195
195
|
side: LABEL_SIDE_TYPE.NORMAL_BRANCH
|
|
196
196
|
});
|
|
@@ -232,8 +232,8 @@ var BlockRegistry = {
|
|
|
232
232
|
const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
|
|
233
233
|
if (hasBranchDraggingAdder) {
|
|
234
234
|
if (isVertical) {
|
|
235
|
-
const currentOffsetRightX = currentTransform.firstChild
|
|
236
|
-
const nextOffsetLeftX = currentTransform.next?.firstChild?.bounds?.left || 0;
|
|
235
|
+
const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
|
|
236
|
+
const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
|
|
237
237
|
const currentInputPointY = currentTransform.inputPoint.y;
|
|
238
238
|
if (currentTransform?.next) {
|
|
239
239
|
draggingLabel.push({
|
|
@@ -249,17 +249,17 @@ var BlockRegistry = {
|
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
251
|
} else {
|
|
252
|
-
const
|
|
253
|
-
const
|
|
252
|
+
const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
|
|
253
|
+
const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
|
|
254
254
|
const currentInputPointX = currentTransform.inputPoint.x;
|
|
255
255
|
if (currentTransform?.next) {
|
|
256
256
|
draggingLabel.push({
|
|
257
257
|
offset: {
|
|
258
258
|
x: currentInputPointX,
|
|
259
|
-
y: (
|
|
259
|
+
y: (currentOffsetBottomX + nextOffsetTopX) / 2
|
|
260
260
|
},
|
|
261
261
|
type: FlowTransitionLabelEnum2.BRANCH_DRAGGING_LABEL,
|
|
262
|
-
width:
|
|
262
|
+
width: nextOffsetTopX - currentOffsetBottomX,
|
|
263
263
|
props: {
|
|
264
264
|
side: LABEL_SIDE_TYPE.NORMAL_BRANCH
|
|
265
265
|
}
|
|
@@ -1497,22 +1497,16 @@ var SimpleSplitRegistry = {
|
|
|
1497
1497
|
onBlockChildCreate(originParent, blockData, addedNodes = []) {
|
|
1498
1498
|
const { document } = originParent;
|
|
1499
1499
|
const parent = document.getNode(`$inlineBlocks$${originParent.id}`);
|
|
1500
|
-
const proxyBlock = document.addNode({
|
|
1501
|
-
id: `$block$${blockData.id}`,
|
|
1502
|
-
type: FlowNodeBaseType17.BLOCK,
|
|
1503
|
-
originParent,
|
|
1504
|
-
parent
|
|
1505
|
-
});
|
|
1506
1500
|
const realBlock = document.addNode(
|
|
1507
1501
|
{
|
|
1508
1502
|
...blockData,
|
|
1509
1503
|
type: blockData.type || FlowNodeBaseType17.BLOCK,
|
|
1510
|
-
parent
|
|
1504
|
+
parent
|
|
1511
1505
|
},
|
|
1512
1506
|
addedNodes
|
|
1513
1507
|
);
|
|
1514
|
-
addedNodes.push(
|
|
1515
|
-
return
|
|
1508
|
+
addedNodes.push(realBlock);
|
|
1509
|
+
return realBlock;
|
|
1516
1510
|
}
|
|
1517
1511
|
// addChild(node, json, options = {}) {
|
|
1518
1512
|
// const { index } = options;
|
|
@@ -1521,6 +1515,263 @@ var SimpleSplitRegistry = {
|
|
|
1521
1515
|
// }
|
|
1522
1516
|
};
|
|
1523
1517
|
|
|
1518
|
+
// src/activities/break.ts
|
|
1519
|
+
import { FlowNodeBaseType as FlowNodeBaseType18 } from "@flowgram.ai/document";
|
|
1520
|
+
var BreakRegistry = {
|
|
1521
|
+
type: FlowNodeBaseType18.BREAK,
|
|
1522
|
+
extend: FlowNodeBaseType18.END
|
|
1523
|
+
};
|
|
1524
|
+
|
|
1525
|
+
// src/activities/input.ts
|
|
1526
|
+
import {
|
|
1527
|
+
FlowNodeBaseType as FlowNodeBaseType19,
|
|
1528
|
+
FlowTransitionLineEnum as FlowTransitionLineEnum6,
|
|
1529
|
+
LABEL_SIDE_TYPE as LABEL_SIDE_TYPE2,
|
|
1530
|
+
FlowTransitionLabelEnum as FlowTransitionLabelEnum13
|
|
1531
|
+
} from "@flowgram.ai/document";
|
|
1532
|
+
var InputRegistry = {
|
|
1533
|
+
type: FlowNodeBaseType19.INPUT,
|
|
1534
|
+
extend: FlowNodeBaseType19.BLOCK,
|
|
1535
|
+
meta: {
|
|
1536
|
+
hidden: false
|
|
1537
|
+
},
|
|
1538
|
+
getLines(transition, layout) {
|
|
1539
|
+
const currentTransform = transition.transform;
|
|
1540
|
+
const { isVertical } = transition.entity;
|
|
1541
|
+
const lines = [];
|
|
1542
|
+
const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
|
|
1543
|
+
if (hasBranchDraggingAdder) {
|
|
1544
|
+
if (isVertical) {
|
|
1545
|
+
const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
|
|
1546
|
+
const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
|
|
1547
|
+
const currentInputPointY = currentTransform.outputPoint.y;
|
|
1548
|
+
if (currentTransform?.next) {
|
|
1549
|
+
lines.push({
|
|
1550
|
+
type: FlowTransitionLineEnum6.MERGE_LINE,
|
|
1551
|
+
isDraggingLine: true,
|
|
1552
|
+
from: {
|
|
1553
|
+
x: (currentOffsetRightX + nextOffsetLeftX) / 2,
|
|
1554
|
+
y: currentInputPointY
|
|
1555
|
+
},
|
|
1556
|
+
to: currentTransform.parent.outputPoint,
|
|
1557
|
+
side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
} else {
|
|
1561
|
+
const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
|
|
1562
|
+
const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
|
|
1563
|
+
const currentInputPointX = currentTransform.outputPoint.x;
|
|
1564
|
+
if (currentTransform?.next) {
|
|
1565
|
+
lines.push({
|
|
1566
|
+
type: FlowTransitionLineEnum6.MERGE_LINE,
|
|
1567
|
+
isDraggingLine: true,
|
|
1568
|
+
from: {
|
|
1569
|
+
x: currentInputPointX,
|
|
1570
|
+
y: (currentOffsetBottomX + nextOffsetTopX) / 2
|
|
1571
|
+
},
|
|
1572
|
+
to: currentTransform.parent.outputPoint,
|
|
1573
|
+
side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
|
|
1574
|
+
});
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
if (!transition.isNodeEnd) {
|
|
1579
|
+
lines.push({
|
|
1580
|
+
type: FlowTransitionLineEnum6.MERGE_LINE,
|
|
1581
|
+
from: currentTransform.outputPoint,
|
|
1582
|
+
to: currentTransform.parent.outputPoint,
|
|
1583
|
+
side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1586
|
+
return lines;
|
|
1587
|
+
},
|
|
1588
|
+
getLabels(transition) {
|
|
1589
|
+
const currentTransform = transition.transform;
|
|
1590
|
+
const { isVertical } = transition.entity;
|
|
1591
|
+
const draggingLabel = [];
|
|
1592
|
+
const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
|
|
1593
|
+
if (hasBranchDraggingAdder) {
|
|
1594
|
+
if (isVertical) {
|
|
1595
|
+
const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
|
|
1596
|
+
const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
|
|
1597
|
+
const currentInputPointY = currentTransform.outputPoint.y;
|
|
1598
|
+
if (currentTransform?.next) {
|
|
1599
|
+
draggingLabel.push({
|
|
1600
|
+
offset: {
|
|
1601
|
+
x: (currentOffsetRightX + nextOffsetLeftX) / 2,
|
|
1602
|
+
y: currentInputPointY
|
|
1603
|
+
},
|
|
1604
|
+
type: FlowTransitionLabelEnum13.BRANCH_DRAGGING_LABEL,
|
|
1605
|
+
width: nextOffsetLeftX - currentOffsetRightX,
|
|
1606
|
+
props: {
|
|
1607
|
+
side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
|
|
1608
|
+
}
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
} else {
|
|
1612
|
+
const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
|
|
1613
|
+
const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
|
|
1614
|
+
const currentInputPointX = currentTransform.outputPoint.x;
|
|
1615
|
+
if (currentTransform?.next) {
|
|
1616
|
+
draggingLabel.push({
|
|
1617
|
+
offset: {
|
|
1618
|
+
x: currentInputPointX,
|
|
1619
|
+
y: (currentOffsetBottomX + nextOffsetTopX) / 2
|
|
1620
|
+
},
|
|
1621
|
+
type: FlowTransitionLabelEnum13.BRANCH_DRAGGING_LABEL,
|
|
1622
|
+
width: nextOffsetTopX - currentOffsetBottomX,
|
|
1623
|
+
props: {
|
|
1624
|
+
side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
|
|
1625
|
+
}
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
return [...draggingLabel];
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1633
|
+
|
|
1634
|
+
// src/activities/output.ts
|
|
1635
|
+
import { FlowNodeBaseType as FlowNodeBaseType20 } from "@flowgram.ai/document";
|
|
1636
|
+
var OuputRegistry = {
|
|
1637
|
+
type: FlowNodeBaseType20.OUTPUT,
|
|
1638
|
+
extend: FlowNodeBaseType20.BLOCK,
|
|
1639
|
+
meta: {
|
|
1640
|
+
hidden: false,
|
|
1641
|
+
isNodeEnd: true
|
|
1642
|
+
}
|
|
1643
|
+
};
|
|
1644
|
+
|
|
1645
|
+
// src/activities/multi-outputs.ts
|
|
1646
|
+
import {
|
|
1647
|
+
FlowLayoutDefault as FlowLayoutDefault7,
|
|
1648
|
+
FlowNodeSplitType as FlowNodeSplitType4,
|
|
1649
|
+
FlowNodeBaseType as FlowNodeBaseType21
|
|
1650
|
+
} from "@flowgram.ai/document";
|
|
1651
|
+
var MultiOuputsRegistry = {
|
|
1652
|
+
type: FlowNodeBaseType21.MULTI_OUTPUTS,
|
|
1653
|
+
extend: FlowNodeSplitType4.SIMPLE_SPLIT,
|
|
1654
|
+
meta: {
|
|
1655
|
+
isNodeEnd: true
|
|
1656
|
+
},
|
|
1657
|
+
getLines: (transition, layout) => {
|
|
1658
|
+
if (transition.entity.parent?.flowNodeType === FlowNodeBaseType21.INLINE_BLOCKS) {
|
|
1659
|
+
return BlockRegistry.getLines(transition, layout);
|
|
1660
|
+
}
|
|
1661
|
+
return [];
|
|
1662
|
+
},
|
|
1663
|
+
getLabels: (transition, layout) => [
|
|
1664
|
+
...DynamicSplitRegistry.getLabels(transition, layout),
|
|
1665
|
+
...BlockRegistry.getLabels(transition, layout)
|
|
1666
|
+
],
|
|
1667
|
+
getOutputPoint(transform, layout) {
|
|
1668
|
+
const isVertical = FlowLayoutDefault7.isVertical(layout);
|
|
1669
|
+
const lastChildOutput = transform.lastChild?.outputPoint;
|
|
1670
|
+
if (isVertical) {
|
|
1671
|
+
return {
|
|
1672
|
+
x: lastChildOutput ? lastChildOutput.x : transform.bounds.center.x,
|
|
1673
|
+
y: transform.bounds.bottom
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
return {
|
|
1677
|
+
x: transform.bounds.right,
|
|
1678
|
+
y: lastChildOutput ? lastChildOutput.y : transform.bounds.center.y
|
|
1679
|
+
};
|
|
1680
|
+
},
|
|
1681
|
+
extendChildRegistries: [
|
|
1682
|
+
{
|
|
1683
|
+
type: FlowNodeBaseType21.BLOCK_ICON,
|
|
1684
|
+
meta: {
|
|
1685
|
+
// isNodeEnd: true
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
]
|
|
1689
|
+
};
|
|
1690
|
+
|
|
1691
|
+
// src/activities/multi-inputs.ts
|
|
1692
|
+
import { Point as Point6 } from "@flowgram.ai/utils";
|
|
1693
|
+
import { FlowRendererKey as FlowRendererKey4 } from "@flowgram.ai/renderer";
|
|
1694
|
+
import {
|
|
1695
|
+
FlowNodeBaseType as FlowNodeBaseType22,
|
|
1696
|
+
FlowNodeRenderData as FlowNodeRenderData3,
|
|
1697
|
+
FlowTransitionLabelEnum as FlowTransitionLabelEnum14,
|
|
1698
|
+
FlowNodeSplitType as FlowNodeSplitType5,
|
|
1699
|
+
getDefaultSpacing as getDefaultSpacing8,
|
|
1700
|
+
ConstantKeys as ConstantKeys7
|
|
1701
|
+
} from "@flowgram.ai/document";
|
|
1702
|
+
var MultiInputsRegistry = {
|
|
1703
|
+
type: FlowNodeBaseType22.MULTI_INPUTS,
|
|
1704
|
+
extend: FlowNodeSplitType5.SIMPLE_SPLIT,
|
|
1705
|
+
extendChildRegistries: [
|
|
1706
|
+
{
|
|
1707
|
+
type: FlowNodeBaseType22.BLOCK_ICON,
|
|
1708
|
+
meta: {
|
|
1709
|
+
hidden: true,
|
|
1710
|
+
spacing: 0
|
|
1711
|
+
},
|
|
1712
|
+
getLines() {
|
|
1713
|
+
return [];
|
|
1714
|
+
},
|
|
1715
|
+
getLabels() {
|
|
1716
|
+
return [];
|
|
1717
|
+
}
|
|
1718
|
+
},
|
|
1719
|
+
{
|
|
1720
|
+
type: FlowNodeBaseType22.INLINE_BLOCKS,
|
|
1721
|
+
meta: {
|
|
1722
|
+
inlineSpacingPre: 0
|
|
1723
|
+
},
|
|
1724
|
+
getLabels(transition) {
|
|
1725
|
+
const isVertical = transition.entity.isVertical;
|
|
1726
|
+
const currentTransform = transition.transform;
|
|
1727
|
+
const spacing = getDefaultSpacing8(
|
|
1728
|
+
transition.entity,
|
|
1729
|
+
ConstantKeys7.INLINE_BLOCKS_PADDING_BOTTOM
|
|
1730
|
+
);
|
|
1731
|
+
if (currentTransform.collapsed || transition.entity.childrenLength === 0) {
|
|
1732
|
+
return [
|
|
1733
|
+
{
|
|
1734
|
+
type: FlowTransitionLabelEnum14.CUSTOM_LABEL,
|
|
1735
|
+
renderKey: FlowRendererKey4.BRANCH_ADDER,
|
|
1736
|
+
offset: Point6.move(
|
|
1737
|
+
currentTransform.outputPoint,
|
|
1738
|
+
isVertical ? { y: spacing } : { x: spacing }
|
|
1739
|
+
),
|
|
1740
|
+
props: {
|
|
1741
|
+
// 激活状态
|
|
1742
|
+
activated: transition.entity.getData(FlowNodeRenderData3).activated,
|
|
1743
|
+
transform: currentTransform,
|
|
1744
|
+
// 传给外部使用的 node 信息
|
|
1745
|
+
node: currentTransform.originParent?.entity
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
];
|
|
1749
|
+
}
|
|
1750
|
+
return [
|
|
1751
|
+
{
|
|
1752
|
+
type: FlowTransitionLabelEnum14.CUSTOM_LABEL,
|
|
1753
|
+
renderKey: FlowRendererKey4.BRANCH_ADDER,
|
|
1754
|
+
offset: Point6.move(
|
|
1755
|
+
currentTransform.outputPoint,
|
|
1756
|
+
isVertical ? { y: -spacing / 2 } : { x: -spacing / 2 }
|
|
1757
|
+
),
|
|
1758
|
+
props: {
|
|
1759
|
+
// 激活状态
|
|
1760
|
+
activated: transition.entity.getData(FlowNodeRenderData3).activated,
|
|
1761
|
+
transform: currentTransform,
|
|
1762
|
+
// 传给外部使用的 node 信息
|
|
1763
|
+
node: currentTransform.originParent?.entity
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
];
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
],
|
|
1770
|
+
getLabels() {
|
|
1771
|
+
return [];
|
|
1772
|
+
}
|
|
1773
|
+
};
|
|
1774
|
+
|
|
1524
1775
|
// src/flow-registers.ts
|
|
1525
1776
|
var FlowRegisters = class {
|
|
1526
1777
|
/**
|
|
@@ -1553,11 +1804,17 @@ var FlowRegisters = class {
|
|
|
1553
1804
|
// 结束节点
|
|
1554
1805
|
LoopRegistry,
|
|
1555
1806
|
// 循环节点
|
|
1556
|
-
EmptyRegistry
|
|
1807
|
+
EmptyRegistry,
|
|
1557
1808
|
// 占位节点
|
|
1809
|
+
BreakRegistry,
|
|
1810
|
+
// 分支断开
|
|
1811
|
+
MultiOuputsRegistry,
|
|
1812
|
+
MultiInputsRegistry,
|
|
1813
|
+
InputRegistry,
|
|
1814
|
+
OuputRegistry
|
|
1558
1815
|
);
|
|
1559
1816
|
document.registerNodeDatas(
|
|
1560
|
-
|
|
1817
|
+
FlowNodeRenderData4,
|
|
1561
1818
|
// 渲染节点相关数据
|
|
1562
1819
|
FlowNodeTransitionData,
|
|
1563
1820
|
// 线条绘制数据
|