quill-converter
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

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

Package Sidebar

Install

npm i quill-converter

Weekly Downloads

321

Version

1.0.3

License

MIT

Unpacked Size

11.9 kB

Total Files

9

Last publish

Collaborators

  • buu700