Class: CKEditor5::Rails::Plugins::WProofreaderSync
- Inherits:
-
Editor::PropsInlinePlugin
- Object
- Editor::PropsBasePlugin
- Editor::PropsInlinePlugin
- CKEditor5::Rails::Plugins::WProofreaderSync
- Defined in:
- lib/ckeditor5/rails/plugins/wproofreader.rb
Overview
Sync I18n language from editor to WProofreader plugin
Constant Summary collapse
- PLUGIN_CODE =
<<~JS const { Plugin, FileRepository } = await import( 'ckeditor5' ); const CORRECTION_LANGUAGES = [ 'en_US', 'en_GB', 'pt_BR', 'da_DK', 'nl_NL', 'en_CA', 'fi_FI', 'fr_FR', 'fr_CA', 'de_DE', 'el_GR', 'it_IT', 'nb_NO', 'pt_PT', 'es_ES', 'sv_SE', 'uk_UA', 'auto' ]; return class WproofreaderSync extends Plugin { static get pluginName() { return 'WProofreaderSync'; } async init() { const { editor } = this; const wproofreaderConfig = editor.config.get('wproofreader'); const editorLangCode = (() => { const config = editor.config.get('language'); return config.content || config.ui; })(); if (!wproofreaderConfig || !editorLangCode) { return; } const lang = CORRECTION_LANGUAGES.find( lang => lang.startsWith(editorLangCode.toLowerCase()) ) || 'auto'; editor.config.set('wproofreader', { lang, localization: editorLangCode, ...wproofreaderConfig, }); } } JS
Instance Attribute Summary
Attributes inherited from Editor::PropsInlinePlugin
Attributes inherited from Editor::PropsBasePlugin
Instance Method Summary collapse
-
#initialize ⇒ WProofreaderSync
constructor
A new instance of WProofreaderSync.
Methods inherited from Editor::PropsInlinePlugin
Methods inherited from Editor::PropsBasePlugin
normalize, #preload_assets_bundle, #to_h
Constructor Details
#initialize ⇒ WProofreaderSync
Returns a new instance of WProofreaderSync.
70 71 72 73 |
# File 'lib/ckeditor5/rails/plugins/wproofreader.rb', line 70 def initialize super(:WProofreaderSync, PLUGIN_CODE) compress! end |