UNPKG

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

107 lines (106 loc) 2.6 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const QuillToolbarTip = require("quill-toolbar-tip"); require("../config/index.cjs.js"); const editor_config = require("../config/editor.config.cjs.js"); const _ToolbarTip = class _ToolbarTip extends QuillToolbarTip { constructor(quill, options) { if (!(options == null ? void 0 : options.tipTextMap)) { options.tipTextMap = {}; } super(quill, options); this.quill = quill; this.quill.on(editor_config.CHANGE_LANGUAGE_EVENT, () => { this.destroyAllTips(); this.options = this.resolveOptions(options); this.createToolbarTip(); }); } resolveOptions(options) { const result = super.resolveOptions(options); const langText = this.quill.options.langText; const btnTips = [ "bold", "italic", "strike", "underline", "undo", "redo", "clean", "link", "blockquote", "code", "image", "file", "emoji", "video", "screenshot", "better-table", "code-block", "formula", "format-painter" ].reduce((map, name) => { map[name] = langText[name]; return map; }, {}); const selectTips = [ "color", "background", "font", "size" ].reduce((map, name) => { map[name] = { onShow() { return langText[name]; } }; return map; }, {}); const valueControlTips = [ "list", "align", "script", "indent", "header", "direction" ].reduce((map, name) => { map[name] = { onShow(target, value) { if (name === "direction") { value = target.classList.contains("ql-active") ? "rtl" : "ltr"; } if (!value) { if (name === "align") { value = "left"; } else if (name === "header") { value = "normal"; } } return langText[`${name}-${value}`]; } }; return map; }, {}); const textMap = { ...btnTips, ...valueControlTips, ...selectTips, fullscreen: { onShow: () => { return langText[this.quill.isFullscreen ? "exit-fullscreen" : "fullscreen"]; } } }; return { ...result, tipTextMap: { ...textMap, ...options.tipTextMap } }; } }; _ToolbarTip.moduleName = "toolbar-tip"; let ToolbarTip = _ToolbarTip; exports.ToolbarTip = ToolbarTip; //# sourceMappingURL=toolbar-tip.cjs.js.map