Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit 8e12e9f

Browse files
author
Nicolas Schäfli
committed
Merge branch 'release/0.3.4' into 'master'
Release/0.3.4 See merge request Apps/bin-eLehrmittel/pdf-wrap!12
2 parents e71b916 + 58416c9 commit 8e12e9f

File tree

12 files changed

+165
-41
lines changed

12 files changed

+165
-41
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## 0.3.2 - 2019-06-12
7+
## 0.3.4 - 2019-07-12
8+
### Fixed
9+
* Form rotation is now properly supported.
10+
* Add missing tslib dependency.
11+
12+
### Changed
13+
* Update pdfjs-dist to version 2.1.266.
14+
* Update typescript to version 3.5.
15+
16+
## 0.3.3 - 2019-06-12
817
### Fixed
918
* Fix form resize bug introduced in 0.3.2.
1019

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@srag/pdf-wrap",
3-
"version": "0.3.3",
3+
"version": "0.3.4",
44
"description": "A high level PDF abstraction library with a rich set of additional features like full text document search. Its primary goal is to provide a simple api to create your own PDF viewer. Tasty! Isn't it?",
55
"repository": "https://github.com/studer-raimann/pdf-wrap",
66
"homepage": "https://studer-raimann.github.io/pdf-wrap/",
@@ -44,16 +44,17 @@
4444
"tslint": "^5.16.0",
4545
"tslint-eslint-rules": "^5.3.1",
4646
"typedoc": "^0.14.2",
47-
"typescript": "^3.4.5"
47+
"typescript": "^3.5.3"
4848
},
4949
"dependencies": {
5050
"intersection-observer": "^0.7.0",
51-
"pdfjs-dist": "2.0.943",
51+
"pdfjs-dist": "2.1.266",
5252
"requestidlecallback-polyfill": "^1.0.2",
5353
"svg.draggable.js": "2.2.2",
5454
"svg.js": "^2.7.1",
5555
"svg.resize.js": "^1.4.3",
5656
"svg.select.js": "^3.0.1",
57+
"tslib": "^1.10.0",
5758
"typescript-logging": "^0.6.2",
5859
"uuid-js": "^0.7.5"
5960
},

src/api/draw/element.builders.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export interface BorderElementBuilder<T, R> {
3939
id(value: string): T;
4040
borderColor(value: Color): T;
4141
borderWidth(px: number): T;
42+
rotation(value: number): T;
4243
build(): R;
4344
}
4445

src/api/draw/elements.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ export interface DrawElement {
2020
export interface BorderElement extends DrawElement {
2121
readonly borderColor: Color;
2222
readonly borderWidth: number;
23+
/**
24+
* Describes to rotation of the element.
25+
* @since 0.3.4
26+
*/
27+
readonly rotation: number;
2328
}
2429

2530
/**

src/paint/canvas.elements.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export interface CanvasElement<T extends DrawElement> extends Transformable <T>,
141141
export interface CanvasBorderElement<T extends DrawElement> extends CanvasElement<T> {
142142
borderWidth: number;
143143
borderColor: Color;
144+
rotation: number;
144145
}
145146

146147
/**
@@ -226,6 +227,11 @@ abstract class AbstractCanvasBorderElement<T extends DrawElement> implements Can
226227
this.borderElement.attr("stroke-width", value);
227228
}
228229

230+
get rotation(): number {
231+
const rotation: number | undefined = this.borderElement.transform().rotation;
232+
return rotation !== undefined ? rotation : 0;
233+
}
234+
229235
backwards(): void {
230236
this.borderElement.backward();
231237
}
@@ -329,6 +335,7 @@ export class CanvasPolyLine extends AbstractCanvasBorderElement<PolyLine> {
329335
.borderColor(this.borderColor)
330336
.borderWidth(this.borderWidth)
331337
.coordinates(this.coordinates)
338+
.rotation(this.rotation)
332339
.build();
333340
}
334341
}
@@ -371,6 +378,7 @@ export class CanvasRectangle extends AbstractCanvasFormElement<Rectangle> {
371378
.fillColor(this.fillColor)
372379
.position(this.position)
373380
.dimension(this.dimension)
381+
.rotation(this.rotation)
374382
.build();
375383
}
376384
}
@@ -405,6 +413,7 @@ export class CanvasCircle extends AbstractCanvasFormElement<Circle> {
405413
.fillColor(this.fillColor)
406414
.position(this.position)
407415
.diameter(this.diameter)
416+
.rotation(this.rotation)
408417
.build();
409418
}
410419
}
@@ -443,6 +452,7 @@ export class CanvasEllipse extends AbstractCanvasFormElement<Ellipse> {
443452
.fillColor(this.fillColor)
444453
.position(this.position)
445454
.dimension(this.dimension)
455+
.rotation(this.rotation)
446456
.build();
447457
}
448458
}
@@ -483,6 +493,7 @@ export class CanvasLine extends AbstractCanvasBorderElement<Line> {
483493
.borderWidth(this.borderWidth)
484494
.start(this.start)
485495
.end(this.end)
496+
.rotation(this.rotation)
486497
.build();
487498
}
488499
}

src/paint/element.builders.impl.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ abstract class AbstractBorderElementBuilder<T, R> implements BorderElementBuilde
5252
protected _id: string = `$svg${uuid.create(4).toString()}`;
5353
protected _borderColor: Color = colorFrom(Colors.BLACK);
5454
protected _borderWidth: number = 1;
55+
protected _rotation: number = 0;
5556

5657
id(value: string): T {
5758
this._id = value;
@@ -68,6 +69,13 @@ abstract class AbstractBorderElementBuilder<T, R> implements BorderElementBuilde
6869
return (this as unknown) as T;
6970
}
7071

72+
73+
rotation(value: number): T {
74+
this._rotation = value;
75+
return (this as unknown) as T;
76+
}
77+
78+
7179
abstract build(): R;
7280
}
7381

@@ -118,7 +126,8 @@ export class PolyLineBuilderImpl extends AbstractBorderElementBuilder<PolyLineBu
118126
this._borderColor,
119127
this._borderWidth,
120128
this._coordinates,
121-
this._id
129+
this._id,
130+
this._rotation
122131
);
123132
}
124133
}
@@ -150,7 +159,8 @@ export class RectangleBuilderImpl extends AbstractFormBuilder<RectangleBuilder,
150159
this._dimension,
151160
this._fillColor,
152161
this._id,
153-
this._position
162+
this._position,
163+
this._rotation
154164
);
155165
}
156166
}
@@ -185,7 +195,8 @@ export class LineBuilderImpl extends AbstractBorderElementBuilder<LineBuilder, L
185195
this._borderWidth,
186196
this._id,
187197
this._start,
188-
this._end
198+
this._end,
199+
this._rotation
189200
);
190201
}
191202
}
@@ -212,7 +223,8 @@ export class CircleBuilderImpl extends AbstractFormBuilder<CircleBuilder, Circle
212223
this._diameter,
213224
this._fillColor,
214225
this._id,
215-
this._position
226+
this._position,
227+
this._rotation
216228
);
217229
}
218230

@@ -244,7 +256,8 @@ export class EllipseBuilderImpl extends AbstractFormBuilder<EllipseBuilder, Elli
244256
this._dimension,
245257
this._fillColor,
246258
this._id,
247-
this._position
259+
this._position,
260+
this._rotation
248261
);
249262
}
250263

src/paint/elements.impl.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export class DrawablePolyLine implements PolyLine, DrawableElement {
3131
readonly borderColor: Color,
3232
readonly borderWidth: number,
3333
readonly coordinates: Array<Point>,
34-
readonly id: string
34+
readonly id: string,
35+
readonly rotation: number
3536
) {}
3637

3738
draw(canvas: Canvas): void {
@@ -41,6 +42,7 @@ export class DrawablePolyLine implements PolyLine, DrawableElement {
4142
.borderColor(this.borderColor)
4243
.borderWidth(this.borderWidth)
4344
.coordinates(this.coordinates)
45+
.rotation(this.rotation)
4446
.paint();
4547
}
4648
}
@@ -59,7 +61,8 @@ export class DrawableRectangle implements Rectangle, DrawableElement {
5961
readonly dimension: Dimension,
6062
readonly fillColor: Color,
6163
readonly id: string,
62-
readonly position: Point
64+
readonly position: Point,
65+
readonly rotation: number
6366
) {}
6467

6568
draw(canvas: Canvas): void {
@@ -71,6 +74,7 @@ export class DrawableRectangle implements Rectangle, DrawableElement {
7174
.fillColor(this.fillColor)
7275
.position(this.position)
7376
.dimension(this.dimension)
77+
.rotation(this.rotation)
7478
.paint();
7579
}
7680
}
@@ -82,6 +86,7 @@ export class DrawableLine implements Line, DrawableElement {
8286
readonly id: string,
8387
readonly start: Point,
8488
readonly end: Point,
89+
readonly rotation: number
8590
) {}
8691

8792
draw(canvas: Canvas): void {
@@ -91,6 +96,7 @@ export class DrawableLine implements Line, DrawableElement {
9196
.borderWidth(this.borderWidth)
9297
.start(this.start)
9398
.end(this.end)
99+
.rotation(this.rotation)
94100
.paint();
95101
}
96102
}
@@ -102,7 +108,8 @@ export class DrawableCircle implements Circle, DrawableElement {
102108
readonly diameter: number,
103109
readonly fillColor: Color,
104110
readonly id: string,
105-
readonly position: Point
111+
readonly position: Point,
112+
readonly rotation: number
106113
) {}
107114

108115
draw(canvas: Canvas): void {
@@ -113,6 +120,7 @@ export class DrawableCircle implements Circle, DrawableElement {
113120
.fillColor(this.fillColor)
114121
.position(this.position)
115122
.diameter(this.diameter)
123+
.rotation(this.rotation)
116124
.paint();
117125
}
118126
}
@@ -124,7 +132,8 @@ export class DrawableEllipse implements Ellipse, DrawableElement {
124132
readonly dimension: Dimension,
125133
readonly fillColor: Color,
126134
readonly id: string,
127-
readonly position: Point
135+
readonly position: Point,
136+
readonly rotation: number
128137
) {}
129138

130139
draw(canvas: Canvas): void {
@@ -135,6 +144,7 @@ export class DrawableEllipse implements Ellipse, DrawableElement {
135144
.fillColor(this.fillColor)
136145
.position(this.position)
137146
.dimension(this.dimension)
147+
.rotation(this.rotation)
138148
.paint();
139149
}
140150
}

0 commit comments

Comments
 (0)