Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add popup to hashed comments/pull requests/issues in file editing/adding preview tab #24040

Merged
merged 13 commits into from
Apr 12, 2023
Merged
9 changes: 2 additions & 7 deletions web_src/js/features/comp/ComboMarkdownEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
});
});
}
Expand Down
14 changes: 11 additions & 3 deletions web_src/js/features/repo-editor.js
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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);
});
});
}
Expand Down Expand Up @@ -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);
}