+
{children}
@@ -87,7 +88,7 @@ export function createRenderElement({labelScaleCategory, valueScaleCategory}) {
);
default:
return (
- |
+ |
{children}
@@ -96,3 +97,7 @@ export function createRenderElement({labelScaleCategory, valueScaleCategory}) {
}
}
}
+
+function cellAttributes(element) {
+ return utils.isBlankEditableTextValue([element]) ? {'data-blank': ''} : {};
+}
diff --git a/entry_types/scrolled/package/src/frontend/inlineEditing/EditableTable/withFixedColumns/handleTableNavigation.js b/entry_types/scrolled/package/src/frontend/inlineEditing/EditableTable/withFixedColumns/handleTableNavigation.js
index 8b3d6a3a4..8f66016ff 100644
--- a/entry_types/scrolled/package/src/frontend/inlineEditing/EditableTable/withFixedColumns/handleTableNavigation.js
+++ b/entry_types/scrolled/package/src/frontend/inlineEditing/EditableTable/withFixedColumns/handleTableNavigation.js
@@ -12,16 +12,19 @@ export function handleTableNavigation(editor, event) {
const [, cellPath] = cellMatch;
const rowPath = cellPath.slice(0, -1);
- if (event.key === 'ArrowUp') {
+ if (event.key === 'ArrowUp' && Cell.inFirstLine(editor, selection.anchor)) {
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));
+ Transforms.select(
+ editor,
+ Cell.getPointAtStartOfLastLine(editor, Editor.start(editor, targetPath).path)
+ );
}
- } else if (event.key === 'ArrowDown') {
+ } else if (event.key === 'ArrowDown' && Cell.inLastLine(editor, selection.anchor)) {
event.preventDefault();
const nextRowPath = Path.next(rowPath);
diff --git a/entry_types/scrolled/package/src/frontend/inlineEditing/EditableTable/withFixedColumns/helpers.js b/entry_types/scrolled/package/src/frontend/inlineEditing/EditableTable/withFixedColumns/helpers.js
index cc563e721..e68c4a3c5 100644
--- a/entry_types/scrolled/package/src/frontend/inlineEditing/EditableTable/withFixedColumns/helpers.js
+++ b/entry_types/scrolled/package/src/frontend/inlineEditing/EditableTable/withFixedColumns/helpers.js
@@ -1,4 +1,4 @@
-import {Editor} from 'slate';
+import {Editor, Node} from 'slate';
export const Row = {
match(editor) {
@@ -49,6 +49,34 @@ export const Cell = {
});
return cellMatch;
+ },
+
+ inFirstLine(editor, point) {
+ const [node] = Editor.node(editor, point.path);
+ const text = Node.string(node);
+
+ const firstLineBreak = text.indexOf('\n');
+
+ return firstLineBreak === -1 || point.offset <= firstLineBreak;
+ },
+
+ inLastLine(editor, point) {
+ const [node] = Editor.node(editor, point.path);
+ const text = Node.string(node);
+
+ const lastLineBreak = text.lastIndexOf('\n');
+
+ return lastLineBreak === -1 || point.offset > lastLineBreak;
+ },
+
+ getPointAtStartOfLastLine(editor, cellPath) {
+ const [node] = Editor.node(editor, cellPath);
+ const text = Node.string(node);
+
+ const lastLineBreak = text.lastIndexOf('\n');
+ const offset = lastLineBreak === -1 ? 0 : lastLineBreak + 1;
+
+ return {path: cellPath, offset};
}
}
|