Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

braft-convert

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

braft-convert - npm Package Compare versions

Comparing version 1.2.0 to 1.7.0

95

dist/configs.js

@@ -6,3 +6,3 @@ "use strict";

});
exports.getFromHTMLConfig = exports.getToHTMLConfig = exports.blocks = exports.getHexColor = undefined;
exports.getToHTMLConfig = exports.getFromHTMLConfig = exports.blocks = exports.getHexColor = undefined;

@@ -256,2 +256,4 @@ var _react = require("react");

);
} else if (mediaType === 'hr') {
return _react2.default.createElement("hr", null);
} else {

@@ -281,2 +283,6 @@ return _react2.default.createElement("p", null);

return _react2.default.createElement("span", { style: { lineHeight: style.split('-')[1] } });
} else if (style.indexOf('letterspacing-') === 0) {
return _react2.default.createElement("span", { style: { letterSpacing: style.split('-')[1] + 'px' } });
} else if (style.indexOf('indent-') === 0) {
return _react2.default.createElement("span", { style: { paddingLeft: style.split('-')[1] + 'px', paddingRight: style.split('-')[1] + 'px' } });
} else if (style.indexOf('fontfamily-') === 0) {

@@ -286,2 +292,3 @@ var fontFamily = props.fontFamilies.find(function (item) {

});
if (!fontFamily) return;
return _react2.default.createElement("span", { style: { fontFamily: fontFamily.family } });

@@ -386,34 +393,37 @@ }

var getToHTMLConfig = exports.getToHTMLConfig = function getToHTMLConfig(props) {
var htmlToStyle = function htmlToStyle(props) {
return function (nodeName, node, currentStyle) {
return {
styleToHTML: styleToHTML(props),
entityToHTML: entityToHTML,
blockToHTML: blockToHTML(props.contentState)
if (nodeName === 'span' && node.style.color) {
var color = getHexColor(node.style.color);
return color ? currentStyle.add('COLOR-' + color.replace('#', '').toUpperCase()) : currentStyle;
} else if (nodeName === 'span' && node.style.backgroundColor) {
var _color = getHexColor(node.style.backgroundColor);
return _color ? currentStyle.add('BGCOLOR-' + _color.replace('#', '').toUpperCase()) : currentStyle;
} else if (nodeName === 'sup') {
return currentStyle.add('SUPERSCRIPT');
} else if (nodeName === 'sub') {
return currentStyle.add('SUBSCRIPT');
} else if (nodeName === 'span' && node.style.fontSize) {
return currentStyle.add('FONTSIZE-' + parseInt(node.style.fontSize, 10));
} else if (nodeName === 'span' && node.style.lineHeight) {
return currentStyle.add('LINEHEIGHT-' + node.style.lineHeight);
} else if (nodeName === 'span' && node.style.letterSpacing) {
return currentStyle.add('LETTERSPACING-' + parseInt(node.style.letterSpacing, 10));
} else if (nodeName === 'span' && node.style.indent) {
return currentStyle.add('INDENT-' + parseInt(node.style.indent, 10));
} else if (nodeName === 'span' && node.style.textDecoration === 'line-through') {
return currentStyle.add('STRIKETHROUGH');
} else if (nodeName === 'span' && node.style.fontFamily) {
var fontFamily = props.fontFamilies.find(function (item) {
return item.family.toLowerCase() === node.style.fontFamily.toLowerCase();
});
if (!fontFamily) return currentStyle;
return currentStyle.add('FONTFAMILY-' + fontFamily.name.toUpperCase());
} else {
return currentStyle;
}
};
};
var htmlToStyle = function htmlToStyle(nodeName, node, currentStyle) {
if (nodeName === 'span' && node.style.color) {
var color = getHexColor(node.style.color);
return color ? currentStyle.add('COLOR-' + color.replace('#', '').toUpperCase()) : currentStyle;
} else if (nodeName === 'span' && node.style.backgroundColor) {
var _color = getHexColor(node.style.backgroundColor);
return _color ? currentStyle.add('BGCOLOR-' + _color.replace('#', '').toUpperCase()) : currentStyle;
} else if (nodeName === 'sup') {
return currentStyle.add('SUPERSCRIPT');
} else if (nodeName === 'sub') {
return currentStyle.add('SUBSCRIPT');
} else if (nodeName === 'span' && node.style.fontSize) {
return currentStyle.add('FONTSIZE-' + parseInt(node.style.fontSize, 10));
} else if (nodeName === 'span' && node.style.lineHeight) {
return currentStyle.add('LINEHEIGHT-' + node.style.lineHeight);
} else if (nodeName === 'span' && node.style.textDecoration === 'line-through') {
return currentStyle.add('STRIKETHROUGH');
} else {
return currentStyle;
}
};
var htmlToEntity = function htmlToEntity(nodeName, node, createEntity) {

@@ -439,2 +449,3 @@

height = height || 'auto';
var entityData = { url: url, width: width, height: height };

@@ -448,2 +459,4 @@

return createEntity('IMAGE', 'IMMUTABLE', entityData);
} else if (nodeName === 'hr') {
return createEntity('HR', 'IMMUTABLE', {});
}

@@ -474,2 +487,8 @@ };

};
} else if (nodeName === 'hr') {
return {
type: 'atomic',
data: {}
};
} else if (nodeName === 'p' && nodeStyle.textAlign) {

@@ -487,4 +506,18 @@

var getFromHTMLConfig = exports.getFromHTMLConfig = function getFromHTMLConfig(props) {
return { htmlToStyle: htmlToStyle, htmlToEntity: htmlToEntity, htmlToBlock: htmlToBlock };
return {
htmlToStyle: htmlToStyle(props),
htmlToEntity: htmlToEntity,
htmlToBlock: htmlToBlock
};
};
var getToHTMLConfig = exports.getToHTMLConfig = function getToHTMLConfig(props) {
return {
styleToHTML: styleToHTML(props),
entityToHTML: entityToHTML,
blockToHTML: blockToHTML(props.contentState)
};
};
;

@@ -508,3 +541,2 @@

reactHotLoader.register(entityToHTML, "entityToHTML", "src/configs.js");
reactHotLoader.register(getToHTMLConfig, "getToHTMLConfig", "src/configs.js");
reactHotLoader.register(htmlToStyle, "htmlToStyle", "src/configs.js");

@@ -514,2 +546,3 @@ reactHotLoader.register(htmlToEntity, "htmlToEntity", "src/configs.js");

reactHotLoader.register(getFromHTMLConfig, "getFromHTMLConfig", "src/configs.js");
reactHotLoader.register(getToHTMLConfig, "getToHTMLConfig", "src/configs.js");
leaveModule(module);

@@ -516,0 +549,0 @@ })();

{
"name": "braft-convert",
"version": "1.2.0",
"version": "1.7.0",
"description": "A convert helper for Braft Editor.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

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