import { nothing, TemplateResult, PropertyValueMap } from 'lit'; import { Ref } from 'lit/directives/ref.js'; import { MeetingType } from '../types/meetings.types'; import { MutationController } from '../controllers/mutation-controller'; import { BlobType, ExternalBlobType, FileMutationContextType, FileType, MutateFileProps } from '../types/files.types'; import { MutationStateController } from '../controllers/mutation-state-controller'; import { MutationState } from '@tanstack/query-core'; import { WyCloudFiles } from './wy-cloud-files'; import { ExternalBlobMutationType } from '../data/blob-external'; import { PollOptionType } from '../types/polls.types'; import { EmbedType } from '../types/embeds.types'; import { DropZoneController } from '../controllers/dropzone-controller'; import { WeavySubAppComponent } from '../classes/weavy-sub-app-component'; import { ShadowPartsController } from '../controllers/shadow-parts-controller'; import { MetadataType } from '../types/lists.types'; import { DropFilesEventType } from '../types/files.events'; import { EmbedRemoveEventType } from '../types/embeds.events'; import { WyEditorCore } from './wy-editor-core'; declare global { interface HTMLElementTagNameMap { "wy-editor-msg": WyEditorMsg; } } /** * Rich text editor used for posts, messages and comments. * * **Used sub components:** * * - [``](./ui/wy-avatar.ts) * - [``](./ui/wy-dropdown.ts) * - [``](./ui/wy-item.ts) * - [``](./ui/wy-button.ts) * - [``](./ui/wy-icon.ts) * - [``](./wy-file-item.ts) * - [``](./wy-embed.ts) * - [``](./wy-cloud-files.ts) * - [``](./wy-embed.ts) * * @csspart wy-editor - Root editor container * @csspart wy-dragging - Applied when dragging files over the editor * @csspart wy-editor-msg-inputs - Container for inputs/buttons * @csspart wy-editor-msg-buttons - Container for action buttons * @csspart wy-poll-form - Poll options container * @csspart wy-input - Inputs inside poll options * * @fires {MsgEditorSubmitEventType} submit - Emitted when the editor content is submitted * @fires {CustomEvent} edit-last - Emitted when the last message should be edited. */ export declare class WyEditorMsg extends WeavySubAppComponent { #private; static styles: import('lit').CSSResult[]; /** * Controller for exporting named shadow parts. * * @internal */ protected exportParts: ShadowPartsController; /** * Whether the editor is disabled. */ disabled: boolean; /** * Parent id for context (message/comment/post). */ parentId?: number; /** * Placeholder text for the editor input. */ placeholder: string; /** * Initial editor text content (draft or loaded content). */ text: string; /** * Metadata associated with the editor content (e.g. agent instructions). * */ metadata?: MetadataType; /** * Optional single embed to prefill the editor. * */ embed?: EmbedType; /** * Poll option templates passed to the editor. */ pollOptions: PollOptionType[]; /** * Attached file references (ids/resolved) shown in the editor. * */ attachments: FileType[]; /** * Meeting object attached to the editor (if any). * */ meeting?: MeetingType; /** * Text for the submit button. */ buttonText: string; /** * Whether typing indicators should be emitted. */ typing: boolean; /** * Whether this instance should persist drafts. */ draft: boolean; /** * Editor usage context, used to adjust behavior and styling. */ editorType: "messages" | "posts" | "comments"; /** * CSS class applied to the editor container. */ editorClass: string; /** * Location context to use for file uploads and embeds. */ editorLocation: "messages" | "posts" | "apps" | "files"; /** * Select all content in the editor. */ selectAllContent(): Promise; /** * Place cursor at the end of the editor content. */ setCursorLast(): Promise; /** * Focus the editor input. */ focusInput(): Promise; set embeds(embeds: EmbedType[]); get embeds(): EmbedType[]; /** * Resolves when the editor is available. * * @returns {Promise} */ whenEditor(): Promise; /** * Id used for handling drafts. * @internal */ protected draftKey: string; /** * App id used for mutations. Automatically set to negative number when no app id is available. * @internal */ protected mutationAppId?: number; /** * Mutation controller for uploading blobs. * * @internal */ protected uploadBlobMutation: MutationController; /** * Tracks state of file mutation uploads. * * @internal */ protected mutatingFiles: MutationStateController; /** * External blob mutation handler (e.g. importing external files). * * @internal */ protected externalBlobMutation?: ExternalBlobMutationType; /** * File input element reference. * * @internal */ protected fileInputRef: Ref; /** * Cloud files picker reference. * * @internal */ protected cloudFilesRef: Ref; /** * Drop zone controller for drag & drop file handling. * * @internal */ protected dropZone: DropZoneController; /** * Reference to the editor DOM node wrapper. * * @internal */ protected editorRef: Ref; /** * Throttled typing indicator sender to reduce network traffic. * * @internal */ handleTyping(): Promise; /** * Reference to oauth authentication window when attaching meetings. */ protected authWindow?: WindowProxy | null; constructor(); willUpdate(changedProperties: PropertyValueMap): Promise; protected updated(changedProperties: PropertyValueMap): void; connectedCallback(): void; disconnectedCallback(): void; protected handleRemoveMeeting(): void; /** * Open native file picker. * * @internal */ openFileInput(): Promise; /** * Open cloud files picker overlay. * * @internal */ openCloudFiles(): Promise; /** * Handle files dropped or pasted on the editor. * * @internal * @param e - Drop files event */ protected handleDropFiles(e: DropFilesEventType): void; /** * Upload array of File objects via the upload blob mutation controller. * * Preserves input value if provided and saves draft after each upload. * * @internal * @param files - FileList or array of File objects to upload * @param input - Optional input element to reset after upload */ protected handleUploadFiles(files: File[] | FileList | null, input?: HTMLInputElement): Promise; /** * Handle external blob imports (cloud/external sources). * * @internal * @param externalBlobs - Array of external blob descriptors */ protected handleExternalBlobs(externalBlobs: ExternalBlobType[] | null): void; /** * Handle removal/abortion of an upload mutation and clean cache state. * * @internal * @param mutation - Mutation state object to remove */ protected handleRemoveUpload(mutation: MutationState): void; /** * Persist draft to storage if draft mode is enabled. * * Saves editor text, embeds, poll options and ongoing file uploads to localStorage. * * @internal */ protected saveDraft(): void; /** * Handle removal of an attachment reference from the editor state. * * @internal * @param attachment - Attachment to remove */ protected handleRemoveAttachment(attachment: FileType): void; /** * Submit the editor content by dispatching a `submit` event. * * Validates that there is content to submit and that no uploads/embeds are still processing. * * @internal */ protected submit(): void; protected editLast(): void; /** * Reset the editor state after a successful submit. * * Clears editor content, removes pending uploads from the query cache and deletes the stored draft. * * @internal */ protected resetEditor(): void; /** * Clear the editor UI and internal state (text, embeds, attachments, metadata). * * @internal */ protected clearEditor(): void; /** * Checks if the editor has a dirty internal state (text, embeds, attachments, metadata). * * @internal */ protected hasChanged(): string | number | true | undefined; /** * Throttled drafting saver to minimize writes. * * @internal */ private throttledDrafting; /** * Message event handler for meeting OAuth responses. * * Listens for postMessage responses from the meeting auth window and completes meeting creation. * * @internal * @param e - MessageEvent containing meeting authorization payload (e.data.name). */ private createMeeting; /** * Create or initiate a meeting for the current user. * * If the meeting requires third-party auth, opens an auth popup; otherwise stores the created meeting. * * @internal * @param name - Provider key for the meeting (e.g. "zoom", "google", "microsoft") */ protected handleMeetingClick(name: string): Promise; /** * Add a discovered embed to the editor and persist draft. * * @internal * @param embed - Embed object to add. */ protected setEmbeds(embed: EmbedType): void; /** * Scan content for embeds and add them via setEmbeds callback. * * @internal * @param content - Text content to scan for embed links. */ protected handleEmbeds(content: string): void; /** * Remove an embed by id from the editor embeds list and persist draft. * * @internal * @param e - Embed remove event containing embed id. */ protected removeEmbed(e: EmbedRemoveEventType): void; /** * Cycle the primary embed (move first to the end) and persist draft. * * @internal */ protected swapEmbed(): void; /** * Toggle the poll UI in the editor and initialize default options when opened. * * @param [open=true] - Whether to open the polls - set `false` to close. * @internal */ protected togglePolls(open?: boolean): void; /** * Handle change to a poll option input and persist draft. * * @internal * @param e - Input event * @param index - Index of the poll option changed */ protected handlePollOptionChange(e: Event, index: number): void; /** * Add a new poll option when focus reaches the last option (limit 5). * * @internal * @param e - Focus/keyboard event * @param index - Index of the poll option that triggered the add */ protected handlePollOptionAdd(e: Event, index: number): void; protected renderEditor(): (TemplateResult | typeof nothing)[] | TemplateResult | typeof nothing; protected renderTopSlot(): (TemplateResult | typeof nothing)[] | TemplateResult | typeof nothing; protected renderMiddleSlot(): (TemplateResult | typeof nothing)[] | TemplateResult | typeof nothing; /** * Render the bottom slot which aggregates lists (polls, meetings, file uploads, attachments, embeds). * * @internal */ protected renderBottomSlot(): (TemplateResult | typeof nothing)[] | TemplateResult | typeof nothing; /** * Render the lists section (poll options, meetings, file uploads, attachments, embeds). * * @internal */ protected renderLists(): TemplateResult | typeof nothing; /** * Render the cloud files picker if cloud files feature is enabled. * * @internal */ protected renderCloudFiles(): TemplateResult | typeof nothing; protected render(): TemplateResult<1>; } //# sourceMappingURL=wy-editor-msg.d.ts.map