2021-10-14 06:13:50 +08:00
|
|
|
|
---
|
|
|
|
|
description: Keep track of where the cursor is, and let the user know you know it.
|
2021-10-16 04:48:57 +08:00
|
|
|
|
icon: focus-line
|
2021-10-14 06:13:50 +08:00
|
|
|
|
---
|
|
|
|
|
|
2020-11-02 22:54:15 +08:00
|
|
|
|
# Focus
|
2021-01-25 17:35:52 +08:00
|
|
|
|
[![Version](https://img.shields.io/npm/v/@tiptap/extension-focus.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-focus)
|
|
|
|
|
[![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-focus.svg)](https://npmcharts.com/compare/@tiptap/extension-focus?minimal=true)
|
|
|
|
|
|
2021-06-30 04:12:51 +08:00
|
|
|
|
The Focus extension adds a CSS class to focused nodes. By default it adds `.has-focus`, but you can change that.
|
2020-11-06 04:57:25 +08:00
|
|
|
|
|
|
|
|
|
Note that it’s only a class, the styling is totally up to you. The usage example below has some CSS for that class.
|
2020-11-02 22:54:15 +08:00
|
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
```bash
|
|
|
|
|
npm install @tiptap/extension-focus
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Settings
|
2021-10-02 07:20:09 +08:00
|
|
|
|
|
|
|
|
|
### className
|
|
|
|
|
The class that is applied to the focused element.
|
|
|
|
|
|
|
|
|
|
Default: `'has-focus'`
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
Focus.configure({
|
|
|
|
|
className: 'focus',
|
|
|
|
|
})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### mode
|
|
|
|
|
Apply the class to `'all'`, the `'shallowest'` or the `'deepest'` node.
|
|
|
|
|
|
|
|
|
|
Default: `'all'`
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
Focus.configure({
|
|
|
|
|
mode: 'deepest',
|
|
|
|
|
})
|
|
|
|
|
```
|
2020-11-02 22:54:15 +08:00
|
|
|
|
|
|
|
|
|
## Source code
|
2021-04-21 21:31:11 +08:00
|
|
|
|
[packages/extension-focus/](https://github.com/ueberdosis/tiptap/blob/main/packages/extension-focus/)
|
2020-11-02 22:54:15 +08:00
|
|
|
|
|
|
|
|
|
## Usage
|
2021-10-19 00:01:47 +08:00
|
|
|
|
https://embed.tiptap.dev/preview/Extensions/Focus
|