Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,22 @@ export function hasValidEditorContent(json: JSONContent): boolean {
(c) => c.type === PromptBlock.name || c.type === CodeBlock.name,
);

// Check for text content
const hasTextContent = json.content?.some((c) => c.content);
// Check for non-whitespace text content
const hasNonWhitespaceText = json.content?.some((c) =>
c.content?.some((child) => {
if (child.type === "text" && child.text) {
return child.text.trim().length > 0;
}
// Mentions and other non-text nodes are valid content
if (child.type === "mention") {
return true;
}
return false;
}),
);

// Content is valid if it has either text or special blocks
return hasTextContent || hasPromptOrCodeBlock || false;
// Content is valid if it has either non-whitespace text or special blocks
return hasNonWhitespaceText || hasPromptOrCodeBlock || false;
}

/**
Expand Down
Loading