2018-05-09 12:01:36 +05:30
|
|
|
import syntaxHighlight from '~/syntax_highlight';
|
2021-03-11 19:13:27 +05:30
|
|
|
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';
|
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';
|
2023-03-04 22:38:38 +05:30
|
|
|
import renderObservability from './render_observability';
|
2022-08-27 11:52:29 +05:30
|
|
|
import { renderJSONTable } from './render_json_table';
|
2018-03-27 19:54:05 +05:30
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
function initPopovers(elements) {
|
|
|
|
if (!elements.length) return;
|
|
|
|
import(/* webpackChunkName: 'IssuablePopoverBundle' */ '~/issuable/popover')
|
|
|
|
.then(({ default: initIssuablePopovers }) => {
|
|
|
|
initIssuablePopovers(elements);
|
|
|
|
})
|
|
|
|
.catch(() => {});
|
|
|
|
}
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
// Render GitLab flavoured Markdown
|
|
|
|
export function renderGFM(element) {
|
|
|
|
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-merge_request',
|
|
|
|
'.js-render-metrics',
|
|
|
|
'.js-render-observability',
|
|
|
|
].map((selector) => Array.from(element.querySelectorAll(selector)));
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
syntaxHighlight(highlightEls);
|
|
|
|
renderKroki(krokiEls);
|
|
|
|
renderMath(mathEls);
|
|
|
|
renderSandboxedMermaid(mermaidEls);
|
|
|
|
renderJSONTable(tableEls.map((e) => e.parentNode));
|
|
|
|
highlightCurrentUser(userEls);
|
|
|
|
renderMetrics(metricsEls);
|
|
|
|
renderObservability(observabilityEls);
|
|
|
|
initPopovers(popoverEls);
|
|
|
|
}
|