Skip to content

Conversation

@smsochneg
Copy link
Contributor

Improvement for tabs removement behavior.
When user presses backspace in the beginning of tab title - it removes current tab and panel associated with it.
Also activating a tab next to it and panel associated with it

@smsochneg smsochneg requested a review from d3m1d0v January 19, 2023 08:44
allowGapCursor: true,
attrs: {class: {default: 'unknown'}},
content: 'yfm_tabs_list* yfm_tab_panel*',
content: 'yfm_tabs_list{1,} yfm_tab_panel{1,}',
Copy link
Member

@d3m1d0v d3m1d0v Jan 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
content: 'yfm_tabs_list{1,} yfm_tab_panel{1,}',
content: 'yfm_tabs_list yfm_tab_panel+',

Comment on lines 78 to 89
.addPlugin(() =>
keymap({
Backspace: tabPanelBackspace,
}),
)
.addPlugin(() =>
keymap({
Backspace: tabBackspace,
}),
);
Copy link
Member

@d3m1d0v d3m1d0v Jan 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.addPlugin(() =>
keymap({
Backspace: tabPanelBackspace,
}),
)
.addPlugin(() =>
keymap({
Backspace: tabBackspace,
}),
);
.addKeymap(() => ({
Backspace: chainCommands(tabPanelBackspace, tabBackspace),
}));

@smsochneg smsochneg force-pushed the tabs-remove-improvement branch from 0b52b82 to 0f85378 Compare January 20, 2023 13:04
@yc-ui-bot
Copy link
Contributor

Preview is ready.

Comment on lines 15 to 24
const tabPanel = findParentNodeOfType(tabPanelType(state.schema))(state.selection);

if (
tabPanel &&
state.selection.from === tabPanel.pos + 2 &&
state.selection.to === state.selection.from
) {
return true;
}
return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const tabPanel = findParentNodeOfType(tabPanelType(state.schema))(state.selection);
if (
tabPanel &&
state.selection.from === tabPanel.pos + 2 &&
state.selection.to === state.selection.from
) {
return true;
}
return false;
const $cursor = get$Cursor(state.selection);
if($cursor?.node($cursor.depth - 1).type === tabPanelType(state.schema) && $cursor.start($cursor.depth - 1) === $cursor.pos - 1) {
return true;
}
return false;

@smsochneg smsochneg force-pushed the tabs-remove-improvement branch from 0f85378 to ebdca47 Compare January 23, 2023 19:32
@smsochneg smsochneg force-pushed the tabs-remove-improvement branch from ebdca47 to f21f6f5 Compare January 24, 2023 19:38
@smsochneg smsochneg merged commit a0404b1 into master Jan 25, 2023
@smsochneg smsochneg deleted the tabs-remove-improvement branch January 25, 2023 11:07
makhnatkin pushed a commit that referenced this pull request May 28, 2024
feat: improvements for tabs removement
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.

4 participants