examples: let people copy out code (#2920)

### Change Type

- [x] `internal` — Any other changes that don't affect the published
package[^2]
This commit is contained in:
Mime Čuvalo 2024-02-22 12:36:03 +00:00 committed by GitHub
parent e15c9f12bb
commit 07f58b6885
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 3 deletions

View file

@ -48,6 +48,7 @@ export default function CanvasEventsExample() {
overflow: 'auto',
whiteSpace: 'pre-wrap',
}}
onCopy={(event) => event.stopPropagation()}
>
<div>{JSON.stringify(events, undefined, 2)}</div>
</div>

View file

@ -92,6 +92,7 @@ export default function StoreEventsExample() {
flexDirection: 'column-reverse',
overflow: 'auto',
}}
onCopy={(event) => event.stopPropagation()}
>
<pre>{storeEvents}</pre>
</div>

View file

@ -11,8 +11,8 @@ export default function UiEventsExample() {
const handleUiEvent = useCallback<TLUiEventHandler>((name, data: any) => {
const codeSnippet = getCodeSnippet(name, data)
setUiEvents((events) => [
`event: ${name} ${JSON.stringify(data)}${codeSnippet && `\ncode: ${codeSnippet}`}`,
...events,
`event: ${name} ${JSON.stringify(data)}${codeSnippet && `\ncode: ${codeSnippet}`}`,
])
}, [])
@ -31,10 +31,9 @@ export default function UiEventsExample() {
fontFamily: 'monospace',
fontSize: 12,
borderLeft: 'solid 2px #333',
display: 'flex',
flexDirection: 'column-reverse',
overflow: 'auto',
}}
onCopy={(event) => event.stopPropagation()}
>
{uiEvents.map((t, i) => (
<Fragment key={i}>