Fixes for empty document

This commit is contained in:
Jori Lallo 2017-10-22 22:20:53 -07:00
parent 4b6e8f5fb8
commit c6537279ba
2 changed files with 6 additions and 1 deletions

View File

@ -51,7 +51,7 @@ type KeyData = {
onImageUploadStop: props.onImageUploadStop,
});
if (props.text) {
if (props.text.trim().length) {
this.state = { state: Markdown.deserialize(props.text) };
} else {
this.state = { state: Plain.deserialize('') };

View File

@ -14,6 +14,11 @@ async function present(ctx: Object, document: Document, options: ?Options) {
...options,
};
ctx.cache.set(document.id, document);
// For empty document content, return the title
if (document.text.trim().length === 0)
document.text = `# ${document.title || 'Untitled document'}`;
const data = {
id: document.id,
url: document.getUrl(),