Comparing version 0.10.3 to 0.10.4
@@ -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 @@ |
@@ -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. |
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1336058
5
20755
35
- Removedenzyme@^2.9.1
- Removedboolbase@1.0.0(transitive)
- Removedcall-bind@1.0.8(transitive)
- Removedcall-bind-apply-helpers@1.0.1(transitive)
- Removedcall-bound@1.0.3(transitive)
- Removedcheerio@0.22.0(transitive)
- Removedcreate-react-class@15.7.0(transitive)
- Removedcss-select@1.2.0(transitive)
- Removedcss-what@2.1.3(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removeddom-serializer@0.1.1(transitive)
- Removeddomelementtype@1.3.1(transitive)
- Removeddomhandler@2.4.2(transitive)
- Removeddomutils@1.5.1(transitive)
- Removeddunder-proto@1.0.1(transitive)
- Removedentities@1.1.2(transitive)
- Removedenzyme@2.9.1(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.0.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedfunction.prototype.name@1.1.8(transitive)
- Removedfunctions-have-names@1.2.3(transitive)
- Removedget-intrinsic@1.2.6(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhtmlparser2@3.10.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-callable@1.2.7(transitive)
- Removedis-subset@0.1.1(transitive)
- Removedlodash@4.17.21(transitive)
- Removedlodash.assignin@4.2.0(transitive)
- Removedlodash.bind@4.2.1(transitive)
- Removedlodash.defaults@4.2.0(transitive)
- Removedlodash.filter@4.6.0(transitive)
- Removedlodash.flatten@4.4.0(transitive)
- Removedlodash.foreach@4.5.0(transitive)
- Removedlodash.map@4.6.0(transitive)
- Removedlodash.merge@4.6.2(transitive)
- Removedlodash.pick@4.4.0(transitive)
- Removedlodash.reduce@4.6.0(transitive)
- Removedlodash.reject@4.6.0(transitive)
- Removedlodash.some@4.6.0(transitive)
- Removedmath-intrinsics@1.1.0(transitive)
- Removednth-check@1.0.2(transitive)
- Removedobject-is@1.1.6(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedobject.assign@4.1.7(transitive)
- Removedobject.entries@1.1.8(transitive)
- Removedobject.values@1.2.1(transitive)
- Removedreact@15.7.0(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removeduuid@3.4.0(transitive)