@tldraw/editor 3.8.0-canary.fc0f484388e4 → 3.8.0-canary.ff19d0d907b9
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 +46 -83
- package/dist-cjs/index.js +8 -8
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/config/TLSessionStateSnapshot.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +0 -1
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.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/types/emit-types.js.map +1 -1
- package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
- package/dist-cjs/lib/exports/StyleEmbedder.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 +46 -83
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/config/TLSessionStateSnapshot.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +0 -1
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.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/exports/StyleEmbedder.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/package.json +20 -20
- package/src/index.ts +1 -13
- package/src/lib/config/TLSessionStateSnapshot.ts +1 -3
- package/src/lib/editor/Editor.ts +16 -16
- package/src/lib/editor/managers/SnapManager/BoundsSnaps.ts +4 -4
- package/src/lib/editor/managers/TextManager.ts +0 -1
- package/src/lib/editor/types/emit-types.ts +0 -1
- package/src/lib/editor/types/external-content.ts +50 -90
- package/src/lib/exports/StyleEmbedder.ts +1 -1
- package/src/version.ts +3 -3
package/src/index.ts
CHANGED
|
@@ -240,21 +240,9 @@ export {
|
|
|
240
240
|
type UiEventType,
|
|
241
241
|
} from './lib/editor/types/event-types'
|
|
242
242
|
export {
|
|
243
|
-
type
|
|
244
|
-
type TLEmbedExternalContent,
|
|
245
|
-
type TLErrorExternalContentSource,
|
|
246
|
-
type TLExcalidrawExternalContentSource,
|
|
247
|
-
type TLExternalAsset,
|
|
243
|
+
type TLExternalAssetContent,
|
|
248
244
|
type TLExternalContent,
|
|
249
245
|
type TLExternalContentSource,
|
|
250
|
-
type TLFileExternalAsset,
|
|
251
|
-
type TLFilesExternalContent,
|
|
252
|
-
type TLSvgTextExternalContent,
|
|
253
|
-
type TLTextExternalContent,
|
|
254
|
-
type TLTextExternalContentSource,
|
|
255
|
-
type TLTldrawExternalContentSource,
|
|
256
|
-
type TLUrlExternalAsset,
|
|
257
|
-
type TLUrlExternalContent,
|
|
258
246
|
} from './lib/editor/types/external-content'
|
|
259
247
|
export {
|
|
260
248
|
type TLHistoryBatchOptions,
|
|
@@ -50,9 +50,7 @@ function iOS() {
|
|
|
50
50
|
* @public
|
|
51
51
|
*/
|
|
52
52
|
export const TAB_ID: string = window
|
|
53
|
-
?
|
|
54
|
-
getFromSessionStorage(tabIdKey) ??
|
|
55
|
-
`TLDRAW_INSTANCE_STATE_V1_` + uniqueId())
|
|
53
|
+
? window[tabIdKey] ?? getFromSessionStorage(tabIdKey) ?? `TLDRAW_INSTANCE_STATE_V1_` + uniqueId()
|
|
56
54
|
: '<error>'
|
|
57
55
|
if (window) {
|
|
58
56
|
window[tabIdKey] = TAB_ID
|
package/src/lib/editor/Editor.ts
CHANGED
|
@@ -155,7 +155,7 @@ import {
|
|
|
155
155
|
TLPointerEventInfo,
|
|
156
156
|
TLWheelEventInfo,
|
|
157
157
|
} from './types/event-types'
|
|
158
|
-
import {
|
|
158
|
+
import { TLExternalAssetContent, TLExternalContent } from './types/external-content'
|
|
159
159
|
import { TLHistoryBatchOptions } from './types/history-types'
|
|
160
160
|
import {
|
|
161
161
|
OptionalKeys,
|
|
@@ -1681,7 +1681,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
1681
1681
|
* @public
|
|
1682
1682
|
*/
|
|
1683
1683
|
isAncestorSelected(shape: TLShape | TLShapeId): boolean {
|
|
1684
|
-
const id = typeof shape === 'string' ? shape :
|
|
1684
|
+
const id = typeof shape === 'string' ? shape : shape?.id ?? null
|
|
1685
1685
|
const _shape = this.getShape(id)
|
|
1686
1686
|
if (!_shape) return false
|
|
1687
1687
|
const selectedShapeIds = this.getSelectedShapeIds()
|
|
@@ -1938,7 +1938,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
1938
1938
|
* @public
|
|
1939
1939
|
*/
|
|
1940
1940
|
setFocusedGroup(shape: TLShapeId | TLGroupShape | null): this {
|
|
1941
|
-
const id = typeof shape === 'string' ? shape :
|
|
1941
|
+
const id = typeof shape === 'string' ? shape : shape?.id ?? null
|
|
1942
1942
|
|
|
1943
1943
|
if (id !== null) {
|
|
1944
1944
|
const shape = this.getShape(id)
|
|
@@ -2021,7 +2021,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
2021
2021
|
* @public
|
|
2022
2022
|
*/
|
|
2023
2023
|
setEditingShape(shape: TLShapeId | TLShape | null): this {
|
|
2024
|
-
const id = typeof shape === 'string' ? shape :
|
|
2024
|
+
const id = typeof shape === 'string' ? shape : shape?.id ?? null
|
|
2025
2025
|
if (id !== this.getEditingShapeId()) {
|
|
2026
2026
|
if (id) {
|
|
2027
2027
|
const shape = this.getShape(id)
|
|
@@ -2082,7 +2082,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
2082
2082
|
* @public
|
|
2083
2083
|
*/
|
|
2084
2084
|
setHoveredShape(shape: TLShapeId | TLShape | null): this {
|
|
2085
|
-
const id = typeof shape === 'string' ? shape :
|
|
2085
|
+
const id = typeof shape === 'string' ? shape : shape?.id ?? null
|
|
2086
2086
|
if (id === this.getHoveredShapeId()) return this
|
|
2087
2087
|
this.run(
|
|
2088
2088
|
() => {
|
|
@@ -2231,7 +2231,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
2231
2231
|
* @public
|
|
2232
2232
|
*/
|
|
2233
2233
|
setCroppingShape(shape: TLShapeId | TLShape | null): this {
|
|
2234
|
-
const id = typeof shape === 'string' ? shape :
|
|
2234
|
+
const id = typeof shape === 'string' ? shape : shape?.id ?? null
|
|
2235
2235
|
if (id !== this.getCroppingShapeId()) {
|
|
2236
2236
|
this.run(
|
|
2237
2237
|
() => {
|
|
@@ -7975,8 +7975,10 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
7975
7975
|
|
|
7976
7976
|
/** @internal */
|
|
7977
7977
|
externalAssetContentHandlers: {
|
|
7978
|
-
[K in
|
|
7979
|
-
[Key in K]:
|
|
7978
|
+
[K in TLExternalAssetContent['type']]: {
|
|
7979
|
+
[Key in K]:
|
|
7980
|
+
| null
|
|
7981
|
+
| ((info: TLExternalAssetContent & { type: Key }) => Promise<TLAsset | undefined>)
|
|
7980
7982
|
}[K]
|
|
7981
7983
|
} = {
|
|
7982
7984
|
file: null,
|
|
@@ -8005,9 +8007,9 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
8005
8007
|
*
|
|
8006
8008
|
* @public
|
|
8007
8009
|
*/
|
|
8008
|
-
registerExternalAssetHandler<T extends
|
|
8010
|
+
registerExternalAssetHandler<T extends TLExternalAssetContent['type']>(
|
|
8009
8011
|
type: T,
|
|
8010
|
-
handler: null | ((info:
|
|
8012
|
+
handler: null | ((info: TLExternalAssetContent & { type: T }) => Promise<TLAsset>)
|
|
8011
8013
|
): this {
|
|
8012
8014
|
this.externalAssetContentHandlers[type] = handler as any
|
|
8013
8015
|
return this
|
|
@@ -8075,11 +8077,11 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
8075
8077
|
* @param info - Info about the external content.
|
|
8076
8078
|
* @returns The asset.
|
|
8077
8079
|
*/
|
|
8078
|
-
async getAssetForExternalContent(info:
|
|
8080
|
+
async getAssetForExternalContent(info: TLExternalAssetContent): Promise<TLAsset | undefined> {
|
|
8079
8081
|
return await this.externalAssetContentHandlers[info.type]?.(info as any)
|
|
8080
8082
|
}
|
|
8081
8083
|
|
|
8082
|
-
hasExternalAssetHandler(type:
|
|
8084
|
+
hasExternalAssetHandler(type: TLExternalAssetContent['type']): boolean {
|
|
8083
8085
|
return !!this.externalAssetContentHandlers[type]
|
|
8084
8086
|
}
|
|
8085
8087
|
|
|
@@ -8801,8 +8803,8 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
8801
8803
|
// If our pointer moved only because we're following some other user, then don't
|
|
8802
8804
|
// update our last activity timestamp; otherwise, update it to the current timestamp.
|
|
8803
8805
|
info.type === 'pointer' && info.pointerId === INTERNAL_POINTER_IDS.CAMERA_MOVE
|
|
8804
|
-
?
|
|
8805
|
-
this._tickManager.now
|
|
8806
|
+
? this.store.unsafeGetWithoutCapture(TLPOINTER_ID)?.lastActivityTimestamp ??
|
|
8807
|
+
this._tickManager.now
|
|
8806
8808
|
: this._tickManager.now,
|
|
8807
8809
|
meta: {},
|
|
8808
8810
|
},
|
|
@@ -9367,8 +9369,6 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
9367
9369
|
// todo: replace with new readonly mode?
|
|
9368
9370
|
if (this.getCrashingError()) return this
|
|
9369
9371
|
|
|
9370
|
-
this.emit('before-event', info)
|
|
9371
|
-
|
|
9372
9372
|
const { inputs } = this
|
|
9373
9373
|
const { type } = info
|
|
9374
9374
|
|
|
@@ -390,8 +390,8 @@ export class BoundsSnaps {
|
|
|
390
390
|
|
|
391
391
|
// at the same time, calculate how far we need to nudge the shape to 'snap' to the target point(s)
|
|
392
392
|
const nudge = new Vec(
|
|
393
|
-
lockedAxis === 'x' ? 0 :
|
|
394
|
-
lockedAxis === 'y' ? 0 :
|
|
393
|
+
lockedAxis === 'x' ? 0 : nearestSnapsX[0]?.nudge ?? 0,
|
|
394
|
+
lockedAxis === 'y' ? 0 : nearestSnapsY[0]?.nudge ?? 0
|
|
395
395
|
)
|
|
396
396
|
|
|
397
397
|
// ok we've figured out how much the box should be nudged, now let's find all the snap points
|
|
@@ -504,8 +504,8 @@ export class BoundsSnaps {
|
|
|
504
504
|
|
|
505
505
|
// at the same time, calculate how far we need to nudge the shape to 'snap' to the target point(s)
|
|
506
506
|
const nudge = new Vec(
|
|
507
|
-
isXLocked ? 0 :
|
|
508
|
-
isYLocked ? 0 :
|
|
507
|
+
isXLocked ? 0 : nearestSnapsX[0]?.nudge ?? 0,
|
|
508
|
+
isYLocked ? 0 : nearestSnapsY[0]?.nudge ?? 0
|
|
509
509
|
)
|
|
510
510
|
|
|
511
511
|
if (isAspectRatioLocked && isSelectionCorner(handle) && nudge.len() !== 0) {
|
|
@@ -230,7 +230,6 @@ export class TextManager {
|
|
|
230
230
|
elm.style.setProperty('font-weight', opts.fontWeight)
|
|
231
231
|
elm.style.setProperty('line-height', `${opts.lineHeight * opts.fontSize}px`)
|
|
232
232
|
elm.style.setProperty('text-align', textAlignmentsForLtr[opts.textAlign])
|
|
233
|
-
elm.style.setProperty('font-style', opts.fontStyle)
|
|
234
233
|
|
|
235
234
|
const shouldTruncateToFirstLine =
|
|
236
235
|
opts.overflow === 'truncate-ellipsis' || opts.overflow === 'truncate-clip'
|
|
@@ -2,97 +2,57 @@ import { TLAssetId } from '@tldraw/tlschema'
|
|
|
2
2
|
import { VecLike } from '../../primitives/Vec'
|
|
3
3
|
import { TLContent } from './clipboard-types'
|
|
4
4
|
|
|
5
|
-
/** @public */
|
|
6
|
-
export interface TLTldrawExternalContentSource {
|
|
7
|
-
type: 'tldraw'
|
|
8
|
-
data: TLContent
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/** @public */
|
|
12
|
-
export interface TLExcalidrawExternalContentSource {
|
|
13
|
-
type: 'excalidraw'
|
|
14
|
-
data: any
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** @public */
|
|
18
|
-
export interface TLTextExternalContentSource {
|
|
19
|
-
type: 'text'
|
|
20
|
-
data: string
|
|
21
|
-
subtype: 'json' | 'html' | 'text' | 'url'
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** @public */
|
|
25
|
-
export interface TLErrorExternalContentSource {
|
|
26
|
-
type: 'error'
|
|
27
|
-
data: string | null
|
|
28
|
-
reason: string
|
|
29
|
-
}
|
|
30
|
-
|
|
31
5
|
/** @public */
|
|
32
6
|
export type TLExternalContentSource =
|
|
33
|
-
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
7
|
+
| {
|
|
8
|
+
type: 'tldraw'
|
|
9
|
+
data: TLContent
|
|
10
|
+
}
|
|
11
|
+
| {
|
|
12
|
+
type: 'excalidraw'
|
|
13
|
+
data: any
|
|
14
|
+
}
|
|
15
|
+
| {
|
|
16
|
+
type: 'text'
|
|
17
|
+
data: string
|
|
18
|
+
subtype: 'json' | 'html' | 'text' | 'url'
|
|
19
|
+
}
|
|
20
|
+
| {
|
|
21
|
+
type: 'error'
|
|
22
|
+
data: string | null
|
|
23
|
+
reason: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** @public */
|
|
27
|
+
export type TLExternalContent<EmbedDefinition> = {
|
|
40
28
|
sources?: TLExternalContentSource[]
|
|
41
29
|
point?: VecLike
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
type: 'embed'
|
|
72
|
-
url: string
|
|
73
|
-
embed: EmbedDefinition
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** @public */
|
|
77
|
-
export type TLExternalContent<EmbedDefinition> =
|
|
78
|
-
| TLTextExternalContent
|
|
79
|
-
| TLFilesExternalContent
|
|
80
|
-
| TLUrlExternalContent
|
|
81
|
-
| TLSvgTextExternalContent
|
|
82
|
-
| TLEmbedExternalContent<EmbedDefinition>
|
|
83
|
-
|
|
84
|
-
/** @public */
|
|
85
|
-
export interface TLFileExternalAsset {
|
|
86
|
-
type: 'file'
|
|
87
|
-
file: File
|
|
88
|
-
assetId?: TLAssetId
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** @public */
|
|
92
|
-
export interface TLUrlExternalAsset {
|
|
93
|
-
type: 'url'
|
|
94
|
-
url: string
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** @public */
|
|
98
|
-
export type TLExternalAsset = TLFileExternalAsset | TLUrlExternalAsset
|
|
30
|
+
} & (
|
|
31
|
+
| {
|
|
32
|
+
type: 'text'
|
|
33
|
+
text: string
|
|
34
|
+
}
|
|
35
|
+
| {
|
|
36
|
+
type: 'files'
|
|
37
|
+
files: File[]
|
|
38
|
+
ignoreParent: boolean
|
|
39
|
+
}
|
|
40
|
+
| {
|
|
41
|
+
type: 'url'
|
|
42
|
+
url: string
|
|
43
|
+
}
|
|
44
|
+
| {
|
|
45
|
+
type: 'svg-text'
|
|
46
|
+
text: string
|
|
47
|
+
}
|
|
48
|
+
| {
|
|
49
|
+
type: 'embed'
|
|
50
|
+
url: string
|
|
51
|
+
embed: EmbedDefinition
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
/** @public */
|
|
56
|
+
export type TLExternalAssetContent =
|
|
57
|
+
| { type: 'file'; file: File; assetId?: TLAssetId }
|
|
58
|
+
| { type: 'url'; url: string }
|
|
@@ -54,7 +54,7 @@ export class StyleEmbedder {
|
|
|
54
54
|
: NO_STYLES
|
|
55
55
|
|
|
56
56
|
const parentStyles = shouldSkipInheritedParentStyles
|
|
57
|
-
?
|
|
57
|
+
? this.styles.get(element.parentElement as Element)?.self ?? NO_STYLES
|
|
58
58
|
: NO_STYLES
|
|
59
59
|
|
|
60
60
|
const info: ElementStyleInfo = {
|
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.8.0-canary.
|
|
4
|
+
export const version = '3.8.0-canary.ff19d0d907b9'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2024-09-13T14:36:29.063Z',
|
|
7
|
-
minor: '2025-01-
|
|
8
|
-
patch: '2025-01-
|
|
7
|
+
minor: '2025-01-29T10:42:55.894Z',
|
|
8
|
+
patch: '2025-01-29T10:42:55.894Z',
|
|
9
9
|
}
|