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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user