Fixed Cmd+P shortcut not toggling preview in new publish flow

no issue

- removed "cmd+p" shortcut from the main editor element
- added "cmd+p" shortcut to `<PublishManagement>`
  - toggles the preview modal on/off
  - closes the publish modal if it's open when switching to the preview modal so we don't end up with both modals open simultaneously
- fixed "Preview" button not showing up for contributors
  - this still uses the old preview modal for now
  - contributor preview/save should be handled inside the new publish flow later on
This commit is contained in:
Kevin Ansfield 2022-05-16 09:39:28 +01:00
parent 3a11faf0b6
commit de2d3977ed
4 changed files with 28 additions and 10 deletions

View File

@ -1164,3 +1164,5 @@ remove|ember-template-lint|no-action|96|43|96|43|659c404406f04b8153690817989630a
remove|ember-template-lint|no-passed-in-event-handlers|95|32|95|32|50acf938ca8cb3c5633b20e7050d7750211b12f4|1652054400000|1662422400000|1665014400000|app/templates/settings/general.hbs
add|ember-template-lint|require-input-label|48|12|48|12|16e2b28dce448cbd2dd1cdc10211c43a7d0ca021|1652400000000|1662768000000|1667955600000|app/components/editor-labs/modals/preview/email.hbs
remove|ember-template-lint|require-input-label|19|8|19|8|aefef8f18b7648ad42353400a95bf5d4ccc426bc|1652227200000|1662595200000|1667782800000|app/components/editor-labs/modals/preview/email.hbs
remove|ember-template-lint|no-action|2|48|2|48|74d234e67cc2c695fd41431692bb2974c2feddcf|1652054400000|1662422400000|1665014400000|app/templates/editor.hbs
remove|ember-template-lint|no-action|35|108|35|108|374dcf5faec6721e81711cb589f7966ab6063a14|1652054400000|1662422400000|1665014400000|app/templates/editor.hbs

View File

@ -1,5 +1,5 @@
{{#if @post.isDraft}}
<div>
<div {{on-key "cmd+p" this.togglePreview}}>
<button type="button" class="gh-btn gh-editor-preview-trigger" {{on "click" this.openPreview}}>
<span>Preview</span>
</button>

View File

@ -98,6 +98,22 @@ export default class PublishManagement extends Component {
}
}
// triggered by ctrl/cmd+p
@action
togglePreview(event) {
event?.preventDefault();
if (!this.previewModal || this.previewModal.isClosing) {
if (this.publishFlowModal && !this.publishFlowModal.isClosing) {
this.togglePreviewPublish();
} else {
this.openPreview();
}
} else {
this.previewModal.close();
}
}
@action
changePreviewTab(tab) {
this.previewTab = tab;

View File

@ -1,5 +1,5 @@
{{#if this.post}}
<div class="flex flex-row" {{on-key "cmd+p" (action "openPostPreview")}}>
<div class="flex flex-row">
<GhEditor
@tagName="section"
@class="gh-editor gh-view relative"
@ -28,15 +28,15 @@
<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}}
{{#if this.post.isDraft}}
<div {{on-key "cmd+p" this.openPostPreview}}>
<button type="button" class="gh-btn gh-editor-preview-trigger" {{on "click" this.openPostPreviewModal}}>
<span>Preview</span>
</button>
</div>
{{/if}}
<GhTaskButton @buttonText="Save"
@task={{this.save}}
@runningText="Saving"