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

draft-js

Package Overview
Dependencies
Maintainers
4
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

draft-js - npm Package Compare versions

Comparing version 0.10.3 to 0.10.4

37

CHANGELOG.md

@@ -7,2 +7,39 @@ # Changelog

## 0.10.4 (October 24th, 2017)
### Added
* Expose `onRightArrow` and `onLeftArrow` props to allow handling keyboard
events when right or left arrow is pressed.
([@eessex](https://github.com/eessex)
in [#1384](https://github.com/facebook/draft-js/pull/1384))
* Expose Draft.css as default CSS export in package.json for use by CSS
preprocessors. ([@darobin](https://github.com/darobin )
in [#566](https://github.com/facebook/draft-js/pull/566))
### Changed
* Change 'lookUpwardForInlineStyle' from O(n^2) to O(n), improving performance.
:) ([@Lemmih](https://github.com/Lemmih)
in [#1429](https://github.com/facebook/draft-js/pull/1429))
### Fixed
* Fix bug where editors inside draggable parent were broken for Safari.
([@mattkrick](https://github.com/mattkrick) in
[#1326](https://github.com/facebook/draft-js/pull/1326))
* Stop pulling in Enzyme as production dependency. D'oh.
([@flarnie](https://github.com/flarnie) in
[#1415](https://github.com/facebook/draft-js/pull/1415))
* Fix `TypeError: Cannot read property 'nodeType' of undefined` error where
`anchorNode` was `undefined`.
([@tleunen](https://github.com/tleunen) in
[#1407](https://github.com/facebook/draft-js/pull/1407))
* Fix error thrown when callback tries to `focus` on editor after it has been
unmounted. ([@mattkrick](https://github.com/mattkrick) in
[#1409](https://github.com/facebook/draft-js/pull/1409))
* Fix bug where selecting a single character then typing it doesn't replace it.
([@karanjthakkar](https://github.com/karanjthakkar) in
[#719](https://github.com/facebook/draft-js/pull/719))
* Clear the block type when backspacing at the start of the first block with
rich text utils. ([@jvaill](https://github.com/jvaill) in
[#748](https://github.com/facebook/draft-js/pull/748))
## 0.10.3 (September 28th, 2017)

@@ -9,0 +46,0 @@

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

outline: 'none',
// fix parent-draggable Safari bug. #1326
userSelect: 'text',
WebkitUserSelect: 'text',
whiteSpace: 'pre-wrap',

@@ -322,2 +325,8 @@ wordWrap: 'break-word'

if (!editorNode) {
// once in a while people call 'focus' in a setTimeout, and the node has
// been deleted, so it can be null in that case.
return;
}
var scrollParent = Style.getScrollParent(editorNode);

@@ -324,0 +333,0 @@

17

lib/editOnBeforeInput.js

@@ -89,2 +89,4 @@ /**

var selection = editorState.getSelection();
var selectionStart = selection.getStartOffset();
var selectionEnd = selection.getEndOffset();
var anchorKey = selection.getAnchorKey();

@@ -94,3 +96,14 @@

e.preventDefault();
editor.update(replaceText(editorState, chars, editorState.getCurrentInlineStyle(), getEntityKeyForSelection(editorState.getCurrentContent(), editorState.getSelection())));
// If the character that the user is trying to replace with
// is the same as the current selection text the just update the
// `SelectionState`. Else, update the ContentState with the new text
var currentlySelectedChars = editorState.getCurrentContent().getPlainText().slice(selectionStart, selectionEnd);
if (chars === currentlySelectedChars) {
this.update(EditorState.forceSelection(editorState, selection.merge({
focusOffset: selectionEnd
})));
} else {
editor.update(replaceText(editorState, chars, editorState.getCurrentInlineStyle(), getEntityKeyForSelection(editorState.getCurrentContent(), editorState.getSelection())));
}
return;

@@ -114,3 +127,3 @@ }

// Selection is necessarily collapsed at this point due to earlier check.
if (nativeSelection.anchorNode !== null && nativeSelection.anchorNode.nodeType === Node.TEXT_NODE) {
if (nativeSelection.anchorNode && nativeSelection.anchorNode.nodeType === Node.TEXT_NODE) {
// See isTabHTMLSpanElement in chromium EditingUtilities.cpp.

@@ -117,0 +130,0 @@ var parentNode = nativeSelection.anchorNode.parentNode;

@@ -104,5 +104,11 @@ /**

return;
case Keys.RIGHT:
editor.props.onRightArrow && editor.props.onRightArrow(e);
return;
case Keys.DOWN:
editor.props.onDownArrow && editor.props.onDownArrow(e);
return;
case Keys.LEFT:
editor.props.onLeftArrow && editor.props.onLeftArrow(e);
return;
case Keys.SPACE:

@@ -109,0 +115,0 @@ // Handling for OSX where option + space scrolls.

16

lib/EditorState.js

@@ -550,13 +550,9 @@ /**

function lookUpwardForInlineStyle(content, fromKey) {
var previousBlock = content.getBlockBefore(fromKey);
var previousLength;
var lastNonEmpty = content.getBlockMap().reverse().skipUntil(function (_, k) {
return k === fromKey;
}).skip(1).skipUntil(function (block, _) {
return block.getLength();
}).first();
while (previousBlock) {
previousLength = previousBlock.getLength();
if (previousLength) {
return previousBlock.getInlineStyleAt(previousLength - 1);
}
previousBlock = content.getBlockBefore(previousBlock.getKey());
}
if (lastNonEmpty) return lastNonEmpty.getInlineStyleAt(lastNonEmpty.getLength() - 1);
return OrderedSet();

@@ -563,0 +559,0 @@ }

@@ -276,5 +276,5 @@ /**

/**
* When a collapsed cursor is at the start of an empty styled block,
* changes block to 'unstyled'. Returns null if block or selection does not
* meet that criteria.
* When a collapsed cursor is at the start of the first styled block, or
* an empty styled block, changes block to 'unstyled'. Returns null if
* block or selection does not meet that criteria.
*/

@@ -288,3 +288,5 @@ tryToRemoveBlockStyle: function tryToRemoveBlockStyle(editorState) {

var block = content.getBlockForKey(key);
if (block.getLength() > 0) {
var firstBlock = content.getFirstBlock();
if (block.getLength() > 0 && block !== firstBlock) {
return null;

@@ -291,0 +293,0 @@ }

{
"name": "draft-js",
"description": "A React framework for building text editors.",
"version": "0.10.3",
"version": "0.10.4",
"keywords": [

@@ -20,2 +20,3 @@ "draftjs",

"main": "lib/Draft.js",
"style": "dist/Draft.css",
"repository": "facebook/draft-js",

@@ -34,3 +35,2 @@ "license": "BSD-3-Clause",

"dependencies": {
"enzyme": "^2.9.1",
"fbjs": "^0.8.15",

@@ -41,4 +41,4 @@ "immutable": "~3.7.4",

"peerDependencies": {
"react": "^0.14.0 || ^15.0.0-rc || ^16.0.0-rc",
"react-dom": "^0.14.0 || ^15.0.0-rc || ^16.0.0-rc"
"react": "^0.14.0 || ^15.0.0-rc || ^16.0.0-rc || ^16.0.0",
"react-dom": "^0.14.0 || ^15.0.0-rc || ^16.0.0-rc || ^16.0.0"
},

@@ -51,2 +51,3 @@ "devDependencies": {

"envify": "^3.4.0",
"enzyme": "^2.9.1",
"es6-shim": "^0.34.4",

@@ -53,0 +54,0 @@ "eslint": "^4.2.0",

Sorry, the diff of this file is not supported yet

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

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

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

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