Don't allow `g` keyboard shortcut in readonly mode, show laser tool in the toolbar (#1459)

Disable `g` keyboard shortcut in readonly mode. Show laser tool in
toolbar when in readonly mode.

Resolves [#1936](https://github.com/tldraw/brivate/issues/1936)
Resolves [#1935](https://github.com/tldraw/brivate/issues/1935)

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

1. Open a readonly room.
2. Press `g` and make sure it doesn't switch to it.
3. Laser tool should be visible in the toolbar in readonly rooms.


### Release Notes

- Disable geo tool shortcut in readonly mode. Show laser on the toolbar.

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
pull/1450/head
Mitja Bezenšek 2023-05-25 21:08:52 +02:00 zatwierdzone przez GitHub
rodzic d22542bc55
commit 042edeb4b4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
5 zmienionych plików z 15 dodań i 2 usunięć

Wyświetl plik

@ -81,6 +81,7 @@ export async function sleep(ms: number) {
export async function clearClipboard() {
return await browser.execute(async () => {
if (!(navigator && navigator.clipboard)) return
if (navigator.clipboard.write) {
await navigator.clipboard.write([
new ClipboardItem({

Wyświetl plik

@ -28,6 +28,7 @@ export const Toolbar = function Toolbar() {
const isReadOnly = useReadonly()
const toolbarItems = useToolbarSchema()
const laserTool = toolbarItems.find((item) => item.toolItem.id === 'laser')
const activeToolId = useValue('current tool id', () => app.currentToolId, [app])
@ -142,6 +143,14 @@ export const Toolbar = function Toolbar() {
/>
)
})}
{isReadOnly && laserTool && (
<ToolbarButton
key={laserTool.toolItem.id}
item={laserTool.toolItem}
title={getTitle(laserTool.toolItem)}
isSelected={isActiveToolItem(laserTool.toolItem, activeToolId, geoState)}
/>
)}
{showEditingTools && (
<>
{/* Draw / Eraser */}

Wyświetl plik

@ -479,7 +479,9 @@ async function handleClipboardThings(app: App, things: ClipboardThing[], point?:
const handleNativeOrMenuCopy = (app: App) => {
const content = app.getContent()
if (!content) {
window.navigator.clipboard.writeText('')
if (navigator && navigator.clipboard) {
navigator.clipboard.writeText('')
}
return
}

Wyświetl plik

@ -144,5 +144,6 @@ async function getExportedImageBlob(app: App, ids: TLShapeId[], format: 'png' |
}
async function fallbackWriteTextAsync(getText: () => Promise<string>) {
if (!(navigator && navigator.clipboard)) return
navigator.clipboard.writeText(await getText())
}

Wyświetl plik

@ -66,7 +66,7 @@ export function useKeyboardShortcuts() {
// todo: move these into the actions themselves and make the UI only display the first one
hot('g', () => {
if (areShortcutsDisabled()) return
if (areShortcutsDisabled() || app.isReadOnly) return
app.setSelectedTool('geo')
})