Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add more customization options #274

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Repl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export interface Props {
importCode?: string
useCode?: string
}
showRuntimeError?: boolean
showRuntimeWarning?: boolean
}
editorOptions?: {
ShowErrorText?: string
}
}

Expand All @@ -51,8 +56,13 @@ const props = withDefaults(defineProps<Props>(), {
importCode: '',
useCode: '',
},
showRuntimeError: true,
showRuntimeWarning: true,
}),
layout: 'horizontal',
editorOptions: () => ({
ShowErrorText: 'Show Error',
}),
})

if (!props.editor) {
Expand All @@ -73,6 +83,7 @@ provide('import-map', toRef(props, 'showImportMap'))
provide('tsconfig', toRef(props, 'showTsConfig'))
provide('clear-console', toRef(props, 'clearConsole'))
provide('preview-options', props.previewOptions)
provide('editor-options', props.editorOptions)
provide('theme', toRef(props, 'theme'))
provide('preview-theme', toRef(props, 'previewTheme'))
provide('preview-ref', () => outputRef.value?.previewRef?.container)
Expand Down
6 changes: 5 additions & 1 deletion src/editor/MessageToggle.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<script setup lang="ts">
import { inject } from 'vue'
import type { Props } from '../Repl.vue'

const editorOptions = inject<Props['editorOptions']>('editor-options')
const visible = defineModel<boolean>()
</script>

<template>
<div class="wrapper" @click="visible = !visible">
<span>Show Error</span>
<span>{{ editorOptions?.ShowErrorText }}</span>
<div class="toggle" :class="[{ active: modelValue }]">
<div class="indicator" />
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/output/Preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ defineExpose({ reload, container })
class="iframe-container"
:class="{ [theme]: previewTheme }"
/>
<Message :err="runtimeError" />
<Message v-if="!runtimeError" :warn="runtimeWarning" />
<Message :err="runtimeError && previewOptions?.showRuntimeError" />
<Message v-if="!runtimeError && previewOptions?.showRuntimeWarning" :warn="runtimeWarning" />
</template>

<style scoped>
Expand Down