@tldraw/editor 3.7.0-canary.916221bf1c79 → 3.7.0-canary.ca54db7c3c7a
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 +3 -5
- package/dist-cjs/lib/editor/Editor.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 +3 -5
- package/dist-esm/lib/editor/Editor.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.test.ts +64 -3
- package/src/lib/editor/Editor.ts +2 -4
- package/src/version.ts +3 -3
package/dist-esm/version.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const version = "3.7.0-canary.
|
|
1
|
+
const version = "3.7.0-canary.ca54db7c3c7a";
|
|
2
2
|
const publishDates = {
|
|
3
3
|
major: "2024-09-13T14:36:29.063Z",
|
|
4
|
-
minor: "2024-12-
|
|
5
|
-
patch: "2024-12-
|
|
4
|
+
minor: "2024-12-05T16:54:38.452Z",
|
|
5
|
+
patch: "2024-12-05T16:54:38.452Z"
|
|
6
6
|
};
|
|
7
7
|
export {
|
|
8
8
|
publishDates,
|
package/dist-esm/version.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/version.ts"],
|
|
4
|
-
"sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.7.0-canary.
|
|
4
|
+
"sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '3.7.0-canary.ca54db7c3c7a'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2024-12-05T16:54:38.452Z',\n\tpatch: '2024-12-05T16:54:38.452Z',\n}\n"],
|
|
5
5
|
"mappings": "AAGO,MAAM,UAAU;AAChB,MAAM,eAAe;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tldraw/editor",
|
|
3
3
|
"description": "A tiny little drawing app (editor).",
|
|
4
|
-
"version": "3.7.0-canary.
|
|
4
|
+
"version": "3.7.0-canary.ca54db7c3c7a",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tldraw Inc.",
|
|
7
7
|
"email": "hello@tldraw.com"
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"lint": "yarn run -T tsx ../../internal/scripts/lint.ts"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@tldraw/state": "3.7.0-canary.
|
|
49
|
-
"@tldraw/state-react": "3.7.0-canary.
|
|
50
|
-
"@tldraw/store": "3.7.0-canary.
|
|
51
|
-
"@tldraw/tlschema": "3.7.0-canary.
|
|
52
|
-
"@tldraw/utils": "3.7.0-canary.
|
|
53
|
-
"@tldraw/validate": "3.7.0-canary.
|
|
48
|
+
"@tldraw/state": "3.7.0-canary.ca54db7c3c7a",
|
|
49
|
+
"@tldraw/state-react": "3.7.0-canary.ca54db7c3c7a",
|
|
50
|
+
"@tldraw/store": "3.7.0-canary.ca54db7c3c7a",
|
|
51
|
+
"@tldraw/tlschema": "3.7.0-canary.ca54db7c3c7a",
|
|
52
|
+
"@tldraw/utils": "3.7.0-canary.ca54db7c3c7a",
|
|
53
|
+
"@tldraw/validate": "3.7.0-canary.ca54db7c3c7a",
|
|
54
54
|
"@types/core-js": "^2.5.5",
|
|
55
55
|
"@use-gesture/react": "^10.2.27",
|
|
56
56
|
"classnames": "^2.3.2",
|
|
@@ -1,14 +1,58 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Box,
|
|
3
|
+
Geometry2d,
|
|
4
|
+
RecordProps,
|
|
5
|
+
Rectangle2d,
|
|
6
|
+
ShapeUtil,
|
|
7
|
+
T,
|
|
8
|
+
TLBaseShape,
|
|
9
|
+
createShapeId,
|
|
10
|
+
createTLStore,
|
|
11
|
+
} from '../..'
|
|
2
12
|
import { Editor } from './Editor'
|
|
3
13
|
|
|
14
|
+
type ICustomShape = TLBaseShape<
|
|
15
|
+
'my-custom-shape',
|
|
16
|
+
{
|
|
17
|
+
w: number
|
|
18
|
+
h: number
|
|
19
|
+
text: string | undefined
|
|
20
|
+
}
|
|
21
|
+
>
|
|
22
|
+
|
|
23
|
+
class CustomShape extends ShapeUtil<ICustomShape> {
|
|
24
|
+
static override type = 'my-custom-shape' as const
|
|
25
|
+
static override props: RecordProps<ICustomShape> = {
|
|
26
|
+
w: T.number,
|
|
27
|
+
h: T.number,
|
|
28
|
+
text: T.string.optional(),
|
|
29
|
+
}
|
|
30
|
+
getDefaultProps(): ICustomShape['props'] {
|
|
31
|
+
return {
|
|
32
|
+
w: 200,
|
|
33
|
+
h: 200,
|
|
34
|
+
text: '',
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
getGeometry(shape: ICustomShape): Geometry2d {
|
|
38
|
+
return new Rectangle2d({
|
|
39
|
+
width: shape.props.w,
|
|
40
|
+
height: shape.props.h,
|
|
41
|
+
isFilled: true,
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
indicator() {}
|
|
45
|
+
component() {}
|
|
46
|
+
}
|
|
47
|
+
|
|
4
48
|
let editor: Editor
|
|
5
49
|
|
|
6
50
|
beforeEach(() => {
|
|
7
51
|
editor = new Editor({
|
|
8
|
-
shapeUtils: [],
|
|
52
|
+
shapeUtils: [CustomShape],
|
|
9
53
|
bindingUtils: [],
|
|
10
54
|
tools: [],
|
|
11
|
-
store: createTLStore({ shapeUtils: [] }),
|
|
55
|
+
store: createTLStore({ shapeUtils: [CustomShape] }),
|
|
12
56
|
getContainer: () => document.body,
|
|
13
57
|
})
|
|
14
58
|
editor.setCameraOptions({ isLocked: true })
|
|
@@ -28,6 +72,23 @@ describe('centerOnPoint', () => {
|
|
|
28
72
|
})
|
|
29
73
|
})
|
|
30
74
|
|
|
75
|
+
describe('updateShape', () => {
|
|
76
|
+
it('updates shape props to undefined', () => {
|
|
77
|
+
const id = createShapeId('sample')
|
|
78
|
+
editor.createShape({
|
|
79
|
+
id,
|
|
80
|
+
type: 'my-custom-shape',
|
|
81
|
+
props: { w: 100, h: 100, text: 'Hello' },
|
|
82
|
+
})
|
|
83
|
+
const shape = editor.getShape(id) as ICustomShape
|
|
84
|
+
expect(shape.props).toEqual({ w: 100, h: 100, text: 'Hello' })
|
|
85
|
+
|
|
86
|
+
editor.updateShape({ ...shape, props: { ...shape.props, text: undefined } })
|
|
87
|
+
const updatedShape = editor.getShape(id) as ICustomShape
|
|
88
|
+
expect(updatedShape.props).toEqual({ w: 100, h: 100, text: undefined })
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
|
|
31
92
|
describe('zoomToFit', () => {
|
|
32
93
|
it('no-op when isLocked is set', () => {
|
|
33
94
|
editor.getCurrentPageShapeIds = jest.fn(() => new Set([createShapeId('box1')]))
|
package/src/lib/editor/Editor.ts
CHANGED
|
@@ -3750,7 +3750,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
3750
3750
|
* @public
|
|
3751
3751
|
*/
|
|
3752
3752
|
@computed getPages(): TLPage[] {
|
|
3753
|
-
return this._getAllPagesQuery().get().sort(sortByIndex)
|
|
3753
|
+
return Array.from(this._getAllPagesQuery().get()).sort(sortByIndex)
|
|
3754
3754
|
}
|
|
3755
3755
|
|
|
3756
3756
|
/**
|
|
@@ -9806,9 +9806,7 @@ function applyPartialToRecordWithProps<
|
|
|
9806
9806
|
if (k === 'props' || k === 'meta') {
|
|
9807
9807
|
next[k] = { ...prev[k] } as JsonObject
|
|
9808
9808
|
for (const [nextKey, nextValue] of Object.entries(v as object)) {
|
|
9809
|
-
|
|
9810
|
-
;(next[k] as JsonObject)[nextKey] = nextValue
|
|
9811
|
-
}
|
|
9809
|
+
;(next[k] as JsonObject)[nextKey] = nextValue
|
|
9812
9810
|
}
|
|
9813
9811
|
continue
|
|
9814
9812
|
}
|
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.7.0-canary.
|
|
4
|
+
export const version = '3.7.0-canary.ca54db7c3c7a'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2024-09-13T14:36:29.063Z',
|
|
7
|
-
minor: '2024-12-
|
|
8
|
-
patch: '2024-12-
|
|
7
|
+
minor: '2024-12-05T16:54:38.452Z',
|
|
8
|
+
patch: '2024-12-05T16:54:38.452Z',
|
|
9
9
|
}
|