@tldraw/editor 3.12.0-canary.ceec8eda0db0 → 3.12.0-canary.d81bcb86d4e7
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 +5 -2
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/TldrawEditor.js.map +1 -1
- package/dist-cjs/lib/components/Shape.js +10 -14
- package/dist-cjs/lib/components/Shape.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +16 -14
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/derivations/notVisibleShapes.js +1 -1
- package/dist-cjs/lib/editor/derivations/notVisibleShapes.js.map +2 -2
- package/dist-cjs/lib/editor/managers/FontManager.js +1 -1
- package/dist-cjs/lib/editor/managers/FontManager.js.map +2 -2
- package/dist-cjs/lib/editor/tools/StateNode.js +4 -1
- package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.js +12 -7
- package/dist-cjs/lib/hooks/useCanvasEvents.js.map +3 -3
- package/dist-cjs/lib/hooks/useGestureEvents.js +12 -6
- package/dist-cjs/lib/hooks/useGestureEvents.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Group2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/Group2d.js.map +2 -2
- package/dist-cjs/lib/utils/debug-flags.js +2 -1
- package/dist-cjs/lib/utils/debug-flags.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 +5 -2
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/TldrawEditor.mjs.map +1 -1
- package/dist-esm/lib/components/Shape.mjs +11 -15
- package/dist-esm/lib/components/Shape.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +16 -14
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs +1 -1
- package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/FontManager.mjs +1 -1
- package/dist-esm/lib/editor/managers/FontManager.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/StateNode.mjs +4 -1
- package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs +12 -7
- package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +3 -3
- package/dist-esm/lib/hooks/useGestureEvents.mjs +12 -6
- package/dist-esm/lib/hooks/useGestureEvents.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Group2d.mjs +1 -1
- package/dist-esm/lib/primitives/geometry/Group2d.mjs.map +2 -2
- package/dist-esm/lib/utils/debug-flags.mjs +2 -1
- package/dist-esm/lib/utils/debug-flags.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +17 -11
- package/package.json +7 -7
- package/src/lib/TldrawEditor.tsx +2 -2
- package/src/lib/components/Shape.tsx +15 -19
- package/src/lib/editor/Editor.ts +19 -15
- package/src/lib/editor/derivations/notVisibleShapes.ts +1 -1
- package/src/lib/editor/managers/FontManager.ts +1 -1
- package/src/lib/editor/tools/StateNode.ts +6 -1
- package/src/lib/hooks/useCanvasEvents.ts +14 -7
- package/src/lib/hooks/useGestureEvents.ts +12 -6
- package/src/lib/primitives/geometry/Group2d.ts +1 -1
- package/src/lib/utils/debug-flags.ts +1 -0
- package/src/version.ts +3 -3
package/editor.css
CHANGED
|
@@ -897,16 +897,17 @@ input,
|
|
|
897
897
|
cursor: var(--tl-cursor-default);
|
|
898
898
|
}
|
|
899
899
|
|
|
900
|
+
.tl-rich-text[data-is-ready-for-editing='true'],
|
|
901
|
+
.tl-text-wrapper[data-is-ready-for-editing='true'] .tl-text-input {
|
|
902
|
+
cursor: var(--tl-cursor-text);
|
|
903
|
+
}
|
|
904
|
+
|
|
900
905
|
.tl-text-input::selection {
|
|
901
906
|
background: var(--color-selected);
|
|
902
907
|
color: var(--color-selected-contrast);
|
|
903
908
|
text-shadow: none;
|
|
904
909
|
}
|
|
905
910
|
|
|
906
|
-
.tl-rich-text[data-iseditinganything='true'] {
|
|
907
|
-
cursor: var(--tl-cursor-text);
|
|
908
|
-
}
|
|
909
|
-
|
|
910
911
|
.tl-rich-text .ProseMirror {
|
|
911
912
|
word-wrap: break-word;
|
|
912
913
|
overflow-wrap: break-word;
|
|
@@ -1421,13 +1422,17 @@ input,
|
|
|
1421
1422
|
}
|
|
1422
1423
|
|
|
1423
1424
|
.tl-frame-heading {
|
|
1425
|
+
--frame-padding-x: 6px;
|
|
1426
|
+
--frame-height: 24px;
|
|
1427
|
+
--frame-minimum-width: 32px;
|
|
1428
|
+
--frame-offset-width: 16px;
|
|
1424
1429
|
display: flex;
|
|
1425
1430
|
align-items: center;
|
|
1426
1431
|
position: absolute;
|
|
1427
1432
|
transform-origin: 0% 100%;
|
|
1428
1433
|
overflow: hidden;
|
|
1429
1434
|
max-width: 100%;
|
|
1430
|
-
min-width:
|
|
1435
|
+
min-width: var(--frame-minimum-width);
|
|
1431
1436
|
height: auto;
|
|
1432
1437
|
font-size: 12px;
|
|
1433
1438
|
padding-bottom: 4px;
|
|
@@ -1439,32 +1444,33 @@ input,
|
|
|
1439
1444
|
/* scale from bottom left corner so we can pin it to the top left corner of the frame */
|
|
1440
1445
|
transform-origin: 0% 100%;
|
|
1441
1446
|
display: flex;
|
|
1442
|
-
height:
|
|
1447
|
+
height: var(--frame-height);
|
|
1443
1448
|
width: 100%;
|
|
1444
1449
|
align-items: center;
|
|
1445
1450
|
border-radius: var(--radius-1);
|
|
1446
|
-
background-color: var(--color-background);
|
|
1447
1451
|
}
|
|
1448
1452
|
|
|
1449
1453
|
.tl-frame-label {
|
|
1450
1454
|
pointer-events: all;
|
|
1451
1455
|
overflow: hidden;
|
|
1452
1456
|
text-overflow: ellipsis;
|
|
1453
|
-
padding:
|
|
1457
|
+
padding: 0px var(--frame-padding-x);
|
|
1458
|
+
border-radius: var(--radius-1);
|
|
1454
1459
|
position: relative;
|
|
1455
1460
|
font-size: inherit;
|
|
1456
1461
|
white-space: pre;
|
|
1457
|
-
border: 1px solid transparent;
|
|
1458
1462
|
}
|
|
1459
1463
|
|
|
1460
1464
|
.tl-frame-label__editing {
|
|
1461
1465
|
color: transparent;
|
|
1462
1466
|
white-space: pre;
|
|
1463
1467
|
width: auto;
|
|
1468
|
+
min-width: var(--frame-minimum-width);
|
|
1469
|
+
height: 100%;
|
|
1464
1470
|
overflow: visible;
|
|
1465
1471
|
background-color: var(--color-panel);
|
|
1466
|
-
border-radius: var(--radius-1);
|
|
1467
1472
|
border-color: var(--color-selected);
|
|
1473
|
+
box-shadow: inset 0px 0px 0px 1.5px var(--color-selected);
|
|
1468
1474
|
}
|
|
1469
1475
|
|
|
1470
1476
|
.tl-frame-name-input {
|
|
@@ -1472,7 +1478,7 @@ input,
|
|
|
1472
1478
|
border: none;
|
|
1473
1479
|
background: none;
|
|
1474
1480
|
outline: none;
|
|
1475
|
-
padding:
|
|
1481
|
+
padding: 0px var(--frame-padding-x);
|
|
1476
1482
|
inset: 0px;
|
|
1477
1483
|
height: 100%;
|
|
1478
1484
|
width: 100%;
|
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.12.0-canary.
|
|
4
|
+
"version": "3.12.0-canary.d81bcb86d4e7",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tldraw Inc.",
|
|
7
7
|
"email": "hello@tldraw.com"
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"@tiptap/core": "^2.9.1",
|
|
49
49
|
"@tiptap/pm": "^2.9.1",
|
|
50
50
|
"@tiptap/react": "^2.9.1",
|
|
51
|
-
"@tldraw/state": "3.12.0-canary.
|
|
52
|
-
"@tldraw/state-react": "3.12.0-canary.
|
|
53
|
-
"@tldraw/store": "3.12.0-canary.
|
|
54
|
-
"@tldraw/tlschema": "3.12.0-canary.
|
|
55
|
-
"@tldraw/utils": "3.12.0-canary.
|
|
56
|
-
"@tldraw/validate": "3.12.0-canary.
|
|
51
|
+
"@tldraw/state": "3.12.0-canary.d81bcb86d4e7",
|
|
52
|
+
"@tldraw/state-react": "3.12.0-canary.d81bcb86d4e7",
|
|
53
|
+
"@tldraw/store": "3.12.0-canary.d81bcb86d4e7",
|
|
54
|
+
"@tldraw/tlschema": "3.12.0-canary.d81bcb86d4e7",
|
|
55
|
+
"@tldraw/utils": "3.12.0-canary.d81bcb86d4e7",
|
|
56
|
+
"@tldraw/validate": "3.12.0-canary.d81bcb86d4e7",
|
|
57
57
|
"@types/core-js": "^2.5.8",
|
|
58
58
|
"@use-gesture/react": "^10.3.1",
|
|
59
59
|
"classnames": "^2.5.1",
|
package/src/lib/TldrawEditor.tsx
CHANGED
|
@@ -50,7 +50,7 @@ import { TLStoreWithStatus } from './utils/sync/StoreWithStatus'
|
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* Props for the {@link tldraw#Tldraw} and {@link TldrawEditor} components, when passing in a
|
|
53
|
-
*
|
|
53
|
+
* `TLStore` directly. If you would like tldraw to create a store for you, use
|
|
54
54
|
* {@link TldrawEditorWithoutStoreProps}.
|
|
55
55
|
*
|
|
56
56
|
* @public
|
|
@@ -64,7 +64,7 @@ export interface TldrawEditorWithStoreProps {
|
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Props for the {@link tldraw#Tldraw} and {@link TldrawEditor} components, when not passing in a
|
|
67
|
-
*
|
|
67
|
+
* `TLStore` directly. If you would like to pass in a store directly, use
|
|
68
68
|
* {@link TldrawEditorWithStoreProps}.
|
|
69
69
|
*
|
|
70
70
|
* @public
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { react } from '@tldraw/state'
|
|
2
2
|
import { useQuickReactor, useStateTracking } from '@tldraw/state-react'
|
|
3
3
|
import { TLShape, TLShapeId } from '@tldraw/tlschema'
|
|
4
|
-
import { memo, useCallback, useEffect, useRef } from 'react'
|
|
4
|
+
import { memo, useCallback, useEffect, useLayoutEffect, useRef } from 'react'
|
|
5
5
|
import { ShapeUtil } from '../editor/shapes/ShapeUtil'
|
|
6
6
|
import { useEditor } from '../hooks/useEditor'
|
|
7
7
|
import { useEditorComponents } from '../hooks/useEditorComponents'
|
|
@@ -44,10 +44,10 @@ export const Shape = memo(function Shape({
|
|
|
44
44
|
|
|
45
45
|
useEffect(() => {
|
|
46
46
|
return react('load fonts', () => {
|
|
47
|
-
const fonts = editor.fonts.getShapeFontFaces(
|
|
47
|
+
const fonts = editor.fonts.getShapeFontFaces(id)
|
|
48
48
|
editor.fonts.requestFonts(fonts)
|
|
49
49
|
})
|
|
50
|
-
}, [editor,
|
|
50
|
+
}, [editor, id])
|
|
51
51
|
|
|
52
52
|
const memoizedStuffRef = useRef({
|
|
53
53
|
transform: '',
|
|
@@ -104,22 +104,18 @@ export const Shape = memo(function Shape({
|
|
|
104
104
|
)
|
|
105
105
|
|
|
106
106
|
// This stuff changes pretty infrequently, so we can change them together
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
setStyleProperty(bgContainer, 'z-index', backgroundIndex)
|
|
120
|
-
},
|
|
121
|
-
[opacity, index, backgroundIndex]
|
|
122
|
-
)
|
|
107
|
+
useLayoutEffect(() => {
|
|
108
|
+
const container = containerRef.current
|
|
109
|
+
const bgContainer = bgContainerRef.current
|
|
110
|
+
|
|
111
|
+
// Opacity
|
|
112
|
+
setStyleProperty(container, 'opacity', opacity)
|
|
113
|
+
setStyleProperty(bgContainer, 'opacity', opacity)
|
|
114
|
+
|
|
115
|
+
// Z-Index
|
|
116
|
+
setStyleProperty(container, 'z-index', index)
|
|
117
|
+
setStyleProperty(bgContainer, 'z-index', backgroundIndex)
|
|
118
|
+
}, [opacity, index, backgroundIndex])
|
|
123
119
|
|
|
124
120
|
useQuickReactor(
|
|
125
121
|
'set display',
|
package/src/lib/editor/Editor.ts
CHANGED
|
@@ -1216,7 +1216,6 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
1216
1216
|
run(fn: () => void, opts?: TLEditorRunOptions): this {
|
|
1217
1217
|
const previousIgnoreShapeLock = this._shouldIgnoreShapeLock
|
|
1218
1218
|
this._shouldIgnoreShapeLock = opts?.ignoreShapeLock ?? previousIgnoreShapeLock
|
|
1219
|
-
|
|
1220
1219
|
try {
|
|
1221
1220
|
this.history.batch(fn, opts)
|
|
1222
1221
|
} finally {
|
|
@@ -8139,8 +8138,18 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
8139
8138
|
if (!currentTool) return styles
|
|
8140
8139
|
|
|
8141
8140
|
if (currentTool.shapeType) {
|
|
8142
|
-
|
|
8143
|
-
|
|
8141
|
+
if (
|
|
8142
|
+
currentTool.shapeType === 'frame' &&
|
|
8143
|
+
!(this.getShapeUtil('frame')!.options as any).showColors
|
|
8144
|
+
) {
|
|
8145
|
+
for (const style of this.styleProps[currentTool.shapeType].keys()) {
|
|
8146
|
+
if (style.id === 'tldraw:color') continue
|
|
8147
|
+
styles.applyValue(style, this.getStyleForNextShape(style))
|
|
8148
|
+
}
|
|
8149
|
+
} else {
|
|
8150
|
+
for (const style of this.styleProps[currentTool.shapeType].keys()) {
|
|
8151
|
+
styles.applyValue(style, this.getStyleForNextShape(style))
|
|
8152
|
+
}
|
|
8144
8153
|
}
|
|
8145
8154
|
}
|
|
8146
8155
|
|
|
@@ -9849,12 +9858,12 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
9849
9858
|
|
|
9850
9859
|
const { x: cx, y: cy, z: cz } = unsafe__withoutCapture(() => this.getCamera())
|
|
9851
9860
|
|
|
9852
|
-
const { panSpeed
|
|
9861
|
+
const { panSpeed } = cameraOptions
|
|
9853
9862
|
this._setCamera(
|
|
9854
9863
|
new Vec(
|
|
9855
|
-
cx + (dx * panSpeed) / cz - x / cz + x /
|
|
9856
|
-
cy + (dy * panSpeed) / cz - y / cz + y /
|
|
9857
|
-
z
|
|
9864
|
+
cx + (dx * panSpeed) / cz - x / cz + x / z,
|
|
9865
|
+
cy + (dy * panSpeed) / cz - y / cz + y / z,
|
|
9866
|
+
z
|
|
9858
9867
|
),
|
|
9859
9868
|
{ immediate: true }
|
|
9860
9869
|
)
|
|
@@ -9929,14 +9938,9 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|
|
9929
9938
|
}
|
|
9930
9939
|
|
|
9931
9940
|
const zoom = cz + (delta ?? 0) * zoomSpeed * cz
|
|
9932
|
-
this._setCamera(
|
|
9933
|
-
|
|
9934
|
-
|
|
9935
|
-
cy + (y / zoom - y) - (y / cz - y),
|
|
9936
|
-
zoom
|
|
9937
|
-
),
|
|
9938
|
-
{ immediate: true }
|
|
9939
|
-
)
|
|
9941
|
+
this._setCamera(new Vec(cx + x / zoom - x / cz, cy + y / zoom - y / cz, zoom), {
|
|
9942
|
+
immediate: true,
|
|
9943
|
+
})
|
|
9940
9944
|
this.maybeTrackPerformance('Zooming')
|
|
9941
9945
|
return
|
|
9942
9946
|
}
|
|
@@ -31,7 +31,7 @@ export const notVisibleShapes = (editor: Editor) => {
|
|
|
31
31
|
})
|
|
32
32
|
return notVisibleShapes
|
|
33
33
|
}
|
|
34
|
-
return computed<Set<TLShapeId>>('
|
|
34
|
+
return computed<Set<TLShapeId>>('notVisibleShapes', (prevValue) => {
|
|
35
35
|
if (isUninitialized(prevValue)) {
|
|
36
36
|
return fromScratch(editor)
|
|
37
37
|
}
|
|
@@ -94,7 +94,7 @@ export class FontManager {
|
|
|
94
94
|
const shapeUtil = this.editor.getShapeUtil(shape)
|
|
95
95
|
return shapeUtil.getFontFaces(shape)
|
|
96
96
|
},
|
|
97
|
-
{ areResultsEqual: areArraysShallowEqual }
|
|
97
|
+
{ areResultsEqual: areArraysShallowEqual, areRecordsEqual: (a, b) => a.props === b.props }
|
|
98
98
|
)
|
|
99
99
|
|
|
100
100
|
this.shapeFontLoadStateCache = editor.store.createCache<(FontState | null)[], TLShape>(
|
|
@@ -38,6 +38,7 @@ export interface TLStateNodeConstructor {
|
|
|
38
38
|
initial?: string
|
|
39
39
|
children?(): TLStateNodeConstructor[]
|
|
40
40
|
isLockable: boolean
|
|
41
|
+
useCoalescedEvents: boolean
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
/** @public */
|
|
@@ -47,7 +48,8 @@ export abstract class StateNode implements Partial<TLEventHandlers> {
|
|
|
47
48
|
public editor: Editor,
|
|
48
49
|
parent?: StateNode
|
|
49
50
|
) {
|
|
50
|
-
const { id, children, initial, isLockable } = this
|
|
51
|
+
const { id, children, initial, isLockable, useCoalescedEvents } = this
|
|
52
|
+
.constructor as TLStateNodeConstructor
|
|
51
53
|
|
|
52
54
|
this.id = id
|
|
53
55
|
this._isActive = atom<boolean>('toolIsActive' + this.id, false)
|
|
@@ -83,6 +85,7 @@ export abstract class StateNode implements Partial<TLEventHandlers> {
|
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
87
|
this.isLockable = isLockable
|
|
88
|
+
this.useCoalescedEvents = useCoalescedEvents
|
|
86
89
|
this.performanceTracker = new PerformanceTracker()
|
|
87
90
|
}
|
|
88
91
|
|
|
@@ -90,6 +93,7 @@ export abstract class StateNode implements Partial<TLEventHandlers> {
|
|
|
90
93
|
static initial?: string
|
|
91
94
|
static children?: () => TLStateNodeConstructor[]
|
|
92
95
|
static isLockable = true
|
|
96
|
+
static useCoalescedEvents = false
|
|
93
97
|
|
|
94
98
|
id: string
|
|
95
99
|
type: 'branch' | 'leaf' | 'root'
|
|
@@ -97,6 +101,7 @@ export abstract class StateNode implements Partial<TLEventHandlers> {
|
|
|
97
101
|
initial?: string
|
|
98
102
|
children?: Record<string, StateNode>
|
|
99
103
|
isLockable: boolean
|
|
104
|
+
useCoalescedEvents: boolean
|
|
100
105
|
parent: StateNode
|
|
101
106
|
|
|
102
107
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useValue } from '@tldraw/state-react'
|
|
1
2
|
import React, { useMemo } from 'react'
|
|
2
3
|
import { RIGHT_MOUSE_BUTTON } from '../constants'
|
|
3
4
|
import {
|
|
@@ -11,6 +12,7 @@ import { useEditor } from './useEditor'
|
|
|
11
12
|
|
|
12
13
|
export function useCanvasEvents() {
|
|
13
14
|
const editor = useEditor()
|
|
15
|
+
const currentTool = useValue('current tool', () => editor.getCurrentTool(), [editor])
|
|
14
16
|
|
|
15
17
|
const events = useMemo(
|
|
16
18
|
function canvasEvents() {
|
|
@@ -49,12 +51,17 @@ export function useCanvasEvents() {
|
|
|
49
51
|
lastX = e.clientX
|
|
50
52
|
lastY = e.clientY
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
// For tools that benefit from a higher fidelity of events,
|
|
55
|
+
// we dispatch the coalesced events.
|
|
56
|
+
const events = currentTool.useCoalescedEvents ? e.nativeEvent.getCoalescedEvents() : [e]
|
|
57
|
+
for (const singleEvent of events) {
|
|
58
|
+
editor.dispatch({
|
|
59
|
+
type: 'pointer',
|
|
60
|
+
target: 'canvas',
|
|
61
|
+
name: 'pointer_move',
|
|
62
|
+
...getPointerInfo(singleEvent),
|
|
63
|
+
})
|
|
64
|
+
}
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
function onPointerUp(e: React.PointerEvent) {
|
|
@@ -159,7 +166,7 @@ export function useCanvasEvents() {
|
|
|
159
166
|
onClick,
|
|
160
167
|
}
|
|
161
168
|
},
|
|
162
|
-
[editor]
|
|
169
|
+
[editor, currentTool]
|
|
163
170
|
)
|
|
164
171
|
|
|
165
172
|
return events
|
|
@@ -135,7 +135,6 @@ export function useGestureEvents(ref: React.RefObject<HTMLDivElement>) {
|
|
|
135
135
|
|
|
136
136
|
let initDistanceBetweenFingers = 1 // the distance between the two fingers when the pinch starts
|
|
137
137
|
let initZoom = 1 // the browser's zoom level when the pinch starts
|
|
138
|
-
let currZoom = 1 // the current zoom level according to the pinch gesture recognizer
|
|
139
138
|
let currDistanceBetweenFingers = 0
|
|
140
139
|
const initPointBetweenFingers = new Vec()
|
|
141
140
|
const prevPointBetweenFingers = new Vec()
|
|
@@ -239,7 +238,7 @@ export function useGestureEvents(ref: React.RefObject<HTMLDivElement>) {
|
|
|
239
238
|
|
|
240
239
|
switch (pinchState) {
|
|
241
240
|
case 'zooming': {
|
|
242
|
-
currZoom = offset[0]
|
|
241
|
+
const currZoom = offset[0] ** editor.getCameraOptions().zoomSpeed
|
|
243
242
|
|
|
244
243
|
editor.dispatch({
|
|
245
244
|
type: 'pinch',
|
|
@@ -278,7 +277,7 @@ export function useGestureEvents(ref: React.RefObject<HTMLDivElement>) {
|
|
|
278
277
|
if (event instanceof WheelEvent) return
|
|
279
278
|
if (!(event.target === elm || elm?.contains(event.target as Node))) return
|
|
280
279
|
|
|
281
|
-
const scale = offset[0]
|
|
280
|
+
const scale = offset[0] ** editor.getCameraOptions().zoomSpeed
|
|
282
281
|
|
|
283
282
|
pinchState = 'not sure'
|
|
284
283
|
|
|
@@ -309,14 +308,21 @@ export function useGestureEvents(ref: React.RefObject<HTMLDivElement>) {
|
|
|
309
308
|
target: ref,
|
|
310
309
|
eventOptions: { passive: false },
|
|
311
310
|
pinch: {
|
|
312
|
-
from: () =>
|
|
311
|
+
from: () => {
|
|
312
|
+
const { zoomSpeed } = editor.getCameraOptions()
|
|
313
|
+
const level = editor.getZoomLevel() ** (1 / zoomSpeed)
|
|
314
|
+
return [level, 0]
|
|
315
|
+
}, // Return the camera z to use when pinch starts
|
|
313
316
|
scaleBounds: () => {
|
|
314
317
|
const baseZoom = editor.getBaseZoom()
|
|
315
|
-
const zoomSteps = editor.getCameraOptions()
|
|
318
|
+
const { zoomSteps, zoomSpeed } = editor.getCameraOptions()
|
|
316
319
|
const zoomMin = zoomSteps[0] * baseZoom
|
|
317
320
|
const zoomMax = zoomSteps[zoomSteps.length - 1] * baseZoom
|
|
318
321
|
|
|
319
|
-
return {
|
|
322
|
+
return {
|
|
323
|
+
max: zoomMax ** (1 / zoomSpeed),
|
|
324
|
+
min: zoomMin ** (1 / zoomSpeed),
|
|
325
|
+
}
|
|
320
326
|
},
|
|
321
327
|
},
|
|
322
328
|
})
|
|
@@ -102,6 +102,6 @@ export class Group2d extends Geometry2d {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
getSvgPathData(): string {
|
|
105
|
-
return this.children.map((c
|
|
105
|
+
return this.children.map((c) => (c.isLabel ? '' : c.getSvgPathData(true))).join(' ')
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -53,6 +53,7 @@ export const debugFlags = {
|
|
|
53
53
|
debugGeometry: createDebugValue('debugGeometry', { defaults: { all: false } }),
|
|
54
54
|
hideShapes: createDebugValue('hideShapes', { defaults: { all: false } }),
|
|
55
55
|
editOnType: createDebugValue('editOnType', { defaults: { all: false } }),
|
|
56
|
+
a11y: createDebugValue('a11y', { defaults: { all: false } }),
|
|
56
57
|
} as const
|
|
57
58
|
|
|
58
59
|
declare global {
|
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.12.0-canary.
|
|
4
|
+
export const version = '3.12.0-canary.d81bcb86d4e7'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2024-09-13T14:36:29.063Z',
|
|
7
|
-
minor: '2025-
|
|
8
|
-
patch: '2025-
|
|
7
|
+
minor: '2025-04-02T09:21:19.427Z',
|
|
8
|
+
patch: '2025-04-02T09:21:19.427Z',
|
|
9
9
|
}
|