Config
Options
You can pass these options to the plugin:
PlaygroundGlobalOptionsPlayground options.
See also: Playground.
(BuiltInPlaygroundPreset | PlaygroundOptions)[]Playground presets. BuiltInPlaygroundPreset is one of "ts", "vue" and "unocss", which enables a built-in preset, while an object configures a custom playground.
stringPlayground container name.
string"Playground"Playground component name.
(data: PlaygroundData) => Record<string, string>Props getter. Its data argument has the following types:
interface PlaygroundCodeConfig {
/**
* Code block extension
*
* @description It's based on filename, not code fence language
*/
ext: string;
/** Code block content */
content: string;
}
interface PlaygroundData {
/** Title of Playground */
title?: string;
/**
* Import map file name
*
* @default "import-map.json"
*/
importMap?: string;
/** Playground files info */
files: Record<
/** File name */
string,
/** File detail */
PlaygroundCodeConfig
>;
/**
* Playground settings
*
* @description It's parsed result of json content after setting directive
*/
settings: Record<string, unknown>;
/** hash key based on playground content */
key: string;
}{ ts?: TSPresetPlaygroundOptions; vue?: VuePresetPlaygroundOptions; unocss?: UnoPresetPlaygroundOptions }Playground config of the built-in presets.
TSPresetPlaygroundOptionsOptions of the ts preset.
string"https://www.typescriptlang.org/play"External playground service url.
VuePresetPlaygroundOptionsOptions of the vue preset.
string"https://sfc.vuejs.org/"External playground service url.
booleanWhether to use the development version.
booleanWhether to enable SSR.
UnoPresetPlaygroundOptionsOptions of the unocss preset.
string"https://unocss.dev/play"External playground service url.
booleanWhether to enable kotlin playground support.
See also: Kotlin Playground.
booleanWhether to enable vue playground support.
See also: Vue Playground.
Partial<CodeDemoOptions> | booleanWhether to enable code demo support.
See also: Code Demo.
string[]External JS libraries for CodePen, JsFiddle only.
string[]External CSS libraries for CodePen, JsFiddle only.
Warning
The above two options are only used by third-party code demo service, you need to import these libraries in head to get it work.
booleantrueWhether to display the JSFiddle button.
booleantrueWhether to display the CodePen button.
"top" | "left" | "right""left"CodePen editor layout.
string"101"CodePen editor status.
The following are the library links used by the third-party code demo service. Unless your environment cannot visit unpkg or the speed is slow, you probably don't need to override the default values.
string"https://unpkg.com/@babel/standalone/babel.min.js"string"https://unpkg.com/vue/dist/vue.global.prod.js"string"https://unpkg.com/react/umd/react.production.min.js"string"https://unpkg.com/react-dom/umd/react-dom.production.min.js"booleanWhether to enable sandpack playground support.
Client Config
defineKotlinPlaygroundConfig
interface KotlinPlaygroundOptions {
server?: string;
version?: string;
onChange?: (code: string) => void;
onRun?: () => void;
onError?: () => void;
getJsCode?: (code: string) => void;
onTestPassed?: () => void;
onTestFailed?: () => void;
onOpenConsole?: () => void;
onCloseConsole?: () => void;
callback?: (targetNode: HTMLElement, mountNode: HTMLElement) => void;
getInstance?: (instance: KotlinPlaygroundInstance) => void;
}
const defineKotlinPlaygroundConfig: (options: KotlinPlaygroundOptions) => void;Define config which you want to pass to kotlin-playground.
defineSandpackConfig
interface SandpackConfig {
/**
* specify the template
*/
template?: SandpackPredefinedTemplate;
/**
* Options to configure the sandpack
*/
options?: SandpackOptions;
/**
* Options to configure the customSetup
*/
customSetup?: SandpackSetup;
}
const defineSandpackConfig = (config: SandpackConfig)=> voidDefine config which you want to pass to sandpack-vue3.
defineVuePlaygroundConfig
export interface VuePlaygroundOptions extends Omit<
ReplProps,
"store" | "editor"
> {
/**
* Specify the version of vue
*/
vueVersion?: string;
/**
* Specify default URL to import Vue dev runtime from in the sandbox
*
* @default "https://unpkg.com/@vue/runtime-dom@${version}/dist/runtime-dom.esm-browser.js"
*/
vueRuntimeDevUrl?: string | (() => string);
/**
* Specify default URL to import Vue prod runtime from in the sandbox
*
* @default "https://unpkg.com/@vue/runtime-dom@${version}/dist/runtime-dom.esm-browser.prod.js"
*/
vueRuntimeProdUrl?: string | (() => string);
/**
* Specify default URL to import Vue Server Renderer from in the sandbox
*
* @default "https://unpkg.com/@vue/server-renderer@${version}/dist/server-renderer.esm-browser.js"
*/
vueServerRendererUrl?: string | (() => string);
}
const defineVuePlaygroundConfig: (options: VuePlaygroundOptions) => void;Define config which you want to pass to @vue/repl.
Changelog
0c1aa-on9a4c3-on7d390-on660a5-onc9017-on70692-on22787-on99f51-on6ad69-onffeb2-on3dcc0-on913bb-onf0fcc-on7bd34-on92957-on8cb86-ond544c-on95198-on497db-onfa8af-on1669d-on7bc15-onbac94-on2dbdd-on55ea3-onf55f2-on8e9aa-on539b3-onf0736-ondef96-on254c5-onef5af-ona648a-onf6ff7-on573c3-on16ff1-on2a306-ond06e4-ona7a28-on12ecd-on91679-ond0c25-on0eb18-onaf82c-onedf2d-on4104e-on1c52f-on74050-onc5742-on1433d-on6e91a-onb4289-on9df60-on6639c-on2243a-on8b5af-on0e45a-on9fcf5-on23f74-on84771-on3dac6-onfeeb6-on637b2-on7c8cf-on2fa50-on1d7fa-on86cc2-on5498b-on099d8-on80eb7-on57c57-on48bca-on63d09-onad023-on88e69-on6d302-one07b5-on904c0-on60053-on716f9-on227bc-on1d0f9-on67429-on4d1ba-on907b9-on8dc9f-on04b8a-onfca17-onace60-on