@tldraw/editor 3.8.0-canary.d0d3a3c316fd → 3.8.0-canary.d0e779ce7b64
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.d.ts +0 -59
- package/dist-cjs/index.js +1 -3
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +15 -25
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/TextManager.js +0 -1
- package/dist-cjs/lib/editor/managers/TextManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/options.js +1 -2
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +0 -59
- package/dist-esm/index.mjs +1 -3
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +15 -25
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/TextManager.mjs +0 -1
- package/dist-esm/lib/editor/managers/TextManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +1 -2
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +1 -2
- package/package.json +7 -7
- package/src/index.ts +0 -2
- package/src/lib/components/default-components/DefaultCanvas.tsx +1 -1
- package/src/lib/editor/Editor.ts +16 -43
- package/src/lib/editor/managers/TextManager.ts +0 -1
- package/src/lib/editor/shapes/ShapeUtil.ts +1 -30
- package/src/lib/options.ts +0 -6
- package/src/version.ts +3 -3
- package/dist-cjs/lib/editor/shapes/shared/resizeScaled.js +0 -66
- package/dist-cjs/lib/editor/shapes/shared/resizeScaled.js.map +0 -7
- package/dist-esm/lib/editor/shapes/shared/resizeScaled.mjs +0 -46
- package/dist-esm/lib/editor/shapes/shared/resizeScaled.mjs.map +0 -7
- package/src/lib/editor/shapes/shared/resizeScaled.ts +0 -61
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { exhaustiveSwitchError } from "@tldraw/utils";
|
|
2
|
-
import { Vec } from "../../../primitives/Vec.mjs";
|
|
3
|
-
function resizeScaled(shape, { initialBounds, scaleX, scaleY, newPoint, handle }) {
|
|
4
|
-
let scaleDelta;
|
|
5
|
-
switch (handle) {
|
|
6
|
-
case "bottom_left":
|
|
7
|
-
case "bottom_right":
|
|
8
|
-
case "top_left":
|
|
9
|
-
case "top_right": {
|
|
10
|
-
scaleDelta = Math.max(0.01, Math.max(Math.abs(scaleX), Math.abs(scaleY)));
|
|
11
|
-
break;
|
|
12
|
-
}
|
|
13
|
-
case "left":
|
|
14
|
-
case "right": {
|
|
15
|
-
scaleDelta = Math.max(0.01, Math.abs(scaleX));
|
|
16
|
-
break;
|
|
17
|
-
}
|
|
18
|
-
case "bottom":
|
|
19
|
-
case "top": {
|
|
20
|
-
scaleDelta = Math.max(0.01, Math.abs(scaleY));
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
default: {
|
|
24
|
-
throw exhaustiveSwitchError(handle);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
const offset = new Vec(0, 0);
|
|
28
|
-
if (scaleX < 0) {
|
|
29
|
-
offset.x = -(initialBounds.width * scaleDelta);
|
|
30
|
-
}
|
|
31
|
-
if (scaleY < 0) {
|
|
32
|
-
offset.y = -(initialBounds.height * scaleDelta);
|
|
33
|
-
}
|
|
34
|
-
const { x, y } = Vec.Add(newPoint, offset.rot(shape.rotation));
|
|
35
|
-
return {
|
|
36
|
-
x,
|
|
37
|
-
y,
|
|
38
|
-
props: {
|
|
39
|
-
scale: scaleDelta * shape.props.scale
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
export {
|
|
44
|
-
resizeScaled
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=resizeScaled.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../src/lib/editor/shapes/shared/resizeScaled.ts"],
|
|
4
|
-
"sourcesContent": ["import { TLBaseShape } from '@tldraw/tlschema'\nimport { exhaustiveSwitchError } from '@tldraw/utils'\nimport { Vec } from '../../../primitives/Vec'\nimport { TLResizeInfo } from '../ShapeUtil'\n\n/**\n * Resize a shape that has a scale prop.\n *\n * @param shape - The shape to resize\n * @param info - The resize info\n *\n * @public */\nexport function resizeScaled(\n\tshape: TLBaseShape<any, { scale: number }>,\n\t{ initialBounds, scaleX, scaleY, newPoint, handle }: TLResizeInfo<any>\n) {\n\tlet scaleDelta: number\n\tswitch (handle) {\n\t\tcase 'bottom_left':\n\t\tcase 'bottom_right':\n\t\tcase 'top_left':\n\t\tcase 'top_right': {\n\t\t\tscaleDelta = Math.max(0.01, Math.max(Math.abs(scaleX), Math.abs(scaleY)))\n\t\t\tbreak\n\t\t}\n\t\tcase 'left':\n\t\tcase 'right': {\n\t\t\tscaleDelta = Math.max(0.01, Math.abs(scaleX))\n\t\t\tbreak\n\t\t}\n\t\tcase 'bottom':\n\t\tcase 'top': {\n\t\t\tscaleDelta = Math.max(0.01, Math.abs(scaleY))\n\t\t\tbreak\n\t\t}\n\t\tdefault: {\n\t\t\tthrow exhaustiveSwitchError(handle)\n\t\t}\n\t}\n\n\t// Compute the offset (if flipped X or flipped Y)\n\tconst offset = new Vec(0, 0)\n\n\tif (scaleX < 0) {\n\t\toffset.x = -(initialBounds.width * scaleDelta)\n\t}\n\tif (scaleY < 0) {\n\t\toffset.y = -(initialBounds.height * scaleDelta)\n\t}\n\n\t// Apply the offset to the new point\n\tconst { x, y } = Vec.Add(newPoint, offset.rot(shape.rotation))\n\n\treturn {\n\t\tx,\n\t\ty,\n\t\tprops: {\n\t\t\tscale: scaleDelta * shape.props.scale,\n\t\t},\n\t}\n}\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,6BAA6B;AACtC,SAAS,WAAW;AAUb,SAAS,aACf,OACA,EAAE,eAAe,QAAQ,QAAQ,UAAU,OAAO,GACjD;AACD,MAAI;AACJ,UAAQ,QAAQ;AAAA,IACf,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK,aAAa;AACjB,mBAAa,KAAK,IAAI,MAAM,KAAK,IAAI,KAAK,IAAI,MAAM,GAAG,KAAK,IAAI,MAAM,CAAC,CAAC;AACxE;AAAA,IACD;AAAA,IACA,KAAK;AAAA,IACL,KAAK,SAAS;AACb,mBAAa,KAAK,IAAI,MAAM,KAAK,IAAI,MAAM,CAAC;AAC5C;AAAA,IACD;AAAA,IACA,KAAK;AAAA,IACL,KAAK,OAAO;AACX,mBAAa,KAAK,IAAI,MAAM,KAAK,IAAI,MAAM,CAAC;AAC5C;AAAA,IACD;AAAA,IACA,SAAS;AACR,YAAM,sBAAsB,MAAM;AAAA,IACnC;AAAA,EACD;AAGA,QAAM,SAAS,IAAI,IAAI,GAAG,CAAC;AAE3B,MAAI,SAAS,GAAG;AACf,WAAO,IAAI,EAAE,cAAc,QAAQ;AAAA,EACpC;AACA,MAAI,SAAS,GAAG;AACf,WAAO,IAAI,EAAE,cAAc,SAAS;AAAA,EACrC;AAGA,QAAM,EAAE,GAAG,EAAE,IAAI,IAAI,IAAI,UAAU,OAAO,IAAI,MAAM,QAAQ,CAAC;AAE7D,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,OAAO;AAAA,MACN,OAAO,aAAa,MAAM,MAAM;AAAA,IACjC;AAAA,EACD;AACD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { TLBaseShape } from '@tldraw/tlschema'
|
|
2
|
-
import { exhaustiveSwitchError } from '@tldraw/utils'
|
|
3
|
-
import { Vec } from '../../../primitives/Vec'
|
|
4
|
-
import { TLResizeInfo } from '../ShapeUtil'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Resize a shape that has a scale prop.
|
|
8
|
-
*
|
|
9
|
-
* @param shape - The shape to resize
|
|
10
|
-
* @param info - The resize info
|
|
11
|
-
*
|
|
12
|
-
* @public */
|
|
13
|
-
export function resizeScaled(
|
|
14
|
-
shape: TLBaseShape<any, { scale: number }>,
|
|
15
|
-
{ initialBounds, scaleX, scaleY, newPoint, handle }: TLResizeInfo<any>
|
|
16
|
-
) {
|
|
17
|
-
let scaleDelta: number
|
|
18
|
-
switch (handle) {
|
|
19
|
-
case 'bottom_left':
|
|
20
|
-
case 'bottom_right':
|
|
21
|
-
case 'top_left':
|
|
22
|
-
case 'top_right': {
|
|
23
|
-
scaleDelta = Math.max(0.01, Math.max(Math.abs(scaleX), Math.abs(scaleY)))
|
|
24
|
-
break
|
|
25
|
-
}
|
|
26
|
-
case 'left':
|
|
27
|
-
case 'right': {
|
|
28
|
-
scaleDelta = Math.max(0.01, Math.abs(scaleX))
|
|
29
|
-
break
|
|
30
|
-
}
|
|
31
|
-
case 'bottom':
|
|
32
|
-
case 'top': {
|
|
33
|
-
scaleDelta = Math.max(0.01, Math.abs(scaleY))
|
|
34
|
-
break
|
|
35
|
-
}
|
|
36
|
-
default: {
|
|
37
|
-
throw exhaustiveSwitchError(handle)
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Compute the offset (if flipped X or flipped Y)
|
|
42
|
-
const offset = new Vec(0, 0)
|
|
43
|
-
|
|
44
|
-
if (scaleX < 0) {
|
|
45
|
-
offset.x = -(initialBounds.width * scaleDelta)
|
|
46
|
-
}
|
|
47
|
-
if (scaleY < 0) {
|
|
48
|
-
offset.y = -(initialBounds.height * scaleDelta)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Apply the offset to the new point
|
|
52
|
-
const { x, y } = Vec.Add(newPoint, offset.rot(shape.rotation))
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
x,
|
|
56
|
-
y,
|
|
57
|
-
props: {
|
|
58
|
-
scale: scaleDelta * shape.props.scale,
|
|
59
|
-
},
|
|
60
|
-
}
|
|
61
|
-
}
|