Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8f4a5ee
Add property "blockList" to ContentBlock
SamyPesse May 10, 2016
9a091c1
Fixing commoner providesModule definition
mitermayer May 13, 2016
526dc55
Removed unused variables from model/immutable/ContentBlock.js
SamyPesse May 13, 2016
6709a41
Adding nestEnabled option
mitermayer May 17, 2016
d05d67f
Add support for nested blocks in convertFromDraftToRaw
SamyPesse May 17, 2016
171cf43
WIP for enabling pasting and html conversion
mitermayer May 18, 2016
83d6ec6
Add "keyBinding" to NestedUtils
SamyPesse May 19, 2016
4c5c3bd
Fixing pasting bugs, builds and updating demo
mitermayer May 20, 2016
98cdb51
Start documenting nesting
SamyPesse May 23, 2016
cd5233c
Updating blocks nesting support
mitermayer May 24, 2016
e984bab
Don't create nested block when nestingEnabled is set to false in bloc…
SamyPesse May 24, 2016
574be64
Fixing the nestedUtils command handler
mitermayer May 25, 2016
e486815
Fix order when importing RawContent and add tests
SamyPesse May 27, 2016
7c81b0c
Fixing range selection for nested elements
mitermayer May 31, 2016
014eaf7
Expose "genNestedKey"
SamyPesse May 31, 2016
3072c80
Refactoring
mitermayer Jun 7, 2016
49bc12c
NestedTextEditorUtil should not handle the basic split-block
SamyPesse Jun 14, 2016
5f97ad5
Removing tests for normal split block for NestedTextEditorUtil
mitermayer Jun 14, 2016
8c8abda
Internal tech review amends
mitermayer Jun 15, 2016
b952567
Nesting pasting bugs
mitermayer Jun 15, 2016
4f73295
Using immutable blockMap instead of an array
mitermayer Jun 16, 2016
9073a7f
Performance improvements
mitermayer Jun 17, 2016
ab30436
Improving rendering performance algorithm for nested trees
mitermayer Jun 18, 2016
c6fd4a2
Fix convertFromRawToDraftState generating random keys for child block…
SamyPesse Jun 18, 2016
150adb8
Reducing iterations on the blockMap
mitermayer Jun 19, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/APIReference-Modifier.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ title: Modifier
layout: docs
category: API Reference
permalink: docs/api-reference-modifier.html
next: experimental-nesting
---

The `Modifier` module is a static set of utility functions that encapsulate common
Expand Down
81 changes: 81 additions & 0 deletions docs/Experimental-Nesting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
id: experimental-nesting
title: Nesting
layout: docs
category: Experimental
next: api-reference-data-conversion
permalink: docs/experimental-nesting.html
---

## Overview

By default Draft.js doesn't support nested blocks, but it can be enabled using some component props.

### Usage

```js
import {Editor, EditorState, NestedUtils} from 'draft-js';

class MyEditor extends React.Component {
constructor(props) {
super(props);
this.state = {editorState: EditorState.createEmpty()};
this.onChange = (editorState) => this.setState({editorState});
this.handleKeyCommand = this.handleKeyCommand.bind(this);
}
handleKeyCommand(command) {
const newState = NestedUtils.handleKeyCommand(this.state.editorState, command);
if (newState) {
this.onChange(newState);
return true;
}
return false;
}
render() {
return (
<Editor
editorState={this.state.editorState}
blockRenderMap={NestedUtils.DefaultBlockRenderMap}
keyBindingFn={NestedUtils.keyBinding}
handleKeyCommand={this.handleKeyCommand}
onChange={this.onChange}
/>
);
}
}
```

### Commands

`NestedUtils` provides two methods: `NestedUtils.keyBinding` and `NestedUtils.handleKeyCommand` to respond to user interactions with the right behavior for nested content.

### Data Conversion

`convertFromRaw` and `convertToRaw` supports nested blocks:

```js
import {convertFromRaw} from 'draft-js';

var contentState = convertFromRaw({
blocks: [
{
type: 'heading-one',
text: 'My Awesome Article'
},
{
type: 'blockquote',
blocks: [
{
type: 'heading-two',
text: 'Another heading in a blockquote'
},
{
type: 'unstyled',
text: 'Followed by a paragraph.'
}
]
}
],
entityMap: {}
});
```
85 changes: 85 additions & 0 deletions examples/tree/tree.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
.RichEditor-root {
background: #fff;
border: 1px solid #ddd;
font-family: 'Georgia', serif;
font-size: 14px;
padding: 15px;
}

.RichEditor-editor {
border-top: 1px solid #ddd;
cursor: text;
font-size: 16px;
margin-top: 10px;
}

.RichEditor-editor .public-DraftEditorPlaceholder-root,
.RichEditor-editor .public-DraftEditor-content {
margin: 0 -15px -15px;
padding: 15px;
}

.RichEditor-editor .public-DraftEditor-content {
min-height: 100px;
}

.RichEditor-hidePlaceholder .public-DraftEditorPlaceholder-root {
display: none;
}

.RichEditor-editor .RichEditor-blockquote {
border-left: 5px solid #eee;
color: #666;
font-family: 'Hoefler Text', 'Georgia', serif;
font-style: italic;
margin: 16px 0;
padding: 10px 20px;
}

.RichEditor-editor .public-DraftStyleDefault-pre {
background-color: rgba(0, 0, 0, 0.05);
font-family: 'Inconsolata', 'Menlo', 'Consolas', monospace;
font-size: 16px;
padding: 20px;
}

.RichEditor-controls {
font-family: 'Helvetica', sans-serif;
font-size: 14px;
margin-bottom: 5px;
user-select: none;
}

.RichEditor-styleButton {
color: #999;
cursor: pointer;
margin-right: 16px;
padding: 2px 0;
display: inline-block;
}

.RichEditor-activeButton {
color: #5890ff;
}

.RichEditor-editor table {
border: 1px solid #ccc;
display: block;
}

.RichEditor-editor tr {
padding: 0;
margin: 0;
}

.RichEditor-editor td {
border: 1px solid black;
}

#target {
width: 600px;
}

.public-DraftStyleDefault-block {
padding-left: 20px;
}
Loading