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.2.7 to 0.2.8

4

js/__test__/inlineTest.js

@@ -114,3 +114,3 @@ import {

forEach(customInlineStylesMap.bgcolor, (key, value) => {
assert.isDefined(value['background-color']);
assert.isDefined(value.backgroundColor);
});

@@ -127,3 +127,3 @@ forEach(customInlineStylesMap.fontSize, (key, value) => {

forEach(customStyleMap, (key, value) => {
assert.isDefined(value.color || value['background-color']
assert.isDefined(value.color || value.backgroundColor
|| value.fontSize || value.fontFamily);

@@ -130,0 +130,0 @@ });

@@ -12,2 +12,3 @@ /* @flow */

List,
Map,
} from 'immutable';

@@ -157,1 +158,43 @@

}
/**
* Function will add block level meta-data.
*/
export function setBlockData(editorState: EditorState, data: Object): EditorState {
const newContentState = Modifier.setBlockData(
editorState.getCurrentContent(),
editorState.getSelection(),
data);
return EditorState.push(editorState, newContentState, 'change-block-data');
}
/**
* Function will return currently selected blocks meta data.
*/
export function getSelectedBlocksMetadata(editorState: EditorState): Map {
let metaData = new Map({});
const selectedBlocks = getSelectedBlocksList(editorState);
if (selectedBlocks && selectedBlocks.size > 0) {
for (let i = 0; i < selectedBlocks.size; i++) {
const data = selectedBlocks.get(i).getData();
if (!data || data.size === 0) {
metaData = metaData.clear();
break;
}
if (i === 0) {
metaData = data;
} else {
metaData.forEach((value, key) => { // eslint-disable-line no-loop-func
if (!data.get(key) || data.get(key) !== value) {
metaData = metaData.delete(key);
}
});
if (metaData.size === 0) {
metaData = metaData.clear();
break;
}
}
}
}
return metaData;
}

@@ -25,2 +25,4 @@ /* @flow */

clearEditorContent,
setBlockData,
getSelectedBlocksMetadata,
} from './block';

@@ -47,2 +49,4 @@ import {

clearEditorContent,
setBlockData,
getSelectedBlocksMetadata,
// Functions related to inline styles

@@ -49,0 +53,0 @@ colors,

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

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

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

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