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 2.0.0 to 2.0.1

10

dist/configs.js

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

var styleToHTML = function styleToHTML(props) {
var styleToHTML = function styleToHTML(options) {
return function (style) {

@@ -329,3 +329,3 @@

} else if (style.indexOf('fontfamily-') === 0) {
var fontFamily = props.fontFamilies.find(function (item) {
var fontFamily = options.fontFamilies.find(function (item) {
return item.name.toLowerCase() === style.split('-')[1];

@@ -577,8 +577,8 @@ });

var getToHTMLConfig = exports.getToHTMLConfig = function getToHTMLConfig(props) {
var getToHTMLConfig = exports.getToHTMLConfig = function getToHTMLConfig(options, contentState) {
return {
styleToHTML: styleToHTML(props),
styleToHTML: styleToHTML(options),
entityToHTML: entityToHTML,
blockToHTML: blockToHTML(props.contentState)
blockToHTML: blockToHTML(contentState)
};

@@ -585,0 +585,0 @@ };

@@ -6,4 +6,6 @@ 'use strict';

});
exports.convertHTMLToRaw = exports.convertRawToHTML = undefined;
exports.convertRawToEditorState = exports.convertEditorStateToRaw = exports.convertHTMLToEditorState = exports.convertEditorStateToHTML = exports.convertHTMLToRaw = exports.convertRawToHTML = undefined;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _draftConvert = require('draft-convert');

@@ -15,8 +17,13 @@

var convertRawToHTML = exports.convertRawToHTML = function convertRawToHTML(content) {
var fontFamilies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _configs.defaultFontFamilies;
var defaultConvertOptions = {
fontFamilies: _configs.defaultFontFamilies
};
var convertRawToHTML = exports.convertRawToHTML = function convertRawToHTML(rawContent, options) {
options = _extends({}, defaultConvertOptions, options);
try {
var contentState = (0, _draftJs.convertFromRaw)(content);
return (0, _draftConvert.convertToHTML)((0, _configs.getToHTMLConfig)({ contentState: contentState, fontFamilies: fontFamilies }))(contentState);
var contentState = (0, _draftJs.convertFromRaw)(rawContent);
return (0, _draftConvert.convertToHTML)((0, _configs.getToHTMLConfig)(options, contentState))(contentState);
} catch (error) {

@@ -28,7 +35,8 @@ console.warn(error);

var convertHTMLToRaw = exports.convertHTMLToRaw = function convertHTMLToRaw(content) {
var fontFamilies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _configs.defaultFontFamilies;
var convertHTMLToRaw = exports.convertHTMLToRaw = function convertHTMLToRaw(HTMLString, options) {
options = _extends({}, defaultConvertOptions, options);
try {
var contentState = (0, _draftConvert.convertFromHTML)((0, _configs.getFromHTMLConfig)({ fontFamilies: fontFamilies }))(content);
var contentState = (0, _draftConvert.convertFromHTML)((0, _configs.getFromHTMLConfig)(options))(HTMLString);
return (0, _draftJs.convertToRaw)(contentState);

@@ -40,2 +48,41 @@ } catch (error) {

};
var convertEditorStateToHTML = exports.convertEditorStateToHTML = function convertEditorStateToHTML(editorState, options) {
options = _extends({}, defaultConvertOptions, options);
try {
var contentState = editorState.getCurrentContent();
return (0, _draftConvert.convertToHTML)((0, _configs.getToHTMLConfig)(options, contentState))(contentState);
} catch (error) {
console.warn(error);
return '';
}
};
var convertHTMLToEditorState = exports.convertHTMLToEditorState = function convertHTMLToEditorState(HTMLString, editorDecorators, options) {
options = _extends({}, defaultConvertOptions, options);
try {
return _draftJs.EditorState.createWithContent((0, _draftConvert.convertFromHTML)((0, _configs.getFromHTMLConfig)(options))(HTMLString), editorDecorators);
} catch (error) {
console.warn(error);
return _draftJs.EditorState.createEmpty(editorDecorators);
}
};
var convertEditorStateToRaw = exports.convertEditorStateToRaw = function convertEditorStateToRaw(editorState) {
return (0, _draftJs.convertToRaw)(editorState.getCurrentContent());
};
var convertRawToEditorState = exports.convertRawToEditorState = function convertRawToEditorState(rawContent, editorDecorators) {
try {
return _draftJs.EditorState.createWithContent((0, _draftJs.convertFromRaw)(rawContent), editorDecorators);
} catch (error) {
console.warn(error);
return _draftJs.EditorState.createEmpty(editorDecorators);
}
};
//# sourceMappingURL=index.js.map
{
"name": "braft-convert",
"version": "2.0.0",
"version": "2.0.1",
"description": "A convert helper for Braft Editor.",

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

"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"babel-preset-stage-0": "^6.24.1",
"babel-runtime": "^6.5.0",
"html-webpack-plugin": "^2.17.0",
"react": "^16.0.0",

@@ -44,4 +45,3 @@ "react-dom": "^16.0.0",

"webpack-hot-middleware": "^2.18.0",
"webpack-merge": "^4.1.0",
"html-webpack-plugin": "^2.17.0"
"webpack-merge": "^4.1.0"
},

@@ -48,0 +48,0 @@ "peerDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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