New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add vim mode1 #433
Add vim mode1 #433
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Режим редактора должен персиститься либо на сервер, либо в local storage. Фича не сильно важная поэтому в local storage лучше. Для этого надо сделать persisted reducer через redux-persist.
Могу помочь с этим
return ( | ||
<div style={{ position: 'relative' }}> | ||
<div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Может этот div уже не нужен?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У нас уже есть бекенд код для персистинга.
Надо просто его завести)
Как и язык
this.vimMode = initVimMode(this.editor, this.statusBarRef.current); | ||
} else if (!isVimMode && prevProps.isVimMode) { | ||
this.vimMode.dispose(); | ||
this.statusBarRef.current.innerHTML = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Что такое statusBar? Почему ему надо обнулять html?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
показывает какой режим включен в виме
обнуление вообще делается внутри monaco-vim при отключение режима, но видимо не очень дружит он с реактом, поэтому пришлось вынести
@@ -98,19 +111,21 @@ class Editor extends PureComponent { | |||
enabled: false, | |||
}, | |||
}; | |||
const editorHeightWithVimMode = isVimMode ? editorHeight.replace(/[a-z]/g, '') - this.statusBarHeight : editorHeight; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Больно как-то регуляркой выбирать числа, может можно проще? Тут, конечно, глядеть надо, так непонятно под што подстраивается высота
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ага, можно) погорячился
добавил redux-persist, крутая штука) не знал что так можно |
import RootContainer from './containers/RootContainer'; | ||
import createStore from './lib/configureStore'; | ||
import reducers from './reducers'; | ||
import GameList from './containers/GameList'; | ||
|
||
|
||
const persistConfig = { | ||
key: 'root', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не ставь на root, ставь только на нужный редьюсер.
пример:
const { auth: authReducer, ...otherReducers } = reducers;
const authPersistConfig = {
key: 'auth',
storage,
};
const rootReducer = combineReducers({
auth: persistReducer(authPersistConfig, authReducer),
...otherReducers,
});
@@ -159,3 +159,5 @@ export const currentChatUserSelector = (state) => { | |||
const currentUser = _.find(chatUsersSelector(state), { id: currentUserId }); | |||
return currentUser; | |||
}; | |||
|
|||
export const editorVimModeSelector = userId => state => _.get(editorDataSelector(userId)(state), 'isVimMode', false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
По поводу дефолтных значений, они у тебя в селекторе и в компоненте, а достаточно в начальное значение редьюсеру прописать и у тебя всегда будет будет валидное значение и нигде дефолты не нужны
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
там не очень то плоский редьюсер у редактора
const initialState = {
meta: {},
text: {},
};
не хочется там копаться и не известно же какие userId будут
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в этот редьюсер не надо ничего класть вообще кроме данных с сервера, ну прикинь по сокету прилетают данные, а еще есть часть которая за совершенно другое отвечает и кладется в локальное хранилище. Для режима редактора нужен отдельный редьюсер. Сделай отдельный редьюсер в корне стейта для этого, в ширь стейт можно сколько угодно растить и никто не проиграет от этого, ничего страшного что будет в пункта рядом, которые относятся к стейту редактора, зато сложность упадет в разы
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ок, понял, завтра сделаю
добавьте еще емакс моде и выбор темы dark/light |
Темы я бы в отдельном по сделал. |
Можно в отдельном ПО |
отдельное ПО? |
ПО === PR |
@skhrv пингани, когда будет готово |
@@ -29,3 +29,6 @@ export const updateCheckStatus = createAction('UPDATE_CHECK_STATUS'); | |||
|
|||
export const compressEditorHeight = createAction('COMPRESS_EDITOR_HEIGHT'); | |||
export const expandEditorHeight = createAction('EXPAND_EDITOR_HEIGHT'); | |||
|
|||
export const toggleVimMode = createAction('MODE_VIM_TOGGLE'); | |||
export const toggleDefaultMode = createAction('MODE_DEFAULT_TOGGLE'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мне кажется лучше сделать один action с параметром режима, типа setEditorMode(mode: string)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
да, исправил
type="button" | ||
className="dropdown-item btn rounded-0" | ||
key={type} | ||
onClick={() => action()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onClick={() => action()}
-> onClick={action}
Надо конфликты порешать |
* add VimMode * fix buttons in toolbar * improve Editor.jsx * add redux-persist * add padding for vim statusBar * fix persisted reducer * add EditorsModeToggle * add editorUI reducer * refactor * fix editorsHeight * fix async load not included syntax for spectators * refactor
No description provided.