@leapfrog/interactive-canvas 1.3.0 → 1.4.1
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.
|
@@ -385,7 +385,6 @@ var UpdateObjectDimensionsLayoutFunction = /** @class */ (function () {
|
|
|
385
385
|
}());
|
|
386
386
|
|
|
387
387
|
var MIN_MAGNITUDE = 1;
|
|
388
|
-
var BULLET_MARGIN = 15;
|
|
389
388
|
var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
390
389
|
function StackObjectsLayoutFunction() {
|
|
391
390
|
}
|
|
@@ -450,7 +449,7 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
450
449
|
var objectMargin = oc(object.getMargin()).left(0);
|
|
451
450
|
var objectLeft = canvasMargin.left + columnOffset + objectMargin;
|
|
452
451
|
if (object.getType() === ObjectType.TEXT && object.isBulleted())
|
|
453
|
-
objectLeft +=
|
|
452
|
+
objectLeft += object.getBulletMargin();
|
|
454
453
|
if (object.getType() === ObjectType.VERTICAL_RULE)
|
|
455
454
|
object.setPosition({ height: row.height });
|
|
456
455
|
object.setPosition({
|
|
@@ -475,7 +474,7 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
475
474
|
if (object.getType() === ObjectType.VERTICAL_RULE)
|
|
476
475
|
return;
|
|
477
476
|
if (object.getType() === ObjectType.TEXT && object.isBulleted())
|
|
478
|
-
actualWidth -=
|
|
477
|
+
actualWidth -= object.getBulletMargin();
|
|
479
478
|
object.setPosition({
|
|
480
479
|
width: actualWidth
|
|
481
480
|
});
|
|
@@ -643,6 +642,7 @@ var AbstractCanvasObject = /** @class */ (function () {
|
|
|
643
642
|
this.fabricObject = fabricObject;
|
|
644
643
|
this.data = data ? data : new CanvasObjectData(type, this.fabricObject.id);
|
|
645
644
|
this.dimensions$ = new BehaviorSubject(new FieldDimensions(this.fabricObject, this.canvas));
|
|
645
|
+
this.opacity$ = new BehaviorSubject(this.fabricObject.opacity);
|
|
646
646
|
this.updatePinToBottomDistance();
|
|
647
647
|
this.canvas.getProfile$().subscribe(function (profile) { return _this.onProfileChange(profile); });
|
|
648
648
|
this.canvas.getLayoutManager$().subscribe(function (layoutManager) { return _this.onLayoutManagerChange(layoutManager); });
|
|
@@ -714,6 +714,29 @@ var AbstractCanvasObject = /** @class */ (function () {
|
|
|
714
714
|
AbstractCanvasObject.prototype.getDimensions$ = function () {
|
|
715
715
|
return this.dimensions$;
|
|
716
716
|
};
|
|
717
|
+
/**
|
|
718
|
+
* @override
|
|
719
|
+
* @inheritDoc
|
|
720
|
+
*/
|
|
721
|
+
AbstractCanvasObject.prototype.getOpacity = function () {
|
|
722
|
+
return this.opacity$.value;
|
|
723
|
+
};
|
|
724
|
+
/**
|
|
725
|
+
* @override
|
|
726
|
+
* @inheritDoc
|
|
727
|
+
*/
|
|
728
|
+
AbstractCanvasObject.prototype.getOpacity$ = function () {
|
|
729
|
+
return this.opacity$;
|
|
730
|
+
};
|
|
731
|
+
/**
|
|
732
|
+
* @override
|
|
733
|
+
* @inheritDoc
|
|
734
|
+
*/
|
|
735
|
+
AbstractCanvasObject.prototype.setOpacity = function (value) {
|
|
736
|
+
this.fabricObject.set({ opacity: value });
|
|
737
|
+
this.opacity$.next(value);
|
|
738
|
+
this.redraw();
|
|
739
|
+
};
|
|
717
740
|
/**
|
|
718
741
|
* @override
|
|
719
742
|
* @inheritDoc
|
|
@@ -1927,6 +1950,20 @@ var Text = /** @class */ (function (_super) {
|
|
|
1927
1950
|
Text.prototype.getPrefillType = function () {
|
|
1928
1951
|
return this.data.prefillType;
|
|
1929
1952
|
};
|
|
1953
|
+
/**
|
|
1954
|
+
* @override
|
|
1955
|
+
* @inheritDoc
|
|
1956
|
+
*/
|
|
1957
|
+
Text.prototype.getBulletMargin = function () {
|
|
1958
|
+
var _this = this;
|
|
1959
|
+
if (!this.isBulleted())
|
|
1960
|
+
return 0;
|
|
1961
|
+
var fontSize = 0;
|
|
1962
|
+
each(this.fabricObject._textLines, function (textLine, lineIndex) {
|
|
1963
|
+
fontSize = Math.max(fontSize, _this.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize"));
|
|
1964
|
+
});
|
|
1965
|
+
return fontSize * 0.6;
|
|
1966
|
+
};
|
|
1930
1967
|
/**
|
|
1931
1968
|
* @override
|
|
1932
1969
|
* @inheritDoc
|
|
@@ -2783,7 +2820,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
2783
2820
|
return __generator(this, function (_a) {
|
|
2784
2821
|
rectOptions = {
|
|
2785
2822
|
id: this.randomId(),
|
|
2786
|
-
width:
|
|
2823
|
+
width: 1,
|
|
2787
2824
|
height: 10,
|
|
2788
2825
|
top: 0,
|
|
2789
2826
|
left: 0,
|
|
@@ -2810,7 +2847,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
2810
2847
|
rectOptions = {
|
|
2811
2848
|
id: this.randomId(),
|
|
2812
2849
|
width: 10,
|
|
2813
|
-
height:
|
|
2850
|
+
height: 1,
|
|
2814
2851
|
top: 0,
|
|
2815
2852
|
left: 0,
|
|
2816
2853
|
fill: "#000000"
|
|
@@ -387,7 +387,6 @@ var UpdateObjectDimensionsLayoutFunction = /** @class */ (function () {
|
|
|
387
387
|
}());
|
|
388
388
|
|
|
389
389
|
var MIN_MAGNITUDE = 1;
|
|
390
|
-
var BULLET_MARGIN = 15;
|
|
391
390
|
var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
392
391
|
function StackObjectsLayoutFunction() {
|
|
393
392
|
}
|
|
@@ -452,7 +451,7 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
452
451
|
var objectMargin = tsOptchain.oc(object.getMargin()).left(0);
|
|
453
452
|
var objectLeft = canvasMargin.left + columnOffset + objectMargin;
|
|
454
453
|
if (object.getType() === exports.ObjectType.TEXT && object.isBulleted())
|
|
455
|
-
objectLeft +=
|
|
454
|
+
objectLeft += object.getBulletMargin();
|
|
456
455
|
if (object.getType() === exports.ObjectType.VERTICAL_RULE)
|
|
457
456
|
object.setPosition({ height: row.height });
|
|
458
457
|
object.setPosition({
|
|
@@ -477,7 +476,7 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
477
476
|
if (object.getType() === exports.ObjectType.VERTICAL_RULE)
|
|
478
477
|
return;
|
|
479
478
|
if (object.getType() === exports.ObjectType.TEXT && object.isBulleted())
|
|
480
|
-
actualWidth -=
|
|
479
|
+
actualWidth -= object.getBulletMargin();
|
|
481
480
|
object.setPosition({
|
|
482
481
|
width: actualWidth
|
|
483
482
|
});
|
|
@@ -645,6 +644,7 @@ var AbstractCanvasObject = /** @class */ (function () {
|
|
|
645
644
|
this.fabricObject = fabricObject;
|
|
646
645
|
this.data = data ? data : new CanvasObjectData(type, this.fabricObject.id);
|
|
647
646
|
this.dimensions$ = new rxjs.BehaviorSubject(new FieldDimensions(this.fabricObject, this.canvas));
|
|
647
|
+
this.opacity$ = new rxjs.BehaviorSubject(this.fabricObject.opacity);
|
|
648
648
|
this.updatePinToBottomDistance();
|
|
649
649
|
this.canvas.getProfile$().subscribe(function (profile) { return _this.onProfileChange(profile); });
|
|
650
650
|
this.canvas.getLayoutManager$().subscribe(function (layoutManager) { return _this.onLayoutManagerChange(layoutManager); });
|
|
@@ -716,6 +716,29 @@ var AbstractCanvasObject = /** @class */ (function () {
|
|
|
716
716
|
AbstractCanvasObject.prototype.getDimensions$ = function () {
|
|
717
717
|
return this.dimensions$;
|
|
718
718
|
};
|
|
719
|
+
/**
|
|
720
|
+
* @override
|
|
721
|
+
* @inheritDoc
|
|
722
|
+
*/
|
|
723
|
+
AbstractCanvasObject.prototype.getOpacity = function () {
|
|
724
|
+
return this.opacity$.value;
|
|
725
|
+
};
|
|
726
|
+
/**
|
|
727
|
+
* @override
|
|
728
|
+
* @inheritDoc
|
|
729
|
+
*/
|
|
730
|
+
AbstractCanvasObject.prototype.getOpacity$ = function () {
|
|
731
|
+
return this.opacity$;
|
|
732
|
+
};
|
|
733
|
+
/**
|
|
734
|
+
* @override
|
|
735
|
+
* @inheritDoc
|
|
736
|
+
*/
|
|
737
|
+
AbstractCanvasObject.prototype.setOpacity = function (value) {
|
|
738
|
+
this.fabricObject.set({ opacity: value });
|
|
739
|
+
this.opacity$.next(value);
|
|
740
|
+
this.redraw();
|
|
741
|
+
};
|
|
719
742
|
/**
|
|
720
743
|
* @override
|
|
721
744
|
* @inheritDoc
|
|
@@ -1929,6 +1952,20 @@ var Text = /** @class */ (function (_super) {
|
|
|
1929
1952
|
Text.prototype.getPrefillType = function () {
|
|
1930
1953
|
return this.data.prefillType;
|
|
1931
1954
|
};
|
|
1955
|
+
/**
|
|
1956
|
+
* @override
|
|
1957
|
+
* @inheritDoc
|
|
1958
|
+
*/
|
|
1959
|
+
Text.prototype.getBulletMargin = function () {
|
|
1960
|
+
var _this = this;
|
|
1961
|
+
if (!this.isBulleted())
|
|
1962
|
+
return 0;
|
|
1963
|
+
var fontSize = 0;
|
|
1964
|
+
_.each(this.fabricObject._textLines, function (textLine, lineIndex) {
|
|
1965
|
+
fontSize = Math.max(fontSize, _this.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize"));
|
|
1966
|
+
});
|
|
1967
|
+
return fontSize * 0.6;
|
|
1968
|
+
};
|
|
1932
1969
|
/**
|
|
1933
1970
|
* @override
|
|
1934
1971
|
* @inheritDoc
|
|
@@ -2783,7 +2820,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
2783
2820
|
return __generator(this, function (_a) {
|
|
2784
2821
|
rectOptions = {
|
|
2785
2822
|
id: this.randomId(),
|
|
2786
|
-
width:
|
|
2823
|
+
width: 1,
|
|
2787
2824
|
height: 10,
|
|
2788
2825
|
top: 0,
|
|
2789
2826
|
left: 0,
|
|
@@ -2810,7 +2847,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
2810
2847
|
rectOptions = {
|
|
2811
2848
|
id: this.randomId(),
|
|
2812
2849
|
width: 10,
|
|
2813
|
-
height:
|
|
2850
|
+
height: 1,
|
|
2814
2851
|
top: 0,
|
|
2815
2852
|
left: 0,
|
|
2816
2853
|
fill: "#000000"
|
|
@@ -10,6 +10,7 @@ export declare abstract class AbstractCanvasObject<T extends Object> implements
|
|
|
10
10
|
protected fabricObject: T;
|
|
11
11
|
protected data: CanvasObjectData;
|
|
12
12
|
private readonly dimensions$;
|
|
13
|
+
private readonly opacity$;
|
|
13
14
|
/**
|
|
14
15
|
* Create a new instance.
|
|
15
16
|
* @param type Object type.
|
|
@@ -53,6 +54,21 @@ export declare abstract class AbstractCanvasObject<T extends Object> implements
|
|
|
53
54
|
* @inheritDoc
|
|
54
55
|
*/
|
|
55
56
|
getDimensions$(): Observable<IObjectDimensions>;
|
|
57
|
+
/**
|
|
58
|
+
* @override
|
|
59
|
+
* @inheritDoc
|
|
60
|
+
*/
|
|
61
|
+
getOpacity(): number;
|
|
62
|
+
/**
|
|
63
|
+
* @override
|
|
64
|
+
* @inheritDoc
|
|
65
|
+
*/
|
|
66
|
+
getOpacity$(): Observable<number>;
|
|
67
|
+
/**
|
|
68
|
+
* @override
|
|
69
|
+
* @inheritDoc
|
|
70
|
+
*/
|
|
71
|
+
setOpacity(value: number): void;
|
|
56
72
|
/**
|
|
57
73
|
* @override
|
|
58
74
|
* @inheritDoc
|
|
@@ -34,6 +34,19 @@ export interface ICanvasObject {
|
|
|
34
34
|
* Get an observable for the field dimensions.
|
|
35
35
|
*/
|
|
36
36
|
getDimensions$(): Observable<IObjectDimensions>;
|
|
37
|
+
/**
|
|
38
|
+
* Get object opacity.
|
|
39
|
+
*/
|
|
40
|
+
getOpacity(): number;
|
|
41
|
+
/**
|
|
42
|
+
* Get an observable for the object opacity.
|
|
43
|
+
*/
|
|
44
|
+
getOpacity$(): Observable<number>;
|
|
45
|
+
/**
|
|
46
|
+
* Set the object opacity.
|
|
47
|
+
* @param value Opacity.
|
|
48
|
+
*/
|
|
49
|
+
setOpacity(value: number): void;
|
|
37
50
|
/**
|
|
38
51
|
* Get the component margin.
|
|
39
52
|
*/
|
|
@@ -40,6 +40,10 @@ export interface IText extends ICanvasObject, IMutableColor, IMutableText, IMuta
|
|
|
40
40
|
* Get the prefill type used for this text field.
|
|
41
41
|
*/
|
|
42
42
|
getPrefillType(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Return the margin needed for bullets on this object.
|
|
45
|
+
*/
|
|
46
|
+
getBulletMargin(): number;
|
|
43
47
|
}
|
|
44
48
|
export declare class Text extends AbstractCanvasObject<fabric.Textbox> implements IText {
|
|
45
49
|
private readonly fontLibrary;
|
|
@@ -197,6 +201,11 @@ export declare class Text extends AbstractCanvasObject<fabric.Textbox> implement
|
|
|
197
201
|
* @inheritDoc
|
|
198
202
|
*/
|
|
199
203
|
getPrefillType(): string;
|
|
204
|
+
/**
|
|
205
|
+
* @override
|
|
206
|
+
* @inheritDoc
|
|
207
|
+
*/
|
|
208
|
+
getBulletMargin(): number;
|
|
200
209
|
/**
|
|
201
210
|
* @override
|
|
202
211
|
* @inheritDoc
|