@tldraw/editor 5.2.0-canary.4a316fdfb2bb → 5.2.0-canary.4e00299c3e28
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/README.md +7 -1
- package/dist-cjs/index.d.ts +39 -40
- package/dist-cjs/index.js +4 -4
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +92 -53
- package/dist-cjs/lib/editor/Editor.js.map +3 -3
- package/dist-cjs/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.js +3 -3
- package/dist-cjs/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js +1 -2
- package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js +12 -2
- package/dist-cjs/lib/editor/managers/HistoryManager/HistoryManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js +4 -2
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +7 -3
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +15 -2
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +2 -2
- package/dist-cjs/lib/editor/overlays/strokeShapeIndicators.js +79 -0
- package/dist-cjs/lib/editor/overlays/strokeShapeIndicators.js.map +7 -0
- package/dist-cjs/lib/hooks/usePresence.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 +39 -40
- package/dist-esm/index.mjs +5 -7
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +92 -53
- package/dist-esm/lib/editor/Editor.mjs.map +3 -3
- package/dist-esm/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.mjs +3 -3
- package/dist-esm/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs +1 -2
- package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs +12 -2
- package/dist-esm/lib/editor/managers/HistoryManager/HistoryManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs +4 -2
- package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +7 -3
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +15 -2
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +2 -2
- package/dist-esm/lib/editor/overlays/strokeShapeIndicators.mjs +59 -0
- package/dist-esm/lib/editor/overlays/strokeShapeIndicators.mjs.map +7 -0
- package/dist-esm/lib/hooks/usePresence.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +2 -0
- package/package.json +8 -8
- package/src/index.ts +2 -5
- package/src/lib/editor/Editor.ts +124 -64
- package/src/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.test.ts +43 -16
- package/src/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.ts +8 -5
- package/src/lib/editor/managers/FocusManager/FocusManager.test.ts +4 -4
- package/src/lib/editor/managers/FocusManager/FocusManager.ts +1 -2
- package/src/lib/editor/managers/FontManager/FontManager.test.ts +13 -9
- package/src/lib/editor/managers/HistoryManager/HistoryManager.ts +20 -2
- package/src/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.ts +9 -2
- package/src/lib/editor/managers/TextManager/TextManager.test.ts +16 -14
- package/src/lib/editor/managers/TextManager/TextManager.ts +17 -2
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +12 -2
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +27 -2
- package/src/lib/editor/overlays/strokeShapeIndicators.ts +86 -0
- package/src/lib/hooks/usePresence.ts +2 -2
- package/src/version.ts +3 -3
- package/dist-cjs/lib/editor/overlays/ShapeIndicatorOverlayUtil.js +0 -161
- package/dist-cjs/lib/editor/overlays/ShapeIndicatorOverlayUtil.js.map +0 -7
- package/dist-esm/lib/editor/overlays/ShapeIndicatorOverlayUtil.mjs +0 -141
- package/dist-esm/lib/editor/overlays/ShapeIndicatorOverlayUtil.mjs.map +0 -7
- package/src/lib/editor/overlays/ShapeIndicatorOverlayUtil.ts +0 -216
|
@@ -37,7 +37,7 @@ export class CollaboratorsManager {
|
|
|
37
37
|
@computed
|
|
38
38
|
private _getCollaboratorsQuery() {
|
|
39
39
|
return this.editor.store.query.records('instance_presence', () => ({
|
|
40
|
-
userId: { neq: this.editor.user.
|
|
40
|
+
userId: { neq: this.editor.user.getRecordId() },
|
|
41
41
|
}))
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -88,14 +88,17 @@ export class CollaboratorsManager {
|
|
|
88
88
|
if (!collaborators.length) return EMPTY_ARRAY
|
|
89
89
|
|
|
90
90
|
const { followingUserId, highlightedUserIds } = this.editor.getInstanceState()
|
|
91
|
-
const currentUserId = this.editor.user.
|
|
91
|
+
const currentUserId = this.editor.user.getRecordId()
|
|
92
92
|
|
|
93
93
|
return collaborators.filter((presence) => {
|
|
94
94
|
const { lastActivityTimestamp, userId, chatMessage } = presence
|
|
95
95
|
|
|
96
|
-
// Treat a missing `lastActivityTimestamp` as "active right now"
|
|
97
|
-
// so newly-joined peers aren't immediately classified as
|
|
98
|
-
|
|
96
|
+
// Treat a missing or zero `lastActivityTimestamp` as "active right now"
|
|
97
|
+
// (elapsed = 0) so newly-joined peers aren't immediately classified as
|
|
98
|
+
// idle/inactive. The broadcast default for peers who haven't moved their
|
|
99
|
+
// pointer yet is `0` (e.g. someone on a touch device who joins and just
|
|
100
|
+
// watches), so a plain `?? now` would leave them hidden. See issue #9017.
|
|
101
|
+
const elapsed = lastActivityTimestamp ? Math.max(0, now - lastActivityTimestamp) : 0
|
|
99
102
|
|
|
100
103
|
if (elapsed > collaboratorInactiveTimeoutMs) {
|
|
101
104
|
// Inactive: If they're inactive, only show if we're following them or they're highlighted
|
|
@@ -14,7 +14,7 @@ describe('FocusManager', () => {
|
|
|
14
14
|
getInstanceState: Mock
|
|
15
15
|
updateInstanceState: Mock
|
|
16
16
|
getContainer: Mock
|
|
17
|
-
|
|
17
|
+
getEditingShapeId: Mock
|
|
18
18
|
getSelectedShapeIds: Mock
|
|
19
19
|
complete: Mock
|
|
20
20
|
}
|
|
@@ -51,7 +51,7 @@ describe('FocusManager', () => {
|
|
|
51
51
|
updateInstanceState: vi.fn(),
|
|
52
52
|
getContainer: vi.fn(() => mockContainer),
|
|
53
53
|
getContainerDocument: vi.fn(() => document),
|
|
54
|
-
|
|
54
|
+
getEditingShapeId: vi.fn(() => null),
|
|
55
55
|
getSelectedShapeIds: vi.fn(() => []),
|
|
56
56
|
complete: vi.fn(),
|
|
57
57
|
} as any
|
|
@@ -243,7 +243,7 @@ describe('FocusManager', () => {
|
|
|
243
243
|
})
|
|
244
244
|
|
|
245
245
|
it('should return early when editor is in editing mode', () => {
|
|
246
|
-
editor.
|
|
246
|
+
editor.getEditingShapeId.mockReturnValue('shape:1')
|
|
247
247
|
const event = new KeyboardEvent('keydown', { key: 'Tab' })
|
|
248
248
|
|
|
249
249
|
keydownHandler(event)
|
|
@@ -407,7 +407,7 @@ describe('FocusManager', () => {
|
|
|
407
407
|
const keydownCall = addEventListenerCalls.find((call: any) => call[0] === 'keydown')
|
|
408
408
|
const keydownHandler = keydownCall![1]
|
|
409
409
|
|
|
410
|
-
editor.
|
|
410
|
+
editor.getEditingShapeId.mockReturnValue('shape:1') // Editing mode
|
|
411
411
|
|
|
412
412
|
const event = new KeyboardEvent('keydown', { key: 'Tab' })
|
|
413
413
|
keydownHandler(event)
|
|
@@ -63,8 +63,7 @@ export class FocusManager {
|
|
|
63
63
|
const activeEl = container.ownerDocument.activeElement
|
|
64
64
|
// Edit mode should remove the focus ring, however if the active element's
|
|
65
65
|
// parent is the contextual toolbar, then allow it.
|
|
66
|
-
if (this.editor.
|
|
67
|
-
return
|
|
66
|
+
if (this.editor.getEditingShapeId() && !activeEl?.closest('.tlui-contextual-toolbar')) return
|
|
68
67
|
if (activeEl === container && this.editor.getSelectedShapeIds().length > 0) return
|
|
69
68
|
if (['Tab', 'ArrowUp', 'ArrowDown'].includes(keyEvent.key)) {
|
|
70
69
|
container.classList.remove('tl-container__no-focus-ring')
|
|
@@ -15,12 +15,14 @@ import { FontManager } from './FontManager'
|
|
|
15
15
|
vi.mock('../../Editor')
|
|
16
16
|
|
|
17
17
|
// Mock globals
|
|
18
|
-
global.FontFace = vi.fn().mockImplementation((family, src, descriptors)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
global.FontFace = vi.fn().mockImplementation(function (family: any, src: any, descriptors: any) {
|
|
19
|
+
return {
|
|
20
|
+
family,
|
|
21
|
+
src,
|
|
22
|
+
...descriptors,
|
|
23
|
+
load: vi.fn(() => Promise.resolve()),
|
|
24
|
+
}
|
|
25
|
+
})
|
|
24
26
|
|
|
25
27
|
Object.defineProperty(global.document, 'fonts', {
|
|
26
28
|
value: {
|
|
@@ -200,9 +202,11 @@ describe('FontManager', () => {
|
|
|
200
202
|
const font = createMockFont()
|
|
201
203
|
const error = new Error('Font load failed')
|
|
202
204
|
|
|
203
|
-
;(global.FontFace as Mock).
|
|
204
|
-
|
|
205
|
-
|
|
205
|
+
;(global.FontFace as Mock).mockImplementationOnce(function () {
|
|
206
|
+
return {
|
|
207
|
+
family: font.family,
|
|
208
|
+
load: vi.fn(() => Promise.reject(error)),
|
|
209
|
+
}
|
|
206
210
|
})
|
|
207
211
|
|
|
208
212
|
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
|
@@ -48,7 +48,11 @@ export class HistoryManager<R extends UnknownRecord> {
|
|
|
48
48
|
switch (this.state) {
|
|
49
49
|
case HistoryRecorderState.Recording:
|
|
50
50
|
this.pendingDiff.apply(entry.changes)
|
|
51
|
-
this
|
|
51
|
+
// this interceptor runs for every store change, so skip the update when the
|
|
52
|
+
// redo stack is already empty
|
|
53
|
+
if (this.stacks.get().redos.length > 0) {
|
|
54
|
+
this.stacks.update(({ undos }) => ({ undos, redos: stack() }))
|
|
55
|
+
}
|
|
52
56
|
break
|
|
53
57
|
case HistoryRecorderState.RecordingPreserveRedoStack:
|
|
54
58
|
this.pendingDiff.apply(entry.changes)
|
|
@@ -349,7 +353,16 @@ class PendingDiff<R extends UnknownRecord> {
|
|
|
349
353
|
|
|
350
354
|
apply(diff: RecordsDiff<R>) {
|
|
351
355
|
squashRecordDiffsMutable(this.diff, [diff])
|
|
352
|
-
|
|
356
|
+
// Recomputing emptiness from the accumulated diff is O(N) (for-in over a
|
|
357
|
+
// dictionary-mode object pays an O(N) key-collection prologue), and this runs on
|
|
358
|
+
// every history interceptor call — e.g. every input tick while resizing many
|
|
359
|
+
// shapes. Updates can never cancel out existing entries during a squash, so the
|
|
360
|
+
// full recompute is only needed when the incoming diff adds or removes records.
|
|
361
|
+
if (hasAnyKey(diff.added) || hasAnyKey(diff.removed)) {
|
|
362
|
+
this.isEmptyAtom.set(isRecordsDiffEmpty(this.diff))
|
|
363
|
+
} else if (this.isEmptyAtom.__unsafe__getWithoutCapture()) {
|
|
364
|
+
this.isEmptyAtom.set(!hasAnyKey(diff.updated))
|
|
365
|
+
}
|
|
353
366
|
}
|
|
354
367
|
|
|
355
368
|
debug() {
|
|
@@ -357,6 +370,11 @@ class PendingDiff<R extends UnknownRecord> {
|
|
|
357
370
|
}
|
|
358
371
|
}
|
|
359
372
|
|
|
373
|
+
function hasAnyKey(obj: object) {
|
|
374
|
+
for (const _ in obj) return true
|
|
375
|
+
return false
|
|
376
|
+
}
|
|
377
|
+
|
|
360
378
|
type Stack<T> = StackItem<T> | EmptyStackItem<T>
|
|
361
379
|
|
|
362
380
|
function stack<T>(): Stack<T> {
|
|
@@ -46,6 +46,10 @@ export class SpatialIndexManager {
|
|
|
46
46
|
|
|
47
47
|
private createSpatialIndexComputed() {
|
|
48
48
|
const shapeHistory = this.editor.store.query.filterHistory('shape')
|
|
49
|
+
// Binding changes can move a shape's derived bounds (e.g. creating or
|
|
50
|
+
// deleting an arrow binding relocates the arrow's body) without
|
|
51
|
+
// touching any shape record, so they must also invalidate the index.
|
|
52
|
+
const bindingHistory = this.editor.store.query.filterHistory('binding')
|
|
49
53
|
|
|
50
54
|
return computed<number>('spatialIndex', (_prevValue, lastComputedEpoch) => {
|
|
51
55
|
if (isUninitialized(_prevValue)) {
|
|
@@ -53,8 +57,9 @@ export class SpatialIndexManager {
|
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
const shapeDiff = shapeHistory.getDiffSince(lastComputedEpoch)
|
|
60
|
+
const bindingDiff = bindingHistory.getDiffSince(lastComputedEpoch)
|
|
56
61
|
|
|
57
|
-
if (shapeDiff === RESET_VALUE) {
|
|
62
|
+
if (shapeDiff === RESET_VALUE || bindingDiff === RESET_VALUE) {
|
|
58
63
|
return this.rebuildAndBumpEpoch()
|
|
59
64
|
}
|
|
60
65
|
|
|
@@ -63,8 +68,10 @@ export class SpatialIndexManager {
|
|
|
63
68
|
return this.rebuildAndBumpEpoch()
|
|
64
69
|
}
|
|
65
70
|
|
|
66
|
-
if (shapeDiff.length === 0) return this._boundsEpoch
|
|
71
|
+
if (shapeDiff.length === 0 && bindingDiff.length === 0) return this._boundsEpoch
|
|
67
72
|
|
|
73
|
+
// A binding-only diff passes an empty shape diff: step 1 is a no-op
|
|
74
|
+
// and the step-2 sweep re-checks the indexed bounds of every shape.
|
|
68
75
|
if (this.processIncrementalUpdate(shapeDiff)) {
|
|
69
76
|
this._boundsEpoch++
|
|
70
77
|
}
|
|
@@ -82,20 +82,22 @@ const mockEditor = {
|
|
|
82
82
|
getContainerDocument: vi.fn(() => mockDocument),
|
|
83
83
|
} as unknown as Editor
|
|
84
84
|
|
|
85
|
-
global.Range = vi.fn(()
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
85
|
+
global.Range = vi.fn(function () {
|
|
86
|
+
return {
|
|
87
|
+
setStart: vi.fn(),
|
|
88
|
+
setEnd: vi.fn(),
|
|
89
|
+
getClientRects: vi.fn(() => [
|
|
90
|
+
{
|
|
91
|
+
width: 10,
|
|
92
|
+
height: 16,
|
|
93
|
+
left: 0,
|
|
94
|
+
top: 0,
|
|
95
|
+
right: 10,
|
|
96
|
+
bottom: 16,
|
|
97
|
+
},
|
|
98
|
+
]),
|
|
99
|
+
}
|
|
100
|
+
}) as any
|
|
99
101
|
|
|
100
102
|
describe('TextManager', () => {
|
|
101
103
|
let textManager: TextManager
|
|
@@ -2,6 +2,21 @@ import { BoxModel, TLDefaultHorizontalAlignStyle } from '@tldraw/tlschema'
|
|
|
2
2
|
import { objectMapKeys } from '@tldraw/utils'
|
|
3
3
|
import type { Editor } from '../../Editor'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* The whole-pixel line-height for a given font size and tldraw's unitless line-height
|
|
7
|
+
* multiplier. tldraw's theme stores line-height as a multiplier (e.g. 1.35); resolving it
|
|
8
|
+
* to a whole pixel keeps line spacing identical across rendering engines, which otherwise
|
|
9
|
+
* disagree on fractional line boxes (WebKit snaps them to whole pixels, Blink keeps the
|
|
10
|
+
* fraction) and let multi-line text drift apart. Apply it everywhere line-height is used —
|
|
11
|
+
* measurement, on-canvas render, and export — so geometry and rendering agree.
|
|
12
|
+
* See https://github.com/tldraw/tldraw/issues/8970.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export function resolveLineHeightPx(fontSize: number, lineHeight: number): number {
|
|
17
|
+
return Math.round(fontSize * lineHeight)
|
|
18
|
+
}
|
|
19
|
+
|
|
5
20
|
const fixNewLines = /\r?\n|\r/g
|
|
6
21
|
|
|
7
22
|
function normalizeTextForDom(text: string) {
|
|
@@ -154,7 +169,7 @@ export class TextManager {
|
|
|
154
169
|
'font-style': opts.fontStyle,
|
|
155
170
|
'font-weight': opts.fontWeight,
|
|
156
171
|
'font-size': opts.fontSize + 'px',
|
|
157
|
-
'line-height': opts.lineHeight
|
|
172
|
+
'line-height': `${resolveLineHeightPx(opts.fontSize, opts.lineHeight)}px`,
|
|
158
173
|
padding: opts.padding,
|
|
159
174
|
'max-width': opts.maxWidth ? opts.maxWidth + 'px' : undefined,
|
|
160
175
|
'min-width': opts.minWidth ? opts.minWidth + 'px' : undefined,
|
|
@@ -382,7 +397,7 @@ export class TextManager {
|
|
|
382
397
|
'font-style': opts.fontStyle,
|
|
383
398
|
'font-weight': opts.fontWeight,
|
|
384
399
|
'font-size': opts.fontSize + 'px',
|
|
385
|
-
'line-height': opts.lineHeight
|
|
400
|
+
'line-height': `${resolveLineHeightPx(opts.fontSize, opts.lineHeight)}px`,
|
|
386
401
|
width: `${elementWidth}px`,
|
|
387
402
|
height: 'min-content',
|
|
388
403
|
'text-align': textAlignmentsForLtr[opts.textAlign],
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { atom } from '@tldraw/state'
|
|
2
|
+
import { createUserId } from '@tldraw/tlschema'
|
|
2
3
|
import { Mocked, vi } from 'vitest'
|
|
3
4
|
import { TLCurrentUser } from '../../../config/createTLCurrentUser'
|
|
4
5
|
import { TLUserPreferences, defaultUserPreferences } from '../../../config/TLUserPreferences'
|
|
@@ -296,8 +297,17 @@ describe('UserPreferencesManager', () => {
|
|
|
296
297
|
userPreferencesManager = new UserPreferencesManager(mockUser, 'light')
|
|
297
298
|
})
|
|
298
299
|
|
|
299
|
-
describe('
|
|
300
|
-
it('should return user id', () => {
|
|
300
|
+
describe('getExternalId / getRecordId', () => {
|
|
301
|
+
it('should return the raw external user id', () => {
|
|
302
|
+
expect(userPreferencesManager.getExternalId()).toBe(mockUserPreferences.id)
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
it('should return the prefixed record id', () => {
|
|
306
|
+
expect(userPreferencesManager.getRecordId()).toBe(createUserId(mockUserPreferences.id))
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
it('getId() still returns the external id', () => {
|
|
310
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
301
311
|
expect(userPreferencesManager.getId()).toBe(mockUserPreferences.id)
|
|
302
312
|
})
|
|
303
313
|
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { atom, computed } from '@tldraw/state'
|
|
2
|
+
import { createUserId, TLUserId } from '@tldraw/tlschema'
|
|
2
3
|
import { TLCurrentUser } from '../../../config/createTLCurrentUser'
|
|
3
4
|
import { TLUserPreferences, defaultUserPreferences } from '../../../config/TLUserPreferences'
|
|
4
5
|
import { getGlobalWindow } from '../../../utils/dom'
|
|
@@ -39,7 +40,7 @@ export class UserPreferencesManager {
|
|
|
39
40
|
}
|
|
40
41
|
@computed getUserPreferences() {
|
|
41
42
|
return {
|
|
42
|
-
id: this.
|
|
43
|
+
id: this.getExternalId(),
|
|
43
44
|
name: this.getName(),
|
|
44
45
|
locale: this.getLocale(),
|
|
45
46
|
color: this.getColor(),
|
|
@@ -89,10 +90,34 @@ export class UserPreferencesManager {
|
|
|
89
90
|
)
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
|
|
93
|
+
/**
|
|
94
|
+
* The current user's raw, app-provided id — the value set in the user's
|
|
95
|
+
* {@link @tldraw/editor#TLUserPreferences}. Use this when you need the id your application
|
|
96
|
+
* assigned to the user. To compare against or look up store records, use
|
|
97
|
+
* {@link UserPreferencesManager.getRecordId} instead.
|
|
98
|
+
*/
|
|
99
|
+
@computed getExternalId(): string {
|
|
93
100
|
return this.user.userPreferences.get().id
|
|
94
101
|
}
|
|
95
102
|
|
|
103
|
+
/**
|
|
104
|
+
* @deprecated Use {@link UserPreferencesManager.getExternalId} for the raw app-provided id, or
|
|
105
|
+
* {@link UserPreferencesManager.getRecordId} for the prefixed `TLUserId` record id.
|
|
106
|
+
*/
|
|
107
|
+
@computed getId() {
|
|
108
|
+
return this.getExternalId()
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The current user's id as a tldraw {@link @tldraw/tlschema#TLUserId} record id (prefixed
|
|
113
|
+
* with `user:`). Use this when comparing against or looking up store records, such as a
|
|
114
|
+
* presence record's `userId` or `followingUserId`. For the raw, app-provided id, use
|
|
115
|
+
* {@link UserPreferencesManager.getExternalId}.
|
|
116
|
+
*/
|
|
117
|
+
@computed getRecordId(): TLUserId {
|
|
118
|
+
return createUserId(this.getExternalId())
|
|
119
|
+
}
|
|
120
|
+
|
|
96
121
|
@computed getName() {
|
|
97
122
|
return this.user.userPreferences.get().name?.trim() ?? defaultUserPreferences.name
|
|
98
123
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createComputedCache } from '@tldraw/store'
|
|
2
|
+
import { TLShape, TLShapeId } from '@tldraw/tlschema'
|
|
3
|
+
import type { Editor } from '../Editor'
|
|
4
|
+
|
|
5
|
+
const indicatorPathCache = createComputedCache(
|
|
6
|
+
'shapeIndicatorPath',
|
|
7
|
+
(editor: Editor, shape: TLShape) => {
|
|
8
|
+
const util = editor.getShapeUtil(shape)
|
|
9
|
+
return util.getIndicatorPath(shape)
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
areRecordsEqual(a, b) {
|
|
13
|
+
return a.props === b.props
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Combine every batchable shape indicator into a single page-space `Path2D` and
|
|
20
|
+
* emit one stroke call. Shapes whose indicator needs an evenodd clip (e.g.
|
|
21
|
+
* arrows with labels or complex arrowheads) can't be batched — they still
|
|
22
|
+
* stroke individually inside a save/restore with `ctx.clip` applied.
|
|
23
|
+
*
|
|
24
|
+
* Shared by any overlay util that paints shape indicators (e.g. collaborator
|
|
25
|
+
* selections).
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export function strokeShapeIndicators(
|
|
30
|
+
editor: Editor,
|
|
31
|
+
ctx: CanvasRenderingContext2D,
|
|
32
|
+
shapeIds: TLShapeId[]
|
|
33
|
+
): void {
|
|
34
|
+
if (shapeIds.length === 0) return
|
|
35
|
+
|
|
36
|
+
const batched = new Path2D()
|
|
37
|
+
|
|
38
|
+
for (const shapeId of shapeIds) {
|
|
39
|
+
const shape = editor.getShape(shapeId)
|
|
40
|
+
if (!shape || shape.isLocked) continue
|
|
41
|
+
|
|
42
|
+
const pageTransform = editor.getShapePageTransform(shape)
|
|
43
|
+
if (!pageTransform) continue
|
|
44
|
+
|
|
45
|
+
const indicatorPath = indicatorPathCache.get(editor, shape.id)
|
|
46
|
+
if (!indicatorPath) continue
|
|
47
|
+
|
|
48
|
+
if (indicatorPath instanceof Path2D) {
|
|
49
|
+
batched.addPath(indicatorPath, pageTransform)
|
|
50
|
+
continue
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const { path, clipPath, additionalPaths } = indicatorPath
|
|
54
|
+
|
|
55
|
+
if (!clipPath) {
|
|
56
|
+
batched.addPath(path, pageTransform)
|
|
57
|
+
if (additionalPaths) {
|
|
58
|
+
for (const p of additionalPaths) batched.addPath(p, pageTransform)
|
|
59
|
+
}
|
|
60
|
+
continue
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Clipped case: fall back to an individual stroke. Rare (arrows with
|
|
64
|
+
// labels / complex arrowheads), so the extra save/restore/stroke
|
|
65
|
+
// pair per such shape isn't worth batching away.
|
|
66
|
+
ctx.save()
|
|
67
|
+
ctx.transform(
|
|
68
|
+
pageTransform.a,
|
|
69
|
+
pageTransform.b,
|
|
70
|
+
pageTransform.c,
|
|
71
|
+
pageTransform.d,
|
|
72
|
+
pageTransform.e,
|
|
73
|
+
pageTransform.f
|
|
74
|
+
)
|
|
75
|
+
ctx.save()
|
|
76
|
+
ctx.clip(clipPath, 'evenodd')
|
|
77
|
+
ctx.stroke(path)
|
|
78
|
+
ctx.restore()
|
|
79
|
+
if (additionalPaths) {
|
|
80
|
+
for (const p of additionalPaths) ctx.stroke(p)
|
|
81
|
+
}
|
|
82
|
+
ctx.restore()
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
ctx.stroke(batched)
|
|
86
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useValue } from '@tldraw/state-react'
|
|
2
|
-
import { TLInstancePresence } from '@tldraw/tlschema'
|
|
2
|
+
import { TLInstancePresence, TLUserId } from '@tldraw/tlschema'
|
|
3
3
|
import { useEditor } from './useEditor'
|
|
4
4
|
|
|
5
5
|
// TODO: maybe move this to a computed property on the App class?
|
|
@@ -7,7 +7,7 @@ import { useEditor } from './useEditor'
|
|
|
7
7
|
* @returns The latest presence of the user matching userId
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
|
-
export function usePresence(userId:
|
|
10
|
+
export function usePresence(userId: TLUserId): TLInstancePresence | null {
|
|
11
11
|
const editor = useEditor()
|
|
12
12
|
|
|
13
13
|
const latestPresence = useValue(
|
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 = '5.2.0-canary.
|
|
4
|
+
export const version = '5.2.0-canary.4e00299c3e28'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2026-05-06T16:28:18.473Z',
|
|
7
|
-
minor: '2026-06-
|
|
8
|
-
patch: '2026-06-
|
|
7
|
+
minor: '2026-06-15T08:32:04.112Z',
|
|
8
|
+
patch: '2026-06-15T08:32:04.112Z',
|
|
9
9
|
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var ShapeIndicatorOverlayUtil_exports = {};
|
|
20
|
-
__export(ShapeIndicatorOverlayUtil_exports, {
|
|
21
|
-
ShapeIndicatorOverlayUtil: () => ShapeIndicatorOverlayUtil,
|
|
22
|
-
strokeShapeIndicators: () => strokeShapeIndicators
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(ShapeIndicatorOverlayUtil_exports);
|
|
25
|
-
var import_state = require("@tldraw/state");
|
|
26
|
-
var import_store = require("@tldraw/store");
|
|
27
|
-
var import_OverlayUtil = require("./OverlayUtil");
|
|
28
|
-
const indicatorPathCache = (0, import_store.createComputedCache)(
|
|
29
|
-
"shapeIndicatorPath",
|
|
30
|
-
(editor, shape) => {
|
|
31
|
-
const util = editor.getShapeUtil(shape);
|
|
32
|
-
return util.getIndicatorPath(shape);
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
areRecordsEqual(a, b) {
|
|
36
|
-
return a.props === b.props;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
);
|
|
40
|
-
function strokeShapeIndicators(editor, ctx, shapeIds) {
|
|
41
|
-
if (shapeIds.length === 0) return;
|
|
42
|
-
const batched = new Path2D();
|
|
43
|
-
for (const shapeId of shapeIds) {
|
|
44
|
-
const shape = editor.getShape(shapeId);
|
|
45
|
-
if (!shape || shape.isLocked) continue;
|
|
46
|
-
const pageTransform = editor.getShapePageTransform(shape);
|
|
47
|
-
if (!pageTransform) continue;
|
|
48
|
-
const indicatorPath = indicatorPathCache.get(editor, shape.id);
|
|
49
|
-
if (!indicatorPath) continue;
|
|
50
|
-
if (indicatorPath instanceof Path2D) {
|
|
51
|
-
batched.addPath(indicatorPath, pageTransform);
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
const { path, clipPath, additionalPaths } = indicatorPath;
|
|
55
|
-
if (!clipPath) {
|
|
56
|
-
batched.addPath(path, pageTransform);
|
|
57
|
-
if (additionalPaths) {
|
|
58
|
-
for (const p of additionalPaths) batched.addPath(p, pageTransform);
|
|
59
|
-
}
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
ctx.save();
|
|
63
|
-
ctx.transform(
|
|
64
|
-
pageTransform.a,
|
|
65
|
-
pageTransform.b,
|
|
66
|
-
pageTransform.c,
|
|
67
|
-
pageTransform.d,
|
|
68
|
-
pageTransform.e,
|
|
69
|
-
pageTransform.f
|
|
70
|
-
);
|
|
71
|
-
ctx.save();
|
|
72
|
-
ctx.clip(clipPath, "evenodd");
|
|
73
|
-
ctx.stroke(path);
|
|
74
|
-
ctx.restore();
|
|
75
|
-
if (additionalPaths) {
|
|
76
|
-
for (const p of additionalPaths) ctx.stroke(p);
|
|
77
|
-
}
|
|
78
|
-
ctx.restore();
|
|
79
|
-
}
|
|
80
|
-
ctx.stroke(batched);
|
|
81
|
-
}
|
|
82
|
-
class ShapeIndicatorOverlayUtil extends import_OverlayUtil.OverlayUtil {
|
|
83
|
-
static type = "shape_indicator";
|
|
84
|
-
options = { zIndex: 50, lineWidth: 1.5, hintedLineWidth: 2.5 };
|
|
85
|
-
// Narrow projection of instance state. Reading the full record would
|
|
86
|
-
// re-fire getOverlays on every cursor move / brush update; gating on these
|
|
87
|
-
// three booleans means we only re-fire when one of them actually flips.
|
|
88
|
-
_instanceFlags$ = (0, import_state.computed)(
|
|
89
|
-
"shape indicator instance flags",
|
|
90
|
-
() => {
|
|
91
|
-
const i = this.editor.getInstanceState();
|
|
92
|
-
return {
|
|
93
|
-
isChangingStyle: i.isChangingStyle,
|
|
94
|
-
isHoveringCanvas: i.isHoveringCanvas,
|
|
95
|
-
isCoarsePointer: i.isCoarsePointer
|
|
96
|
-
};
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
isEqual: (a, b) => a.isChangingStyle === b.isChangingStyle && a.isHoveringCanvas === b.isHoveringCanvas && a.isCoarsePointer === b.isCoarsePointer
|
|
100
|
-
}
|
|
101
|
-
);
|
|
102
|
-
isActive() {
|
|
103
|
-
return true;
|
|
104
|
-
}
|
|
105
|
-
getOverlays() {
|
|
106
|
-
const editor = this.editor;
|
|
107
|
-
const renderingShapeIds = new Set(editor.getRenderingShapes().map((s) => s.id));
|
|
108
|
-
const idsToDisplay = [];
|
|
109
|
-
const { isChangingStyle, isHoveringCanvas, isCoarsePointer } = this._instanceFlags$.get();
|
|
110
|
-
const isIdleOrEditing = editor.isInAny("select.idle", "select.editing_shape");
|
|
111
|
-
const isInSelectState = editor.isInAny(
|
|
112
|
-
"select.brushing",
|
|
113
|
-
"select.scribble_brushing",
|
|
114
|
-
"select.pointing_shape",
|
|
115
|
-
"select.pointing_selection",
|
|
116
|
-
"select.pointing_handle"
|
|
117
|
-
);
|
|
118
|
-
if (!isChangingStyle && (isIdleOrEditing || isInSelectState)) {
|
|
119
|
-
for (const id of editor.getSelectedShapeIds()) {
|
|
120
|
-
if (renderingShapeIds.has(id)) idsToDisplay.push(id);
|
|
121
|
-
}
|
|
122
|
-
if (isIdleOrEditing && isHoveringCanvas && !isCoarsePointer) {
|
|
123
|
-
const hovered = editor.getHoveredShapeId();
|
|
124
|
-
if (hovered && renderingShapeIds.has(hovered) && !idsToDisplay.includes(hovered)) {
|
|
125
|
-
idsToDisplay.push(hovered);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
const hintingShapeIds = [];
|
|
130
|
-
for (const id of editor.getHintingShapeIds()) {
|
|
131
|
-
if (renderingShapeIds.has(id)) hintingShapeIds.push(id);
|
|
132
|
-
}
|
|
133
|
-
if (idsToDisplay.length === 0 && hintingShapeIds.length === 0) {
|
|
134
|
-
return [];
|
|
135
|
-
}
|
|
136
|
-
return [
|
|
137
|
-
{
|
|
138
|
-
id: "shape_indicator",
|
|
139
|
-
type: "shape_indicator",
|
|
140
|
-
props: { idsToDisplay, hintingShapeIds }
|
|
141
|
-
}
|
|
142
|
-
];
|
|
143
|
-
}
|
|
144
|
-
render(ctx, overlays) {
|
|
145
|
-
const overlay = overlays[0];
|
|
146
|
-
if (!overlay) return;
|
|
147
|
-
const editor = this.editor;
|
|
148
|
-
const zoom = editor.getZoomLevel();
|
|
149
|
-
const { idsToDisplay, hintingShapeIds } = overlay.props;
|
|
150
|
-
ctx.lineCap = "round";
|
|
151
|
-
ctx.lineJoin = "round";
|
|
152
|
-
ctx.strokeStyle = editor.getCurrentTheme().colors[editor.getColorMode()].selectionStroke;
|
|
153
|
-
ctx.lineWidth = this.options.lineWidth / zoom;
|
|
154
|
-
strokeShapeIndicators(editor, ctx, idsToDisplay);
|
|
155
|
-
if (hintingShapeIds.length > 0) {
|
|
156
|
-
ctx.lineWidth = this.options.hintedLineWidth / zoom;
|
|
157
|
-
strokeShapeIndicators(editor, ctx, hintingShapeIds);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
//# sourceMappingURL=ShapeIndicatorOverlayUtil.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/lib/editor/overlays/ShapeIndicatorOverlayUtil.ts"],
|
|
4
|
-
"sourcesContent": ["import { computed } from '@tldraw/state'\nimport { createComputedCache } from '@tldraw/store'\nimport { TLShape, TLShapeId } from '@tldraw/tlschema'\nimport type { Editor } from '../Editor'\nimport { OverlayUtil, TLOverlay } from './OverlayUtil'\n\ninterface RelevantInstanceFlags {\n\tisChangingStyle: boolean\n\tisHoveringCanvas: boolean | null\n\tisCoarsePointer: boolean\n}\n\n/** @public */\nexport interface TLShapeIndicatorOverlay extends TLOverlay {\n\tprops: {\n\t\tidsToDisplay: TLShapeId[]\n\t\thintingShapeIds: TLShapeId[]\n\t}\n}\n\nconst indicatorPathCache = createComputedCache(\n\t'shapeIndicatorPath',\n\t(editor: Editor, shape: TLShape) => {\n\t\tconst util = editor.getShapeUtil(shape)\n\t\treturn util.getIndicatorPath(shape)\n\t},\n\t{\n\t\tareRecordsEqual(a, b) {\n\t\t\treturn a.props === b.props\n\t\t},\n\t}\n)\n\n/**\n * Combine every batchable shape indicator into a single page-space `Path2D` and\n * emit one stroke call. Shapes whose indicator needs an evenodd clip (e.g.\n * arrows with labels or complex arrowheads) can't be batched \u2014 they still\n * stroke individually inside a save/restore with `ctx.clip` applied.\n *\n * Shared by {@link ShapeIndicatorOverlayUtil} and any overlay util that paints\n * shape indicators (e.g. collaborator selections).\n *\n * @public\n */\nexport function strokeShapeIndicators(\n\teditor: Editor,\n\tctx: CanvasRenderingContext2D,\n\tshapeIds: TLShapeId[]\n): void {\n\tif (shapeIds.length === 0) return\n\n\tconst batched = new Path2D()\n\n\tfor (const shapeId of shapeIds) {\n\t\tconst shape = editor.getShape(shapeId)\n\t\tif (!shape || shape.isLocked) continue\n\n\t\tconst pageTransform = editor.getShapePageTransform(shape)\n\t\tif (!pageTransform) continue\n\n\t\tconst indicatorPath = indicatorPathCache.get(editor, shape.id)\n\t\tif (!indicatorPath) continue\n\n\t\tif (indicatorPath instanceof Path2D) {\n\t\t\tbatched.addPath(indicatorPath, pageTransform)\n\t\t\tcontinue\n\t\t}\n\n\t\tconst { path, clipPath, additionalPaths } = indicatorPath\n\n\t\tif (!clipPath) {\n\t\t\tbatched.addPath(path, pageTransform)\n\t\t\tif (additionalPaths) {\n\t\t\t\tfor (const p of additionalPaths) batched.addPath(p, pageTransform)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\t// Clipped case: fall back to an individual stroke. Rare (arrows with\n\t\t// labels / complex arrowheads), so the extra save/restore/stroke\n\t\t// pair per such shape isn't worth batching away.\n\t\tctx.save()\n\t\tctx.transform(\n\t\t\tpageTransform.a,\n\t\t\tpageTransform.b,\n\t\t\tpageTransform.c,\n\t\t\tpageTransform.d,\n\t\t\tpageTransform.e,\n\t\t\tpageTransform.f\n\t\t)\n\t\tctx.save()\n\t\tctx.clip(clipPath, 'evenodd')\n\t\tctx.stroke(path)\n\t\tctx.restore()\n\t\tif (additionalPaths) {\n\t\t\tfor (const p of additionalPaths) ctx.stroke(p)\n\t\t}\n\t\tctx.restore()\n\t}\n\n\tctx.stroke(batched)\n}\n\n/**\n * Overlay util for shape indicators \u2014 the selection / hover / hint outlines drawn\n * under the selection foreground. Paints local indicators in the theme's\n * selection color.\n *\n * Remote collaborator selection indicators are drawn by a separate overlay util\n * (e.g. `CollaboratorShapeIndicatorOverlayUtil` from `tldraw`) that runs at a\n * lower z-index so peer selections appear under the local indicators.\n *\n * Non-interactive: contributes no hit-test geometry.\n *\n * @public\n */\nexport class ShapeIndicatorOverlayUtil extends OverlayUtil<TLShapeIndicatorOverlay> {\n\tstatic override type = 'shape_indicator'\n\toverride options = { zIndex: 50, lineWidth: 1.5, hintedLineWidth: 2.5 }\n\n\t// Narrow projection of instance state. Reading the full record would\n\t// re-fire getOverlays on every cursor move / brush update; gating on these\n\t// three booleans means we only re-fire when one of them actually flips.\n\tprivate _instanceFlags$ = computed<RelevantInstanceFlags>(\n\t\t'shape indicator instance flags',\n\t\t() => {\n\t\t\tconst i = this.editor.getInstanceState()\n\t\t\treturn {\n\t\t\t\tisChangingStyle: i.isChangingStyle,\n\t\t\t\tisHoveringCanvas: i.isHoveringCanvas,\n\t\t\t\tisCoarsePointer: i.isCoarsePointer,\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\tisEqual: (a, b) =>\n\t\t\t\ta.isChangingStyle === b.isChangingStyle &&\n\t\t\t\ta.isHoveringCanvas === b.isHoveringCanvas &&\n\t\t\t\ta.isCoarsePointer === b.isCoarsePointer,\n\t\t}\n\t)\n\n\toverride isActive(): boolean {\n\t\treturn true\n\t}\n\n\toverride getOverlays(): TLShapeIndicatorOverlay[] {\n\t\tconst editor = this.editor\n\t\tconst renderingShapeIds = new Set(editor.getRenderingShapes().map((s) => s.id))\n\n\t\t// Local selected / hovered indicators.\n\t\tconst idsToDisplay: TLShapeId[] = []\n\t\tconst { isChangingStyle, isHoveringCanvas, isCoarsePointer } = this._instanceFlags$.get()\n\t\tconst isIdleOrEditing = editor.isInAny('select.idle', 'select.editing_shape')\n\t\tconst isInSelectState = editor.isInAny(\n\t\t\t'select.brushing',\n\t\t\t'select.scribble_brushing',\n\t\t\t'select.pointing_shape',\n\t\t\t'select.pointing_selection',\n\t\t\t'select.pointing_handle'\n\t\t)\n\n\t\tif (!isChangingStyle && (isIdleOrEditing || isInSelectState)) {\n\t\t\tfor (const id of editor.getSelectedShapeIds()) {\n\t\t\t\tif (renderingShapeIds.has(id)) idsToDisplay.push(id)\n\t\t\t}\n\t\t\tif (isIdleOrEditing && isHoveringCanvas && !isCoarsePointer) {\n\t\t\t\tconst hovered = editor.getHoveredShapeId()\n\t\t\t\tif (hovered && renderingShapeIds.has(hovered) && !idsToDisplay.includes(hovered)) {\n\t\t\t\t\tidsToDisplay.push(hovered)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Hinted shapes (drawn thicker). Already deduped at write time in\n\t\t// `updateHintingShapeIds`, so no need to dedupe again here.\n\t\tconst hintingShapeIds: TLShapeId[] = []\n\t\tfor (const id of editor.getHintingShapeIds()) {\n\t\t\tif (renderingShapeIds.has(id)) hintingShapeIds.push(id)\n\t\t}\n\n\t\tif (idsToDisplay.length === 0 && hintingShapeIds.length === 0) {\n\t\t\treturn []\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tid: 'shape_indicator',\n\t\t\t\ttype: 'shape_indicator',\n\t\t\t\tprops: { idsToDisplay, hintingShapeIds },\n\t\t\t},\n\t\t]\n\t}\n\n\toverride render(ctx: CanvasRenderingContext2D, overlays: TLShapeIndicatorOverlay[]): void {\n\t\tconst overlay = overlays[0]\n\t\tif (!overlay) return\n\n\t\tconst editor = this.editor\n\t\tconst zoom = editor.getZoomLevel()\n\t\tconst { idsToDisplay, hintingShapeIds } = overlay.props\n\n\t\tctx.lineCap = 'round'\n\t\tctx.lineJoin = 'round'\n\n\t\t// Local selected / hovered indicators \u2014 one stroke call for the whole batch.\n\t\tctx.strokeStyle = editor.getCurrentTheme().colors[editor.getColorMode()].selectionStroke\n\t\tctx.lineWidth = this.options.lineWidth / zoom\n\t\tstrokeShapeIndicators(editor, ctx, idsToDisplay)\n\n\t\t// Hinted shapes \u2014 thicker stroke, one call for the whole batch.\n\t\tif (hintingShapeIds.length > 0) {\n\t\t\tctx.lineWidth = this.options.hintedLineWidth / zoom\n\t\t\tstrokeShapeIndicators(editor, ctx, hintingShapeIds)\n\t\t}\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAyB;AACzB,mBAAoC;AAGpC,yBAAuC;AAgBvC,MAAM,yBAAqB;AAAA,E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