File tree Expand file tree Collapse file tree
libs/@hashintel/petrinaut/src/clipboard Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,7 +19,11 @@ export async function copySelectionToClipboard(
1919) : Promise < void > {
2020 const payload = serializeSelection ( sdcpn , selection , documentId ) ;
2121 const json = JSON . stringify ( payload ) ;
22- await navigator . clipboard . writeText ( json ) ;
22+ try {
23+ await navigator . clipboard . writeText ( json ) ;
24+ } catch {
25+ // Clipboard write can fail (permissions denied, non-secure context, etc.)
26+ }
2327}
2428
2529/**
@@ -30,7 +34,13 @@ export async function copySelectionToClipboard(
3034export async function pasteFromClipboard (
3135 mutatePetriNetDefinition : ( mutateFn : ( sdcpn : SDCPN ) => void ) => void ,
3236) : Promise < Array < { type : string ; id : string } > | null > {
33- const text = await navigator . clipboard . readText ( ) ;
37+ let text : string ;
38+ try {
39+ text = await navigator . clipboard . readText ( ) ;
40+ } catch {
41+ // Clipboard read can fail (permissions denied, non-secure context, etc.)
42+ return null ;
43+ }
3444 const payload = parseClipboardPayload ( text ) ;
3545
3646 if ( ! payload ) {
You can’t perform that action at this time.
0 commit comments