Remove slate-plain-serializer dependency

This commit is contained in:
Tom Moor 2017-12-08 19:13:35 -08:00
parent 7b9fa9f4a7
commit d7d13179d6
3 changed files with 4 additions and 8 deletions

View File

@ -5,7 +5,6 @@ import { observer } from 'mobx-react';
import { Value, Change } from 'slate';
import { Editor } from 'slate-react';
import type { SlateNodeProps, Plugin } from './types';
import Plain from 'slate-plain-serializer';
import keydown from 'react-keydown';
import getDataTransferFiles from 'utils/getDataTransferFiles';
import Flex from 'shared/components/Flex';
@ -52,11 +51,7 @@ class MarkdownEditor extends Component {
onImageUploadStop: props.onImageUploadStop,
});
if (props.text.trim().length) {
this.editorValue = Markdown.deserialize(props.text);
} else {
this.editorValue = Plain.deserialize('');
}
this.editorValue = Markdown.deserialize(props.text);
}
componentDidMount() {
@ -77,6 +72,7 @@ class MarkdownEditor extends Component {
onChange = (change: Change) => {
if (this.editorValue !== change.value) {
this.props.onChange(Markdown.serialize(change.value));
console.log('this.props.onChange', Markdown.serialize(change.value));
this.editorValue = change.value;
}
};

View File

@ -28,7 +28,8 @@ class FormattingToolbar extends Component {
};
isBlock = (type: string) => {
return this.props.editor.value.startBlock.type === type;
const startBlock = this.props.editor.value.startBlock;
return startBlock && startBlock.type === type;
};
/**

View File

@ -167,7 +167,6 @@
"slate-edit-list": "^0.10.1",
"slate-md-serializer": "^1.0.4",
"slate-paste-linkify": "^0.5.0",
"slate-plain-serializer": "^0.4.12",
"slate-prism": "^0.4.0",
"slate-react": "^0.10.19",
"slate-trailing-block": "^0.4.0",