[feature] unlock all action (#1820)

This PR adds an "Unlock all" action to the edit menu. 

- Selecting `unlock all` sets `isLocked` to false for all shapes on the
current page
- The option is disabled if the page is empty; but we don't check
whether there are locked shapes on the page (juice < squeeze)

Closes https://github.com/tldraw/tldraw/issues/1809

### Change Type

- [x] `minor` — New feature

### Test Plan

1. Create locked shapes
2. Select menu > edit > unlock all

### Release Notes

- Adds the unlock all feature.
pull/1819/head^2
Steve Ruiz 2023-08-24 14:25:04 +02:00 zatwierdzone przez GitHub
rodzic df9f4254c4
commit af573bac51
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
7 zmienionych plików z 24 dodań i 2 usunięć

Wyświetl plik

@ -22,6 +22,7 @@
"action.copy": "Copy",
"action.cut": "Cut",
"action.delete": "Delete",
"action.unlock-all": "Unlock all",
"action.distribute-horizontal": "Distribute horizontally",
"action.distribute-vertical": "Distribute vertically",
"action.distribute-horizontal.short": "Distribute H",

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -859,6 +859,23 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
},
checkbox: true,
},
{
id: 'unlock-all',
label: 'action.unlock-all',
readonlyOk: false,
onSelect(source) {
trackEvent('unlock-all', { source })
const updates = [] as TLShapePartial[]
for (const shape of editor.currentPageShapes) {
if (shape.isLocked) {
updates.push({ id: shape.id, type: shape.type, isLocked: false })
}
}
if (updates.length > 0) {
editor.updateShapes(updates)
}
},
},
{
id: 'toggle-focus-mode',
label: 'action.toggle-focus-mode',

Wyświetl plik

@ -83,6 +83,7 @@ export interface TLUiEventMap {
'stop-following': null
'open-cursor-chat': null
'zoom-tool': null
'unlock-all': null
}
type Join<T, K> = K extends null

Wyświetl plik

@ -172,7 +172,8 @@ export function TLUiMenuSchemaProvider({ overrides, children }: TLUiMenuSchemaPr
showEditLink && menuItem(actions['edit-link']),
menuItem(actions['duplicate'], { disabled: !oneSelected }),
allowGroup && menuItem(actions['group']),
allowUngroup && menuItem(actions['ungroup'])
allowUngroup && menuItem(actions['ungroup']),
menuItem(actions['unlock-all'], { disabled: emptyPage })
),
menuGroup('delete-group', menuItem(actions['delete'], { disabled: !oneSelected })),
menuGroup(

Wyświetl plik

@ -26,6 +26,7 @@ export type TLUiTranslationKey =
| 'action.copy'
| 'action.cut'
| 'action.delete'
| 'action.unlock-all'
| 'action.distribute-horizontal'
| 'action.distribute-vertical'
| 'action.distribute-horizontal.short'

Wyświetl plik

@ -26,6 +26,7 @@ export const DEFAULT_TRANSLATION = {
'action.copy': 'Copy',
'action.cut': 'Cut',
'action.delete': 'Delete',
'action.unlock-all': 'Unlock all',
'action.distribute-horizontal': 'Distribute horizontally',
'action.distribute-vertical': 'Distribute vertically',
'action.distribute-horizontal.short': 'Distribute H',