@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.
109 lines (108 loc) • 3.53 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
function getBackgroundConfig(quill) {
var _a;
const MindMapModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"];
if (!MindMapModule || typeof MindMapModule !== "object") {
return false;
}
if ("background" in MindMapModule) {
const background = MindMapModule.background;
if (background === false || background === void 0) {
return false;
}
if (typeof background === "object" && background !== null) {
const typedBackground = background;
const backgroundConfig = {};
if (typedBackground.color) {
backgroundConfig.backgroundColor = typedBackground.color;
}
if (typedBackground.image) {
backgroundConfig.backgroundImage = typedBackground.image;
}
if (typedBackground.repeat) {
backgroundConfig.backgroundRepeat = typedBackground.repeat;
}
if (typedBackground.position) {
backgroundConfig.backgroundPosition = typedBackground.position;
}
if (typedBackground.size) {
backgroundConfig.backgroundSize = typedBackground.size;
}
return backgroundConfig;
}
}
return false;
}
function getLineConfig(quill) {
var _a;
const MindMapModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"];
if (!MindMapModule || typeof MindMapModule !== "object") {
return false;
}
if ("line" in MindMapModule) {
const line = MindMapModule.line;
if (line === false || line === void 0) {
return false;
}
if (typeof line === "object" && line !== null) {
const typedLine = line;
const lineConfig = {};
if (typedLine.color) {
lineConfig.lineColor = typedLine.color;
}
if (typedLine.width) {
lineConfig.lineWidth = typedLine.width;
}
if (typedLine.dasharray) {
lineConfig.lineDasharray = typedLine.dasharray;
}
if (typedLine.style) {
lineConfig.lineStyle = typedLine.style;
}
return lineConfig;
}
}
return false;
}
function getResizeConfig(quill) {
var _a;
const MindMapModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"];
if (!MindMapModule || typeof MindMapModule !== "object") {
return false;
}
if ("resize" in MindMapModule) {
const resize = MindMapModule.resize;
return resize === true;
}
return false;
}
function getThemeConfig(quill) {
var _a;
const MindMapModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"];
if (!MindMapModule || typeof MindMapModule !== "object") {
return "default";
}
if ("theme" in MindMapModule) {
const theme = MindMapModule.theme;
return theme || "default";
}
return "default";
}
function getAllConfigs(quill) {
var _a, _b;
const deps = (_b = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["mind-map"]) == null ? void 0 : _b.deps;
return {
backgroundConfig: getBackgroundConfig(quill),
resizeConfig: getResizeConfig(quill),
lineConfig: getLineConfig(quill),
themeConfig: getThemeConfig(quill),
deps
};
}
exports.getAllConfigs = getAllConfigs;
exports.getBackgroundConfig = getBackgroundConfig;
exports.getLineConfig = getLineConfig;
exports.getResizeConfig = getResizeConfig;
exports.getThemeConfig = getThemeConfig;
//# sourceMappingURL=config-utils.cjs.js.map