1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
import syntaxHighlight from '~/syntax_highlight';
import highlightCurrentUser from './highlight_current_user';
import { renderKroki } from './render_kroki';
import renderMath from './render_math';
import renderSandboxedMermaid from './render_sandboxed_mermaid';
import renderMetrics from './render_metrics';
import renderObservability from './render_observability';
import { renderJSONTable } from './render_json_table';
function initPopovers(elements) {
if (!elements.length) return;
import(/* webpackChunkName: 'IssuablePopoverBundle' */ 'ee_else_ce/issuable/popover')
.then(({ default: initIssuablePopovers }) => {
initIssuablePopovers(elements);
})
.catch(() => {});
}
// Render GitLab flavoured Markdown
export function renderGFM(element) {
if (!element) {
return;
}
const [
highlightEls,
krokiEls,
mathEls,
mermaidEls,
tableEls,
userEls,
popoverEls,
metricsEls,
observabilityEls,
] = [
'.js-syntax-highlight',
'.js-render-kroki[hidden]',
'.js-render-math',
'.js-render-mermaid',
'[lang="json"][data-lang-params="table"]',
'.gfm-project_member',
'.gfm-issue, .gfm-work_item, .gfm-merge_request, .gfm-epic',
'.js-render-metrics',
'.js-render-observability',
].map((selector) => Array.from(element.querySelectorAll(selector)));
syntaxHighlight(highlightEls);
renderKroki(krokiEls);
renderMath(mathEls);
renderSandboxedMermaid(mermaidEls);
renderJSONTable(tableEls.map((e) => e.parentNode));
highlightCurrentUser(userEls);
if (!window.gon?.features?.removeMonitorMetrics) {
renderMetrics(metricsEls);
}
renderObservability(observabilityEls);
initPopovers(popoverEls);
}
|