From c472f9844ed2806f7965713cf618363210e37de1 Mon Sep 17 00:00:00 2001 From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> Date: Sat, 15 Jun 2024 00:08:00 -0400 Subject: text highlighting works with 'this.' format --- .../collectionSchema/SchemaTableCell.tsx | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/client/views/collections/collectionSchema/SchemaTableCell.tsx') 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 { - // 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 {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 selectedCell(this._props) && this._props.autoFocus && r?.setIsFocused(true)} oneLine={this._props.oneLine} allowCRs={this._props.allowCRs} -- cgit v1.2.3-70-g09d2