Skip to content

Commit b43ad51

Browse files
HesterGlunnysilverwind
authored
Add popup to hashed comments/pull requests/issues in file editing/adding preview tab (#24040)
#23734 didn't add popups(tippy) to ref issues for the preview tab when adding/editing a file The location of the preview tab: <img width="1214" alt="截屏2023-04-10 13 55 38" src="https://user-images.githubusercontent.com/17645053/230836213-a73f0cee-378c-4a21-93db-583ba2c72f77.png"> This PR resues the logic in `ComboMarkdownEditor.js` to also add popup to hashed comments/pull requests/issues in file editing/adding preview tab. After - On hover: <img width="1222" alt="截屏2023-04-10 13 55 42" src="https://user-images.githubusercontent.com/17645053/230836250-527ca7d0-6ec4-4c68-89ab-4f1b57b09239.png"> --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: silverwind <me@silverwind.io>
1 parent 6892e2b commit b43ad51

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

web_src/js/features/comp/ComboMarkdownEditor.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import $ from 'jquery';
44
import {attachTribute} from '../tribute.js';
55
import {hideElem, showElem, autosize} from '../../utils/dom.js';
66
import {initEasyMDEImagePaste, initTextareaImagePaste} from './ImagePaste.js';
7-
import {initMarkupContent} from '../../markup/content.js';
87
import {handleGlobalEnterQuickSubmit} from './QuickSubmit.js';
9-
import {attachRefIssueContextPopup} from '../contextpopup.js';
108
import {emojiKeys, emojiString} from '../emoji.js';
9+
import {renderPreviewPanelContent} from '../repo-editor.js';
1110

1211
let elementIdCounter = 0;
1312
const maxExpanderMatches = 6;
@@ -194,11 +193,7 @@ class ComboMarkdownEditor {
194193
text: this.value(),
195194
wiki: this.previewWiki,
196195
}, (data) => {
197-
$panelPreviewer.html(data);
198-
initMarkupContent();
199-
200-
const refIssues = $panelPreviewer.find('p .ref-issue');
201-
attachRefIssueContextPopup(refIssues);
196+
renderPreviewPanelContent($panelPreviewer, data);
202197
});
203198
});
204199
}

web_src/js/features/repo-editor.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import $ from 'jquery';
22
import {htmlEscape} from 'escape-goat';
3-
import {initMarkupContent} from '../markup/content.js';
43
import {createCodeEditor} from './codeeditor.js';
54
import {hideElem, showElem} from '../utils/dom.js';
5+
import {initMarkupContent} from '../markup/content.js';
6+
import {attachRefIssueContextPopup} from './contextpopup.js';
67

78
const {csrfToken} = window.config;
89

@@ -28,8 +29,7 @@ function initEditPreviewTab($form) {
2829
file_path: treePathEl.val(),
2930
}, (data) => {
3031
const $previewPanel = $form.find(`.tab[data-tab="${$tabMenu.data('preview')}"]`);
31-
$previewPanel.html(data);
32-
initMarkupContent();
32+
renderPreviewPanelContent($previewPanel, data);
3333
});
3434
});
3535
}
@@ -191,3 +191,11 @@ export function initRepoEditor() {
191191
});
192192
})();
193193
}
194+
195+
export function renderPreviewPanelContent($panelPreviewer, data) {
196+
$panelPreviewer.html(data);
197+
initMarkupContent();
198+
199+
const refIssues = $panelPreviewer.find('p .ref-issue');
200+
attachRefIssueContextPopup(refIssues);
201+
}

0 commit comments

Comments
 (0)