import { html, nothing, TemplateResult } from "lit"; import { customElement } from "../utils/decorators/custom-element"; import { localized, msg } from "@lit/localize"; import { ref } from "lit/directives/ref.js"; import { Feature } from "../types/features.types"; import messageEditorCss from "../scss/components/editor-message.scss"; import { WyEditorMsg } from "./wy-editor-msg"; import "./ui/wy-dropdown"; import "./ui/wy-icon"; import "./ui/wy-button"; declare global { interface HTMLElementTagNameMap { "wy-editor-message": WyEditorMessage; } } /** * Message editor used inside conversations for composing messages. * * **Used sub components:** * * - [``](./ui/wy-dropdown.ts) * - [``](./ui/wy-dropdown.ts) * - [``](./ui/wy-icon.ts) * - [``](./ui/wy-button.ts) * * @csspart wy-editor-message-inputs - Container for the editor inputs and add menu * @csspart wy-editor-message-text - Wrapper for the editor text area */ @customElement("wy-editor-message") @localized() export class WyEditorMessage extends WyEditorMsg { static override styles = [...WyEditorMsg.styles, messageEditorCss]; constructor() { super(); this.editorType = "messages"; this.editorClass = "wy-editor-message"; } /** * Render content that appears above the message editor. * * By default returns the same lists section used by the base editor. * * @internal */ protected override renderTopSlot(): (TemplateResult | typeof nothing)[] | TemplateResult | typeof nothing { return [this.renderLists()]; } /** * Render the primary middle slot containing the add-menu, editor and send button. * * Overrides the base implementation to provide message-specific controls and layout. * * @internal */ protected override renderMiddleSlot() { return html`
${this.componentFeatures?.allowsAnyFeature( Feature.Attachments, Feature.CloudFiles, Feature.Polls, Feature.Meetings, Feature.ZoomMeetings, Feature.GoogleMeet, Feature.MicrosoftTeams, ) ? html` ${this.componentFeatures?.allowsFeature(Feature.Attachments) ? html` this.openFileInput()} title=${msg("From device")}> ${msg("From device")} e.stopPropagation()} @change=${(e: Event) => this.handleUploadFiles( Array.from((e.target as HTMLInputElement).files || []), e.target as HTMLInputElement, )} multiple hidden tabindex="-1" /> ` : nothing} ${this.componentFeatures?.allowsFeature(Feature.CloudFiles) ? html` this.openCloudFiles()} title=${msg("From cloud")}> ${msg("From cloud")} ` : nothing} ${this.componentFeatures?.allowsFeature(Feature.Polls) ? html` this.togglePolls()} title=${msg("Poll")}> ${msg("Poll")} ` : nothing} ${this.componentFeatures?.allowsAnyFeature(Feature.Meetings, Feature.ZoomMeetings) ? html` this.handleMeetingClick("zoom")} title=${msg("Zoom meeting")}> ${msg("Zoom meeting")} ` : nothing} ${this.componentFeatures?.allowsAnyFeature(Feature.Meetings, Feature.GoogleMeet) ? html` this.handleMeetingClick("google")} title=${msg("Google Meet")}> ${msg("Google Meet")} ` : nothing} ${this.componentFeatures?.allowsAnyFeature(Feature.Meetings, Feature.MicrosoftTeams) ? html` this.handleMeetingClick("microsoft")} title=${msg("Microsoft Teams")} > ${msg("Microsoft Teams")} ` : nothing} ` : nothing} ${this.renderEditor()}
`; } /** * Render the bottom slot for message editor with no content. * * @internal */ protected override renderBottomSlot(): (TemplateResult | typeof nothing)[] | TemplateResult | typeof nothing { return nothing; } }