-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2185 from tf/info-table-2
Improve editable table
- Loading branch information
Showing
10 changed files
with
1,433 additions
and
313 deletions.
There are no files selected for viewing
960 changes: 950 additions & 10 deletions
960
...types/scrolled/package/spec/frontend/inlineEditing/EditableTable/withFixedColumns-spec.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
302 changes: 0 additions & 302 deletions
302
entry_types/scrolled/package/src/frontend/inlineEditing/EditableTable/withFixedColumns.js
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...ackage/src/frontend/inlineEditing/EditableTable/withFixedColumns/handleTableNavigation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.