Attachments: pure-image website attachments

This commit is contained in:
Enrico Ros
2024-07-16 03:47:23 -07:00
parent 730ed42931
commit f00a87fc06
3 changed files with 12 additions and 3 deletions
@@ -73,7 +73,7 @@ const InputErrorIndicator = () =>
<WarningRoundedIcon sx={{ color: 'danger.solidBg' }} />;
const converterTypeToIconMap: { [key in AttachmentDraftConverterType]: React.ComponentType<any> } = {
const converterTypeToIconMap: { [key in AttachmentDraftConverterType]: React.ComponentType<any> | null } = {
'text': TextFieldsIcon,
'rich-text': CodeIcon,
'rich-text-cleaner': CodeIcon,
@@ -89,6 +89,7 @@ const converterTypeToIconMap: { [key in AttachmentDraftConverterType]: React.Com
'url-page-text': TextFieldsIcon, // was LanguageIcon
'url-page-markdown': CodeIcon, // was LanguageIcon
'url-page-html': HtmlIcon, // was LanguageIcon
'url-page-null': TextureIcon,
'url-page-image': ImageOutlinedIcon,
'ego-fragments-inlined': TelegramIcon,
'unhandled': TextureIcon,
@@ -319,8 +319,11 @@ export function attachmentDefineConverters(sourceType: AttachmentDraftSource['me
converters.push({ id: 'url-page-markdown', name: 'Markdown (suggested)', isActive: preferMarkdown });
if (pageData.pageCleanedHtml)
converters.push({ id: 'url-page-html', name: 'Clean HTML', isActive: !preferMarkdown && !pageData.pageText });
if (input.urlImage)
if (input.urlImage) {
if (converters.length)
converters.push({ id: 'url-page-null', name: 'Do not attach' });
converters.push({ id: 'url-page-image', name: 'Add Screenshot', disabled: !input.urlImage.width || !input.urlImage.height, isCheckbox: true });
}
break;
// EGO
@@ -656,6 +659,11 @@ export async function attachmentPerformConversion(
newFragments.push(createDocAttachmentFragment(title, caption, 'text/html', pageHtmlData, refString, docMeta));
break;
// url page null
case 'url-page-null':
// user chose to not attach any version of the page
break;
// url page image
case 'url-page-image':
if (!input.urlImage) {
@@ -123,7 +123,7 @@ export type AttachmentDraftConverterType =
| 'image-original' | 'image-resized-high' | 'image-resized-low' | 'image-ocr' | 'image-to-default'
| 'pdf-text' | 'pdf-images'
| 'docx-to-html'
| 'url-page-text' | 'url-page-markdown' | 'url-page-html' | 'url-page-image'
| 'url-page-text' | 'url-page-markdown' | 'url-page-html' | 'url-page-null' | 'url-page-image'
| 'ego-fragments-inlined'
| 'unhandled';