2018-03-27 22:42:46 -04:00
|
|
|
const CKEDITOR = {"js": ["libraries/ckeditor/ckeditor.js"]};
|
|
|
|
|
|
|
|
const CODE_MIRROR = {
|
|
|
|
js: [
|
2024-10-12 20:41:50 +03:00
|
|
|
"node_modules/codemirror/lib/codemirror.js",
|
2024-08-12 17:41:33 +02:00
|
|
|
"node_modules/codemirror/addon/display/placeholder.js",
|
|
|
|
"node_modules/codemirror/addon/edit/matchbrackets.js",
|
|
|
|
"node_modules/codemirror/addon/edit/matchtags.js",
|
|
|
|
"node_modules/codemirror/addon/fold/xml-fold.js",
|
|
|
|
"node_modules/codemirror/addon/lint/lint.js",
|
|
|
|
"node_modules/codemirror/addon/mode/loadmode.js",
|
|
|
|
"node_modules/codemirror/addon/mode/multiplex.js",
|
|
|
|
"node_modules/codemirror/addon/mode/overlay.js",
|
|
|
|
"node_modules/codemirror/addon/mode/simple.js",
|
|
|
|
"node_modules/codemirror/addon/search/match-highlighter.js",
|
|
|
|
"node_modules/codemirror/mode/meta.js",
|
|
|
|
"node_modules/codemirror/keymap/vim.js"
|
2018-03-27 22:42:46 -04:00
|
|
|
],
|
|
|
|
css: [
|
2024-08-12 17:41:33 +02:00
|
|
|
"node_modules/codemirror/lib/codemirror.css",
|
|
|
|
"node_modules/codemirror/addon/lint/lint.css"
|
2018-03-27 22:42:46 -04:00
|
|
|
]
|
|
|
|
};
|
|
|
|
|
2024-08-11 01:20:17 +02:00
|
|
|
const ESLINT = {js: ["node_modules/eslint/bin/eslint.js"]};
|
2018-03-27 22:42:46 -04:00
|
|
|
|
2018-10-18 11:46:07 +02:00
|
|
|
const RELATION_MAP = {
|
|
|
|
js: [
|
2024-08-11 01:20:17 +02:00
|
|
|
"node_modules/jsplumb/dist/js/jsplumb.min.js",
|
2023-11-22 20:28:17 +01:00
|
|
|
"node_modules/panzoom/dist/panzoom.min.js"
|
2018-10-18 11:46:07 +02:00
|
|
|
],
|
|
|
|
css: [
|
2018-11-13 19:00:01 +01:00
|
|
|
"stylesheets/relation_map.css"
|
2018-10-18 11:46:07 +02:00
|
|
|
]
|
|
|
|
};
|
|
|
|
|
2023-11-22 20:22:16 +01:00
|
|
|
const PRINT_THIS = {js: ["node_modules/print-this/printThis.js"]};
|
2019-06-29 22:57:47 +02:00
|
|
|
|
2019-09-08 16:06:42 +02:00
|
|
|
const CALENDAR_WIDGET = {css: ["stylesheets/calendar.css"]};
|
|
|
|
|
2020-09-21 22:57:22 +02:00
|
|
|
const KATEX = {
|
2023-11-09 18:33:36 -03:00
|
|
|
js: [ "node_modules/katex/dist/katex.min.js",
|
|
|
|
"node_modules/katex/dist/contrib/mhchem.min.js",
|
|
|
|
"node_modules/katex/dist/contrib/auto-render.min.js" ],
|
2023-11-14 00:57:19 +01:00
|
|
|
css: [ "node_modules/katex/dist/katex.min.css" ]
|
2020-09-21 22:57:22 +02:00
|
|
|
};
|
|
|
|
|
2021-03-15 22:24:56 +01:00
|
|
|
const WHEEL_ZOOM = {
|
2024-08-11 01:20:17 +02:00
|
|
|
js: [ "node_modules/vanilla-js-wheel-zoom/dist/wheel-zoom.min.js"]
|
2021-03-15 22:24:56 +01:00
|
|
|
};
|
|
|
|
|
2021-05-29 22:52:32 +02:00
|
|
|
const FORCE_GRAPH = {
|
2023-11-22 20:02:35 +01:00
|
|
|
js: [ "node_modules/force-graph/dist/force-graph.min.js"]
|
2021-05-29 22:52:32 +02:00
|
|
|
};
|
|
|
|
|
2021-09-29 21:54:56 +02:00
|
|
|
const MERMAID = {
|
2023-11-22 20:09:04 +01:00
|
|
|
js: [ "node_modules/mermaid/dist/mermaid.min.js" ]
|
2021-09-29 21:54:56 +02:00
|
|
|
}
|
|
|
|
|
2022-04-05 15:35:15 +02:00
|
|
|
const EXCALIDRAW = {
|
2021-11-25 13:45:58 +01:00
|
|
|
js: [
|
2022-05-09 15:16:12 +02:00
|
|
|
"node_modules/react/umd/react.production.min.js",
|
|
|
|
"node_modules/react-dom/umd/react-dom.production.min.js",
|
|
|
|
"node_modules/@excalidraw/excalidraw/dist/excalidraw.production.min.js",
|
2022-05-25 23:38:06 +02:00
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
const MARKJS = {
|
|
|
|
js: [
|
2024-08-11 01:20:17 +02:00
|
|
|
"node_modules/mark.js/dist/jquery.mark.es6.min.js"
|
2022-05-25 23:38:06 +02:00
|
|
|
]
|
2021-11-25 13:45:58 +01:00
|
|
|
};
|
|
|
|
|
2024-07-20 11:42:54 +03:00
|
|
|
const I18NEXT = {
|
|
|
|
js: [
|
|
|
|
"node_modules/i18next/i18next.min.js",
|
|
|
|
"node_modules/i18next-http-backend/i18nextHttpBackend.min.js"
|
|
|
|
]
|
|
|
|
};
|
2024-07-20 09:32:56 +03:00
|
|
|
|
2024-09-01 15:04:47 +03:00
|
|
|
const MIND_ELIXIR = {
|
|
|
|
js: [
|
|
|
|
"node_modules/mind-elixir/dist/MindElixir.iife.js"
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
2018-03-27 22:42:46 -04:00
|
|
|
async function requireLibrary(library) {
|
|
|
|
if (library.css) {
|
2020-02-17 19:42:52 +01:00
|
|
|
library.css.map(cssUrl => requireCss(cssUrl));
|
2018-03-27 22:42:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (library.js) {
|
|
|
|
for (const scriptUrl of library.js) {
|
|
|
|
await requireScript(scriptUrl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-07 15:56:46 -04:00
|
|
|
// we save the promises in case of the same script being required concurrently multiple times
|
|
|
|
const loadedScriptPromises = {};
|
2018-03-27 22:42:46 -04:00
|
|
|
|
|
|
|
async function requireScript(url) {
|
2022-12-21 15:19:05 +01:00
|
|
|
url = `${window.glob.assetPath}/${url}`;
|
2022-10-26 23:50:54 +02:00
|
|
|
|
2018-04-07 15:56:46 -04:00
|
|
|
if (!loadedScriptPromises[url]) {
|
|
|
|
loadedScriptPromises[url] = $.ajax({
|
2018-03-27 22:42:46 -04:00
|
|
|
url: url,
|
|
|
|
dataType: "script",
|
|
|
|
cache: true
|
2018-04-07 15:56:46 -04:00
|
|
|
});
|
2018-03-27 22:42:46 -04:00
|
|
|
}
|
2018-04-07 15:56:46 -04:00
|
|
|
|
|
|
|
await loadedScriptPromises[url];
|
2018-03-27 22:42:46 -04:00
|
|
|
}
|
|
|
|
|
2022-10-26 23:50:54 +02:00
|
|
|
async function requireCss(url, prependAssetPath = true) {
|
2020-02-17 19:42:52 +01:00
|
|
|
const cssLinks = Array
|
|
|
|
.from(document.querySelectorAll('link'))
|
|
|
|
.map(el => el.href);
|
|
|
|
|
|
|
|
if (!cssLinks.some(l => l.endsWith(url))) {
|
2022-10-26 23:50:54 +02:00
|
|
|
if (prependAssetPath) {
|
2022-12-21 15:19:05 +01:00
|
|
|
url = `${window.glob.assetPath}/${url}`;
|
2022-10-26 23:50:54 +02:00
|
|
|
}
|
|
|
|
|
2020-02-17 19:42:52 +01:00
|
|
|
$('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', url));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-27 22:42:46 -04:00
|
|
|
export default {
|
2020-02-17 19:42:52 +01:00
|
|
|
requireCss,
|
2018-03-27 22:42:46 -04:00
|
|
|
requireLibrary,
|
|
|
|
CKEDITOR,
|
|
|
|
CODE_MIRROR,
|
2018-09-02 23:02:01 +02:00
|
|
|
ESLINT,
|
2019-06-03 22:55:59 +02:00
|
|
|
RELATION_MAP,
|
2019-08-20 23:30:19 +02:00
|
|
|
PRINT_THIS,
|
2020-09-21 22:57:22 +02:00
|
|
|
CALENDAR_WIDGET,
|
2021-03-15 22:24:56 +01:00
|
|
|
KATEX,
|
2021-05-29 22:52:32 +02:00
|
|
|
WHEEL_ZOOM,
|
2021-09-29 21:54:56 +02:00
|
|
|
FORCE_GRAPH,
|
2021-11-25 13:45:58 +01:00
|
|
|
MERMAID,
|
2022-05-25 23:38:06 +02:00
|
|
|
EXCALIDRAW,
|
2024-07-20 09:32:56 +03:00
|
|
|
MARKJS,
|
2024-09-01 15:04:47 +03:00
|
|
|
I18NEXT,
|
|
|
|
MIND_ELIXIR
|
2020-07-04 10:18:01 +02:00
|
|
|
}
|