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.39 kB
import { I18N_LOCALE_CHANGE } from "quill-i18n"; import { isFunction } from "../../utils/is.es.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_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 (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 = 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); }; } }; } export { generateTableUp }; //# sourceMappingURL=index.es.js.map