@@ -3,7 +3,7 @@ import {handleReply} from './repo-issue.ts';
3
3
import { getComboMarkdownEditor , initComboMarkdownEditor , ComboMarkdownEditor } from './comp/ComboMarkdownEditor.ts' ;
4
4
import { POST } from '../modules/fetch.ts' ;
5
5
import { showErrorToast } from '../modules/toast.ts' ;
6
- import { hideElem , showElem } from '../utils/dom.ts' ;
6
+ import { hideElem , querySingleVisibleElem , showElem } from '../utils/dom.ts' ;
7
7
import { attachRefIssueContextPopup } from './contextpopup.ts' ;
8
8
import { initCommentContent , initMarkupContent } from '../markup/content.ts' ;
9
9
import { triggerUploadStateChanged } from './comp/EditorUpload.ts' ;
@@ -77,20 +77,22 @@ async function onEditContent(event) {
77
77
}
78
78
} ;
79
79
80
+ // Show write/preview tab and copy raw content as needed
81
+ showElem ( editContentZone ) ;
82
+ hideElem ( renderContent ) ;
83
+
80
84
comboMarkdownEditor = getComboMarkdownEditor ( editContentZone . querySelector ( '.combo-markdown-editor' ) ) ;
81
85
if ( ! comboMarkdownEditor ) {
82
86
editContentZone . innerHTML = document . querySelector ( '#issue-comment-editor-template' ) . innerHTML ;
83
- const saveButton = editContentZone . querySelector ( '.ui.primary.button' ) ;
87
+ const saveButton = querySingleVisibleElem < HTMLButtonElement > ( editContentZone , '.ui.primary.button' ) ;
88
+ const cancelButton = querySingleVisibleElem < HTMLButtonElement > ( editContentZone , '.ui.cancel.button' ) ;
84
89
comboMarkdownEditor = await initComboMarkdownEditor ( editContentZone . querySelector ( '.combo-markdown-editor' ) ) ;
85
90
const syncUiState = ( ) => saveButton . disabled = comboMarkdownEditor . isUploading ( ) ;
86
91
comboMarkdownEditor . container . addEventListener ( ComboMarkdownEditor . EventUploadStateChanged , syncUiState ) ;
87
- editContentZone . querySelector ( '.ui.cancel.button' ) . addEventListener ( 'click' , cancelAndReset ) ;
92
+ cancelButton . addEventListener ( 'click' , cancelAndReset ) ;
88
93
saveButton . addEventListener ( 'click' , saveAndRefresh ) ;
89
94
}
90
95
91
- // Show write/preview tab and copy raw content as needed
92
- showElem ( editContentZone ) ;
93
- hideElem ( renderContent ) ;
94
96
// FIXME: ideally here should reload content and attachment list from backend for existing editor, to avoid losing data
95
97
if ( ! comboMarkdownEditor . value ( ) ) {
96
98
comboMarkdownEditor . value ( rawContent . textContent ) ;
0 commit comments