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.

120 lines (119 loc) 4.99 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); const index = require("../config/index.cjs.js"); const fluentEditor = require("../core/fluent-editor.cjs.js"); const CustomImageSpec = require("../modules/custom-image/specs/CustomImageSpec.cjs.js"); const betterTable = require("../modules/table/better-table.cjs.js"); const formatPainter = require("../tools/format-painter.cjs.js"); const fullscreen = require("../tools/fullscreen.cjs.js"); const screenshot = require("../tools/screenshot.cjs.js"); const SnowTheme = fluentEditor.default.imports["themes/snow"]; SnowTheme.DEFAULTS = { modules: { "i18n": true, "keyboard": { bindings: { ...betterTable.default.keyboardBindings } }, "toolbar": { handlers: { ...SnowTheme.DEFAULTS.modules.toolbar.handlers, "formula": function() { if (!this.quill.isEnabled()) return; const mathlive = this.quill.getModule("mathlive"); if (!mathlive) { this.quill.theme.tooltip.edit("formula"); } else { mathlive.createDialog(); } }, "undo": function() { this.quill.history.undo(); }, "redo": function() { this.quill.history.redo(); }, "better-table": function() { this.quill.getModule("better-table").insertTable(3, 3); }, "file": function() { var _a, _b; const accept = (_b = (_a = this.quill.options) == null ? void 0 : _a.uploadOption) == null ? void 0 : _b.fileAccept; index.inputFile.call(this, "file", accept); }, "image": function() { var _a, _b; const accept = (_b = (_a = this.quill.options) == null ? void 0 : _a.uploadOption) == null ? void 0 : _b.imageAccept; index.inputFile.call(this, "image", accept); }, "emoji": function() { }, "fullscreen": fullscreen.fullscreenHandler, "list": function(value) { var _a, _b; const range = this.quill.getSelection(); const formats = this.quill.getFormat(range); const preListValue = Array.isArray(formats.list) ? (_a = formats.list[0]) == null ? void 0 : _a.value : (_b = formats.list) == null ? void 0 : _b.value; const curListValue = index.getListValue(value, preListValue); const lines = this.quill.getLines(range.index, range.length); const tableCols = lines.filter((line) => line.statics.blotName === "table-col" && !line.prev); if (tableCols.length) { let start = range.index; tableCols.forEach((item, index2) => { const table = item.domNode.closest("table.quill-better-table"); const tableBlot = fluentEditor.default.find(table); const tableLength = tableBlot.length(); const tableStart = this.quill.getIndex(item); const tableEnd = tableStart + tableLength; const beforeTableRangeLength = tableStart - start; this.quill.setSelection(start, beforeTableRangeLength, fluentEditor.default.sources.SILENT); this.quill.format("list", curListValue, fluentEditor.default.sources.USER); table.parentNode.classList.remove("quill-better-table-selected"); start = tableEnd; if (index2 === tableCols.length - 1) { this.quill.setSelection(tableEnd, range.index + range.length - tableEnd); this.quill.format("list", curListValue, fluentEditor.default.sources.USER); } }); } else { this.quill.format("list", curListValue, fluentEditor.default.sources.USER); } }, [formatPainter.FormatPainter.toolName]: formatPainter.FormatPainter, [screenshot.Screenshot.toolName]: screenshot.Screenshot, "lineheight": function(value) { this.quill.format("line-height", value); }, "divider": function() { const range = this.quill.getSelection(true); this.quill.insertText(range.index, "\n", fluentEditor.default.sources.USER); this.quill.insertEmbed(range.index + 1, "divider", true, fluentEditor.default.sources.USER); this.quill.setSelection(range.index + 2, fluentEditor.default.sources.SILENT); } } }, "better-table": { operationMenu: { color: true } }, "image": { specs: [CustomImageSpec.CustomImageSpec], overlay: { style: { border: "1px dashed rgb(68, 68, 68)" } }, align: { icons: { left: '<i class="icon-text-align-left"></i>', center: '<i class="icon-text-align-center"></i>', right: '<i class="icon-text-align-right"></i>' } } } } }; exports.default = SnowTheme; //# sourceMappingURL=snow.cjs.js.map