opnform/resources/js/components/forms/RichTextAreaInput.vue

82 lines
2.4 KiB
Vue
Raw Normal View History

2022-09-20 19:59:52 +00:00
<template>
2023-11-28 08:24:57 +00:00
<input-wrapper
2023-12-01 20:24:38 +00:00
v-bind="inputWrapperProps"
2023-11-28 08:24:57 +00:00
>
<template #label>
<slot name="label" />
</template>
2023-12-01 20:24:38 +00:00
<vue-editor :id="id?id:name" ref="editor" v-model="compVal" :disabled="disabled?true:null"
: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-11-28 08:24:57 +00:00
<template #help>
<slot name="help" />
</template>
<template #error>
<slot name="error" />
</template>
</input-wrapper>
2022-09-20 19:59:52 +00:00
</template>
<script>
2023-11-28 08:24:57 +00:00
import { inputProps, useFormInput } from './useFormInput.js'
import InputWrapper from './components/InputWrapper.vue'
import { VueEditor, Quill } from 'vue3-editor'
2022-09-20 19:59:52 +00:00
Quill.imports['formats/link'].PROTOCOL_WHITELIST.push('notion')
export default {
name: 'RichTextAreaInput',
2023-11-28 08:24:57 +00:00
components: { InputWrapper, VueEditor },
2022-09-20 19:59:52 +00:00
props: {
2023-11-28 08:24:57 +00:00
...inputProps,
2022-09-20 19:59:52 +00:00
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' }],
2023-12-01 20:24:38 +00:00
[{ color: [] }]
2022-09-20 19:59:52 +00:00
]
}
}
2023-11-28 08:24:57 +00:00
},
setup (props, context) {
return {
2023-12-01 20:24:38 +00:00
...useFormInput(props, context)
2023-11-28 08:24:57 +00:00
}
2022-09-20 19:59:52 +00:00
}
2023-11-28 08:24:57 +00:00
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>