This commit is contained in:
Your Name
2026-03-11 09:49:47 +08:00
parent 02ae537b4c
commit 38ad60f4bb
290 changed files with 36917 additions and 123 deletions
@@ -0,0 +1,45 @@
import { MessageContentType } from './type';
import type { InputContent } from './type';
function convertInputContentToEditorNode(item: InputContent) {
switch (item.type) {
case MessageContentType.TEXT:
return {
type: 'text',
text: item.content,
};
case MessageContentType.IMAGE: {
const imageFile = item.content as File;
const imageUrl = URL.createObjectURL(imageFile);
return {
type: MessageContentType.IMAGE,
attrs: {
src: imageUrl,
alt: imageFile?.name,
fileData: imageFile,
title: imageFile?.name,
},
};
}
case MessageContentType.EMOJI: {
const emoticonContent = item.content as { url: string; key: string; text: string };
return {
type: MessageContentType.EMOJI,
attrs: {
src: emoticonContent.url,
alt: emoticonContent.key,
title: emoticonContent.text,
},
};
}
default:
return {
type: 'text',
text: String(item.content),
};
}
}
export {
convertInputContentToEditorNode,
};