@tldraw/editor 3.14.0-canary.f6a0206007b3 → 3.14.0-canary.f8af44c4d1e2
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/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/editor/Editor.js +1 -4
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/FontManager.js +5 -1
- package/dist-cjs/lib/editor/managers/FontManager.js.map +2 -2
- package/dist-cjs/lib/primitives/Box.js +33 -33
- package/dist-cjs/lib/primitives/Box.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/editor/Editor.mjs +1 -4
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/FontManager.mjs +5 -1
- package/dist-esm/lib/editor/managers/FontManager.mjs.map +2 -2
- package/dist-esm/lib/primitives/Box.mjs +33 -33
- package/dist-esm/lib/primitives/Box.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/package.json +7 -7
- package/src/lib/editor/Editor.ts +1 -4
- package/src/lib/editor/managers/FontManager.ts +5 -1
- package/src/lib/primitives/Box.test.ts +588 -7
- package/src/lib/primitives/Box.ts +33 -33
- package/src/version.ts +3 -3
|
@@ -134,33 +134,33 @@ export class Box {
|
|
|
134
134
|
|
|
135
135
|
// eslint-disable-next-line no-restricted-syntax
|
|
136
136
|
get center() {
|
|
137
|
-
return new Vec(this.
|
|
137
|
+
return new Vec(this.x + this.w / 2, this.y + this.h / 2)
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
// eslint-disable-next-line no-restricted-syntax
|
|
141
141
|
set center(v: Vec) {
|
|
142
|
-
this.
|
|
143
|
-
this.
|
|
142
|
+
this.x = v.x - this.w / 2
|
|
143
|
+
this.y = v.y - this.h / 2
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
// eslint-disable-next-line no-restricted-syntax
|
|
147
147
|
get corners() {
|
|
148
148
|
return [
|
|
149
|
-
new Vec(this.
|
|
150
|
-
new Vec(this.
|
|
151
|
-
new Vec(this.
|
|
152
|
-
new Vec(this.
|
|
149
|
+
new Vec(this.x, this.y),
|
|
150
|
+
new Vec(this.x + this.w, this.y),
|
|
151
|
+
new Vec(this.x + this.w, this.y + this.h),
|
|
152
|
+
new Vec(this.x, this.y + this.h),
|
|
153
153
|
]
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
// eslint-disable-next-line no-restricted-syntax
|
|
157
157
|
get cornersAndCenter() {
|
|
158
158
|
return [
|
|
159
|
-
new Vec(this.
|
|
160
|
-
new Vec(this.
|
|
161
|
-
new Vec(this.
|
|
162
|
-
new Vec(this.
|
|
163
|
-
this.
|
|
159
|
+
new Vec(this.x, this.y),
|
|
160
|
+
new Vec(this.x + this.w, this.y),
|
|
161
|
+
new Vec(this.x + this.w, this.y + this.h),
|
|
162
|
+
new Vec(this.x, this.y + this.h),
|
|
163
|
+
new Vec(this.x + this.w / 2, this.y + this.h / 2),
|
|
164
164
|
]
|
|
165
165
|
}
|
|
166
166
|
|
|
@@ -205,10 +205,10 @@ export class Box {
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
expand(A: Box) {
|
|
208
|
-
const minX = Math.min(this.
|
|
209
|
-
const minY = Math.min(this.
|
|
210
|
-
const maxX = Math.max(this.
|
|
211
|
-
const maxY = Math.max(this.
|
|
208
|
+
const minX = Math.min(this.x, A.x)
|
|
209
|
+
const minY = Math.min(this.y, A.y)
|
|
210
|
+
const maxX = Math.max(this.x + this.w, A.x + A.w)
|
|
211
|
+
const maxY = Math.max(this.y + this.h, A.y + A.h)
|
|
212
212
|
|
|
213
213
|
this.x = minX
|
|
214
214
|
this.y = minY
|
|
@@ -245,10 +245,10 @@ export class Box {
|
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
snapToGrid(size: number) {
|
|
248
|
-
const minX = Math.round(this.
|
|
249
|
-
const minY = Math.round(this.
|
|
250
|
-
const maxX = Math.round(this.
|
|
251
|
-
const maxY = Math.round(this.
|
|
248
|
+
const minX = Math.round(this.x / size) * size
|
|
249
|
+
const minY = Math.round(this.y / size) * size
|
|
250
|
+
const maxX = Math.round((this.x + this.w) / size) * size
|
|
251
|
+
const maxY = Math.round((this.y + this.h) / size) * size
|
|
252
252
|
this.minX = minX
|
|
253
253
|
this.minY = minY
|
|
254
254
|
this.width = Math.max(1, maxX - minX)
|
|
@@ -274,26 +274,26 @@ export class Box {
|
|
|
274
274
|
getHandlePoint(handle: SelectionCorner | SelectionEdge) {
|
|
275
275
|
switch (handle) {
|
|
276
276
|
case 'top_left':
|
|
277
|
-
return new Vec(this.
|
|
277
|
+
return new Vec(this.x, this.y)
|
|
278
278
|
case 'top_right':
|
|
279
|
-
return new Vec(this.
|
|
279
|
+
return new Vec(this.x + this.w, this.y)
|
|
280
280
|
case 'bottom_left':
|
|
281
|
-
return new Vec(this.
|
|
281
|
+
return new Vec(this.x, this.y + this.h)
|
|
282
282
|
case 'bottom_right':
|
|
283
|
-
return new Vec(this.
|
|
283
|
+
return new Vec(this.x + this.w, this.y + this.h)
|
|
284
284
|
case 'top':
|
|
285
|
-
return new Vec(this.
|
|
285
|
+
return new Vec(this.x + this.w / 2, this.y)
|
|
286
286
|
case 'right':
|
|
287
|
-
return new Vec(this.
|
|
287
|
+
return new Vec(this.x + this.w, this.y + this.h / 2)
|
|
288
288
|
case 'bottom':
|
|
289
|
-
return new Vec(this.
|
|
289
|
+
return new Vec(this.x + this.w / 2, this.y + this.h)
|
|
290
290
|
case 'left':
|
|
291
|
-
return new Vec(this.
|
|
291
|
+
return new Vec(this.x, this.y + this.h / 2)
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
|
|
295
295
|
toJson(): BoxModel {
|
|
296
|
-
return { x: this.
|
|
296
|
+
return { x: this.x, y: this.y, w: this.w, h: this.h }
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
resize(handle: SelectionCorner | SelectionEdge | string, dx: number, dy: number) {
|
|
@@ -357,10 +357,10 @@ export class Box {
|
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
union(box: BoxModel) {
|
|
360
|
-
const minX = Math.min(this.
|
|
361
|
-
const minY = Math.min(this.
|
|
362
|
-
const maxX = Math.max(this.
|
|
363
|
-
const maxY = Math.max(this.
|
|
360
|
+
const minX = Math.min(this.x, box.x)
|
|
361
|
+
const minY = Math.min(this.y, box.y)
|
|
362
|
+
const maxX = Math.max(this.x + this.w, box.x + box.w)
|
|
363
|
+
const maxY = Math.max(this.y + this.h, box.y + box.h)
|
|
364
364
|
|
|
365
365
|
this.x = minX
|
|
366
366
|
this.y = minY
|
package/src/version.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// This file is automatically generated by internal/scripts/refresh-assets.ts.
|
|
2
2
|
// Do not edit manually. Or do, I'm a comment, not a cop.
|
|
3
3
|
|
|
4
|
-
export const version = '3.14.0-canary.
|
|
4
|
+
export const version = '3.14.0-canary.f8af44c4d1e2'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2024-09-13T14:36:29.063Z',
|
|
7
|
-
minor: '2025-06-
|
|
8
|
-
patch: '2025-06-
|
|
7
|
+
minor: '2025-06-06T13:42:11.362Z',
|
|
8
|
+
patch: '2025-06-06T13:42:11.362Z',
|
|
9
9
|
}
|