@opentiny/fluent-editor
Version:
A rich text editor based on Quill 2.0, which extends rich modules and formats on the basis of Quill. It's powerful and out-of-the-box.
54 lines (53 loc) • 1.96 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Quill = require("quill");
const Syntax = Quill.import("modules/syntax");
class CustomSyntax extends Syntax {
detectLanguage(text) {
var _a;
const hljs = (_a = this.options) == null ? void 0 : _a.hljs;
if (!hljs || typeof hljs.highlightAuto !== "function") {
return null;
}
const result = hljs.highlightAuto(text, Object.keys(this.languages || {}));
return (result == null ? void 0 : result.language) || null;
}
highlightBlot(text, language = "plain") {
var _a;
if (!language || !((_a = this.languages) == null ? void 0 : _a[language]) || language === "plain") {
const detected = this.detectLanguage(text);
if (detected) {
language = detected;
}
}
return super.highlightBlot(text, language);
}
}
__publicField(CustomSyntax, "DEFAULTS");
CustomSyntax.DEFAULTS = {
hljs: (() => {
return window.hljs;
})(),
interval: 1e3,
languages: [
{ key: "plain", label: "Plain" },
{ key: "bash", label: "Bash" },
{ key: "cpp", label: "C++" },
{ key: "cs", label: "C#" },
{ key: "css", label: "CSS" },
{ key: "diff", label: "Diff" },
{ key: "xml", label: "HTML/XML" },
{ key: "java", label: "Java" },
{ key: "javascript", label: "Javascript" },
{ key: "markdown", label: "Markdown" },
{ key: "php", label: "PHP" },
{ key: "python", label: "Python" },
{ key: "ruby", label: "Ruby" },
{ key: "sql", label: "SQL" }
]
};
exports.default = CustomSyntax;
//# sourceMappingURL=syntax.cjs.js.map