Set char limit on rich text (#662)
* Set char limit on rich text * richtext placeholder
This commit is contained in:
parent
72d139e2af
commit
06c35121a0
|
|
@ -30,17 +30,33 @@
|
||||||
v-model="compVal"
|
v-model="compVal"
|
||||||
:options="quillOptions"
|
:options="quillOptions"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:placeholder="placeholder"
|
|
||||||
:style="inputStyle"
|
:style="inputStyle"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template #help>
|
<template
|
||||||
|
v-if="$slots.help"
|
||||||
|
#help
|
||||||
|
>
|
||||||
<slot name="help" />
|
<slot name="help" />
|
||||||
</template>
|
</template>
|
||||||
<template #error>
|
|
||||||
|
<template
|
||||||
|
v-if="maxCharLimit && showCharLimit"
|
||||||
|
#bottom_after_help
|
||||||
|
>
|
||||||
|
<small :class="theme.default.help">
|
||||||
|
{{ charCount }}/{{ maxCharLimit }}
|
||||||
|
</small>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template
|
||||||
|
v-if="$slots.error"
|
||||||
|
#error
|
||||||
|
>
|
||||||
<slot name="error" />
|
<slot name="error" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<MentionDropdown
|
<MentionDropdown
|
||||||
v-if="enableMentions && mentionState"
|
v-if="enableMentions && mentionState"
|
||||||
:state="mentionState"
|
:state="mentionState"
|
||||||
|
|
@ -59,6 +75,7 @@ import registerMentionExtension from '~/lib/quill/quillMentionExtension.js'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
...inputProps,
|
...inputProps,
|
||||||
|
maxCharLimit: { type: Number, required: false, default: null },
|
||||||
editorOptions: {
|
editorOptions: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({})
|
default: () => ({})
|
||||||
|
|
@ -86,6 +103,7 @@ if (props.enableMentions && !Quill.imports['blots/mention']) {
|
||||||
|
|
||||||
const quillOptions = computed(() => {
|
const quillOptions = computed(() => {
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
|
placeholder: props.placeholder || '',
|
||||||
theme: 'snow',
|
theme: 'snow',
|
||||||
modules: {
|
modules: {
|
||||||
toolbar: [
|
toolbar: [
|
||||||
|
|
@ -110,6 +128,10 @@ const quillOptions = computed(() => {
|
||||||
|
|
||||||
return mergedOptions
|
return mergedOptions
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const charCount = computed(() => {
|
||||||
|
return compVal.value ? compVal.value.replace(/<[^>]*>/g, '').trim().length : 0
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
|
||||||
|
|
@ -552,7 +552,7 @@
|
||||||
@update:model-value="onFieldHelpPositionChange"
|
@update:model-value="onFieldHelpPositionChange"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<template v-if="['text', 'number', 'url', 'email'].includes(field.type)">
|
<template v-if="['text', 'rich_text', 'number', 'url', 'email'].includes(field.type)">
|
||||||
<text-input
|
<text-input
|
||||||
name="max_char_limit"
|
name="max_char_limit"
|
||||||
native-type="number"
|
native-type="number"
|
||||||
|
|
@ -841,6 +841,9 @@ export default {
|
||||||
multi_lines: false,
|
multi_lines: false,
|
||||||
max_char_limit: 2000
|
max_char_limit: 2000
|
||||||
},
|
},
|
||||||
|
rich_text: {
|
||||||
|
max_char_limit: 2000
|
||||||
|
},
|
||||||
email: {
|
email: {
|
||||||
max_char_limit: 2000
|
max_char_limit: 2000
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue