@@ -8,11 +8,17 @@ import mermaid from '@comark/nuxt/plugins/mermaid'
88import jsonRender from ' @comark/nuxt/plugins/json-render'
99import footnotes from ' @comark/nuxt/plugins/footnotes'
1010import punctuation from ' @comark/nuxt/plugins/punctuation'
11- import breaks from ' @comark/vue /plugins/breaks'
11+ import breaks from ' @comark/nuxt /plugins/breaks'
1212
1313import { renderMarkdown } from ' comark/render'
1414import { Splitpanes , Pane } from ' splitpanes'
15- import { defaultMarkdown } from ' ~/constants'
15+ import { airbnbMarkdown , playgroundExamples } from ' ~/constants'
16+ import PropertyGallery from ' ~/components/playground/PropertyGallery.vue'
17+ import RatingBar from ' ~/components/playground/RatingBar.vue'
18+ import HostInfo from ' ~/components/playground/HostInfo.vue'
19+ import Facility from ' ~/components/playground/Facility.vue'
20+ import TwoColumn from ' ~/components/playground/TwoColumn.vue'
21+ import BookingCard from ' ~/components/playground/BookingCard.vue'
1622import { useLocalStorage , watchDebounced } from ' @vueuse/core'
1723import type { ComarkTree , ComarkPlugin } from ' comark'
1824import VueJsonPretty from ' vue-json-pretty'
@@ -21,7 +27,12 @@ const props = defineProps<{
2127 compact? : boolean
2228}>()
2329
24- const markdown = ref <string >(defaultMarkdown .trim ())
30+ const selectedExample = ref (' airbnb' )
31+ const currentExample = computed (() =>
32+ playgroundExamples .find (e => e .value === selectedExample .value ) ?? playgroundExamples [0 ]! ,
33+ )
34+
35+ const markdown = ref <string >(airbnbMarkdown .trim ())
2536const tree = ref <ComarkTree | null >(null )
2637const parseTime = ref <number >(0 )
2738const nodeCount = ref <number >(0 )
@@ -125,7 +136,7 @@ const parseOptionDefs = [
125136
126137const activePlugins = computed <ComarkPlugin []>(() =>
127138 pluginDefs
128- .filter (p => pluginToggles .value [p .key ])
139+ .filter (p => pluginToggles .value [p .key as keyof typeof pluginToggles . value ])
129140 .map (p => p .factory ()),
130141)
131142
@@ -195,15 +206,19 @@ onMounted(() => {
195206 nextTick (() => parseMarkdown ())
196207})
197208
209+ watch (selectedExample , () => {
210+ markdown .value = currentExample .value .content .trim ()
211+ })
212+
198213function resetComark(): void {
199- markdown .value = defaultMarkdown .trim ()
214+ markdown .value = currentExample . value . content .trim ()
200215}
201216
202217const formattedOutput = ref <string >(' ' )
203218
204- watch ( tree , async (t : ComarkTree | null ) => {
205- formattedOutput .value = t ? await renderMarkdown (t ) : ' '
206- }, { immediate: true } )
219+ watchEffect ( async () => {
220+ formattedOutput .value = tree . value ? await renderMarkdown (tree . value as any ) : ' '
221+ })
207222
208223const formattedOutputModel = computed ({
209224 get : () => formattedOutput .value ,
@@ -228,12 +243,20 @@ const isMatch = computed(() =>
228243 >
229244 <div class =" h-full flex flex-col" >
230245 <div class =" shrink-0 flex items-center gap-2 px-3 h-9 border-b border-default bg-default" >
246+ <USelect
247+ v-if =" !compact"
248+ v-model =" selectedExample"
249+ :items =" playgroundExamples"
250+ size =" xs"
251+ color =" neutral"
252+ variant =" ghost"
253+ class =" w-32"
254+ />
231255 <UTooltip
232- v-if =" markdown !== defaultMarkdown .trim()"
233- text =" Reset to default content "
256+ v-if =" markdown !== currentExample.content .trim()"
257+ text =" Reset to example "
234258 >
235259 <UButton
236- :disabled =" markdown === defaultMarkdown.trim()"
237260 size =" xs"
238261 color =" neutral"
239262 variant =" ghost"
@@ -279,7 +302,7 @@ const isMatch = computed(() =>
279302 v-for =" plugin in pluginDefs"
280303 :key =" plugin.key"
281304 class =" flex items-center gap-2.5 w-full px-2 py-1.5 rounded-md text-sm hover:bg-elevated transition-colors"
282- @click =" pluginToggles[plugin.key] = !pluginToggles[plugin.key] as any "
305+ @click =" pluginToggles[plugin.key] = !pluginToggles[plugin.key]"
283306 >
284307 <UIcon
285308 :name =" plugin.icon"
@@ -432,7 +455,7 @@ const isMatch = computed(() =>
432455 >
433456 <ComarkDocsRenderer
434457 :tree =" tree"
435- :components =" { Binding }"
458+ :components =" { Binding, PropertyGallery, RatingBar, HostInfo, Facility, TwoColumn, BookingCard }"
436459 />
437460 </div >
438461 </UScrollArea >
0 commit comments