# luna-dom-highlighter

> Highlighter for html elements

Latest version **1.0.2** (published 2022-11-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install luna-dom-highlighter
pnpm add luna-dom-highlighter
yarn add luna-dom-highlighter
bun add luna-dom-highlighter
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-11-27 |
| First published | 2021-07-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 438 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 348 |
| Author | redhoodsu |
| Maintainers | surunzi |
| Keywords | ui |

## Links

- npm: https://www.npmjs.com/package/luna-dom-highlighter
- Repository: https://github.com/liriliri/luna
- Homepage: https://github.com/liriliri/luna#readme
- Issues: https://github.com/liriliri/luna/issues
- npm.io page: https://npm.io/package/luna-dom-highlighter

## Dependencies (2)

- [licia](https://npm.io/package/licia.md) ^1.35.1
- [path2d-polyfill](https://npm.io/package/path2d-polyfill.md) ^1.2.3

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2022-11-27
- 1.0.1 — 2022-11-26
- 1.0.0 — 2022-11-10
- 0.3.2 — 2021-10-21
- 0.3.1 — 2021-10-17
- 0.3.0 — 2021-07-13
- 0.2.0 — 2021-07-13
- 0.1.0 — 2021-07-12

## README

# Luna Dom Highlighter

Highlighter for html elements.

## Demo

https://luna.liriliri.io/?path=/story/dom-highlighter

## Install

Add the following script and style to your page.

```html
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/luna-dom-highlighter/luna-dom-highlighter.css" />
<script src="//cdn.jsdelivr.net/npm/luna-dom-highlighter/luna-dom-highlighter.js"></script>
```

You can also get it on npm.

```bash
npm install luna-dom-highlighter --save
```

```javascript
import 'luna-dom-highlighter/luna-dom-highlighter.css'
import LunaDomHighlighter from 'luna-dom-highlighter'
```

## Usage

```javascript
const domHighlighter = new LunaDomHighlighter(container, {
  showRulers: true,
  showExtensionLines: true,
  showInfo: true,
})
domHighlighter.highlight(document.getElementById('test'))
domHighlighter.hide()
```

## Configuration

* borderColor(string | IRgb): The border highlight fill color.
* colorFormat('rgb' | 'hsl' | 'hex'): The color format used to format color styles.
* contentColor(string | IRgb): The content box highlight fill color.
* marginColor(string | IRgb): The margin highlight fill color.
* monitorResize(boolean | IRgb): Auto redraw if target element is resized.
* paddingColor(string | IRgb): The padding highlight fill color.
* showAccessibilityInfo(boolean): Whether the a11y info should be shown.
* showExtensionLines(boolean): Whether the extension lines from node to the rulers should be shown.
* showInfo(boolean): Whether the node info tooltip should be shown.
* showRulers(boolean): Whether the rulers should be shown.
* showStyles(boolean): Whether the node styles in the tooltip.

## Api

### hide(): void

Hide highlight.

### highlight(target: HTMLElement | Text,options?: IOptions): void

Highlight element or text node.

## Types

### IRgb

* a(number): Alpha.
* b(number): Blue.
* g(number): Green.
* r(number): Red.

---
_Source: https://npm.io/package/luna-dom-highlighter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
