Files
Zero/apps/mail/actions/extractText.ts
Ahmet Kilinc d6b1c3b243 Release 2 (#351)
* fix: remove tracked node_modules/.bin files

* added to .gitignore

* update compose

* feat: Add AI brain and summary features for email

- Implemented EnableBrain action to subscribe to mail gateway
- Created GetSummary action to retrieve email thread summaries
- Added useSummary hook for fetching summaries
- Introduced mail0_summary database table
- Added Brain button to app sidebar for enabling AI features

* fix: Improve null safety and remove unused imports

- Fixed potential null access in thread-display by checking array first
- Removed unused markAsReadAction import in use-threads hook
- Removed unnecessary cache deletion logic in IndexedDB storage provider
- Removed threadId from ParsedMessage type definition

* fix: Use environment variable for brain gateway URL

- Replace hardcoded mail gateway URL with configurable environment variable
- Improve flexibility and configuration of brain subscription endpoint

* big push for connections and server actions:
- unread count 
- remove `/connect-email` 
- update redirects and callbacks to `/settings/connections` 
- make everything else server actions 
- remove old route.ts files 

* feat: Improve HTML text extraction and email parsing

- Added Cheerio for robust HTML text extraction in extractTextFromHTML
- Enhanced null safety in Google email driver for sender name and subject
- Updated mail list and threads hooks to handle potential undefined values
- Improved text cleaning and handling of edge cases in email parsing

* editor working

* compose and video

* fix: remove t3-oss env

* update max results to 10 per requst

* zero button floating sidebar

* lots of changes:
- removes old mail compose modal
- smaller upload limit
- useReducer on components with lots of state
- image logos for some file types (still more to add)
- resolve comments from previous review

* add logos

* straing to staging

* improvements to create ui (#345)

* made create wider

* send to multiple emails and new ui for 'to' list

* add icons for file upload (#346)

* added icon for figma icon

* added else ifs for other icons

* add file name to the getLogo func

* fix figma if statement

* fix figma

* fix excel

* remove console logs

* fix back to original component

* file icons

* ui tweaks

---------

Co-authored-by: Nizzy <nizabizaher@gmail.com>
Co-authored-by: nizzy <140507264+nizzyabi@users.noreply.github.com>

* fix: sidebar and settings page ui fixes (#348)

* fixes

* define to emails

* rotate on hover logo

* early access count on homepage

* updated readme

---------

Co-authored-by: Sijan Mainali <sijanmainali2@gmail.com>
Co-authored-by: Adam <x_1337@outlook.com>
Co-authored-by: Nizzy <nizabizaher@gmail.com>
Co-authored-by: user12224 <122770437+user12224@users.noreply.github.com>
Co-authored-by: nizzy <140507264+nizzyabi@users.noreply.github.com>
2025-03-01 16:36:17 -05:00

26 lines
700 B
TypeScript

"use server";
import * as cheerio from 'cheerio';
export async function extractTextFromHTML(decodedBody: string): Promise<string> {
try {
// Load HTML into cheerio
const $ = cheerio.load(decodedBody);
// Remove script and style elements
$('script').remove();
$('style').remove();
// Get text content and clean it up
const textOnly = $('body')
.text()
.replace(/\r?\n|\r/g, ' ') // Remove line breaks
.replace(/\s+/g, ' ') // Replace multiple spaces with single space
.trim();
return textOnly;
} catch (error) {
console.error("Error extracting text from HTML:", error);
throw new Error("Failed to extract text from HTML");
}
}