|
@@ -195,6 +195,42 @@ Graph.registerConnector(
|
|
|
true
|
|
|
);
|
|
|
|
|
|
+// 括号
|
|
|
+Graph.registerConnector(
|
|
|
+ "bracket-branch-connector",
|
|
|
+ function (sourcePoint, targetPoint, routerPoints, options) {
|
|
|
+ const midX =
|
|
|
+ sourcePoint.x +
|
|
|
+ (sourcePoint.x < targetPoint.x ? 20 : -20);
|
|
|
+ const midY = sourcePoint.y;
|
|
|
+ const pathData = `
|
|
|
+ M ${sourcePoint.x} ${sourcePoint.y}
|
|
|
+ Q ${midX} ${midY} ${midX} ${sourcePoint.y + (sourcePoint.y < targetPoint.y ? 20 : -20)}
|
|
|
+ L ${midX} ${targetPoint.y + (targetPoint.y < sourcePoint.y ? 20 : targetPoint.y === sourcePoint.y ? 0 : -20)}
|
|
|
+ Q ${midX} ${targetPoint.y} ${midX + (targetPoint.x < sourcePoint.x ? -20 : 20)} ${targetPoint.y}
|
|
|
+ `;
|
|
|
+ return options.raw ? Path.parse(pathData) : pathData;
|
|
|
+ },
|
|
|
+ true
|
|
|
+);
|
|
|
+Graph.registerConnector(
|
|
|
+ "bracket-sub-connector",
|
|
|
+ function (sourcePoint, targetPoint, routerPoints, options) {
|
|
|
+ const midX =
|
|
|
+ sourcePoint.x +
|
|
|
+ (sourcePoint.x < targetPoint.x ? 10 : -10);
|
|
|
+ const midY = sourcePoint.y;
|
|
|
+ const pathData = `
|
|
|
+ M ${sourcePoint.x} ${sourcePoint.y}
|
|
|
+ Q ${midX} ${midY} ${midX} ${sourcePoint.y + (sourcePoint.y < targetPoint.y ? 10 : -10)}
|
|
|
+ L ${midX} ${targetPoint.y + (targetPoint.y < sourcePoint.y ? 10 : targetPoint.y === sourcePoint.y ? 0 : -10)}
|
|
|
+ Q ${midX} ${targetPoint.y} ${midX + (targetPoint.x < sourcePoint.x ? -10 : 10)} ${targetPoint.y}
|
|
|
+ `;
|
|
|
+ return options.raw ? Path.parse(pathData) : pathData;
|
|
|
+ },
|
|
|
+ true
|
|
|
+);
|
|
|
+
|
|
|
const getConnector = (
|
|
|
structure: StructureType,
|
|
|
theme: string,
|
|
@@ -207,6 +243,9 @@ const getConnector = (
|
|
|
if (structure === StructureType.organization) {
|
|
|
return `organization-${type}-connector`;
|
|
|
}
|
|
|
+ if ([StructureType.leftBracket, StructureType.rightBracket].includes(structure)) {
|
|
|
+ return `bracket-${type}-connector`;
|
|
|
+ }
|
|
|
const themeObj = getTheme(theme);
|
|
|
if (type === TopicType.branch) {
|
|
|
return `${themeObj.branchConnector}-${type}-connector`;
|
|
@@ -257,10 +296,24 @@ const getSourceAnchor = (type: TopicType, structure: StructureType) => {
|
|
|
name: "bottom",
|
|
|
};
|
|
|
}
|
|
|
- case StructureType.leftBracket:
|
|
|
+ case StructureType.leftBracket: {
|
|
|
+ return {
|
|
|
+ name: "left",
|
|
|
+ args: {
|
|
|
+ dx: -10,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ }
|
|
|
+ case StructureType.rightBracket: {
|
|
|
+ return {
|
|
|
+ name: "right",
|
|
|
+ args: {
|
|
|
+ dx: 10,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ }
|
|
|
case StructureType.leftFishbone:
|
|
|
case StructureType.leftTreeShape:
|
|
|
- case StructureType.rightBracket:
|
|
|
case StructureType.rightFishbone:
|
|
|
case StructureType.rightTreeShape:
|
|
|
return {
|
|
@@ -298,10 +351,24 @@ const getTargetAnchor = (type: TopicType, structure: StructureType) => {
|
|
|
name: "top",
|
|
|
};
|
|
|
}
|
|
|
- case StructureType.leftBracket:
|
|
|
+ case StructureType.leftBracket: {
|
|
|
+ return {
|
|
|
+ name: "right",
|
|
|
+ args: {
|
|
|
+ dx: 10,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ }
|
|
|
+ case StructureType.rightBracket: {
|
|
|
+ return {
|
|
|
+ name: "left",
|
|
|
+ args: {
|
|
|
+ dx: 10,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ }
|
|
|
case StructureType.leftFishbone:
|
|
|
case StructureType.leftTreeShape:
|
|
|
- case StructureType.rightBracket:
|
|
|
case StructureType.rightFishbone:
|
|
|
case StructureType.rightTreeShape:
|
|
|
return {
|