# scribe-plugin-span-style

> A Scribe Plugin for adding inline styles through elements

Latest version **0.2.0** (published 2016-01-31) · ISC license · 0 weekly downloads

## Install

```sh
npm install scribe-plugin-span-style
pnpm add scribe-plugin-span-style
yarn add scribe-plugin-span-style
bun add scribe-plugin-span-style
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2016-01-31 |
| First published | 2015-11-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Jonathan Siebern |
| Maintainers | jsiebern |
| Keywords | scribe, wysiwyg, inline, styles |

## Links

- npm: https://www.npmjs.com/package/scribe-plugin-span-style
- Repository: https://github.com/jsiebern/scribe-plugin-span-style
- Homepage: https://github.com/jsiebern/scribe-plugin-span-style#readme
- Issues: https://github.com/jsiebern/scribe-plugin-span-style/issues
- npm.io page: https://npm.io/package/scribe-plugin-span-style

## 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.2.0 (latest) — 2016-01-31
- 0.1.7 — 2015-11-19
- 0.1.6 — 2015-11-19
- 0.1.5 — 2015-11-16
- 0.1.4 — 2015-11-16
- 0.1.3 — 2015-11-16
- 0.1.2 — 2015-11-16
- 0.1.1 — 2015-11-16
- 0.1.0 — 2015-11-16

## README

# scribe-plugin-span-style
A Scribe Plugin for adding inline styles through `<span>` elements.

*The description `<span>` is probably not accurate anymore. From 0.2.0 on, the plugin will now use any available tags it can find, that includes `<b>`,`<i>`,`<strong>`,`<em>`,`<li>`,`etc`. Only if it is not able to use one of those will it create a `<span>` to wrap the selection into.*

**Example:**
```javascript
import Scribe from 'scribe-editor';
import ScribeSpanStyleCommand from 'scribe-plugin-span-style';

// ...............

let scribe = new Scribe(document.querySelector('#my-editor'));
scribe.use(ScribeSpanStyleCommand('color'));
scribe.use(ScribeSpanStyleCommand('fontSize'));
scribe.use(ScribeSpanStyleCommand('fontFamily'));

// ...............

let command = scribe.getCommand('fontSize');
command.execute('24px');

// ...............

let command = scribe.getCommand('fontSize');
let originalRange = scribe.selection.range;

// Some more code that causes the selection to lose focus...

command.execute({
    value: '24px',
    range: originalRange
});

```

**Requirements**
- Scribe should always put `<p>` or `<div>` tags as the root nodes of your lines

**Known Issues / Todo**
- Heavily nested `<span>` nodes sometimes do not get unwrapped properly
- Untested performance on a lot of text ("logical" algorithm might be a bit slow for that)
- Untested in older browsers

**Changelog**

*v0.2.0*
- Complete code makeover
- Multi-line selections are supported mostly reliable now (even cross browser)
- Implemented "logical" algorithm to keep the nesting as clean as possible
- Supports the passing of an object as value now (`{value: '12px', range: originalRange}`) to support input elements that might cause losing the selection before execution of the command

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