## class: `WyFileViewText`, `wy-file-view-text`

Text / code / HTML preview component used in file previews.

**Used sub components:**

*   [`<wy-empty>`](./wy-empty)
*   [`<wy-progress-circular>`](./ui/wy-progress-circular)
*   [`<wy-container>`](./ui/wy-container)

### Fields

| Name      | Type                             | Default  | Description                                                                                                           | Inherited From        |
| --------- | -------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------- | --------------------- |
| `file`    | `FileType \| undefined`          |          | Source file.                                                                                                          |                       |
| `edit`    | `boolean`                        | `false`  |                                                                                                                       |                       |
| `draft`   | `boolean`                        | `false`  | Show the unsaved draft instead of the stored content. Ignored while editing, since the editor loads the draft itself. |                       |
| `display` | `"text" \| "code" \| "document"` | `"text"` |                                                                                                                       |                       |
| `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        |
| ---------------- | ------------------------------------------------------------------------------------------------------------- | --------------------------------- | ---------------------------- | --------------------- |
| `setFocus`       | Puts focus to the editor if available.                                                                        |                                   |                              |                       |
| `save`           | Publishes the current text edit, or the unsaved draft when called outside the editor (from the preview menu). |                                   |                              |                       |
| `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    |
| --------------------- | ---------------------------- | -------------------------------------- | ----------------- |
| `file-preview-loaded` | `FilePreviewLoadedEventType` | The file preview is considered loaded. |                   |
| `ready`               | `CustomEvent`                | When the component has rendered.       | WeavySubComponent |

### Attributes

| Name    | Field | Inherited From |
| ------- | ----- | -------------- |
| `edit`  | edit  |                |
| `draft` | draft |                |

### CSS Parts

| Name                  | Description                                    |
| --------------------- | ---------------------------------------------- |
| `wy-content-progress` | Progress indicator shown while loading.        |
| `wy-content-code`     | Container for rendered code content.           |
| `wy-code`             | Modifier for code styling.                     |
| `wy-document`         | Document wrapper used for HTML/text rendering. |
| `wy-content-html`     | Container for rendered HTML.                   |
| `wy-content-text`     | Container for plain text content.              |

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

### Fields

| Name                        | Privacy   | Type                                                               | Default                                                                               | Description                                                                                          | Inherited From        |
| --------------------------- | --------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | --------------------- |
| `exportParts`               | protected |                                                                    | `new ShadowPartsController(this)`                                                     |                                                                                                      |                       |
| `contentKey`                | private   | `string \| undefined`                                              |                                                                                       | Identifies the loaded revision and representation independently of mutable query-cache file objects. |                       |
| `contentRequest`            | private   | `number`                                                           | `0`                                                                                   | Prevents an older content response from overwriting a newer revision or representation.              |                       |
| `#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 |
| ------------ | --------- | --------------------------------------------------------------------------------- | -------------------------------------------------------- | --------------------------------------------- | -------------- |
| `renderText` | protected | Renders the content to show, either the stored file content or the unsaved draft. | `content: string, contentHtml: string, isDraft: boolean` | `TemplateResult \| DirectiveResult \| string` |                |

</details>

<hr/>

## Exports

| Kind                        | Name                | Declaration    | Module                              | Package |
| --------------------------- | ------------------- | -------------- | ----------------------------------- | ------- |
| `js`                        | `WyFileViewText`    | WyFileViewText | lib/components/wy-file-view-text.ts |         |
| `custom-element-definition` | `wy-file-view-text` | WyFileViewText | lib/components/wy-file-view-text.ts |         |
