# TooltipManager

class

A tooltip manager class for the UI of the editor.

**Note**: Most likely you do not have to use the `TooltipManager` API listed below in order to display tooltips. Popular [UI components](../framework/architecture/ui-library.md) support tooltips out-of-the-box via observable properties (see [`tooltip`](module_ui_button_buttonview-ButtonView.md#member-tooltip) and [`tooltipPosition`](module_ui_button_buttonview-ButtonView.md#member-tooltipPosition)).

#### Displaying tooltips

To display a tooltip, set `data-cke-tooltip-text` attribute on any DOM element:

```typescript
domElement.dataset.ckeTooltipText = 'My tooltip';
```

The tooltip will show up whenever the user moves the mouse over the element or the element gets focus in DOM.

#### Positioning tooltips

To change the position of the tooltip, use the `data-cke-tooltip-position` attribute (`s`, `se`, `sw`, `n`, `e`, or `w`):

```typescript
domElement.dataset.ckeTooltipText = 'Tooltip to the north';
domElement.dataset.ckeTooltipPosition = 'n';
```

#### Disabling tooltips

In order to disable the tooltip temporarily, use the `data-cke-tooltip-disabled` attribute:

```typescript
domElement.dataset.ckeTooltipText = 'Disabled. For now.';
domElement.dataset.ckeTooltipDisabled = 'true';
```

#### Instant tooltips

To remove the delay before showing or hiding the tooltip, use the `data-cke-tooltip-instant` attribute:

```typescript
domElement.dataset.ckeTooltipInstant = 'true';
```

#### Styling tooltips

By default, the tooltip has `.ck-tooltip` class and its text inner `.ck-tooltip__text`.

If your tooltip requires custom styling, using `data-cke-tooltip-class` attribute will add additional class to the balloon displaying the tooltip:

```typescript
domElement.dataset.ckeTooltipText = 'Tooltip with a red text';
domElement.dataset.ckeTooltipClass = 'my-class';
```

```css
.ck.ck-tooltip.my-class { color: red }
```

**Note**: This class is a singleton. All editor instances re-use the same instance loaded by [`EditorUI`](module_ui_editorui_editorui-EditorUI.md) of the first editor.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L98)

<a id="properties">

## Properties

<a id="member-balloonPanelView">

### `balloonPanelView: BalloonPanelView` _(readonly)_

The instance of the balloon panel that renders and positions the tooltip.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L107)

<a id="member-tooltipTextView">

### `tooltipTextView: View<HTMLElement> & object` _(readonly)_

The view rendering text of the tooltip.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L102)

<a id="member-_bodyCollectionByTree">

### `_bodyCollectionByTree: Map<Document | ShadowRoot, BodyCollection>` _(private)_

Maps each DOM tree (the document or a shadow root) that hosts tooltip-bearing UI to the body collection the shared tooltip balloon should be pinned into for targets in that tree. Rebuilt from [`_registrations`](#static-member-_registrations) by [`_rebuild`](#function-_rebuild).

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

<a id="member-_currentElementWithTooltip">

### `_currentElementWithTooltip: HTMLElement | null` _(private)_

Stores the reference to the DOM element the tooltip is attached to. `null` when there's no tooltip in the UI.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L122)

<a id="member-_currentTooltipPosition">

### `_currentTooltipPosition: TooltipPosition | null` _(private)_

Stores the current tooltip position. `null` when there's no tooltip in the UI.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L127)

<a id="member-_mutationObserver">

### `_mutationObserver: MutationObserverWrapper | null` _(private)_

An instance of the mutation observer that keeps track on target element attributes changes.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L132)

<a id="member-_pinTooltipDebounced">

### `_pinTooltipDebounced: DebouncedFunc<( targetDomElement: HTMLElement, data: TooltipData ) => void>` _(private)_

A debounced version of [`_pinTooltip`](#function-_pinTooltip). Tooltips show with a delay to avoid flashing and to improve the UX.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L138)

<a id="member-_refCount">

### `_refCount: number` _(private)_

The number of holders (editors and features) currently using the singleton, so it is destroyed only when the last one [releases](#function-release) it.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L163)

<a id="member-_shadowRoots">

### `_shadowRoots: Set<ShadowRoot>` _(private)_

Shadow roots the manager currently has listeners attached to.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L148)

<a id="member-_unpinTooltipDebounced">

### `_unpinTooltipDebounced: DebouncedFunc<VoidFunction>` _(private)_

A debounced version of [`_unpinTooltip`](#function-_unpinTooltip). Tooltips hide with a delay to allow hovering of their titles.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L143)

<a id="member-_watchdogExcluded">

### `_watchdogExcluded: true` _(private)_

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L157)

#### Static properties

<a id="static-member-defaultBalloonPositions">

### `defaultBalloonPositions: Record<string, PositioningFunction>` _(static)_

A set of default [positioning functions](module_utils_dom_position-PositioningFunction.md) used by the `TooltipManager` to pin tooltips in different positions.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L113)

<a id="static-member-_instance">

### `_instance: TooltipManager | null` _(private)_

A reference to the `TooltipManager` instance. The class is a singleton and as such, successive attempts at creating instances should return this instance.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L169)

<a id="static-member-_registrations">

### `_registrations: Map<BodyCollection, BodyCollectionRegistration>` _(private)_

The body collections the shared tooltip balloon may be pinned into, each with the sources describing where its tooltip-bearing UI lives: an optional [`ShadowRootRegistry`](module_utils_dom_shadowrootregistry-ShadowRootRegistry.md) (the shadow roots its out-of-collection UI occupies) and an optional emitter whose `update` event should reposition a pinned tooltip.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L177)

<a id="methods">

## Methods

<a id="function-constructor">

### `constructor( locale )` _(private)_

Creates an instance of the tooltip manager. Private – use [`for`](#static-function-for) to obtain the shared singleton.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L204)

#### Parameters

* `locale: Locale`

<a id="function-delegate">

### `delegate( events ) → EmitterMixinDelegateChain` _(inherited)_

Delegates selected events to another [`Emitter`](module_utils_emittermixin-Emitter.md). For instance:

```typescript
emitterA.delegate( 'eventX' ).to( emitterB );
emitterA.delegate( 'eventX', 'eventY' ).to( emitterC );
```

then `eventX` is delegated (fired by) `emitterB` and `emitterC` along with `data`:

```typescript
emitterA.fire( 'eventX', data );
```

and `eventY` is delegated (fired by) `emitterC` along with `data`:

```typescript
emitterA.fire( 'eventY', data );
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/emittermixin.ts#L539)

#### Parameters

* `events: Array<string>`

  Event names that will be delegated to another emitter.

#### Returns

* `EmitterMixinDelegateChain`

<a id="function-fire">

### `fire( eventOrInfo, args ) → GetEventInfo<TEvent>[ 'return' ]` _(inherited)_

Fires an event, executing all callbacks registered for it.

The first parameter passed to callbacks is an [`EventInfo`](module_utils_eventinfo-EventInfo.md) object, followed by the optional `args` provided in the `fire()` method call.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/emittermixin.ts#L512)

#### Type parameters

* `TEvent: extends BaseEvent`

  The type describing the event. See [`BaseEvent`](module_utils_emittermixin-BaseEvent.md).

#### Parameters

* `eventOrInfo: GetNameOrEventInfo<TEvent>`

  The name of the event or `EventInfo` object if event is delegated.

* `args: TEvent[ 'args' ]`

  Additional arguments to be passed to the callbacks.

#### Returns

* `GetEventInfo<TEvent>[ 'return' ]`

  By default the method returns `undefined`. However, the return value can be changed by listeners through modification of the [`evt.return`](module_utils_eventinfo-EventInfo.md#member-return)'s property (the event info is the first param of every callback).

<a id="function-listenTo:DOM_EMITTER">

### `listenTo( emitter, event, callback, options? ) → void` _(inherited)_

Registers a callback function to be executed when an event is fired in a specific (emitter) object.

Events can be grouped in namespaces using `:`. When namespaced event is fired, it additionally fires all callbacks for that namespace.

```typescript
// myEmitter.on( ... ) is a shorthand for myEmitter.listenTo( myEmitter, ... ).
myEmitter.on( 'myGroup', genericCallback );
myEmitter.on( 'myGroup:myEvent', specificCallback );

// genericCallback is fired.
myEmitter.fire( 'myGroup' );
// both genericCallback and specificCallback are fired.
myEmitter.fire( 'myGroup:myEvent' );
// genericCallback is fired even though there are no callbacks for "foo".
myEmitter.fire( 'myGroup:foo' );
```

An event callback can [stop the event](module_utils_eventinfo-EventInfo.md#member-stop) and set the [return value](module_utils_eventinfo-EventInfo.md#member-return) of the [`fire`](#function-fire) method.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/dom/emittermixin.ts#L457)

#### Type parameters

* `TEvent: extends BaseEvent`

  The type describing the event. See [`BaseEvent`](module_utils_emittermixin-BaseEvent.md).

#### Parameters

* `emitter: Emitter`

  The object that fires the event.

* `event: TEvent[ 'name' ]`

  The name of the event.

* `callback: GetCallback<TEvent>`

  The function to be called on event.

* `options?: CallbackOptions`

  Additional options.

#### Returns

* `void`

<a id="function-listenTo:BASE_EMITTER">

### `listenTo( emitter, event, callback, options? ) → void` _(inherited)_

Registers a callback function to be executed when an event is fired in a specific (emitter) object.

Events can be grouped in namespaces using `:`. When namespaced event is fired, it additionally fires all callbacks for that namespace.

```typescript
// myEmitter.on( ... ) is a shorthand for myEmitter.listenTo( myEmitter, ... ).
myEmitter.on( 'myGroup', genericCallback );
myEmitter.on( 'myGroup:myEvent', specificCallback );

// genericCallback is fired.
myEmitter.fire( 'myGroup' );
// both genericCallback and specificCallback are fired.
myEmitter.fire( 'myGroup:myEvent' );
// genericCallback is fired even though there are no callbacks for "foo".
myEmitter.fire( 'myGroup:foo' );
```

An event callback can [stop the event](module_utils_eventinfo-EventInfo.md#member-stop) and set the [return value](module_utils_eventinfo-EventInfo.md#member-return) of the [`fire`](#function-fire) method.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/emittermixin.ts#L475)

#### Type parameters

* `TEvent: extends BaseEvent`

  The type describing the event. See [`BaseEvent`](module_utils_emittermixin-BaseEvent.md).

#### Parameters

* `emitter: Emitter`

  The object that fires the event.

* `event: TEvent[ 'name' ]`

  The name of the event.

* `callback: GetCallback<TEvent>`

  The function to be called on event.

* `options?: GetCallbackOptions<TEvent>`

  Additional options.

#### Returns

* `void`

<a id="function-listenTo:HTML_EMITTER">

### `listenTo( emitter, event, callback, options? ) → void` _(inherited)_

Registers a callback function to be executed when an event is fired in a specific Emitter or DOM Node. It is backwards compatible with [`listenTo`](module_utils_emittermixin-Emitter.md#function-listenTo:BASE_EMITTER).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/dom/emittermixin.ts#L421)

#### Type parameters

* `K: extends keyof DomEventMap`

#### Parameters

* `emitter: Window | EventTarget | Node`

  The object that fires the event.

* `event: K`

  The name of the event.

* `callback: ( this: this, ev: EventInfo, event: DomEventMap[ K ] ) => void`

  The function to be called on event.

* `options?: CallbackOptions & object`

  Additional options.

#### Returns

* `void`

<a id="function-off">

### `off( event, callback ) → void` _(inherited)_

Stops executing the callback on the given event. Shorthand for [`this.stopListening( this, event, callback )`](#function-stopListening:DOM_STOP).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/emittermixin.ts#L444)

#### Parameters

* `event: string`

  The name of the event.

* `callback: Function`

  The function to stop being called.

#### Returns

* `void`

<a id="function-on">

### `on( event, callback, options? ) → void` _(inherited)_

Registers a callback function to be executed when an event is fired.

Shorthand for [`this.listenTo( this, event, callback, options )`](#function-listenTo:HTML_EMITTER) (it makes the emitter listen on itself).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/emittermixin.ts#L416)

#### Type parameters

* `TEvent: extends BaseEvent`

  The type descibing the event. See [`BaseEvent`](module_utils_emittermixin-BaseEvent.md).

#### Parameters

* `event: TEvent[ 'name' ]`

  The name of the event.

* `callback: GetCallback<TEvent>`

  The function to be called on event.

* `options?: GetCallbackOptions<TEvent>`

  Additional options.

#### Returns

* `void`

<a id="function-once">

### `once( event, callback, options? ) → void` _(inherited)_

Registers a callback function to be executed on the next time the event is fired only. This is similar to calling [`on`](#function-on) followed by [`off`](#function-off) in the callback.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/emittermixin.ts#L431)

#### Type parameters

* `TEvent: extends BaseEvent`

  The type descibing the event. See [`BaseEvent`](module_utils_emittermixin-BaseEvent.md).

#### Parameters

* `event: TEvent[ 'name' ]`

  The name of the event.

* `callback: GetCallback<TEvent>`

  The function to be called on event.

* `options?: GetCallbackOptions<TEvent>`

  Additional options.

#### Returns

* `void`

<a id="function-registerBodyCollection">

### `registerBodyCollection( bodyCollection, options ) → void`

Registers a body collection the shared tooltip balloon may be pinned into, so that a tooltip triggered inside its DOM tree is hosted there instead of an unrelated one – keeping it in the same shadow tree, not clipped by or mis-styled across a boundary. Editors register their own [body collection](module_ui_editorui_editoruiview-EditorUIView.md#member-body); features that render floating UI in their own body collection register it too, which is what lets them display tooltips without an editor.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L296)

#### Parameters

* `bodyCollection: BodyCollection`

  The body collection to register.

* `options: BodyCollectionRegistration`

  Additional sources describing where this collection's tooltip-bearing UI lives.

  Defaults to `{}`

#### Returns

* `void`

<a id="function-release">

### `release() → void`

Marks one holder as done with the singleton (see [`for`](#static-function-for)). When the last holder releases it, the singleton unpins the tooltip, destroys the shared balloon and drops every listener.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L264)

#### Returns

* `void`

<a id="function-stopDelegating">

### `stopDelegating( event?, emitter? ) → void` _(inherited)_

Stops delegating events. It can be used at different levels:

* To stop delegating all events.
* To stop delegating a specific event to all emitters.
* To stop delegating a specific event to a specific emitter.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/emittermixin.ts#L552)

#### Parameters

* `event?: string`

  The name of the event to stop delegating. If omitted, stops it all delegations.

* `emitter?: Emitter`

  (requires `event`) The object to stop delegating a particular event to. If omitted, stops delegation of `event` to all emitters.

#### Returns

* `void`

<a id="function-stopListening:BASE_STOP">

### `stopListening( emitter?, event?, callback? ) → void` _(inherited)_

Stops listening for events. It can be used at different levels:

* To stop listening to a specific callback.
* To stop listening to a specific event.
* To stop listening to all events fired by a specific object.
* To stop listening to all events fired by all objects.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/emittermixin.ts#L497)

#### Parameters

* `emitter?: Emitter`

  The object to stop listening to. If omitted, stops it for all objects.

* `event?: string`

  (Requires the `emitter`) The name of the event to stop listening to. If omitted, stops it for all events from `emitter`.

* `callback?: Function`

  (Requires the `event`) The function to be removed from the call list for the given `event`.

#### Returns

* `void`

<a id="function-stopListening:DOM_STOP">

### `stopListening( emitter?, event?, callback? ) → void` _(inherited)_

Stops listening for events. It can be used at different levels: It is backwards compatible with [`listenTo`](module_utils_emittermixin-Emitter.md#function-listenTo:BASE_EMITTER).

* To stop listening to a specific callback.
* To stop listening to a specific event.
* To stop listening to all events fired by a specific object.
* To stop listening to all events fired by all objects.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/dom/emittermixin.ts#L481)

#### Parameters

* `emitter?: Window | EventTarget | Node | Emitter`

  The object to stop listening to. If omitted, stops it for all objects.

* `event?: string`

  (Requires the `emitter`) The name of the event to stop listening to. If omitted, stops it for all events from `emitter`.

* `callback?: Function`

  (Requires the `event`) The function to be removed from the call list for the given `event`.

#### Returns

* `void`

<a id="function-unregisterBodyCollection">

### `unregisterBodyCollection( bodyCollection ) → void`

Reverts [`registerBodyCollection`](#function-registerBodyCollection): stops hosting the shared balloon in the given collection and drops the listeners set up for it. Pulls the shared balloon out first, so it never dangles in a collection that is going away.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L334)

#### Parameters

* `bodyCollection: BodyCollection`

  The body collection to unregister.

#### Returns

* `void`

<a id="function-_getConnectedBodyCollection">

### `_getConnectedBodyCollection( targetDomElement ) → BodyCollection | null` _(private)_

Returns the body collection the shared tooltip balloon should be pinned into. The balloon is a singleton, but each registered body collection can live in a different DOM tree (a shadow root, or a configured `ui.overlayContainer`). To keep the tooltip in the tree of the hovered element — so it is styled by that tree's sheets and not clipped by another root — the tree is looked up in [`_bodyCollectionByTree`](#member-_bodyCollectionByTree), which maps every tree hosting tooltip-bearing UI (a collection's own mount tree, and an editor's editable, toolbar or menu bar trees) to the collection that should host it.

A body collection is mounted lazily and unmounted when its host leaves the document, and a configured `ui.overlayContainer` may be detached — a body in either state would render the balloon outside the document and hide tooltips, so the mount target must be connected, not merely set. When no connected body collection hosts the hovered element's tree, it falls back to the first connected registrant, then to the first registered one, and to `null` when nothing is registered at all.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L786)

#### Parameters

* `targetDomElement: HTMLElement`

  The element the tooltip is being pinned to.

#### Returns

* `BodyCollection | null`

<a id="function-_getUpdateEmitters">

### `_getUpdateEmitters() → Set<Emitter>` _(private)_

Returns the distinct `update` emitters of all registered body collections.

Deduplicated, because an emitter can be shared by several registrations (an editor and a feature hosting its own overlay layer both follow the editor's UI update) while listeners are attached per emitter, not per registration – listening once per registration would reposition a pinned tooltip several times per update.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L379)

#### Returns

* `Set<Emitter>`

<a id="function-_moveBalloonToConnectedBodyCollection">

### `_moveBalloonToConnectedBodyCollection( targetDomElement ) → boolean` _(private)_

Moves the shared tooltip balloon into the body collection returned by [`_getConnectedBodyCollection`](#function-_getConnectedBodyCollection), first removing it from any registered body collection that previously hosted it. The balloon is a singleton shared by every registrant, so it must belong to exactly one collection at a time; otherwise unregistering one collection would detach the shared element while another registrant still references it.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L748)

#### Parameters

* `targetDomElement: HTMLElement`

  The element the tooltip is being pinned to, used to prefer the body collection that hosts its DOM tree.

#### Returns

* `boolean`

  `true` if a host body collection was found (and the balloon moved into it), `false` when none is registered and the tooltip therefore cannot be shown.

<a id="function-_onEnterOrFocus">

### `_onEnterOrFocus( evt, domEvent ) → void` _(private)_

Handles displaying tooltips on `mouseenter` and `focus` in DOM.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L471)

#### Parameters

* `evt: EventInfo`

  An object containing information about the fired event.

* `domEvent: any`

  The DOM event.

#### Returns

* `void`

<a id="function-_onKeyDown">

### `_onKeyDown( evt, domEvent ) → void` _(private)_

Handles hiding tooltips on `keydown` in DOM.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L458)

#### Parameters

* `evt: EventInfo`

  An object containing information about the fired event.

* `domEvent: KeyboardEvent`

  The DOM event.

#### Returns

* `void`

<a id="function-_onLeaveOrBlur">

### `_onLeaveOrBlur( evt, domEvent ) → void` _(private)_

Handles hiding tooltips on `mouseleave` and `blur` in DOM.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L539)

#### Parameters

* `evt: EventInfo`

  An object containing information about the fired event.

* `domEvent: any`

  The DOM event.

#### Returns

* `void`

<a id="function-_onScroll">

### `_onScroll( evt, domEvent ) → void` _(private)_

Handles hiding tooltips on `scroll` in DOM.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L670)

#### Parameters

* `evt: unknown`

  An object containing information about the fired event.

* `domEvent: any`

  The DOM event.

#### Returns

* `void`

<a id="function-_pinTooltip">

### `_pinTooltip( targetDomElement, options ) → void` _(private)_

Pins the tooltip to a specific DOM element.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L698)

#### Parameters

* `targetDomElement: HTMLElement`

  Element to be pinned to.

* `options: TooltipData`

  Options for the tooltip.

#### Returns

* `void`

<a id="function-_rebuild">

### `_rebuild() → void` _(private)_

Rebuilds [`_bodyCollectionByTree`](#member-_bodyCollectionByTree) from [`_registrations`](#static-member-_registrations): every registered collection claims the DOM tree it is mounted in, and – for editors – every shadow root its registry reports (ancestor-inclusive, so nested and decoupled trees resolve too). Then re-syncs the per-shadow-root listeners.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L396)

#### Returns

* `void`

<a id="function-_resyncShadowRootListeners">

### `_resyncShadowRootListeners() → void` _(private)_

Attaches or detaches listeners on shadow roots so they match the shadow roots that host tooltip-bearing UI exactly, i.e. the shadow-root keys of [`_bodyCollectionByTree`](#member-_bodyCollectionByTree).

The listeners duplicate the ones on `document` for two different reasons:

* `mouseenter`, `mouseleave` and `scroll` are not `composed`, so their event path ends at the shadow root they originated in and the `document` listeners never see them at all. Here the per-root listener is what delivers the event.
* `focus` and `blur` are `composed`, so the capturing `document` listeners do see them (the capture phase walks the whole composed path even though these events do not bubble) — but with `target` retargeted to the shadow host, which is useless for `getDescendantWithTooltip()`. Here the per-root listener is what provides the real target. It cannot be replaced by reading `composedPath()[0]` on `document`, because that path is truncated at the boundary of a `closed` root.

Since the capture phase runs outwards-in, the `document` listener fires _before_ these; see the `isShadowHostOf()` guards in [`_onEnterOrFocus`](#function-_onEnterOrFocus) and [`_onLeaveOrBlur`](#function-_onLeaveOrBlur), which make the outer listeners step aside for the innermost one.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L629)

#### Returns

* `void`

<a id="function-_unpinTooltip">

### `_unpinTooltip() → void` _(private)_

Unpins the tooltip and cancels all queued pinning.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L806)

#### Returns

* `void`

<a id="function-_updateTooltipPosition">

### `_updateTooltipPosition() → void` _(private)_

Updates the position of the tooltip so it stays in sync with the element it is pinned to.

Hides the tooltip when the element is no longer visible in DOM or the tooltip text was removed.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L828)

#### Returns

* `void`

#### Static methods

<a id="static-function-for">

### `for( locale ) → TooltipManager` _(static)_

Returns the shared `TooltipManager` singleton, creating it – with the given locale – on first use, and marks one more holder as using it. Every caller must later [`release`](#function-release) it, so the singleton is destroyed once the last holder is gone.

Editors and features obtain the manager this way and then [register](#function-registerBodyCollection) the body collection their tooltip-bearing UI renders into. A feature therefore does not need an editor reference to display tooltips – it attaches to the same singleton directly.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L190)

#### Parameters

* `locale: Locale`

  The locale used to create the tooltip views on first use.

#### Returns

* `TooltipManager`

<a id="static-function-getPositioningFunctions">

### `getPositioningFunctions( position ) → Array<PositioningFunction>` _(static)_

Returns [`balloonPanelView`](#member-balloonPanelView) [positioning functions](module_utils_dom_position-PositioningFunction.md) for a given position name.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-ui/src/tooltipmanager.ts#L434)

#### Parameters

* `position: TooltipPosition`

  Name of the position (`s`, `se`, `sw`, `n`, `e`, or `w`).

#### Returns

* `Array<PositioningFunction>`

  Positioning functions to be used by the [`balloonPanelView`](#member-balloonPanelView).

---

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