feat(draw): lock shape

This commit is contained in:
alt1o
2022-07-28 18:56:39 +08:00
parent 5a78afceb2
commit fbce0e11dc
7 changed files with 170 additions and 1 deletions

View File

@@ -3577,6 +3577,24 @@ export class TldrawApp extends StateManager<TDSnapshot> {
);
};
lock = (ids = this.selectedIds): this => {
if (ids.length === 0) {
return this;
}
return this.set_state(
this.commands.setShapesLockStatus(this, ids, true)
);
};
unlock = (ids = this.selectedIds): this => {
if (ids.length === 0) {
return this;
}
return this.set_state(
this.commands.setShapesLockStatus(this, ids, false)
);
};
/**
* Toggle the fixed-aspect-ratio property of one or more shapes.
* @param ids The ids to change (defaults to selection).

View File

@@ -102,4 +102,9 @@ export interface Commands {
updates: ({ id: string } & Partial<TDShape>)[],
pageId: string
): TldrawCommand;
setShapesLockStatus(
app: TldrawApp,
ids: string[],
isLocked: boolean
): TldrawCommand;
}