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.

40 lines (39 loc) 1.51 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); require("../config/index.cjs.js"); const is = require("../utils/is.cjs.js"); const editor_config = require("../config/editor.config.cjs.js"); class I18N { constructor(quill, options) { this.quill = quill; this.isFullscreen = false; this.options = { lang: "en-US", langText: editor_config.LANG_CONF["en-US"] }; this.options = Object.assign({}, options, this.resolveLanguageOption(options || {})); this.changeLanguage(this.options); } resolveLanguageOption(options) { if (is.isUndefined(options.lang)) { options.lang = editor_config.defaultLanguage; } if (!(options.lang in editor_config.LANG_CONF)) { console.warn(`The language ${options.lang} is not supported. Use the default language: ${editor_config.defaultLanguage}`); options.lang = editor_config.defaultLanguage; } return { lang: options.lang, langText: Object.assign({}, editor_config.LANG_CONF[options.lang], options.langText || {}) }; } changeLanguage(options) { const langOps = this.resolveLanguageOption(options); if (langOps.lang === this.quill.lang) return; this.options.lang = langOps.lang; this.options.langText = langOps.langText; this.quill.emitter.emit(editor_config.CHANGE_LANGUAGE_EVENT, this.options.lang, this.options.langText); } } exports.default = I18N; //# sourceMappingURL=i18n.cjs.js.map