Beautiful Open-Source Form Builder
Enhance Text and Error Display with Responsive Wrapping
JhumanJb2ae67e40f74
diff --git a/client/components/forms/TextBlock.vue b/client/components/forms/TextBlock.vueindex 5400af894..a95851487 100644--- a/client/components/forms/TextBlock.vue+++ b/client/components/forms/TextBlock.vue@@ -1,5 +1,6 @@<template><div+ class="break-words whitespace-break-spaces"v-html="processedContent"/></template>diff --git a/client/components/forms/components/InputHelp.vue b/client/components/forms/components/InputHelp.vueindex 1552e0089..ff4dd8bde 100644--- a/client/components/forms/components/InputHelp.vue+++ b/client/components/forms/components/InputHelp.vue@@ -10,7 +10,7 @@<slot><spanv-if="help"- class="field-help"+ class="field-help break-words whitespace-break-spaces"v-html="help"/></slot>diff --git a/client/components/forms/validation/HasError.vue b/client/components/forms/validation/HasError.vueindex 427e01d44..800b04656 100644--- a/client/components/forms/validation/HasError.vue+++ b/client/components/forms/validation/HasError.vue@@ -2,7 +2,7 @@<transition name="fade"><divv-if="errorMessage"- class="has-error text-xs text-red-500 mt-1"+ class="has-error text-xs text-red-500 mt-1 break-words whitespace-break-spaces"v-html="errorMessage"/></transition>diff --git a/client/components/open/forms/OpenCompleteForm.vue b/client/components/open/forms/OpenCompleteForm.vueindex 881837898..be7dc51bc 100644--- a/client/components/open/forms/OpenCompleteForm.vue+++ b/client/components/open/forms/OpenCompleteForm.vue@@ -73,7 +73,7 @@><template #description><div- class="py-2"+ class="break-words whitespace-break-spaces"v-html="form.closed_text"/></template>@@ -88,7 +88,7 @@><template #description><div- class="py-2"+ class="break-words whitespace-break-spaces"v-html="form.max_submissions_reached_text"/></template>diff --git a/client/components/open/forms/OpenFormField.vue b/client/components/open/forms/OpenFormField.vueindex 52f631b23..e8a42fe3f 100644--- a/client/components/open/forms/OpenFormField.vue+++ b/client/components/open/forms/OpenFormField.vue@@ -87,7 +87,7 @@v-if="field.type === 'nf-text' && field.content":id="field.id":key="field.id"- class="nf-text w-full my-1.5"+ class="nf-text w-full my-1.5 break-words whitespace-break-spaces":class="[getFieldAlignClasses(field)]"v-html="field.content"/>diff --git a/client/components/open/tables/components/OpenText.vue b/client/components/open/tables/components/OpenText.vueindex b86063cb4..470d1fc4d 100644--- a/client/components/open/tables/components/OpenText.vue+++ b/client/components/open/tables/components/OpenText.vue@@ -1,5 +1,5 @@<template>- <div v-html="value" />+ <div class="break-words whitespace-break-spaces" v-html="value" /></template><script>diff --git a/client/components/pages/forms/show/FormCleanings.vue b/client/components/pages/forms/show/FormCleanings.vueindex b72d56ab8..ca18df796 100644--- a/client/components/pages/forms/show/FormCleanings.vue+++ b/client/components/pages/forms/show/FormCleanings.vue@@ -24,7 +24,7 @@following features are disabled on the published form:</p><div- class="text-slate-500"+ class="text-slate-500 break-words whitespace-break-spaces"v-html="cleaningContent"/></div>diff --git a/client/lib/quill/quillPatches.js b/client/lib/quill/quillPatches.jsindex 2155d470a..97264656c 100644--- a/client/lib/quill/quillPatches.js+++ b/client/lib/quill/quillPatches.js@@ -2,21 +2,48 @@ import Quill from 'quill'// Self-executing function to patch Quill's prototype;(function installQuillFixes() {- // Store the original method++ // ---------------------------------------------------------------------------+ // NBSP handling: preserve multiples spaces without blocking wrapping+ // ---------------------------------------------------------------------------++ const normaliseNbsp = (text) => {+ const placeholder = '\uF000'+ return text+ .replace(/\u00A0\u00A0/g, placeholder) // protect pairs+ .replace(/\u00A0/g, ' ') // single NBSP → space+ .replace(new RegExp(placeholder, 'g'), '\u00A0 ') // pair → NBSP + space+ }++ // 2a) Tweak getSemanticHTML so exported HTML keeps blank lines **and**+ // converts NBSP-runs into NBSP+space sequences.const originalGetSemanticHTML = Quill.prototype.getSemanticHTML+ Quill.prototype.getSemanticHTML = function (index = 0, length) {+ let html = originalGetSemanticHTML.call(this, index, length || this.getLength())++ // Fix blank lines (<p></p> → <p><br/></p>)+ html = html.replace(/<p><\/p>/g, '<p><br/></p>')++ // NBSP entity form+ html = html.replace(/ /g, ' ').replace(/ /g, ' ')++ // Raw NBSP char (just in case)+ html = normaliseNbsp(html)- // Override the getSemanticHTML method- Quill.prototype.getSemanticHTML = function(index = 0, length) {- // Call the original method- const html = originalGetSemanticHTML.call(this, index, length || this.getLength())-- // Apply fixes:return html- // 1. Replace double with a non-breaking and a regular space.- // This preserves spacing while allowing wrapping, fixing overflow issues.- .replace(/ /g, ' ')- // 2. Fix line breaks by replacing empty paragraphs with paragraphs containing <br/>- .replace(/<p><\/p>/g, '<p><br/></p>')+ }++ // 2b) Clipboard matcher so pasted content is normalised before entering Delta+ if (typeof window !== 'undefined') {+ const Clipboard = Quill.import('modules/clipboard')+ const Delta = Quill.import('delta')++ const matcher = (node) => {+ const text = normaliseNbsp(node.data)+ return new Delta().insert(text)+ }++ Clipboard.DEFAULTS.matchers.push([Node.TEXT_NODE, matcher])}})()