Ghost/ghost/admin/app/templates/editor.hbs

173 lines
7.6 KiB
Handlebars
Raw Normal View History

{{#if this.post}}
<div class="flex flex-row" {{on-key "cmd+p" (action "openPostPreview")}}>
<GhEditor
@tagName="section"
@class="gh-editor gh-view relative"
as |editor|
>
<header class="gh-editor-header br2 pe-none">
<div class="flex items-center pe-auto h-100">
{{#if this.ui.isFullScreen}}
<LinkTo @route={{pluralize this.post.displayName }} class="gh-editor-back-button" data-test-link={{pluralize this.post.displayName}}>
<span>
{{svg-jar "arrow-left"}}
{{capitalize (pluralize this.post.displayName)}}
</span>
</LinkTo>
{{/if}}
<div class="gh-editor-post-status">
<span>
<GhEditorPostStatus
@post={{this.post}}
@hasDirtyAttributes={{this.hasDirtyAttributes}}
@isSaving={{or this.autosaveTask.isRunning this.saveTasks.isRunning}}
/>
</span>
</div>
</div>
<section class="flex" style="pointer-events: auto">
{{#unless this.post.isNew}}
{{#if (and this.post.isDraft (not (feature "publishingFlow")))}}
<div>
<button type="button" class="gh-btn gh-editor-preview-trigger" {{on "click" (action "openPostPreviewModal")}}>
<span>Preview</span>
</button>
</div>
{{/if}}
{{#if this.session.user.isContributor}}
<GhTaskButton @buttonText="Save"
@task={{this.save}}
@runningText="Saving"
@class="gh-btn gh-btn-icon gh-btn-editor contributor-save-button"
data-test-contributor-save />
{{else}}
{{#if (feature "publishingFlow")}}
Added first iteration of saving to new publish flow refs https://github.com/TryGhost/Team/issues/1542 - extracted before/after save routines in the editor controller into separate actions - allows saving to occur in the publish flow without it needing any editor-specific knowledge - allows for easier cleanup of email related logic from the editor save tasks later on - added `saveTask` to `PublishOptions` - applies the selected options to the post model where they correspond to model attributes and keeps the previous values in memory so the changes can be undone on failure - this keeps the local model state in sync because if a publish fails we want the editor to continue showing the draft state, non-scheduled publish time, and not have an unexpected email-only state - saves the post model directly passing `adapterOptions` so the save request query params match the chosen publish options - added a `saveTask` to the `<PublishManagement>` component - passed through to the `publish-flow` modal and is triggered by the confirm button on the confirmation screen - runs the before/afterSave arguments passed in from the editor - runs the `saveTask` on `PublishOptions` which handles everything needed to change status and send emails - polls the post after saving to wait for the attached email to switch to submitted/failed which lets us show a failure message and retry button as required (message + retry not yet implemented) - adds "complete" state to publish flow once save has finished - confirms what just happened based on saved post data rather than chosen publish options - has a link to the view the post
2022-05-04 12:30:37 +03:00
<EditorLabs::PublishManagement
@post={{this.post}}
@hasUnsavedChanges={{this.hasDirtyAttributes}}
@beforePublish={{perform this.beforeSaveTask}}
@afterPublish={{this.afterSave}}
@saveTask={{this.saveTask}}
Added first iteration of saving to new publish flow refs https://github.com/TryGhost/Team/issues/1542 - extracted before/after save routines in the editor controller into separate actions - allows saving to occur in the publish flow without it needing any editor-specific knowledge - allows for easier cleanup of email related logic from the editor save tasks later on - added `saveTask` to `PublishOptions` - applies the selected options to the post model where they correspond to model attributes and keeps the previous values in memory so the changes can be undone on failure - this keeps the local model state in sync because if a publish fails we want the editor to continue showing the draft state, non-scheduled publish time, and not have an unexpected email-only state - saves the post model directly passing `adapterOptions` so the save request query params match the chosen publish options - added a `saveTask` to the `<PublishManagement>` component - passed through to the `publish-flow` modal and is triggered by the confirm button on the confirmation screen - runs the before/afterSave arguments passed in from the editor - runs the `saveTask` on `PublishOptions` which handles everything needed to change status and send emails - polls the post after saving to wait for the attached email to switch to submitted/failed which lets us show a failure message and retry button as required (message + retry not yet implemented) - adds "complete" state to publish flow once save has finished - confirms what just happened based on saved post data rather than chosen publish options - has a link to the view the post
2022-05-04 12:30:37 +03:00
/>
{{else}}
<GhPublishmenu
@post={{this.post}}
@postStatus={{this.post.status}}
@saveTask={{this.saveTask}}
@setSaveType={{action "setSaveType"}}
@onOpen={{action "cancelAutosave"}} />
{{/if}}
{{/if}}
{{#unless this.showSettingsMenu}}
<div class="settings-menu-toggle-spacer"></div>
{{/unless}}
{{/unless}}
</section>
</header>
{{!--
gh-koenig-editor acts as a wrapper around the title input and
koenig editor canvas to support Ghost-specific editor behaviour
--}}
<GhKoenigEditor
@title={{readonly this.post.titleScratch}}
@titleAutofocus={{this.shouldFocusTitle}}
@titlePlaceholder={{concat (capitalize this.post.displayName) " title"}}
@onTitleChange={{action "updateTitleScratch"}}
@onTitleBlur={{action (perform this.saveTitleTask)}}
@body={{readonly this.post.scratch}}
@bodyPlaceholder={{concat "Begin writing your " this.post.displayName "..."}}
@onBodyChange={{action "updateScratch"}}
@headerOffset={{editor.headerHeight}}
@scrollContainerSelector=".gh-koenig-editor"
@scrollOffsetBottomSelector=".gh-mobile-nav-bar"
@onEditorCreated={{action "setKoenigEditor"}}
@onWordCountChange={{action "updateWordCount"}}
@snippets={{this.snippets}}
@saveSnippet={{if this.canManageSnippets this.saveSnippet}}
@updateSnippet={{if this.canManageSnippets this.toggleUpdateSnippetModal}}
@deleteSnippet={{if this.canManageSnippets this.toggleDeleteSnippetModal}}
@featureImage={{this.post.featureImage}}
@featureImageAlt={{this.post.featureImageAlt}}
@featureImageCaption={{this.post.featureImageCaption}}
@setFeatureImage={{action "setFeatureImage"}}
@setFeatureImageAlt={{action "setFeatureImageAlt"}}
@setFeatureImageCaption={{action "setFeatureImageCaption"}}
@clearFeatureImage={{action "clearFeatureImage"}}
@cardOptions={{hash
post=this.post
}}
@postType={{this.post.displayName}}
/>
<div class="gh-editor-wordcount-container">
<div class="gh-editor-wordcount">
{{gh-pluralize this.wordCount.wordCount "word"}}
</div>
<a href="https://ghost.org/help/using-the-editor/" class="flex" target="_blank" rel="noopener noreferrer">{{svg-jar "help"}}</a>
</div>
</GhEditor>
{{#if this.showSettingsMenu}}
<GhPostSettingsMenu
@post={{this.post}}
@deletePost={{action "openDeletePostModal"}}
@updateSlugTask={{this.updateSlugTask}}
@savePostTask={{this.savePostTask}}
/>
{{/if}}
</div>
<button type="button" class="settings-menu-toggle gh-btn gh-btn-editor gh-btn-icon icon-only gh-btn-action-icon" title="Settings" {{on "click" this.toggleSettingsMenu}} data-test-psm-trigger>
{{#if this.showSettingsMenu}}
<span class="settings-menu-open">{{svg-jar "sidemenu-open"}}</span>
{{else}}
<span>{{svg-jar "sidemenu"}}</span>
{{/if}}
</button>
{{#if this.showReAuthenticateModal}}
<GhFullscreenModal @modal="re-authenticate"
@close={{action "toggleReAuthenticateModal"}}
@modifier="action wide" />
{{/if}}
{{#if this.showUpgradeModal}}
<GhFullscreenModal
@modal="upgrade-host-limit"
@model={{hash
message=this.hostLimitError.context
details=this.hostLimitError.details
}}
@close={{action "closeUpgradeModal"}}
@modifier="action wide"
/>
{{/if}}
{{#if this.snippetToUpdate}}
<GhFullscreenModal
@modal="update-snippet"
@model={{this.snippetToUpdate}}
@confirm={{this.updateSnippet}}
@close={{this.toggleUpdateSnippetModal}}
@modifier="action wide"
/>
{{/if}}
{{#if this.snippetToDelete}}
<GhFullscreenModal
@modal="delete-snippet"
@model={{this.snippetToDelete}}
@confirm={{this.deleteSnippet}}
@close={{this.toggleDeleteSnippetModal}}
@modifier="action wide"
/>
{{/if}}
{{/if}}
{{outlet}}