{"_id":"@crayton1995/quill-delta-to-html","name":"@crayton1995/quill-delta-to-html","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@crayton1995/quill-delta-to-html","version":"1.0.0","description":"Converts Quill's delta ops to HTML","main":"./dist/commonjs/main.js","types":"./dist/commonjs/main.d.ts","dependencies":{"lodash.isequal":"^4.5.0"},"devDependencies":{"@types/lodash":"^4.14.119","@types/lodash.isequal":"^4.5.5","@types/mocha":"^2","browserify":"^16.2","coveralls":"^3.0","husky":"^3.0.9","mocha":"^6","nyc":"^14.1","prettier":"^2.0.4","pretty-quick":"^2.0.1","ts-node":"^8","typescript":"^2"},"scripts":{"browserbundle":"browserify ./dist/commonjs/QuillDeltaToHtmlConverter.js -o ./dist/browser/QuillDeltaToHtmlConverter.bundle.js -s QuillDeltaToHtmlConverter","browser":"npm run browserbundle && echo '; window.QuillDeltaToHtmlConverter = window.QuillDeltaToHtmlConverter ? window.QuillDeltaToHtmlConverter.QuillDeltaToHtmlConverter : window.QuillDeltaToHtmlConverter; ' >>  ./dist/browser/QuillDeltaToHtmlConverter.bundle.js","build":"tsc && npm run browser","test":"nyc mocha --require ts-node/register -b \"./test/**/*.ts\"","coverage":"nyc report --reporter=text-lcov | coveralls","coveragehtml":"nyc report --reporter=html"},"repository":{"type":"git","url":"git+ssh://git@github.com/nozer/quill-delta-to-html.git"},"keywords":["quill","delta","html"],"author":{"name":"Nihat Özer","email":"nihatforweb@gmail.com"},"license":"ISC","bugs":{"url":"https://github.com/nozer/quill-delta-to-html/issues"},"homepage":"https://github.com/nozer/quill-delta-to-html#readme","nyc":{"include":["src/**/*.ts"],"exclude":["typings","src/main.ts","**/*.d.ts"],"extension":[".ts"],"require":["ts-node/register"],"reporter":["json","html"],"all":true},"husky":{"hooks":{"pre-commit":"pretty-quick --staged"}},"_id":"@crayton1995/quill-delta-to-html@1.0.0","_nodeVersion":"16.14.0","_npmVersion":"8.3.1","dist":{"integrity":"sha512-PWL+V4UnqCAn6Nx5zgtthKNupOY/JBzPLHv2hiJNT2uTM82bZIFnPPVluZ53sVk0FPw1LgAiNV0DyXiFBxBlvw==","shasum":"d8e49d85c1b43a2daab26c663205972b85c4e6ef","tarball":"https://registry.npmjs.org/@crayton1995/quill-delta-to-html/-/quill-delta-to-html-1.0.0.tgz","fileCount":92,"unpackedSize":373308,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIH7DGc21we3NonIgob0elxxJjFFq90ksl9PyfuCTafQEAiBtJwmPwQu7JDTKKnsQiAxR4CLCZOxQfxiNtuSqOJnIfA=="}]},"_npmUser":{"name":"crayton1995","email":"crayton1995@yahoo.com"},"directories":{},"maintainers":[{"name":"crayton1995","email":"crayton1995@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/quill-delta-to-html_1.0.0_1756329291231_0.8394906337753463"},"_hasShrinkwrap":false}},"time":{"created":"2025-08-27T21:14:51.230Z","1.0.0":"2025-08-27T21:14:51.483Z","modified":"2025-08-27T21:14:52.048Z"},"maintainers":[{"name":"crayton1995","email":"crayton1995@yahoo.com"}],"description":"Converts Quill's delta ops to HTML","homepage":"https://github.com/nozer/quill-delta-to-html#readme","keywords":["quill","delta","html"],"repository":{"type":"git","url":"git+ssh://git@github.com/nozer/quill-delta-to-html.git"},"author":{"name":"Nihat Özer","email":"nihatforweb@gmail.com"},"bugs":{"url":"https://github.com/nozer/quill-delta-to-html/issues"},"license":"ISC","readme":"[![Build Status](https://travis-ci.org/nozer/quill-delta-to-html.svg?branch=master)](https://travis-ci.org/nozer/quill-delta-to-html) \n[![Coverage Status](https://coveralls.io/repos/github/nozer/quill-delta-to-html/badge.svg?branch=master)](https://coveralls.io/github/nozer/quill-delta-to-html?branch=master)\n\n\n# Quill Delta to HTML Converter #\nConverts [Quill's](https://quilljs.com) [Delta](https://quilljs.com/docs/delta/) format to HTML (insert ops only) with properly nested lists.\n\nYou can try a live demo of the conversion by opening the `demo-browser.html` file after cloning the repo.\n\n## Breaking change: `import/require` has changed as of `v0.10.0`. See Usage below ##\n\n\n\n## Quickstart ## \n\nInstallation\n```\nnpm install quill-delta-to-html\n```\n\nUsage\n```javascript\nvar QuillDeltaToHtmlConverter = require('quill-delta-to-html').QuillDeltaToHtmlConverter;\n\n// TypeScript / ES6:\n// import { QuillDeltaToHtmlConverter } from 'quill-delta-to-html'; \n\nvar deltaOps =  [\n    {insert: \"Hello\\n\"},\n    {insert: \"This is colorful\", attributes: {color: '#f00'}}\n];\n\nvar cfg = {};\n\nvar converter = new QuillDeltaToHtmlConverter(deltaOps, cfg);\n\nvar html = converter.convert(); \n```\n\n## Configuration ## \n\n`QuillDeltaToHtmlConverter` accepts a few configuration options as shown below:\n\n|Option | Type | Default | Description \n|---|---|---|---|\n|`paragraphTag`| string |  'p' | Custom tag to wrap inline html elements|\n|`encodeHtml`| boolean | true | If true, `<, >, /, ', \", &` characters in content will be encoded.|\n|`classPrefix`| string | 'ql' | A css class name to prefix class generating styles such as `size`, `font`, etc. |\n|`inlineStyles`| boolean or object | false | If true or an object, use inline styles instead of classes. See Rendering Inline Styles section below for using an object |\n|`multiLineBlockquote`| boolean | true | Instead of rendering multiple `blockquote` elements for quotes that are consecutive and have same styles(`align`, `indent`, and `direction`), it renders them into only one|\n|`multiLineHeader`| boolean | true | Same deal as `multiLineBlockquote` for headers|\n|`multiLineCodeblock`| boolean | true | Same deal as `multiLineBlockquote` for code-blocks|\n|`multiLineParagraph`| boolean | true | Set to false to generate a new paragraph tag after each enter press (new line)|\n|`linkRel`| string | none generated | Specifies a value to put on the `rel` attr on all links. This can be overridden by an individual link op by specifying the `rel` attribute in the respective op's attributes|\n|`linkTarget`| string | '_blank' | Specifies target for all links; use `''` (empty string) to not generate `target` attribute. This can be overridden by an individual link op by specifiying the `target` with a value in the respective op's attributes.|\n|`allowBackgroundClasses`| boolean | false | If true, css classes will be added for background attr|\n|`urlSanitizer`| function `(url: string): string \\| undefined` | undefined | A function that is called once per url in the ops (image, video, link) for you to do custom sanitization. If your function returns a string, it is assumed that you sanitized the url and no further sanitization will be done by the library; when anything other than a string is returned (e.g. `undefined`), it is assumed that no sanitization has been done and the library's own function will be used to clean up the url|\n\n\n## Rendering Quill Formats ##\n\nYou can customize the rendering of Quill formats by registering to the render events before calling the `convert()` method. \n\nThere are `beforeRender` and `afterRender` events and they are called multiple times before and after rendering each group. A group is one of:\n\n- continuous sets of inline elements\n- a video element\n- list elements\n- block elements (header, code-block, blockquote, align, indent, and direction)\n\n`beforeRender` event is called with raw operation objects for you to generate and return your own html. If you return a `falsy` value, system will return its own generated html. \n\n`afterRender` event is called with generated html for you to inspect, maybe make some changes and return your modified or original html.\n\n```javascript\n\nconverter.beforeRender(function(groupType, data){\n    // ... generate your own html \n    // return your html\n});\nconverter.afterRender(function(groupType, htmlString){\n    // modify if you wish\n    // return the html\n});\n\nhtml = converter.convert();\n\n```\n\nFollowing shows the parameter formats for `beforeRender` event: \n\n\n\n|groupType|data|\n|---|---|\n|`video`|{op: `op object`}|\n|`block`|{op: `op object`: ops: Array<`op object`>}|\n|`list`| {items: Array<{item: `block`, innerList: `list` or `null` }> }|\n|`inline-group`|{ops: Array<`op object`>}|\n\n`op object` will have the following format: \n\n```javascript\n{\n    insert: {\n        type: '' // one of 'text' | 'image' | 'video' | 'formula',\n        value: '' // some string value  \n    }, \n    attributes: {\n        // ... quill delta attributes \n    }\n}\n```\n\n## Rendering Inline Styles ##\n\nIf you are rendering to HTML that you intend to include in an email, using classes and a style sheet are not recommended, as [not all browsers support style sheets](https://www.campaignmonitor.com/css/style-element/style-in-head/).  quill-delta-to-html supports rendering inline styles instead.  The easiest way to enable this is to pass the option `inlineStyles: true`.\n\nYou can customize styles by passing an object to `inlineStyles` instead:\n\n```javascript\ninlineStyles: {\n   font: {\n      'serif': 'font-family: Georgia, Times New Roman, serif',\n      'monospace': 'font-family: Monaco, Courier New, monospace'\n   },\n   size: {\n      'small': 'font-size: 0.75em',\n      'large': 'font-size: 1.5em',\n      'huge': 'font-size: 2.5em'\n   },\n   indent: (value, op) => {\n      var indentSize = parseInt(value, 10) * 3;\n      var side = op.attributes['direction'] === 'rtl' ? 'right' : 'left';\n      return 'padding-' + side + ':' + indentSize + 'em';\n   },\n   direction: (value, op) => {\n      if (value === 'rtl') {\n         return 'direction:rtl' + ( op.attributes['align'] ? '' : '; text-align: inherit' );\n      } else {\n         return '';\n      }\n   }\n};\n```\n\nKeys to this object are the names of attributes from Quill.  The values are either a simple lookup table (like in the 'font' example above) used to map values to styles, or a `fn(value, op)` which returns a style string.\n\n## Rendering Custom Blot Formats ##\n\nYou need to tell system how to render your custom blot by registering a renderer callback function to `renderCustomWith` method before calling the `convert()` method. \n\nIf you would like your custom blot to be rendered as a block (not inside another block or grouped as part of inlines), then add `renderAsBlock: true` to its attributes. \n\nExample:\n```javascript \nlet ops = [\n    {insert: {'my-blot': {id: 2, text: 'xyz'}}, attributes: {renderAsBlock: true|false}}\n];\n\nlet converter = new QuillDeltaToHtmlConverter(ops);\n\n// customOp is your custom blot op\n// contextOp is the block op that wraps this op, if any. \n// If, for example, your custom blot is located inside a list item,\n// then contextOp would provide that op. \nconverter.renderCustomWith(function(customOp, contextOp){\n    if (customOp.insert.type === 'my-blot') {\n        let val = customOp.insert.value;\n        return `<span id=\"${val.id}\">${val.text}</span>`;\n    } else {\n        return 'Unmanaged custom blot!';\n    }\n});\n\nhtml = converter.convert();\n```\n`customOp object` will have the following format: \n\n```javascript\n{\n    insert: {\n        type: string //whatever you specified as key for insert, in above example: 'my-blot'\n        value: any // value for the custom blot  \n    }, \n    attributes: {\n        // ... any attributes custom blot may have\n    }\n}\n```\n\n## Advanced Custom Rendering Using Grouped Ops ##\n\nIf you want to do the full rendering yourself, you can do so \nby getting the processed & grouped ops.\n\n```javascript\nlet groupedOps = converter.getGroupedOps();\n```\nEach element in groupedOps array will be an instance of the \nfollowing types: \n\n|type|properties|\n|---|---|\n|`InlineGroup`|ops: Array<`op object`>|\n|`VideoItem`|op: `op object`|\n|`BlockGroup`|op: `op object`, ops: Array<`op object`>|\n|`ListGroup`|items: Array<`ListItem`>|\n||ListItem: {item:`BlockGroup`, innerList:`ListGroup`}|\n|`BlotBlock`|op: `op object`|\n\n`BlotBlock` represents custom blots with `renderAsBlock:true` property pair in its attributes\n\nSee above for `op object` format. \n","readmeFilename":"README.md","_rev":"1-c271dd79344cdb7fef8dc54b9cf80813"}