Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,26 @@ Example: [Configuration/Settings.yaml](Configuration/Settings.yaml)
- **Not null** Using an empty class (cssClass: null) to unset the value might cause errors during rendering in the backend. The select boxes of this package contain an "x" button for resetting the value.
- Although you can add **multiple classes** by separating them with a whitespace. e.g. `btn btn-primary`, it is **highly recommended** to use only **one and unique** class across all Inline- or BlockStyles. See [known issues](#konwn-issues) for more details.

**How to translate labels?**

To provide localized labels you can pass the translation id for each label. [How to create your translations in Neos?](https://docs.neos.io/guide/rendering/translating-text-in-fusion#create-a-translation-file)

```yaml
TechDivision:
CkStyles:
InlineStyles:
presets:
'fontColor':
label: Vendor.Package:Main:inlinestyles.fontcolor.label
options:
'primary':
label: Vendor.Package:Main:inlinestyles.fontcolor.options.red
cssClass: 'my-class-red'
'secondary':
label: Vendor.Package:Main:inlinestyles.fontcolor.options.green
cssClass: 'my-class-green'
```

### 3. Activate the preset for your inline editable NodeType property:

```yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {SelectBox} from '@neos-project/react-ui-components';
import {neos} from '@neos-project/neos-ui-decorators';
import {connect} from 'react-redux';
import {$transform} from 'plow-js';
import PresetType from '../PresetType';

import {selectors} from '@neos-project/neos-ui-redux-store';
import * as CkEditorApi from '@neos-project/neos-ui-ckeditor5-bindings';

@neos(globalRegistry => ({
i18nRegistry: globalRegistry.get('i18n')
}))

@connect($transform({
formattingUnderCursor: selectors.UI.ContentCanvas.formattingUnderCursor
}))
Expand All @@ -18,7 +23,10 @@ export default class BlockStyleSelector extends PureComponent {
presetConfiguration: PresetType.isRequired,

// from @connect
formattingUnderCursor: PropTypes.object
formattingUnderCursor: PropTypes.object,

// from @neos
i18nRegistry: PropTypes.object.isRequired
};

constructor(...args) {
Expand All @@ -28,10 +36,12 @@ export default class BlockStyleSelector extends PureComponent {
}

render() {
const {i18nRegistry} = this.props;

const optionsForSelect = Object.entries(this.props.presetConfiguration.options)
.map(([optionIdentifier, optionConfiguration]) => ({
value: optionIdentifier,
label: optionConfiguration.label
label: i18nRegistry.translate(optionConfiguration.label)
}));

if (optionsForSelect.length === 0) {
Expand All @@ -45,7 +55,7 @@ export default class BlockStyleSelector extends PureComponent {
options={optionsForSelect}
value={currentValue}
allowEmpty={true}
placeholder={this.props.presetConfiguration.label}
placeholder={i18nRegistry.translate(this.props.presetConfiguration.label)}
onValueChange={this.handleOnSelect}
/>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {SelectBox} from '@neos-project/react-ui-components';
import {neos} from '@neos-project/neos-ui-decorators';
import {connect} from 'react-redux';
import {$transform} from 'plow-js';
import PresetType from '../PresetType';

import {selectors} from '@neos-project/neos-ui-redux-store';
import * as CkEditorApi from '@neos-project/neos-ui-ckeditor5-bindings';

@neos(globalRegistry => ({
i18nRegistry: globalRegistry.get('i18n')
}))

@connect($transform({
formattingUnderCursor: selectors.UI.ContentCanvas.formattingUnderCursor
}))
Expand All @@ -18,7 +23,10 @@ export default class InlineStyleSelector extends PureComponent {
presetConfiguration: PresetType.isRequired,

// from @connect
formattingUnderCursor: PropTypes.object
formattingUnderCursor: PropTypes.object,

// from @neos
i18nRegistry: PropTypes.object.isRequired
};

constructor(...args) {
Expand All @@ -28,10 +36,12 @@ export default class InlineStyleSelector extends PureComponent {
}

render() {
const {i18nRegistry} = this.props;

const optionsForSelect = Object.entries(this.props.presetConfiguration.options)
.map(([optionIdentifier, optionConfiguration]) => ({
value: optionIdentifier,
label: optionConfiguration.label
label: i18nRegistry.translate(optionConfiguration.label)
}));

if (optionsForSelect.length === 0) {
Expand All @@ -45,7 +55,7 @@ export default class InlineStyleSelector extends PureComponent {
options={optionsForSelect}
value={currentValue}
allowEmpty={true}
placeholder={this.props.presetConfiguration.label}
placeholder={i18nRegistry.translate(this.props.presetConfiguration.label)}
onValueChange={this.handleOnSelect}
/>
);
Expand Down
Loading