This commit is contained in:
crusader 2018-10-11 17:32:00 +09:00
parent d47a5e636c
commit 3a0a72aca4
10 changed files with 22 additions and 20 deletions

View File

@ -79,6 +79,7 @@
"devtron": "^1.4.0", "devtron": "^1.4.0",
"dexie": "^2.0.4", "dexie": "^2.0.4",
"electron": "^2.0.9", "electron": "^2.0.9",
"electron-i18n": "^1.606.0",
"electron-builder": "^20.28.4", "electron-builder": "^20.28.4",
"electron-connect": "^0.6.3", "electron-connect": "^0.6.3",
"electron-connect-webpack-plugin": "^0.1.1", "electron-connect-webpack-plugin": "^0.1.1",

View File

@ -33,12 +33,12 @@
</p-footer> </p-footer>
</p-dialog> </p-dialog>
<p-dialog header="Export as JPG" [(visible)]="displayExportJPG" [modal]="true" [responsive]="true" [width]="350" <p-dialog header="Export as JPEG" [(visible)]="displayExportJPEG" [modal]="true" [responsive]="true" [width]="350"
[minWidth]="200" [minY]="70" [closable]="false"> [minWidth]="200" [minY]="70" [closable]="false">
<app-menu-export-jpg #exportJPG></app-menu-export-jpg> <app-menu-export-jpeg #exportJPEG></app-menu-export-jpeg>
<p-footer> <p-footer>
<button type="button" pButton icon="pi pi-check" (click)="exportJPG.export();" label="Yes"></button> <button type="button" pButton icon="pi pi-check" (click)="exportJPEG.export();" label="Yes"></button>
<button type="button" pButton icon="pi pi-close" (click)="displayExportJPG=false" label="No" class="ui-button-secondary"></button> <button type="button" pButton icon="pi pi-close" (click)="displayExportJPEG=false" label="No" class="ui-button-secondary"></button>
</p-footer> </p-footer>
</p-dialog> </p-dialog>

View File

@ -22,7 +22,7 @@ export class AppComponent implements OnInit, AfterContentInit, AfterViewInit, On
menuSubscription: Subscription; menuSubscription: Subscription;
displayAbout: boolean; displayAbout: boolean;
displayExportJPG: boolean; displayExportJPEG: boolean;
displayExportPNG: boolean; displayExportPNG: boolean;
displayExportSVG: boolean; displayExportSVG: boolean;
displayPreferences: boolean; displayPreferences: boolean;
@ -50,8 +50,8 @@ export class AppComponent implements OnInit, AfterContentInit, AfterViewInit, On
case 'show-about': case 'show-about':
this.displayAbout = true; this.displayAbout = true;
break; break;
case 'show-export-jpg': case 'show-export-jpeg':
this.displayExportJPG = true; this.displayExportJPEG = true;
break; break;
case 'show-export-png': case 'show-export-png':
this.displayExportPNG = true; this.displayExportPNG = true;

View File

@ -1,4 +1,4 @@
<div> <div>
<p-messages [(value)]="msgs"></p-messages> <p-messages [(value)]="msgs"></p-messages>
Export JPG Export JPEG
</div> </div>

View File

@ -9,11 +9,11 @@ import { Message } from 'primeng/primeng';
const { saveSvgAsPng, svgAsDataUri } = require('save-svg-as-png'); const { saveSvgAsPng, svgAsDataUri } = require('save-svg-as-png');
@Component({ @Component({
selector: 'app-menu-export-jpg', selector: 'app-menu-export-jpeg',
templateUrl: './export-jpg.component.html', templateUrl: './export-jpeg.component.html',
styleUrls: ['./export-jpg.component.scss'], styleUrls: ['./export-jpeg.component.scss'],
}) })
export class ExportJPGComponent implements OnInit, AfterContentInit, OnDestroy { export class ExportJPEGComponent implements OnInit, AfterContentInit, OnDestroy {
msgs: Message[] = []; msgs: Message[] = [];
constructor( constructor(
@ -53,7 +53,7 @@ export class ExportJPGComponent implements OnInit, AfterContentInit, OnDestroy {
// svgAsDataUri(targetDisplayElementRef.nativeElement, {}, function (uri) { // svgAsDataUri(targetDisplayElementRef.nativeElement, {}, function (uri) {
// console.log(`uri: ${uri}`); // console.log(`uri: ${uri}`);
// }); // });
saveSvgAsPng(targetDisplayElementRef.nativeElement, 'diagram.jpg', { backgroundColor: '#ffffff', encoderType: 'image/jpeg' }); saveSvgAsPng(targetDisplayElementRef.nativeElement, 'diagram.jpeg', { backgroundColor: '#ffffff', encoderType: 'image/jpeg' });
}), }),
).subscribe(); ).subscribe();
} }

View File

@ -1,5 +1,5 @@
import { AboutComponent } from './about.component'; import { AboutComponent } from './about.component';
import { ExportJPGComponent } from './export-jpg.component'; import { ExportJPEGComponent } from './export-jpeg.component';
import { ExportPNGComponent } from './export-png.component'; import { ExportPNGComponent } from './export-png.component';
import { ExportSVGComponent } from './export-svg.component'; import { ExportSVGComponent } from './export-svg.component';
import { PreferencesComponent } from './preferences.component'; import { PreferencesComponent } from './preferences.component';
@ -7,7 +7,7 @@ import { PrintComponent } from './print.component';
export const COMPONENTS = [ export const COMPONENTS = [
AboutComponent, AboutComponent,
ExportJPGComponent, ExportJPEGComponent,
ExportPNGComponent, ExportPNGComponent,
ExportSVGComponent, ExportSVGComponent,
PreferencesComponent, PreferencesComponent,

View File

@ -3,7 +3,7 @@ export type MenuEvent =
| 'show-preferences' | 'show-preferences'
| 'show-about' | 'show-about'
| 'show-export-png' | 'show-export-png'
| 'show-export-jpg' | 'show-export-jpeg'
| 'show-export-svg' | 'show-export-svg'
| 'show-export-csv' | 'show-export-csv'
| 'show-print' | 'show-print'

View File

@ -3,7 +3,7 @@ export type MenuIDs =
| 'preferences' | 'preferences'
| 'about' | 'about'
| 'export-png' | 'export-png'
| 'export-jpg' | 'export-jpeg'
| 'export-svg' | 'export-svg'
| 'export-csv' | 'export-csv'
| 'print' | 'print'

View File

@ -62,15 +62,16 @@ export function buildDefaultMenu(
click: emit('show-export-png'), click: emit('show-export-png'),
}, },
{ {
label: __DARWIN__ ? 'JPG…' : 'JPG…', label: __DARWIN__ ? 'JPEG…' : 'JPEG…',
id: 'export-jpg', id: 'export-jpeg',
click: emit('show-export-jpg'), click: emit('show-export-jpeg'),
}, },
{ {
label: __DARWIN__ ? 'SVG…' : 'SVG…', label: __DARWIN__ ? 'SVG…' : 'SVG…',
id: 'export-svg', id: 'export-svg',
click: emit('show-export-svg'), click: emit('show-export-svg'),
}, },
separator,
{ {
label: __DARWIN__ ? 'CSV…' : 'CSV…', label: __DARWIN__ ? 'CSV…' : 'CSV…',
id: 'export-csv', id: 'export-csv',