Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

saved_snippet: Prepopulate new saved snippet content.

opmkumaree70cd8af31f
diff --git a/web/src/saved_snippets_ui.ts b/web/src/saved_snippets_ui.ts
index 57845f706ff..6d89255846c 100644
--- a/web/src/saved_snippets_ui.ts
+++ b/web/src/saved_snippets_ui.ts
@@ -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",
diff --git a/web/templates/add_saved_snippet_modal.hbs b/web/templates/add_saved_snippet_modal.hbs
index 75e73ef0b50..a5936c6f5f1 100644
--- a/web/templates/add_saved_snippet_modal.hbs
+++ b/web/templates/add_saved_snippet_modal.hbs
@@ -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>