Support for Rich Text Input (#630)

* Support for Rich Text Input

* rich text support for prefilled

* apply Purify for rich_text

---------

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
Chirag Chhatrala 2024-11-28 20:42:24 +05:30 committed by GitHub
parent e2c6af69e6
commit 13c40f6e54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 26 additions and 4 deletions

View File

@ -14,6 +14,7 @@ use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Illuminate\Validation\Rule; use Illuminate\Validation\Rule;
use Stevebauman\Purify\Facades\Purify;
class AnswerFormRequest extends FormRequest class AnswerFormRequest extends FormRequest
{ {
@ -175,6 +176,7 @@ class AnswerFormRequest extends FormRequest
{ {
switch ($property['type']) { switch ($property['type']) {
case 'text': case 'text':
case 'rich_text':
case 'signature': case 'signature':
return ['string']; return ['string'];
case 'number': case 'number':
@ -282,6 +284,10 @@ class AnswerFormRequest extends FormRequest
if ($property['type'] === 'phone_number' && (!isset($property['use_simple_text_input']) || !$property['use_simple_text_input']) && $receivedValue && in_array($receivedValue, $countryCodeMapper)) { if ($property['type'] === 'phone_number' && (!isset($property['use_simple_text_input']) || !$property['use_simple_text_input']) && $receivedValue && in_array($receivedValue, $countryCodeMapper)) {
$mergeData[$property['id']] = null; $mergeData[$property['id']] = null;
} }
if ($property['type'] === 'rich_text' && $receivedValue) {
$mergeData[$property['id']] = Purify::clean($receivedValue);
}
}); });
$this->merge($mergeData); $this->merge($mergeData);

View File

@ -210,6 +210,7 @@ export default {
} }
return { return {
text: 'TextInput', text: 'TextInput',
rich_text: 'RichTextAreaInput',
number: 'TextInput', number: 'TextInput',
rating: 'RatingInput', rating: 'RatingInput',
scale: 'ScaleInput', scale: 'ScaleInput',

View File

@ -448,8 +448,15 @@
:multiple="field.multiple === true" :multiple="field.multiple === true"
:move-to-form-assets="true" :move-to-form-assets="true"
/> />
<rich-text-area-input
v-else-if="field.type === 'rich_text'"
name="prefill"
class="mt-3"
:form="field"
label="Pre-filled value"
/>
<text-input <text-input
v-else-if="!['files', 'signature'].includes(field.type)" v-else-if="!['files', 'signature', 'rich_text'].includes(field.type)"
name="prefill" name="prefill"
class="mt-3" class="mt-3"
:form="field" :form="field"

View File

@ -193,6 +193,7 @@ export default {
rafId: null, rafId: null,
fieldComponents: { fieldComponents: {
text: shallowRef(OpenText), text: shallowRef(OpenText),
rich_text: shallowRef(OpenText),
number: shallowRef(OpenText), number: shallowRef(OpenText),
rating: shallowRef(OpenText), rating: shallowRef(OpenText),
scale: shallowRef(OpenText), scale: shallowRef(OpenText),

View File

@ -1,7 +1,5 @@
<template> <template>
<span> <div v-html="value" />
{{ value }}
</span>
</template> </template>
<script> <script>

View File

@ -8,6 +8,15 @@
"text_class": "text-blue-900", "text_class": "text-blue-900",
"is_input": true "is_input": true
}, },
"rich_text": {
"name": "rich_text",
"title": "Rich Text Input",
"icon": "i-heroicons-bars-3-20-solid",
"default_block_name": "Description",
"bg_class": "bg-blue-100",
"text_class": "text-blue-900",
"is_input": true
},
"date": { "date": {
"name": "date", "name": "date",
"title": "Date Input", "title": "Date Input",