diff --git a/e2e/test/helpers/util.ts b/e2e/test/helpers/util.ts
index 30f3c156ce5..3ea62184542 100644
--- a/e2e/test/helpers/util.ts
+++ b/e2e/test/helpers/util.ts
@@ -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({
diff --git a/packages/ui/src/lib/components/Toolbar/Toolbar.tsx b/packages/ui/src/lib/components/Toolbar/Toolbar.tsx
index 5cc7cb1fcb6..29f93c95e17 100644
--- a/packages/ui/src/lib/components/Toolbar/Toolbar.tsx
+++ b/packages/ui/src/lib/components/Toolbar/Toolbar.tsx
@@ -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 && (
+
+ )}
{showEditingTools && (
<>
{/* Draw / Eraser */}
diff --git a/packages/ui/src/lib/hooks/useClipboardEvents.ts b/packages/ui/src/lib/hooks/useClipboardEvents.ts
index 0b4bac36daf..731fb68cf9a 100644
--- a/packages/ui/src/lib/hooks/useClipboardEvents.ts
+++ b/packages/ui/src/lib/hooks/useClipboardEvents.ts
@@ -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
}
diff --git a/packages/ui/src/lib/hooks/useCopyAs.ts b/packages/ui/src/lib/hooks/useCopyAs.ts
index 9dfb804acd1..934e3742c92 100644
--- a/packages/ui/src/lib/hooks/useCopyAs.ts
+++ b/packages/ui/src/lib/hooks/useCopyAs.ts
@@ -144,5 +144,6 @@ async function getExportedImageBlob(app: App, ids: TLShapeId[], format: 'png' |
}
async function fallbackWriteTextAsync(getText: () => Promise) {
+ if (!(navigator && navigator.clipboard)) return
navigator.clipboard.writeText(await getText())
}
diff --git a/packages/ui/src/lib/hooks/useKeyboardShortcuts.ts b/packages/ui/src/lib/hooks/useKeyboardShortcuts.ts
index 8bfcf461897..35b821b9bae 100644
--- a/packages/ui/src/lib/hooks/useKeyboardShortcuts.ts
+++ b/packages/ui/src/lib/hooks/useKeyboardShortcuts.ts
@@ -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')
})