@eccenca/gui-elements
Version:
GUI elements based on other libraries, usable in React application, written in Typescript.
51 lines • 1.97 kB
JavaScript
//adapted v6 modes imports
import { javascript } from "@codemirror/lang-javascript";
import { json } from "@codemirror/lang-json";
import { markdown } from "@codemirror/lang-markdown";
import { sql } from "@codemirror/lang-sql";
import { xml } from "@codemirror/lang-xml";
import { yaml } from "@codemirror/lang-yaml";
import { html } from "@codemirror/lang-html";
import { defaultHighlightStyle, StreamLanguage } from "@codemirror/language";
//legacy mode imports
import { jinja2 } from "@codemirror/legacy-modes/mode/jinja2.js";
import { mathematica } from "@codemirror/legacy-modes/mode/mathematica.js";
import { ntriples } from "@codemirror/legacy-modes/mode/ntriples.js";
import { python } from "@codemirror/legacy-modes/mode/python.js";
import { sparql } from "@codemirror/legacy-modes/mode/sparql.js";
import { turtle } from "@codemirror/legacy-modes/mode/turtle.js";
//adaptations
import { adaptedSyntaxHighlighting } from "../tests/codemirrorTestHelper.js";
var supportedModes = {
markdown: markdown,
python: python,
sparql: sparql,
turtle: turtle,
xml: xml,
yaml: yaml,
jinja2: jinja2,
json: json,
ntriples: ntriples,
mathematica: mathematica,
sql: sql,
javascript: javascript,
html: html
};
export var supportedCodeEditorModes = Object.keys(supportedModes);
var v6AdaptedModes = new Map([
["json", true],
["markdown", true],
["xml", true],
["sql", true],
["yaml", true],
["javascript", true],
["html", true]
]);
export var useCodeMirrorModeExtension = function (mode) {
return !mode
? adaptedSyntaxHighlighting(defaultHighlightStyle)
: v6AdaptedModes.has(mode)
? (typeof supportedModes[mode] === "function" ? supportedModes[mode] : function () { return null; })()
: StreamLanguage === null || StreamLanguage === void 0 ? void 0 : StreamLanguage.define(supportedModes[mode]);
};
//# sourceMappingURL=useCodemirrorModeExtension.hooks.js.map