saved_snippet: Prepopulate new saved snippet content.

Fixes #31827.
This commit is contained in:
opmkumar 2024-10-02 21:04:43 +05:30 committed by Tim Abbott
parent 2807d7fbb8
commit ee70cd8af3
2 changed files with 7 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import render_add_saved_snippet_modal from "../templates/add_saved_snippet_modal
import render_confirm_delete_saved_snippet from "../templates/confirm_dialog/confirm_delete_saved_snippet.hbs";
import * as channel from "./channel";
import * as compose_state from "./compose_state";
import * as compose_ui from "./compose_ui";
import * as confirm_dialog from "./confirm_dialog";
import * as dialog_widget from "./dialog_widget";
@ -91,7 +92,9 @@ function item_click_callback(
if (current_value === saved_snippets.ADD_SAVED_SNIPPET_OPTION_ID) {
dialog_widget.launch({
html_heading: $t_html({defaultMessage: "Add a new saved snippet"}),
html_body: render_add_saved_snippet_modal(),
html_body: render_add_saved_snippet_modal({
prepopulated_content: compose_state.message_content(),
}),
html_submit_button: $t_html({defaultMessage: "Save"}),
id: "add-new-saved-snippet-modal",
form_id: "add-new-saved-snippet-form",

View File

@ -3,6 +3,8 @@
<label for="title" class="modal-field-label">{{t "Title" }}</label>
<input id="new-saved-snippet-title" type="text" name="title" class="modal_text_input saved-snippet-title" value="" autocomplete="off" spellcheck="false" autofocus="autofocus"/>
<div>{{t "Content" }}</div>
<textarea class="settings_textarea saved-snippet-content" rows="4"></textarea>
<textarea class="settings_textarea saved-snippet-content" rows="4">
{{~prepopulated_content~}}
</textarea>
</form>
</div>