Enable "Publish Preview" for Markdown
This commit is contained in:
parent
abeb7a852c
commit
3df7ea71d3
1 changed files with 11 additions and 5 deletions
|
@ -261,11 +261,13 @@ function PublishForm(props: Props) {
|
||||||
// @endif
|
// @endif
|
||||||
|
|
||||||
async function handlePublish() {
|
async function handlePublish() {
|
||||||
|
let outputFile = filePath;
|
||||||
|
let runPublish = false;
|
||||||
|
|
||||||
// Publish post:
|
// Publish post:
|
||||||
// If here is no file selected yet on desktop, show file dialog and let the
|
// If here is no file selected yet on desktop, show file dialog and let the
|
||||||
// user choose a file path. On web a new File is created
|
// user choose a file path. On web a new File is created
|
||||||
if (mode === PUBLISH_MODES.POST && !emptyPostError) {
|
if (mode === PUBLISH_MODES.POST && !emptyPostError) {
|
||||||
let outputFile = filePath;
|
|
||||||
// If user modified content on the text editor or editing name has changed:
|
// If user modified content on the text editor or editing name has changed:
|
||||||
// Save changes and update file path
|
// Save changes and update file path
|
||||||
if (fileEdited || nameEdited) {
|
if (fileEdited || nameEdited) {
|
||||||
|
@ -280,20 +282,24 @@ function PublishForm(props: Props) {
|
||||||
// New content stored locally and is not empty
|
// New content stored locally and is not empty
|
||||||
if (outputFile) {
|
if (outputFile) {
|
||||||
updatePublishForm({ filePath: outputFile });
|
updatePublishForm({ filePath: outputFile });
|
||||||
publish(outputFile);
|
runPublish = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Only metadata has changed.
|
// Only metadata has changed.
|
||||||
publish(outputFile);
|
runPublish = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Publish file
|
// Publish file
|
||||||
if (mode === PUBLISH_MODES.FILE) {
|
if (mode === PUBLISH_MODES.FILE) {
|
||||||
|
runPublish = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (runPublish) {
|
||||||
if (enablePublishPreview) {
|
if (enablePublishPreview) {
|
||||||
setPreviewing(true);
|
setPreviewing(true);
|
||||||
publish(filePath, true);
|
publish(outputFile, true);
|
||||||
} else {
|
} else {
|
||||||
publish(filePath, false);
|
publish(outputFile, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue