@leapfrog/interactive-canvas 1.4.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 += BULLET_MARGIN;
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 -= BULLET_MARGIN;
477
+ actualWidth -= object.getBulletMargin();
479
478
  object.setPosition({
480
479
  width: actualWidth
481
480
  });
@@ -1951,6 +1950,20 @@ var Text = /** @class */ (function (_super) {
1951
1950
  Text.prototype.getPrefillType = function () {
1952
1951
  return this.data.prefillType;
1953
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
+ };
1954
1967
  /**
1955
1968
  * @override
1956
1969
  * @inheritDoc
@@ -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 += BULLET_MARGIN;
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 -= BULLET_MARGIN;
479
+ actualWidth -= object.getBulletMargin();
481
480
  object.setPosition({
482
481
  width: actualWidth
483
482
  });
@@ -1953,6 +1952,20 @@ var Text = /** @class */ (function (_super) {
1953
1952
  Text.prototype.getPrefillType = function () {
1954
1953
  return this.data.prefillType;
1955
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
+ };
1956
1969
  /**
1957
1970
  * @override
1958
1971
  * @inheritDoc
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leapfrog/interactive-canvas",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Leapfrog interactive canvas",
5
5
  "files": [
6
6
  "dist"