Socket
Socket
Sign inDemoInstall

draft-js-entity-props-plugin

Package Overview
Dependencies
31
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

lib/utils/removeBlock.js

37

lib/index.js

@@ -11,10 +11,41 @@ 'use strict';

var _removeBlock = require('./utils/removeBlock');
var _removeBlock2 = _interopRequireDefault(_removeBlock);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var setEntityDataFn = function setEntityDataFn(contentBlock, _ref) {
var getEditorState = _ref.getEditorState;
var setEditorState = _ref.setEditorState;
return function (data) {
var entityKey = contentBlock.getEntityAt(0);
if (entityKey) {
var editorState = getEditorState();
_draftJs.Entity.mergeData(entityKey, _extends({}, data));
setEditorState(_draftJs.EditorState.forceSelection(editorState, editorState.getSelection()));
}
};
};
var removeBlockFn = function removeBlockFn(contentBlock, _ref2) {
var getEditorState = _ref2.getEditorState;
var setEditorState = _ref2.setEditorState;
return function () {
setEditorState((0, _removeBlock2.default)(getEditorState(), contentBlock.get('key')));
};
};
var entityPropsPlugin = function entityPropsPlugin() {
return {
blockRendererFn: function blockRendererFn(contentBlock) {
blockRendererFn: function blockRendererFn(contentBlock, options) {
var entityKey = contentBlock.getEntityAt(0);
var data = entityKey ? _draftJs.Entity.get(entityKey).data : {};
// Add entity data to blockProps of all blocks
return {
props: _extends({}, data)
props: _extends({
pluginEditor: options
}, options, data, {
setEntityData: setEntityDataFn(contentBlock, options),
removeBlock: removeBlockFn(contentBlock, options)
})
};

@@ -21,0 +52,0 @@ }

2

package.json
{
"name": "draft-js-entity-props-plugin",
"version": "1.0.0",
"version": "1.0.1",
"description": "Entity Props Plugin for DraftJS",

@@ -5,0 +5,0 @@ "author": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc