2022-09-20 19:59:52 +00:00
|
|
|
<template>
|
|
|
|
<div :class="wrapperClass">
|
|
|
|
<label v-if="label" :for="id?id:name"
|
|
|
|
:class="[theme.RichTextAreaInput.label, {'uppercase text-xs':uppercaseLabels, 'text-sm':!uppercaseLabels}]"
|
|
|
|
>
|
|
|
|
{{ label }}
|
|
|
|
<span v-if="required" class="text-red-500 required-dot">*</span>
|
|
|
|
</label>
|
2023-04-19 08:13:50 +00:00
|
|
|
<div v-if="help && helpPosition=='above_input'" class="flex mb-1">
|
|
|
|
<small :class="theme.RichTextAreaInput.help" class="grow">
|
|
|
|
<slot name="help"><span class="field-help" v-html="help" /></slot>
|
|
|
|
</small>
|
|
|
|
</div>
|
2022-09-20 19:59:52 +00:00
|
|
|
<vue-editor :id="id?id:name" ref="editor" v-model="compVal" :disabled="disabled"
|
2023-03-22 14:49:52 +00:00
|
|
|
:placeholder="placeholder" :class="[{ '!ring-red-500 !ring-2': hasValidation && form.errors.has(name), '!cursor-not-allowed !bg-gray-200':disabled }, theme.RichTextAreaInput.input]"
|
2022-09-20 19:59:52 +00:00
|
|
|
:editor-toolbar="editorToolbar" class="rich-editor resize-y"
|
|
|
|
:style="inputStyle"
|
|
|
|
/>
|
|
|
|
|
2023-04-19 08:13:50 +00:00
|
|
|
<small v-if="help && helpPosition=='below_input'" :class="theme.RichTextAreaInput.help">
|
|
|
|
<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>
|
|
|
|
import { VueEditor, Quill } from 'vue2-editor'
|
2023-01-21 11:57:37 +00:00
|
|
|
import inputMixin from '~/mixins/forms/input.js'
|
2022-09-20 19:59:52 +00:00
|
|
|
|
|
|
|
Quill.imports['formats/link'].PROTOCOL_WHITELIST.push('notion')
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'RichTextAreaInput',
|
|
|
|
components: { VueEditor },
|
|
|
|
mixins: [inputMixin],
|
|
|
|
|
|
|
|
props: {
|
|
|
|
editorToolbar: {
|
|
|
|
type: Array,
|
|
|
|
default: () => {
|
|
|
|
return [
|
|
|
|
[{ header: 1 }, { header: 2 }],
|
|
|
|
['bold', 'italic', 'underline', 'link'],
|
2023-04-12 11:36:12 +00:00
|
|
|
[{ list: 'ordered' }, { list: 'bullet' }],
|
|
|
|
[{color: []}]
|
2022-09-20 19:59:52 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.rich-editor {
|
|
|
|
.ql-container {
|
|
|
|
border-bottom: 0px !important;
|
|
|
|
border-right: 0px !important;
|
|
|
|
border-left: 0px !important;
|
|
|
|
|
|
|
|
.ql-editor {
|
|
|
|
min-height: 100px !important;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.ql-toolbar {
|
|
|
|
border-top: 0px !important;
|
|
|
|
border-right: 0px !important;
|
|
|
|
border-left: 0px !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
.ql-snow .ql-toolbar .ql-picker-item.ql-selected, .ql-snow .ql-toolbar .ql-picker-item:hover, .ql-snow .ql-toolbar .ql-picker-label.ql-active, .ql-snow .ql-toolbar .ql-picker-label:hover, .ql-snow .ql-toolbar button.ql-active, .ql-snow .ql-toolbar button:focus, .ql-snow .ql-toolbar button:hover, .ql-snow.ql-toolbar .ql-picker-item.ql-selected, .ql-snow.ql-toolbar .ql-picker-item:hover, .ql-snow.ql-toolbar .ql-picker-label.ql-active, .ql-snow.ql-toolbar .ql-picker-label:hover, .ql-snow.ql-toolbar button.ql-active, .ql-snow.ql-toolbar button:focus, .ql-snow.ql-toolbar button:hover {
|
|
|
|
@apply text-nt-blue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|