mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2025-01-10 16:29:12 +08:00
fix: jsx-explorer default text value error
This commit is contained in:
parent
b2d0394281
commit
4c858a26e4
@ -4,7 +4,7 @@ import * as m from 'monaco-editor';
|
||||
import { watchEffect } from 'vue';
|
||||
import { transform } from '@babel/core';
|
||||
import babelPluginJsx from '../../babel-plugin-jsx/src';
|
||||
import { initOptions, compilerOptions } from './options';
|
||||
import { initOptions, compilerOptions, VueJSXPluginOptions } from './options';
|
||||
import './index.css';
|
||||
|
||||
declare global {
|
||||
@ -14,9 +14,22 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
interface PersistedState {
|
||||
src: string
|
||||
options: VueJSXPluginOptions
|
||||
}
|
||||
|
||||
window.init = () => {
|
||||
const { monaco } = window;
|
||||
|
||||
const persistedState: PersistedState = JSON.parse(
|
||||
decodeURIComponent(window.location.hash.slice(1))
|
||||
|| localStorage.getItem('state')
|
||||
|| '{}',
|
||||
);
|
||||
|
||||
Object.assign(compilerOptions, persistedState.options);
|
||||
|
||||
const sharedEditorOptions: m.editor.IStandaloneEditorConstructionOptions = {
|
||||
theme: 'vs-dark',
|
||||
fontSize: 14,
|
||||
@ -37,7 +50,7 @@ window.init = () => {
|
||||
});
|
||||
|
||||
const editor = monaco.editor.create(document.getElementById('source')!, {
|
||||
value: decodeURIComponent(window.location.hash.slice(1)) || localStorage.getItem('state') || 'const App = () => <div>Hello World</div>',
|
||||
value: decodeURIComponent(window.location.hash.slice(1)) || persistedState.src || 'const App = () => <div>Hello World</div>',
|
||||
language: 'typescript',
|
||||
tabSize: 2,
|
||||
...sharedEditorOptions,
|
||||
|
@ -3,6 +3,8 @@ import {
|
||||
} from 'vue';
|
||||
import { VueJSXPluginOptions } from '../../babel-plugin-jsx/src';
|
||||
|
||||
export { VueJSXPluginOptions };
|
||||
|
||||
export const compilerOptions: VueJSXPluginOptions = reactive({
|
||||
mergeProps: true,
|
||||
optimize: false,
|
||||
|
Loading…
Reference in New Issue
Block a user