Closed Blackman99 closed 1 year ago
Thanks for api adjustments suggestion. I've changed the origin api to suggested previewOptions
But there is still a problem:
If I merge the import code with the app use code (use the previewOptions.customCode
option) like this:
const App = {
setup() {
const store = new ReplStore()
store.setImportMap({
imports: {
"casual-ui-vue":
"https://unpkg.com/casual-ui-vue/dist/casual-ui-vue.es.js",
},
});
return () =>
h(Repl, {
store,
previewOptions: {
headHTML: '<link rel="stylesheet" href="https://unpkg.com/casual-ui-vue/dist/style.css">',
customCode: `import CUI from 'casual-ui-vue; app.use(CUI)`
}
});
}
}
somehow the repl shows an error message: Unexpected Identifier which points to the import statement:
The error only disappeared when I separate them.
Based on that I changed the previewOptions.customCode
to previewOptions.customCode.importCode
and previewOptions.customCode.useCode
Here's my changed commit, in the test/main.ts, has some code I've used to test the feature, using a components lib write by myself: Casual UI
in the test/main.ts
const App = {
setup() {
const store = new ReplStore()
store.setImportMap({
imports: {
"casual-ui-vue":
"https://unpkg.com/casual-ui-vue/dist/casual-ui-vue.es.js",
},
});
return () =>
h(Repl, {
store,
previewOptions: {
headHTML:
'<link rel="stylesheet" href="https://unpkg.com/casual-ui-vue/dist/style.css">',
customCode: {
importCode: `import CUI from 'casual-ui-vue'`,
useCode: 'app.use(CUI)'
}
}
});
}
}
In the repl, write some code like this would work as expected:
<script setup>
import { ref } from 'vue'
const msg = ref('Hello World!')
</script>
<template>
<c-button :label="msg" />
</template>
Why hasn't this feature been merged yet? I believe it could be very useful. Is there any default feature that allows us to accomplish this?
๐๐๐๐๐๐๐๐พ๐พ๐๐
ๅฆไฝๅจ็ผ่ฏ้ถๆฎต๏ผๅฐฑๆui็ปไปถ็ป็ผ่ฏไบๅข๏ผ
Support for customize some sandbox features
<link ref="stylesheet" href="custom/css/file">
import SomePlugin/GlobalComponent from 'customLib'
app.use(SomePlugin)
,app.component('CompName', GlobalComponent)
Example for global use ElementPlus
Then in the repl editor, you can use any ElementPlus Components
This PR can possibly solve issue (#41)