## class: `WyEditorFile`, `wy-editor-file`

Rich text editor used for posts, messages and comments.

**Used sub components:**

*   [`<wy-avatar>`](./ui/wy-avatar)
*   [`<wy-dropdown>`](./ui/wy-dropdown)
*   [`<wy-item>`](./ui/wy-item)
*   [`<wy-button>`](./ui/wy-button)
*   [`<wy-icon>`](./ui/wy-icon)

### Fields

| Name                | Type                                                         | Default     | Description                                                             | Inherited From        |
| ------------------- | ------------------------------------------------------------ | ----------- | ----------------------------------------------------------------------- | --------------------- |
| `disabled`          | `boolean`                                                    | `false`     | Whether the editor is disabled.                                         |                       |
| `parentId`          | `number \| undefined`                                        |             | Parent id for context (message/comment/post).                           |                       |
| `placeholder`       | `string`                                                     | `""`        | Placeholder text for the editor input.                                  |                       |
| `text`              | `string`                                                     | `""`        | Initial editor text content (draft or loaded content).                  |                       |
| `file`              | `FileType \| undefined`                                      |             | The file info if applicable. Required for full functionality.           |                       |
| `fileContent`       | `string \| undefined`                                        |             | Current file text content (loaded content).                             |                       |
| `appearance`        | `"default" \| "code" \| "document" \| "text"`                | `"default"` | Optionally display the editor as a code editor or as a document layout. |                       |
| `mode`              | `ThemeModeType`                                              | `"auto"`    | Override the theme mode.                                                |                       |
| `metadata`          | `MetadataType \| undefined`                                  | `{}`        | Metadata associated with the editor content (e.g. agent instructions).  |                       |
| `buttonText`        | `string`                                                     | `""`        | Text for the submit button.                                             |                       |
| `draft`             | `boolean`                                                    | `false`     | Whether this instance should persist drafts.                            |                       |
| `draftText`         | `string \| undefined`                                        |             | Initial draft text.                                                     |                       |
| `markdownIsLoading` |                                                              |             | Reactive state for markdown loading.                                    |                       |
| `showLive`          | `boolean`                                                    | `false`     | Whether to show a live markdown preview in an overlay.                  |                       |
| `liveRender`        | `Uint8Array<ArrayBufferLike> \| string \| null \| undefined` |             | Markdown text rendered as a html string.                                |                       |
| `app`               | `AppType \| undefined`                                       |             | The app data.                                                           | WeavySubAppComponent  |
| `apps`              | `AppListType \| undefined`                                   |             | Multiple apps data.                                                     | WeavySubAppComponent  |
| `link`              | `LinkType \| undefined`                                      |             | Any provided link that should be loaded, shown and highlighted.         | WeavySubTypeComponent |

### Methods

| Name               | Description                                                                                           | Parameters                        | Return                       | Inherited From        |
| ------------------ | ----------------------------------------------------------------------------------------------------- | --------------------------------- | ---------------------------- | --------------------- |
| `selectAllContent` | Select all content in the editor.                                                                     |                                   |                              |                       |
| `setCursorFirst`   | Place cursor at the end of the editor content.                                                        |                                   |                              |                       |
| `setCursorLast`    | Place cursor at the end of the editor content.                                                        |                                   |                              |                       |
| `focusInput`       | Focus the editor input.                                                                               |                                   |                              |                       |
| `whenEditor`       | Resolves when the editor is available.                                                                |                                   | `Promise<WyEditorCore>`      |                       |
| `getText`          | Gets the displayed document, including restored drafts and edits not yet saved by the draft throttle. |                                   |                              |                       |
| `whenApp`          | Resolves when app data is available.                                                                  |                                   | `Promise<AppType>`           | WeavySubAppComponent  |
| `whenApps`         | Resolves when multiple app data is available.                                                         |                                   | `Promise<AppListType>`       | WeavySubAppComponent  |
| `whenLink`         | Resolves when a provided link is available.                                                           |                                   | `Promise<LinkType>`          | WeavySubTypeComponent |
| `whenReady`        | Resolves when the component has rendered first time.                                                  |                                   | `Promise<WeavySubComponent>` | WeavySubComponent     |
| `dispatchAction`   | Dispatch a \`wy-action\` event on the component.                                                      | `detail: WyActionEventDetailType` | `boolean`                    | WeavySubComponent     |

### Events

| Name        | Type                       | Description                                     | Inherited From    |
| ----------- | -------------------------- | ----------------------------------------------- | ----------------- |
| `submit`    | `MsgEditorSubmitEventType` | Emitted when the editor content is submitted    |                   |
| `edit-last` | `CustomEvent`              | Emitted when the last message should be edited. |                   |
| `ready`     | `CustomEvent`              | When the component has rendered.                | WeavySubComponent |

### Attributes

| Name          | Field       | Inherited From |
| ------------- | ----------- | -------------- |
| `disabled`    | disabled    |                |
| `placeholder` | placeholder |                |
| `appearance`  | appearance  |                |
| `mode`        | mode        |                |
| `metadata`    | metadata    |                |
| `buttonText`  | buttonText  |                |
| `draft`       | draft       |                |
| `showLive`    | showLive    |                |

### CSS Parts

| Name                    | Description                  |
| ----------------------- | ---------------------------- |
| `wy-editor`             | Root editor container        |
| `wy-editor-msg-inputs`  | Container for inputs/buttons |
| `wy-editor-msg-buttons` | Container for action buttons |

<details><summary>Private API</summary>

### Fields

| Name                        | Privacy | Type                                                               | Default                                                                               | Description | Inherited From        |
| --------------------------- | ------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------- | ----------- | --------------------- |
| `#resolveEditor`            | private | `(editor: WyEditorCore) => void \| undefined`                      |                                                                                       |             |                       |
| `#whenEditor`               | private |                                                                    | `new Promise<WyEditorCore>((r) => { this.#resolveEditor = r; })`                      |             |                       |
| `#resolveApp`               | private | `(app: AppType) => void \| undefined`                              |                                                                                       |             | WeavySubAppComponent  |
| `#whenApp`                  | private |                                                                    | `new Promise<AppType>((r) => { this.#resolveApp = r; })`                              |             | WeavySubAppComponent  |
| `#resolveApps`              | private | `(apps: AppListType) => void \| undefined`                         |                                                                                       |             | WeavySubAppComponent  |
| `#whenApps`                 | private |                                                                    | `new Promise<AppListType>((r) => { this.#resolveApps = r; })`                         |             | WeavySubAppComponent  |
| `#resolveContextDataBlobs`  | private | `(blobs: ContextDataBlobsType) => void \| undefined`               |                                                                                       |             | WeavySubTypeComponent |
| `#whenContextDataBlobs`     | private |                                                                    | `new Promise<ContextDataBlobsType>((r) => { this.#resolveContextDataBlobs = r; })`    |             | WeavySubTypeComponent |
| `#resolveComponentFeatures` | private | `(componentFeatures: ComponentFeaturePolicy) => void \| undefined` |                                                                                       |             | WeavySubTypeComponent |
| `#whenComponentFeatures`    | private |                                                                    | `new Promise<ComponentFeaturePolicy>((r) => { this.#resolveComponentFeatures = r; })` |             | WeavySubTypeComponent |
| `#resolveLink`              | private | `(link: LinkType) => void \| undefined`                            |                                                                                       |             | WeavySubTypeComponent |
| `#whenLink`                 | private |                                                                    | `new Promise<LinkType>((r) => { this.#resolveLink = r; })`                            |             | WeavySubTypeComponent |
| `#resolveSettings`          | private | `(settings: WeavyComponentSettingsType) => void \| undefined`      |                                                                                       |             | WeavySubTypeComponent |
| `#whenSettings`             | private |                                                                    | `new Promise<WeavyComponentSettingsType>((r) => { this.#resolveSettings = r; })`      |             | WeavySubTypeComponent |
| `#resolveContextId`         | private | `(contextId: ContextIdType) => void \| undefined`                  |                                                                                       |             | WeavySubComponent     |
| `#whenContextId`            | private |                                                                    | `new Promise<ContextIdType>((r) => { this.#resolveContextId = r; })`                  |             | WeavySubComponent     |
| `#resolveUser`              | private | `(user: UserType) => void \| undefined`                            |                                                                                       |             | WeavySubComponent     |
| `#whenUser`                 | private |                                                                    | `new Promise<UserType>((r) => { this.#resolveUser = r; })`                            |             | WeavySubComponent     |
| `#resolveWeavy`             | private | `(weavy: WeavyType) => void \| undefined`                          |                                                                                       |             | WeavySubComponent     |
| `#whenWeavy`                | private |                                                                    | `new Promise<WeavyType>((r) => { this.#resolveWeavy = r; })`                          |             | WeavySubComponent     |
| `#resolveReady`             | private | `(component: WeavySubComponent) => void \| undefined`              |                                                                                       |             | WeavySubComponent     |
| `#whenReady`                | private |                                                                    | `new Promise<WeavySubComponent>((r) => { this.#resolveReady = r; })`                  |             | WeavySubComponent     |

### Methods

| Name               | Privacy   | Description | Parameters | Return                                                                     | Inherited From |
| ------------------ | --------- | ----------- | ---------- | -------------------------------------------------------------------------- | -------------- |
| `renderEditor`     | protected |             |            | `(TemplateResult \| typeof nothing)[] \| TemplateResult \| typeof nothing` |                |
| `renderLiveView`   | protected |             |            |                                                                            |                |
| `renderTopSlot`    | protected |             |            | `(TemplateResult \| typeof nothing)[] \| TemplateResult \| typeof nothing` |                |
| `renderMiddleSlot` | protected |             |            | `(TemplateResult \| typeof nothing)[] \| TemplateResult \| typeof nothing` |                |

</details>

<hr/>

## Exports

| Kind                        | Name             | Declaration  | Module                           | Package |
| --------------------------- | ---------------- | ------------ | -------------------------------- | ------- |
| `js`                        | `WyEditorFile`   | WyEditorFile | lib/components/wy-editor-file.ts |         |
| `custom-element-definition` | `wy-editor-file` | WyEditorFile | lib/components/wy-editor-file.ts |         |
