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 Component from "@glimmer/component";
|
||||||
import { tracked } from "@glimmer/tracking";
|
|
||||||
import { fn } from "@ember/helper";
|
import { fn } from "@ember/helper";
|
||||||
import { on } from "@ember/modifier";
|
import { on } from "@ember/modifier";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
import { inject as service } from "@ember/service";
|
import { inject as service } from "@ember/service";
|
||||||
import ConditionalLoadingSpinner from "discourse/components/conditional-loading-spinner";
|
import ConditionalLoadingSpinner from "discourse/components/conditional-loading-spinner";
|
||||||
import DButton from "discourse/components/d-button";
|
import DButton from "discourse/components/d-button";
|
||||||
|
import DTextarea from "discourse/components/d-textarea";
|
||||||
import autoFocus from "discourse/modifiers/auto-focus";
|
import autoFocus from "discourse/modifiers/auto-focus";
|
||||||
import icon from "discourse-common/helpers/d-icon";
|
import icon from "discourse-common/helpers/d-icon";
|
||||||
import i18n from "discourse-common/helpers/i18n";
|
import i18n from "discourse-common/helpers/i18n";
|
||||||
|
@ -15,12 +15,11 @@ export default class AiImageCaptionContainer extends Component {
|
||||||
@service imageCaptionPopup;
|
@service imageCaptionPopup;
|
||||||
@service appEvents;
|
@service appEvents;
|
||||||
@service composer;
|
@service composer;
|
||||||
@tracked newCaption = this.imageCaptionPopup.newCaption || "";
|
|
||||||
|
|
||||||
@action
|
@action
|
||||||
updateCaption(event) {
|
updateCaption(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.newCaption = event.target.value;
|
this.imageCaptionPopup.newCaption = event.target.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
@ -31,7 +30,7 @@ export default class AiImageCaptionContainer extends Component {
|
||||||
const match = matchingPlaceholder[index];
|
const match = matchingPlaceholder[index];
|
||||||
const replacement = match.replace(
|
const replacement = match.replace(
|
||||||
IMAGE_MARKDOWN_REGEX,
|
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.appEvents.trigger("composer:replace-text", match, replacement);
|
||||||
this.imageCaptionPopup.showPopup = false;
|
this.imageCaptionPopup.showPopup = false;
|
||||||
|
@ -50,10 +49,11 @@ export default class AiImageCaptionContainer extends Component {
|
||||||
<ConditionalLoadingSpinner
|
<ConditionalLoadingSpinner
|
||||||
@condition={{this.imageCaptionPopup.loading}}
|
@condition={{this.imageCaptionPopup.loading}}
|
||||||
>
|
>
|
||||||
<textarea
|
<DTextarea
|
||||||
{{on "input" this.updateCaption}}
|
@value={{this.imageCaptionPopup.newCaption}}
|
||||||
|
{{on "change" this.updateCaption}}
|
||||||
{{autoFocus}}
|
{{autoFocus}}
|
||||||
>{{this.newCaption}}</textarea>
|
/>
|
||||||
</ConditionalLoadingSpinner>
|
</ConditionalLoadingSpinner>
|
||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
|
|
Loading…
Reference in New Issue