refactor: Sort editor array after concat

This commit is contained in:
Aman Harwara
2021-10-01 21:07:26 +05:30
parent e71c5cc85d
commit 7aea7f330c

View File

@@ -100,9 +100,6 @@ export const Defaults: FunctionComponent<Props> = ({ application }) => {
useEffect(() => {
const editors = application.componentManager
.componentsForArea(ComponentArea.Editor)
.sort((a, b) => {
return a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1;
})
.map((editor) => {
const identifier = editor.package_info.identifier;
const iconType = getEditorIconType(identifier);
@@ -112,16 +109,19 @@ export const Defaults: FunctionComponent<Props> = ({ application }) => {
value: identifier,
...(iconType ? { icon: iconType } : null),
};
})
.concat([
{
icon: 'plain-text',
label: 'Plain Editor',
value: EditorIdentifier.PlainEditor,
},
])
.sort((a, b) => {
return a.label.toLowerCase() < b.label.toLowerCase() ? -1 : 1;
});
setEditorItems([
{
icon: 'plain-text',
label: 'Plain Editor',
value: EditorIdentifier.PlainEditor,
},
...editors,
]);
setEditorItems(editors);
}, [application]);
const setDefaultEditor = (value: string) => {