@contrail/documents 1.15.0-alpha.8841401 → 1.15.0-alpha.a213e4a
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.
- package/CHANGELOG.md +3 -3
- package/lib/element-order.d.ts +6 -0
- package/lib/element-order.js +17 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/types/common.d.ts +0 -5
- package/lib/types/document-element.d.ts +1 -2
- package/lib/types/document.d.ts +7 -2
- package/lib/types/document.js +7 -2
- package/package.json +1 -1
- package/lib/util/mask/index.d.ts +0 -4
- package/lib/util/mask/index.js +0 -20
- package/lib/util/mask/mask-preset-geometry.d.ts +0 -3
- package/lib/util/mask/mask-preset-geometry.js +0 -19
- package/lib/util/mask/mask-shape-geometry.d.ts +0 -26
- package/lib/util/mask/mask-shape-geometry.js +0 -154
- package/lib/util/mask/rotation-math.d.ts +0 -2
- package/lib/util/mask/rotation-math.js +0 -14
- package/lib/util/mask/shape-mask-element.d.ts +0 -16
- package/lib/util/mask/shape-mask-element.js +0 -61
package/CHANGELOG.md
CHANGED
|
@@ -5,12 +5,12 @@ All notable changes to `@contrail/documents` are documented here.
|
|
|
5
5
|
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
6
6
|
Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [1.15.0] - 2026-08-
|
|
8
|
+
## [1.15.0] - 2026-08-21
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
-
- `
|
|
13
|
-
-
|
|
12
|
+
- `sortElementsByArrayOrder(elements, sortOrder)` and `assignSortIndexes(orderedElements)` — the two ordering transforms that convert, restore and the document read path had each grown their own copy of. `sortElementsByArrayOrder` puts elements missing from the array last, keeping their relative order.
|
|
13
|
+
- `SORT_MODE` — the named constants for `DocumentSortMode`. `DocumentSortMode` and `DOCUMENT_SORT_MODES` are now derived from it, so the mode values are declared in exactly one place. `DOCUMENT_SORT_MODES` is now `readonly DocumentSortMode[]` rather than a literal tuple; it stays exported because it is the runtime list behind the entity's `@IsIn` validation.
|
|
14
14
|
|
|
15
15
|
## [1.14.0] - 2026-07-29
|
|
16
16
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface OrderableElement {
|
|
2
|
+
id?: string;
|
|
3
|
+
sortIndex?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function sortElementsByArrayOrder<T extends OrderableElement>(elements: T[], sortOrder?: string[]): T[];
|
|
6
|
+
export declare function assignSortIndexes<T extends OrderableElement>(orderedElements: T[]): T[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortElementsByArrayOrder = sortElementsByArrayOrder;
|
|
4
|
+
exports.assignSortIndexes = assignSortIndexes;
|
|
5
|
+
const sort_index_1 = require("./sort-index");
|
|
6
|
+
function sortElementsByArrayOrder(elements, sortOrder) {
|
|
7
|
+
if (!(sortOrder === null || sortOrder === void 0 ? void 0 : sortOrder.length)) {
|
|
8
|
+
return [...elements];
|
|
9
|
+
}
|
|
10
|
+
const positionById = new Map(sortOrder.map((id, index) => [id, index]));
|
|
11
|
+
const unorderedPosition = sortOrder.length;
|
|
12
|
+
return [...elements].sort((a, b) => { var _a, _b; return ((_a = positionById.get(a.id)) !== null && _a !== void 0 ? _a : unorderedPosition) - ((_b = positionById.get(b.id)) !== null && _b !== void 0 ? _b : unorderedPosition); });
|
|
13
|
+
}
|
|
14
|
+
function assignSortIndexes(orderedElements) {
|
|
15
|
+
const sortIndexes = (0, sort_index_1.buildNKeysBetween)(null, null, orderedElements.length);
|
|
16
|
+
return orderedElements.map((element, index) => (Object.assign(Object.assign({}, element), { sortIndex: sortIndexes[index] })));
|
|
17
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './types';
|
|
2
2
|
export * from './sort-index';
|
|
3
|
+
export * from './element-order';
|
|
3
4
|
export * from './sort-order-errors';
|
|
4
5
|
export * from './components';
|
|
5
6
|
export * from './document-element-factory';
|
|
@@ -11,5 +12,4 @@ export * from './document-element-constants';
|
|
|
11
12
|
export * from './util/curved-line/point';
|
|
12
13
|
export * from './util/curved-line/curved-line';
|
|
13
14
|
export * from './util/callout/callout';
|
|
14
|
-
export * from './util/mask';
|
|
15
15
|
export * from './document-frame.service';
|
package/lib/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./types"), exports);
|
|
18
18
|
__exportStar(require("./sort-index"), exports);
|
|
19
|
+
__exportStar(require("./element-order"), exports);
|
|
19
20
|
__exportStar(require("./sort-order-errors"), exports);
|
|
20
21
|
__exportStar(require("./components"), exports);
|
|
21
22
|
__exportStar(require("./document-element-factory"), exports);
|
|
@@ -27,5 +28,4 @@ __exportStar(require("./document-element-constants"), exports);
|
|
|
27
28
|
__exportStar(require("./util/curved-line/point"), exports);
|
|
28
29
|
__exportStar(require("./util/curved-line/curved-line"), exports);
|
|
29
30
|
__exportStar(require("./util/callout/callout"), exports);
|
|
30
|
-
__exportStar(require("./util/mask"), exports);
|
|
31
31
|
__exportStar(require("./document-frame.service"), exports);
|
package/lib/types/common.d.ts
CHANGED
|
@@ -74,11 +74,6 @@ export interface LineDefinition {
|
|
|
74
74
|
markerEnd?: string;
|
|
75
75
|
lineType?: LineType;
|
|
76
76
|
}
|
|
77
|
-
export type MaskShapeKey = 'circle' | 'square' | 'rounded' | 'triangle' | 'diamond' | 'parallelogram' | 'star' | 'heart' | 'cloud';
|
|
78
|
-
export interface MaskDefinition {
|
|
79
|
-
shape: MaskShapeKey;
|
|
80
|
-
rotation?: number;
|
|
81
|
-
}
|
|
82
77
|
export interface CropDefinition {
|
|
83
78
|
x1?: number;
|
|
84
79
|
x2?: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PropertyLevel } from '@contrail/types';
|
|
2
|
-
import { CropDefinition, LineDefinition,
|
|
2
|
+
import { CropDefinition, LineDefinition, PositionDefinition, RotationDefinition, SizeDefinition } from './common';
|
|
3
3
|
import { Document } from './document';
|
|
4
4
|
import { ScaleTransformation } from './element-transformation';
|
|
5
5
|
export interface AlternateUrls {
|
|
@@ -32,7 +32,6 @@ export interface DocumentElement extends Document {
|
|
|
32
32
|
annotations?: any;
|
|
33
33
|
isLocked?: boolean;
|
|
34
34
|
cropDefinition?: CropDefinition;
|
|
35
|
-
maskDefinition?: MaskDefinition;
|
|
36
35
|
embedInfo?: any;
|
|
37
36
|
isHidden?: boolean;
|
|
38
37
|
elementIds?: Array<string>;
|
package/lib/types/document.d.ts
CHANGED
|
@@ -5,8 +5,13 @@ export interface ImportReferenceDetail {
|
|
|
5
5
|
importedFileReference?: string;
|
|
6
6
|
}
|
|
7
7
|
export type DocumentWriteMode = 'transactional' | 'legacy';
|
|
8
|
-
export declare const
|
|
9
|
-
|
|
8
|
+
export declare const SORT_MODE: {
|
|
9
|
+
readonly ARRAY: "array";
|
|
10
|
+
readonly ELEMENT_INDEXING: "elementIndexing";
|
|
11
|
+
readonly MIGRATING: "migrating";
|
|
12
|
+
};
|
|
13
|
+
export type DocumentSortMode = (typeof SORT_MODE)[keyof typeof SORT_MODE];
|
|
14
|
+
export declare const DOCUMENT_SORT_MODES: readonly DocumentSortMode[];
|
|
10
15
|
export interface Document {
|
|
11
16
|
id?: string;
|
|
12
17
|
name?: string;
|
package/lib/types/document.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DOCUMENT_SORT_MODES = void 0;
|
|
4
|
-
exports.
|
|
3
|
+
exports.DOCUMENT_SORT_MODES = exports.SORT_MODE = void 0;
|
|
4
|
+
exports.SORT_MODE = {
|
|
5
|
+
ARRAY: 'array',
|
|
6
|
+
ELEMENT_INDEXING: 'elementIndexing',
|
|
7
|
+
MIGRATING: 'migrating',
|
|
8
|
+
};
|
|
9
|
+
exports.DOCUMENT_SORT_MODES = Object.values(exports.SORT_MODE);
|
package/package.json
CHANGED
package/lib/util/mask/index.d.ts
DELETED
package/lib/util/mask/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./mask-shape-geometry"), exports);
|
|
18
|
-
__exportStar(require("./rotation-math"), exports);
|
|
19
|
-
__exportStar(require("./shape-mask-element"), exports);
|
|
20
|
-
__exportStar(require("./mask-preset-geometry"), exports);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MASK_SHAPE_PRESET_GEOMETRY = void 0;
|
|
4
|
-
exports.getMaskPresetGeometry = getMaskPresetGeometry;
|
|
5
|
-
exports.MASK_SHAPE_PRESET_GEOMETRY = {
|
|
6
|
-
circle: 'ellipse',
|
|
7
|
-
square: 'rect',
|
|
8
|
-
rounded: 'roundRect',
|
|
9
|
-
triangle: 'triangle',
|
|
10
|
-
diamond: 'diamond',
|
|
11
|
-
parallelogram: 'parallelogram',
|
|
12
|
-
star: 'star5',
|
|
13
|
-
heart: 'heart',
|
|
14
|
-
cloud: 'cloud',
|
|
15
|
-
};
|
|
16
|
-
function getMaskPresetGeometry(shape) {
|
|
17
|
-
var _a;
|
|
18
|
-
return shape ? (_a = exports.MASK_SHAPE_PRESET_GEOMETRY[shape]) !== null && _a !== void 0 ? _a : null : null;
|
|
19
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { MaskShapeKey } from '../../types';
|
|
2
|
-
export { MaskShapeKey };
|
|
3
|
-
export declare const MASK_SHAPE_KEYS: readonly MaskShapeKey[];
|
|
4
|
-
export interface MaskRect {
|
|
5
|
-
x: number;
|
|
6
|
-
y: number;
|
|
7
|
-
width: number;
|
|
8
|
-
height: number;
|
|
9
|
-
}
|
|
10
|
-
export type PathSegment = {
|
|
11
|
-
op: 'move' | 'line';
|
|
12
|
-
x: number;
|
|
13
|
-
y: number;
|
|
14
|
-
} | {
|
|
15
|
-
op: 'cubic';
|
|
16
|
-
c1x: number;
|
|
17
|
-
c1y: number;
|
|
18
|
-
c2x: number;
|
|
19
|
-
c2y: number;
|
|
20
|
-
x: number;
|
|
21
|
-
y: number;
|
|
22
|
-
} | {
|
|
23
|
-
op: 'close';
|
|
24
|
-
};
|
|
25
|
-
export declare function getMaskShapeSegments(shape: MaskShapeKey, rect: MaskRect, rotationDeg?: number): PathSegment[];
|
|
26
|
-
export declare function rotatedRectAABB(rect: MaskRect, rotationDeg: number): MaskRect;
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MASK_SHAPE_KEYS = void 0;
|
|
4
|
-
exports.getMaskShapeSegments = getMaskShapeSegments;
|
|
5
|
-
exports.rotatedRectAABB = rotatedRectAABB;
|
|
6
|
-
const rotation_math_1 = require("./rotation-math");
|
|
7
|
-
exports.MASK_SHAPE_KEYS = [
|
|
8
|
-
'circle',
|
|
9
|
-
'square',
|
|
10
|
-
'rounded',
|
|
11
|
-
'triangle',
|
|
12
|
-
'diamond',
|
|
13
|
-
'parallelogram',
|
|
14
|
-
'star',
|
|
15
|
-
'heart',
|
|
16
|
-
'cloud',
|
|
17
|
-
];
|
|
18
|
-
const K = 0.5522847498;
|
|
19
|
-
function polygon(points) {
|
|
20
|
-
const [first, ...rest] = points;
|
|
21
|
-
return [
|
|
22
|
-
{ op: 'move', x: first[0], y: first[1] },
|
|
23
|
-
...rest.map(([x, y]) => ({ op: 'line', x, y })),
|
|
24
|
-
{ op: 'close' },
|
|
25
|
-
];
|
|
26
|
-
}
|
|
27
|
-
function ellipse(cx, cy, rx, ry) {
|
|
28
|
-
return [
|
|
29
|
-
{ op: 'move', x: cx + rx, y: cy },
|
|
30
|
-
{ op: 'cubic', c1x: cx + rx, c1y: cy + K * ry, c2x: cx + K * rx, c2y: cy + ry, x: cx, y: cy + ry },
|
|
31
|
-
{ op: 'cubic', c1x: cx - K * rx, c1y: cy + ry, c2x: cx - rx, c2y: cy + K * ry, x: cx - rx, y: cy },
|
|
32
|
-
{ op: 'cubic', c1x: cx - rx, c1y: cy - K * ry, c2x: cx - K * rx, c2y: cy - ry, x: cx, y: cy - ry },
|
|
33
|
-
{ op: 'cubic', c1x: cx + K * rx, c1y: cy - ry, c2x: cx + rx, c2y: cy - K * ry, x: cx + rx, y: cy },
|
|
34
|
-
{ op: 'close' },
|
|
35
|
-
];
|
|
36
|
-
}
|
|
37
|
-
function roundedRect(x, y, w, h, r) {
|
|
38
|
-
const x2 = x + w;
|
|
39
|
-
const y2 = y + h;
|
|
40
|
-
return [
|
|
41
|
-
{ op: 'move', x: x + r, y },
|
|
42
|
-
{ op: 'line', x: x2 - r, y },
|
|
43
|
-
{ op: 'cubic', c1x: x2 - r + K * r, c1y: y, c2x: x2, c2y: y + r - K * r, x: x2, y: y + r },
|
|
44
|
-
{ op: 'line', x: x2, y: y2 - r },
|
|
45
|
-
{ op: 'cubic', c1x: x2, c1y: y2 - r + K * r, c2x: x2 - r + K * r, c2y: y2, x: x2 - r, y: y2 },
|
|
46
|
-
{ op: 'line', x: x + r, y: y2 },
|
|
47
|
-
{ op: 'cubic', c1x: x + r - K * r, c1y: y2, c2x: x, c2y: y2 - r + K * r, x, y: y2 - r },
|
|
48
|
-
{ op: 'line', x, y: y + r },
|
|
49
|
-
{ op: 'cubic', c1x: x, c1y: y + r - K * r, c2x: x + r - K * r, c2y: y, x: x + r, y },
|
|
50
|
-
{ op: 'close' },
|
|
51
|
-
];
|
|
52
|
-
}
|
|
53
|
-
const UNIT_SEGMENTS = {
|
|
54
|
-
circle: ellipse(50, 50, 49, 49),
|
|
55
|
-
square: polygon([
|
|
56
|
-
[1, 1],
|
|
57
|
-
[99, 1],
|
|
58
|
-
[99, 99],
|
|
59
|
-
[1, 99],
|
|
60
|
-
]),
|
|
61
|
-
rounded: roundedRect(1, 1, 98, 98, 16),
|
|
62
|
-
triangle: polygon([
|
|
63
|
-
[50, 3],
|
|
64
|
-
[97, 96],
|
|
65
|
-
[3, 96],
|
|
66
|
-
]),
|
|
67
|
-
diamond: polygon([
|
|
68
|
-
[50, 2],
|
|
69
|
-
[98, 50],
|
|
70
|
-
[50, 98],
|
|
71
|
-
[2, 50],
|
|
72
|
-
]),
|
|
73
|
-
parallelogram: polygon([
|
|
74
|
-
[27, 12],
|
|
75
|
-
[98, 12],
|
|
76
|
-
[73, 88],
|
|
77
|
-
[2, 88],
|
|
78
|
-
]),
|
|
79
|
-
star: polygon([
|
|
80
|
-
[50, 3],
|
|
81
|
-
[61, 37],
|
|
82
|
-
[97, 37],
|
|
83
|
-
[68, 59],
|
|
84
|
-
[79, 95],
|
|
85
|
-
[50, 73],
|
|
86
|
-
[21, 95],
|
|
87
|
-
[32, 59],
|
|
88
|
-
[3, 37],
|
|
89
|
-
[39, 37],
|
|
90
|
-
]),
|
|
91
|
-
heart: [
|
|
92
|
-
{ op: 'move', x: 50, y: 90 },
|
|
93
|
-
{ op: 'cubic', c1x: 6, c1y: 58, c2x: 10, c2y: 20, x: 32, y: 18 },
|
|
94
|
-
{ op: 'cubic', c1x: 44, c1y: 17, c2x: 50, c2y: 27, x: 50, y: 34 },
|
|
95
|
-
{ op: 'cubic', c1x: 50, c1y: 27, c2x: 56, c2y: 17, x: 68, y: 18 },
|
|
96
|
-
{ op: 'cubic', c1x: 90, c1y: 20, c2x: 94, c2y: 58, x: 50, y: 90 },
|
|
97
|
-
{ op: 'close' },
|
|
98
|
-
],
|
|
99
|
-
cloud: [
|
|
100
|
-
{ op: 'move', x: 30, y: 80 },
|
|
101
|
-
{ op: 'cubic', c1x: 13, c1y: 80, c2x: 6, c2y: 66, x: 16, y: 56 },
|
|
102
|
-
{ op: 'cubic', c1x: 11, c1y: 42, c2x: 27, c2y: 34, x: 37, y: 42 },
|
|
103
|
-
{ op: 'cubic', c1x: 41, c1y: 24, c2x: 66, c2y: 24, x: 70, y: 42 },
|
|
104
|
-
{ op: 'cubic', c1x: 86, c1y: 38, c2x: 96, c2y: 56, x: 84, y: 68 },
|
|
105
|
-
{ op: 'cubic', c1x: 92, c1y: 78, c2x: 82, c2y: 88, x: 70, y: 84 },
|
|
106
|
-
{ op: 'close' },
|
|
107
|
-
],
|
|
108
|
-
};
|
|
109
|
-
function getMaskShapeSegments(shape, rect, rotationDeg = 0) {
|
|
110
|
-
const unit = UNIT_SEGMENTS[shape];
|
|
111
|
-
if (!unit) {
|
|
112
|
-
throw new Error(`Unknown mask shape: ${shape}`);
|
|
113
|
-
}
|
|
114
|
-
const sx = rect.width / 100;
|
|
115
|
-
const sy = rect.height / 100;
|
|
116
|
-
const tx = (x) => rect.x + x * sx;
|
|
117
|
-
const ty = (y) => rect.y + y * sy;
|
|
118
|
-
const cx = rect.x + rect.width * 0.5;
|
|
119
|
-
const cy = rect.y + rect.height * 0.5;
|
|
120
|
-
const rotate = (x, y) => rotationDeg ? (0, rotation_math_1.rotatePoint)({ x, y }, rotationDeg, { x: cx, y: cy }) : { x, y };
|
|
121
|
-
return unit.map((s) => {
|
|
122
|
-
if (s.op === 'close') {
|
|
123
|
-
return { op: 'close' };
|
|
124
|
-
}
|
|
125
|
-
if (s.op === 'cubic') {
|
|
126
|
-
const c1 = rotate(tx(s.c1x), ty(s.c1y));
|
|
127
|
-
const c2 = rotate(tx(s.c2x), ty(s.c2y));
|
|
128
|
-
const p = rotate(tx(s.x), ty(s.y));
|
|
129
|
-
return { op: 'cubic', c1x: c1.x, c1y: c1.y, c2x: c2.x, c2y: c2.y, x: p.x, y: p.y };
|
|
130
|
-
}
|
|
131
|
-
const p = rotate(tx(s.x), ty(s.y));
|
|
132
|
-
return { op: s.op, x: p.x, y: p.y };
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
function rotatedRectAABB(rect, rotationDeg) {
|
|
136
|
-
if (!rotationDeg) {
|
|
137
|
-
return Object.assign({}, rect);
|
|
138
|
-
}
|
|
139
|
-
const cx = rect.x + rect.width * 0.5;
|
|
140
|
-
const cy = rect.y + rect.height * 0.5;
|
|
141
|
-
const corners = [
|
|
142
|
-
{ x: rect.x, y: rect.y },
|
|
143
|
-
{ x: rect.x + rect.width, y: rect.y },
|
|
144
|
-
{ x: rect.x + rect.width, y: rect.y + rect.height },
|
|
145
|
-
{ x: rect.x, y: rect.y + rect.height },
|
|
146
|
-
].map(p => (0, rotation_math_1.rotatePoint)(p, rotationDeg, { x: cx, y: cy }));
|
|
147
|
-
const xs = corners.map(p => p.x);
|
|
148
|
-
const ys = corners.map(p => p.y);
|
|
149
|
-
const minX = Math.min(...xs);
|
|
150
|
-
const maxX = Math.max(...xs);
|
|
151
|
-
const minY = Math.min(...ys);
|
|
152
|
-
const maxY = Math.max(...ys);
|
|
153
|
-
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
154
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rotatePoint = rotatePoint;
|
|
4
|
-
function rotatePoint(point, angleDeg, pivot = { x: 0, y: 0 }) {
|
|
5
|
-
const theta = (angleDeg * Math.PI) / 180;
|
|
6
|
-
const cos = Math.cos(theta);
|
|
7
|
-
const sin = Math.sin(theta);
|
|
8
|
-
const dx = point.x - pivot.x;
|
|
9
|
-
const dy = point.y - pivot.y;
|
|
10
|
-
return {
|
|
11
|
-
x: dx * cos - dy * sin + pivot.x,
|
|
12
|
-
y: dx * sin + dy * cos + pivot.y,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { CropDefinition, DocumentElement, SizeDefinition } from '../../types';
|
|
2
|
-
import { MaskRect, MaskShapeKey } from './mask-shape-geometry';
|
|
3
|
-
export declare function hasShapeMask(element: DocumentElement): boolean;
|
|
4
|
-
export declare function getShapeMaskKey(element: DocumentElement): MaskShapeKey | null;
|
|
5
|
-
export declare function getShapeMaskRotation(element: DocumentElement): number;
|
|
6
|
-
export declare function normalizeMaskRotation(rotation: number): number;
|
|
7
|
-
export declare function isShapeMaskable(element: DocumentElement): boolean;
|
|
8
|
-
export declare function getDefaultShapeMaskCrop(size: SizeDefinition): CropDefinition;
|
|
9
|
-
export declare function cropDefinitionToMaskRect(crop: CropDefinition, size: SizeDefinition): MaskRect;
|
|
10
|
-
export declare function maskRectToCropDefinition(rect: MaskRect, size: SizeDefinition): CropDefinition;
|
|
11
|
-
export declare const SHAPE_MASK_CLEAR_FIELDS: {
|
|
12
|
-
readonly maskDefinition: any;
|
|
13
|
-
readonly cropDefinition: any;
|
|
14
|
-
readonly imageSize: any;
|
|
15
|
-
readonly imagePosition: any;
|
|
16
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SHAPE_MASK_CLEAR_FIELDS = void 0;
|
|
4
|
-
exports.hasShapeMask = hasShapeMask;
|
|
5
|
-
exports.getShapeMaskKey = getShapeMaskKey;
|
|
6
|
-
exports.getShapeMaskRotation = getShapeMaskRotation;
|
|
7
|
-
exports.normalizeMaskRotation = normalizeMaskRotation;
|
|
8
|
-
exports.isShapeMaskable = isShapeMaskable;
|
|
9
|
-
exports.getDefaultShapeMaskCrop = getDefaultShapeMaskCrop;
|
|
10
|
-
exports.cropDefinitionToMaskRect = cropDefinitionToMaskRect;
|
|
11
|
-
exports.maskRectToCropDefinition = maskRectToCropDefinition;
|
|
12
|
-
const DEFAULT_MASK_FRACTION = 0.72;
|
|
13
|
-
function hasShapeMask(element) {
|
|
14
|
-
var _a, _b;
|
|
15
|
-
return (!!getShapeMaskKey(element) && !!((_a = element === null || element === void 0 ? void 0 : element.cropDefinition) === null || _a === void 0 ? void 0 : _a.widthPercent) && !!((_b = element === null || element === void 0 ? void 0 : element.cropDefinition) === null || _b === void 0 ? void 0 : _b.heightPercent));
|
|
16
|
-
}
|
|
17
|
-
function getShapeMaskKey(element) {
|
|
18
|
-
var _a, _b;
|
|
19
|
-
return (_b = (_a = element === null || element === void 0 ? void 0 : element.maskDefinition) === null || _a === void 0 ? void 0 : _a.shape) !== null && _b !== void 0 ? _b : null;
|
|
20
|
-
}
|
|
21
|
-
function getShapeMaskRotation(element) {
|
|
22
|
-
var _a, _b;
|
|
23
|
-
return (_b = (_a = element === null || element === void 0 ? void 0 : element.maskDefinition) === null || _a === void 0 ? void 0 : _a.rotation) !== null && _b !== void 0 ? _b : 0;
|
|
24
|
-
}
|
|
25
|
-
function normalizeMaskRotation(rotation) {
|
|
26
|
-
return ((rotation % 360) + 360) % 360;
|
|
27
|
-
}
|
|
28
|
-
function isShapeMaskable(element) {
|
|
29
|
-
return (element === null || element === void 0 ? void 0 : element.type) === 'image';
|
|
30
|
-
}
|
|
31
|
-
function getDefaultShapeMaskCrop(size) {
|
|
32
|
-
const side = Math.min(size.width, size.height) * DEFAULT_MASK_FRACTION;
|
|
33
|
-
return {
|
|
34
|
-
x1Percent: ((size.width - side) * 0.5) / size.width,
|
|
35
|
-
y1Percent: ((size.height - side) * 0.5) / size.height,
|
|
36
|
-
widthPercent: side / size.width,
|
|
37
|
-
heightPercent: side / size.height,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function cropDefinitionToMaskRect(crop, size) {
|
|
41
|
-
return {
|
|
42
|
-
x: crop.x1Percent * size.width,
|
|
43
|
-
y: crop.y1Percent * size.height,
|
|
44
|
-
width: crop.widthPercent * size.width,
|
|
45
|
-
height: crop.heightPercent * size.height,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function maskRectToCropDefinition(rect, size) {
|
|
49
|
-
return {
|
|
50
|
-
x1Percent: rect.x / size.width,
|
|
51
|
-
y1Percent: rect.y / size.height,
|
|
52
|
-
widthPercent: rect.width / size.width,
|
|
53
|
-
heightPercent: rect.height / size.height,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
exports.SHAPE_MASK_CLEAR_FIELDS = {
|
|
57
|
-
maskDefinition: null,
|
|
58
|
-
cropDefinition: null,
|
|
59
|
-
imageSize: null,
|
|
60
|
-
imagePosition: null,
|
|
61
|
-
};
|