aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/util/SelectionManager.ts1
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.tsx26
-rw-r--r--src/client/views/collections/collectionSchema/SchemaCellField.tsx11
-rw-r--r--src/client/views/collections/collectionSchema/SchemaRowBox.tsx3
-rw-r--r--src/client/views/collections/collectionSchema/SchemaTableCell.tsx8
5 files changed, 32 insertions, 17 deletions
diff --git a/src/client/util/SelectionManager.ts b/src/client/util/SelectionManager.ts
index 0b942116c..fc494583f 100644
--- a/src/client/util/SelectionManager.ts
+++ b/src/client/util/SelectionManager.ts
@@ -58,6 +58,7 @@ export class SelectionManager {
});
public static DeselectAll = (except?: Doc): void => {
+
const found = this.Instance.SelectedViews.find(dv => dv.Document === except);
runInAction(() => {
if (LinkManager.Instance) {
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
index c3dc4bad6..3b5a32ca7 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
@@ -634,6 +634,7 @@ export class CollectionSchemaView extends CollectionSubView() {
@action
clearSelection = () => {
+ if (this._referenceSelectMode.enabled) return;
DocumentView.DeselectAll();
this.deselectAllCells();
};
@@ -651,20 +652,19 @@ export class CollectionSchemaView extends CollectionSubView() {
}
};
- @action
- selectCell = (doc: Doc | undefined, col: number, shiftKey: boolean, ctrlKey: boolean) => {
+ selectReference = (doc: Doc | undefined, col: number) => {
if (!doc) return;
+ const docIndex = DocumentView.getDocViewIndex(doc);
+ const field = this.columnKeys[col];
+ const refToAdd = `d${docIndex}.${field}`
+ const editedField = this._referenceSelectMode.currEditing ? this._referenceSelectMode.currEditing as SchemaCellField : null;
+ editedField?.appendText(refToAdd);
+ editedField?.setupRefSelect(false);
+ return;
+ }
- if (this._referenceSelectMode.enabled) {
- const docIndex = DocumentView.getDocViewIndex(doc);
- const field = this.columnKeys[col];
- const refToAdd = `d${docIndex}.${field}`
- const editedField = this._referenceSelectMode.currEditing ? this._referenceSelectMode.currEditing as SchemaCellField : null;
- editedField?.appendText(refToAdd);
- editedField?.setupRefSelect(false);
- return;
- }
-
+ @action
+ selectCell = (doc: Doc, col: number, shiftKey: boolean, ctrlKey: boolean) => {
this.closeColumnMenu();
if (!shiftKey && !ctrlKey) this.clearSelection();
!this._selectedCells && (this._selectedCells = []);
@@ -687,12 +687,14 @@ export class CollectionSchemaView extends CollectionSubView() {
@action
deselectCell = (doc: Doc) => {
+ console.log('single deselect called')
this._selectedCells && (this._selectedCells = this._selectedCells.filter(d => d !== doc));
if (this.rowIndex(doc) === this._lowestSelectedIndex) this._lowestSelectedIndex = Math.min(...this._selectedDocs.map(d => this.rowIndex(d)));
};
@action
deselectAllCells = () => {
+ console.log('deselectall called')
this._selectedCells = [];
this._lowestSelectedIndex = -1;
};
diff --git a/src/client/views/collections/collectionSchema/SchemaCellField.tsx b/src/client/views/collections/collectionSchema/SchemaCellField.tsx
index 84b4d3462..06d3926a8 100644
--- a/src/client/views/collections/collectionSchema/SchemaCellField.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaCellField.tsx
@@ -62,6 +62,7 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
() => this._editing,
editing => {
if (editing) {
+ if (this.lastChar !== '+') this.setupRefSelect(false);
setTimeout(() => {
if (this._inputref?.innerText.startsWith('=') || this._inputref?.innerText.startsWith(':=')) {
this._overlayDisposer?.();
@@ -145,8 +146,8 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
@action
appendText = (text: string) => {
- this._unrenderedContent += text;
- this.setContent(this._unrenderedContent);
+ const newText = this._unrenderedContent.concat(text);
+ this.onChange(undefined, newText);
}
@action
@@ -209,9 +210,9 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
//if (contains self-ref pattern)
};
- onChange = (e: FormEvent<HTMLDivElement>) => {
+ onChange = (e: FormEvent<HTMLDivElement> | undefined, newText?: string) => {
const prevVal = this._unrenderedContent;
- const targVal = e.currentTarget.innerText;
+ const targVal = newText ?? e!.currentTarget.innerText; // TODO: bang
if (!(targVal.startsWith(':=') || targVal.startsWith('='))) {
this._overlayDisposer?.();
this._overlayDisposer = undefined;
@@ -319,7 +320,7 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
className='schemaField-editing'
ref={r => { this._inputref = r; }}
style={{ cursor: 'text', outline: 'none', overflow: 'auto', minHeight: `min(100%, ${(this._props.GetValue()?.split('\n').length || 1) * 15})`, minWidth: 20, }}
- onBlur={e => this.finalizeEdit(false, true, false)}
+ onBlur={e => {this._props.refSelectModeInfo.enabled ? setTimeout(() => {this.setIsFocused(true)}, 1000) : this.finalizeEdit(false, true, false)}}
autoFocus
onInput={this.onChange}
onKeyDown={this.onKeyDown}
diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
index b15804d41..3f5c2a90e 100644
--- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
@@ -23,6 +23,7 @@ import { CollectionFreeFormView } from '../collectionFreeForm';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { IconProp } from '@fortawesome/fontawesome-svg-core';
import { infoState } from '../collectionFreeForm/CollectionFreeFormInfoState';
+import { TbShieldX } from 'react-icons/tb';
interface SchemaRowBoxProps extends FieldViewProps {
rowIndex: number;
@@ -127,6 +128,7 @@ export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() {
columnWidth = computedFn((index: number) => () => this.schemaView?.displayColumnWidths[index] ?? CollectionSchemaView._minColWidth);
computeRowIndex = () => this.schemaView?.rowIndex(this.Document);
highlightCells = (text: string) => this.schemaView?.highlightCells(text);
+ selectReference = (doc: Doc, col: number) => {this.schemaView.selectReference(doc, col)}
eqHighlightFunc = (text: string) => {
const info = this.schemaView.findCellRefs(text);
const cells: HTMLDivElement[] = [];
@@ -175,6 +177,7 @@ export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() {
<div className="row-cells">
{this.schemaView?.columnKeys?.map((key, index) => (
<SchemaTableCell
+ selectReference={this.selectReference}
refSelectModeInfo={this.refSelectModeInfo}
func={this.eqHighlightFunc}
equationHighlightRef={this.schemaView._cellHighlightColors}
diff --git a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
index 75b31315e..ef46c44da 100644
--- a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
@@ -65,6 +65,7 @@ export interface SchemaTableCellProps {
equationHighlightRef: ObservableMap<HTMLDivElement, string>;
func: (text: string) => HTMLDivElement[] | [];
refSelectModeInfo: {enabled: boolean, currEditing: SchemaCellField | undefined};
+ selectReference: (doc: Doc, col: number) => void;
}
function selectedCell(props: SchemaTableCellProps) {
@@ -254,6 +255,13 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
className="schema-table-cell"
onContextMenu={e => StopEvent(e)}
onPointerDown={action(e => {
+ if (this._props.refSelectModeInfo.enabled && !selectedCell(this._props)){
+ e.stopPropagation();
+ e.preventDefault();
+ this._props.selectReference(this._props.Document, this._props.col);
+ return;
+ }
+
const shift: boolean = e.shiftKey;
const ctrl: boolean = e.ctrlKey;
if (this._props.isRowActive?.()) {