Implement textarea validation for character limits in submission service; enhance user feedback with error messages for minimum and maximum character requirements. Update translations and UI components to support new validation features.

This commit is contained in:
Rotimi Best
2026-03-29 09:50:24 +01:00
parent acccbee110
commit ff2ad59377
24 changed files with 805 additions and 88 deletions
@@ -49,6 +49,14 @@
// Browser detection
const browser = typeof window !== 'undefined';
function normalizeEditorContent(value: HTMLContent | undefined): string {
const html = String(value ?? '').trim();
if (html === '' || html === '<p></p>' || html === '<p><br></p>') return '';
return html;
}
// Handle content persistence
$effect(() => {
if (enablePersistence && browser && content) {
@@ -94,6 +102,17 @@
}
});
$effect(() => {
if (!editor || editor.isDestroyed) return;
const nextContent = normalizeEditorContent(content);
const currentContent = normalizeEditorContent(editor.getHTML());
if (currentContent === nextContent) return;
editor.commands.setContent(nextContent, false);
});
function onUpdate(props: { editor: Editor; transaction: Transaction }) {
if (props?.editor && !props.editor.isDestroyed) {
const newContent = props.editor.getHTML();