1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-07 21:47:02 +09:00

JS-4328: fix

This commit is contained in:
Andrew Simachev 2025-06-05 17:25:09 +02:00
parent ffd8987bb5
commit 665d6f7394
No known key found for this signature in database
GPG key ID: 1DFE44B21443F0EF
5 changed files with 26 additions and 18 deletions

View file

@ -119,8 +119,8 @@ const getSections = () => {
{ name: translate('popupShortcutNavigationPage5'), keys: [ cmdKey, 'arrowright' ] },
{ name: translate('popupShortcutNavigationPage6'), keys: [ cmdKey, 'arrowup' ] },
{ name: translate('popupShortcutNavigationPage7'), keys: [ cmdKey, 'arrowdown' ] },
{ id: 'moveSelectionUp', name: translate('popupShortcutNavigationPage8'), keys: [ cmdKey, 'shift', 'arrowup' ] },
{ id: 'moveSelectionDown', name: translate('popupShortcutNavigationPage11'), keys: [ cmdKey, 'shift', 'arrowdown' ] },
{ id: 'moveSelectionUp', name: translate('popupShortcutNavigationPage8') + ' / ' + translate('blockTableShortcutRowMoveUp'), keys: [ cmdKey, 'shift', 'arrowup' ], description: translate('blockTableShortcutRowMoveUpDesc') },
{ id: 'moveSelectionDown', name: translate('popupShortcutNavigationPage11') + ' / ' + translate('blockTableShortcutRowMoveDown'), keys: [ cmdKey, 'shift', 'arrowdown' ], description: translate('blockTableShortcutRowMoveDownDesc') },
{ name: translate('popupShortcutNavigationPage10'), keys: [ cmdKey, 'enter' ] },
{ id: 'turnBlock0', name: translate('popupShortcutEditorTurn0'), keys: [ cmdKey, '0' ], noEdit: true },

View file

@ -790,18 +790,20 @@ const BlockTable = observer(class BlockTable extends React.Component<I.BlockComp
keyboard.shortcut('moveSelectionUp, moveSelectionDown', e, (pressed: string) => {
e.preventDefault();
const dir = pressed.match('Up') ? -1 : 1;
const dir = pressed == 'moveSelectionUp' ? -1 : 1;
const position = dir < 0 ? I.BlockPosition.Top : I.BlockPosition.Bottom;
const { rows } = this.getData();
const idx = rows.findIndex(row => row.id === rowId);
const nextIdx = idx + dir;
if (idx === -1 || nextIdx < 0 || nextIdx >= rows.length) return;
if ((idx < 0) || (nextIdx < 0) || (nextIdx >= rows.length)) {
return;
};
const nextRow = rows[nextIdx];
if (nextRow && !nextRow.content.isHeader) {
const position = dir < 0 ? I.BlockPosition.Top : I.BlockPosition.Bottom;
this.onSortEndRow(rowId, nextRow.id, position);
}
};
ret = true;
});
@ -1193,7 +1195,7 @@ const BlockTable = observer(class BlockTable extends React.Component<I.BlockComp
const { rootId } = this.props;
C.BlockTableColumnMove(this.props.rootId, id, targetId, position);
C.BlockTableColumnMove(rootId, id, targetId, position);
$('body').removeClass('grab');
keyboard.disableSelection(false);

View file

@ -1009,12 +1009,10 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
// Tab, indent block
keyboard.shortcut('indent, outdent', e, (pressed: string) => {
const isShift = pressed.match('shift') ? true : false;
if (isInsideTable) {
this.onArrowHorizontal(e, text, pressed, { from: length, to: length }, length, props);
} else {
this.onTabBlock(e, range, isShift);
this.onTabBlock(e, range, pressed == 'outdent');
};
});
@ -1059,7 +1057,7 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
return;
};
const shift = pressed.match('shift');
const shift = pressed == 'outdent';
const first = S.Block.getLeaf(rootId, ids[0]);
if (!first) {
return;
@ -1096,7 +1094,7 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
const { rootId, isPopup } = this.props;
const selection = S.Common.getRef('selectionProvider');
const dir = pressed.match(Key.up) ? -1 : 1;
const dir = pressed == 'moveSelectionUp' ? -1 : 1;
const ids = selection?.get(I.SelectType.Block, false) || [];
if (!ids.length) {
@ -1167,7 +1165,7 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
return;
};
const dir = pressed.match(Key.up) ? -1 : 1;
const dir = pressed == 'moveSelectionUp' ? -1 : 1;
let next = S.Block.getNextBlock(rootId, block.id, dir, it => (
!it.isIcon() &&
@ -1618,9 +1616,13 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
const { rootId } = this.props;
const { isInsideTable } = props;
const block = S.Block.getLeaf(rootId, focused);
const withTab = pressed.match(Key.tab);
const withTab = [ 'indent', 'outdent' ].includes(pressed);
const isRtl = U.Common.checkRtl(text);
const dir = (pressed.match([ Key.left, Key.shift ].join('|')) ? -1 : 1) * (isRtl ? -1 : 1);
let dir = (pressed == 'outdent') || (pressed == Key.left) ? -1 : 1;
if (isRtl) {
dir = -dir;
};
if (!block) {
return;

View file

@ -80,9 +80,9 @@ const Vault = observer(forwardRef<VaultRefProps>((props, ref) => {
pressed.current.add(key);
};
keyboard.shortcut('nextSpace, prevSpace', e, pressed => {
keyboard.shortcut('prevSpace, nextSpace', e, pressed => {
checkKeyUp.current = true;
onArrow(pressed.match('shift') ? -1 : 1);
onArrow(pressed == 'prevSpace' ? -1 : 1);
if (sidebar.isAnimating) {
return;

View file

@ -1633,6 +1633,10 @@ class Keyboard {
keys = item.split('+');
};
if (!keys.length) {
continue;
};
keys.sort();
for (const k of keys) {
@ -1647,7 +1651,7 @@ class Keyboard {
const check = U.Common.arrayUnique(pressed).sort().join('+');
if (check == keys.join('+')) {
res = check;
res = item;
};
};