New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

convert-rich-text

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

convert-rich-text - npm Package Compare versions

Comparing version 1.2.1 to 2.0.0

.travis.yml

11

index.js

@@ -1,9 +0,8 @@

var Doc = require('./lib/doc');
var jsdom = require('jsdom').jsdom;
var convert = require('./lib/convert');
module.exports = function(delta, formats, options) {
var doc = new Doc(formats, options);
for (var i = 0; i < delta.ops.length; i++) {
doc.writeOp(delta.ops[i]);
}
return doc.getHTML();
options.document = jsdom();
return convert(delta, formats, options);
};

@@ -7,5 +7,6 @@ var dom = require('./dom');

this.formats = formats;
this.document = options.document;
this.blockTag = options && options.blockTag || 'div';
this.inlineTag = options && options.inlineTag || 'span';
this.root = document.createElement('div');
this.root = this.document.createElement('div');
}

@@ -44,3 +45,3 @@

if (!this.line) {
this.line = document.createElement(this.blockTag);
this.line = this.document.createElement(this.blockTag);
this.root.appendChild(this.line);

@@ -51,3 +52,3 @@ }

var node = document.createTextNode(text);
var node = this.document.createTextNode(text);

@@ -76,3 +77,3 @@ this.line.appendChild(node);

if (dom.VOID_TAGS[format.tag]) {
node = dom(node).replaceWith(document.createElement(format.tag)).get();
node = dom(node).replaceWith(this.document.createElement(format.tag)).get();
} else {

@@ -102,3 +103,9 @@ node = dom(node).wrap(format.tag).get();

if (format.class) {
node.classList.add(format.class + value);
if (typeof node.classList === 'undefined') {
var newClass = format.class + value;
var className = node.className;
node.className = className.length ? (className + ' ' + newClass) : (className + newClass);
} else {
node.classList.add(format.class + value);
}
}

@@ -111,3 +118,3 @@ if (format.style && value !== format.default) {

if (typeof format.add === 'function') {
node = format.add(node, value);
node = format.add(node, value, dom);
}

@@ -114,0 +121,0 @@

@@ -7,2 +7,3 @@ var dom = module.exports = function(node) {

this.node = node;
this.document = node.ownerDocument;
};

@@ -124,3 +125,3 @@

if (this.node.tagName === newTag) { return this.node; }
var newNode = document.createElement(newTag);
var newNode = this.document.createElement(newTag);
var attributes = this.attributes();

@@ -166,3 +167,3 @@ if (!dom.VOID_TAGS[newTag]) { this.moveChildren(newNode); }

dom.prototype.wrap = function(tag) {
var wrapper = document.createElement(tag);
var wrapper = this.document.createElement(tag);
if (this.node.parentNode) {

@@ -169,0 +170,0 @@ this.node.parentNode.insertBefore(wrapper, this.node);

{
"name": "convert-rich-text",
"version": "1.2.1",
"version": "2.0.0",
"description": "Convert an insert-only rich-text delta into HTML",
"main": "index.js",
"browser": "browser.js",
"scripts": {

@@ -10,3 +11,3 @@ "info": "make info",

"start": "make start",
"test": "make test"
"test": "NODE_ENV=test karma start && mocha test/server/server.js -R spec"
},

@@ -30,3 +31,5 @@ "repository": {

"homepage": "https://github.com/thomsbg/convert-rich-text",
"dependencies": {},
"dependencies": {
"jsdom": "^3.1.2"
},
"devDependencies": {

@@ -37,5 +40,17 @@ "browserify": "^9.0.8",

"jshint": "^2.7.0",
"karma": "^0.13.22",
"karma-chai": "^0.1.0",
"karma-mocha": "^0.2.2",
"karma-phantomjs-launcher": "^1.0.0",
"karma-phantomjs-shim": "^1.2.0",
"karma-source-map-support": "^1.1.0",
"karma-webpack": "^1.7.0",
"mocha-phantomjs": "^3.5.3",
"watchify": "^3.2.0"
"phantomjs-prebuilt": "^2.1.7",
"watchify": "^3.2.0",
"webpack": "^1.12.15"
},
"engines": {
"node": "<=0.12"
}
}

@@ -5,2 +5,4 @@ # convert-rich-text

[![Build Status](https://travis-ci.org/thomsbg/convert-rich-text.svg?branch=master)](https://travis-ci.org/thomsbg/convert-rich-text)
## Install

@@ -69,3 +71,3 @@

`add: function(node, value)` -- a hook for custom behavior, runs after logic for other options. e.g.
`add: function(node, value[, dom])` -- a hook for custom behavior, runs after logic for other options. e.g.

@@ -107,2 +109,7 @@ ```javascript

## Changelog
- `2.0.0` [Server-side support via jsdom](https://github.com/thomsbg/convert-rich-text/pull/2), node version locked to <=0.12
- `1.2.1` Beginning of changelog
## Development

@@ -109,0 +116,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc