kopia lustrzana https://github.com/Tldraw/Tldraw
Fix stuck bindings
rodzic
e98edef97d
commit
ab619385f3
|
@ -3,7 +3,7 @@ import type { Data, TLDrawCommand, PagePartial } from '~types'
|
|||
|
||||
// - [x] Delete shapes
|
||||
// - [x] Delete bindings too
|
||||
// - [ ] Delete bound shapes (arrows)
|
||||
// - [x] Delete bound shapes (arrows)
|
||||
// - [ ] Update parents and possibly delete parents
|
||||
|
||||
export function deleteShapes(data: Data, ids: string[]): TLDrawCommand {
|
||||
|
|
|
@ -44,7 +44,7 @@ export class ArrowSession implements Session {
|
|||
}
|
||||
}
|
||||
|
||||
start = (data: Data) => data
|
||||
start = () => void null
|
||||
|
||||
update = (data: Data, point: number[], shiftKey: boolean, altKey: boolean, metaKey: boolean) => {
|
||||
const page = TLDR.getPage(data, data.appState.currentPageId)
|
||||
|
@ -73,13 +73,15 @@ export class ArrowSession implements Session {
|
|||
{ delta, shiftKey, altKey, metaKey }
|
||||
)
|
||||
|
||||
if (!change) return data
|
||||
// If the handle changed produced no change, bail here
|
||||
if (!change) return
|
||||
|
||||
let nextBindings: Record<string, TLDrawBinding> = { ...page.bindings }
|
||||
let nextBindings: Record<string, TLDrawBinding> = page.bindings
|
||||
|
||||
let nextShape = { ...shape, ...change }
|
||||
|
||||
if (handle.canBind) {
|
||||
nextBindings = { ...nextBindings }
|
||||
let nextBinding: ArrowBinding | undefined = undefined
|
||||
let nextTarget: TLDrawShape | undefined = undefined
|
||||
|
||||
|
@ -137,15 +139,16 @@ export class ArrowSession implements Session {
|
|||
// If we didn't find a target...
|
||||
if (nextBinding === undefined) {
|
||||
this.didBind = false
|
||||
|
||||
if (handle.bindingId) {
|
||||
delete nextBindings[handle.bindingId]
|
||||
nextBindings[handle.bindingId] = undefined as any
|
||||
}
|
||||
nextShape.handles[handleId].bindingId = undefined
|
||||
} else if (nextTarget) {
|
||||
this.didBind = true
|
||||
|
||||
if (handle.bindingId && handle.bindingId !== this.newBindingId) {
|
||||
delete nextBindings[handle.bindingId]
|
||||
nextBindings[handle.bindingId] = undefined as any
|
||||
nextShape.handles[handleId].bindingId = undefined
|
||||
}
|
||||
|
||||
|
|
|
@ -698,7 +698,9 @@ export class TLDrawState extends StateManager<Data> {
|
|||
|
||||
startSession<T extends Session>(session: T, ...args: ParametersExceptFirst<T['start']>): this {
|
||||
this.session = session
|
||||
|
||||
const result = session.start(this.state, ...args)
|
||||
|
||||
if (result) {
|
||||
return this.patchState(
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue