# engine/view/placeholder

module

<a id="interfaces">

## Interfaces

<a id="interface-PlaceholderableViewElement">

### `PlaceholderableViewElement`

<a id="functions">

## Functions

<a id="function-disableViewPlaceholder">

### `disableViewPlaceholder( view, element ) → void`

Disables the placeholder functionality from a given element.

See [`enableViewPlaceholder()`](#function-enableViewPlaceholder) to learn more.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/view/placeholder.ts#L100)

#### Parameters

* `view: EditingView`
* `element: ViewElement`

#### Returns

* `void`

<a id="function-enableViewPlaceholder">

### `enableViewPlaceholder( options = { options.element, options.isDirectHost?, options.keepOnFocus?, options.text?, options.view } ) → void`

A helper that enables a placeholder on the provided view element (also updates its visibility). The placeholder is a CSS pseudo–element (with a text content) attached to the element.

To change the placeholder text, change value of the `placeholder` property in the provided `element`.

To disable the placeholder, use [`disableViewPlaceholder()`](#function-disableViewPlaceholder) helper.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/view/placeholder.ts#L42)

#### Parameters

* `options: object`

  Configuration options of the placeholder.

  Properties

  * `options.element: ViewEditableElement | PlaceholderableViewElement`

    Element that will gain a placeholder. See `options.isDirectHost` to learn more.

  * `options.isDirectHost?: boolean`

    If set `false`, the placeholder will not be enabled directly in the passed `element` but in one of its children (selected automatically, i.e. a first empty child element). Useful when attaching placeholders to elements that can host other elements (not just text), for instance, editable root elements.

    Defaults to `true`

  * `options.keepOnFocus?: boolean`

    If set `true`, the placeholder stay visible when the host element is focused.

    Defaults to `false`

  * `options.text?: string`

    Placeholder text. It's **deprecated** and will be removed soon. Use [`options.element.placeholder`](module_engine_view_placeholder-PlaceholderableViewElement.md#member-placeholder) instead.

  * `options.view: EditingView`

    Editing view instance.

#### Returns

* `void`

<a id="function-hideViewPlaceholder">

### `hideViewPlaceholder( writer, element ) → boolean`

Hides a placeholder in the element by changing related attributes and CSS classes.

**Note**: This helper will not update the placeholder visibility nor manage the it in any way in the future. What it does is a one–time state change of an element. Use [`enableViewPlaceholder()`](#function-enableViewPlaceholder) and [`disableViewPlaceholder()`](#function-disableViewPlaceholder) for full placeholder functionality.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/view/placeholder.ts#L155)

#### Parameters

* `writer: ViewDowncastWriter`
* `element: ViewElement`

#### Returns

* `boolean`

  `true`, if any changes were made to the `element`.

<a id="function-needsViewPlaceholder">

### `needsViewPlaceholder( element, keepOnFocus ) → boolean`

Checks if a placeholder should be displayed in the element.

**Note**: This helper will blindly check the possibility of showing a placeholder directly in the root editable element if one is passed, which may not be the expected result. If an element can host other elements (not just text), most likely one of its children should be checked instead because it will be the final host for the placeholder. Use [`enableViewPlaceholder()`](#function-enableViewPlaceholder) in that case or make sure the correct element is passed to the helper.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/view/placeholder.ts#L178)

#### Parameters

* `element: ViewElement`

  Element that holds the placeholder.

* `keepOnFocus: boolean`

  Focusing the element will keep the placeholder visible.

#### Returns

* `boolean`

<a id="function-showViewPlaceholder">

### `showViewPlaceholder( writer, element ) → boolean`

Shows a placeholder in the provided element by changing related attributes and CSS classes.

**Note**: This helper will not update the placeholder visibility nor manage the it in any way in the future. What it does is a one–time state change of an element. Use [`enableViewPlaceholder()`](#function-enableViewPlaceholder) and [`disableViewPlaceholder()`](#function-disableViewPlaceholder) for full placeholder functionality.

**Note**: This helper will blindly show the placeholder directly in the root editable element if one is passed, which could result in a visual clash if the editable element has some children (for instance, an empty paragraph). Use [`enableViewPlaceholder()`](#function-enableViewPlaceholder) in that case or make sure the correct element is passed to the helper.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-engine/src/view/placeholder.ts#L134)

#### Parameters

* `writer: ViewDowncastWriter`
* `element: ViewElement`

#### Returns

* `boolean`

  `true`, if any changes were made to the `element`.

---

Full index of the CKEditor 5 API reference: [llms.txt](llms.txt)
