mirror of
https://github.com/ONLYOFFICE/desktop-sdk.git
synced 2026-02-10 18:15:05 +08:00
Fixed Bug 78519 - Special characters are used in the chat save to file dialog
This commit is contained in:
@ -39,12 +39,16 @@ export const convertMessagesToMd = (messages: ThreadMessageLike[]) => {
|
||||
return content;
|
||||
};
|
||||
|
||||
export const removeSpecialCharacter = (str: string) => {
|
||||
return str.replace(/[\\/:*"<>|?]/g, "");
|
||||
};
|
||||
|
||||
export const getMessageTitleFromMd = (md: string) => {
|
||||
const lines = md.split("\n");
|
||||
|
||||
const title = lines[0].replace("## ", "");
|
||||
|
||||
return title.substring(0, 30);
|
||||
return removeSpecialCharacter(title).substring(0, 30);
|
||||
};
|
||||
|
||||
export const isDocument = (type: number) => {
|
||||
|
||||
@ -9,7 +9,7 @@ import {
|
||||
} from "@/database/threads";
|
||||
import { readMessages } from "@/database/messages";
|
||||
import type { Thread } from "@/lib/types";
|
||||
import { convertMessagesToMd } from "@/lib/utils";
|
||||
import { convertMessagesToMd, removeSpecialCharacter } from "@/lib/utils";
|
||||
|
||||
type UseThreadsStoreProps = {
|
||||
threadId: string;
|
||||
@ -71,7 +71,7 @@ const useThreadsStore = create<UseThreadsStoreProps>((set, get) => ({
|
||||
const thread = thisStore.threads.find((t) => t.threadId === id);
|
||||
const messages = await readMessages(id);
|
||||
|
||||
const title = thread?.title || "Chat Export";
|
||||
const title = removeSpecialCharacter(thread?.title || "Chat Export");
|
||||
|
||||
const content = convertMessagesToMd(messages);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user