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

draftjs-utils

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

draftjs-utils - npm Package Compare versions

Comparing version 0.7.2 to 0.7.3

4

js/__test__/inlineTest.js

@@ -138,3 +138,3 @@ import { assert } from 'chai';

);
editorState = toggleCustomInlineStyle(editorState, 'color', 'color-rgb(97,189,109)');
editorState = toggleCustomInlineStyle(editorState, 'color', 'rgb(97,189,109)');
assert.equal(getSelectionCustomInlineStyle(

@@ -144,3 +144,3 @@ editorState,

);
editorState = toggleCustomInlineStyle(editorState, 'bgcolor', 'bgcolor-rgb(97,189,109)');
editorState = toggleCustomInlineStyle(editorState, 'bgcolor', 'rgb(97,189,109)');
assert.equal(getSelectionCustomInlineStyle(

@@ -147,0 +147,0 @@ editorState,

@@ -5,5 +5,2 @@ /* @flow */

getEntityRange,
setColors,
setFontSizes,
setFontFamilies,
getCustomStyleMap,

@@ -52,5 +49,2 @@ toggleCustomInlineStyle,

getEntityRange,
setColors,
setFontSizes,
setFontFamilies,
getCustomStyleMap,

@@ -57,0 +51,0 @@ toggleCustomInlineStyle,

@@ -130,2 +130,21 @@ /* @flow */

*/
const customInlineStyleMap = {
SUPERSCRIPT: {
fontSize: 11,
position: 'relative',
top: -8,
display: 'inline-flex',
},
SUBSCRIPT: {
fontSize: 11,
position: 'relative',
bottom: -8,
display: 'inline-flex',
},
};
/**
* Collection of all custom inline styles.
*/
export const customInlineStylesMap =

@@ -152,38 +171,9 @@ {

/**
* Set colors.
* Set style.
*/
export const setColors = (colors: Array<string>) => {
colors.forEach((color) => {
customInlineStylesMap.color[`color-${color}`] = {
color,
};
customInlineStylesMap.bgcolor[`bgcolor-${color}`] = {
backgroundColor: color,
};
});
const addToCustomStyleMap = (styleType, styleKey, style) => { // eslint-disable-line
customInlineStylesMap[styleType][`${styleType.toLowerCase()}-${style}`] = { [`${styleKey}`]: style };
};
/**
* Set font families.
*/
export const setFontSizes = (fontSizes: Array<number>) => {
fontSizes.forEach((size) => {
customInlineStylesMap.fontSize[`fontsize-${size}`] = {
fontSize: size,
};
});
};
/**
* Set font families.
*/
export const setFontFamilies = (fontFamilies: Array<string>) => {
fontFamilies.forEach((family) => {
customInlineStylesMap.fontFamily[`fontfamily-${family}`] = {
fontFamily: family,
};
});
};
/**
* Combined map of all custon inline styles used to initialize editor.

@@ -225,7 +215,18 @@ */

}
if (!currentStyle.has(style)) {
nextEditorState = RichUtils.toggleInlineStyle(
nextEditorState,
style,
);
if (styleType === 'SUPERSCRIPT' || styleType == 'SUBSCRIPT') {
if (!currentStyle.has(style)) {
nextEditorState = RichUtils.toggleInlineStyle(
nextEditorState,
style,
);
}
} else {
const styleKey = styleType === 'bgcolor' ? 'backgroundColor' : styleType;
if (!currentStyle.has(`${styleKey}-${style}`)) {
nextEditorState = RichUtils.toggleInlineStyle(
nextEditorState,
`${styleType.toLowerCase()}-${style}`,
);
addToCustomStyleMap(styleType, styleKey, style);
}
}

@@ -232,0 +233,0 @@ return nextEditorState;

{
"name": "draftjs-utils",
"version": "0.7.2",
"version": "0.7.3",
"description": "Collection of utility function for use with Draftjs.",

@@ -5,0 +5,0 @@ "main": "lib/draftjs-utils.js",

Sorry, the diff of this file is too big to display

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