2022-09-20 19:59:52 +00:00
|
|
|
<template>
|
|
|
|
<div :class="wrapperClass">
|
|
|
|
<label v-if="label" :for="id?id:name"
|
|
|
|
:class="[theme.CodeInput.label,{'uppercase text-xs':uppercaseLabels, 'text-sm':!uppercaseLabels}]"
|
|
|
|
>
|
|
|
|
{{ label }}
|
|
|
|
<span v-if="required" class="text-red-500 required-dot">*</span>
|
|
|
|
</label>
|
|
|
|
|
2023-08-30 07:58:29 +00:00
|
|
|
<div :class="[theme.CodeInput.input,{ '!ring-red-500 !ring-2': hasValidation && form.errors.has(name), '!cursor-not-allowed !bg-gray-200':disabled }]">
|
|
|
|
<codemirror :id="id?id:name" v-model="compVal" :disabled="disabled"
|
|
|
|
:options="cmOptions"
|
2022-09-20 19:59:52 +00:00
|
|
|
:style="inputStyle" :name="name"
|
|
|
|
:placeholder="placeholder"
|
2023-08-30 07:58:29 +00:00
|
|
|
/>
|
|
|
|
</div>
|
2022-09-20 19:59:52 +00:00
|
|
|
|
|
|
|
<small v-if="help" :class="theme.CodeInput.help">
|
2023-04-19 08:13:50 +00:00
|
|
|
<slot name="help"><span class="field-help" v-html="help" /></slot>
|
2022-09-20 19:59:52 +00:00
|
|
|
</small>
|
|
|
|
<has-error v-if="hasValidation" :form="form" :field="name" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-08-30 07:58:29 +00:00
|
|
|
import { codemirror } from 'vue-codemirror'
|
|
|
|
import 'codemirror/lib/codemirror.css'
|
|
|
|
|
|
|
|
import 'codemirror/mode/htmlmixed/htmlmixed.js'
|
|
|
|
|
2023-01-21 11:57:37 +00:00
|
|
|
import inputMixin from '~/mixins/forms/input.js'
|
2022-09-20 19:59:52 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'CodeInput',
|
|
|
|
|
2023-08-30 07:58:29 +00:00
|
|
|
components: { codemirror },
|
2022-09-20 19:59:52 +00:00
|
|
|
mixins: [inputMixin],
|
|
|
|
|
2023-08-30 07:58:29 +00:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
cmOptions: {
|
|
|
|
// codemirror options
|
|
|
|
tabSize: 4,
|
|
|
|
mode: 'text/html',
|
|
|
|
theme: 'default',
|
|
|
|
lineNumbers: true,
|
|
|
|
line: true
|
|
|
|
}
|
2022-09-20 19:59:52 +00:00
|
|
|
}
|
2023-08-30 07:58:29 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {}
|
2022-09-20 19:59:52 +00:00
|
|
|
}
|
|
|
|
</script>
|