fix: lock/unlock elements in frames
This commit is contained in:
parent
18a7b97515
commit
c9af72e2ee
@ -10,17 +10,12 @@ const shouldLock = (elements: readonly ExcalidrawElement[]) =>
|
||||
export const actionToggleElementLock = register({
|
||||
name: "toggleElementLock",
|
||||
trackEvent: { category: "element" },
|
||||
predicate: (elements, appState, _, app) => {
|
||||
const selectedElements = app.scene.getSelectedElements(appState);
|
||||
return !selectedElements.some(
|
||||
(element) => element.locked && element.frameId,
|
||||
);
|
||||
},
|
||||
perform: (elements, appState, _, app) => {
|
||||
// Frames and their children should not be selected at the same time.
|
||||
// Therefore, there's no need to include elements in frame in the selection.
|
||||
const selectedElements = app.scene.getSelectedElements({
|
||||
selectedElementIds: appState.selectedElementIds,
|
||||
includeBoundTextElement: true,
|
||||
includeElementsInFrames: true,
|
||||
});
|
||||
|
||||
if (!selectedElements.length) {
|
||||
@ -31,7 +26,11 @@ export const actionToggleElementLock = register({
|
||||
const selectedElementsMap = arrayToMap(selectedElements);
|
||||
return {
|
||||
elements: elements.map((element) => {
|
||||
if (!selectedElementsMap.has(element.id)) {
|
||||
if (
|
||||
!selectedElementsMap.has(element.id) &&
|
||||
element.frameId &&
|
||||
!selectedElementsMap.has(element.frameId)
|
||||
) {
|
||||
return element;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user