@tldraw/editor 3.15.0-canary.53600affdb31 → 3.15.0-canary.5c62460ab7f9
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 +34 -0
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +63 -34
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/types/misc-types.js.map +1 -1
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +34 -0
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +63 -34
- 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/index.ts +1 -0
- package/src/lib/editor/Editor.ts +70 -34
- package/src/lib/editor/types/misc-types.ts +19 -0
- package/src/version.ts +3 -3
package/dist-esm/version.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const version = "3.15.0-canary.
|
|
1
|
+
const version = "3.15.0-canary.5c62460ab7f9";
|
|
2
2
|
const publishDates = {
|
|
3
3
|
major: "2024-09-13T14:36:29.063Z",
|
|
4
|
-
minor: "2025-07-
|
|
5
|
-
patch: "2025-07-
|
|
4
|
+
minor: "2025-07-29T11:08:24.423Z",
|
|
5
|
+
patch: "2025-07-29T11:08:24.423Z"
|
|
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.15.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.15.0-canary.5c62460ab7f9'\nexport const publishDates = {\n\tmajor: '2024-09-13T14:36:29.063Z',\n\tminor: '2025-07-29T11:08:24.423Z',\n\tpatch: '2025-07-29T11:08:24.423Z',\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": "tldraw infinite canvas SDK (editor).",
|
|
4
|
-
"version": "3.15.0-canary.
|
|
4
|
+
"version": "3.15.0-canary.5c62460ab7f9",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tldraw Inc.",
|
|
7
7
|
"email": "hello@tldraw.com"
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"@tiptap/core": "^2.9.1",
|
|
50
50
|
"@tiptap/pm": "^2.9.1",
|
|
51
51
|
"@tiptap/react": "^2.9.1",
|
|
52
|
-
"@tldraw/state": "3.15.0-canary.
|
|
53
|
-
"@tldraw/state-react": "3.15.0-canary.
|
|
54
|
-
"@tldraw/store": "3.15.0-canary.
|
|
55
|
-
"@tldraw/tlschema": "3.15.0-canary.
|
|
56
|
-
"@tldraw/utils": "3.15.0-canary.
|
|
57
|
-
"@tldraw/validate": "3.15.0-canary.
|
|
52
|
+
"@tldraw/state": "3.15.0-canary.5c62460ab7f9",
|
|
53
|
+
"@tldraw/state-react": "3.15.0-canary.5c62460ab7f9",
|
|
54
|
+
"@tldraw/store": "3.15.0-canary.5c62460ab7f9",
|
|
55
|
+
"@tldraw/tlschema": "3.15.0-canary.5c62460ab7f9",
|
|
56
|
+
"@tldraw/utils": "3.15.0-canary.5c62460ab7f9",
|
|
57
|
+
"@tldraw/validate": "3.15.0-canary.5c62460ab7f9",
|
|
58
58
|
"@types/core-js": "^2.5.8",
|
|
59
59
|
"@use-gesture/react": "^10.3.1",
|
|
60
60
|
"classnames": "^2.5.1",
|
package/src/index.ts
CHANGED
package/src/lib/editor/Editor.ts
CHANGED
|
@@ -178,6 +178,7 @@ import {
|
|
|
178
178
|
TLCameraOptions,
|
|
179
179
|
TLImageExportOptions,
|
|
180
180
|
TLSvgExportOptions,
|
|
181
|
+
TLUpdatePointerOptions,
|
|
181
182
|
} from './types/misc-types'
|
|
182
183
|
import { TLAdjacentDirection, TLResizeHandle } from './types/selection-types'
|
|
183
184
|
|
|
@@ -3072,7 +3073,6 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
3072
3073
|
// Dispatch a new pointer move because the pointer's page will have changed
|
|
3073
3074
|
// (its screen position will compute to a new page position given the new camera position)
|
|
3074
3075
|
const { currentScreenPoint, currentPagePoint } = this.inputs
|
|
3075
|
-
const { screenBounds } = this.store.unsafeGetWithoutCapture(TLINSTANCE_ID)!
|
|
3076
3076
|
|
|
3077
3077
|
// compare the next page point (derived from the current camera) to the current page point
|
|
3078
3078
|
if (
|
|
@@ -3080,27 +3080,10 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
3080
3080
|
currentScreenPoint.y / z - y !== currentPagePoint.y
|
|
3081
3081
|
) {
|
|
3082
3082
|
// If it's changed, dispatch a pointer event
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
target: 'canvas',
|
|
3086
|
-
name: 'pointer_move',
|
|
3087
|
-
// weird but true: we need to put the screen point back into client space
|
|
3088
|
-
point: Vec.AddXY(currentScreenPoint, screenBounds.x, screenBounds.y),
|
|
3083
|
+
this.updatePointer({
|
|
3084
|
+
immediate: opts?.immediate,
|
|
3089
3085
|
pointerId: INTERNAL_POINTER_IDS.CAMERA_MOVE,
|
|
3090
|
-
|
|
3091
|
-
altKey: this.inputs.altKey,
|
|
3092
|
-
shiftKey: this.inputs.shiftKey,
|
|
3093
|
-
metaKey: this.inputs.metaKey,
|
|
3094
|
-
accelKey: isAccelKey(this.inputs),
|
|
3095
|
-
button: 0,
|
|
3096
|
-
isPen: this.getInstanceState().isPenMode ?? false,
|
|
3097
|
-
}
|
|
3098
|
-
|
|
3099
|
-
if (opts?.immediate) {
|
|
3100
|
-
this._flushEventForTick(event)
|
|
3101
|
-
} else {
|
|
3102
|
-
this.dispatch(event)
|
|
3103
|
-
}
|
|
3086
|
+
})
|
|
3104
3087
|
}
|
|
3105
3088
|
|
|
3106
3089
|
this._tickCameraState()
|
|
@@ -4421,21 +4404,28 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
4421
4404
|
*/
|
|
4422
4405
|
deletePage(page: TLPageId | TLPage): this {
|
|
4423
4406
|
const id = typeof page === 'string' ? page : page.id
|
|
4424
|
-
this.run(
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4407
|
+
this.run(
|
|
4408
|
+
() => {
|
|
4409
|
+
if (this.getIsReadonly()) return
|
|
4410
|
+
const pages = this.getPages()
|
|
4411
|
+
if (pages.length === 1) return
|
|
4428
4412
|
|
|
4429
|
-
|
|
4430
|
-
|
|
4413
|
+
const deletedPage = this.getPage(id)
|
|
4414
|
+
if (!deletedPage) return
|
|
4431
4415
|
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4416
|
+
if (id === this.getCurrentPageId()) {
|
|
4417
|
+
const index = pages.findIndex((page) => page.id === id)
|
|
4418
|
+
const next = pages[index - 1] ?? pages[index + 1]
|
|
4419
|
+
this.setCurrentPage(next.id)
|
|
4420
|
+
}
|
|
4421
|
+
|
|
4422
|
+
const shapes = this.getSortedChildIdsForParent(deletedPage.id)
|
|
4423
|
+
this.deleteShapes(shapes)
|
|
4424
|
+
|
|
4425
|
+
this.store.remove([deletedPage.id])
|
|
4426
|
+
},
|
|
4427
|
+
{ ignoreShapeLock: true }
|
|
4428
|
+
)
|
|
4439
4429
|
return this
|
|
4440
4430
|
}
|
|
4441
4431
|
|
|
@@ -9673,6 +9663,52 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
9673
9663
|
return this
|
|
9674
9664
|
}
|
|
9675
9665
|
|
|
9666
|
+
/**
|
|
9667
|
+
* Dispatch a pointer move event in the current position of the pointer. This is useful when
|
|
9668
|
+
* external circumstances have changed (e.g. the camera moved or a shape was moved) and you want
|
|
9669
|
+
* the current interaction to respond to that change.
|
|
9670
|
+
*
|
|
9671
|
+
* @example
|
|
9672
|
+
* ```ts
|
|
9673
|
+
* editor.updatePointer()
|
|
9674
|
+
* ```
|
|
9675
|
+
*
|
|
9676
|
+
* @param options - The options for updating the pointer.
|
|
9677
|
+
* @returns The editor instance.
|
|
9678
|
+
* @public
|
|
9679
|
+
*/
|
|
9680
|
+
updatePointer(options?: TLUpdatePointerOptions): this {
|
|
9681
|
+
const event: TLPointerEventInfo = {
|
|
9682
|
+
type: 'pointer',
|
|
9683
|
+
target: 'canvas',
|
|
9684
|
+
name: 'pointer_move',
|
|
9685
|
+
point:
|
|
9686
|
+
options?.point ??
|
|
9687
|
+
// weird but true: what `inputs` calls screen-space is actually viewport space. so
|
|
9688
|
+
// we need to convert back into true screen space first. we should fix this...
|
|
9689
|
+
Vec.Add(
|
|
9690
|
+
this.inputs.currentScreenPoint,
|
|
9691
|
+
this.store.unsafeGetWithoutCapture(TLINSTANCE_ID)!.screenBounds
|
|
9692
|
+
),
|
|
9693
|
+
pointerId: options?.pointerId ?? 0,
|
|
9694
|
+
button: options?.button ?? 0,
|
|
9695
|
+
isPen: options?.isPen ?? this.inputs.isPen,
|
|
9696
|
+
shiftKey: options?.shiftKey ?? this.inputs.shiftKey,
|
|
9697
|
+
altKey: options?.altKey ?? this.inputs.altKey,
|
|
9698
|
+
ctrlKey: options?.ctrlKey ?? this.inputs.ctrlKey,
|
|
9699
|
+
metaKey: options?.metaKey ?? this.inputs.metaKey,
|
|
9700
|
+
accelKey: options?.accelKey ?? isAccelKey(this.inputs),
|
|
9701
|
+
}
|
|
9702
|
+
|
|
9703
|
+
if (options?.immediate) {
|
|
9704
|
+
this._flushEventForTick(event)
|
|
9705
|
+
} else {
|
|
9706
|
+
this.dispatch(event)
|
|
9707
|
+
}
|
|
9708
|
+
|
|
9709
|
+
return this
|
|
9710
|
+
}
|
|
9711
|
+
|
|
9676
9712
|
/**
|
|
9677
9713
|
* Puts the editor into focused mode.
|
|
9678
9714
|
*
|
|
@@ -187,3 +187,22 @@ export interface TLCameraConstraints {
|
|
|
187
187
|
y: 'free' | 'fixed' | 'inside' | 'outside' | 'contain'
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
+
|
|
191
|
+
/** @public */
|
|
192
|
+
export interface TLUpdatePointerOptions {
|
|
193
|
+
/** Whether to update the pointer immediately, rather than on the next tick. */
|
|
194
|
+
immediate?: boolean
|
|
195
|
+
/**
|
|
196
|
+
* The point, in screen-space, to update the pointer to. Defaults to the position of the last
|
|
197
|
+
* pointer event.
|
|
198
|
+
*/
|
|
199
|
+
point?: VecLike
|
|
200
|
+
pointerId?: number
|
|
201
|
+
ctrlKey?: boolean
|
|
202
|
+
altKey?: boolean
|
|
203
|
+
shiftKey?: boolean
|
|
204
|
+
metaKey?: boolean
|
|
205
|
+
accelKey?: boolean
|
|
206
|
+
isPen?: boolean
|
|
207
|
+
button?: number
|
|
208
|
+
}
|
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.15.0-canary.
|
|
4
|
+
export const version = '3.15.0-canary.5c62460ab7f9'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2024-09-13T14:36:29.063Z',
|
|
7
|
-
minor: '2025-07-
|
|
8
|
-
patch: '2025-07-
|
|
7
|
+
minor: '2025-07-29T11:08:24.423Z',
|
|
8
|
+
patch: '2025-07-29T11:08:24.423Z',
|
|
9
9
|
}
|