Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
noiron committed Jul 21, 2019
1 parent adcdd9f commit 65576c1
Show file tree
Hide file tree
Showing 3 changed files with 2,474 additions and 2,593 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -14,7 +14,7 @@ yarn start

- [Draft Editor 在线预览](http://www.wukai.me/draft-editor/)

## 待实现功能
## 实现功能

- 文本加粗
- 插入图片
Expand Down
2 changes: 2 additions & 0 deletions src/MyEditor.js
Expand Up @@ -111,9 +111,11 @@ class MyEditor extends React.PureComponent {
focusOffset: block.getLength(),
});

// 重写 entity 数据,将其从 block 中移除,防止这个 entity 还被其它的 block 引用
const contentStateWithoutEntity = Modifier.applyEntity(contentState, selectionOfAtomicBlock, null);
const editorStateWithoutEntity = EditorState.push(editorState, contentStateWithoutEntity, 'apply-entity');

// 移除 block
const contentStateWithoutBlock = Modifier.removeRange(contentStateWithoutEntity, selectionOfAtomicBlock, 'backward');
const newEditorState = EditorState.push(editorStateWithoutEntity, contentStateWithoutBlock, 'remove-range',);

Expand Down

0 comments on commit 65576c1

Please sign in to comment.