-
SVG Preview
+
SVG {{ previewTitle }}
@@ -44,6 +54,7 @@
SVG Preview
type="button"
icon="pi pi-file-import"
label="Import SVG"
+ [disabled]="submitting"
(click)="chooseFile()">
SVG Preview
icon="pi pi-file-export"
[disabled]="!sanitizedSvg"
label="Export SVG"
+ [disabled]="submitting"
(click)="exportSVG()">
;
@@ -34,8 +35,31 @@ export class SvgCreatorComponent {
this.clearFile();
}
+ ngOnInit() {
+ this.previewTitle = 'Preview';
+ this.creator.svgCode$.subscribe(rs => {
+ if (rs.done) {
+ // SSE 结束后统一解析
+ const svgCodes = this.creator.extractSVGCode(rs.content);
+ if (svgCodes.length) {
+ this.svgCode = svgCodes.join('\n');
+ }
+ } else {
+ // 临时显示输出
+ this._svgCode = rs.content
+ .replace(/[\s\S]*(?=(