@aurigma/design-atoms-model
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
73 lines • 3.22 kB
JavaScript
import { BaseTextItem } from "./BaseTextItem";
import { PointF } from "../../Math/PointF";
import { equals } from "../../Utils/Utils";
export class PlainTextItem extends BaseTextItem {
constructor(text, location, postScriptFontName, fontSize) {
super(text, postScriptFontName, fontSize);
this._baselineLocation = new PointF();
this._isVertical = false;
this.type = PlainTextItem.type;
if (location != null)
this.baselineLocation = location;
this._ignorePermissionsChange = true;
this.manipulationPermissions.resizeGrips.setCornerArbitrary(false);
this.manipulationPermissions.resizeGrips.edge = false;
this._ignorePermissionsChange = false;
}
get isVertical() {
return this._isVertical;
}
set isVertical(value) {
if (this._isVertical === value)
return;
this._isVertical = value;
this._propertyChanged.notify(this, "isVertical");
}
get baselineLocation() {
return this._baselineLocation;
}
set baselineLocation(value) {
this.setBaselineLocation(value);
}
setBaselineLocation(value, suppressPropertyChanged = false) {
if (PointF.isEqual(this._baselineLocation, value))
return;
this._baselineLocation = value;
if (!suppressPropertyChanged)
this._propertyChanged.notify(this, "baselineLocation");
}
applyPermissionsConstrain() {
super.applyPermissionsConstrain();
if (this.manipulationPermissions != null && this.manipulationPermissions.resizeGrips != null) {
this.manipulationPermissions.resizeGrips.setCornerArbitrary(false);
this.manipulationPermissions.resizeGrips.edgeConstraint = false;
}
}
getSimplifiedObject(omitProperties = []) {
const simplified = super.getSimplifiedObject(["_placeholders", "currentTextImage", "sourcePath", "sourceRectangle"].concat(omitProperties));
simplified["placeholders"] = this.placeholders.toArray();
return simplified;
}
_copy(source, destination, generateNewIds, appropriateParentContainer) {
super._copy(source, destination, generateNewIds, appropriateParentContainer);
if (destination.type == "AutoScaledTextItem" || destination.type == "BoundedTextItem" || destination.type == "PathBoundedTextItem" || destination.type == "PlainTextItem") {
destination["isVertical"] = source.isVertical;
}
if (destination instanceof PlainTextItem) {
destination.baselineLocation = source.baselineLocation;
}
return destination;
}
equals(other) {
return super.equals(other) &&
equals(this._isVertical, other._isVertical) &&
equals(this._baselineLocation, other._baselineLocation);
}
clone(generateNewIds = false, appropriateParentContainer = false) {
const item = new PlainTextItem();
this._copy(this, item, generateNewIds, appropriateParentContainer);
return item;
}
}
PlainTextItem.type = "PlainTextItem";
//# sourceMappingURL=PlainTextItem.js.map