Skip to content
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

Merged
merged 10 commits into from
Dec 7, 2022

Conversation

ianeli1
Copy link
Member

@ianeli1 ianeli1 commented Nov 30, 2022

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

) => {
const isRTL =
event.rawEvent.keyCode !== Keys.TAB &&
getComputedStyle(editor.getElementAtCursor(), 'direction') == 'rtl';
Copy link
Collaborator

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.

Copy link
Member Author

@ianeli1 ianeli1 Dec 2, 2022

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

@ianeli1 ianeli1 merged commit b6685d7 into master Dec 7, 2022
@JiuqingSong JiuqingSong deleted the u/ianeli/shift-alt-lr-indent branch September 8, 2023 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants