@@ -82,13 +82,21 @@ export function ThemeEditorPage() {
8282 )
8383
8484 const copyThemeObject = async ( ) => {
85- await copyTextToClipboard ( buildThemeObjectSnippet ( theme ) )
86- notify ( 'Copied theme object to clipboard' , { id : 'theme-copy' } )
85+ try {
86+ await copyTextToClipboard ( buildThemeObjectSnippet ( theme ) )
87+ notify ( 'Copied theme object to clipboard' , { id : 'theme-copy' } )
88+ } catch {
89+ notify ( 'Failed to copy theme object' , { id : 'theme-copy' } )
90+ }
8791 }
8892
8993 const copyAgentPrompt = async ( ) => {
90- await copyTextToClipboard ( buildAgentPrompt ( theme ) )
91- notify ( 'Copied AI prompt to clipboard' , { id : 'theme-copy-prompt' } )
94+ try {
95+ await copyTextToClipboard ( buildAgentPrompt ( theme ) )
96+ notify ( 'Copied AI prompt to clipboard' , { id : 'theme-copy-prompt' } )
97+ } catch {
98+ notify ( 'Failed to copy AI prompt' , { id : 'theme-copy-prompt' } )
99+ }
92100 }
93101
94102 return (
@@ -173,10 +181,11 @@ export function ThemeEditorPage() {
173181 ) ) }
174182
175183 < div className = "flex flex-wrap gap-2" >
176- < Button variant = "secondary " size = "sm" onClick = { copyThemeObject } >
184+ < Button variant = "ghost " size = "sm" onClick = { copyThemeObject } >
177185 Copy theme object
178186 </ Button >
179- < Button variant = "ghost" size = "sm" onClick = { copyAgentPrompt } >
187+
188+ < Button variant = "secondary" size = "sm" onClick = { copyAgentPrompt } >
180189 Copy AI prompt
181190 </ Button >
182191 </ div >
@@ -272,16 +281,16 @@ function normalizeHex(value: string) {
272281function buildThemeObjectSnippet ( theme : HighlightTheme ) {
273282 const identifier = toThemeIdentifier ( theme . name )
274283 const tokenLines = themeTokenClasses
275- . map ( ( token ) => ` '${ token } ': ' ${ theme . tokens [ token ] } ' ,` )
284+ . map ( ( token ) => ` '${ token } ': ${ JSON . stringify ( theme . tokens [ token ] ) } ,` )
276285 . join ( '\n' )
277286
278287 return `import type { HighlightTheme } from '@tanstack/highlight/theme'
279288
280289export const ${ identifier } = {
281- name: ' ${ theme . name } ' ,
282- type: ' ${ theme . type } ' ,
283- background: ' ${ theme . background } ' ,
284- foreground: ' ${ theme . foreground } ' ,
290+ name: ${ JSON . stringify ( theme . name ) } ,
291+ type: ${ JSON . stringify ( theme . type ) } ,
292+ background: ${ JSON . stringify ( theme . background ) } ,
293+ foreground: ${ JSON . stringify ( theme . foreground ) } ,
285294 tokens: {
286295${ tokenLines }
287296 },
0 commit comments