@@ -27,7 +27,7 @@ const PreviewInner = styled(Box)`
2727
2828export interface PreviewCodeProps {
2929 type ?: CodeInputType
30- value ?: CodeInputValue
30+ value ?: { selection ?: CodeInputValue }
3131}
3232
3333export default function PreviewCode ( props : PreviewCodeProps ) {
@@ -52,14 +52,15 @@ export default function PreviewCode(props: PreviewCodeProps) {
5252 const { value, type} = props
5353 const fixedLanguage = type ?. options ?. language
5454
55- const mode = value ?. language || fixedLanguage || 'text'
56- const AceEditor = useAceEditor ( )
55+ const selection = value ?. selection
56+ const mode = selection ?. language || fixedLanguage || 'text'
5757
58+ const AceEditor = useAceEditor ( )
5859 return (
5960 < PreviewContainer >
6061 < PreviewInner padding = { 4 } >
6162 { AceEditor && (
62- < Suspense fallback = { < div > Loading code editor ...</ div > } >
63+ < Suspense fallback = { < div > Loading code preview ...</ div > } >
6364 < AceEditor
6465 ref = { aceEditorRef }
6566 focus = { false }
@@ -73,10 +74,10 @@ export default function PreviewCode(props: PreviewCodeProps) {
7374 showPrintMargin = { false }
7475 highlightActiveLine = { false }
7576 cursorStart = { - 1 }
76- value = { ( value && value . code ) || '' }
77+ value = { selection ? .code || '' }
7778 markers = {
78- value && value . highlightedLines
79- ? createHighlightMarkers ( value . highlightedLines )
79+ selection ? .highlightedLines
80+ ? createHighlightMarkers ( selection . highlightedLines )
8081 : undefined
8182 }
8283 tabSize = { 2 }
0 commit comments