1.0.3 • Published 6 months ago

quill-converter v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

quill-converter NPM version

Convert text/HTML to a Quill Delta or a Quill Delta to text/HTML

The purpose of this package is to assist in migrating to or from the Quill editor.

Installation

# Via NPM
npm install quill-converter --save

# Via Yarn
yarn add quill-converter

Getting Started

Convert a plain text string to a Quill delta:

const { convertTextToDelta } = require('quill-converter');

let text = 'hello, world';
let delta = convertTextToDelta(text);

console.log(JSON.stringify(delta)); // {"ops":[{"insert":"hello, world\n"}]}

Convert a Quill delta to a plain text string:

const { convertDeltaToHtml } = require('quill-converter');

let text = convertDeltaToText(delta);

console.log(text) ; // 'hello, world'

Convert a HTML string to a Quill delta:

const { convertHtmlToDelta } = require('quill-converter');

let htmlString = '<p>hello, <strong>world</strong></p>';
let delta = convertHtmlToDelta(htmlString);

console.log(JSON.stringify(delta); // {"ops":[{"insert":"hello, "},{"insert":"world","attributes":{"bold":true}}]}

Convert a Quill delta to an HTML string:

const { convertDeltaToHtml } = require('quill-converter');

let html = convertDeltaToHtml(delta);

console.log(html) ; // '<p>hello, <strong>world</strong></p>'

Based on node-quill-converter by Joel Colucci

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago

0.5.0

6 months ago

0.4.0

6 months ago