@aurigma/design-atoms
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
108 lines • 4.86 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { CurvedTextItem } from "@aurigma/design-atoms-model/Product/Items";
import { NewBaseTextItemHandler } from "./NewBaseTextItemHandler";
import { EqualsOfFloatNumbers } from "@aurigma/design-atoms-model/Math";
import { TextFrameType } from "@aurigma/design-atoms-text/TextEditor/Enums/TextFrameType";
import { toTextWhizzPath } from "@aurigma/design-atoms-text/Utils/PathUtils";
var NewCurvedTextItemHandler = /** @class */ (function (_super) {
__extends(NewCurvedTextItemHandler, _super);
function NewCurvedTextItemHandler(fontRegistry, textEditorControllerFactory, item, textWhizz, apiClient, colorPreviewService) {
if (textWhizz === void 0) { textWhizz = null; }
return _super.call(this, fontRegistry, textEditorControllerFactory, item, textWhizz, apiClient, colorPreviewService) || this;
}
Object.defineProperty(NewCurvedTextItemHandler.prototype, "item", {
get: function () {
return this._getItem();
},
set: function (item) {
_super.prototype._setItem.call(this, item);
},
enumerable: true,
configurable: true
});
NewCurvedTextItemHandler.prototype.getFramesData = function () {
var data = [];
data.push(this.item.textPath);
return {
type: TextFrameType.pathTextFrame,
frames: data
};
};
;
//TODO: to del
NewCurvedTextItemHandler.prototype.updateTextWhizzFrames = function (handler) {
handler.replaceFrame(this._createTextWhizzFrame(), 0);
};
NewCurvedTextItemHandler.prototype.setTextWhizzWrappingPath = function (handler) {
};
NewCurvedTextItemHandler.prototype.getWrappingPathData = function () {
return {};
};
NewCurvedTextItemHandler.prototype._onItemPropertyChanged = function (sender, propertyName) {
switch (propertyName) {
case "textPath":
case "start":
case "end":
this.update(null, null, "frame");
break;
case "fitToPath":
case "fitToPathStep":
case "stretch":
case "originalFontSize":
this.update();
break;
default:
}
_super.prototype._onItemPropertyChanged.call(this, sender, propertyName);
};
//TODO: to del
NewCurvedTextItemHandler.prototype._addTextWhizzFrames = function (handler) {
handler.addFrame(this._createTextWhizzFrame());
};
NewCurvedTextItemHandler.prototype._getEndTransformTrigger = function (resized) {
return resized ? null : "frame";
};
NewCurvedTextItemHandler.prototype._applyTransform = function (item, transform, center) {
var _a, _b;
if (!(item instanceof CurvedTextItem))
return;
var textPath = item.textPath.clone();
textPath.transform(transform, center);
item.textPath = textPath;
var limits = this._getPreviewScaleLimits();
var previewScale = this.item.previewScale * transform.scaleY;
previewScale = Math.min((_a = limits.max) !== null && _a !== void 0 ? _a : Number.MAX_VALUE, previewScale);
previewScale = Math.max((_b = limits.min) !== null && _b !== void 0 ? _b : Number.MIN_VALUE, previewScale);
item.previewScale = previewScale;
};
//TODO: to del
NewCurvedTextItemHandler.prototype._createTextWhizzFrame = function () {
var path = toTextWhizzPath(this._textWhizz, this.item.textPath);
var scale = this.item.previewScale;
if (!EqualsOfFloatNumbers(scale, 1))
path.scale(1 / scale, 1 / scale);
var frame = new this._textWhizz.PathTextFrame();
frame.baseline = path;
frame.start = this.item.start;
frame.end = this.item.end;
if (this.item.fitToPath)
frame.copyFittingMode = this._textWhizz.CopyFittingMode.fitToWidth;
return frame;
};
NewCurvedTextItemHandler.typeName = "NewCurvedTextItemHandler";
return NewCurvedTextItemHandler;
}(NewBaseTextItemHandler));
export { NewCurvedTextItemHandler };
//# sourceMappingURL=NewCurvedTextItemHandler.js.map