aboutsummaryrefslogtreecommitdiff
path: root/web_src
diff options
context:
space:
mode:
authorwxiaoguang2023-02-28 07:13:52 +0800
committerGitHub2023-02-27 17:13:52 -0600
commit8b86ccbee189b578b6ebe1b18be0283b49168c7c (patch)
treee7135eff6e57453aa4512504ac375732050fed98 /web_src
parent725a97c6c9d2576797b7d15a687146941fba3a02 (diff)
Change button text for commenting and closing an issue at the same time (#23135)
Close #10468 Without SimpleMDE/EasyMDE, using Simple Textarea, the button text could be changed when content changes. After introducing SimpleMDE/EasyMDE, there is no code for updating the button text.
Diffstat (limited to 'web_src')
-rw-r--r--web_src/js/features/comp/EasyMDE.js3
-rw-r--r--web_src/js/features/repo-legacy.js8
2 files changed, 10 insertions, 1 deletions
diff --git a/web_src/js/features/comp/EasyMDE.js b/web_src/js/features/comp/EasyMDE.js
index 182e6b429..a030db83a 100644
--- a/web_src/js/features/comp/EasyMDE.js
+++ b/web_src/js/features/comp/EasyMDE.js
@@ -77,6 +77,9 @@ export async function createCommentEasyMDE(textarea, easyMDEOptions = {}) {
const inputField = easyMDE.codemirror.getInputField();
+ easyMDE.codemirror.on('change', (...args) => {
+ easyMDEOptions?.onChange(...args);
+ });
easyMDE.codemirror.setOption('extraKeys', {
'Cmd-Enter': codeMirrorQuickSubmit,
'Ctrl-Enter': codeMirrorQuickSubmit,
diff --git a/web_src/js/features/repo-legacy.js b/web_src/js/features/repo-legacy.js
index a9229c0d1..118475e32 100644
--- a/web_src/js/features/repo-legacy.js
+++ b/web_src/js/features/repo-legacy.js
@@ -85,12 +85,18 @@ export function initRepoCommentForm() {
}
(async () => {
+ const $statusButton = $('#status-button');
for (const textarea of $commentForm.find('textarea:not(.review-textarea, .no-easymde)')) {
// Don't initialize EasyMDE for the dormant #edit-content-form
if (textarea.closest('#edit-content-form')) {
continue;
}
- const easyMDE = await createCommentEasyMDE(textarea);
+ const easyMDE = await createCommentEasyMDE(textarea, {
+ 'onChange': () => {
+ const value = easyMDE?.value().trim();
+ $statusButton.text($statusButton.attr(value.length === 0 ? 'data-status' : 'data-status-and-comment'));
+ },
+ });
initEasyMDEImagePaste(easyMDE, $commentForm.find('.dropzone'));
}
})();