Skip to content

Commit

Permalink
fixed #1 rewrite the configuration to neos frontend configuration BRE…
Browse files Browse the repository at this point in the history
…AKING
  • Loading branch information
breadlesscode committed Jun 18, 2019
1 parent 822eb62 commit 6656b4d
Show file tree
Hide file tree
Showing 8 changed files with 34,156 additions and 2,734 deletions.
27 changes: 0 additions & 27 deletions Classes/Controller/CkeditorConfigurationController.php

This file was deleted.

10 changes: 0 additions & 10 deletions Configuration/Policy.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions Configuration/Routes.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@ Neos:
javascript:
'Breadlesscode.SimpleEditorExtend:UiPlugin':
resource: resource://Breadlesscode.SimpleEditorExtend/Public/UiPlugin/Plugin.js
Flow:
mvc:
routes:
'Breadlesscode.SimpleEditorExtend':
position: 'start'
48 changes: 25 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,31 @@ The --no-update command prevent the automatic update of the dependencies. After
## Example configuration

```yaml
Breadlesscode:
SimpleEditorExtend:
buttons:
'Test.Test:MyCustomSpan':
extensionName: 'exampleExtension'
icon: 'plus-square'
tooltip: 'Mark the text in color green'
position: 'before strong'
formatting:
tag: 'span'
classes: 'test-class'
styles:
background-color: 'green'
'Test.Test:MyCustomSpan2':
extensionName: 'exampleExtension2'
icon: 'rocket'
tooltip: 'Mark the text in color red'
position: 'before exampleExtension'
formatting:
tag: 'span'
classes: 'test-class-2'
styles:
background-color: 'red'
Neos:
Neos:
Ui:
frontendConfiguration:
'Breadlesscode.SimpleEditorExtend:Buttons':
'Test.Test:MyCustomSpan':
extensionName: 'exampleExtension'
icon: 'plus-square'
tooltip: 'Mark the text in color green'
position: 'before strong'
formatting:
tag: 'span'
classes: 'test-class'
styles:
background-color: 'green'
'Test.Test:MyCustomSpan2':
extensionName: 'exampleExtension2'
icon: 'rocket'
tooltip: 'Mark the text in color red'
position: 'before exampleExtension'
formatting:
tag: 'span'
classes: 'test-class-2'
styles:
background-color: 'red'
```
Now you can use your new formattings like this:
Expand Down
41 changes: 19 additions & 22 deletions Resources/Private/UiPlugin/src/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,27 @@ import manifest from '@neos-project/neos-ui-extensibility';
import {getCkeditorPlugin, getCkeditorPluginConfig, getRichtextToolbarConfig} from './CkeditorPluginUtils';
import backend from '@neos-project/neos-ui-backend-connector';

manifest('Breadlesscode.SimpleEditorExtend:UiPlugin', {}, globalRegistry => {
manifest('Breadlesscode.SimpleEditorExtend:UiPlugin', {}, (globalRegistry, { frontendConfiguration }) => {
const richtextToolbar = globalRegistry.get('ckEditor5').get('richtextToolbar');
const config = globalRegistry.get('ckEditor5').get('config');
const { getJsonResource } = backend.get().endpoints;
const configUri = '/breadlesscode/editor-config';
const ckEditorConfig = globalRegistry.get('ckEditor5').get('config');
const buttonConfig = frontendConfiguration['Breadlesscode.SimpleEditorExtend:Buttons'];

getJsonResource(configUri).then((buttonConfig) => {
Object.keys(buttonConfig).forEach((formattingName) => {
const options = buttonConfig[formattingName];
const commandName = options.extensionName + 'Command';
Object.keys(buttonConfig).forEach((formattingName) => {
const options = buttonConfig[formattingName];
const commandName = options.extensionName + 'Command';

richtextToolbar.set(
options.extensionName,
getRichtextToolbarConfig(commandName, formattingName, options.icon, options.tooltip),
options.position
);

config.set(
options.extensionName,
getCkeditorPluginConfig(
formattingName,
getCkeditorPlugin(options.extensionName, commandName, options.formatting)
)
);
});
richtextToolbar.set(
options.extensionName,
getRichtextToolbarConfig(commandName, formattingName, options.icon, options.tooltip),
options.position
);

ckEditorConfig.set(
options.extensionName,
getCkeditorPluginConfig(
formattingName,
getCkeditorPlugin(options.extensionName, commandName, options.formatting)
)
);
});
});
Loading

0 comments on commit 6656b4d

Please sign in to comment.