mirror of
https://github.com/StanGirard/quivr.git
synced 2025-01-07 11:39:00 +03:00
14e44ac6ec
* feat: add FeedBrainInput component * feat: add upload button * feat: update translations add feed_brain_placeholder * refactor(uploadPage): add config.ts * feat(lib): add MentionInput * feat: add <BrainSelector/> component * feat: update FeedBrainInput
23 lines
674 B
TypeScript
23 lines
674 B
TypeScript
import { MentionData } from "@draft-js-plugins/mention";
|
|
import { EditorState } from "draft-js";
|
|
|
|
export const getEditorText = (editorState: EditorState): string => {
|
|
const mentions: string[] = [];
|
|
const editorEntities = editorState.getCurrentContent().getAllEntities();
|
|
|
|
editorEntities.forEach((entity) => {
|
|
const entityData = entity?.getData() as { mention?: MentionData };
|
|
if (entityData.mention !== undefined) {
|
|
mentions.push(entityData.mention.name);
|
|
}
|
|
});
|
|
|
|
let content = editorState.getCurrentContent().getPlainText();
|
|
|
|
for (const mention of mentions) {
|
|
content = content.replace(`@#${mention}`, "");
|
|
}
|
|
|
|
return content.trim();
|
|
};
|