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.

65 lines (64 loc) 2.48 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const I18n = require("quill-i18n"); const is = require("../../utils/is.cjs.js"); function generateTableUp(QuillTableUp) { return class extends QuillTableUp { constructor(quill, options) { super(quill, options); this.quill = quill; if (!this.quill.options["format-painter"]) this.quill.options["format-painter"] = {}; const currentIgnoreFormat = this.quill.options["format-painter"].ignoreFormat || []; this.quill.options["format-painter"].ignoreFormat = Array.from( /* @__PURE__ */ new Set([ ...currentIgnoreFormat, "table-up-cell-inner" ]) ); this.quill.on(I18n.I18N_LOCALE_CHANGE, () => { this.refreshUI(); const toolbar = this.quill.getModule("toolbar"); if (toolbar && this.quill.theme.pickers) { const [, select] = (toolbar.controls || []).find(([name]) => name === this.statics.toolName) || []; if (select && select.tagName.toLocaleLowerCase() === "select") { const picker = this.quill.theme.pickers.find((picker2) => picker2.select === select); if (picker) { this.buildCustomSelect(this.options.customSelect, picker); } } } Object.keys(this.modules).forEach((key) => { if (is.isFunction(this.modules[key].destroy)) { this.modules[key].destroy(); } }); this.modules = {}; this.initModules(); }); } resolveOptions(options = {}) { const { texts, ...rest } = options || {}; const resolvedOptions = super.resolveOptions(rest); resolvedOptions.texts = super.resolveTexts(this.createTextResolver(texts)); return resolvedOptions; } resolveTexts(options = {}) { return super.resolveTexts(this.createTextResolver(options)); } createTextResolver(options = {}) { const textResolver = is.isFunction(options) ? options : null; const textMap = textResolver ? {} : options; return (key) => { if (textResolver) { const customText = textResolver.call(this, key); if (customText !== void 0) return customText; } else if (textMap[key] !== void 0) { return textMap[key]; } return this.quill.getLangText(key); }; } }; } exports.generateTableUp = generateTableUp; //# sourceMappingURL=index.cjs.js.map