@tldraw/editor 3.14.0-canary.7c3d5520bd87 → 3.14.0-canary.813644a5fc45
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 +32 -3
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +30 -1
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +4 -3
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +1 -1
- package/dist-cjs/lib/editor/tools/StateNode.js +3 -3
- package/dist-cjs/lib/editor/tools/StateNode.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/hooks/useCanvasEvents.js +1 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.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 +32 -3
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +30 -1
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +4 -3
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/editor/tools/StateNode.mjs +3 -3
- package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs +1 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +17 -1
- package/package.json +7 -7
- package/src/index.ts +1 -0
- package/src/lib/editor/Editor.ts +32 -1
- package/src/lib/editor/managers/TextManager/TextManager.test.ts +1 -5
- package/src/lib/editor/managers/TextManager/TextManager.ts +7 -3
- package/src/lib/editor/shapes/ShapeUtil.ts +1 -0
- package/src/lib/editor/tools/StateNode.ts +3 -3
- package/src/lib/editor/types/emit-types.ts +4 -0
- package/src/lib/editor/types/external-content.ts +11 -2
- package/src/lib/hooks/useCanvasEvents.ts +0 -1
- package/src/version.ts +3 -3
|
@@ -26,6 +26,7 @@ export interface TLMeasureTextOpts {
|
|
|
26
26
|
fontWeight: string
|
|
27
27
|
fontFamily: string
|
|
28
28
|
fontSize: number
|
|
29
|
+
/** This must be a number, e.g. 1.35, not a pixel value. */
|
|
29
30
|
lineHeight: number
|
|
30
31
|
/**
|
|
31
32
|
* When maxWidth is a number, the text will be wrapped to that maxWidth. When maxWidth
|
|
@@ -38,6 +39,7 @@ export interface TLMeasureTextOpts {
|
|
|
38
39
|
padding: string
|
|
39
40
|
otherStyles?: Record<string, string>
|
|
40
41
|
disableOverflowWrapBreaking?: boolean
|
|
42
|
+
measureScrollWidth?: boolean
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
/** @public */
|
|
@@ -53,6 +55,7 @@ export interface TLMeasureTextSpanOpts {
|
|
|
53
55
|
lineHeight: number
|
|
54
56
|
textAlign: TLDefaultHorizontalAlignStyle
|
|
55
57
|
otherStyles?: Record<string, string>
|
|
58
|
+
measureScrollWidth?: boolean
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
const spaceCharacterRegex = /\s/
|
|
@@ -73,6 +76,7 @@ export class TextManager {
|
|
|
73
76
|
// we need to save the default styles so that we can restore them when we're done
|
|
74
77
|
// these must be the css names, not the js names for the styles
|
|
75
78
|
this.defaultStyles = {
|
|
79
|
+
'overflow-wrap': 'break-word',
|
|
76
80
|
'word-break': 'auto',
|
|
77
81
|
width: null,
|
|
78
82
|
height: null,
|
|
@@ -121,7 +125,7 @@ export class TextManager {
|
|
|
121
125
|
elm.style.setProperty('font-style', opts.fontStyle)
|
|
122
126
|
elm.style.setProperty('font-weight', opts.fontWeight)
|
|
123
127
|
elm.style.setProperty('font-size', opts.fontSize + 'px')
|
|
124
|
-
elm.style.setProperty('line-height', opts.lineHeight
|
|
128
|
+
elm.style.setProperty('line-height', opts.lineHeight.toString())
|
|
125
129
|
elm.style.setProperty('padding', opts.padding)
|
|
126
130
|
|
|
127
131
|
if (opts.maxWidth) {
|
|
@@ -142,7 +146,7 @@ export class TextManager {
|
|
|
142
146
|
}
|
|
143
147
|
}
|
|
144
148
|
|
|
145
|
-
const scrollWidth = elm.scrollWidth
|
|
149
|
+
const scrollWidth = opts.measureScrollWidth ? elm.scrollWidth : 0
|
|
146
150
|
const rect = elm.getBoundingClientRect()
|
|
147
151
|
|
|
148
152
|
return {
|
|
@@ -285,7 +289,7 @@ export class TextManager {
|
|
|
285
289
|
elm.style.setProperty('font-style', opts.fontStyle)
|
|
286
290
|
elm.style.setProperty('font-weight', opts.fontWeight)
|
|
287
291
|
elm.style.setProperty('font-size', opts.fontSize + 'px')
|
|
288
|
-
elm.style.setProperty('line-height', opts.lineHeight
|
|
292
|
+
elm.style.setProperty('line-height', opts.lineHeight.toString())
|
|
289
293
|
|
|
290
294
|
const elementWidth = Math.ceil(opts.width - opts.padding * 2)
|
|
291
295
|
elm.style.setProperty('width', `${elementWidth}px`)
|
|
@@ -206,15 +206,15 @@ export abstract class StateNode implements Partial<TLEventHandlers> {
|
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
// todo: move this logic into transition
|
|
209
|
-
exit(info: any,
|
|
209
|
+
exit(info: any, to: string) {
|
|
210
210
|
if (debugFlags.measurePerformance.get() && this.performanceTracker.isStarted()) {
|
|
211
211
|
this.performanceTracker.stop()
|
|
212
212
|
}
|
|
213
213
|
this._isActive.set(false)
|
|
214
|
-
this.onExit?.(info,
|
|
214
|
+
this.onExit?.(info, to)
|
|
215
215
|
|
|
216
216
|
if (!this.getIsActive()) {
|
|
217
|
-
this.getCurrent()?.exit(info,
|
|
217
|
+
this.getCurrent()?.exit(info, to)
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
|
|
@@ -18,6 +18,10 @@ export interface TLEventMap {
|
|
|
18
18
|
frame: [number]
|
|
19
19
|
'select-all-text': [{ shapeId: TLShapeId }]
|
|
20
20
|
'place-caret': [{ shapeId: TLShapeId; point: { x: number; y: number } }]
|
|
21
|
+
'created-shapes': [TLRecord[]]
|
|
22
|
+
'edited-shapes': [TLRecord[]]
|
|
23
|
+
'deleted-shapes': [TLShapeId[]]
|
|
24
|
+
edit: []
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
/** @public */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TLAssetId } from '@tldraw/tlschema'
|
|
1
|
+
import { TLAssetId, TLShapeId } from '@tldraw/tlschema'
|
|
2
2
|
import { VecLike } from '../../primitives/Vec'
|
|
3
3
|
import { TLContent } from './clipboard-types'
|
|
4
4
|
|
|
@@ -52,7 +52,15 @@ export interface TLTextExternalContent extends TLBaseExternalContent {
|
|
|
52
52
|
export interface TLFilesExternalContent extends TLBaseExternalContent {
|
|
53
53
|
type: 'files'
|
|
54
54
|
files: File[]
|
|
55
|
-
ignoreParent
|
|
55
|
+
ignoreParent?: boolean
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** @public */
|
|
59
|
+
export interface TLFileReplaceExternalContent extends TLBaseExternalContent {
|
|
60
|
+
type: 'file-replace'
|
|
61
|
+
file: File
|
|
62
|
+
shapeId: TLShapeId
|
|
63
|
+
isImage: boolean
|
|
56
64
|
}
|
|
57
65
|
|
|
58
66
|
/** @public */
|
|
@@ -90,6 +98,7 @@ export interface TLExcalidrawExternalContent extends TLBaseExternalContent {
|
|
|
90
98
|
export type TLExternalContent<EmbedDefinition> =
|
|
91
99
|
| TLTextExternalContent
|
|
92
100
|
| TLFilesExternalContent
|
|
101
|
+
| TLFileReplaceExternalContent
|
|
93
102
|
| TLUrlExternalContent
|
|
94
103
|
| TLSvgTextExternalContent
|
|
95
104
|
| TLEmbedExternalContent<EmbedDefinition>
|
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.14.0-canary.
|
|
4
|
+
export const version = '3.14.0-canary.813644a5fc45'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2024-09-13T14:36:29.063Z',
|
|
7
|
-
minor: '2025-06-
|
|
8
|
-
patch: '2025-06-
|
|
7
|
+
minor: '2025-06-24T10:21:59.286Z',
|
|
8
|
+
patch: '2025-06-24T10:21:59.286Z',
|
|
9
9
|
}
|