2023-12-09 15:47:03 +01:00
|
|
|
<template>
|
2024-07-17 14:22:54 +02:00
|
|
|
<InputWrapper v-bind="inputWrapperProps">
|
2023-12-09 15:47:03 +01:00
|
|
|
<template #label>
|
|
|
|
|
<slot name="label" />
|
|
|
|
|
</template>
|
|
|
|
|
|
2024-07-17 14:22:54 +02:00
|
|
|
<VueEditor
|
2024-04-15 19:39:03 +02:00
|
|
|
:id="id ? id : name"
|
|
|
|
|
ref="editor"
|
|
|
|
|
v-model="compVal"
|
|
|
|
|
:disabled="disabled ? true : null"
|
|
|
|
|
:placeholder="placeholder"
|
|
|
|
|
:class="[
|
|
|
|
|
{
|
|
|
|
|
'!ring-red-500 !ring-2 !border-transparent': hasError,
|
|
|
|
|
'!cursor-not-allowed !bg-gray-200': disabled,
|
|
|
|
|
},
|
|
|
|
|
theme.RichTextAreaInput.input,
|
2024-06-27 17:52:49 +02:00
|
|
|
theme.RichTextAreaInput.borderRadius,
|
2024-04-15 19:39:03 +02:00
|
|
|
]"
|
2024-07-17 14:22:54 +02:00
|
|
|
:editor-options="editorOptions"
|
2024-04-15 19:39:03 +02:00
|
|
|
:editor-toolbar="editorToolbar"
|
|
|
|
|
class="rich-editor resize-y"
|
|
|
|
|
:style="inputStyle"
|
2023-12-09 15:47:03 +01:00
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<template #help>
|
|
|
|
|
<slot name="help" />
|
|
|
|
|
</template>
|
|
|
|
|
<template #error>
|
|
|
|
|
<slot name="error" />
|
|
|
|
|
</template>
|
2024-07-17 14:22:54 +02:00
|
|
|
</InputWrapper>
|
2023-12-09 15:47:03 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2024-07-17 14:22:54 +02:00
|
|
|
import { Quill, VueEditor } from 'vue3-editor'
|
|
|
|
|
import { inputProps, useFormInput } from './useFormInput.js'
|
|
|
|
|
import InputWrapper from './components/InputWrapper.vue'
|
2023-12-09 15:47:03 +01:00
|
|
|
|
2024-07-17 14:22:54 +02:00
|
|
|
Quill.imports['formats/link'].PROTOCOL_WHITELIST.push('notion')
|
2023-12-09 15:47:03 +01:00
|
|
|
|
|
|
|
|
export default {
|
2024-07-17 14:22:54 +02:00
|
|
|
name: 'RichTextAreaInput',
|
2023-12-09 15:47:03 +01:00
|
|
|
components: { InputWrapper, VueEditor },
|
|
|
|
|
|
|
|
|
|
props: {
|
|
|
|
|
...inputProps,
|
2024-07-17 14:22:54 +02:00
|
|
|
editorOptions: {
|
|
|
|
|
type: Object,
|
|
|
|
|
default: () => {
|
|
|
|
|
return {
|
|
|
|
|
formats: [
|
|
|
|
|
'bold',
|
|
|
|
|
'color',
|
|
|
|
|
'font',
|
|
|
|
|
'italic',
|
|
|
|
|
'link',
|
|
|
|
|
'underline',
|
|
|
|
|
'header',
|
|
|
|
|
'indent',
|
|
|
|
|
'list'
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-12-09 15:47:03 +01:00
|
|
|
editorToolbar: {
|
|
|
|
|
type: Array,
|
|
|
|
|
default: () => {
|
|
|
|
|
return [
|
|
|
|
|
[{ header: 1 }, { header: 2 }],
|
2024-07-17 14:22:54 +02:00
|
|
|
['bold', 'italic', 'underline', 'link'],
|
|
|
|
|
[{ list: 'ordered' }, { list: 'bullet' }],
|
|
|
|
|
[{ color: [] }]
|
2023-12-09 15:47:03 +01:00
|
|
|
]
|
2024-07-17 14:22:54 +02:00
|
|
|
}
|
|
|
|
|
}
|
2023-12-09 15:47:03 +01:00
|
|
|
},
|
|
|
|
|
|
2024-07-17 14:22:54 +02:00
|
|
|
setup (props, context) {
|
2023-12-09 15:47:03 +01:00
|
|
|
return {
|
2024-07-17 14:22:54 +02:00
|
|
|
...useFormInput(props, context)
|
2023-12-09 15:47:03 +01:00
|
|
|
}
|
2024-07-17 14:22:54 +02:00
|
|
|
}
|
2023-12-09 15:47:03 +01: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;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-15 19:39:03 +02:00
|
|
|
.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 {
|
2023-12-09 15:47:03 +01:00
|
|
|
@apply text-nt-blue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|