File size: 1,073 Bytes
e1d589b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import {memoize} from 'ramda';
import {SynchronousRegistry} from '@neos-project/neos-ui-extensibility/src/registry';
export default class RichTextToolbarRegistry extends SynchronousRegistry {
constructor(...args) {
super(...args);
this.TRISTATE_DISABLED = 0;
this.TRISTATE_ON = 1;
this.TRISTATE_OFF = 2;
}
setNodeTypesRegistry(nodeTypesRegistry) {
this.nodeTypesRegistry = nodeTypesRegistry;
}
hasFormattingRule = formattingRuleId =>
Object.values(this._registry).some(option => option.formattingRule === formattingRuleId);
getEnabledFormattingRulesForNodeTypeAndProperty = memoize(nodeTypeName => memoize(propertyName => {
const editorOptions = this.nodeTypesRegistry
.getInlineEditorOptionsForProperty(nodeTypeName, propertyName) || {};
return [].concat(
...['format', 'link', 'list', 'table']
.map(configurationKey => editorOptions[configurationKey])
.filter(i => i)
).filter(this.hasFormattingRule);
}));
}
|