Skip to content

Commit c213478

Browse files
authored
Merge pull request #76 from kevoj/master
Merge with Master
2 parents 0892d2c + de28391 commit c213478

File tree

3 files changed

+9834
-9916
lines changed

3 files changed

+9834
-9916
lines changed

projects/angular-editor-fabric-js/src/lib/angular-editor-fabric-js.component.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,15 +505,14 @@ export class FabricjsEditorComponent implements AfterViewInit {
505505
const activeObject = this.canvas.getActiveObject();
506506
const activeGroup = this.canvas.getActiveObjects();
507507

508-
if (activeObject) {
509-
this.canvas.remove(activeObject);
510-
// this.textString = '';
511-
} else if (activeGroup) {
508+
if (activeGroup) {
512509
this.canvas.discardActiveObject();
513510
const self = this;
514511
activeGroup.forEach((object) => {
515512
self.canvas.remove(object);
516513
});
514+
} else if (activeObject) {
515+
this.canvas.remove(activeObject);
517516
}
518517
}
519518

@@ -559,14 +558,36 @@ export class FabricjsEditorComponent implements AfterViewInit {
559558
image.src = this.canvas.toDataURL({format: 'png'});
560559
const w = window.open('');
561560
w.document.write(image.outerHTML);
561+
this.downLoadImage();
562+
}
563+
564+
downLoadImage(){
565+
const c = this.canvas.toDataURL({format: 'png'});
566+
const downloadLink = document.createElement('a');
567+
document.body.appendChild(downloadLink);
568+
downloadLink.href = c;
569+
downloadLink.target = '_self';
570+
downloadLink.download = Date.now()+'.png';
571+
downloadLink.click();
562572
}
563573

564574
rasterizeSVG() {
565575
const w = window.open('');
566576
w.document.write(this.canvas.toSVG());
577+
this.downLoadSVG();
567578
return 'data:image/svg+xml;utf8,' + encodeURIComponent(this.canvas.toSVG());
568579
}
569580

581+
downLoadSVG(){
582+
const c = 'data:image/svg+xml;utf8,' + encodeURIComponent(this.canvas.toSVG());
583+
const downloadLink = document.createElement('a');
584+
document.body.appendChild(downloadLink);
585+
downloadLink.href = c;
586+
downloadLink.target = '_self';
587+
downloadLink.download = Date.now()+'.svg';
588+
downloadLink.click();
589+
}
590+
570591
saveCanvasToJSON() {
571592
const json = JSON.stringify(this.canvas);
572593
localStorage.setItem('Kanvas', json);

src/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="container">
22
<div class="row">
33
<div class="col-xl-12 main-title">
4-
<h4>Github: <a href="https://github.com/kevoj/angular-editor-fabric-js">angular-editor-fabric-js</a></h4>
4+
<h4>Github: <a href="https://github.com/saqib92/angular-editor-fabric-js">angular-editor-fabric-js</a></h4>
55
</div>
66
<div class="col-xl-12">
77
<div class="row">

0 commit comments

Comments
 (0)