@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/index.d.mts CHANGED
@@ -163,6 +163,7 @@ declare const ConstantKeys: {
163
163
  */
164
164
  INLINE_BLOCKS_PADDING_TOP: string;
165
165
  NODE_SPACING: string;
166
+ BRANCH_SPACING: string;
166
167
  ROUNDED_LINE_X_RADIUS: string;
167
168
  ROUNDED_LINE_Y_RADIUS: string;
168
169
  INLINE_BLOCKS_PADDING_BOTTOM: string;
@@ -401,6 +402,7 @@ declare class FlowDocument<T = FlowDocumentJSON> implements Disposable {
401
402
  * 返回需要渲染的数据
402
403
  */
403
404
  getRenderDatas<T extends EntityData>(dataRegistry: EntityDataRegistry<T>, containHiddenNodes?: boolean): T[];
405
+ toNodeJSON(node: FlowNodeEntity): FlowNodeJSON;
404
406
  /**
405
407
  * 移动节点
406
408
  * @param param0
@@ -975,6 +977,10 @@ declare const DefaultSpacingKey: {
975
977
  * 普通节点间距。垂直 / 水平
976
978
  */
977
979
  NODE_SPACING: string;
980
+ /**
981
+ * 分支节点间距
982
+ */
983
+ BRANCH_SPACING: string;
978
984
  /**
979
985
  * 圆弧线条 x radius
980
986
  */
@@ -1003,6 +1009,9 @@ declare const DefaultSpacingKey: {
1003
1009
  declare const DEFAULT_SPACING: {
1004
1010
  [x: string]: number;
1005
1011
  NULL: number;
1012
+ /**
1013
+ * @deprecated use 'BRANCH_SPACING' instead
1014
+ */
1006
1015
  MARGIN_RIGHT: number;
1007
1016
  INLINE_BLOCK_PADDING_BOTTOM: number;
1008
1017
  INLINE_BLOCKS_PADDING_TOP: number;
package/dist/index.d.ts CHANGED
@@ -163,6 +163,7 @@ declare const ConstantKeys: {
163
163
  */
164
164
  INLINE_BLOCKS_PADDING_TOP: string;
165
165
  NODE_SPACING: string;
166
+ BRANCH_SPACING: string;
166
167
  ROUNDED_LINE_X_RADIUS: string;
167
168
  ROUNDED_LINE_Y_RADIUS: string;
168
169
  INLINE_BLOCKS_PADDING_BOTTOM: string;
@@ -401,6 +402,7 @@ declare class FlowDocument<T = FlowDocumentJSON> implements Disposable {
401
402
  * 返回需要渲染的数据
402
403
  */
403
404
  getRenderDatas<T extends EntityData>(dataRegistry: EntityDataRegistry<T>, containHiddenNodes?: boolean): T[];
405
+ toNodeJSON(node: FlowNodeEntity): FlowNodeJSON;
404
406
  /**
405
407
  * 移动节点
406
408
  * @param param0
@@ -975,6 +977,10 @@ declare const DefaultSpacingKey: {
975
977
  * 普通节点间距。垂直 / 水平
976
978
  */
977
979
  NODE_SPACING: string;
980
+ /**
981
+ * 分支节点间距
982
+ */
983
+ BRANCH_SPACING: string;
978
984
  /**
979
985
  * 圆弧线条 x radius
980
986
  */
@@ -1003,6 +1009,9 @@ declare const DefaultSpacingKey: {
1003
1009
  declare const DEFAULT_SPACING: {
1004
1010
  [x: string]: number;
1005
1011
  NULL: number;
1012
+ /**
1013
+ * @deprecated use 'BRANCH_SPACING' instead
1014
+ */
1006
1015
  MARGIN_RIGHT: number;
1007
1016
  INLINE_BLOCK_PADDING_BOTTOM: number;
1008
1017
  INLINE_BLOCKS_PADDING_TOP: number;
package/dist/index.js CHANGED
@@ -151,6 +151,10 @@ var DefaultSpacingKey = {
151
151
  * 普通节点间距。垂直 / 水平
152
152
  */
153
153
  NODE_SPACING: "SPACING",
154
+ /**
155
+ * 分支节点间距
156
+ */
157
+ BRANCH_SPACING: "BRANCH_SPACING",
154
158
  /**
155
159
  * 圆弧线条 x radius
156
160
  */
@@ -177,8 +181,13 @@ var DEFAULT_SPACING = {
177
181
  NULL: 0,
178
182
  [DefaultSpacingKey.NODE_SPACING]: 32,
179
183
  // 普通节点间距。垂直 / 水平
184
+ [DefaultSpacingKey.BRANCH_SPACING]: 20,
185
+ // 分支节点间距
186
+ /**
187
+ * @deprecated use 'BRANCH_SPACING' instead
188
+ */
180
189
  MARGIN_RIGHT: 20,
181
- // 普通节点右边间距
190
+ // 分支节点右边间距
182
191
  INLINE_BLOCK_PADDING_BOTTOM: 16,
183
192
  // block 底部留白
184
193
  INLINE_BLOCKS_PADDING_TOP: 30,
@@ -1074,37 +1083,7 @@ var FlowNodeEntity = class extends import_core4.Entity {
1074
1083
  * @param newId
1075
1084
  */
1076
1085
  toJSON() {
1077
- if (this.document.options.toNodeJSON) {
1078
- return this.document.options.toNodeJSON(this);
1079
- }
1080
- const nodesMap = {};
1081
- let startNodeJSON;
1082
- this.document.traverse((node) => {
1083
- const isSystemNode = node.id.startsWith("$");
1084
- if (isSystemNode) return;
1085
- const nodeJSONData = this.getJSONData();
1086
- const nodeJSON = {
1087
- id: node.id,
1088
- type: node.flowNodeType
1089
- };
1090
- if (nodeJSONData !== void 0) {
1091
- nodeJSON.data = nodeJSONData;
1092
- }
1093
- if (!startNodeJSON) startNodeJSON = nodeJSON;
1094
- let { parent } = node;
1095
- if (parent && parent.id.startsWith("$")) {
1096
- parent = parent.originParent;
1097
- }
1098
- const parentJSON = parent ? nodesMap[parent.id] : void 0;
1099
- if (parentJSON) {
1100
- if (!parentJSON.blocks) {
1101
- parentJSON.blocks = [];
1102
- }
1103
- parentJSON.blocks.push(nodeJSON);
1104
- }
1105
- nodesMap[node.id] = nodeJSON;
1106
- }, this);
1107
- return startNodeJSON;
1086
+ return this.document.toNodeJSON(this);
1108
1087
  }
1109
1088
  get isVertical() {
1110
1089
  return this.document.layout.name === "vertical-fixed-layout" /* VERTICAL_FIXED_LAYOUT */;
@@ -2153,6 +2132,39 @@ var FlowDocument = class {
2153
2132
  });
2154
2133
  return result;
2155
2134
  }
2135
+ toNodeJSON(node) {
2136
+ if (this.options.toNodeJSON) {
2137
+ return this.options.toNodeJSON(node);
2138
+ }
2139
+ const nodesMap = {};
2140
+ let startNodeJSON;
2141
+ this.traverse((node2) => {
2142
+ const isSystemNode = node2.id.startsWith("$");
2143
+ if (isSystemNode) return;
2144
+ const nodeJSONData = node2.getJSONData();
2145
+ const nodeJSON = {
2146
+ id: node2.id,
2147
+ type: node2.flowNodeType
2148
+ };
2149
+ if (nodeJSONData !== void 0) {
2150
+ nodeJSON.data = nodeJSONData;
2151
+ }
2152
+ if (!startNodeJSON) startNodeJSON = nodeJSON;
2153
+ let { parent } = node2;
2154
+ if (parent && parent.id.startsWith("$")) {
2155
+ parent = parent.originParent;
2156
+ }
2157
+ const parentJSON = parent ? nodesMap[parent.id] : void 0;
2158
+ if (parentJSON) {
2159
+ if (!parentJSON.blocks) {
2160
+ parentJSON.blocks = [];
2161
+ }
2162
+ parentJSON.blocks.push(nodeJSON);
2163
+ }
2164
+ nodesMap[node2.id] = nodeJSON;
2165
+ }, node);
2166
+ return startNodeJSON;
2167
+ }
2156
2168
  /**
2157
2169
  * 移动节点
2158
2170
  * @param param0