braft-convert
Advanced tools
Comparing version 1.8.1 to 1.8.5
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.mergeStyledSpans = exports.getToHTMLConfig = exports.getFromHTMLConfig = exports.blocks = exports.getHexColor = exports.defaultFontFamilies = undefined; | ||
exports.convertCodeBlock = exports.mergeStyledSpans = exports.getFromHTMLConfig = exports.getToHTMLConfig = exports.blocks = exports.getHexColor = exports.defaultFontFamilies = undefined; | ||
@@ -289,3 +289,3 @@ var _react = require("react"); | ||
if (style === 'strikethrough') { | ||
return _react2.default.createElement("braftspan", { style: { textDecoration: 'line-through' }, isbrafttag: "1" }); | ||
return _react2.default.createElement("span", { style: { textDecoration: 'line-through' } }); | ||
} else if (style === 'superscript') { | ||
@@ -296,13 +296,13 @@ return _react2.default.createElement("sup", null); | ||
} else if (style.indexOf('color-') === 0) { | ||
return _react2.default.createElement("braftspan", { style: { color: '#' + style.split('-')[1] }, isbrafttag: "1" }); | ||
return _react2.default.createElement("span", { style: { color: '#' + style.split('-')[1] } }); | ||
} else if (style.indexOf('bgcolor-') === 0) { | ||
return _react2.default.createElement("braftspan", { style: { backgroundColor: '#' + style.split('-')[1] }, isbrafttag: "1" }); | ||
return _react2.default.createElement("span", { style: { backgroundColor: '#' + style.split('-')[1] } }); | ||
} else if (style.indexOf('fontsize-') === 0) { | ||
return _react2.default.createElement("braftspan", { style: { fontSize: style.split('-')[1] + 'px' }, isbrafttag: "1" }); | ||
return _react2.default.createElement("span", { style: { fontSize: style.split('-')[1] + 'px' } }); | ||
} else if (style.indexOf('lineheight-') === 0) { | ||
return _react2.default.createElement("braftspan", { style: { lineHeight: style.split('-')[1] }, isbrafttag: "1" }); | ||
return _react2.default.createElement("span", { style: { lineHeight: style.split('-')[1] } }); | ||
} else if (style.indexOf('letterspacing-') === 0) { | ||
return _react2.default.createElement("braftspan", { style: { letterSpacing: style.split('-')[1] + 'px' }, isbrafttag: "1" }); | ||
return _react2.default.createElement("span", { style: { letterSpacing: style.split('-')[1] + 'px' } }); | ||
} else if (style.indexOf('indent-') === 0) { | ||
return _react2.default.createElement("braftspan", { style: { paddingLeft: style.split('-')[1] + 'px', paddingRight: style.split('-')[1] + 'px' }, isbrafttag: "1" }); | ||
return _react2.default.createElement("span", { style: { paddingLeft: style.split('-')[1] + 'px', paddingRight: style.split('-')[1] + 'px' } }); | ||
} else if (style.indexOf('fontfamily-') === 0) { | ||
@@ -313,3 +313,3 @@ var fontFamily = props.fontFamilies.find(function (item) { | ||
if (!fontFamily) return; | ||
return _react2.default.createElement("braftspan", { style: { fontFamily: fontFamily.family }, isbrafttag: "1" }); | ||
return _react2.default.createElement("span", { style: { fontFamily: fontFamily.family } }); | ||
} | ||
@@ -416,2 +416,6 @@ }; | ||
if (!node || !node.style) { | ||
return currentStyle; | ||
} | ||
var newStyle = currentStyle; | ||
@@ -434,3 +438,3 @@ | ||
newStyle = newStyle.add('LINEHEIGHT-' + node.style.lineHeight); | ||
} else if (nodeName === 'span' && node.style[i] === 'letter-spacing') { | ||
} else if (nodeName === 'span' && node.style[i] === 'letter-spacing' && !isNaN(node.style.letterSpacing)) { | ||
newStyle = newStyle.add('LETTERSPACING-' + parseInt(node.style.letterSpacing, 10)); | ||
@@ -527,17 +531,17 @@ } else if (nodeName === 'span' && (node.style[i] === 'padding-left' || node.style[i] === 'padding-right')) { | ||
var getFromHTMLConfig = exports.getFromHTMLConfig = function getFromHTMLConfig(props) { | ||
var getToHTMLConfig = exports.getToHTMLConfig = function getToHTMLConfig(props) { | ||
return { | ||
htmlToStyle: htmlToStyle(props), | ||
htmlToEntity: htmlToEntity, | ||
htmlToBlock: htmlToBlock | ||
styleToHTML: styleToHTML(props), | ||
entityToHTML: entityToHTML, | ||
blockToHTML: blockToHTML(props.contentState) | ||
}; | ||
}; | ||
var getToHTMLConfig = exports.getToHTMLConfig = function getToHTMLConfig(props) { | ||
var getFromHTMLConfig = exports.getFromHTMLConfig = function getFromHTMLConfig(props) { | ||
return { | ||
styleToHTML: styleToHTML(props), | ||
entityToHTML: entityToHTML, | ||
blockToHTML: blockToHTML(props.contentState) | ||
htmlToStyle: htmlToStyle(props), | ||
htmlToEntity: htmlToEntity, | ||
htmlToBlock: htmlToBlock | ||
}; | ||
@@ -547,5 +551,9 @@ }; | ||
var mergeStyledSpans = exports.mergeStyledSpans = function mergeStyledSpans(htmlContent) { | ||
return htmlContent; | ||
}; | ||
var result = htmlContent.replace(/" isbrafttag="1"><braftspan style="/g, ';').replace(/(\<\/braftspan>)+/g, '</span>').replace(/<braftspan/g, '<span').replace(/" isbrafttag="1"/g, ';"'); | ||
var convertCodeBlock = exports.convertCodeBlock = function convertCodeBlock(htmlContent) { | ||
var result = htmlContent.replace(/\<code\>\<div\>\<br\>\<\/div\>\<\/code\>/g, "<code><div></div></code>").replace(/\<pre\>\<code\>\<div\>/g, '<code><div>').replace(/\<\/div\>\<\/code\>\<\/pre\>/g, '</div></code>').replace(/\<code\>\<div\>/g, '<pre><code>').replace(/\<\/div\>\<\/code\>/g, '</code></pre>'); | ||
return result; | ||
@@ -575,5 +583,6 @@ }; | ||
reactHotLoader.register(htmlToBlock, "htmlToBlock", "src/configs.js"); | ||
reactHotLoader.register(getToHTMLConfig, "getToHTMLConfig", "src/configs.js"); | ||
reactHotLoader.register(getFromHTMLConfig, "getFromHTMLConfig", "src/configs.js"); | ||
reactHotLoader.register(getToHTMLConfig, "getToHTMLConfig", "src/configs.js"); | ||
reactHotLoader.register(mergeStyledSpans, "mergeStyledSpans", "src/configs.js"); | ||
reactHotLoader.register(convertCodeBlock, "convertCodeBlock", "src/configs.js"); | ||
leaveModule(module); | ||
@@ -580,0 +589,0 @@ })(); |
{ | ||
"name": "braft-convert", | ||
"version": "1.8.1", | ||
"version": "1.8.5", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
217174
619