@leapfrog/interactive-canvas 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dimensions/pixel-canvas-dimensions.d.ts +13 -0
- package/dist/dimensions/print-6-col-canvas-dimensions.d.ts +18 -0
- package/dist/dimensions/print-8-col-canvas-dimensions.d.ts +18 -0
- package/dist/font/font-library.d.ts +22 -0
- package/dist/font/font-library.interface.d.ts +20 -0
- package/dist/font/font.interface.d.ts +20 -0
- package/dist/font/unknown-font.d.ts +6 -0
- package/dist/index.d.ts +47 -0
- package/dist/interactive-canvas.impl.d.ts +305 -0
- package/dist/interactive-canvas.interface.d.ts +221 -0
- package/dist/interactive-canvas.js +34 -0
- package/dist/interactive-canvas.js.map +1 -0
- package/dist/interactive-canvas.nomin.js +57456 -0
- package/dist/layout/abstract-layout-manager.d.ts +18 -0
- package/dist/layout/advanced-layout-manager.d.ts +15 -0
- package/dist/layout/function/pin-to-bottom.layout-function.d.ts +4 -0
- package/dist/layout/function/redraw-all.layout-function.d.ts +4 -0
- package/dist/layout/function/reposition-borders.layout-function.d.ts +4 -0
- package/dist/layout/function/reposition-cutoffs.layout-function.d.ts +4 -0
- package/dist/layout/function/resize-canvas.layout-function.d.ts +4 -0
- package/dist/layout/function/stack-objects.layout-function.d.ts +11 -0
- package/dist/layout/function/update-object-dimensions.layout-function.d.ts +4 -0
- package/dist/layout/layout-manager.enum.d.ts +5 -0
- package/dist/layout/layout-manager.interface.d.ts +13 -0
- package/dist/layout/standard-layout-manager.d.ts +36 -0
- package/dist/mutator/mutable-background-color.interface.d.ts +15 -0
- package/dist/mutator/mutable-color.interface.d.ts +6 -0
- package/dist/mutator/mutable-image.interface.d.ts +28 -0
- package/dist/mutator/mutable-position.interface.d.ts +33 -0
- package/dist/mutator/mutable-text-style.interface.d.ts +149 -0
- package/dist/mutator/mutable-text.interface.d.ts +40 -0
- package/dist/object/abstract-canvas-object.d.ts +155 -0
- package/dist/object/canvas-object-data.d.ts +23 -0
- package/dist/object/canvas-object.interface.d.ts +96 -0
- package/dist/object/impl/border.d.ts +60 -0
- package/dist/object/impl/cutoff.d.ts +60 -0
- package/dist/object/impl/horizontal-rule.d.ts +89 -0
- package/dist/object/impl/image.d.ts +82 -0
- package/dist/object/impl/rectangle.d.ts +59 -0
- package/dist/object/impl/text.d.ts +255 -0
- package/dist/object/impl/vertical-rule.d.ts +89 -0
- package/dist/profile/canvas-profile.interface.d.ts +22 -0
- package/dist/profile/default-canvas-profile.d.ts +23 -0
- package/dist/types/canvas-dimension-restrictions.interface.d.ts +14 -0
- package/dist/types/canvas-dimensions.interface.d.ts +21 -0
- package/dist/types/canvas-state.interface.d.ts +11 -0
- package/dist/types/dimension-restrictions.interface.d.ts +6 -0
- package/dist/types/image-type.enum.d.ts +6 -0
- package/dist/types/margin.interface.d.ts +6 -0
- package/dist/types/object-dimensions.interface.d.ts +23 -0
- package/dist/types/object-type.enum.d.ts +10 -0
- package/dist/types/overflow.interface.d.ts +4 -0
- package/dist/types/position.interface.d.ts +6 -0
- package/dist/types/rect.interface.d.ts +6 -0
- package/dist/types/selection-data.interface.d.ts +19 -0
- package/dist/types/text-alignment.interface.d.ts +1 -0
- package/package.json +32 -0
- package/readme.md +43 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { ICanvasObject } from "../canvas-object.interface";
|
|
3
|
+
import { IMutableColor, IMutablePosition } from "../..";
|
|
4
|
+
import { AbstractCanvasObject } from "../abstract-canvas-object";
|
|
5
|
+
import { CanvasObjectData } from "../canvas-object-data";
|
|
6
|
+
import { InteractiveCanvas } from "../../interactive-canvas.impl";
|
|
7
|
+
import { fabric } from "fabric";
|
|
8
|
+
/**
|
|
9
|
+
* Vertical rule. A basic block of color that spans the canvas/row height.
|
|
10
|
+
*/
|
|
11
|
+
export interface IVerticalRule extends ICanvasObject, IMutableColor, IMutablePosition {
|
|
12
|
+
/**
|
|
13
|
+
* Get the width of the rule.
|
|
14
|
+
*/
|
|
15
|
+
getStrokeWidth(): number;
|
|
16
|
+
/**
|
|
17
|
+
* Get an observable of the width of the rule.
|
|
18
|
+
*/
|
|
19
|
+
getStrokeWidth$(): Observable<number>;
|
|
20
|
+
/**
|
|
21
|
+
* Set the rule width.
|
|
22
|
+
* @param width New width.
|
|
23
|
+
*/
|
|
24
|
+
setStrokeWidth(width: number): void;
|
|
25
|
+
}
|
|
26
|
+
export declare class VerticalRule extends AbstractCanvasObject<fabric.Rect> implements IVerticalRule {
|
|
27
|
+
private readonly strokeWidth$;
|
|
28
|
+
constructor(canvas: InteractiveCanvas, fabricObject: fabric.Rect, persistedField?: CanvasObjectData);
|
|
29
|
+
/**
|
|
30
|
+
* @override
|
|
31
|
+
* @inheritDoc
|
|
32
|
+
*/
|
|
33
|
+
getStrokeWidth(): number;
|
|
34
|
+
/**
|
|
35
|
+
* @override
|
|
36
|
+
* @inheritDoc
|
|
37
|
+
*/
|
|
38
|
+
getStrokeWidth$(): Observable<number>;
|
|
39
|
+
/**
|
|
40
|
+
* @override
|
|
41
|
+
* @inheritDoc
|
|
42
|
+
*/
|
|
43
|
+
setStrokeWidth(width: number): void;
|
|
44
|
+
/**
|
|
45
|
+
* @override
|
|
46
|
+
* @inheritDoc
|
|
47
|
+
*/
|
|
48
|
+
getColor(): string;
|
|
49
|
+
/**
|
|
50
|
+
* @override
|
|
51
|
+
* @inheritDoc
|
|
52
|
+
*/
|
|
53
|
+
setColor(color: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* @override
|
|
56
|
+
* @inheritDoc
|
|
57
|
+
*/
|
|
58
|
+
centerHorizontally(): void;
|
|
59
|
+
/**
|
|
60
|
+
* @override
|
|
61
|
+
* @inheritDoc
|
|
62
|
+
*/
|
|
63
|
+
centerVertically(): void;
|
|
64
|
+
/**
|
|
65
|
+
* @override
|
|
66
|
+
* @inheritDoc
|
|
67
|
+
*/
|
|
68
|
+
setHeight(height: number): void;
|
|
69
|
+
/**
|
|
70
|
+
* @override
|
|
71
|
+
* @inheritDoc
|
|
72
|
+
*/
|
|
73
|
+
nudgeUp(): void;
|
|
74
|
+
/**
|
|
75
|
+
* @override
|
|
76
|
+
* @inheritDoc
|
|
77
|
+
*/
|
|
78
|
+
nudgeDown(): void;
|
|
79
|
+
/**
|
|
80
|
+
* @override
|
|
81
|
+
* @inheritDoc
|
|
82
|
+
*/
|
|
83
|
+
nudgeLeft(): void;
|
|
84
|
+
/**
|
|
85
|
+
* @override
|
|
86
|
+
* @inheritDoc
|
|
87
|
+
*/
|
|
88
|
+
nudgeRight(): void;
|
|
89
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TextAlignment } from "..";
|
|
2
|
+
/**
|
|
3
|
+
* Defines the set of behaviors that can be adjusted on the interactive canvas, and provides an interface for grouping feature settings into a reusable profile.
|
|
4
|
+
*/
|
|
5
|
+
export interface ICanvasProfile {
|
|
6
|
+
readonly allowMultiSelect: boolean;
|
|
7
|
+
readonly allowObjectsToLeaveCanvas: boolean;
|
|
8
|
+
readonly enterTextEditImmediatelyOnSelect: boolean;
|
|
9
|
+
readonly allowMove: boolean;
|
|
10
|
+
readonly allowRotate: boolean;
|
|
11
|
+
readonly allowScale: boolean;
|
|
12
|
+
readonly defaultFont?: string;
|
|
13
|
+
readonly defaultFontSize: number;
|
|
14
|
+
readonly defaultFontColor: string;
|
|
15
|
+
readonly defaultLineHeight: number;
|
|
16
|
+
readonly defaultCharacterSpacing: number;
|
|
17
|
+
readonly defaultTextAlignment: TextAlignment;
|
|
18
|
+
readonly defaultBorderColor: string;
|
|
19
|
+
readonly defaultBorderWidth: number;
|
|
20
|
+
readonly defaultCutoffColor: string;
|
|
21
|
+
readonly defaultCutoffWidth: number;
|
|
22
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TextAlignment } from "..";
|
|
2
|
+
import { ICanvasProfile } from "./canvas-profile.interface";
|
|
3
|
+
/**
|
|
4
|
+
* Profile with as many features disabled as possible.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DefaultCanvasProfile implements ICanvasProfile {
|
|
7
|
+
readonly allowMultiSelect: boolean;
|
|
8
|
+
readonly enterTextEditImmediatelyOnSelect: boolean;
|
|
9
|
+
readonly allowObjectsToLeaveCanvas: boolean;
|
|
10
|
+
readonly allowMove: boolean;
|
|
11
|
+
readonly allowRotate: boolean;
|
|
12
|
+
readonly allowScale: boolean;
|
|
13
|
+
readonly defaultFont?: string;
|
|
14
|
+
readonly defaultFontSize: number;
|
|
15
|
+
readonly defaultFontColor: string;
|
|
16
|
+
readonly defaultLineHeight: number;
|
|
17
|
+
readonly defaultCharacterSpacing: number;
|
|
18
|
+
readonly defaultTextAlignment: TextAlignment;
|
|
19
|
+
readonly defaultBorderColor: string;
|
|
20
|
+
readonly defaultBorderWidth: number;
|
|
21
|
+
readonly defaultCutoffColor: string;
|
|
22
|
+
readonly defaultCutoffWidth: number;
|
|
23
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface ICanvasDimensions {
|
|
2
|
+
readonly width: number;
|
|
3
|
+
readonly widthPx: number;
|
|
4
|
+
readonly widthMm?: number;
|
|
5
|
+
readonly widthUnit: string;
|
|
6
|
+
readonly height: number;
|
|
7
|
+
readonly heightPx: number;
|
|
8
|
+
readonly heightMm?: number;
|
|
9
|
+
readonly heightUnit: string;
|
|
10
|
+
withSize(width: number, height: number): ICanvasDimensions;
|
|
11
|
+
/**
|
|
12
|
+
* Convert a number of pixels on the width to millimeters.
|
|
13
|
+
* @param px Pixel count.
|
|
14
|
+
*/
|
|
15
|
+
widthPxToMm(px: number): number | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Convert a number of pixels on the height to millimeters.
|
|
18
|
+
* @param px Pixel count.
|
|
19
|
+
*/
|
|
20
|
+
heightPxToMm(px: number): number | undefined;
|
|
21
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ICanvasDimensions } from "./canvas-dimensions.interface";
|
|
2
|
+
import { CanvasObjectData } from "..";
|
|
3
|
+
/**
|
|
4
|
+
* Serialized canvas state that can be used to save the canvas.
|
|
5
|
+
*/
|
|
6
|
+
export interface ICanvasState {
|
|
7
|
+
readonly dimensions: ICanvasDimensions;
|
|
8
|
+
readonly canvasJson: string;
|
|
9
|
+
readonly objects: CanvasObjectData[];
|
|
10
|
+
readonly backgroundColor?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface IObjectDimensions {
|
|
2
|
+
readonly top: {
|
|
3
|
+
readonly px: number;
|
|
4
|
+
readonly mm: number;
|
|
5
|
+
};
|
|
6
|
+
readonly left: {
|
|
7
|
+
readonly px: number;
|
|
8
|
+
readonly mm: number;
|
|
9
|
+
};
|
|
10
|
+
readonly width: {
|
|
11
|
+
readonly px: number;
|
|
12
|
+
readonly mm: number;
|
|
13
|
+
};
|
|
14
|
+
readonly height: {
|
|
15
|
+
readonly px: number;
|
|
16
|
+
readonly mm: number;
|
|
17
|
+
};
|
|
18
|
+
readonly angle: number;
|
|
19
|
+
readonly scale: {
|
|
20
|
+
readonly x: number;
|
|
21
|
+
readonly y: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ICanvasObject, ITextSelection } from "..";
|
|
2
|
+
export interface ISelectionData {
|
|
3
|
+
/**
|
|
4
|
+
* The currently selected fields.
|
|
5
|
+
*/
|
|
6
|
+
readonly objects: ICanvasObject[];
|
|
7
|
+
/**
|
|
8
|
+
* True if there is nothing selected.
|
|
9
|
+
*/
|
|
10
|
+
readonly empty: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* True if text is currently being edited.
|
|
13
|
+
*/
|
|
14
|
+
readonly isText: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Text selection data.
|
|
17
|
+
*/
|
|
18
|
+
readonly textSelection: ITextSelection | null;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type TextAlignment = "left" | "center" | "right" | "justify";
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@leapfrog/interactive-canvas",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Leapfrog interactive canvas",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"main": "dist/interactive-canvas.js",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "webpack --mode=production",
|
|
12
|
+
"watch": "webpack --mode=production --watch"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/fabric": "^3.6.5",
|
|
16
|
+
"@types/lodash": "^4.14.153",
|
|
17
|
+
"clean-webpack-plugin": "^3.0.0",
|
|
18
|
+
"ts-loader": "^6.0.4",
|
|
19
|
+
"typescript": "^3.5.3",
|
|
20
|
+
"unminified-webpack-plugin": "^2.0.0",
|
|
21
|
+
"webpack": "^4.39.3",
|
|
22
|
+
"webpack-cli": "^3.3.7"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"fabric": "^3.6.3",
|
|
26
|
+
"lodash": "^4.17.15",
|
|
27
|
+
"rxjs": "^6.5.5",
|
|
28
|
+
"ts-optchain": "^0.1.8"
|
|
29
|
+
},
|
|
30
|
+
"author": "",
|
|
31
|
+
"license": "UNLICENSED"
|
|
32
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Leapfrog Interactive Canvas #
|
|
2
|
+
|
|
3
|
+
A set of APIs wrapping the fabric.js library, providing Leapfrog-specific behavior and interactions.
|
|
4
|
+
|
|
5
|
+
### Building
|
|
6
|
+
npm run build
|
|
7
|
+
|
|
8
|
+
or
|
|
9
|
+
|
|
10
|
+
npm run watch
|
|
11
|
+
|
|
12
|
+
### Using library in another Project
|
|
13
|
+
`npm install @leapfrog/interactive-canvas`
|
|
14
|
+
|
|
15
|
+
### Linking for local development
|
|
16
|
+
|
|
17
|
+
You can use `npm link` to see changes to the library immediately in a linked project.
|
|
18
|
+
|
|
19
|
+
Add the following lines to the `package.json` `scripts` config in the project that uses this library:
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"scripts": {
|
|
23
|
+
"link:lic": "npm link @leapfrog/interactive-canvas",
|
|
24
|
+
"upgrade:lic": "npm install @leapfrog/interactive-canvas@latest"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
* In this project: `npm link`
|
|
30
|
+
* In the calling project: `npm run link:lic`
|
|
31
|
+
* In this project: `npm run watch`
|
|
32
|
+
|
|
33
|
+
Changes in the library will be visible in the calling project.
|
|
34
|
+
|
|
35
|
+
Once complete, publish the changes then run `npm run upgrade:lic` to get the latest published version of the
|
|
36
|
+
library in the calling project.
|
|
37
|
+
|
|
38
|
+
### Publishing
|
|
39
|
+
The `.npmrc` file contains the access token needed to publish to the `@leapfrog` npm repo.
|
|
40
|
+
* Increment the version number in `package.json`.
|
|
41
|
+
* `npm install` to update the `package-lock.json`.
|
|
42
|
+
* `npm run build`
|
|
43
|
+
* `npm publish`
|