UNPKG

@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.

103 lines (102 loc) 3.46 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); function getGridConfig(quill) { var _a, _b, _c; const defaultGrid = { size: 20, visible: true, type: "dot", config: { color: "#ababab", thickness: 1 } }; const flowChartModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["flow-chart"]; if (!flowChartModule || typeof flowChartModule !== "object") { return defaultGrid; } if ("grid" in flowChartModule) { const grid = flowChartModule.grid; if (grid === false || grid === void 0) { return null; } if (typeof grid === "object" && grid !== null) { const typedGrid = grid; const gridConfig = { size: typedGrid.size || defaultGrid.size, visible: typedGrid.visible !== void 0 ? typedGrid.visible : defaultGrid.visible, type: typedGrid.type || defaultGrid.type, config: { color: ((_b = typedGrid.config) == null ? void 0 : _b.color) || defaultGrid.config.color, thickness: ((_c = typedGrid.config) == null ? void 0 : _c.thickness) || defaultGrid.config.thickness } }; return gridConfig; } } return defaultGrid; } function getBackgroundConfig(quill) { var _a; const flowChartModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["flow-chart"]; if (!flowChartModule || typeof flowChartModule !== "object") { return false; } if ("background" in flowChartModule) { const background = flowChartModule.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; } if (typedBackground.opacity) { backgroundConfig.opacity = typedBackground.opacity; } return backgroundConfig; } } return false; } function getResizeConfig(quill) { var _a; const flowChartModule = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["flow-chart"]; if (!flowChartModule || typeof flowChartModule !== "object") { return false; } if ("resize" in flowChartModule) { const resize = flowChartModule.resize; return resize === true; } return false; } function getAllConfigs(quill) { var _a, _b; const deps = (_b = (_a = quill == null ? void 0 : quill.options.modules) == null ? void 0 : _a["flow-chart"]) == null ? void 0 : _b.deps; return { gridConfig: getGridConfig(quill), backgroundConfig: getBackgroundConfig(quill), resizeConfig: getResizeConfig(quill), deps }; } exports.getAllConfigs = getAllConfigs; exports.getBackgroundConfig = getBackgroundConfig; exports.getGridConfig = getGridConfig; exports.getResizeConfig = getResizeConfig; //# sourceMappingURL=config-utils.cjs.js.map