import { html, nothing, type PropertyValueMap, type 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 commentEditorStyles from "../scss/components/editor-comment.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-comment": WyEditorComment; } } /** * Comment editor used for composing comments. * * **Used sub components:** * * - [``](./ui/wy-dropdown.ts) * - [``](./ui/wy-dropdown.ts) * - [``](./ui/wy-icon.ts) * - [``](./ui/wy-button.ts) * * @csspart wy-editor-comment-inputs - Container for the editor inputs and add menu * @csspart wy-editor-comment-text - Wrapper for the editor text area * @csspart wy-is-invalid - Applied to the editor text wrapper when there is a validation/error state */ @customElement("wy-editor-comment") @localized() export class WyEditorComment extends WyEditorMsg { static override styles = [...WyEditorMsg.styles, commentEditorStyles]; constructor() { super(); this.editorType = "comments"; this.editorClass = "wy-editor-comment"; } override async willUpdate(changedProperties: PropertyValueMap): Promise { await super.willUpdate(changedProperties); if (changedProperties.has("editorLocation")) { if (this.editorLocation === "files") { this.editorClass = "wy-editor-comment wy-editor-comment-bottom"; } else if (this.editorLocation === "apps") { this.editorClass = "wy-editor-comment wy-editor-comment-bottom"; } } } /** * Render the top slot for comment editor with no content. * * @internal */ protected override renderTopSlot(): TemplateResult | typeof nothing { return nothing; } /** * 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.Meetings, Feature.ZoomMeetings, Feature.GoogleMeet, Feature.MicrosoftTeams, Feature.Polls, ) ? 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?.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} ${this.componentFeatures?.allowsFeature(Feature.Polls) ? html` this.togglePolls()} title=${msg("Poll")}> ${msg("Poll")} ` : nothing} ` : nothing} ${this.renderEditor()}
`; } /** * Render content that appears below the message editor. * * By default returns the same lists section used by the base editor. * * @internal */ protected override renderBottomSlot(): (TemplateResult | typeof nothing)[] | TemplateResult | typeof nothing { return [this.renderLists()]; } }