A platform for community discussion. Free, open, simple.
UX: Composer redesign (#41781)
chapoia7bcfad6bb85
diff --git a/app/assets/stylesheets/common/base/compose.scss b/app/assets/stylesheets/common/base/compose.scssindex 509ea8fe53b..db76f79a901 100644--- a/app/assets/stylesheets/common/base/compose.scss+++ b/app/assets/stylesheets/common/base/compose.scss@@ -1249,3 +1249,287 @@ body.has-sidebar-page {display: none;}}++.uc-enable-composer-redesign {+ .composer-actions-trigger {+ background: var(--secondary);+ }++ #reply-control {+ // the redesigned grippie is taller than the height the default layout+ // reserves for it, so size the reply area with flex instead+ .grippie ~ .reply-area {+ flex: 1 1 auto;+ height: auto;+ min-height: 0;+ }+ }++ .grippie {+ padding-block: var(--space-1);+ border-top-left-radius: var(--d-border-radius-large);+ border-top-right-radius: var(--d-border-radius-large);+ background: var(--primary-very-low);+ }++ .reply-to {+ padding: var(--space-2) var(--space-4);+ margin: 0 !important;+ border-bottom: 1px solid var(--primary-low);+ }++ .reply-area {+ padding: 0 !important;+ }++ .composer-controls {+ .btn {+ font-size: var(--font-down-1-rem);+ }+ }++ .title-and-category {+ padding: 0 !important;+ width: 100% !important;+ gap: 0 !important;+ border-bottom: 1px solid var(--primary-low);+ }++ .category-input,+ .users-input {+ border-right: 1px solid var(--primary-low);++ @include viewport.until(sm) {+ flex-grow: 1;+ }+ }++ .tags-input {+ @include viewport.until(sm) {+ flex-grow: 0 !important;+ }++ @include viewport.until(sm) {+ .select-kit {+ .formatted-selection {+ display: none !important;+ }+ }+ }++ .select-kit-header-wrapper {+ gap: var(--space-1);++ .formatted-selection {+ color: var(--primary-medium);+ }++ .d-icon-plus {+ @include viewport.until(sm) {+ display: none;+ }+ }++ .d-icon-tag {+ color: var(--primary-low-mid) !important;+ }+ }++ .has-selection {+ .select-kit-header-wrapper {+ .formatted-selection {+ color: var(--primary-high);+ }++ .d-icon-tag {+ color: var(--tertiary) !important;+ }+ }+ }+ }++ .category-input,+ .tags-input,+ .users-input {+ margin: 0 !important;+ max-width: unset !important;+ width: 50% !important;+ box-sizing: border-box;++ @include viewport.until(sm) {+ width: auto !important;+ }++ .select-kit.combo-box .select-kit-header,+ .select-kit.multi-select .multi-select-header {+ border: 0;+ padding: var(--space-3) var(--space-4);++ .d-icon {+ font-size: var(--font-down-1-rem);+ color: var(--primary-medium);+ }+ }+ }++ .title-input {+ #reply-title {+ border: 0;+ padding: var(--space-4);+ font-size: var(--font-up-3);+ margin-bottom: 0 !important;++ &::placeholder {+ color: var(--primary-medium);+ }++ @include viewport.until(sm) {+ font-size: var(--font-up-2);+ }++ &:focus {+ outline: 0;+ }+ }+ }++ .d-editor-textarea-wrapper {+ border: 0;+ transition: margin 250ms cubic-bezier(0.05, 0.7, 0.1, 1);++ @media (prefers-reduced-motion: reduce) {+ transition: none;+ }++ &:focus,+ &.in-focus {+ outline: none;+ border: 0;++ @include viewport.until(sm) {+ margin-top: calc(+ (+ var(--composer-fields-height, 0px) ++ (var(--header-offset, 0px) / 3)+ ) *+ -1+ );+ z-index: z("composer", "dropdown") + 1;+ box-shadow: 0 -12px 12px 0 rgb(var(--primary-rgb), 0.15);+ border-top-left-radius: var(--d-border-radius-large);+ border-top-right-radius: var(--d-border-radius-large);+ padding-top: var(--space-4);+ }+ }+ }++ .d-editor-input {+ padding-inline: var(--space-4);+ padding-top: 0 !important;+ }++ .wmd-controls:not(.toolbar-visible)+ ~ .composer-footer+ .d-editor-button-bar__wrap {+ display: none;+ }++ // clean up selector once the uc- body class is no longer in the way+ .show-preview .d-editor-container.--markdown-editor-enabled {+ .d-editor-textarea-column {+ border-right: 1px solid var(--primary-low);+ }++ .d-editor-preview-wrapper {+ margin-top: var(--space-2);+ }+ }++ .composer-footer {+ display: flex;+ align-items: center;+ flex-wrap: nowrap;+ gap: var(--space-2);++ @include viewport.from(sm) {+ padding: var(--space-2) var(--space-4);+ border-top: 1px solid var(--primary-low);+ }++ @include viewport.until(sm) {+ flex-direction: column;+ }++ &__toolbar {+ overflow: hidden;+ flex-grow: 1;++ @include viewport.until(sm) {+ width: 100%;+ padding-inline: var(--space-2);+ box-sizing: border-box;+ border-top: 1px solid var(--primary-low);+ border-bottom: 1px solid var(--primary-low);+ }+ }++ .submit-panel {+ margin: 0 !important;++ @include viewport.until(sm) {+ width: 100%;+ padding-inline: var(--space-2);+ box-sizing: border-box;++ .save-or-cancel {+ display: inline-flex !important;+ margin-left: auto;+ flex: unset !important;+ margin-right: 0 !important;+ }++ #draft-status {+ margin-left: 0 !important;+ }+ }+ }++ .d-editor-button-bar__wrap {+ @include viewport.until(sm) {+ margin: 0;+ }+ }++ .d-editor-button-bar {+ @include viewport.until(sm) {+ padding-inline: var(--space-2);+ }++ &__scroll-btn {+ color: var(--primary-medium);+ font-size: var(--font-down-1-rem);+ }++ .btn,+ .composer-toggle-switch__left-icon,+ .composer-toggle-switch__right-icon {+ font-size: var(--font-down-1-rem);+ }+ }++ .composer-toggle-switch {+ margin-left: 0;+ }+ }++ @include viewport.until(sm) {+ .reply-area {+ background: var(--secondary);+ padding: 0 0 max(env(safe-area-inset-bottom), var(--space-2)) !important;+ }++ .reply-to {+ padding: var(--space-3);+ }+ }+}diff --git a/app/assets/stylesheets/common/d-editor.scss b/app/assets/stylesheets/common/d-editor.scssindex 4e4f0038e4f..9c009e34d11 100644--- a/app/assets/stylesheets/common/d-editor.scss+++ b/app/assets/stylesheets/common/d-editor.scss@@ -405,6 +405,13 @@-ms-overflow-style: none;max-width: 100%;+ // the toolbar can be rendered outside .d-editor-textarea-wrapper, so the+ // disabled state is carried on the bar itself+ &.--disabled {+ opacity: 0.5;+ pointer-events: none;+ }+&::-webkit-scrollbar {display: none;}diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex da32ae1b00d..70fddf76673 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -3475,6 +3475,7 @@ en:users_placeholder: "Add users or groups"title_placeholder: "What is this discussion about in one brief sentence?"+ title_placeholder_redesign: "Title"title_or_link_placeholder: "Type title, or paste a link here"edit_reason_placeholder: "Why are you editing?"topic_featured_link_placeholder: "Enter link shown with title."@@ -5185,7 +5186,7 @@ en:category:none: "(no category)"all: "All categories"- choose: "category…"+ choose: "Category…"edit: "Edit"edit_title: "Edit this category"edit_dialog_title: "Edit: %{categoryName}"@@ -5918,7 +5919,7 @@ en:selector_no_tags: "no tags"selector_remove_filter: "remove filter"tags: "Tags"- choose_for_topic: "optional tags"+ choose_for_topic: "Optional tags…"choose_for_topic_required:one: "select at least %{count} tag…"other: "select at least %{count} tags…"diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex c5f6c179b17..f90a7efd4b2 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -2904,6 +2904,7 @@ en:enable_auto_grid_images: "Automatically wraps images in [grid] tags when 3 or more images are uploaded in the composer."enable_new_checkbox_style: "Enable the redesigned checkbox style for FormKit checkboxes."enable_new_post_reactions_menu: "Enable the redesigned post likes and reactions menu, with infinite scroll and a native mobile experience."+ enable_composer_redesign: "Enable the redesigned composer."enable_new_composer_actions: "Enable the redesigned composer actions menu and combo save button, with whisper, no-bump, and unlist toggles surfaced next to the save action."prioritize_recently_used_tags: "When adding tags while creating or editing a topic, show the tags the member has recently used on their own topics at the top of the list, before the most popular tags of the forum."experimental_impersonation_time_limit_minutes: "How long before an impersonation session is automatically ended."diff --git a/config/site_settings.yml b/config/site_settings.ymlindex a48cd05febf..df4332d5867 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -4548,6 +4548,16 @@ experimental:status: "stable"impact: "feature,all_members"learn_more_url: "https://meta.discourse.org/t/-/389820"+ enable_composer_redesign:+ default: false+ client: true+ hidden: true+ area: "experimental"+ upcoming_change:+ status: "conceptual"+ impact: "other,all_members"+ body_class: true+ learn_more_url: "https://meta.discourse.org/t/-/407849"enable_new_composer_actions:default: falseclient: truediff --git a/frontend/discourse/app/components/composer-container.gjs b/frontend/discourse/app/components/composer-container.gjsindex 1ee1e51adc1..f6c40b241cb 100644--- a/frontend/discourse/app/components/composer-container.gjs+++ b/frontend/discourse/app/components/composer-container.gjs@@ -1,11 +1,14 @@import Component from "@glimmer/component";+import { tracked } from "@glimmer/tracking";import { Input } from "@ember/component";import { fn, hash } from "@ember/helper";import { on } from "@ember/modifier";import { action } from "@ember/object";+import didInsert from "@ember/render-modifiers/modifiers/did-insert";import { cancel } from "@ember/runloop";import { service } from "@ember/service";import { trustHTML } from "@ember/template";+import { modifier } from "ember-modifier";import ComposerActionTitle from "discourse/components/composer-action-title";import ComposerBody from "discourse/components/composer-body";import ComposerEditor from "discourse/components/composer-editor";@@ -36,6 +39,54 @@ import dIcon from "discourse/ui-kit/helpers/d-icon";import dLoadingSpinner from "discourse/ui-kit/helpers/d-loading-spinner";import { i18n } from "discourse-i18n";+const trackFieldsHeight = modifier((element, [enabled]) => {+ if (!enabled) {+ return;+ }++ const target = document.getElementById("reply-control");+ if (!target) {+ return;+ }++ const update = (height) => {+ target.style.setProperty(+ "--composer-fields-height",+ `${Math.round(height)}px`+ );+ };++ update(element.offsetHeight);++ const observer = new ResizeObserver(([entry]) => {+ update(entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height);+ });+ observer.observe(element);++ return () => {+ observer.disconnect();+ target.style.removeProperty("--composer-fields-height");+ };+});++const PmUserSelector = <template>+ <div class="user-selector">+ <ComposerUserSelector+ @topicId={{@topicId}}+ @recipients={{@model.targetRecipients}}+ @hasGroups={{@model.hasTargetGroups}}+ @focusTarget={{@focusTarget}}+ class={{dConcatClass "users-input" (if @showWarning "can-warn")}}+ />+ {{#if @showWarning}}+ <label class="add-warning">+ <Input @type="checkbox" @checked={{@model.isWarning}} />+ <span>{{i18n "composer.add_warning"}}</span>+ </label>+ {{/if}}+ </div>+</template>;+export default class ComposerContainer extends Component {@service composer;@service languageNameLookup;@@ -44,11 +95,22 @@ export default class ComposerContainer extends Component {@service appEvents;@service keyValueStore;+ @tracked toolbarPortalTarget;+willDestroy() {super.willDestroy(...arguments);cancel(this.composerResizeDebounceHandler);}+ get composerRedesign() {+ return this.siteSettings.enable_composer_redesign;+ }++ @action+ setToolbarPortalTarget(element) {+ this.toolbarPortalTarget = element;+ }+get availableContentLocalizationLocales() {const originalPostLocale = this.composer.model?.post?.locale;@@ -317,47 +379,50 @@ export default class ComposerContainer extends Component {/></div>- <ComposerEditor>- <div class="composer-fields">+ <ComposerEditor @toolbarPortalTarget={{this.toolbarPortalTarget}}>+ <div+ class="composer-fields"+ {{trackFieldsHeight this.composerRedesign}}+ ><PluginOutlet@name="before-composer-fields"@outletArgs={{lazyHash model=this.composer.model}}/>{{#unless this.composer.model.viewFullscreen}}{{#if this.composer.model.canEditTitle}}- {{#if this.composer.model.creatingPrivateMessage}}- <div class="user-selector">- <ComposerUserSelector+ {{#unless this.composerRedesign}}+ {{#if this.composer.model.creatingPrivateMessage}}+ <PmUserSelector@topicId={{this.composer.topicModel.id}}- @recipients={{this.composer.model.targetRecipients}}- @hasGroups={{this.composer.model.hasTargetGroups}}+ @model={{this.composer.model}}@focusTarget={{this.composer.focusTarget}}- class={{dConcatClass- "users-input"- (if this.composer.showWarning "can-warn")- }}+ @showWarning={{this.composer.showWarning}}/>- {{#if this.composer.showWarning}}- <label class="add-warning">- <Input- @type="checkbox"- @checked={{this.composer.model.isWarning}}- />- <span>{{i18n "composer.add_warning"}}</span>- </label>- {{/if}}- </div>- {{/if}}+ {{/if}}+ {{/unless}}<divclass="title-and-category{{if this.composer.isPreviewVisible 'with-preview'}}">- <ComposerTitle- @composer={{this.composer.model}}- @lastValidatedAt={{this.composer.lastValidatedAt}}- @focusTarget={{this.composer.focusTarget}}- />+ {{#if this.composerRedesign}}+ {{#if this.composer.model.creatingPrivateMessage}}+ <PmUserSelector+ @topicId={{this.composer.topicModel.id}}+ @model={{this.composer.model}}+ @focusTarget={{this.composer.focusTarget}}+ @showWarning={{this.composer.showWarning}}+ />+ {{/if}}+ {{/if}}++ {{#unless this.composerRedesign}}+ <ComposerTitle+ @composer={{this.composer.model}}+ @lastValidatedAt={{this.composer.lastValidatedAt}}+ @focusTarget={{this.composer.focusTarget}}+ />+ {{/unless}}{{#if this.composer.model.showCategoryChooser}}<div class="category-input">@@ -392,6 +457,7 @@ export default class ComposerContainer extends Component {disabled=this.composer.disableTagsChoosercategoryId=this.composer.model.categoryIdminimum=this.composer.model.minimumRequiredTags+ icon=(if this.composerRedesign "tag")prioritizeRecentTags=true}}/>@@ -417,6 +483,14 @@ export default class ComposerContainer extends Component {}}/></div>++ {{#if this.composerRedesign}}+ <ComposerTitle+ @composer={{this.composer.model}}+ @lastValidatedAt={{this.composer.lastValidatedAt}}+ @focusTarget={{this.composer.focusTarget}}+ />+ {{/if}}{{/if}}<span>@@ -440,154 +514,299 @@ export default class ComposerContainer extends Component {/></span>- <div class="submit-panel">- <span>- <PluginOutlet- @name="composer-fields-below"- @connectorTagName="div"- @outletArgs={{lazyHash model=this.composer.model}}- />- </span>-- <div class="save-or-cancel">- <ComposerSaveButton- @action={{this.composer.saveAction}}- @icon={{this.composer.saveIcon}}- @label={{this.composer.saveLabel}}- @forwardEvent={{true}}- @disableSubmit={{this.composer.disableSubmit}}- />+ {{#if this.composerRedesign}}+ <div class="composer-footer">+ <div+ class="composer-footer__toolbar"+ {{didInsert this.setToolbarPortalTarget}}+ ></div>- {{#unless this.site.mobileView}}- <DButton- @action={{this.composer.cancel}}- class="discard-button btn-transparent"- @title={{this.composer.cancelLabel}}- @label={{this.composer.cancelLabel}}- />- {{/unless}}+ <div class="submit-panel">+ <span>+ <PluginOutlet+ @name="composer-fields-below"+ @connectorTagName="div"+ @outletArgs={{lazyHash model=this.composer.model}}+ />+ </span>- {{#if this.site.mobileView}}- <DButton- @action={{this.composer.cancel}}- @icon={{this.composer.cancelIcon}}- class="discard-button btn-transparent"- @title={{this.composer.cancelLabel}}- />- {{/if}}+ {{#if this.site.mobileView}}+ {{#if this.composer.model.noBump}}+ <span class="no-bump">{{dIcon "anchor"}}</span>+ {{/if}}+ {{/if}}++ {{#if this.composer.model.draftStatus}}+ <div+ class={{if this.composer.isUploading "hidden"}}+ id="draft-status"+ >+ <span+ class="draft-error"+ title={{this.composer.model.draftStatus}}+ >+ {{#if this.composer.model.draftConflictUser}}+ {{dAvatar+ this.composer.model.draftConflictUser+ imageSize="small"+ }}+ {{dIcon "user-pen"}}+ {{else}}+ {{dIcon "triangle-exclamation"}}+ {{/if}}+ {{#if this.site.desktopView}}+ {{this.composer.model.draftStatus}}+ {{/if}}+ </span>+ </div>+ {{/if}}++ {{#if+ (or+ this.composer.isUploading this.composer.isProcessingUpload+ )+ }}+ <div id="file-uploading">+ {{#if this.composer.isProcessingUpload}}+ {{dLoadingSpinner size="small"}}<span>{{i18n+ "upload_selector.processing"+ }}</span>+ {{else}}+ {{dLoadingSpinner size="small"}}<span>{{i18n+ "upload_selector.uploading"+ }}+ {{this.composer.uploadProgress}}%</span>+ {{/if}}++ {{#if this.composer.isCancellable}}+ <a+ href+ id="cancel-file-upload"+ {{on "click" this.composer.cancelUpload}}+ >{{dIcon "xmark"}}</a>+ {{/if}}+ </div>+ {{/if}}++ <div class="save-or-cancel">++ <DButton+ @action={{this.composer.cancel}}+ class="discard-button btn-transparent"+ @title={{this.composer.cancelLabel}}+ @label={{this.composer.cancelLabel}}+ />++ <ComposerSaveButton+ @action={{this.composer.saveAction}}+ @label={{this.composer.saveLabel}}+ @forwardEvent={{true}}+ @disableSubmit={{this.composer.disableSubmit}}+ />++ <PluginOutlet+ @name="composer-after-save-or-cancel"+ @outletArgs={{lazyHash model=this.composer.model}}+ />++ </div>+ {{#if this.site.mobileView}}+ <span>+ <PluginOutlet+ @name="composer-mobile-buttons-bottom"+ @outletArgs={{lazyHash model=this.composer.model}}+ />+ </span>++ {{#if this.composer.allowPreview}}+ <a+ href+ class="btn btn-default no-text mobile-preview"+ title={{i18n "composer.show_preview"}}+ {{on "click" this.composer.togglePreview}}+ aria-label={{i18n "composer.show_preview"}}+ >+ {{dIcon "desktop"}}+ </a>+ {{/if}}++ {{#if this.composer.isPreviewVisible}}+ <DButton+ @action={{this.composer.togglePreview}}+ @title="composer.hide_preview"+ @ariaLabel="composer.hide_preview"+ @icon="pencil"+ class="hide-preview"+ />+ {{/if}}+ {{/if}}++ {{#if (and this.composer.allowPreview this.site.desktopView)}}+ <DButton+ @action={{this.composer.togglePreview}}+ @translatedTitle={{this.composer.toggleText}}+ @icon="angles-left"+ class={{dConcatClass+ "btn-transparent btn-mini-toggle toggle-preview"+ (unless this.composer.isPreviewVisible "active")+ }}+ />+ {{/if}}+ </div>+ </div>+ {{else}}+ <div class="submit-panel"><span><PluginOutlet- @name="composer-after-save-or-cancel"+ @name="composer-fields-below"+ @connectorTagName="div"@outletArgs={{lazyHash model=this.composer.model}}/></span>- </div>- {{#if this.site.mobileView}}- <span>- <PluginOutlet- @name="composer-mobile-buttons-bottom"- @outletArgs={{lazyHash model=this.composer.model}}+ <div class="save-or-cancel">+ <ComposerSaveButton+ @action={{this.composer.saveAction}}+ @icon={{this.composer.saveIcon}}+ @label={{this.composer.saveLabel}}+ @forwardEvent={{true}}+ @disableSubmit={{this.composer.disableSubmit}}/>- </span>- {{#if this.composer.allowUpload}}- <a- id="mobile-file-upload"- class="btn btn-default no-text mobile-file-upload- {{if this.composer.isUploading 'hidden'}}"- aria-label={{i18n "composer.upload_title"}}- >- {{dIcon this.composer.uploadIcon}}- </a>- {{/if}}+ {{#unless this.site.mobileView}}+ <DButton+ @action={{this.composer.cancel}}+ class="discard-button btn-transparent"+ @title={{this.composer.cancelLabel}}+ @label={{this.composer.cancelLabel}}+ />+ {{/unless}}++ {{#if this.site.mobileView}}+ <DButton+ @action={{this.composer.cancel}}+ @icon={{this.composer.cancelIcon}}+ class="discard-button btn-transparent"+ @title={{this.composer.cancelLabel}}+ />+ {{/if}}- {{#if this.composer.allowPreview}}- <a- href- class="btn btn-default no-text mobile-preview"- title={{i18n "composer.show_preview"}}- {{on "click" this.composer.togglePreview}}- aria-label={{i18n "composer.show_preview"}}- >- {{dIcon "desktop"}}- </a>- {{/if}}+ <span>+ <PluginOutlet+ @name="composer-after-save-or-cancel"+ @outletArgs={{lazyHash model=this.composer.model}}+ />+ </span>+ </div>- {{#if this.composer.isPreviewVisible}}- <DButton- @action={{this.composer.togglePreview}}- @title="composer.hide_preview"- @ariaLabel="composer.hide_preview"- @icon="pencil"- class="hide-preview"- />- {{/if}}- {{/if}}+ {{#if this.site.mobileView}}+ <span>+ <PluginOutlet+ @name="composer-mobile-buttons-bottom"+ @outletArgs={{lazyHash model=this.composer.model}}+ />+ </span>- {{#if- (or this.composer.isUploading this.composer.isProcessingUpload)- }}- <div id="file-uploading">- {{#if this.composer.isProcessingUpload}}- {{dLoadingSpinner size="small"}}<span>{{i18n- "upload_selector.processing"- }}</span>- {{else}}- {{dLoadingSpinner size="small"}}<span>{{i18n- "upload_selector.uploading"- }}- {{this.composer.uploadProgress}}%</span>+ {{#if this.composer.allowUpload}}+ <a+ id="mobile-file-upload"+ class="btn btn-default no-text mobile-file-upload+ {{if this.composer.isUploading 'hidden'}}"+ aria-label={{i18n "composer.upload_title"}}+ >+ {{dIcon this.composer.uploadIcon}}+ </a>{{/if}}- {{#if this.composer.isCancellable}}+ {{#if this.composer.allowPreview}}<ahref- id="cancel-file-upload"- {{on "click" this.composer.cancelUpload}}- >{{dIcon "xmark"}}</a>+ class="btn btn-default no-text mobile-preview"+ title={{i18n "composer.show_preview"}}+ {{on "click" this.composer.togglePreview}}+ aria-label={{i18n "composer.show_preview"}}+ >+ {{dIcon "desktop"}}+ </a>{{/if}}- </div>- {{/if}}- {{#if this.composer.model.draftStatus}}- <div- class={{if this.composer.isUploading "hidden"}}- id="draft-status"- >- <span- class="draft-error"- title={{this.composer.model.draftStatus}}- >- {{#if this.composer.model.draftConflictUser}}- {{dAvatar- this.composer.model.draftConflictUser- imageSize="small"- }}- {{dIcon "user-pen"}}+ {{#if this.composer.isPreviewVisible}}+ <DButton+ @action={{this.composer.togglePreview}}+ @title="composer.hide_preview"+ @ariaLabel="composer.hide_preview"+ @icon="pencil"+ class="hide-preview"+ />+ {{/if}}+ {{/if}}++ {{#if+ (or+ this.composer.isUploading this.composer.isProcessingUpload+ )+ }}+ <div id="file-uploading">+ {{#if this.composer.isProcessingUpload}}+ {{dLoadingSpinner size="small"}}<span>{{i18n+ "upload_selector.processing"+ }}</span>{{else}}- {{dIcon "triangle-exclamation"}}+ {{dLoadingSpinner size="small"}}<span>{{i18n+ "upload_selector.uploading"+ }}+ {{this.composer.uploadProgress}}%</span>{{/if}}- {{#if this.site.desktopView}}- {{this.composer.model.draftStatus}}++ {{#if this.composer.isCancellable}}+ <a+ href+ id="cancel-file-upload"+ {{on "click" this.composer.cancelUpload}}+ >{{dIcon "xmark"}}</a>{{/if}}- </span>- </div>- {{/if}}-- {{#if (and this.composer.allowPreview this.site.desktopView)}}- <DButton- @action={{this.composer.togglePreview}}- @translatedTitle={{this.composer.toggleText}}- @icon="angles-left"- class={{dConcatClass- "btn-transparent btn-small toggle-preview"- (unless this.composer.isPreviewVisible "active")- }}- />- {{/if}}- </div>+ </div>+ {{/if}}++ {{#if this.composer.model.draftStatus}}+ <div+ class={{if this.composer.isUploading "hidden"}}+ id="draft-status"+ >+ <span+ class="draft-error"+ title={{this.composer.model.draftStatus}}+ >+ {{#if this.composer.model.draftConflictUser}}+ {{dAvatar+ this.composer.model.draftConflictUser+ imageSize="small"+ }}+ {{dIcon "user-pen"}}+ {{else}}+ {{dIcon "triangle-exclamation"}}+ {{/if}}+ {{#if this.site.desktopView}}+ {{this.composer.model.draftStatus}}+ {{/if}}+ </span>+ </div>+ {{/if}}++ {{#if (and this.composer.allowPreview this.site.desktopView)}}+ <DButton+ @action={{this.composer.togglePreview}}+ @translatedTitle={{this.composer.toggleText}}+ @icon="angles-left"+ class={{dConcatClass+ "btn-transparent btn-small toggle-preview"+ (unless this.composer.isPreviewVisible "active")+ }}+ />+ {{/if}}+ </div>+ {{/if}}</div>{{else}}<div class="saving-text">diff --git a/frontend/discourse/app/components/composer-editor.gjs b/frontend/discourse/app/components/composer-editor.gjsindex 880eff9dcf8..683a20efc59 100644--- a/frontend/discourse/app/components/composer-editor.gjs+++ b/frontend/discourse/app/components/composer-editor.gjs@@ -802,10 +802,12 @@ export default class ComposerEditor extends Component {@actionextraButtons(toolbar) {+ const composerRedesign = this.siteSettings.enable_composer_redesign;+if (this.composer.allowUpload &&this.composer.uploadIcon &&- this.site.desktopView+ (composerRedesign || this.site.desktopView)) {toolbar.addButton({id: "upload",@@ -819,7 +821,7 @@ export default class ComposerEditor extends Component {toolbar.addButton({id: "options",group: "extras",- icon: "circle-plus",+ icon: composerRedesign ? "discourse-circle-plus" : "circle-plus",title: "composer.options",sendAction: this.onExpandPopupMenuOptions.bind(this),popupMenu: {@@ -1000,6 +1002,7 @@ export default class ComposerEditor extends Component {@replyingToUserId={{this.composer.replyingToUserId}}@onSetup={{this.setupEditor}}@disableSubmit={{this.composer.disableSubmit}}+ @toolbarPortalTarget={{this.toolbarPortalTarget}}{{didInsert this._composerEditorInitEditor}}{{willDestroy this._composerEditorDestroyEditor}}{{didInsert this._composerEditorInitPreview}}diff --git a/frontend/discourse/app/components/composer-toggles.gjs b/frontend/discourse/app/components/composer-toggles.gjsindex 1eee0b52597..5921a67404f 100644--- a/frontend/discourse/app/components/composer-toggles.gjs+++ b/frontend/discourse/app/components/composer-toggles.gjs@@ -47,11 +47,15 @@ export default class ComposerToggles extends Component {return !this.args.disableTextarea;}+ get showToolbarToggle() {+ return this.site.mobileView;+ }+<template><div class={{dConcatClass "composer-controls" this.additionalClasses}}><PluginOutlet @name="before-composer-toggles" @connectorTagName="div" />- {{#if this.site.mobileView}}+ {{#if this.showToolbarToggle}}<DButton@icon="bars"@action={{@toggleToolbar}}diff --git a/frontend/discourse/app/models/composer.js b/frontend/discourse/app/models/composer.jsindex 99a531eadc6..58e7dce855c 100644--- a/frontend/discourse/app/models/composer.js+++ b/frontend/discourse/app/models/composer.js@@ -534,8 +534,13 @@ export default class Composer extends RestModel {if (custom) {return custom;}- return this.canEditTopicFeaturedLink- ? "composer.title_or_link_placeholder"++ if (this.canEditTopicFeaturedLink) {+ return "composer.title_or_link_placeholder";+ }++ return this.siteSettings.enable_composer_redesign+ ? "composer.title_placeholder_redesign": "composer.title_placeholder";}diff --git a/frontend/discourse/app/ui-kit/d-editor.gjs b/frontend/discourse/app/ui-kit/d-editor.gjsindex f26e8be70ac..0af9238bca1 100644--- a/frontend/discourse/app/ui-kit/d-editor.gjs+++ b/frontend/discourse/app/ui-kit/d-editor.gjs@@ -43,6 +43,7 @@ import {import { PLATFORM_KEY_MODIFIER } from "discourse/services/keyboard-shortcuts";import { not } from "discourse/truth-helpers";import DButton from "discourse/ui-kit/d-button";+import DConditionalInElement from "discourse/ui-kit/d-conditional-in-element";import DConditionalLoadingSpinner from "discourse/ui-kit/d-conditional-loading-spinner";import DPopupInputTip from "discourse/ui-kit/d-popup-input-tip";import dConcatClass from "discourse/ui-kit/helpers/d-concat-class";@@ -787,41 +788,51 @@ export default class DEditor extends Component {{{if this.disabled 'disabled'}}{{if this.isEditorFocused 'in-focus'}}">-- {{#if this.replacedToolbarInstance}}- <ToolbarScrollContainer @class="--replaced-toolbar">- <DButton- @action={{this.resetToolbar}}- @icon="angle-left"- @preventFocus={{true}}- @onKeyDown={{this.rovingButtonBar}}- class="d-editor-button-bar__back"- />- <ToolbarButtons- @data={{this.replacedToolbarInstance}}- @rovingButtonBar={{this.rovingButtonBar}}- @isFirst={{false}}- />- </ToolbarScrollContainer>- {{else}}- <ToolbarScrollContainer>- {{#if this.showEditorModeToggle}}- <ToggleSwitch+ <DConditionalInElement+ @inline={{not @toolbarPortalTarget}}+ @element={{@toolbarPortalTarget}}+ @append={{true}}+ >+ {{#if this.replacedToolbarInstance}}+ <ToolbarScrollContainer+ @class={{dConcatClass+ "--replaced-toolbar"+ (if this.disabled "--disabled")+ }}+ >+ <DButton+ @action={{this.resetToolbar}}+ @icon="angle-left"@preventFocus={{true}}- @disabled={{@disableSubmit}}- @state={{this.isRichEditorEnabled}}- {{on "click" this.toggleRichEditor}}- {{on "keydown" this.rovingButtonBar}}+ @onKeyDown={{this.rovingButtonBar}}+ class="d-editor-button-bar__back"+ />+ <ToolbarButtons+ @data={{this.replacedToolbarInstance}}+ @rovingButtonBar={{this.rovingButtonBar}}+ @isFirst={{false}}+ />+ </ToolbarScrollContainer>+ {{else}}+ <ToolbarScrollContainer @class={{if this.disabled "--disabled"}}>+ {{#if this.showEditorModeToggle}}+ <ToggleSwitch+ @preventFocus={{true}}+ @disabled={{@disableSubmit}}+ @state={{this.isRichEditorEnabled}}+ {{on "click" this.toggleRichEditor}}+ {{on "keydown" this.rovingButtonBar}}+ />+ {{/if}}++ <ToolbarButtons+ @data={{this.toolbar}}+ @rovingButtonBar={{this.rovingButtonBar}}+ @isFirst={{not this.siteSettings.rich_editor}}/>- {{/if}}-- <ToolbarButtons- @data={{this.toolbar}}- @rovingButtonBar={{this.rovingButtonBar}}- @isFirst={{not this.siteSettings.rich_editor}}- />- </ToolbarScrollContainer>- {{/if}}+ </ToolbarScrollContainer>+ {{/if}}+ </DConditionalInElement><DConditionalLoadingSpinner @condition={{this.loading}} /><this.editorComponentdiff --git a/frontend/discourse/tests/acceptance/composer-test.js b/frontend/discourse/tests/acceptance/composer-test.jsindex bcea32ed0cd..f224d4ccb50 100644--- a/frontend/discourse/tests/acceptance/composer-test.js+++ b/frontend/discourse/tests/acceptance/composer-test.js@@ -1463,7 +1463,7 @@ acceptance(`Composer - default category not set`, function (needs) {assert.strictEqual(selectKit(".category-chooser").header().value(), null);assert.strictEqual(selectKit(".category-chooser").header().name(),- "category…"+ i18n("category.choose"));});});diff --git a/frontend/discourse/tests/acceptance/topic-edit-timer-test.js b/frontend/discourse/tests/acceptance/topic-edit-timer-test.jsindex a9d03a13497..9137b08d81b 100644--- a/frontend/discourse/tests/acceptance/topic-edit-timer-test.js+++ b/frontend/discourse/tests/acceptance/topic-edit-timer-test.js@@ -139,7 +139,10 @@ acceptance("Topic - Edit timer", function (needs) {await select(".timer-type", "publish_to_category");const categoryChooser = selectKit(".d-modal__body .category-chooser");- assert.strictEqual(categoryChooser.header().label(), "category…");+ assert.strictEqual(+ categoryChooser.header().label(),+ i18n("category.choose").replace("…", "…")+ );assert.strictEqual(categoryChooser.header().value(), null);await categoryChooser.expand();@@ -171,7 +174,10 @@ acceptance("Topic - Edit timer", function (needs) {await select(".timer-type", "publish_to_category");const categoryChooser = selectKit(".d-modal__body .category-chooser");- assert.strictEqual(categoryChooser.header().label(), "category…");+ assert.strictEqual(+ categoryChooser.header().label(),+ i18n("category.choose").replace("…", "…")+ );assert.strictEqual(categoryChooser.header().value(), null);await categoryChooser.expand();@@ -208,7 +214,10 @@ acceptance("Topic - Edit timer", function (needs) {await select(".timer-type", "publish_to_category");const categoryChooser = selectKit(".d-modal__body .category-chooser");- assert.strictEqual(categoryChooser.header().label(), "category…");+ assert.strictEqual(+ categoryChooser.header().label(),+ i18n("category.choose").replace("…", "…")+ );assert.strictEqual(categoryChooser.header().value(), null);await categoryChooser.expand();diff --git a/frontend/discourse/tests/integration/components/select-kit/category-chooser-test.gjs b/frontend/discourse/tests/integration/components/select-kit/category-chooser-test.gjsindex a5d4bde5ce9..1f0c7886e68 100644--- a/frontend/discourse/tests/integration/components/select-kit/category-chooser-test.gjs+++ b/frontend/discourse/tests/integration/components/select-kit/category-chooser-test.gjs@@ -5,7 +5,7 @@ import { module, test } from "qunit";import CategoryChooser from "discourse/select-kit/components/category-chooser";import { setupRenderingTest } from "discourse/tests/helpers/component-test";import selectKit from "discourse/tests/helpers/select-kit-helper";-import I18n from "discourse-i18n";+import I18n, { i18n } from "discourse-i18n";module("Integration | Component | SelectKit | CategoryChooser",@@ -122,7 +122,10 @@ module();assert.strictEqual(this.subject.header().value(), null);- assert.strictEqual(this.subject.header().label(), "category…");+ assert.strictEqual(+ this.subject.header().label(),+ i18n("category.choose").replace("…", "…")+ );});test("with allowUncategorized=null and defaultComposerCategory present", async function (assert) {@@ -156,7 +159,10 @@ module();assert.strictEqual(this.subject.header().value(), null);- assert.strictEqual(this.subject.header().label(), "category…");+ assert.strictEqual(+ this.subject.header().label(),+ i18n("category.choose").replace("…", "…")+ );});test("with allowUncategorized=null none=true", async function (assert) {diff --git a/plugins/discourse-ai/assets/stylesheets/modules/ai-helper/common/ai-helper.scss b/plugins/discourse-ai/assets/stylesheets/modules/ai-helper/common/ai-helper.scssindex 4ea9552bebf..addd077b276 100644--- a/plugins/discourse-ai/assets/stylesheets/modules/ai-helper/common/ai-helper.scss+++ b/plugins/discourse-ai/assets/stylesheets/modules/ai-helper/common/ai-helper.scss@@ -268,7 +268,7 @@border-radius: var(--d-input-border-radius); // to match surrounding inputpadding: 0.4em;font-size: var(--font-down-1-rem);- z-index: z("composer", "dropdown") + 1;+ z-index: z("composer", "dropdown");.d-icon {color: var(--tertiary);diff --git a/public/images/upcoming_changes/enable_composer_redesign.png b/public/images/upcoming_changes/enable_composer_redesign.pngnew file mode 100644index 00000000000..11b07b097fdBinary files /dev/null and b/public/images/upcoming_changes/enable_composer_redesign.png differdiff --git a/spec/system/composer/default_to_subcategory_spec.rb b/spec/system/composer/default_to_subcategory_spec.rbindex b8c88fd9e80..05ea591d200 100644--- a/spec/system/composer/default_to_subcategory_spec.rb+++ b/spec/system/composer/default_to_subcategory_spec.rb@@ -49,7 +49,7 @@ describe "Default to Subcategory when parent Category doesn't allow posting" doselect_kit =PageObjects::Components::SelectKit.new("#reply-control.open .category-chooser")- expect(select_kit).to have_selected_name("category…")+ expect(select_kit).to have_selected_name(I18n.t("js.category.choose"))endendend@@ -79,7 +79,7 @@ describe "Default to Subcategory when parent Category doesn't allow posting" docategory_page.new_topic_button.clickselect_kit =PageObjects::Components::SelectKit.new("#reply-control.open .category-chooser")- expect(select_kit).to have_selected_name("category…")+ expect(select_kit).to have_selected_name(I18n.t("js.category.choose"))endendend@@ -91,7 +91,7 @@ describe "Default to Subcategory when parent Category doesn't allow posting" doselect_kit =PageObjects::Components::SelectKit.new("#reply-control.open .category-chooser")- expect(select_kit).to have_selected_name("category…")+ expect(select_kit).to have_selected_name(I18n.t("js.category.choose"))endendend@@ -109,7 +109,7 @@ describe "Default to Subcategory when parent Category doesn't allow posting" dopage.find("#create-topic").clickselect_kit = PageObjects::Components::SelectKit.new("#reply-control.open .category-chooser")- expect(select_kit).to have_selected_name("category…")+ expect(select_kit).to have_selected_name(I18n.t("js.category.choose"))endendenddiff --git a/spec/system/composer/redesign_spec.rb b/spec/system/composer/redesign_spec.rbnew file mode 100644index 00000000000..e7e9adabbe4--- /dev/null+++ b/spec/system/composer/redesign_spec.rb@@ -0,0 +1,90 @@+# frozen_string_literal: true++describe "Composer redesign" do+ fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }+ fab!(:category)+ fab!(:topic) { Fabricate(:topic, category: category) }+ fab!(:first_post) { Fabricate(:post, topic: topic) }++ let(:composer) { PageObjects::Components::Composer.new }+ let(:topic_page) { PageObjects::Pages::Topic.new }++ before { sign_in(user) }++ context "when enable_composer_redesign is enabled" do+ before { SiteSetting.enable_composer_redesign = true }++ it "lets the user create a topic with the redesigned composer" do+ visit("/new-topic")++ expect(composer).to be_opened+ expect(composer).to have_footer_toolbar+ expect(composer).to have_title_below_category_row++ composer.fill_title("Topic from the redesigned composer")+ composer.fill_content("The content of the topic")+ composer.submit++ expect(topic_page).to have_topic_title("Topic from the redesigned composer")+ expect(topic_page).to have_post_content(post_number: 1, content: "The content of the topic")+ end++ it "lets the user reply to a topic with the redesigned composer" do+ topic_page.visit_topic(topic)+ topic_page.click_reply_button++ expect(composer).to be_opened+ expect(composer).to have_footer_toolbar++ composer.fill_content("A reply from the redesigned composer")+ composer.submit++ expect(topic_page).to have_post_content(+ post_number: 2,+ content: "A reply from the redesigned composer",+ )+ end++ it "shows the recipient selector in the top row when the user composes a personal message" do+ visit("/new-message")++ expect(composer).to be_opened+ expect(composer).to have_pm_recipients_in_category_row+ expect(composer).to have_title_below_category_row+ end++ it "keeps the toolbar visible in the footer on mobile", mobile: true do+ visit("/new-topic")++ expect(composer).to be_opened+ expect(composer).to have_footer_toolbar+ expect(composer).to have_toggle_toolbar_button+ end+ end++ context "when enable_composer_redesign is disabled" do+ before { SiteSetting.enable_composer_redesign = false }++ it "shows the user the legacy composer layout" do+ visit("/new-topic")++ expect(composer).to be_opened+ expect(composer).to have_inline_toolbar+ expect(composer).to have_no_footer_toolbar+ expect(composer).to have_title_in_category_row+ end++ it "lets the user hide and show the toolbar on mobile", mobile: true do+ visit("/new-topic")++ expect(composer).to be_opened+ expect(composer).to have_visible_toolbar++ composer.toggle_toolbar+ expect(composer).to have_no_visible_toolbar++ composer.toggle_toolbar+ expect(composer).to have_visible_toolbar+ end+ end+enddiff --git a/spec/system/page_objects/components/composer.rb b/spec/system/page_objects/components/composer.rbindex a31f5ac2952..87a10427c9b 100644--- a/spec/system/page_objects/components/composer.rb+++ b/spec/system/page_objects/components/composer.rb@@ -75,6 +75,51 @@ module PageObjectshas_field?("reply-title", with: value)end+ # Methods for when the enable_composer_redesign upcoming change is enabled.++ def has_footer_toolbar?+ page.has_css?("#{@composer_id} .composer-footer__toolbar .d-editor-button-bar")+ end++ def has_title_below_category_row?+ page.has_css?("#{@composer_id} .title-and-category + .title-input")+ end++ def has_pm_recipients_in_category_row?+ page.has_css?("#{@composer_id} .title-and-category .user-selector")+ end++ def has_toggle_toolbar_button?+ page.has_css?("#{@composer_id} .toggle-toolbar")+ end++ # Methods for when the enable_composer_redesign upcoming change is disabled.++ def has_no_footer_toolbar?+ page.has_no_css?("#{@composer_id} .composer-footer")+ end++ def has_inline_toolbar?+ page.has_css?("#{@composer_id} .d-editor-textarea-wrapper .d-editor-button-bar")+ end++ def has_title_in_category_row?+ page.has_css?("#{@composer_id} .title-and-category .title-input")+ end++ def toggle_toolbar+ find("#{@composer_id} .toggle-toolbar").click+ self+ end++ def has_visible_toolbar?+ page.has_css?("#{@composer_id} .d-editor-button-bar")+ end++ def has_no_visible_toolbar?+ page.has_no_css?("#{@composer_id} .d-editor-button-bar")+ end+def fill_content(content)find("#{@composer_id} .d-editor .d-editor-input").fill_in(with: content)self