feat(#3): Use Latex for PDF output
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
<div class="bg-white dark:bg-white rounded-md border border-gray-200 dark:border-gray-200 overflow-hidden">
|
||||
<UEditor
|
||||
v-slot="{ editor }"
|
||||
v-model="htmlContent"
|
||||
content-type="html"
|
||||
v-model="editorContent"
|
||||
content-type="json"
|
||||
:editable="!props.disabled"
|
||||
:placeholder="t('applicationForms.formElements.richTextPlaceholder')"
|
||||
:ui="{
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { EmployeeDataCategory, ProcessingPurpose, type FormOptionDto } from '~~/.api-client'
|
||||
import type { JSONContent } from '@tiptap/vue-3'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
@@ -38,13 +39,25 @@ const emit = defineEmits<{
|
||||
(e: 'update:formOptions', value: FormOptionDto[]): void
|
||||
}>()
|
||||
|
||||
const htmlContent = computed({
|
||||
get: () => props.formOptions[0]?.value ?? '',
|
||||
set: (newValue: string) => {
|
||||
const editorContent = computed({
|
||||
get: () => {
|
||||
const rawValue = props.formOptions[0]?.value ?? ''
|
||||
if (rawValue.trim().startsWith('{')) {
|
||||
try {
|
||||
return JSON.parse(rawValue) as JSONContent
|
||||
} catch {
|
||||
return rawValue // Fallback to HTML if JSON parse fails
|
||||
}
|
||||
}
|
||||
return rawValue // Treat as HTML
|
||||
},
|
||||
set: (newValue: string | JSONContent) => {
|
||||
const updatedOptions: FormOptionDto[] = [...props.formOptions]
|
||||
const stringifiedValue = typeof newValue === 'string' ? newValue : JSON.stringify(newValue)
|
||||
|
||||
if (updatedOptions.length === 0) {
|
||||
const createdOption: FormOptionDto = {
|
||||
value: newValue,
|
||||
value: stringifiedValue,
|
||||
label: '',
|
||||
processingPurpose: ProcessingPurpose.None,
|
||||
employeeDataCategory: EmployeeDataCategory.None
|
||||
@@ -52,7 +65,7 @@ const htmlContent = computed({
|
||||
updatedOptions.push(createdOption)
|
||||
} else {
|
||||
const firstOption = updatedOptions[0]!
|
||||
updatedOptions[0] = { ...firstOption, value: newValue }
|
||||
updatedOptions[0] = { ...firstOption, value: stringifiedValue }
|
||||
}
|
||||
emit('update:formOptions', updatedOptions)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user