-
Notifications
You must be signed in to change notification settings - Fork 167
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
Allow Shift-Alt-<Left|Right> to indent/outdent list #1444
Conversation
packages/roosterjs-editor-plugins/lib/plugins/ContentEdit/features/listFeatures.ts
Outdated
Show resolved
Hide resolved
packages/roosterjs-editor-plugins/lib/plugins/ContentEdit/features/listFeatures.ts
Show resolved
Hide resolved
) => { | ||
const isRTL = | ||
event.rawEvent.keyCode !== Keys.TAB && | ||
getComputedStyle(editor.getElementAtCursor(), 'direction') == 'rtl'; |
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.
getComputedStyle() is kind of heavy. So we should only call it when we really need to.
In this case, it means when we know that it is LEFT/RIGHT key with SHIFT key pressed, and there is list, then finally we can check if it is RTL. So that this function is only called when really need.
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.
Shift key check is handled by shouldHandleIndentationEvent
, getComputedStyle doesn't get called if keycode is TAB, and this function is only called when shouldHandleIndentationEvent
returns true, which already verifies if cursor is inside a list
Merges the following ContentEdit features from
listFeatures.ts
:indentWhenTab
outdentWhenShiftTab
Into a new
outdentIndentListItem
feature which also allows Shift-Alt-Right to perform the action of indenting and Shift-Alt-Left for outdenting