|
|
@@ -337,37 +337,7 @@ export class FlowNodeEntity extends Entity<FlowNodeEntityConfig> {
|
|
|
* @param newId
|
|
|
*/
|
|
|
toJSON(): FlowNodeJSON {
|
|
|
- if (this.document.options.toNodeJSON) {
|
|
|
- return this.document.options.toNodeJSON(this);
|
|
|
- }
|
|
|
- const nodesMap: Record<string, FlowNodeJSON> = {};
|
|
|
- let startNodeJSON: FlowNodeJSON;
|
|
|
- this.document.traverse((node) => {
|
|
|
- const isSystemNode = node.id.startsWith('$');
|
|
|
- if (isSystemNode) return;
|
|
|
- const nodeJSONData = this.getJSONData();
|
|
|
- const nodeJSON: FlowNodeJSON = {
|
|
|
- id: node.id,
|
|
|
- type: node.flowNodeType,
|
|
|
- };
|
|
|
- if (nodeJSONData !== undefined) {
|
|
|
- nodeJSON.data = nodeJSONData;
|
|
|
- }
|
|
|
- if (!startNodeJSON) startNodeJSON = nodeJSON;
|
|
|
- let { parent } = node;
|
|
|
- if (parent && parent.id.startsWith('$')) {
|
|
|
- parent = parent.originParent;
|
|
|
- }
|
|
|
- const parentJSON = parent ? nodesMap[parent.id] : undefined;
|
|
|
- if (parentJSON) {
|
|
|
- if (!parentJSON.blocks) {
|
|
|
- parentJSON.blocks = [];
|
|
|
- }
|
|
|
- parentJSON.blocks.push(nodeJSON);
|
|
|
- }
|
|
|
- nodesMap[node.id] = nodeJSON;
|
|
|
- }, this);
|
|
|
- return startNodeJSON!;
|
|
|
+ return this.document.toNodeJSON(this);
|
|
|
}
|
|
|
|
|
|
get isVertical(): boolean {
|