@@ -3,7 +3,7 @@ import {handleReply} from './repo-issue.ts';
33import { getComboMarkdownEditor , initComboMarkdownEditor , ComboMarkdownEditor } from './comp/ComboMarkdownEditor.ts' ;
44import { POST } from '../modules/fetch.ts' ;
55import { showErrorToast } from '../modules/toast.ts' ;
6- import { hideElem , showElem } from '../utils/dom.ts' ;
6+ import { hideElem , querySingleVisibleElem , showElem } from '../utils/dom.ts' ;
77import { attachRefIssueContextPopup } from './contextpopup.ts' ;
88import { initCommentContent , initMarkupContent } from '../markup/content.ts' ;
99import { triggerUploadStateChanged } from './comp/EditorUpload.ts' ;
@@ -77,20 +77,22 @@ async function onEditContent(event) {
7777 }
7878 } ;
7979
80+ // Show write/preview tab and copy raw content as needed
81+ showElem ( editContentZone ) ;
82+ hideElem ( renderContent ) ;
83+
8084 comboMarkdownEditor = getComboMarkdownEditor ( editContentZone . querySelector ( '.combo-markdown-editor' ) ) ;
8185 if ( ! comboMarkdownEditor ) {
8286 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' ) ;
8489 comboMarkdownEditor = await initComboMarkdownEditor ( editContentZone . querySelector ( '.combo-markdown-editor' ) ) ;
8590 const syncUiState = ( ) => saveButton . disabled = comboMarkdownEditor . isUploading ( ) ;
8691 comboMarkdownEditor . container . addEventListener ( ComboMarkdownEditor . EventUploadStateChanged , syncUiState ) ;
87- editContentZone . querySelector ( '.ui.cancel.button' ) . addEventListener ( 'click' , cancelAndReset ) ;
92+ cancelButton . addEventListener ( 'click' , cancelAndReset ) ;
8893 saveButton . addEventListener ( 'click' , saveAndRefresh ) ;
8994 }
9095
91- // Show write/preview tab and copy raw content as needed
92- showElem ( editContentZone ) ;
93- hideElem ( renderContent ) ;
9496 // FIXME: ideally here should reload content and attachment list from backend for existing editor, to avoid losing data
9597 if ( ! comboMarkdownEditor . value ( ) ) {
9698 comboMarkdownEditor . value ( rawContent . textContent ) ;
0 commit comments