-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set char limit on rich text #662
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -30,17 +30,33 @@ | |||||||||||||||||||
v-model="compVal" | ||||||||||||||||||||
:options="quillOptions" | ||||||||||||||||||||
:disabled="disabled" | ||||||||||||||||||||
:placeholder="placeholder" | ||||||||||||||||||||
:style="inputStyle" | ||||||||||||||||||||
/> | ||||||||||||||||||||
</div> | ||||||||||||||||||||
|
||||||||||||||||||||
<template #help> | ||||||||||||||||||||
<template | ||||||||||||||||||||
v-if="$slots.help" | ||||||||||||||||||||
#help | ||||||||||||||||||||
> | ||||||||||||||||||||
<slot name="help" /> | ||||||||||||||||||||
</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" /> | ||||||||||||||||||||
</template> | ||||||||||||||||||||
|
||||||||||||||||||||
<MentionDropdown | ||||||||||||||||||||
v-if="enableMentions && mentionState" | ||||||||||||||||||||
:state="mentionState" | ||||||||||||||||||||
|
@@ -59,6 +75,7 @@ import registerMentionExtension from '~/lib/quill/quillMentionExtension.js' | |||||||||||||||||||
|
||||||||||||||||||||
const props = defineProps({ | ||||||||||||||||||||
...inputProps, | ||||||||||||||||||||
maxCharLimit: { type: Number, required: false, default: null }, | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add validation for maxCharLimit prop. The
- maxCharLimit: { type: Number, required: false, default: null },
+ maxCharLimit: {
+ type: Number,
+ required: false,
+ default: null,
+ validator: (value) => {
+ return value === null || (value > 0 && value <= 100000);
+ }
+ }, 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||
editorOptions: { | ||||||||||||||||||||
type: Object, | ||||||||||||||||||||
default: () => ({}) | ||||||||||||||||||||
|
@@ -86,6 +103,7 @@ if (props.enableMentions && !Quill.imports['blots/mention']) { | |||||||||||||||||||
|
||||||||||||||||||||
const quillOptions = computed(() => { | ||||||||||||||||||||
const defaultOptions = { | ||||||||||||||||||||
placeholder: props.placeholder || '', | ||||||||||||||||||||
theme: 'snow', | ||||||||||||||||||||
modules: { | ||||||||||||||||||||
toolbar: [ | ||||||||||||||||||||
|
@@ -110,6 +128,10 @@ const quillOptions = computed(() => { | |||||||||||||||||||
|
||||||||||||||||||||
return mergedOptions | ||||||||||||||||||||
}) | ||||||||||||||||||||
|
||||||||||||||||||||
const charCount = computed(() => { | ||||||||||||||||||||
return compVal.value ? compVal.value.replace(/<[^>]*>/g, '').trim().length : 0 | ||||||||||||||||||||
}) | ||||||||||||||||||||
</script> | ||||||||||||||||||||
|
||||||||||||||||||||
<style lang="scss"> | ||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -552,7 +552,7 @@ | |
@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)"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Missing prop definition and character limit enforcement in RichTextAreaInput
🔗 Analysis chainVerify integration with RichTextAreaInput component. The changes look good, but we should verify that the Also applies to: 844-846 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify that RichTextAreaInput component handles maxCharLimit and showCharLimit props
# Search for RichTextAreaInput component definition
echo "Searching for RichTextAreaInput component definition..."
ast-grep --pattern 'export default {
name: "RichTextAreaInput",
$$$
}'
# Search for maxCharLimit and showCharLimit prop definitions
echo "Searching for character limit prop definitions..."
rg -A 5 'props.*\{' client/components/**/RichTextAreaInput*.vue
# Search for character limit usage in template
echo "Searching for character limit usage in template..."
rg -A 5 'maxCharLimit|showCharLimit' client/components/**/RichTextAreaInput*.vue
Length of output: 1895 Script: #!/bin/bash
# Search for showCharLimit prop and charCount implementation
echo "Searching for showCharLimit prop..."
rg -A 2 'showCharLimit.*\{' client/components/forms/RichTextAreaInput.client.vue
echo "Searching for charCount implementation..."
rg -A 5 'charCount' client/components/forms/RichTextAreaInput.client.vue
echo "Searching for validation or restriction logic..."
rg -A 10 'maxCharLimit' client/components/forms/RichTextAreaInput.client.vue
Length of output: 1305 |
||
<text-input | ||
name="max_char_limit" | ||
native-type="number" | ||
|
@@ -841,6 +841,9 @@ export default { | |
multi_lines: false, | ||
max_char_limit: 2000 | ||
}, | ||
rich_text: { | ||
max_char_limit: 2000 | ||
}, | ||
email: { | ||
max_char_limit: 2000 | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Prevent input when character limit is exceeded.
Currently, the component only displays the character count but doesn't prevent users from exceeding the limit. Consider adding an input prevention mechanism: