@aurigma/design-atoms
Version:
Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.
28 lines • 1.32 kB
JavaScript
import { BaseTextItem, GroupItem } from "@aurigma/design-atoms-model";
export class TextsWorkaroundItemsComparer {
constructor() {
this._sourceItemsToCompare = new Map();
}
itemsEqual(source, destination) {
if (source.type === destination.type && this._requiresSpecialComparison(source)) {
if (this._sourceItemsToCompare.has(source.id)) {
const areEqual = this._sourceItemsToCompare.get(source.id).equals(source);
if (areEqual) {
return true;
}
this._sourceItemsToCompare.set(source.id, source.clone());
return false;
}
this._sourceItemsToCompare.set(source.id, source.clone());
}
return source.equals(destination);
}
/**Text items and groups from source surface require comparison with its own clones,
* but not with ones from PreviewCanvas.
* This is due to sourceRectangle of the text item that is on PreviewCanvas
* becomes slightly different from the source item after server-side update is performed. */
_requiresSpecialComparison(item) {
return item instanceof BaseTextItem || item instanceof GroupItem;
}
}
//# sourceMappingURL=TextsWorkaroundItemsComparer.js.map