feat: support HTML content from WYSIWYG editor for job content#3397
feat: support HTML content from WYSIWYG editor for job content#3397
Conversation
- Add sanitizeHtml function to sanitize HTML from rich text editor - Add isHtmlContent to detect HTML vs markdown content - Update renderOpportunityContent to handle both HTML and legacy markdown - Add isomorphic-dompurify dependency for server-side HTML sanitization
|
🍹 The Update (preview) for dailydotdev/api/prod (at 2cbf386) was successful. Resource Changes Name Type Operation
~ vpc-native-sync-subscription-with-cio-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-zombie-images-cron kubernetes:batch/v1:CronJob update
+- clickhouse-sync-clickhouse-sync kubernetes:apps/v1:Deployment create-replacement
+ vpc-native-api-clickhouse-migration-9335b757 kubernetes:batch/v1:Job create
~ vpc-native-calculate-top-readers-cron kubernetes:batch/v1:CronJob update
~ vpc-native-generate-search-invites-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-current-streak-cron kubernetes:batch/v1:CronJob update
~ vpc-native-daily-digest-cron kubernetes:batch/v1:CronJob update
~ vpc-native-ws-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-update-source-public-threshold-cron kubernetes:batch/v1:CronJob update
~ vpc-native-user-profile-updated-sync-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-tag-recommendations-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-zombie-opportunities-cron kubernetes:batch/v1:CronJob update
- vpc-native-api-db-migration-7b6b66d7 kubernetes:batch/v1:Job delete
~ vpc-native-validate-active-users-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-trending-cron kubernetes:batch/v1:CronJob update
~ vpc-native-post-analytics-clickhouse-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-tags-str-cron kubernetes:batch/v1:CronJob update
+- clickhouse-sync-clickhouse-sync-config kubernetes:core/v1:Secret create-replacement
~ vpc-native-post-analytics-history-day-clickhouse-cron kubernetes:batch/v1:CronJob update
~ vpc-native-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-personalized-digest-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-source-tag-view-cron kubernetes:batch/v1:CronJob update
~ vpc-native-private-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-hourly-notification-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-stale-user-transactions-cron kubernetes:batch/v1:CronJob update
~ vpc-native-bg-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-update-highlighted-views-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-gifted-plus-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-zombie-users-cron kubernetes:batch/v1:CronJob update
~ vpc-native-personalized-digest-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-check-analytics-report-cron kubernetes:batch/v1:CronJob update
~ vpc-native-generic-referral-reminder-cron kubernetes:batch/v1:CronJob update
+ vpc-native-api-db-migration-9335b757 kubernetes:batch/v1:Job create
~ vpc-native-clean-zombie-user-companies-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-views-cron kubernetes:batch/v1:CronJob update
- vpc-native-api-clickhouse-migration-7b6b66d7 kubernetes:batch/v1:Job delete
~ vpc-native-temporal-deployment kubernetes:apps/v1:Deployment update
|
| */ | ||
| export const isHtmlContent = (content: string): boolean => { | ||
| // Check for common HTML tags used in rich text | ||
| return /<\/?(?:p|strong|em|ul|ol|li|a|br)[^>]*>/i.test(content); |
There was a problem hiding this comment.
We should match open and closing tag as well, for example <strong>whatever else I want here!!! ### .....
Think HTML content should be always wrapped in a section or parent div. Also markdown can have mix of html links and images, for example github allows <img /> tag. We don't have to support it but somebody pasting markdown from github to us could false detect.
There was a problem hiding this comment.
yes but i think in this case, it's better to be stricter and to think it's html then the opposite. but actually when thinking about it, i don't even need this function. i need to support only html. we don't need backwards compatibility
There was a problem hiding this comment.
Was also gonna say since there's no active users and we store html we don't need backward compat.
rebelchris
left a comment
There was a problem hiding this comment.
Nth: remove the markdown all together for this purpose.
| ALLOWED_ATTR: ['href', 'target', 'rel'], | ||
| // Force all links to open in new tab with nofollow | ||
| ADD_ATTR: ['target', 'rel'], | ||
| }).replace(/<a /g, '<a target="_blank" rel="noopener nofollow" '); |
There was a problem hiding this comment.
Doesn't this add double target/rel if that already exists?
| * Renders content for opportunity fields | ||
| * Handles both HTML (from WYSIWYG editor) and markdown (legacy) content | ||
| * - If content contains HTML tags, sanitizes it directly | ||
| * - If content is markdown (legacy), converts to HTML |
|
@claude we don't need to the markdown support for this feature anymore, so you can remove it from here |
|
Claude finished @idoshamun's task in 1m 48s —— View job Completed removing markdown support
Changes madeI've removed the markdown support from the opportunity content feature:
The changes have been committed and pushed to the branch. The feature now only supports HTML content from the WYSIWYG editor without any backward compatibility for markdown. --- | Branch |
Remove isHtmlContent helper and markdown fallback from renderOpportunityContent since backward compatibility is not needed. Only HTML content from WYSIWYG editor is supported now. Co-authored-by: Ido Shamun <idoshamun@users.noreply.github.com>
Summary
Test plan