FIX: Caption was broken with multiple subsequent calls (#481)
This commit is contained in:
parent
becbe01f68
commit
bfd4fafaec
|
@ -1,11 +1,11 @@
|
|||
import Component from "@glimmer/component";
|
||||
import { tracked } from "@glimmer/tracking";
|
||||
import { fn } from "@ember/helper";
|
||||
import { on } from "@ember/modifier";
|
||||
import { action } from "@ember/object";
|
||||
import { inject as service } from "@ember/service";
|
||||
import ConditionalLoadingSpinner from "discourse/components/conditional-loading-spinner";
|
||||
import DButton from "discourse/components/d-button";
|
||||
import DTextarea from "discourse/components/d-textarea";
|
||||
import autoFocus from "discourse/modifiers/auto-focus";
|
||||
import icon from "discourse-common/helpers/d-icon";
|
||||
import i18n from "discourse-common/helpers/i18n";
|
||||
|
@ -15,12 +15,11 @@ export default class AiImageCaptionContainer extends Component {
|
|||
@service imageCaptionPopup;
|
||||
@service appEvents;
|
||||
@service composer;
|
||||
@tracked newCaption = this.imageCaptionPopup.newCaption || "";
|
||||
|
||||
@action
|
||||
updateCaption(event) {
|
||||
event.preventDefault();
|
||||
this.newCaption = event.target.value;
|
||||
this.imageCaptionPopup.newCaption = event.target.value;
|
||||
}
|
||||
|
||||
@action
|
||||
|
@ -31,7 +30,7 @@ export default class AiImageCaptionContainer extends Component {
|
|||
const match = matchingPlaceholder[index];
|
||||
const replacement = match.replace(
|
||||
IMAGE_MARKDOWN_REGEX,
|
||||
`![${this.newCaption}|$2$3$4]($5)`
|
||||
`![${this.imageCaptionPopup.newCaption}|$2$3$4]($5)`
|
||||
);
|
||||
this.appEvents.trigger("composer:replace-text", match, replacement);
|
||||
this.imageCaptionPopup.showPopup = false;
|
||||
|
@ -50,10 +49,11 @@ export default class AiImageCaptionContainer extends Component {
|
|||
<ConditionalLoadingSpinner
|
||||
@condition={{this.imageCaptionPopup.loading}}
|
||||
>
|
||||
<textarea
|
||||
{{on "input" this.updateCaption}}
|
||||
<DTextarea
|
||||
@value={{this.imageCaptionPopup.newCaption}}
|
||||
{{on "change" this.updateCaption}}
|
||||
{{autoFocus}}
|
||||
>{{this.newCaption}}</textarea>
|
||||
/>
|
||||
</ConditionalLoadingSpinner>
|
||||
|
||||
<div class="actions">
|
||||
|
|
Loading…
Reference in New Issue