# slate-align

> Provides align for slate editor

Latest version **0.1.4** (published 2018-07-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install slate-align
pnpm add slate-align
yarn add slate-align
bun add slate-align
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2018-07-05 |
| First published | 2018-02-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 962.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 26 |
| Author | zhujinxuan |
| Maintainers | jinxuan |
| Keywords | slate |

## Links

- npm: https://www.npmjs.com/package/slate-align
- Repository: https://github.com/zhujinxuan/slate-sensible
- npm.io page: https://npm.io/package/slate-align

## Alternatives

- [ext-list](https://npm.io/package/ext-list.md) — 6.3M weekly downloads
- [@lexical/selection](https://npm.io/package/@lexical/selection.md) — 3.8M weekly downloads
- [@lexical/text](https://npm.io/package/@lexical/text.md) — 3.6M weekly downloads
- [@lexical/clipboard](https://npm.io/package/@lexical/clipboard.md) — 3.0M weekly downloads
- [@tiptap/extension-mention](https://npm.io/package/@tiptap/extension-mention.md) — 3.0M weekly downloads

## Recent versions

- 0.1.4 (latest) — 2018-07-05
- 0.1.3 — 2018-07-05
- 0.1.2 — 2018-06-29
- 0.1.1 — 2018-06-29
- 0.0.12 — 2018-04-06
- 0.0.11 — 2018-04-06
- 0.0.10 — 2018-04-06
- 0.0.9 — 2018-04-05
- 0.0.8 — 2018-04-05
- 0.0.7 — 2018-03-21
- 0.0.6 — 2018-03-21
- 0.0.5 — 2018-03-01
- 0.0.4 — 2018-03-01
- 0.0.3 — 2018-02-26
- 0.0.2 — 2018-02-26
- … 1 more at https://npm.io/package/slate-align/versions

## README

# slate-align

[![NPM version](https://badge.fury.io/js/slate-align.svg)](http://badge.fury.io/js/slate-align)

Provides `data.textAlign` for blocks, providing `validateNode` for align blocks, providing `getStyle` and `getData` to convert between CSS style and slate `block.data`.

## Install

```
yarn add slate-align
```

or

```
npm i --save slate-align
```

## Simple Usage

```javascript
import AlignPlugin from "slate-align";
export default AlignPlugin(/* options */);
```

## Data Structure

```javascript
<block type="paragraph" textAlign="left" /* or "center", "right" */>
  {" "}
  /* content */{" "}
</block>
```

## Options

Option object you can pass to the plugin.

- `[floatBlocks : Array<string>]`: (Default : `['table', 'bad-table', 'image']`) block types whose rendering DOMs is aligned by `style.float` attribute.
- `[textBlocks: Array<string>]`: (Default: `['paragraph', 'heading', 'table_cell', 'bad-table-cell']`) block types whose rendering DOMs is aligned by `style.textAlign` attribute.

## Align Plugin

### `AlignPlugin(options: Options) => Instance`

Constructs an instance of the align plugin. Once the plugin is craeted, you get access to utilities, style convection and changes function.

### `plugin.validateNode`

This plugin provides normalization that removes all

### `plugin.utils`

#### `plugin.utils.getAlignBlocksAtRange`

```javascript
getAlignBlocksAtRange(range: Range, document: Document ) : Array<Block>
```

Get all align-able blocks within the range

### `plugin.changes`

#### `plugin.changes.removeAlignAtRange`

```javascript
removeAlignAtRange(change: Change, range: Range, align: string) : void
```

Unset all aligned blocks within the range whose `textAlign` is equal to `align`.

#### `plugin.changes.setAlignBlocksAtRange`

```javascript
setAlignBlocksAtRange(change: Change, range: Range, align: string) : void
```

Align all align-able blocks with `align` within the range.

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