@flowgram.ai/document 0.2.14 → 0.2.16

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 CHANGED
@@ -88,6 +88,10 @@ var DefaultSpacingKey = {
88
88
  * 普通节点间距。垂直 / 水平
89
89
  */
90
90
  NODE_SPACING: "SPACING",
91
+ /**
92
+ * 分支节点间距
93
+ */
94
+ BRANCH_SPACING: "BRANCH_SPACING",
91
95
  /**
92
96
  * 圆弧线条 x radius
93
97
  */
@@ -114,8 +118,13 @@ var DEFAULT_SPACING = {
114
118
  NULL: 0,
115
119
  [DefaultSpacingKey.NODE_SPACING]: 32,
116
120
  // 普通节点间距。垂直 / 水平
121
+ [DefaultSpacingKey.BRANCH_SPACING]: 20,
122
+ // 分支节点间距
123
+ /**
124
+ * @deprecated use 'BRANCH_SPACING' instead
125
+ */
117
126
  MARGIN_RIGHT: 20,
118
- // 普通节点右边间距
127
+ // 分支节点右边间距
119
128
  INLINE_BLOCK_PADDING_BOTTOM: 16,
120
129
  // block 底部留白
121
130
  INLINE_BLOCKS_PADDING_TOP: 30,
@@ -1015,37 +1024,7 @@ var FlowNodeEntity = class extends Entity {
1015
1024
  * @param newId
1016
1025
  */
1017
1026
  toJSON() {
1018
- if (this.document.options.toNodeJSON) {
1019
- return this.document.options.toNodeJSON(this);
1020
- }
1021
- const nodesMap = {};
1022
- let startNodeJSON;
1023
- this.document.traverse((node) => {
1024
- const isSystemNode = node.id.startsWith("$");
1025
- if (isSystemNode) return;
1026
- const nodeJSONData = this.getJSONData();
1027
- const nodeJSON = {
1028
- id: node.id,
1029
- type: node.flowNodeType
1030
- };
1031
- if (nodeJSONData !== void 0) {
1032
- nodeJSON.data = nodeJSONData;
1033
- }
1034
- if (!startNodeJSON) startNodeJSON = nodeJSON;
1035
- let { parent } = node;
1036
- if (parent && parent.id.startsWith("$")) {
1037
- parent = parent.originParent;
1038
- }
1039
- const parentJSON = parent ? nodesMap[parent.id] : void 0;
1040
- if (parentJSON) {
1041
- if (!parentJSON.blocks) {
1042
- parentJSON.blocks = [];
1043
- }
1044
- parentJSON.blocks.push(nodeJSON);
1045
- }
1046
- nodesMap[node.id] = nodeJSON;
1047
- }, this);
1048
- return startNodeJSON;
1027
+ return this.document.toNodeJSON(this);
1049
1028
  }
1050
1029
  get isVertical() {
1051
1030
  return this.document.layout.name === "vertical-fixed-layout" /* VERTICAL_FIXED_LAYOUT */;
@@ -2094,6 +2073,39 @@ var FlowDocument = class {
2094
2073
  });
2095
2074
  return result;
2096
2075
  }
2076
+ toNodeJSON(node) {
2077
+ if (this.options.toNodeJSON) {
2078
+ return this.options.toNodeJSON(node);
2079
+ }
2080
+ const nodesMap = {};
2081
+ let startNodeJSON;
2082
+ this.traverse((node2) => {
2083
+ const isSystemNode = node2.id.startsWith("$");
2084
+ if (isSystemNode) return;
2085
+ const nodeJSONData = node2.getJSONData();
2086
+ const nodeJSON = {
2087
+ id: node2.id,
2088
+ type: node2.flowNodeType
2089
+ };
2090
+ if (nodeJSONData !== void 0) {
2091
+ nodeJSON.data = nodeJSONData;
2092
+ }
2093
+ if (!startNodeJSON) startNodeJSON = nodeJSON;
2094
+ let { parent } = node2;
2095
+ if (parent && parent.id.startsWith("$")) {
2096
+ parent = parent.originParent;
2097
+ }
2098
+ const parentJSON = parent ? nodesMap[parent.id] : void 0;
2099
+ if (parentJSON) {
2100
+ if (!parentJSON.blocks) {
2101
+ parentJSON.blocks = [];
2102
+ }
2103
+ parentJSON.blocks.push(nodeJSON);
2104
+ }
2105
+ nodesMap[node2.id] = nodeJSON;
2106
+ }, node);
2107
+ return startNodeJSON;
2108
+ }
2097
2109
  /**
2098
2110
  * 移动节点
2099
2111
  * @param param0