Skip to content

Commit 5cc5506

Browse files
committed
rewrite editor
1 parent 140b392 commit 5cc5506

File tree

1 file changed

+14
-2
lines changed
  • packages/web/components/common/Textarea/PromptEditor

1 file changed

+14
-2
lines changed

packages/web/components/common/Textarea/PromptEditor/utils.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,21 @@ export const editorStateToText = (editor: LexicalEditor) => {
524524
return node.children.map(extractText).join('');
525525
}
526526

527-
// Unknown node type
527+
// Unknown node type - return the raw text content if available
528528
console.warn('Unknown node type in extractText:', (node as any).type, node);
529-
return '';
529+
530+
// Try to extract text content from unknown node types
531+
if ('text' in node && typeof (node as any).text === 'string') {
532+
return (node as any).text;
533+
}
534+
535+
// Try to recursively extract from children if present
536+
if ('children' in node && Array.isArray((node as any).children)) {
537+
return (node as any).children.map(extractText).join('');
538+
}
539+
540+
// Fallback to stringifying the node content
541+
return JSON.stringify(node);
530542
};
531543

532544
paragraphs.forEach((paragraph) => {

0 commit comments

Comments
 (0)