fix default to hand tool

This commit is contained in:
Jeff Emmett 2024-11-27 13:38:54 +07:00
parent 6079f0ad15
commit 45ddffbde3
2 changed files with 11 additions and 23 deletions

View File

@ -95,6 +95,7 @@ export function Board() {
onSelect: () => {
if (editor.getSelectedShapeIds().length > 0) {
zoomToSelection(editor);
editor.setCurrentTool('hand');
}
},
readonlyOk: true,
@ -110,6 +111,7 @@ export function Board() {
url.searchParams.set('y', camera.y.toString());
url.searchParams.set('zoom', camera.z.toString());
navigator.clipboard.writeText(url.toString());
editor.setCurrentTool('hand');
},
readonlyOk: true,
},
@ -119,6 +121,7 @@ export function Board() {
kbd: 'b',
onSelect: () => {
revertCamera();
editor.setCurrentTool('hand');
},
readonlyOk: true,
},

View File

@ -310,8 +310,9 @@ export const uiOverrides: TLUiOverrides = {
label: 'Revert Camera',
kbd: 'b',
onSelect: () => {
console.log('Reverting camera position');
revertCamera(editor);
if (cameraHistory.length > 0) {
revertCamera(editor);
}
},
readonlyOk: true,
}
@ -387,8 +388,11 @@ export const components: TLComponents = {
label="Revert Camera"
icon="undo"
kbd="b"
disabled={!hasCameraHistory}
onSelect={() => revertCamera(editor)}
onSelect={() => {
if (hasCameraHistory) {
revertCamera(editor);
}
}}
/>
{/* Shape Creation Tools */}
@ -419,25 +423,6 @@ export const components: TLComponents = {
editor.setCurrentTool('Embed');
}}
/>
Frame-specific actions
{isFrame && (
<>
<TldrawUiMenuItem
id="copy-frame-link"
label="Copy Frame Link"
icon="link"
onSelect={() => copyFrameLink(editor, selectedShape.id)}
/>
<TldrawUiMenuItem
id="zoom-to-frame"
label="Zoom to Frame"
icon="zoom-in"
onSelect={() => zoomToSelection(editor)}
/>
</>
)}
</DefaultContextMenu>
)
},