Fixes for empty document
This commit is contained in:
@ -51,7 +51,7 @@ type KeyData = {
|
|||||||
onImageUploadStop: props.onImageUploadStop,
|
onImageUploadStop: props.onImageUploadStop,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (props.text) {
|
if (props.text.trim().length) {
|
||||||
this.state = { state: Markdown.deserialize(props.text) };
|
this.state = { state: Markdown.deserialize(props.text) };
|
||||||
} else {
|
} else {
|
||||||
this.state = { state: Plain.deserialize('') };
|
this.state = { state: Plain.deserialize('') };
|
||||||
|
@ -14,6 +14,11 @@ async function present(ctx: Object, document: Document, options: ?Options) {
|
|||||||
...options,
|
...options,
|
||||||
};
|
};
|
||||||
ctx.cache.set(document.id, document);
|
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 = {
|
const data = {
|
||||||
id: document.id,
|
id: document.id,
|
||||||
url: document.getUrl(),
|
url: document.getUrl(),
|
||||||
|
Reference in New Issue
Block a user