@tldraw/editor 3.13.0-canary.9061a9bbd3fb → 3.13.0-canary.996d0adfecaf
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 +29 -14
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/TldrawEditor.js +2 -1
- package/dist-cjs/lib/TldrawEditor.js.map +2 -2
- package/dist-cjs/lib/components/Shape.js +12 -8
- package/dist-cjs/lib/components/Shape.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +27 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js +8 -6
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js +17 -11
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultSpinner.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultSpinner.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +21 -8
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/exports/getSvgJsx.js +12 -3
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/hooks/useDocumentEvents.js +3 -2
- package/dist-cjs/lib/hooks/useDocumentEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useEditorComponents.js +16 -15
- package/dist-cjs/lib/hooks/useEditorComponents.js.map +2 -2
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/utils/areShapesContentEqual.js +25 -0
- package/dist-cjs/lib/utils/areShapesContentEqual.js.map +7 -0
- package/dist-cjs/lib/utils/dom.js +3 -3
- package/dist-cjs/lib/utils/dom.js.map +2 -2
- package/dist-cjs/lib/utils/nearestMultiple.js +34 -0
- package/dist-cjs/lib/utils/nearestMultiple.js.map +7 -0
- package/dist-cjs/lib/utils/rotation.js +5 -5
- package/dist-cjs/lib/utils/rotation.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 +29 -14
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/TldrawEditor.mjs +2 -1
- package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
- package/dist-esm/lib/components/Shape.mjs +12 -8
- package/dist-esm/lib/components/Shape.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +27 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs +8 -6
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs +17 -11
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultSpinner.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultSpinner.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +21 -8
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs +12 -3
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
- package/dist-esm/lib/hooks/useDocumentEvents.mjs +3 -2
- package/dist-esm/lib/hooks/useDocumentEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditorComponents.mjs +16 -15
- package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/utils/areShapesContentEqual.mjs +5 -0
- package/dist-esm/lib/utils/areShapesContentEqual.mjs.map +7 -0
- package/dist-esm/lib/utils/dom.mjs +3 -3
- package/dist-esm/lib/utils/dom.mjs.map +2 -2
- package/dist-esm/lib/utils/nearestMultiple.mjs +14 -0
- package/dist-esm/lib/utils/nearestMultiple.mjs.map +7 -0
- package/dist-esm/lib/utils/rotation.mjs +5 -5
- package/dist-esm/lib/utils/rotation.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +5 -0
- package/package.json +7 -7
- package/src/lib/TldrawEditor.tsx +6 -1
- package/src/lib/components/Shape.tsx +14 -10
- package/src/lib/components/default-components/DefaultCanvas.tsx +32 -2
- package/src/lib/components/default-components/DefaultErrorFallback.tsx +15 -8
- package/src/lib/components/default-components/DefaultShapeIndicator.tsx +17 -8
- package/src/lib/components/default-components/DefaultSpinner.tsx +1 -1
- package/src/lib/editor/Editor.ts +21 -8
- package/src/lib/editor/shapes/ShapeUtil.ts +13 -1
- package/src/lib/exports/getSvgJsx.tsx +16 -7
- package/src/lib/hooks/useDocumentEvents.ts +7 -2
- package/src/lib/hooks/useEditorComponents.tsx +32 -28
- package/src/lib/options.ts +4 -0
- package/src/lib/utils/areShapesContentEqual.ts +4 -0
- package/src/lib/utils/dom.ts +4 -4
- package/src/lib/utils/nearestMultiple.ts +13 -0
- package/src/lib/utils/rotation.ts +8 -6
- package/src/version.ts +3 -3
package/src/lib/options.ts
CHANGED
|
@@ -80,6 +80,10 @@ export interface TldrawOptions {
|
|
|
80
80
|
* nonce to use in the editor's styles.
|
|
81
81
|
*/
|
|
82
82
|
readonly nonce: string | undefined
|
|
83
|
+
/**
|
|
84
|
+
* Branding name of the app, currently only used for adding aria-label for the application.
|
|
85
|
+
*/
|
|
86
|
+
readonly branding?: string
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
/** @public */
|
package/src/lib/utils/dom.ts
CHANGED
|
@@ -91,14 +91,14 @@ export const setStyleProperty = (
|
|
|
91
91
|
elm.style.setProperty(property, value as string)
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
const INPUTS = ['input', 'select', 'button', 'textarea']
|
|
95
|
-
|
|
96
94
|
/** @internal */
|
|
97
|
-
export function activeElementShouldCaptureKeys() {
|
|
95
|
+
export function activeElementShouldCaptureKeys(allowButtons = false) {
|
|
98
96
|
const { activeElement } = document
|
|
97
|
+
const elements = allowButtons ? ['input', 'textarea'] : ['input', 'select', 'button', 'textarea']
|
|
99
98
|
return !!(
|
|
100
99
|
activeElement &&
|
|
101
100
|
((activeElement as HTMLElement).isContentEditable ||
|
|
102
|
-
|
|
101
|
+
elements.indexOf(activeElement.tagName.toLowerCase()) > -1 ||
|
|
102
|
+
activeElement.classList.contains('tlui-slider__thumb'))
|
|
103
103
|
)
|
|
104
104
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Euclidean algorithm to find the GCD
|
|
2
|
+
function gcd(a: number, b: number): number {
|
|
3
|
+
return b === 0 ? a : gcd(b, a % b)
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// Returns the lowest value that the given number can be multiplied by to reach an integer
|
|
7
|
+
export function nearestMultiple(float: number) {
|
|
8
|
+
const decimal = float.toString().split('.')[1]
|
|
9
|
+
if (!decimal) return 1
|
|
10
|
+
const denominator = Math.pow(10, decimal.length)
|
|
11
|
+
const numerator = parseInt(decimal, 10)
|
|
12
|
+
return denominator / gcd(numerator, denominator)
|
|
13
|
+
}
|
|
@@ -26,11 +26,13 @@ export function getRotationSnapshot({
|
|
|
26
26
|
return null
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const
|
|
29
|
+
const initialPageCenter = rotatedPageBounds.center
|
|
30
|
+
.clone()
|
|
31
|
+
.rotWith(rotatedPageBounds.point, rotation)
|
|
30
32
|
|
|
31
33
|
return {
|
|
32
|
-
|
|
33
|
-
initialCursorAngle:
|
|
34
|
+
initialPageCenter,
|
|
35
|
+
initialCursorAngle: initialPageCenter.angle(editor.inputs.originPagePoint),
|
|
34
36
|
initialShapesRotation: rotation,
|
|
35
37
|
shapeSnapshots: shapes.map((shape) => ({
|
|
36
38
|
shape,
|
|
@@ -43,7 +45,7 @@ export function getRotationSnapshot({
|
|
|
43
45
|
* @internal
|
|
44
46
|
**/
|
|
45
47
|
export interface TLRotationSnapshot {
|
|
46
|
-
|
|
48
|
+
initialPageCenter: Vec
|
|
47
49
|
initialCursorAngle: number
|
|
48
50
|
initialShapesRotation: number
|
|
49
51
|
shapeSnapshots: {
|
|
@@ -66,7 +68,7 @@ export function applyRotationToSnapshotShapes({
|
|
|
66
68
|
stage: 'start' | 'update' | 'end' | 'one-off'
|
|
67
69
|
centerOverride?: VecLike
|
|
68
70
|
}) {
|
|
69
|
-
const {
|
|
71
|
+
const { initialPageCenter, shapeSnapshots } = snapshot
|
|
70
72
|
|
|
71
73
|
editor.updateShapes(
|
|
72
74
|
shapeSnapshots.map(({ shape, initialPagePoint }) => {
|
|
@@ -77,7 +79,7 @@ export function applyRotationToSnapshotShapes({
|
|
|
77
79
|
? editor.getShapePageTransform(shape.parentId)!
|
|
78
80
|
: Mat.Identity()
|
|
79
81
|
|
|
80
|
-
const newPagePoint = Vec.RotWith(initialPagePoint, centerOverride ??
|
|
82
|
+
const newPagePoint = Vec.RotWith(initialPagePoint, centerOverride ?? initialPageCenter, delta)
|
|
81
83
|
|
|
82
84
|
const newLocalPoint = Mat.applyToPoint(
|
|
83
85
|
// use the current parent transform in case it has moved/resized since the start
|
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.13.0-canary.
|
|
4
|
+
export const version = '3.13.0-canary.996d0adfecaf'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2024-09-13T14:36:29.063Z',
|
|
7
|
-
minor: '2025-
|
|
8
|
-
patch: '2025-
|
|
7
|
+
minor: '2025-05-06T11:20:43.652Z',
|
|
8
|
+
patch: '2025-05-06T11:20:43.652Z',
|
|
9
9
|
}
|