aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
diff options
context:
space:
mode:
authorNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2024-06-15 00:08:00 -0400
committerNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2024-06-15 00:08:00 -0400
commitc472f9844ed2806f7965713cf618363210e37de1 (patch)
tree6be42f28db78837a0305b310141e94de709a18b2 /src/client/views/collections/collectionSchema/SchemaTableCell.tsx
parent9866828b7b530b3f748509c55e3bb2c76dadce49 (diff)
text highlighting works with 'this.' format
Diffstat (limited to 'src/client/views/collections/collectionSchema/SchemaTableCell.tsx')
-rw-r--r--src/client/views/collections/collectionSchema/SchemaTableCell.tsx28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
index 26dc9c3c2..69880b280 100644
--- a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
@@ -81,13 +81,11 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
makeObservable(this);
}
- get isDefault(){
- return SchemaColumnHeader.isDefaultField(this._props.fieldKey);
- }
+ get docIndex(){return DocumentView.getDocViewIndex(this._props.Document);} // prettier-ignore
- get lockedInteraction(){
- return (this.isDefault || this._props.Document._lockedSchemaEditing);
- }
+ get isDefault(){return SchemaColumnHeader.isDefaultField(this._props.fieldKey);} // prettier-ignore
+
+ get lockedInteraction(){return (this.isDefault || this._props.Document._lockedSchemaEditing);} // prettier-ignore
get backgroundColor(){
if (this.lockedInteraction){
@@ -141,13 +139,12 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
const pointerEvents: 'all' | 'none' = !readOnly && isRowActive() ? 'all' : 'none';
return { color, textDecoration, fieldProps, cursor, pointerEvents };
}
-
- // openContextMenu = () => {
- // const cm = ContextMenu.Instance;
- // cm.clearItems();
-
- // }
+ adjustedHighlight = (field: string) => {
+ const pattern = /\bthis.\b/g;
+ const modField = field.replace(pattern, `d${this.docIndex}.`);
+ this._props.highlightCells(modField);
+ }
// parses a field from the "idToDoc(####)" format to DocumentId (d#) format for readability
cleanupField = (field: string) => {
@@ -158,6 +155,11 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
while ((matches = idPattern.exec(field)) !== null) {results.push([matches[0], matches[1].replace(/"/g, '')]); }
results.forEach((idFuncPair) => {modField = modField.replace(idFuncPair[0], 'd' + (DocumentView.getDocViewIndex(IdToDoc(idFuncPair[1]))).toString());})
if (modField.charAt(modField.length - 1) === ';') modField = modField.substring(0, modField.length - 1);
+
+ const selfRefPattern = `d${this.docIndex}.${this._props.fieldKey}`
+ const selfRefRegX = RegExp(selfRefPattern, 'g');
+ if (selfRefRegX.exec(modField) !== null) { return 'Invalid'}
+
return modField;
}
@@ -175,7 +177,7 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
pointerEvents: this.lockedInteraction ? 'none' : pointerEvents,
}}>
<EditableView
- highlightCells={this._props.highlightCells}
+ highlightCells={this.adjustedHighlight}
ref={r => selectedCell(this._props) && this._props.autoFocus && r?.setIsFocused(true)}
oneLine={this._props.oneLine}
allowCRs={this._props.allowCRs}