Skip to content

Commit de84c2a

Browse files
committed
refactored richtext toolbar config generation
1 parent 01e11ec commit de84c2a

File tree

4 files changed

+47
-32
lines changed

4 files changed

+47
-32
lines changed

Resources/Private/UiPlugin/src/CkeditorPluginUtils.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
22
import AttributeCommand from '@ckeditor/ckeditor5-basic-styles/src/attributecommand';
33
import {$add, $get} from 'plow-js';
4+
import ButtonComponent from './ButtonComponent';
45

56
const getCkeditorPlugin = function(extensionName, commandName, formatting) {
67
const attributeName = extensionName + 'Attribute';
@@ -40,4 +41,15 @@ const getCkeditorPluginConfig = function(formattingName, ckeditorPlugin) {
4041
}
4142
};
4243

43-
export { getCkeditorPlugin, getCkeditorPluginConfig};
44+
const getRichtextToolbarConfig = function(commandName, formattingName, icon, tooltip) {
45+
return {
46+
commandName: commandName,
47+
isActive: $get(commandName),
48+
isVisible: $get(['formatting', formattingName]),
49+
component: ButtonComponent(commandName),
50+
icon: icon,
51+
tooltip: tooltip,
52+
};
53+
}
54+
55+
export { getCkeditorPlugin, getCkeditorPluginConfig, getRichtextToolbarConfig};
Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import manifest from '@neos-project/neos-ui-extensibility';
2-
import {$get} from 'plow-js';
3-
import ButtonComponent from './ButtonComponent';
4-
import {getCkeditorPlugin, getCkeditorPluginConfig} from './CkeditorPluginUtils';
2+
import {getCkeditorPlugin, getCkeditorPluginConfig, getRichtextToolbarConfig} from './CkeditorPluginUtils';
53
import backend from '@neos-project/neos-ui-backend-connector';
64

75
manifest('Breadlesscode.SimpleEditorExtend:UiPlugin', {}, globalRegistry => {
@@ -15,18 +13,19 @@ manifest('Breadlesscode.SimpleEditorExtend:UiPlugin', {}, globalRegistry => {
1513
const options = buttonConfig[formattingName];
1614
const commandName = options.extensionName + 'Command';
1715

18-
richtextToolbar.set(options.extensionName, {
19-
commandName: commandName,
20-
isActive: $get(commandName),
21-
isVisible: $get(['formatting', formattingName]),
22-
component: ButtonComponent(commandName),
23-
icon: options.icon,
24-
tooltip: options.tooltip,
25-
}, options.position);
26-
config.set(options.extensionName, getCkeditorPluginConfig(
27-
formattingName,
28-
getCkeditorPlugin(options.extensionName, commandName, options.formatting)
29-
));
16+
richtextToolbar.set(
17+
options.extensionName,
18+
getRichtextToolbarConfig(commandName, formattingName, options.icon, options.tooltip),
19+
options.position
20+
);
21+
22+
config.set(
23+
options.extensionName,
24+
getCkeditorPluginConfig(
25+
formattingName,
26+
getCkeditorPlugin(options.extensionName, commandName, options.formatting)
27+
)
28+
);
3029
});
3130
});
3231
});

Resources/Public/UiPlugin/Plugin.js

Lines changed: 19 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Resources/Public/UiPlugin/Plugin.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)