From b43ad51a3dd28b747f7135f081d8812dedd89879 Mon Sep 17 00:00:00 2001 From: Hester Gong Date: Wed, 12 Apr 2023 11:03:23 +0800 Subject: Add popup to hashed comments/pull requests/issues in file editing/adding preview tab (#24040) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #23734 didn't add popups(tippy) to ref issues for the preview tab when adding/editing a file The location of the preview tab: 截屏2023-04-10 13 55 38 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: 截屏2023-04-10 13 55 42 --------- Co-authored-by: Lunny Xiao Co-authored-by: silverwind --- web_src/js/features/repo-editor.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'web_src/js/features/repo-editor.js') diff --git a/web_src/js/features/repo-editor.js b/web_src/js/features/repo-editor.js index a7c59fb039..b7937cf006 100644 --- a/web_src/js/features/repo-editor.js +++ b/web_src/js/features/repo-editor.js @@ -1,8 +1,9 @@ import $ from 'jquery'; import {htmlEscape} from 'escape-goat'; -import {initMarkupContent} from '../markup/content.js'; import {createCodeEditor} from './codeeditor.js'; import {hideElem, showElem} from '../utils/dom.js'; +import {initMarkupContent} from '../markup/content.js'; +import {attachRefIssueContextPopup} from './contextpopup.js'; const {csrfToken} = window.config; @@ -28,8 +29,7 @@ function initEditPreviewTab($form) { file_path: treePathEl.val(), }, (data) => { const $previewPanel = $form.find(`.tab[data-tab="${$tabMenu.data('preview')}"]`); - $previewPanel.html(data); - initMarkupContent(); + renderPreviewPanelContent($previewPanel, data); }); }); } @@ -191,3 +191,11 @@ export function initRepoEditor() { }); })(); } + +export function renderPreviewPanelContent($panelPreviewer, data) { + $panelPreviewer.html(data); + initMarkupContent(); + + const refIssues = $panelPreviewer.find('p .ref-issue'); + attachRefIssueContextPopup(refIssues); +} -- cgit v1.2.3