Skip to content

Commit

Permalink
TASK: Apply suggestion from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Jul 3, 2023
1 parent 1234d9a commit 42030fe
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions packages/neos-ui-ckeditor5-bindings/src/manifest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,18 @@ export default ckEditorRegistry => {

//
// Base CKE configuration
// - configuration of language
// - and placeholder feature see https://ckeditor.com/docs/ckeditor5/16.0.0/api/module_core_editor_editorconfig-EditorConfig.html#member-placeholder
//
config.set('baseConfiguration', (ckEditorConfiguration, {userPreferences}) => {
return Object.assign(ckEditorConfiguration, {
config.set('baseConfiguration', (ckEditorConfiguration, {globalRegistry, editorOptions, userPreferences}) => {
const i18nRegistry = globalRegistry.get('i18n');
const placeholder = $get('placeholder', editorOptions);
return {
...ckEditorConfiguration,
// stripTags, because we allow `<p>Edit text here</p>` as placeholder for legacy
placeholder: placeholder ? stripTags(i18nRegistry.translate(placeholder)) : undefined,
language: String($get('interfaceLanguage', userPreferences))
});
};
});

//
Expand Down Expand Up @@ -144,21 +151,5 @@ export default ckEditorRegistry => {
]}
}));

//
// @see https://ckeditor.com/docs/ckeditor5/16.0.0/api/module_core_editor_editorconfig-EditorConfig.html#member-placeholder
//
config.set('placeholder', (config, {globalRegistry, editorOptions}) => {
const i18nRegistry = globalRegistry.get('i18n');
const placeholder = $get('placeholder', editorOptions);
if (!placeholder) {
return config;
}
return {
...config,
// stripTags, because we allow `<p>Edit text here</p>` as placeholder for legacy
placeholder: stripTags(i18nRegistry.translate(placeholder))
};
});

return config;
};

0 comments on commit 42030fe

Please sign in to comment.