@tldraw/editor 4.6.0-internal.c7df3c92455a → 4.6.0-next.0eb36d65eec3
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 +124 -6
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawEditor.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js.map +2 -2
- package/dist-cjs/lib/config/createTLStore.js +1 -1
- package/dist-cjs/lib/config/createTLStore.js.map +2 -2
- package/dist-cjs/lib/config/createTLUser.js.map +1 -1
- package/dist-cjs/lib/config/defaultShapes.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +463 -354
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js +25 -64
- package/dist-cjs/lib/editor/managers/ClickManager/ClickManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js +1 -1
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js +14 -53
- package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js.map +1 -1
- package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js +71 -112
- package/dist-cjs/lib/editor/managers/InputsManager/InputsManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js +21 -56
- package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js +11 -52
- package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js +19 -56
- package/dist-cjs/lib/editor/managers/SnapManager/SnapManager.js.map +1 -1
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js +4 -4
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +102 -30
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/TickManager/TickManager.js +16 -55
- package/dist-cjs/lib/editor/managers/TickManager/TickManager.js.map +1 -1
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +57 -68
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +1 -1
- package/dist-cjs/lib/exports/ExportDelay.js +12 -53
- package/dist-cjs/lib/exports/ExportDelay.js.map +1 -1
- package/dist-cjs/lib/exports/FontEmbedder.js +14 -57
- package/dist-cjs/lib/exports/FontEmbedder.js.map +1 -1
- package/dist-cjs/lib/exports/StyleEmbedder.js +1 -1
- package/dist-cjs/lib/exports/StyleEmbedder.js.map +2 -2
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/hooks/useEditorComponents.js.map +2 -2
- package/dist-cjs/lib/hooks/useLocalStore.js.map +2 -2
- package/dist-cjs/lib/options.js +3 -0
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/primitives/Box.js +26 -26
- package/dist-cjs/lib/primitives/Box.js.map +2 -2
- package/dist-cjs/lib/primitives/Vec.js +1 -1
- package/dist-cjs/lib/primitives/Vec.js.map +1 -1
- package/dist-cjs/lib/primitives/geometry/Arc2d.js +2 -2
- package/dist-cjs/lib/primitives/geometry/Arc2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Circle2d.js +2 -2
- package/dist-cjs/lib/primitives/geometry/Circle2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/CubicSpline2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/CubicSpline2d.js.map +1 -1
- package/dist-cjs/lib/primitives/geometry/Ellipse2d.js +3 -3
- package/dist-cjs/lib/primitives/geometry/Ellipse2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js +10 -9
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Polyline2d.js +2 -2
- package/dist-cjs/lib/primitives/geometry/Polyline2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Stadium2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/Stadium2d.js.map +2 -2
- package/dist-cjs/lib/utils/SharedStylesMap.js +1 -1
- package/dist-cjs/lib/utils/SharedStylesMap.js.map +1 -1
- package/dist-cjs/lib/utils/getSvgPathFromPoints.js.map +2 -2
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +3 -2
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.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 +124 -6
- package/dist-esm/index.mjs +4 -2
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs.map +2 -2
- package/dist-esm/lib/config/createTLStore.mjs +1 -1
- package/dist-esm/lib/config/createTLStore.mjs.map +2 -2
- package/dist-esm/lib/config/createTLUser.mjs.map +1 -1
- package/dist-esm/lib/config/defaultShapes.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +465 -357
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs +25 -64
- package/dist-esm/lib/editor/managers/ClickManager/ClickManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs +1 -1
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs +14 -53
- package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs +71 -112
- package/dist-esm/lib/editor/managers/InputsManager/InputsManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs +21 -56
- package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs +11 -52
- package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs +19 -56
- package/dist-esm/lib/editor/managers/SnapManager/SnapManager.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs +4 -4
- package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +102 -30
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs +16 -55
- package/dist-esm/lib/editor/managers/TickManager/TickManager.mjs.map +1 -1
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +57 -68
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +1 -1
- package/dist-esm/lib/exports/ExportDelay.mjs +12 -53
- package/dist-esm/lib/exports/ExportDelay.mjs.map +1 -1
- package/dist-esm/lib/exports/FontEmbedder.mjs +14 -57
- package/dist-esm/lib/exports/FontEmbedder.mjs.map +1 -1
- package/dist-esm/lib/exports/StyleEmbedder.mjs +1 -1
- package/dist-esm/lib/exports/StyleEmbedder.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useLocalStore.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +3 -0
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/primitives/Box.mjs +26 -26
- package/dist-esm/lib/primitives/Box.mjs.map +2 -2
- package/dist-esm/lib/primitives/Vec.mjs +1 -1
- package/dist-esm/lib/primitives/Vec.mjs.map +1 -1
- package/dist-esm/lib/primitives/geometry/Arc2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Arc2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Circle2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Circle2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs +1 -1
- package/dist-esm/lib/primitives/geometry/CubicSpline2d.mjs.map +1 -1
- package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs +3 -3
- package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +10 -9
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Polyline2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Polyline2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Stadium2d.mjs +1 -1
- package/dist-esm/lib/primitives/geometry/Stadium2d.mjs.map +2 -2
- package/dist-esm/lib/utils/SharedStylesMap.mjs +1 -1
- package/dist-esm/lib/utils/SharedStylesMap.mjs.map +1 -1
- package/dist-esm/lib/utils/getSvgPathFromPoints.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +3 -2
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/package.json +8 -8
- package/src/index.ts +15 -7
- package/src/lib/TldrawEditor.tsx +1 -1
- package/src/lib/components/default-components/DefaultCanvas.tsx +1 -1
- package/src/lib/components/default-components/DefaultCollaboratorHint.tsx +1 -1
- package/src/lib/components/default-components/DefaultErrorFallback.tsx +1 -0
- package/src/lib/config/TLEditorSnapshot.test.ts +1 -1
- package/src/lib/config/createTLStore.ts +1 -1
- package/src/lib/config/createTLUser.ts +3 -3
- package/src/lib/config/defaultShapes.ts +1 -1
- package/src/lib/editor/Editor.ts +9 -8
- package/src/lib/editor/managers/ClickManager/ClickManager.ts +1 -1
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.ts +1 -1
- package/src/lib/editor/managers/InputsManager/InputsManager.ts +30 -30
- package/src/lib/editor/managers/SnapManager/BoundsSnaps.ts +1 -1
- package/src/lib/editor/managers/SnapManager/HandleSnaps.ts +1 -1
- package/src/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.ts +5 -5
- package/src/lib/editor/managers/TextManager/TextManager.test.ts +18 -4
- package/src/lib/editor/managers/TextManager/TextManager.ts +140 -34
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +1 -1
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +1 -1
- package/src/lib/editor/shapes/ShapeUtil.ts +2 -2
- package/src/lib/exports/StyleEmbedder.ts +1 -1
- package/src/lib/exports/getSvgJsx.tsx +1 -1
- package/src/lib/hooks/useEditorComponents.tsx +1 -1
- package/src/lib/hooks/useLocalStore.ts +1 -1
- package/src/lib/options.ts +108 -0
- package/src/lib/primitives/Box.ts +26 -26
- package/src/lib/primitives/Vec.ts +1 -1
- package/src/lib/primitives/geometry/Arc2d.ts +2 -2
- package/src/lib/primitives/geometry/Circle2d.ts +2 -2
- package/src/lib/primitives/geometry/CubicSpline2d.ts +1 -1
- package/src/lib/primitives/geometry/Ellipse2d.ts +3 -3
- package/src/lib/primitives/geometry/Geometry2d.ts +10 -9
- package/src/lib/primitives/geometry/Polyline2d.ts +2 -2
- package/src/lib/primitives/geometry/Stadium2d.ts +1 -1
- package/src/lib/utils/SharedStylesMap.ts +1 -1
- package/src/lib/utils/getSvgPathFromPoints.ts +1 -1
- package/src/lib/utils/sync/TLLocalSyncClient.test.ts +1 -1
- package/src/lib/utils/sync/TLLocalSyncClient.ts +2 -1
- package/src/version.ts +3 -3
|
@@ -12,9 +12,9 @@ import {
|
|
|
12
12
|
} from '@tldraw/tlschema'
|
|
13
13
|
import { FileHelpers, assert } from '@tldraw/utils'
|
|
14
14
|
import { Editor } from '../editor/Editor'
|
|
15
|
-
import { TLEditorSnapshot, loadSnapshot } from './TLEditorSnapshot'
|
|
16
15
|
import { TLAnyBindingUtilConstructor, checkBindings } from './defaultBindings'
|
|
17
16
|
import { TLAnyShapeUtilConstructor, checkShapesAndAddCore } from './defaultShapes'
|
|
17
|
+
import { TLEditorSnapshot, loadSnapshot } from './TLEditorSnapshot'
|
|
18
18
|
|
|
19
19
|
/** @public */
|
|
20
20
|
export interface TLStoreBaseOptions {
|
|
@@ -7,7 +7,7 @@ import { TLUserPreferences, getUserPreferences, setUserPreferences } from './TLU
|
|
|
7
7
|
/** @public */
|
|
8
8
|
export interface TLUser {
|
|
9
9
|
readonly userPreferences: Signal<TLUserPreferences>
|
|
10
|
-
// eslint-disable-next-line
|
|
10
|
+
// eslint-disable-next-line tldraw/method-signature-style
|
|
11
11
|
readonly setUserPreferences: (userPreferences: TLUserPreferences) => void
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -19,7 +19,7 @@ const defaultLocalStorageUserPrefs = computed('defaultLocalStorageUserPrefs', ()
|
|
|
19
19
|
export function createTLUser(
|
|
20
20
|
opts = {} as {
|
|
21
21
|
userPreferences?: Signal<TLUserPreferences>
|
|
22
|
-
// eslint-disable-next-line
|
|
22
|
+
// eslint-disable-next-line tldraw/method-signature-style
|
|
23
23
|
setUserPreferences?: (userPreferences: TLUserPreferences) => void
|
|
24
24
|
}
|
|
25
25
|
): TLUser {
|
|
@@ -34,7 +34,7 @@ export function createTLUser(
|
|
|
34
34
|
*/
|
|
35
35
|
export function useTldrawUser(opts: {
|
|
36
36
|
userPreferences?: Signal<TLUserPreferences> | TLUserPreferences
|
|
37
|
-
// eslint-disable-next-line
|
|
37
|
+
// eslint-disable-next-line tldraw/method-signature-style
|
|
38
38
|
setUserPreferences?: (userPreferences: TLUserPreferences) => void
|
|
39
39
|
}): TLUser {
|
|
40
40
|
const prefs = useShallowObjectIdentity(opts.userPreferences ?? defaultLocalStorageUserPrefs)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TLShapeUtilConstructor } from '../editor/shapes/ShapeUtil'
|
|
2
1
|
import { GroupShapeUtil } from '../editor/shapes/group/GroupShapeUtil'
|
|
2
|
+
import { TLShapeUtilConstructor } from '../editor/shapes/ShapeUtil'
|
|
3
3
|
|
|
4
4
|
/** @public */
|
|
5
5
|
export type TLAnyShapeUtilConstructor = TLShapeUtilConstructor<any>
|
package/src/lib/editor/Editor.ts
CHANGED
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
ComputedCache,
|
|
12
12
|
RecordType,
|
|
13
|
-
StoreSideEffects,
|
|
14
|
-
StoreSnapshot,
|
|
15
13
|
UnknownRecord,
|
|
16
14
|
reverseRecordsDiff,
|
|
15
|
+
StoreSnapshot,
|
|
16
|
+
StoreSideEffects,
|
|
17
17
|
} from '@tldraw/store'
|
|
18
18
|
import {
|
|
19
19
|
CameraRecordType,
|
|
@@ -90,15 +90,15 @@ import {
|
|
|
90
90
|
uniqueId,
|
|
91
91
|
} from '@tldraw/utils'
|
|
92
92
|
import EventEmitter from 'eventemitter3'
|
|
93
|
+
import { TLUser, createTLUser } from '../config/createTLUser'
|
|
94
|
+
import { TLAnyBindingUtilConstructor, checkBindings } from '../config/defaultBindings'
|
|
95
|
+
import { TLAnyShapeUtilConstructor, checkShapesAndAddCore } from '../config/defaultShapes'
|
|
93
96
|
import {
|
|
94
97
|
TLEditorSnapshot,
|
|
95
98
|
TLLoadSnapshotOptions,
|
|
96
99
|
getSnapshot,
|
|
97
100
|
loadSnapshot,
|
|
98
101
|
} from '../config/TLEditorSnapshot'
|
|
99
|
-
import { TLUser, createTLUser } from '../config/createTLUser'
|
|
100
|
-
import { TLAnyBindingUtilConstructor, checkBindings } from '../config/defaultBindings'
|
|
101
|
-
import { TLAnyShapeUtilConstructor, checkShapesAndAddCore } from '../config/defaultShapes'
|
|
102
102
|
import {
|
|
103
103
|
DEFAULT_ANIMATION_OPTIONS,
|
|
104
104
|
DEFAULT_CAMERA_OPTIONS,
|
|
@@ -115,14 +115,13 @@ import { tlmenus } from '../globals/menus'
|
|
|
115
115
|
import { tltime } from '../globals/time'
|
|
116
116
|
import { TldrawOptions, defaultTldrawOptions } from '../options'
|
|
117
117
|
import { Box, BoxLike } from '../primitives/Box'
|
|
118
|
-
import { Mat, MatLike } from '../primitives/Mat'
|
|
119
|
-
import { Vec, VecLike } from '../primitives/Vec'
|
|
120
118
|
import { EASINGS } from '../primitives/easings'
|
|
121
119
|
import { Geometry2d } from '../primitives/geometry/Geometry2d'
|
|
122
120
|
import { Group2d } from '../primitives/geometry/Group2d'
|
|
123
121
|
import { intersectPolygonPolygon } from '../primitives/intersect'
|
|
122
|
+
import { Mat, MatLike } from '../primitives/Mat'
|
|
124
123
|
import { PI, approximately, areAnglesCompatible, clamp, pointInPolygon } from '../primitives/utils'
|
|
125
|
-
import {
|
|
124
|
+
import { Vec, VecLike } from '../primitives/Vec'
|
|
126
125
|
import { areShapesContentEqual } from '../utils/areShapesContentEqual'
|
|
127
126
|
import { dataUrlToFile } from '../utils/assets'
|
|
128
127
|
import { debugFlags } from '../utils/debug-flags'
|
|
@@ -137,6 +136,7 @@ import { getReorderingShapesChanges } from '../utils/reorderShapes'
|
|
|
137
136
|
import { getDroppedShapesToNewParents, kickoutOccludedShapes } from '../utils/reparenting'
|
|
138
137
|
import { TLTextOptions, TiptapEditor } from '../utils/richText'
|
|
139
138
|
import { applyRotationToSnapshotShapes, getRotationSnapshot } from '../utils/rotation'
|
|
139
|
+
import { ReadonlySharedStyleMap, SharedStyle, SharedStyleMap } from '../utils/SharedStylesMap'
|
|
140
140
|
import { BindingOnDeleteOptions, BindingUtil } from './bindings/BindingUtil'
|
|
141
141
|
import { bindingsIndex } from './derivations/bindingsIndex'
|
|
142
142
|
import { notVisibleShapes } from './derivations/notVisibleShapes'
|
|
@@ -9071,6 +9071,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
9071
9071
|
opts = {} as { force?: boolean }
|
|
9072
9072
|
): Promise<void> {
|
|
9073
9073
|
if (!opts.force && this.getIsReadonly()) return
|
|
9074
|
+
|
|
9074
9075
|
return this.externalContentHandlers[info.type]?.(info as any)
|
|
9075
9076
|
}
|
|
9076
9077
|
|
|
@@ -21,7 +21,7 @@ export class InputsManager {
|
|
|
21
21
|
/**
|
|
22
22
|
* @deprecated Use `getOriginPagePoint()` instead.
|
|
23
23
|
*/
|
|
24
|
-
// eslint-disable-next-line no-
|
|
24
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
25
25
|
get originPagePoint() {
|
|
26
26
|
return this.getOriginPagePoint()
|
|
27
27
|
}
|
|
@@ -36,7 +36,7 @@ export class InputsManager {
|
|
|
36
36
|
/**
|
|
37
37
|
* @deprecated Use `getOriginScreenPoint()` instead.
|
|
38
38
|
*/
|
|
39
|
-
// eslint-disable-next-line no-
|
|
39
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
40
40
|
get originScreenPoint() {
|
|
41
41
|
return this.getOriginScreenPoint()
|
|
42
42
|
}
|
|
@@ -51,7 +51,7 @@ export class InputsManager {
|
|
|
51
51
|
/**
|
|
52
52
|
* @deprecated Use `getPreviousPagePoint()` instead.
|
|
53
53
|
*/
|
|
54
|
-
// eslint-disable-next-line no-
|
|
54
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
55
55
|
get previousPagePoint() {
|
|
56
56
|
return this.getPreviousPagePoint()
|
|
57
57
|
}
|
|
@@ -66,7 +66,7 @@ export class InputsManager {
|
|
|
66
66
|
/**
|
|
67
67
|
* @deprecated Use `getPreviousScreenPoint()` instead.
|
|
68
68
|
*/
|
|
69
|
-
// eslint-disable-next-line no-
|
|
69
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
70
70
|
get previousScreenPoint() {
|
|
71
71
|
return this.getPreviousScreenPoint()
|
|
72
72
|
}
|
|
@@ -81,7 +81,7 @@ export class InputsManager {
|
|
|
81
81
|
/**
|
|
82
82
|
* @deprecated Use `getCurrentPagePoint()` instead.
|
|
83
83
|
*/
|
|
84
|
-
// eslint-disable-next-line no-
|
|
84
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
85
85
|
get currentPagePoint() {
|
|
86
86
|
return this.getCurrentPagePoint()
|
|
87
87
|
}
|
|
@@ -96,7 +96,7 @@ export class InputsManager {
|
|
|
96
96
|
/**
|
|
97
97
|
* @deprecated Use `getCurrentScreenPoint()` instead.
|
|
98
98
|
*/
|
|
99
|
-
// eslint-disable-next-line no-
|
|
99
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
100
100
|
get currentScreenPoint() {
|
|
101
101
|
return this.getCurrentScreenPoint()
|
|
102
102
|
}
|
|
@@ -111,7 +111,7 @@ export class InputsManager {
|
|
|
111
111
|
/**
|
|
112
112
|
* @deprecated Use `getPointerVelocity()` instead.
|
|
113
113
|
*/
|
|
114
|
-
// eslint-disable-next-line no-
|
|
114
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
115
115
|
get pointerVelocity() {
|
|
116
116
|
return this.getPointerVelocity()
|
|
117
117
|
}
|
|
@@ -147,11 +147,11 @@ export class InputsManager {
|
|
|
147
147
|
/**
|
|
148
148
|
* @deprecated Use `getIsPen()` instead.
|
|
149
149
|
*/
|
|
150
|
-
// eslint-disable-next-line no-
|
|
150
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
151
151
|
get isPen() {
|
|
152
152
|
return this.getIsPen()
|
|
153
153
|
}
|
|
154
|
-
// eslint-disable-next-line no-
|
|
154
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
155
155
|
set isPen(isPen: boolean) {
|
|
156
156
|
this.setIsPen(isPen)
|
|
157
157
|
}
|
|
@@ -172,11 +172,11 @@ export class InputsManager {
|
|
|
172
172
|
/**
|
|
173
173
|
* @deprecated Use `getShiftKey()` instead.
|
|
174
174
|
*/
|
|
175
|
-
// eslint-disable-next-line no-
|
|
175
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
176
176
|
get shiftKey() {
|
|
177
177
|
return this.getShiftKey()
|
|
178
178
|
}
|
|
179
|
-
// eslint-disable-next-line no-
|
|
179
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
180
180
|
set shiftKey(shiftKey: boolean) {
|
|
181
181
|
this.setShiftKey(shiftKey)
|
|
182
182
|
}
|
|
@@ -198,11 +198,11 @@ export class InputsManager {
|
|
|
198
198
|
/**
|
|
199
199
|
* @deprecated Use `getMetaKey()` instead.
|
|
200
200
|
*/
|
|
201
|
-
// eslint-disable-next-line no-
|
|
201
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
202
202
|
get metaKey() {
|
|
203
203
|
return this.getMetaKey()
|
|
204
204
|
}
|
|
205
|
-
// eslint-disable-next-line no-
|
|
205
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
206
206
|
set metaKey(metaKey: boolean) {
|
|
207
207
|
this.setMetaKey(metaKey)
|
|
208
208
|
}
|
|
@@ -224,11 +224,11 @@ export class InputsManager {
|
|
|
224
224
|
/**
|
|
225
225
|
* @deprecated Use `getCtrlKey()` instead.
|
|
226
226
|
*/
|
|
227
|
-
// eslint-disable-next-line no-
|
|
227
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
228
228
|
get ctrlKey() {
|
|
229
229
|
return this.getCtrlKey()
|
|
230
230
|
}
|
|
231
|
-
// eslint-disable-next-line no-
|
|
231
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
232
232
|
set ctrlKey(ctrlKey: boolean) {
|
|
233
233
|
this.setCtrlKey(ctrlKey)
|
|
234
234
|
}
|
|
@@ -250,11 +250,11 @@ export class InputsManager {
|
|
|
250
250
|
/**
|
|
251
251
|
* @deprecated Use `getAltKey()` instead.
|
|
252
252
|
*/
|
|
253
|
-
// eslint-disable-next-line no-
|
|
253
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
254
254
|
get altKey() {
|
|
255
255
|
return this.getAltKey()
|
|
256
256
|
}
|
|
257
|
-
// eslint-disable-next-line no-
|
|
257
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
258
258
|
set altKey(altKey: boolean) {
|
|
259
259
|
this.setAltKey(altKey)
|
|
260
260
|
}
|
|
@@ -275,7 +275,7 @@ export class InputsManager {
|
|
|
275
275
|
/**
|
|
276
276
|
* @deprecated Use `getAccelKey()` instead.
|
|
277
277
|
*/
|
|
278
|
-
// eslint-disable-next-line no-
|
|
278
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
279
279
|
get accelKey() {
|
|
280
280
|
return this.getAccelKey()
|
|
281
281
|
}
|
|
@@ -290,11 +290,11 @@ export class InputsManager {
|
|
|
290
290
|
/**
|
|
291
291
|
* Soon to be deprecated, use `getIsDragging()` instead.
|
|
292
292
|
*/
|
|
293
|
-
// eslint-disable-next-line no-
|
|
293
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
294
294
|
get isDragging() {
|
|
295
295
|
return this.getIsDragging()
|
|
296
296
|
}
|
|
297
|
-
// eslint-disable-next-line no-
|
|
297
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
298
298
|
set isDragging(isDragging: boolean) {
|
|
299
299
|
this.setIsDragging(isDragging)
|
|
300
300
|
}
|
|
@@ -315,11 +315,11 @@ export class InputsManager {
|
|
|
315
315
|
/**
|
|
316
316
|
* @deprecated Use `getIsPointing()` instead.
|
|
317
317
|
*/
|
|
318
|
-
// eslint-disable-next-line no-
|
|
318
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
319
319
|
get isPointing() {
|
|
320
320
|
return this.getIsPointing()
|
|
321
321
|
}
|
|
322
|
-
// eslint-disable-next-line no-
|
|
322
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
323
323
|
set isPointing(isPointing: boolean) {
|
|
324
324
|
this.setIsPointing(isPointing)
|
|
325
325
|
}
|
|
@@ -341,11 +341,11 @@ export class InputsManager {
|
|
|
341
341
|
/**
|
|
342
342
|
* @deprecated Use `getIsPinching()` instead.
|
|
343
343
|
*/
|
|
344
|
-
// eslint-disable-next-line no-
|
|
344
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
345
345
|
get isPinching() {
|
|
346
346
|
return this.getIsPinching()
|
|
347
347
|
}
|
|
348
|
-
// eslint-disable-next-line no-
|
|
348
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
349
349
|
set isPinching(isPinching: boolean) {
|
|
350
350
|
this.setIsPinching(isPinching)
|
|
351
351
|
}
|
|
@@ -367,11 +367,11 @@ export class InputsManager {
|
|
|
367
367
|
/**
|
|
368
368
|
* @deprecated Use `getIsEditing()` instead.
|
|
369
369
|
*/
|
|
370
|
-
// eslint-disable-next-line no-
|
|
370
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
371
371
|
get isEditing() {
|
|
372
372
|
return this.getIsEditing()
|
|
373
373
|
}
|
|
374
|
-
// eslint-disable-next-line no-
|
|
374
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
375
375
|
set isEditing(isEditing: boolean) {
|
|
376
376
|
this.setIsEditing(isEditing)
|
|
377
377
|
}
|
|
@@ -392,11 +392,11 @@ export class InputsManager {
|
|
|
392
392
|
/**
|
|
393
393
|
* @deprecated Use `getIsPanning()` instead.
|
|
394
394
|
*/
|
|
395
|
-
// eslint-disable-next-line no-
|
|
395
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
396
396
|
get isPanning() {
|
|
397
397
|
return this.getIsPanning()
|
|
398
398
|
}
|
|
399
|
-
// eslint-disable-next-line no-
|
|
399
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
400
400
|
set isPanning(isPanning: boolean) {
|
|
401
401
|
this.setIsPanning(isPanning)
|
|
402
402
|
}
|
|
@@ -418,11 +418,11 @@ export class InputsManager {
|
|
|
418
418
|
/**
|
|
419
419
|
* @deprecated Use `getIsSpacebarPanning()` instead.
|
|
420
420
|
*/
|
|
421
|
-
// eslint-disable-next-line no-
|
|
421
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
422
422
|
get isSpacebarPanning() {
|
|
423
423
|
return this.getIsSpacebarPanning()
|
|
424
424
|
}
|
|
425
|
-
// eslint-disable-next-line no-
|
|
425
|
+
// eslint-disable-next-line tldraw/no-setter-getter
|
|
426
426
|
set isSpacebarPanning(isSpacebarPanning: boolean) {
|
|
427
427
|
this.setIsSpacebarPanning(isSpacebarPanning)
|
|
428
428
|
}
|
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
isSelectionCorner,
|
|
11
11
|
} from '../../../primitives/Box'
|
|
12
12
|
import { Mat } from '../../../primitives/Mat'
|
|
13
|
-
import { Vec } from '../../../primitives/Vec'
|
|
14
13
|
import { rangeIntersection, rangesOverlap } from '../../../primitives/utils'
|
|
14
|
+
import { Vec } from '../../../primitives/Vec'
|
|
15
15
|
import type { Editor } from '../../Editor'
|
|
16
16
|
import type {
|
|
17
17
|
GapsSnapIndicator,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { computed } from '@tldraw/state'
|
|
2
2
|
import { TLHandle, TLShape, TLShapeId, VecModel } from '@tldraw/tlschema'
|
|
3
3
|
import { assertExists, uniqueId } from '@tldraw/utils'
|
|
4
|
-
import { Vec } from '../../../primitives/Vec'
|
|
5
4
|
import { Geometry2d } from '../../../primitives/geometry/Geometry2d'
|
|
5
|
+
import { Vec } from '../../../primitives/Vec'
|
|
6
6
|
import type { Editor } from '../../Editor'
|
|
7
7
|
import type { PointsSnapIndicator, SnapData, SnapManager } from './SnapManager'
|
|
8
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Computed, RESET_VALUE, computed, isUninitialized } from '@tldraw/state'
|
|
2
2
|
import type { RecordsDiff } from '@tldraw/store'
|
|
3
|
-
import type { TLRecord } from '@tldraw/tlschema'
|
|
4
3
|
import { TLPageId, TLShape, TLShapeId, isShape } from '@tldraw/tlschema'
|
|
4
|
+
import type { TLRecord } from '@tldraw/tlschema'
|
|
5
5
|
import { objectMapValues } from '@tldraw/utils'
|
|
6
6
|
import { Box } from '../../../primitives/Box'
|
|
7
7
|
import type { Editor } from '../../Editor'
|
|
@@ -74,7 +74,7 @@ export class SpatialIndexManager {
|
|
|
74
74
|
// Collect all shape elements for bulk loading
|
|
75
75
|
for (const shape of shapes) {
|
|
76
76
|
const bounds = this.editor.getShapePageBounds(shape.id)
|
|
77
|
-
if (bounds) {
|
|
77
|
+
if (bounds && bounds.isValid()) {
|
|
78
78
|
elements.push({
|
|
79
79
|
minX: bounds.minX,
|
|
80
80
|
minY: bounds.minY,
|
|
@@ -101,7 +101,7 @@ export class SpatialIndexManager {
|
|
|
101
101
|
for (const shape of objectMapValues(changes.added) as TLShape[]) {
|
|
102
102
|
if (isShape(shape) && this.editor.getAncestorPageId(shape) === this.lastPageId) {
|
|
103
103
|
const bounds = this.editor.getShapePageBounds(shape.id)
|
|
104
|
-
if (bounds) {
|
|
104
|
+
if (bounds && bounds.isValid()) {
|
|
105
105
|
this.rbush.upsert(shape.id, bounds)
|
|
106
106
|
}
|
|
107
107
|
processedShapeIds.add(shape.id)
|
|
@@ -125,7 +125,7 @@ export class SpatialIndexManager {
|
|
|
125
125
|
|
|
126
126
|
if (isOnPage) {
|
|
127
127
|
const bounds = this.editor.getShapePageBounds(to.id)
|
|
128
|
-
if (bounds) {
|
|
128
|
+
if (bounds && bounds.isValid()) {
|
|
129
129
|
this.rbush.upsert(to.id, bounds)
|
|
130
130
|
}
|
|
131
131
|
} else {
|
|
@@ -145,7 +145,7 @@ export class SpatialIndexManager {
|
|
|
145
145
|
const indexedBounds = this.rbush.getBounds(shapeId)
|
|
146
146
|
|
|
147
147
|
if (!this.areBoundsEqual(currentBounds, indexedBounds)) {
|
|
148
|
-
if (currentBounds) {
|
|
148
|
+
if (currentBounds && currentBounds.isValid()) {
|
|
149
149
|
this.rbush.upsert(shapeId, currentBounds)
|
|
150
150
|
} else {
|
|
151
151
|
this.rbush.remove(shapeId)
|
|
@@ -3,6 +3,22 @@ import { Editor } from '../../Editor'
|
|
|
3
3
|
import { TextManager, TLMeasureTextSpanOpts } from './TextManager'
|
|
4
4
|
|
|
5
5
|
// Create a simple mock DOM environment
|
|
6
|
+
function createMockStyle() {
|
|
7
|
+
const properties = new Map<string, string>()
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
setProperty: vi.fn((key: string, value: string) => {
|
|
11
|
+
properties.set(key, value)
|
|
12
|
+
}),
|
|
13
|
+
getPropertyValue: vi.fn((key: string) => properties.get(key) ?? ''),
|
|
14
|
+
removeProperty: vi.fn((key: string) => {
|
|
15
|
+
const previous = properties.get(key) ?? ''
|
|
16
|
+
properties.delete(key)
|
|
17
|
+
return previous
|
|
18
|
+
}),
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
6
22
|
const mockElement = {
|
|
7
23
|
classList: { add: vi.fn() },
|
|
8
24
|
tabIndex: -1,
|
|
@@ -10,10 +26,7 @@ const mockElement = {
|
|
|
10
26
|
innerHTML: '',
|
|
11
27
|
textContent: '',
|
|
12
28
|
setAttribute: vi.fn(),
|
|
13
|
-
style:
|
|
14
|
-
setProperty: vi.fn(),
|
|
15
|
-
getPropertyValue: vi.fn(() => ''),
|
|
16
|
-
},
|
|
29
|
+
style: createMockStyle(),
|
|
17
30
|
scrollWidth: 100,
|
|
18
31
|
getBoundingClientRect: vi.fn(() => ({
|
|
19
32
|
width: 100,
|
|
@@ -31,6 +44,7 @@ const mockElement = {
|
|
|
31
44
|
// Mock document.createElement to return our mock element
|
|
32
45
|
const mockCreateElement = vi.fn(() => {
|
|
33
46
|
const element = { ...mockElement }
|
|
47
|
+
element.style = createMockStyle()
|
|
34
48
|
element.cloneNode = vi.fn(() => ({ ...element }))
|
|
35
49
|
|
|
36
50
|
// Make textContent and innerHTML reactive like real DOM elements
|