first commit

This commit is contained in:
Your Name
2026-09-08 11:40:15 +08:00
commit a5353f7eb5
9568 changed files with 1646214 additions and 0 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,
};