From b43ad51a3dd28b747f7135f081d8812dedd89879 Mon Sep 17 00:00:00 2001 From: Hester Gong Date: Wed, 12 Apr 2023 11:03:23 +0800 Subject: [PATCH] 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/comp/ComboMarkdownEditor.js | 9 ++------- web_src/js/features/repo-editor.js | 14 +++++++++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/web_src/js/features/comp/ComboMarkdownEditor.js b/web_src/js/features/comp/ComboMarkdownEditor.js index 7283dab35c..a7d69af7b4 100644 --- a/web_src/js/features/comp/ComboMarkdownEditor.js +++ b/web_src/js/features/comp/ComboMarkdownEditor.js @@ -4,10 +4,9 @@ import $ from 'jquery'; import {attachTribute} from '../tribute.js'; import {hideElem, showElem, autosize} from '../../utils/dom.js'; import {initEasyMDEImagePaste, initTextareaImagePaste} from './ImagePaste.js'; -import {initMarkupContent} from '../../markup/content.js'; import {handleGlobalEnterQuickSubmit} from './QuickSubmit.js'; -import {attachRefIssueContextPopup} from '../contextpopup.js'; import {emojiKeys, emojiString} from '../emoji.js'; +import {renderPreviewPanelContent} from '../repo-editor.js'; let elementIdCounter = 0; const maxExpanderMatches = 6; @@ -194,11 +193,7 @@ class ComboMarkdownEditor { text: this.value(), wiki: this.previewWiki, }, (data) => { - $panelPreviewer.html(data); - initMarkupContent(); - - const refIssues = $panelPreviewer.find('p .ref-issue'); - attachRefIssueContextPopup(refIssues); + renderPreviewPanelContent($panelPreviewer, data); }); }); } 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); +}