diff --git a/web_src/js/features/comp/ComboMarkdownEditor.js b/web_src/js/features/comp/ComboMarkdownEditor.js index 7283dab35c022..a7d69af7b4e75 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 a7c59fb039561..b7937cf0065b0 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); +}