feat: get editor icons and their colors from snjs (#828)

* feat: get editor icons and their colors from snjs

* feat: get icons and their tints from snjs

* fix: use IconType from snjs
This commit is contained in:
Vardan Hakobyan
2022-01-31 18:58:36 +04:00
committed by GitHub
parent e890e22630
commit bf382ce0f8
21 changed files with 126 additions and 104 deletions

View File

@@ -1,5 +1,4 @@
import { Dropdown, DropdownItem } from '@/components/Dropdown';
import { IconType } from '@/components/Icon';
import { FeatureIdentifier, PrefKey } from '@standardnotes/snjs';
import {
PreferencesGroup,
@@ -27,31 +26,6 @@ type EditorOption = DropdownItem & {
value: FeatureIdentifier | 'plain-editor';
};
export const getIconAndTintForEditor = (
identifier: FeatureIdentifier | undefined
): [IconType, number] => {
switch (identifier) {
case FeatureIdentifier.BoldEditor:
case FeatureIdentifier.PlusEditor:
return ['rich-text', 1];
case FeatureIdentifier.MarkdownBasicEditor:
case FeatureIdentifier.MarkdownMathEditor:
case FeatureIdentifier.MarkdownMinimistEditor:
case FeatureIdentifier.MarkdownProEditor:
return ['markdown', 2];
case FeatureIdentifier.TokenVaultEditor:
return ['authenticator', 6];
case FeatureIdentifier.SheetsEditor:
return ['spreadsheets', 5];
case FeatureIdentifier.TaskEditor:
return ['tasks', 3];
case FeatureIdentifier.CodeEditor:
return ['code', 4];
default:
return ['plain-text', 1];
}
};
const makeEditorDefault = (
application: WebApplication,
component: SNComponent,
@@ -103,7 +77,8 @@ export const Defaults: FunctionComponent<Props> = ({ application }) => {
.componentsForArea(ComponentArea.Editor)
.map((editor): EditorOption => {
const identifier = editor.package_info.identifier;
const [iconType, tint] = getIconAndTintForEditor(identifier);
const [iconType, tint] =
application.iconsController.getIconAndTintForEditor(identifier);
return {
label: editor.name,