diff options
author | mehekj <mehek.jethani@gmail.com> | 2023-02-28 17:44:16 -0500 |
---|---|---|
committer | mehekj <mehek.jethani@gmail.com> | 2023-02-28 17:44:16 -0500 |
commit | 027c89584d087ada9d45a46cb620b157ae29d0b9 (patch) | |
tree | 5282327e88058c7b503614f665ccc74e367482ea /src | |
parent | d7cb4929e437f2a03336e21b16aa4fb0cebf5ebe (diff) |
arrow key movement
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/collections/collectionSchema/CollectionSchemaView.tsx | 46 | ||||
-rw-r--r-- | src/client/views/collections/collectionSchema/SchemaRowBox.tsx | 2 |
2 files changed, 20 insertions, 28 deletions
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx index 0cf5a1ed9..a0e1ae8b2 100644 --- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx +++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx @@ -125,32 +125,26 @@ export class CollectionSchemaView extends CollectionSubView() { @action onKeyDown = (e: KeyboardEvent) => { - // if (this._selectedDocs.size > 0) { - // if (e.key == 'ArrowDown') { - // const lastDoc = Array.from(this._selectedDocs.values()).lastElement(); - // const lastIndex = this.childDocs.indexOf(lastDoc); - // if (lastIndex >= 0 && lastIndex < this.childDocs.length - 1) { - // this._selectedDocs.clear(); - // const newDoc = this.childDocs[lastIndex + 1]; - // this._selectedDocs.add(newDoc); - // const presDocView = DocumentManager.Instance.getDocumentView(this.rootDoc); - // if (presDocView) SelectionManager.SelectView(presDocView, false); - // SelectionManager.SelectSchemaViewDoc(newDoc); - // this._previewDoc = newDoc; - // } - // } - // if (e.key == 'ArrowUp') { - // const firstDoc = Array.from(this._selectedDocs.values())[0]; - // const firstIndex = this.childDocs.indexOf(firstDoc); - // if (firstIndex > 0) { - // this._selectedDocs.clear(); - // const newDoc = this.childDocs[firstIndex - 1]; - // this._selectedDocs.add(newDoc); - // SelectionManager.SelectSchemaViewDoc(newDoc); - // this._previewDoc = newDoc; - // } - // } - // } + if (this._selectedDocs.size > 0) { + if (e.key == 'ArrowDown') { + const lastDoc = Array.from(this._selectedDocs.values()).lastElement(); + const lastIndex = this.rowIndex(lastDoc); + if (lastIndex >= 0 && lastIndex < this.childDocs.length - 1) { + !e.shiftKey && this.clearSelection(); + const newDoc = this.childDocs[lastIndex + 1]; + this.addDocToSelection(newDoc, e.shiftKey, lastIndex + 1); + } + } + if (e.key == 'ArrowUp') { + const firstDoc = Array.from(this._selectedDocs.values())[0]; + const firstIndex = this.rowIndex(firstDoc); + if (firstIndex > 0 && firstIndex < this.childDocs.length) { + !e.shiftKey && this.clearSelection(); + const newDoc = this.childDocs[firstIndex - 1]; + this.addDocToSelection(newDoc, e.shiftKey, firstIndex - 1); + } + } + } }; @undoBatch diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx index 0e7b0fa16..0ed5f2df4 100644 --- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx +++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx @@ -38,8 +38,6 @@ export class SchemaRowBox extends ViewBoxBaseComponent<FieldViewProps>() { return this.schemaView?.rowIndex(this.rootDoc) ?? -1; } - // isSelected = () => this.props.selectedDocs.has(this.props.Document); - @action onRowPointerDown = (e: React.PointerEvent) => { e.stopPropagation(); |