From bfd4fafaec79641053d24591073e835825371654 Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Tue, 20 Feb 2024 12:44:15 -0300 Subject: [PATCH] FIX: Caption was broken with multiple subsequent calls (#481) --- .../editor-preview/ai-image-caption-container.gjs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/assets/javascripts/discourse/connectors/editor-preview/ai-image-caption-container.gjs b/assets/javascripts/discourse/connectors/editor-preview/ai-image-caption-container.gjs index 9d14061a..33f120eb 100644 --- a/assets/javascripts/discourse/connectors/editor-preview/ai-image-caption-container.gjs +++ b/assets/javascripts/discourse/connectors/editor-preview/ai-image-caption-container.gjs @@ -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 { - + />