Skip to content

Commit

Permalink
Merge pull request #2185 from tf/info-table-2
Browse files Browse the repository at this point in the history
Improve editable table
  • Loading branch information
tf authored Dec 18, 2024
2 parents 4eccad2 + 78b51ea commit ea42a19
Show file tree
Hide file tree
Showing 10 changed files with 1,433 additions and 313 deletions.

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

0 comments on commit ea42a19

Please sign in to comment.