tik-attributed-text

4.0.8 • Public • Published

tik-attributed-text npm version Build Status codecov.io

Encodes and decodes TikApi::v5 text attributes to HTML

Install

$ npm install --save tik-attributed-text

Usage

Below is a example of usage.

var attrsTextToHTML = require('tik-attributed-text/to-html');
attrsTextToHTML("Hello World!", [
  {
    _type: "Tik::ApiModel::Text::BoldSpan",
    start: 2,
    end: 6
  },
  {
    _type: "Tik::ApiModel::Text::ItalicSpan",
    start: 4,
    end: 8
  }
]); // => "He<strong>ll<em>o </em></strong><em>Wo</em>rld!"
HTMLtoAttrs("He<strong>ll<em>o</em></strong><em> Wo</em>rld!"); /* => {
  text: "Hello World!",
  attrs: [
    { _type: 'Tik::ApiModel::Text::BoldSpan', start: 2, end: 6 },
    { _type: 'Tik::ApiModel::Text::ItalicSpan', start: 4, end: 8 }
  ]
}*/

Options

to-attrs:

replaceBrTagWithNewLine

default: false

replaces <br> tags with new lines \n

to-html:

proxyDocument

default: undefined (Browser document)

if you want to run this function in a browserless environment like node

skipIntersectionsCompress

default: false

if you want to skip intersections normalization

replaceNewLinesWithBrTag

default: false

replaces new lines \n with <br> tags

Readme

Keywords

Package Sidebar

Install

npm i tik-attributed-text

Weekly Downloads

1

Version

4.0.8

License

MIT

Last publish

Collaborators

  • a7madgamal
  • antpaw