Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.

Commit d0527e9

Browse files
committed
Merge branch 'ng-legacy'
* ng-legacy: Add method for requesting full drawing history # Conflicts: # dist/canvas-whiteboard.component.js # dist/canvas-whiteboard.component.metadata.json # package-lock.json # package.json # src/canvas-whiteboard.component.ts
2 parents 484fa9f + 84c26c9 commit d0527e9

16 files changed

+91
-21
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ export class AppComponent {
370370
}
371371
}
372372
```
373+
### Requesting the full update history so far
374+
Can be called via the method `getDrawingHistory(): CanvasWhiteboardUpdate[]`. The items will be deep cloned for consistency using lodash.
373375
374376
## Saving drawn canvas as an image
375377
In order to save drawn images you can either click the Save button in the canvas,

dist/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ export class AppComponent {
370370
}
371371
}
372372
```
373+
### Requesting the full update history so far
374+
Can be called via the method `getDrawingHistory(): CanvasWhiteboardUpdate[]`. The items will be deep cloned for consistency using lodash.
373375
374376
## Saving drawn canvas as an image
375377
In order to save drawn images you can either click the Save button in the canvas,

dist/bundles/ng2-canvas-whiteboard.umd.js

Lines changed: 13 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/bundles/ng2-canvas-whiteboard.umd.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modules/ng2-canvas-whiteboard.es5.js

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modules/ng2-canvas-whiteboard.js

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ng2-canvas-whiteboard.metadata.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ng2-canvas-whiteboard",
3-
"version": "3.0.2",
3+
"version": "3.0.3",
44
"description": "A Canvas component for Angular which supports free drawing.",
55
"main": "./bundles/ng2-canvas-whiteboard.umd.js",
66
"module": "./modules/ng2-canvas-whiteboard.es5.js",
@@ -40,7 +40,9 @@
4040
"peerDependencies": {
4141
"rxjs": "^6.0.0"
4242
},
43-
"dependencies": {},
43+
"dependencies": {
44+
"lodash": "4.17.11"
45+
},
4446
"devDependencies": {
4547
"@angular/animations": "^6.0.0",
4648
"@angular/common": "^6.0.0",
@@ -50,6 +52,7 @@
5052
"@angular/platform-browser": "^6.0.0",
5153
"@angular/platform-browser-dynamic": "^6.0.0",
5254
"@angular/platform-server": "^6.0.0",
55+
"@types/lodash": "4.14.116",
5356
"@types/node": "7.0.10",
5457
"chalk": "1.1.3",
5558
"core-js": "2.4.1",

dist/src/canvas-whiteboard.component.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,11 @@ export declare class CanvasWhiteboardComponent implements OnInit, AfterViewInit,
391391
*/
392392
toggleShapeSelector(value: boolean): void;
393393
selectShape(newShapeBlueprint: INewCanvasWhiteboardShape<CanvasWhiteboardShape>): void;
394+
/**
395+
* Returns a deep copy of the current drawing history for the canvas.
396+
* The deep copy is returned because we don't want anyone to mutate the current history
397+
*/
398+
getDrawingHistory(): CanvasWhiteboardUpdate[];
394399
/**
395400
* Unsubscribe from a given subscription if it is active
396401
* @param subscription

package-lock.json

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ng2-canvas-whiteboard",
3-
"version": "3.0.2",
3+
"version": "3.0.3",
44
"description": "A Canvas component for Angular which supports free drawing.",
55
"main": "./bundles/ng2-canvas-whiteboard.umd.js",
66
"module": "./modules/ng2-canvas-whiteboard.es5.js",
@@ -40,7 +40,9 @@
4040
"peerDependencies": {
4141
"rxjs": "^6.0.0"
4242
},
43-
"dependencies": {},
43+
"dependencies": {
44+
"lodash": "4.17.11"
45+
},
4446
"devDependencies": {
4547
"@angular/animations": "^6.0.0",
4648
"@angular/common": "^6.0.0",
@@ -50,6 +52,7 @@
5052
"@angular/platform-browser": "^6.0.0",
5153
"@angular/platform-browser-dynamic": "^6.0.0",
5254
"@angular/platform-server": "^6.0.0",
55+
"@types/lodash": "4.14.116",
5356
"@types/node": "7.0.10",
5457
"chalk": "1.1.3",
5558
"core-js": "2.4.1",

public_api.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/canvas-whiteboard.component.js

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/canvas-whiteboard.component.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {CanvasWhiteboardShapeService, INewCanvasWhiteboardShape} from "./shapes/
1818
import {CanvasWhiteboardShapeOptions} from "./shapes/canvas-whiteboard-shape-options";
1919
import {fromEvent, Subscription} from "rxjs/index";
2020
import {debounceTime, distinctUntilChanged} from "rxjs/operators";
21+
import {cloneDeep} from "lodash";
2122

2223
@Component({
2324
selector: 'canvas-whiteboard',
@@ -820,7 +821,7 @@ export class CanvasWhiteboardComponent implements OnInit, AfterViewInit, OnChang
820821
* @return Emits an Array of Updates when the batch.
821822
*/
822823
private _prepareUpdateForBatchDispatch(update: CanvasWhiteboardUpdate): void {
823-
this._batchUpdates.push(update);
824+
this._batchUpdates.push(cloneDeep(update));
824825
if (!this._updateTimeout) {
825826
this._updateTimeout = setTimeout(() => {
826827
this.onBatchUpdate.emit(this._batchUpdates);
@@ -1074,6 +1075,14 @@ export class CanvasWhiteboardComponent implements OnInit, AfterViewInit, OnChang
10741075
this.selectedShapeConstructor = newShapeBlueprint;
10751076
}
10761077

1078+
/**
1079+
* Returns a deep copy of the current drawing history for the canvas.
1080+
* The deep copy is returned because we don't want anyone to mutate the current history
1081+
*/
1082+
getDrawingHistory(): CanvasWhiteboardUpdate[] {
1083+
return cloneDeep(this._updateHistory);
1084+
}
1085+
10771086
/**
10781087
* Unsubscribe from a given subscription if it is active
10791088
* @param subscription

src/ng2-canvas-whiteboard.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"target": "es5",
1818
"skipLibCheck": true,
1919
"types": [
20-
"node"
20+
"node",
21+
"lodash"
2122
]
2223
},
2324
"exclude": [

0 commit comments

Comments
 (0)