* 导出 schema
(stage: IPublicEnumTransformStage = IPublicEnumTransformStage.Save, options: any = {})
| 945 | * 导出 schema |
| 946 | */ |
| 947 | export<T = IPublicTypeNodeSchema>(stage: IPublicEnumTransformStage = IPublicEnumTransformStage.Save, options: any = {}): T { |
| 948 | stage = compatStage(stage); |
| 949 | const baseSchema: any = { |
| 950 | componentName: this.componentName, |
| 951 | }; |
| 952 | |
| 953 | if (stage !== IPublicEnumTransformStage.Clone) { |
| 954 | baseSchema.id = this.id; |
| 955 | } |
| 956 | if (stage === IPublicEnumTransformStage.Render) { |
| 957 | baseSchema.docId = this.document.id; |
| 958 | } |
| 959 | |
| 960 | if (this.isLeaf()) { |
| 961 | if (!options.bypassChildren) { |
| 962 | baseSchema.children = this.props.get('children')?.export(stage); |
| 963 | } |
| 964 | return baseSchema; |
| 965 | } |
| 966 | |
| 967 | const { props = {}, extras } = this.props.export(stage) || {}; |
| 968 | const _extras_: { [key: string]: any } = { |
| 969 | ...extras, |
| 970 | }; |
| 971 | /* istanbul ignore next */ |
| 972 | Object.keys(this._addons).forEach((key) => { |
| 973 | const addon = this._addons[key]; |
| 974 | if (addon) { |
| 975 | if (addon.isProp) { |
| 976 | (props as any)[getConvertedExtraKey(key)] = addon.exportData(); |
| 977 | } else { |
| 978 | _extras_[key] = addon.exportData(); |
| 979 | } |
| 980 | } |
| 981 | }); |
| 982 | |
| 983 | const schema: any = { |
| 984 | ...baseSchema, |
| 985 | props: this.document.designer.transformProps(props, this, stage), |
| 986 | ...this.document.designer.transformProps(_extras_, this, stage), |
| 987 | }; |
| 988 | |
| 989 | if (this.isParental() && this.children && this.children.size > 0 && !options.bypassChildren) { |
| 990 | schema.children = this.children.export(stage); |
| 991 | } |
| 992 | |
| 993 | return schema; |
| 994 | } |
| 995 | |
| 996 | /** |
| 997 | * 判断是否包含特定节点 |
no test coverage detected