File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
packages/jsx-explorer/src Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import * as m from 'monaco-editor';
44import { watchEffect } from 'vue' ;
55import { transform } from '@babel/core' ;
66import babelPluginJsx from '../../babel-plugin-jsx/src' ;
7- import { initOptions , compilerOptions } from './options' ;
7+ import { initOptions , compilerOptions , VueJSXPluginOptions } from './options' ;
88import './index.css' ;
99
1010declare global {
@@ -14,9 +14,22 @@ declare global {
1414 }
1515}
1616
17+ interface PersistedState {
18+ src : string
19+ options : VueJSXPluginOptions
20+ }
21+
1722window . init = ( ) => {
1823 const { monaco } = window ;
1924
25+ const persistedState : PersistedState = JSON . parse (
26+ decodeURIComponent ( window . location . hash . slice ( 1 ) )
27+ || localStorage . getItem ( 'state' )
28+ || '{}' ,
29+ ) ;
30+
31+ Object . assign ( compilerOptions , persistedState . options ) ;
32+
2033 const sharedEditorOptions : m . editor . IStandaloneEditorConstructionOptions = {
2134 theme : 'vs-dark' ,
2235 fontSize : 14 ,
@@ -37,7 +50,7 @@ window.init = () => {
3750 } ) ;
3851
3952 const editor = monaco . editor . create ( document . getElementById ( 'source' ) ! , {
40- value : decodeURIComponent ( window . location . hash . slice ( 1 ) ) || localStorage . getItem ( 'state' ) || 'const App = () => <div>Hello World</div>' ,
53+ value : decodeURIComponent ( window . location . hash . slice ( 1 ) ) || persistedState . src || 'const App = () => <div>Hello World</div>' ,
4154 language : 'typescript' ,
4255 tabSize : 2 ,
4356 ...sharedEditorOptions ,
Original file line number Diff line number Diff line change 33} from 'vue' ;
44import { VueJSXPluginOptions } from '../../babel-plugin-jsx/src' ;
55
6+ export { VueJSXPluginOptions } ;
7+
68export const compilerOptions : VueJSXPluginOptions = reactive ( {
79 mergeProps : true ,
810 optimize : false ,
You can’t perform that action at this time.
0 commit comments