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

draftail

Package Overview
Dependencies
Maintainers
6
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

draftail - npm Package Compare versions

Comparing version 0.7.3 to 0.8.0

es/api/behavior.js

15

CHANGELOG.md

@@ -5,6 +5,19 @@ # Changelog

## Unreleased
## [[v0.8.0]](https://github.com/springload/draftail/releases/tag/v0.8.0)
### Added
- Add `name` attribute to button elements to facilitate targeting in browser automation tests.
- Publish the package as an ES2015 module.
### Changed
- Upgrade draftjs-utils to latest (draftjs-utils).
- Use references to window object instead of global.
- Update dependencies to remove Immutable.js duplication
## [[v0.7.3]](https://github.com/springload/draftail/releases/tag/v0.7.3)
### Added
- Expose reusable Portal component as part of the API.

@@ -11,0 +24,0 @@

1

dist/api/behavior.js

@@ -92,3 +92,2 @@ 'use strict';

return Object.keys(allTypes).reduce(function (enabled, key) {
// eslint-disable-next-line no-param-reassign
enabled[key] = activeTypes.some(function (item) {

@@ -95,0 +94,0 @@ return item.type === allTypes[key];

@@ -6,3 +6,2 @@ 'use strict';

});
// Originally from https://github.com/draft-js-utils/draft-js-utils/blob/master/src/Constants.js.

@@ -65,17 +64,53 @@ var BLOCK_TYPE = exports.BLOCK_TYPE = {

var KEYBOARD_SHORTCUTS = exports.KEYBOARD_SHORTCUTS = {};
KEYBOARD_SHORTCUTS[BLOCK_TYPE.UNSTYLED] = { other: 'ctrl + alt + 0', macOS: '⌘ + option + 0' };
KEYBOARD_SHORTCUTS[BLOCK_TYPE.HEADER_ONE] = { other: 'ctrl + alt + 1', macOS: '⌘ + option + 1' };
KEYBOARD_SHORTCUTS[BLOCK_TYPE.HEADER_TWO] = { other: 'ctrl + alt + 2', macOS: '⌘ + option + 2' };
KEYBOARD_SHORTCUTS[BLOCK_TYPE.HEADER_THREE] = { other: 'ctrl + alt + 3', macOS: '⌘ + option + 3' };
KEYBOARD_SHORTCUTS[BLOCK_TYPE.HEADER_FOUR] = { other: 'ctrl + alt + 4', macOS: '⌘ + option + 4' };
KEYBOARD_SHORTCUTS[BLOCK_TYPE.HEADER_FIVE] = { other: 'ctrl + alt + 5', macOS: '⌘ + option + 5' };
KEYBOARD_SHORTCUTS[BLOCK_TYPE.HEADER_SIX] = { other: 'ctrl + alt + 6', macOS: '⌘ + option + 6' };
KEYBOARD_SHORTCUTS[BLOCK_TYPE.UNORDERED_LIST_ITEM] = { other: 'ctrl + shift + 8', macOS: '⌘ + shift + 8' };
KEYBOARD_SHORTCUTS[BLOCK_TYPE.ORDERED_LIST_ITEM] = { other: 'ctrl + shift + 7', macOS: '⌘ + shift + 7' };
KEYBOARD_SHORTCUTS[BLOCK_TYPE.UNSTYLED] = {
other: 'ctrl + alt + 0',
macOS: '⌘ + option + 0'
};
KEYBOARD_SHORTCUTS[BLOCK_TYPE.HEADER_ONE] = {
other: 'ctrl + alt + 1',
macOS: '⌘ + option + 1'
};
KEYBOARD_SHORTCUTS[BLOCK_TYPE.HEADER_TWO] = {
other: 'ctrl + alt + 2',
macOS: '⌘ + option + 2'
};
KEYBOARD_SHORTCUTS[BLOCK_TYPE.HEADER_THREE] = {
other: 'ctrl + alt + 3',
macOS: '⌘ + option + 3'
};
KEYBOARD_SHORTCUTS[BLOCK_TYPE.HEADER_FOUR] = {
other: 'ctrl + alt + 4',
macOS: '⌘ + option + 4'
};
KEYBOARD_SHORTCUTS[BLOCK_TYPE.HEADER_FIVE] = {
other: 'ctrl + alt + 5',
macOS: '⌘ + option + 5'
};
KEYBOARD_SHORTCUTS[BLOCK_TYPE.HEADER_SIX] = {
other: 'ctrl + alt + 6',
macOS: '⌘ + option + 6'
};
KEYBOARD_SHORTCUTS[BLOCK_TYPE.UNORDERED_LIST_ITEM] = {
other: 'ctrl + shift + 8',
macOS: '⌘ + shift + 8'
};
KEYBOARD_SHORTCUTS[BLOCK_TYPE.ORDERED_LIST_ITEM] = {
other: 'ctrl + shift + 7',
macOS: '⌘ + shift + 7'
};
KEYBOARD_SHORTCUTS[ENTITY_TYPE.LINK] = { other: 'ctrl + K', macOS: '⌘ + K' };
KEYBOARD_SHORTCUTS[BR_TYPE] = { other: 'shift + enter', macOS: 'shift + enter' };
KEYBOARD_SHORTCUTS[BR_TYPE] = {
other: 'shift + enter',
macOS: 'shift + enter'
};
KEYBOARD_SHORTCUTS[INLINE_STYLE.BOLD] = { other: 'ctrl + B', macOS: '⌘ + B' };
KEYBOARD_SHORTCUTS[INLINE_STYLE.ITALIC] = { other: 'ctrl + I', macOS: '⌘ + I' };
KEYBOARD_SHORTCUTS[INLINE_STYLE.UNDERLINE] = { other: 'ctrl + U', macOS: '⌘ + U' };
KEYBOARD_SHORTCUTS[INLINE_STYLE.STRIKETHROUGH] = { other: 'alt + shift + 5', macOS: 'option + shift + 5' };
KEYBOARD_SHORTCUTS[INLINE_STYLE.UNDERLINE] = {
other: 'ctrl + U',
macOS: '⌘ + U'
};
KEYBOARD_SHORTCUTS[INLINE_STYLE.STRIKETHROUGH] = {
other: 'alt + shift + 5',
macOS: 'option + shift + 5'
};

@@ -82,0 +117,0 @@ var NBSP = exports.NBSP = '\xA0';

@@ -76,3 +76,7 @@ 'use strict';

'a',
{ href: url, target: '_blank', rel: 'noopener noreferrer' },
{
href: url,
target: '_blank',
rel: 'noopener noreferrer'
},
url

@@ -79,0 +83,0 @@ )

@@ -176,3 +176,7 @@ 'use strict';

'button',
{ type: 'button', className: 'button button-secondary', onClick: this.onSave },
{
type: 'button',
className: 'button button-secondary',
onClick: this.onSave
},
'Save changes'

@@ -182,3 +186,7 @@ ),

'button',
{ type: 'button', className: 'button button-secondary no', onClick: onCancel },
{
type: 'button',
className: 'button button-secondary no',
onClick: onCancel
},
'Cancel'

@@ -185,0 +193,0 @@ )

@@ -111,3 +111,5 @@ 'use strict';

'div',
{ className: 'RichEditor-media' + (isActive ? ' RichEditor-media--open' : '') },
{
className: 'RichEditor-media' + (isActive ? ' RichEditor-media--open' : '')
},
_react2.default.createElement(Block, {

@@ -114,0 +116,0 @@ entity: blockProps.entity,

@@ -28,3 +28,4 @@ 'use strict';

var Button = function Button(_ref) {
var active = _ref.active,
var name = _ref.name,
active = _ref.active,
label = _ref.label,

@@ -37,2 +38,3 @@ title = _ref.title,

{
name: name,
className: 'RichEditor-styleButton' + (active ? ' RichEditor-activeButton' : ''),

@@ -49,2 +51,3 @@ type: 'button',

Button.propTypes = {
name: _propTypes2.default.string,
active: _propTypes2.default.bool,

@@ -58,2 +61,3 @@ label: _propTypes2.default.string,

Button.defaultProps = {
name: null,
active: false,

@@ -60,0 +64,0 @@ label: null,

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

}, function () {
global.clearTimeout(_this2.updateTimeout);
_this2.updateTimeout = global.setTimeout(_this2.saveState, stateSaveInterval);
window.clearTimeout(_this2.updateTimeout);
_this2.updateTimeout = window.setTimeout(_this2.saveState, stateSaveInterval);
});

@@ -297,3 +297,3 @@ }

if (entityData.url) {
global.open(entityData.url);
window.open(entityData.url);
}

@@ -304,3 +304,2 @@ }

// Quick hack to disable soft line breaks.
// eslint-disable-next-line no-param-reassign
e.which = 0;

@@ -410,3 +409,5 @@ }

this.onChange(_DraftUtils2.default.resetBlockWithType(editorState, newBlockType, { text: '' }));
this.onChange(_DraftUtils2.default.resetBlockWithType(editorState, newBlockType, {
text: ''
}));

@@ -540,5 +541,5 @@ return _constants.HANDLED;

global.setTimeout(function () {
window.setTimeout(function () {
_this3.setState({ readOnly: false }, function () {
global.setTimeout(function () {
window.setTimeout(function () {
_this3.editorRef.focus();

@@ -545,0 +546,0 @@ }, 0);

@@ -49,2 +49,3 @@ 'use strict';

key: block.type,
name: block.type,
active: _DraftUtils2.default.isSelectedBlockType(editorState, block.type),

@@ -60,2 +61,3 @@ label: block.label,

key: style.type,
name: style.type,
active: _DraftUtils2.default.hasCurrentInlineStyle(editorState, style.type),

@@ -69,2 +71,3 @@ label: style.label,

enableHorizontalRule ? _react2.default.createElement(_Button2.default, {
name: _constants.ENTITY_TYPE.HORIZONTAL_RULE,
onClick: addHR,

@@ -74,2 +77,3 @@ label: 'HR'

enableLineBreak ? _react2.default.createElement(_Button2.default, {
name: _constants.BR_TYPE,
onClick: addBR,

@@ -82,2 +86,3 @@ label: 'BR',

key: entity.type,
name: entity.type,
onClick: onRequestDialog.bind(null, entity.type),

@@ -84,0 +89,0 @@ label: entity.label,

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});

@@ -6,0 +6,0 @@ exports.Portal = exports.Icon = exports.INLINE_STYLE = exports.ENTITY_TYPE = exports.BLOCK_TYPE = exports.DraftUtils = undefined;

@@ -11,3 +11,3 @@ 'use strict';

var stopChars = [' ', '/', '&'];
var acceptableShortness = l * 0.80; // When to start looking for stop characters
var acceptableShortness = l * 0.8; // When to start looking for stop characters
var str = reverse ? s.split('').reverse().join('') : s;

@@ -14,0 +14,0 @@ var ret = '';

{
"name": "draftail",
"version": "0.7.3",
"description": "📝🍸 A batteries-excluded rich text editor based on Draft.js",
"author": "Springload",
"license": "MIT",
"main": "dist/index.js",
"keywords": [
"draftjs",
"draft.js",
"draft",
"draft-js",
"editor",
"wysiwyg",
"rich text",
"rte",
"react",
"react-component",
"react-components"
],
"repository": {
"type": "git",
"url": "https://github.com/springload/draftail"
},
"bugs": {
"url": "https://github.com/springload/draftail/issues"
},
"homepage": "https://springload.github.io/draftail/",
"babel": {
"presets": [
[
"env",
{
"targets": {
"browsers": [
"> 1%",
"IE 11"
]
}
"name": "draftail",
"version": "0.8.0",
"description": "📝🍸 A batteries-excluded rich text editor based on Draft.js",
"author": "Springload",
"license": "MIT",
"main": "dist/index.js",
"module": "es/index.js",
"keywords": [
"draftjs",
"draft.js",
"draft",
"draft-js",
"editor",
"wysiwyg",
"rich text",
"rte",
"react",
"react-component",
"react-components"
],
"repository": {
"type": "git",
"url": "https://github.com/springload/draftail"
},
"bugs": {
"url": "https://github.com/springload/draftail/issues"
},
"homepage": "https://springload.github.io/draftail/",
"babel": {
"presets": [
[
"env",
{
"targets": {
"browsers": ["> 1%", "IE 11"]
},
"modules": false
}
],
"react"
],
"env": {
"test": {
"presets": [
[
"env",
{
"targets": {
"browsers": ["> 1%", "IE 11"]
}
}
],
"react"
]
}
}
],
"react"
]
},
"eslintConfig": {
"extends": "plugin:springload/recommended"
},
"jest": {
"moduleNameMapper": {
"\\.scss$": "<rootDir>/lib/tests/styleMock.js"
},
"testPathIgnorePatterns": [
"/node_modules/",
"/dist/",
"/pages/",
"/examples/test.js"
],
"snapshotSerializers": [
"enzyme-to-json/serializer"
]
},
"dependencies": {
"draftjs-utils": "0.7.3",
"immutable": "^3.0.0"
},
"devDependencies": {
"autoprefixer": "^7.1.1",
"babel-cli": "^6.22.2",
"babel-jest": "^20.0.0",
"babel-loader": "^7.0.0",
"babel-preset-env": "^1.5.1",
"babel-preset-react": "^6.24.1",
"coveralls": "^2.11.15",
"css-loader": "^0.28.2",
"dotenv": "^4.0.0",
"draft-js": "^0.10.0",
"element-closest": "^2.0.2",
"enzyme": "^2.8.2",
"enzyme-to-json": "^1.5.1",
"eslint": "^3.19.0",
"eslint-plugin-springload": "^1.0.2",
"extract-text-webpack-plugin": "^2.1.0",
"jest": "^20.0.0",
"node-sass": "^4.5.3",
"postcss-loader": "^2.0.5",
"prop-types": "^15.5.8",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-test-renderer": "^15.5.4",
"sass-loader": "^6.0.5",
"webpack": "^2.6.1",
"webpack-dev-server": "^2.4.5"
},
"peerDependencies": {
"draft-js": "^0.10.0",
"prop-types": "^15.5.0",
"react": "^15.5.0",
"react-dom": "^15.5.0"
},
"scripts": {
"start": "webpack-dev-server --config=webpack/webpack.config.dev.js",
"js": "babel -d dist lib",
"build": "npm run js -s && webpack --config=webpack/webpack.config.prod.js && cp pages/assets/draftail.css dist",
"dist": "NODE_ENV=production npm run build -s",
"linter:js": "eslint",
"lint": "npm run linter:js -s -- .",
"test": "jest",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch",
"test:watch:coverage": "jest --watch --coverage",
"report:coverage": "open coverage/lcov-report/index.html",
"report:build": "NODE_ENV=production webpack --config webpack/webpack.config.prod.js --profile --json > webpack-stats.json",
"test:ci": "npm run lint -s && npm run test:coverage -s && npm run dist -s",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"pages": "rm -rf pages && cp -R examples pages && npm run dist -s",
"deploy": "./bin/deploy.sh"
}
"eslintConfig": {
"extends": "plugin:springload/prettier"
},
"jest": {
"moduleNameMapper": {
"\\.scss$": "<rootDir>/lib/tests/styleMock.js"
},
"testPathIgnorePatterns": ["/node_modules/", "/dist/", "/examples/"],
"snapshotSerializers": ["enzyme-to-json/serializer"]
},
"dependencies": {
"draftjs-utils": "0.8.4"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-cli": "^6.24.1",
"babel-jest": "^20.0.0",
"babel-loader": "^7.1.1",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.4",
"dotenv": "^4.0.0",
"draft-js": "^0.10.1",
"element-closest": "^2.0.2",
"enzyme": "^2.8.2",
"enzyme-to-json": "^1.5.1",
"eslint": "^3.19.0",
"eslint-plugin-springload": "^2.0.2",
"extract-text-webpack-plugin": "^3.0.0",
"immutable": "~3.7.4",
"jest": "^20.0.0",
"node-sass": "^4.5.3",
"postcss-loader": "^2.0.6",
"prettier": "^1.5.3",
"prop-types": "^15.5.10",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-test-renderer": "^15.6.1",
"sass-loader": "^6.0.6",
"webpack": "^3.4.1",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-server": "^2.6.1"
},
"peerDependencies": {
"draft-js": "^0.10.1",
"prop-types": "^15.5.0",
"react": "^15.5.0",
"react-dom": "^15.5.0",
"immutable": "~3.7.4"
},
"scripts": {
"start": "webpack-dev-server --config=webpack/webpack.config.dev.js",
"js": "babel lib -d es && BABEL_ENV=test babel lib -d dist",
"build": "npm run js -s && webpack --config=webpack/webpack.config.prod.js --display-optimization-bailout && cp examples/assets/draftail.css dist",
"dist": "NODE_ENV=production npm run build -s",
"linter:js": "eslint",
"lint": "npm run linter:js -s -- .",
"formatter:js": "prettier --print-width 80 --tab-width 4 --single-quote --trailing-comma all",
"format": "npm run formatter:js -- --write lib/**/*.js examples/sources/*.js examples/entities/*.js examples/utils/*.js examples/*.js webpack/*.js",
"test": "jest",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch",
"test:watch:coverage": "jest --watch --coverage",
"report:coverage": "open coverage/lcov-report/index.html",
"report:build": "open webpack/webpack-stats.html",
"test:ci": "npm run lint -s && npm run test:coverage -s && npm run dist -s"
}
}

@@ -277,2 +277,4 @@ # [Draftail](https://springload.github.io/draftail/) [![npm](https://img.shields.io/npm/v/draftail.svg?style=flat-square)](https://www.npmjs.com/package/draftail) [![Build Status](https://travis-ci.org/springload/draftail.svg?branch=master)](https://travis-ci.org/springload/draftail) [![Coverage Status](https://coveralls.io/repos/github/springload/draftail/badge.svg)](https://coveralls.io/github/springload/draftail)

npm run lint
# Re-formats all of the files in the project (with Prettier).
npm run format
# Run tests in a watcher.

@@ -284,2 +286,4 @@ npm run test:watch

npm run report:coverage
# Open the build report with:
npm run report:build
# View other available commands with:

@@ -286,0 +290,0 @@ npm run

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