debian-mirror-gitlab/app/assets/javascripts/behaviors/markdown/render_gfm.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-05-09 12:01:36 +05:30
import $ from 'jquery';
import syntaxHighlight from '~/syntax_highlight';
2021-03-11 19:13:27 +05:30
import initUserPopovers from '../../user_popovers';
import highlightCurrentUser from './highlight_current_user';
2022-04-01 21:47:47 +05:30
import { renderKroki } from './render_kroki';
2018-03-17 18:26:18 +05:30
import renderMath from './render_math';
import renderMermaid from './render_mermaid';
2022-03-02 08:16:31 +05:30
import renderSandboxedMermaid from './render_sandboxed_mermaid';
2019-10-12 21:52:04 +05:30
import renderMetrics from './render_metrics';
2018-03-27 19:54:05 +05:30
2018-12-05 23:21:45 +05:30
// Render GitLab flavoured Markdown
2017-08-17 22:00:37 +05:30
//
2018-03-17 18:26:18 +05:30
// Delegates to syntax highlight and render math & mermaid diagrams.
2017-08-17 22:00:37 +05:30
//
2018-03-17 18:26:18 +05:30
$.fn.renderGFM = function renderGFM() {
2021-10-27 15:23:28 +05:30
syntaxHighlight(this.find('.js-syntax-highlight').get());
2022-04-01 21:47:47 +05:30
renderKroki(this.find('.js-render-kroki[hidden]').get());
2018-03-17 18:26:18 +05:30
renderMath(this.find('.js-render-math'));
2022-03-02 08:16:31 +05:30
if (gon.features?.sandboxedMermaid) {
renderSandboxedMermaid(this.find('.js-render-mermaid'));
} else {
renderMermaid(this.find('.js-render-mermaid'));
}
2018-12-05 23:21:45 +05:30
highlightCurrentUser(this.find('.gfm-project_member').get());
2020-05-24 23:13:21 +05:30
initUserPopovers(this.find('.js-user-link').get());
2020-11-24 15:15:51 +05:30
const mrPopoverElements = this.find('.gfm-merge_request').get();
if (mrPopoverElements.length) {
2022-06-21 17:19:12 +05:30
import(/* webpackChunkName: 'MrPopoverBundle' */ '~/mr_popover')
2020-11-24 15:15:51 +05:30
.then(({ default: initMRPopovers }) => {
initMRPopovers(mrPopoverElements);
})
.catch(() => {});
}
2019-10-12 21:52:04 +05:30
renderMetrics(this.find('.js-render-metrics').get());
2018-03-17 18:26:18 +05:30
return this;
};
2017-08-17 22:00:37 +05:30
2020-11-24 15:15:51 +05:30
$(() => {
window.requestIdleCallback(
() => {
$('body').renderGFM();
},
{ timeout: 500 },
);
});