Commit a108f4c5 authored by bgm's avatar bgm
Browse files

Merge branch 'locale' into symbiotic

parents 132288ce 0ea1cb20
......@@ -75,8 +75,7 @@ Administer->Customize Data and Screens->Display Preferences
## Known Issues
- the language is not yet passed through to the editor. It should be added in crm.ckeditor5.js
where [lang](https://github.com/Studio-42/elFinder/wiki/Client-configuration-options-2.1#lang) is set.
- The editor language only works in the ElFinder mode, and is set according to the current CiviCRM language, but Ckeditor5 ships its own set of translations which may not include all CiviCRM languages (see the files in js/ckeditor5/ckeditor-classic-build/translations).
- some session errors are visible when using elfinder with debug enabled - need to implement a [session override](https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options-2.1#session-218)
- The file browser for elFinder is in the background when popups are on - but given the
previous item this is OK for now.
......
......@@ -154,8 +154,12 @@ function ckeditor5_civicrm_themes(&$themes) {
function ckeditor5_civicrm_coreResourceList(&$items, $region) {
if ($region === 'html-header') {
if (Civi::settings()->get('editor_id') === 'CKEditor5-elfinder') {
$locale = CRM_Core_I18n::getLocale();
$lang = substr($locale, 0, 2);
$items[] = [
'config' => [
'CKEditor5Language' => ($lang != 'en' ? CRM_Core_Resources::singleton()->getUrl('ckeditor5', 'js/ckeditor5/ckeditor-classic-build/translations/' . $lang . '.js') : ''),
'wysisygScriptLocation' => CRM_Core_Resources::singleton()->getUrl('ckeditor5', 'js/wysiwyg/crm.ckeditor5.js'),
// Note that I am just using 'classic build' at the moment - not a configured
// build so no build in the path.
......
......@@ -279,7 +279,7 @@
'horizontalLine'
]
},
language: 'en',
language: (typeof CRM.config.locale == 'string' ? CRM.config.locale.substr(0,2) : 'en'),
image: {
toolbar: [
'imageTextAlternative',
......@@ -307,7 +307,69 @@
*/
function initializeWithELFinder() {
$(item).addClass('crm-wysiwyg-enabled');
ClassicEditor.create($(item)[0]).then(onReadyElFinder);
ClassicEditor.create($(item)[0], {
toolbar: {
// With this it wraps rather than offering a drop down for more.
// I'm on the fence about which is better but this is consistent with
// ckeditor4. If we added configurability we could expose this.
// https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editorconfig-EditorConfig.html#member-toolbar
shouldNotGroupWhenFull: true,
items: [
'heading',
'|',
'bold',
'underline',
'italic',
'strikethrough',
'superscript',
'subscript',
'highlight',
'|',
'removeFormat',
'specialCharacters',
'fontFamily',
'fontColor',
'fontBackgroundColor',
'fontSize',
'|',
'bulletedList',
'numberedList',
'|',
'indent',
'outdent',
'|',
'link',
'imageUpload',
'blockQuote',
'insertTable',
'alignment',
'mediaEmbed',
'undo',
'redo',
'pageBreak',
'horizontalLine'
]
},
language: (typeof CRM.config.locale == 'string' ? CRM.config.locale.substr(0,2) : 'en'),
image: {
toolbar: [
'imageTextAlternative',
'imageStyle:full',
'imageStyle:side'
]
},
table: {
contentToolbar: [
'tableColumn',
'tableRow',
'mergeTableCells',
'tableCellProperties',
'tableProperties'
]
},
licenseKey: '',
}).then(onReadyElFinder);
}
if ($(item).hasClass('crm-wysiwyg-enabled')) {
......@@ -319,7 +381,12 @@
initialize();
} else {
if (CRM.config.ELFinderLocation) {
CRM.loadScript(CRM.config.CKEditor5Location).done(CRM.loadScript(CRM.config.ELFinderLocation).done(initialize));
if (CRM.config.CKEditor5Language) {
CRM.loadScript(CRM.config.CKEditor5Language).done(CRM.loadScript(CRM.config.CKEditor5Location).done(CRM.loadScript(CRM.config.ELFinderLocation).done(initialize)));
}
else {
CRM.loadScript(CRM.config.CKEditor5Location).done(CRM.loadScript(CRM.config.ELFinderLocation).done(initialize));
}
}
else {
CRM.loadScript(CRM.config.CKEditor5Location).done(initialize);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment