Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
email-pill: Add generate_pill_html for email pills.
Pritesh Shetty4a719a6d676c
diff --git a/web/src/email_pill.ts b/web/src/email_pill.tsindex 2d3cec86dc4..91ba9741589 100644--- a/web/src/email_pill.ts+++ b/web/src/email_pill.ts@@ -1,5 +1,7 @@import {parseAddressList, parseOneAddress} from "email-addresses";+import render_input_pill from "../templates/input_pill.hbs";+import type {InputPillConfig, InputPillContainer} from "./input_pill.ts";import * as input_pill from "./input_pill.ts";@@ -66,6 +68,19 @@ export function split_text_to_form_email_pills(raw_emails: string): string[] {.map((email) => (email.name ? `"${email.name}" <${email.address}>` : email.address));}+export function generate_pill_html(item: EmailPill): string {+ const parsed_address = parseOneAddress(item.email);+ const name = parsed_address?.name;+ // Remove quotes from the name if they exist+ const invited_user_name = name?.replaceAll(/"([^"]*)"/g, "$1");++ return render_input_pill({+ is_email_pill: true,+ invited_user_name,+ display_value: invited_user_name ? `<${item.parsed_email}>` : item.parsed_email,+ });+}+export function create_pills($pill_container: JQuery,pill_config?: InputPillConfig,@@ -78,6 +93,7 @@ export function create_pills(get_display_value_from_item: get_email_from_item,split_text_on_comma: false,split_text_to_form_pills: split_text_to_form_email_pills,+ generate_pill_html,});return pill_container;}diff --git a/web/styles/input_pill.css b/web/styles/input_pill.cssindex 3efa598233a..4e8d1b52b21 100644--- a/web/styles/input_pill.css+++ b/web/styles/input_pill.css@@ -57,6 +57,15 @@background-color: var(--color-background-input-pill-hover);}+ .invited-user-name {+ flex: 1;+ min-width: 0;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+ margin-right: 3px;+ }+.pill-image {height: var(--height-input-pill);width: var(--height-input-pill);diff --git a/web/templates/input_pill.hbs b/web/templates/input_pill.hbsindex 6c97bff980a..f7d5c764607 100644--- a/web/templates/input_pill.hbs+++ b/web/templates/input_pill.hbs@@ -11,6 +11,11 @@{{/if}}{{/if}}<span class="pill-label">+ {{#if is_email_pill}}+ {{~#if invited_user_name}}+ <span class="invited-user-name">{{invited_user_name}}</span>+ {{~/if~}}+ {{/if}}<span class="pill-value">{{#if has_stream}}{{> decorated_channel_name stream=stream }}