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

Improve editable table #2185

Merged
merged 9 commits into from
Dec 18, 2024

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion entry_types/scrolled/package/src/frontend/EditableTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export function createRenderElement({labelScaleCategory, valueScaleCategory}) {
<Text scaleCategory={valueScaleCategory}>
{children}
</Text>

</td>
);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {Editor, Node, Path, Range, Transforms} from 'slate';

import {Cell} from './helpers';

export function handleTableNavigation(editor, event) {
const {selection} = editor;

if (selection && Range.isCollapsed(selection)) {
const cellMatch = Cell.match(editor);

if (cellMatch) {
const [, cellPath] = cellMatch;
const rowPath = cellPath.slice(0, -1);

if (event.key === 'ArrowUp') {
event.preventDefault();

if (rowPath[rowPath.length - 1] > 0) {
const previousRowPath = Path.previous(rowPath);
const targetPath = [...previousRowPath, cellPath[cellPath.length - 1]];

Transforms.select(editor, Editor.start(editor, targetPath));
}
} else if (event.key === 'ArrowDown') {
event.preventDefault();

const nextRowPath = Path.next(rowPath);
const targetPath = [...nextRowPath, cellPath[cellPath.length - 1]];

if (Node.has(editor, targetPath)) {
Transforms.select(editor, Editor.start(editor, targetPath));
}
}
}
}
}
Loading
Loading