migrate Text.createFromString to Text.create

This commit is contained in:
Shawn Erquhart 2017-09-28 17:23:34 -04:00
parent 39f65476c3
commit 70e8eae599
4 changed files with 5 additions and 5 deletions

View File

@ -16,7 +16,7 @@ import styles from './index.css';
export default class Editor extends Component { export default class Editor extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
const emptyText = Text.createFromString(''); const emptyText = Text.create('');
const emptyBlock = Block.create({ kind: 'block', type: 'paragraph', nodes: [ emptyText ] }); const emptyBlock = Block.create({ kind: 'block', type: 'paragraph', nodes: [ emptyText ] });
const emptyRawDoc = { nodes: [emptyBlock] }; const emptyRawDoc = { nodes: [emptyBlock] };
const rawDoc = this.props.value && markdownToSlate(this.props.value); const rawDoc = this.props.value && markdownToSlate(this.props.value);
@ -133,7 +133,7 @@ export default class Editor extends Component {
shortcode: plugin.id, shortcode: plugin.id,
shortcodeData, shortcodeData,
}; };
const nodes = [Text.createFromString('')]; const nodes = [Text.create('')];
const block = { kind: 'block', type: 'shortcode', data, isVoid: true, nodes }; const block = { kind: 'block', type: 'shortcode', data, isVoid: true, nodes };
let change = editorState.change(); let change = editorState.change();
const { focusBlock } = change.state; const { focusBlock } = change.state;

View File

@ -6,7 +6,7 @@ function onKeyDown(e, data, change) {
const createDefaultBlock = () => { const createDefaultBlock = () => {
return Block.create({ return Block.create({
type: 'paragraph', type: 'paragraph',
nodes: [Text.createFromString('')] nodes: [Text.create('')]
}); });
}; };
if (data.key === 'enter') { if (data.key === 'enter') {

View File

@ -19,7 +19,7 @@ const SoftBreak = (options = {}) => ({
return trimmed.insertBlock(defaultBlock); return trimmed.insertBlock(defaultBlock);
} }
const textNode = Text.createFromString('\n'); const textNode = Text.create('\n');
const breakNode = Inline.create({ type: 'break', nodes: [ textNode ] }); const breakNode = Inline.create({ type: 'break', nodes: [ textNode ] });
return change return change
.insertInline(breakNode) .insertInline(breakNode)

View File

@ -18,7 +18,7 @@ const enforceNeverEmpty = {
normalize: change => { normalize: change => {
const block = Block.create({ const block = Block.create({
type: 'paragraph', type: 'paragraph',
nodes: [Text.createFromString('')], nodes: [Text.create('')],
}); });
const { key } = change.state.document; const { key } = change.state.document;
return change.insertNodeByKey(key, 0, block).focus(); return change.insertNodeByKey(key, 0, block).focus();