@rivm-loculus-tools/sequence-editor 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitkeep +0 -0
- package/CHANGELOG.md +8 -0
- package/LICENSE +288 -0
- package/eslint.config.js +16 -0
- package/package.json +140 -3
- package/scripts/update-exports.js +9 -0
- package/src/classes/services/EditorWorkerService/EditorWorkerService.ts +163 -0
- package/src/classes/services/EditorWorkerService/index.ts +1 -0
- package/src/classes/services/SequenceEditorEventBusService/SequenceEditorEventBusService.ts +37 -0
- package/src/classes/services/SequenceEditorEventBusService/index.ts +1 -0
- package/src/classes/workers/EngineWorker/EngineWorker.ts +196 -0
- package/src/classes/workers/EngineWorker/index.ts +1 -0
- package/src/components/app/App/App.tsx +22 -0
- package/src/components/app/App/index.ts +1 -0
- package/src/components/pages/EmptyWorkspace.tsx +43 -0
- package/src/components/pages/SequenceEditorErrorPage/SequenceEditorErrorPage.tsx +16 -0
- package/src/components/pages/SequenceEditorErrorPage/index.ts +1 -0
- package/src/components/pages/SequenceEditorMainPage/SequenceEditorMainPage.tsx +76 -0
- package/src/components/pages/SequenceEditorMainPage/index.ts +1 -0
- package/src/components/ui/SequenceEditor/SequenceEditor.tsx +896 -0
- package/src/components/ui/SequenceEditor/SequenceEditorGotoPositionDialog.tsx +108 -0
- package/src/components/ui/SequenceEditor/SequenceEditorStatusBar.tsx +72 -0
- package/src/components/ui/SequenceEditor/index.ts +1 -0
- package/src/components/ui/SequenceEditorPage/SequenceEditorPage.tsx +23 -0
- package/src/components/ui/SequenceEditorPage/index.ts +1 -0
- package/src/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawer.tsx +234 -0
- package/src/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawerColorForm.tsx +73 -0
- package/src/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawerKeyboardShortcuts.tsx +230 -0
- package/src/components/ui/SequenceEditorPageDrawer/index.ts +1 -0
- package/src/components/ui/SequenceEditorPageHeader/SequenceEditorPageHeader.tsx +71 -0
- package/src/components/ui/SequenceEditorPageHeader/index.ts +1 -0
- package/src/components/ui/SequenceEditorSearchBar/SequenceEditorSearchBar.tsx +35 -0
- package/src/components/ui/SequenceEditorSearchBar/index.ts +1 -0
- package/src/constants/editor.ts +15 -0
- package/src/constants/index.ts +3 -0
- package/src/constants/keyboard.ts +154 -0
- package/src/constants/palette.ts +227 -0
- package/src/models/editor.ts +6 -0
- package/src/models/index.ts +3 -0
- package/src/models/model.ts +295 -0
- package/src/models/palette.ts +68 -0
- package/src/stores/sequenceEditorStore/index.ts +1 -0
- package/src/stores/sequenceEditorStore/sequenceEditorStore.ts +103 -0
- package/src/utils/EditorUtil/EditorUtil.ts +892 -0
- package/src/utils/EditorUtil/index.ts +1 -0
- package/src/utils/EngineErrorUtil/EngineErrorUtil.ts +25 -0
- package/src/utils/PaletteUtil/PaletteUtil.ts +31 -0
- package/src/utils/PaletteUtil/index.ts +1 -0
- package/tsconfig.build.json +14 -0
- package/tsconfig.json +32 -0
- package/vite.config.ts +177 -0
- package/README.md +0 -3
package/src/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawerKeyboardShortcuts.tsx
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Box,
|
|
3
|
+
ListItemButton,
|
|
4
|
+
ListItemText,
|
|
5
|
+
Typography,
|
|
6
|
+
} from '@mui/material';
|
|
7
|
+
import {
|
|
8
|
+
KeyboardArrowDown,
|
|
9
|
+
KeyboardArrowLeft,
|
|
10
|
+
KeyboardArrowRight,
|
|
11
|
+
KeyboardArrowUp,
|
|
12
|
+
KeyboardCommandKey,
|
|
13
|
+
KeyboardControlKey,
|
|
14
|
+
KeyboardOptionKey,
|
|
15
|
+
SpaceBar,
|
|
16
|
+
} from '@mui/icons-material';
|
|
17
|
+
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
|
18
|
+
import type {
|
|
19
|
+
ComponentType,
|
|
20
|
+
MouseEvent as ReactMouseEvent,
|
|
21
|
+
} from 'react';
|
|
22
|
+
import type { KeyboardModifier } from '@gen-epix/ui-core/classes/services/KeyboardShortcutService';
|
|
23
|
+
|
|
24
|
+
import { KEYBOARD_SHORTCUTS } from '../../../constants';
|
|
25
|
+
|
|
26
|
+
type ShortcutKey = {
|
|
27
|
+
icon?: ComponentType<SvgIconProps>;
|
|
28
|
+
label: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const MODIFIER_LABELS = new Map<KeyboardModifier, string>([
|
|
32
|
+
['Alt', 'Alt'],
|
|
33
|
+
['AltGraph', 'AltGr'],
|
|
34
|
+
['Control', 'Ctrl'],
|
|
35
|
+
['Meta', 'Cmd'],
|
|
36
|
+
['Shift', 'Shift'],
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
const MODIFIER_ICONS = new Map<KeyboardModifier, ComponentType<SvgIconProps>>([
|
|
40
|
+
['Alt', KeyboardOptionKey],
|
|
41
|
+
['Control', KeyboardControlKey],
|
|
42
|
+
['Meta', KeyboardCommandKey],
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
const CODE_KEYS = new Map<string, ShortcutKey>([
|
|
46
|
+
['ArrowDown', { icon: KeyboardArrowDown, label: 'Arrow down' }],
|
|
47
|
+
['ArrowLeft', { icon: KeyboardArrowLeft, label: 'Arrow left' }],
|
|
48
|
+
['ArrowRight', { icon: KeyboardArrowRight, label: 'Arrow right' }],
|
|
49
|
+
['ArrowUp', { icon: KeyboardArrowUp, label: 'Arrow up' }],
|
|
50
|
+
['Backspace', { label: 'Backspace' }],
|
|
51
|
+
['Delete', { label: 'Delete' }],
|
|
52
|
+
['End', { label: 'End' }],
|
|
53
|
+
['Home', { label: 'Home' }],
|
|
54
|
+
['PageDown', { label: 'Page down' }],
|
|
55
|
+
['PageUp', { label: 'Page up' }],
|
|
56
|
+
['Space', { icon: SpaceBar, label: 'Space' }],
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
type Shortcut = typeof KEYBOARD_SHORTCUTS[string];
|
|
60
|
+
|
|
61
|
+
type ShortcutGroup = {
|
|
62
|
+
name: string;
|
|
63
|
+
shortcuts: Shortcut[];
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const isMacOs = typeof navigator !== 'undefined' && /Mac|iPhone|iPad|iPod/.test(navigator.platform);
|
|
67
|
+
|
|
68
|
+
const SHORTCUT_GROUPS: ShortcutGroup[] = [
|
|
69
|
+
{
|
|
70
|
+
name: 'Selection',
|
|
71
|
+
shortcuts: [
|
|
72
|
+
KEYBOARD_SHORTCUTS.moveSelectionLeft,
|
|
73
|
+
KEYBOARD_SHORTCUTS.moveSelectionRight,
|
|
74
|
+
KEYBOARD_SHORTCUTS.moveSelectionUp,
|
|
75
|
+
KEYBOARD_SHORTCUTS.moveSelectionDown,
|
|
76
|
+
KEYBOARD_SHORTCUTS.expandSelectionLeft,
|
|
77
|
+
KEYBOARD_SHORTCUTS.expandSelectionRight,
|
|
78
|
+
KEYBOARD_SHORTCUTS.expandSelectionUp,
|
|
79
|
+
KEYBOARD_SHORTCUTS.expandSelectionDown,
|
|
80
|
+
KEYBOARD_SHORTCUTS.moveCellLeft,
|
|
81
|
+
KEYBOARD_SHORTCUTS.moveCellRight,
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'Rows',
|
|
86
|
+
shortcuts: [
|
|
87
|
+
KEYBOARD_SHORTCUTS.moveRowUp,
|
|
88
|
+
KEYBOARD_SHORTCUTS.moveRowDown,
|
|
89
|
+
KEYBOARD_SHORTCUTS.moveRowToStart,
|
|
90
|
+
KEYBOARD_SHORTCUTS.moveRowToEnd,
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: 'Navigation',
|
|
95
|
+
shortcuts: [
|
|
96
|
+
KEYBOARD_SHORTCUTS.scrollToLineStart,
|
|
97
|
+
KEYBOARD_SHORTCUTS.scrollToLineEnd,
|
|
98
|
+
KEYBOARD_SHORTCUTS.scrollPageUp,
|
|
99
|
+
KEYBOARD_SHORTCUTS.scrollPageDown,
|
|
100
|
+
KEYBOARD_SHORTCUTS.gotoPosition,
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: 'Editing',
|
|
105
|
+
shortcuts: [
|
|
106
|
+
KEYBOARD_SHORTCUTS.insertGap,
|
|
107
|
+
KEYBOARD_SHORTCUTS.deleteBackward,
|
|
108
|
+
KEYBOARD_SHORTCUTS.deleteSelection,
|
|
109
|
+
KEYBOARD_SHORTCUTS.deleteBase,
|
|
110
|
+
KEYBOARD_SHORTCUTS.undo,
|
|
111
|
+
KEYBOARD_SHORTCUTS.redo,
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
];
|
|
115
|
+
|
|
116
|
+
const getActiveModifierGroup = (modifierGroups: KeyboardModifier[][]): KeyboardModifier[] => {
|
|
117
|
+
const preferredModifier = isMacOs ? 'Meta' : 'Control';
|
|
118
|
+
return modifierGroups.find((modifierGroup) => modifierGroup.includes(preferredModifier)) ?? modifierGroups[0] ?? [];
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const getShortcutKeys = (shortcut: Shortcut): ShortcutKey[] => {
|
|
122
|
+
const { code, key, modifiers = [] } = shortcut.shortcut;
|
|
123
|
+
const keyLabel = code ? (CODE_KEYS.get(code) ?? { label: code }) : { label: key?.toUpperCase() ?? '' };
|
|
124
|
+
const modifierGroup = getActiveModifierGroup(modifiers);
|
|
125
|
+
return [
|
|
126
|
+
...modifierGroup.map((modifier) => ({
|
|
127
|
+
icon: MODIFIER_ICONS.get(modifier),
|
|
128
|
+
label: isMacOs && modifier === 'Alt' ? 'Option' : MODIFIER_LABELS.get(modifier) ?? modifier,
|
|
129
|
+
})),
|
|
130
|
+
keyLabel,
|
|
131
|
+
];
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const renderShortcutKeys = (shortcut: Shortcut) => {
|
|
135
|
+
const keyGroups = getShortcutKeys(shortcut);
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<Box
|
|
139
|
+
aria-label={keyGroups.map(({ label }) => label).join(' ')}
|
|
140
|
+
sx={{ alignItems: 'center', display: 'flex', flexShrink: 0, gap: 0.5 }}
|
|
141
|
+
>
|
|
142
|
+
<Box sx={{ alignItems: 'center', display: 'flex', gap: 0.5 }}>
|
|
143
|
+
{keyGroups.map((keyItem) => {
|
|
144
|
+
const KeyIcon = keyItem.icon;
|
|
145
|
+
return (
|
|
146
|
+
<Box
|
|
147
|
+
aria-label={keyItem.label}
|
|
148
|
+
component={'kbd'}
|
|
149
|
+
key={keyItem.label}
|
|
150
|
+
sx={{
|
|
151
|
+
alignItems: 'center',
|
|
152
|
+
backgroundColor: 'action.hover',
|
|
153
|
+
border: '1px solid',
|
|
154
|
+
borderColor: 'divider',
|
|
155
|
+
borderRadius: 0.75,
|
|
156
|
+
boxShadow: '0 1px 0 rgba(0, 0, 0, 0.2)',
|
|
157
|
+
color: 'text.primary',
|
|
158
|
+
display: 'flex',
|
|
159
|
+
fontFamily: 'monospace',
|
|
160
|
+
fontSize: '0.7rem',
|
|
161
|
+
justifyContent: 'center',
|
|
162
|
+
lineHeight: 1,
|
|
163
|
+
minWidth: keyItem.label.length === 1 ? 24 : 'auto',
|
|
164
|
+
px: 0.75,
|
|
165
|
+
py: 0.5,
|
|
166
|
+
textAlign: 'center',
|
|
167
|
+
}}
|
|
168
|
+
>
|
|
169
|
+
{KeyIcon ? (
|
|
170
|
+
<KeyIcon
|
|
171
|
+
aria-hidden
|
|
172
|
+
fontSize={'inherit'}
|
|
173
|
+
/>
|
|
174
|
+
) : keyItem.label}
|
|
175
|
+
</Box>
|
|
176
|
+
);
|
|
177
|
+
})}
|
|
178
|
+
</Box>
|
|
179
|
+
</Box>
|
|
180
|
+
);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const onClickShortcut = (event: ReactMouseEvent<HTMLElement>) => {
|
|
184
|
+
const shortcut = Object.values(KEYBOARD_SHORTCUTS).find(({ description }) => description === event.currentTarget.dataset.shortcut);
|
|
185
|
+
if (!shortcut) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const { code, key, modifiers = [] } = shortcut.shortcut;
|
|
190
|
+
const activeModifiers = getActiveModifierGroup(modifiers);
|
|
191
|
+
shortcut.callback(new KeyboardEvent('keydown', {
|
|
192
|
+
altKey: activeModifiers.includes('Alt'),
|
|
193
|
+
code: code ?? '',
|
|
194
|
+
ctrlKey: activeModifiers.includes('Control'),
|
|
195
|
+
key: key ?? code ?? '',
|
|
196
|
+
metaKey: activeModifiers.includes('Meta'),
|
|
197
|
+
shiftKey: activeModifiers.includes('Shift'),
|
|
198
|
+
}));
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
export const SequenceEditorPageDrawerKeyboardShortcuts = () => (
|
|
202
|
+
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 2, px: 2, py: 2.5 }}>
|
|
203
|
+
{SHORTCUT_GROUPS.map((group) => (
|
|
204
|
+
<Box key={group.name}>
|
|
205
|
+
<Typography
|
|
206
|
+
sx={{ color: 'text.secondary', fontWeight: 700, mb: 0.5, textTransform: 'uppercase' }}
|
|
207
|
+
variant={'caption'}
|
|
208
|
+
>
|
|
209
|
+
{group.name}
|
|
210
|
+
</Typography>
|
|
211
|
+
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 0.5 }}>
|
|
212
|
+
{group.shortcuts.map((shortcut) => (
|
|
213
|
+
<ListItemButton
|
|
214
|
+
data-shortcut={shortcut.description}
|
|
215
|
+
key={shortcut.description}
|
|
216
|
+
onClick={onClickShortcut}
|
|
217
|
+
sx={{ borderRadius: 1, gap: 1, justifyContent: 'space-between', px: 1, py: 0.75 }}
|
|
218
|
+
>
|
|
219
|
+
<ListItemText
|
|
220
|
+
primary={shortcut.description}
|
|
221
|
+
sx={{ '& .MuiListItemText-primary': { typography: 'body2' } }}
|
|
222
|
+
/>
|
|
223
|
+
{renderShortcutKeys(shortcut)}
|
|
224
|
+
</ListItemButton>
|
|
225
|
+
))}
|
|
226
|
+
</Box>
|
|
227
|
+
</Box>
|
|
228
|
+
))}
|
|
229
|
+
</Box>
|
|
230
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SequenceEditorPageDrawer';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { FastaPageHeaderCenterComponent } from '@rivm-loculus-tools/common-frontend/components/FastaPageHeaderCenterComponent';
|
|
2
|
+
import { FastaPageHeaderImportButton } from '@rivm-loculus-tools/common-frontend/components/FastaPageHeaderImportButton';
|
|
3
|
+
import { FastaPageHeaderResetButton } from '@rivm-loculus-tools/common-frontend/components/FastaPageHeaderResetButton';
|
|
4
|
+
import { PageCommonHeader } from '@rivm-loculus-tools/common-frontend/components/page';
|
|
5
|
+
import { PageHeaderDocumentationButton } from '@rivm-loculus-tools/common-frontend/components/PageHeaderDocumentationButton';
|
|
6
|
+
import { useCallback } from 'react';
|
|
7
|
+
import { useStore } from 'zustand';
|
|
8
|
+
import BiotechOutlinedIcon from '@mui/icons-material/BiotechOutlined';
|
|
9
|
+
import UndoIcon from '@mui/icons-material/Undo';
|
|
10
|
+
import RedoIcon from '@mui/icons-material/Redo';
|
|
11
|
+
import {
|
|
12
|
+
IconButton,
|
|
13
|
+
Tooltip,
|
|
14
|
+
} from '@mui/material';
|
|
15
|
+
|
|
16
|
+
import { sequenceEditorStore } from '../../../stores/sequenceEditorStore';
|
|
17
|
+
import { SequenceEditorEventBusService } from '../../../classes/services/SequenceEditorEventBusService';
|
|
18
|
+
|
|
19
|
+
export const SequenceEditorPageHeader = () => {
|
|
20
|
+
const resetDataset = useStore(sequenceEditorStore, (state) => state.resetDataset);
|
|
21
|
+
const meta = useStore(sequenceEditorStore, (state) => state.meta);
|
|
22
|
+
|
|
23
|
+
const onReset = useCallback(() => {
|
|
24
|
+
resetDataset();
|
|
25
|
+
}, [resetDataset]);
|
|
26
|
+
|
|
27
|
+
const onUndoButtonClick = useCallback(() => {
|
|
28
|
+
SequenceEditorEventBusService.getInstance().emit('onUndo');
|
|
29
|
+
}, []);
|
|
30
|
+
|
|
31
|
+
const onRedoButtonClick = useCallback(() => {
|
|
32
|
+
SequenceEditorEventBusService.getInstance().emit('onRedo');
|
|
33
|
+
}, []);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<PageCommonHeader
|
|
37
|
+
centerComponent={<FastaPageHeaderCenterComponent store={sequenceEditorStore} />}
|
|
38
|
+
icon={<BiotechOutlinedIcon sx={{ fontSize: 24 }} />}
|
|
39
|
+
rightComponent={(
|
|
40
|
+
<>
|
|
41
|
+
<FastaPageHeaderImportButton />
|
|
42
|
+
<Tooltip title={'Undo last action'}>
|
|
43
|
+
<IconButton
|
|
44
|
+
color={'inherit'}
|
|
45
|
+
disabled={meta?.undoDepth === 0}
|
|
46
|
+
onClick={onUndoButtonClick}
|
|
47
|
+
size={'small'}
|
|
48
|
+
sx={{ opacity: 0.85 }}
|
|
49
|
+
>
|
|
50
|
+
<UndoIcon fontSize={'small'} />
|
|
51
|
+
</IconButton>
|
|
52
|
+
</Tooltip>
|
|
53
|
+
<Tooltip title={'Redo last action'}>
|
|
54
|
+
<IconButton
|
|
55
|
+
color={'inherit'}
|
|
56
|
+
disabled={meta?.redoDepth === 0}
|
|
57
|
+
onClick={onRedoButtonClick}
|
|
58
|
+
size={'small'}
|
|
59
|
+
sx={{ opacity: 0.85 }}
|
|
60
|
+
>
|
|
61
|
+
<RedoIcon fontSize={'small'} />
|
|
62
|
+
</IconButton>
|
|
63
|
+
</Tooltip>
|
|
64
|
+
<FastaPageHeaderResetButton onReset={onReset} />
|
|
65
|
+
<PageHeaderDocumentationButton />
|
|
66
|
+
</>
|
|
67
|
+
)}
|
|
68
|
+
title={'Sequence Editor'}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SequenceEditorPageHeader';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SearchBar } from '@rivm-loculus-tools/common-frontend/components/SearchBar';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { useStore } from 'zustand';
|
|
4
|
+
|
|
5
|
+
import { sequenceEditorStore } from '../../../stores/sequenceEditorStore';
|
|
6
|
+
import { SequenceEditorEventBusService } from '../../../classes/services/SequenceEditorEventBusService';
|
|
7
|
+
|
|
8
|
+
export const SequenceEditorSearchBar = () => {
|
|
9
|
+
const setSearchQuery = useStore(sequenceEditorStore, (state) => state.setSearchQuery);
|
|
10
|
+
const setSearchHighlightedIndex = useStore(sequenceEditorStore, (state) => state.setSearchResultHighlightedIndex);
|
|
11
|
+
const searchQuery = useStore(sequenceEditorStore, (state) => state.searchQuery);
|
|
12
|
+
const searchResults = useStore(sequenceEditorStore, (state) => state.searchResult);
|
|
13
|
+
const searchHighlightedIndex = useStore(sequenceEditorStore, (state) => state.searchResultHighlightedIndex);
|
|
14
|
+
|
|
15
|
+
const onSearchQueryChange = useCallback((query: string) => {
|
|
16
|
+
setSearchQuery(query);
|
|
17
|
+
SequenceEditorEventBusService.getInstance().emit('onSearch', query);
|
|
18
|
+
}, [setSearchQuery]);
|
|
19
|
+
|
|
20
|
+
const onHighlightedIndexChange = useCallback((index: number) => {
|
|
21
|
+
setSearchHighlightedIndex(index);
|
|
22
|
+
}, [setSearchHighlightedIndex]);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<SearchBar
|
|
26
|
+
allowNavigation
|
|
27
|
+
highlightedIndex={searchHighlightedIndex}
|
|
28
|
+
numResults={searchResults?.num_matches}
|
|
29
|
+
onHighlightedIndexChange={onHighlightedIndexChange}
|
|
30
|
+
onSearchQueryChange={onSearchQueryChange}
|
|
31
|
+
searchQuery={searchQuery}
|
|
32
|
+
truncated={searchResults?.truncated}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SequenceEditorSearchBar';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { GridGeometry } from '../models';
|
|
2
|
+
|
|
3
|
+
export const MIN_LABEL_WIDTH = 120;
|
|
4
|
+
|
|
5
|
+
export const DEFAULT_GRID_GEOMETRY: GridGeometry = {
|
|
6
|
+
cellHeight: 22,
|
|
7
|
+
cellWidth: 18,
|
|
8
|
+
dividerWidth: 4,
|
|
9
|
+
labelWidth: 300,
|
|
10
|
+
numOverscanCols: 128,
|
|
11
|
+
numOverscanRows: 16,
|
|
12
|
+
rulerHeight: 26,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const IUPAC_KEYS = new Set('ACGTURYKMSWBDHVN');
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { KeyboardShortcutConfig } from '@gen-epix/ui-core/classes/services/KeyboardShortcutService';
|
|
2
|
+
|
|
3
|
+
import { SequenceEditorEventBusService } from '../classes/services/SequenceEditorEventBusService';
|
|
4
|
+
import { EDITOR_DIRECTION } from '../models/editor';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
type KeyboardShortcut = {
|
|
8
|
+
callback: KeyboardShortcutConfig['callback'];
|
|
9
|
+
description: string;
|
|
10
|
+
shortcut: Pick<KeyboardShortcutConfig, 'code' | 'key' | 'modifiers'>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const emitDirection = (eventName: 'onExpandSelection' | 'onMoveCells' | 'onMoveRows' | 'onMoveRowsEnd' | 'onMoveSelection', direction: EDITOR_DIRECTION): KeyboardShortcutConfig['callback'] => (event) => {
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
SequenceEditorEventBusService.getInstance().emit(eventName, direction);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const emitVoid = (eventName: 'onDeleteBackward' | 'onGotoPosition' | 'onInsert' | 'onRedo' | 'onScrollPageDown' | 'onScrollPageUp' | 'onScrollToLineEnd' | 'onScrollToLineStart' | 'onUndo'): KeyboardShortcutConfig['callback'] => (event) => {
|
|
19
|
+
event.preventDefault();
|
|
20
|
+
SequenceEditorEventBusService.getInstance().emit(eventName);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const emitMutateSelection = (base: string): KeyboardShortcutConfig['callback'] => (event) => {
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
SequenceEditorEventBusService.getInstance().emit('onMutateSelection', base);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const KEYBOARD_SHORTCUTS: { [key: string]: KeyboardShortcut } = {
|
|
29
|
+
deleteBackward: {
|
|
30
|
+
callback: emitVoid('onDeleteBackward'),
|
|
31
|
+
description: 'Delete backward',
|
|
32
|
+
shortcut: { code: 'Backspace' },
|
|
33
|
+
},
|
|
34
|
+
deleteBase: {
|
|
35
|
+
callback: emitMutateSelection('-'),
|
|
36
|
+
description: 'Delete base',
|
|
37
|
+
shortcut: { key: '-' },
|
|
38
|
+
},
|
|
39
|
+
deleteSelection: {
|
|
40
|
+
callback: emitMutateSelection('-'),
|
|
41
|
+
description: 'Delete selection',
|
|
42
|
+
shortcut: { code: 'Delete' },
|
|
43
|
+
},
|
|
44
|
+
expandSelectionDown: {
|
|
45
|
+
callback: emitDirection('onExpandSelection', EDITOR_DIRECTION.DOWN),
|
|
46
|
+
description: 'Expand selection down',
|
|
47
|
+
shortcut: { code: 'ArrowDown', modifiers: [['Shift']] },
|
|
48
|
+
},
|
|
49
|
+
expandSelectionLeft: {
|
|
50
|
+
callback: emitDirection('onExpandSelection', EDITOR_DIRECTION.LEFT),
|
|
51
|
+
description: 'Expand selection left',
|
|
52
|
+
shortcut: { code: 'ArrowLeft', modifiers: [['Shift']] },
|
|
53
|
+
},
|
|
54
|
+
expandSelectionRight: {
|
|
55
|
+
callback: emitDirection('onExpandSelection', EDITOR_DIRECTION.RIGHT),
|
|
56
|
+
description: 'Expand selection right',
|
|
57
|
+
shortcut: { code: 'ArrowRight', modifiers: [['Shift']] },
|
|
58
|
+
},
|
|
59
|
+
expandSelectionUp: {
|
|
60
|
+
callback: emitDirection('onExpandSelection', EDITOR_DIRECTION.UP),
|
|
61
|
+
description: 'Expand selection up',
|
|
62
|
+
shortcut: { code: 'ArrowUp', modifiers: [['Shift']] },
|
|
63
|
+
},
|
|
64
|
+
gotoPosition: {
|
|
65
|
+
callback: emitVoid('onGotoPosition'),
|
|
66
|
+
description: 'Go to position',
|
|
67
|
+
shortcut: { key: 'g', modifiers: [['Meta'], ['Control']] },
|
|
68
|
+
},
|
|
69
|
+
insertGap: {
|
|
70
|
+
callback: emitVoid('onInsert'),
|
|
71
|
+
description: 'Insert gap',
|
|
72
|
+
shortcut: { code: 'Space' },
|
|
73
|
+
},
|
|
74
|
+
moveCellLeft: {
|
|
75
|
+
callback: emitDirection('onMoveCells', EDITOR_DIRECTION.LEFT),
|
|
76
|
+
description: 'Move cell left',
|
|
77
|
+
shortcut: { code: 'ArrowLeft', modifiers: [['Alt']] },
|
|
78
|
+
},
|
|
79
|
+
moveCellRight: {
|
|
80
|
+
callback: emitDirection('onMoveCells', EDITOR_DIRECTION.RIGHT),
|
|
81
|
+
description: 'Move cell right',
|
|
82
|
+
shortcut: { code: 'ArrowRight', modifiers: [['Alt']] },
|
|
83
|
+
},
|
|
84
|
+
moveRowDown: {
|
|
85
|
+
callback: emitDirection('onMoveRows', EDITOR_DIRECTION.DOWN),
|
|
86
|
+
description: 'Move row down',
|
|
87
|
+
shortcut: { code: 'ArrowDown', modifiers: [['Control'], ['Meta']] },
|
|
88
|
+
},
|
|
89
|
+
moveRowToEnd: {
|
|
90
|
+
callback: emitDirection('onMoveRowsEnd', EDITOR_DIRECTION.DOWN),
|
|
91
|
+
description: 'Move row to end',
|
|
92
|
+
shortcut: { code: 'ArrowDown', modifiers: [['Alt']] },
|
|
93
|
+
},
|
|
94
|
+
moveRowToStart: {
|
|
95
|
+
callback: emitDirection('onMoveRowsEnd', EDITOR_DIRECTION.UP),
|
|
96
|
+
description: 'Move row to start',
|
|
97
|
+
shortcut: { code: 'ArrowUp', modifiers: [['Alt']] },
|
|
98
|
+
},
|
|
99
|
+
moveRowUp: {
|
|
100
|
+
callback: emitDirection('onMoveRows', EDITOR_DIRECTION.UP),
|
|
101
|
+
description: 'Move row up',
|
|
102
|
+
shortcut: { code: 'ArrowUp', modifiers: [['Control'], ['Meta']] },
|
|
103
|
+
},
|
|
104
|
+
moveSelectionDown: {
|
|
105
|
+
callback: emitDirection('onMoveSelection', EDITOR_DIRECTION.DOWN),
|
|
106
|
+
description: 'Move selection down',
|
|
107
|
+
shortcut: { code: 'ArrowDown' },
|
|
108
|
+
},
|
|
109
|
+
moveSelectionLeft: {
|
|
110
|
+
callback: emitDirection('onMoveSelection', EDITOR_DIRECTION.LEFT),
|
|
111
|
+
description: 'Move selection left',
|
|
112
|
+
shortcut: { code: 'ArrowLeft' },
|
|
113
|
+
},
|
|
114
|
+
moveSelectionRight: {
|
|
115
|
+
callback: emitDirection('onMoveSelection', EDITOR_DIRECTION.RIGHT),
|
|
116
|
+
description: 'Move selection right',
|
|
117
|
+
shortcut: { code: 'ArrowRight' },
|
|
118
|
+
},
|
|
119
|
+
moveSelectionUp: {
|
|
120
|
+
callback: emitDirection('onMoveSelection', EDITOR_DIRECTION.UP),
|
|
121
|
+
description: 'Move selection up',
|
|
122
|
+
shortcut: { code: 'ArrowUp' },
|
|
123
|
+
},
|
|
124
|
+
redo: {
|
|
125
|
+
callback: emitVoid('onRedo'),
|
|
126
|
+
description: 'Redo',
|
|
127
|
+
shortcut: { key: 'z', modifiers: [['Meta', 'Shift'], ['Control', 'Shift']] },
|
|
128
|
+
},
|
|
129
|
+
scrollPageDown: {
|
|
130
|
+
callback: emitVoid('onScrollPageDown'),
|
|
131
|
+
description: 'Scroll page down',
|
|
132
|
+
shortcut: { code: 'PageDown' },
|
|
133
|
+
},
|
|
134
|
+
scrollPageUp: {
|
|
135
|
+
callback: emitVoid('onScrollPageUp'),
|
|
136
|
+
description: 'Scroll page up',
|
|
137
|
+
shortcut: { code: 'PageUp' },
|
|
138
|
+
},
|
|
139
|
+
scrollToLineEnd: {
|
|
140
|
+
callback: emitVoid('onScrollToLineEnd'),
|
|
141
|
+
description: 'Scroll to line end',
|
|
142
|
+
shortcut: { code: 'End' },
|
|
143
|
+
},
|
|
144
|
+
scrollToLineStart: {
|
|
145
|
+
callback: emitVoid('onScrollToLineStart'),
|
|
146
|
+
description: 'Scroll to line start',
|
|
147
|
+
shortcut: { code: 'Home' },
|
|
148
|
+
},
|
|
149
|
+
undo: {
|
|
150
|
+
callback: emitVoid('onUndo'),
|
|
151
|
+
description: 'Undo',
|
|
152
|
+
shortcut: { key: 'z', modifiers: [['Meta'], ['Control']] },
|
|
153
|
+
},
|
|
154
|
+
};
|