From b28af64893c6dd54eb3b30341a8eca2575ab50d8 Mon Sep 17 00:00:00 2001 From: Timo Date: Wed, 2 Dec 2020 11:43:35 +0200 Subject: [PATCH] editor search --- .../dictionary-overview-screen.component.html | 14 ++++++ .../dictionary-overview-screen.component.scss | 25 +++++++++- .../dictionary-overview-screen.component.ts | 47 +++++++++++++++++-- apps/red-ui/src/assets/i18n/en.json | 1 + apps/red-ui/src/assets/styles/red-editor.scss | 6 +++ 5 files changed, 88 insertions(+), 5 deletions(-) diff --git a/apps/red-ui/src/app/screens/admin/dictionary-overview-screen/dictionary-overview-screen.component.html b/apps/red-ui/src/app/screens/admin/dictionary-overview-screen/dictionary-overview-screen.component.html index 62c22a0b4..75ba45ef2 100644 --- a/apps/red-ui/src/app/screens/admin/dictionary-overview-screen/dictionary-overview-screen.component.html +++ b/apps/red-ui/src/app/screens/admin/dictionary-overview-screen/dictionary-overview-screen.component.html @@ -39,6 +39,20 @@
+
+ + +
+
+ +
+
+ + + +
+
+
{ + this.editorComponent.getEditor().getSession().removeMarker(am); + }); + this.activeSearchMarkers = []; + + for (let position of positions) { + this.activeSearchMarkers.push( + this.editorComponent + .getEditor() + .getSession() + .addMarker(new Range(position.row, position.column, position.row, position.column + position.length), 'search-marker', 'text') + ); + } + } + + private _getSearchPositions() { + return this.currentDictionaryEntries + .map((val, index) => { + const columnIndex = val.toLowerCase().indexOf(this.searchText); + if (columnIndex >= 0) { + return { row: index, column: columnIndex, length: this.searchText.length }; + } + }) + .filter((entry) => !!entry); + } + textChanged($event: any) { this.currentDictionaryEntries = $event.split('\n'); this.changedLines = []; - this.activeMarkers.forEach((am) => { + this.activeEditMarkers.forEach((am) => { this.editorComponent.getEditor().getSession().removeMarker(am); }); - this.activeMarkers = []; + this.activeEditMarkers = []; for (let i = 0; i < this.currentDictionaryEntries.length; i++) { const currentEntry = this.currentDictionaryEntries[i]; @@ -88,7 +127,7 @@ export class DictionaryOverviewScreenComponent { } for (const i of this.changedLines) { - this.activeMarkers.push(this.editorComponent.getEditor().getSession().addMarker(new Range(i, 0, i, 1), 'changed-row-marker', 'fullLine')); + this.activeEditMarkers.push(this.editorComponent.getEditor().getSession().addMarker(new Range(i, 0, i, 1), 'changed-row-marker', 'fullLine')); } } diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index df74e2b63..0a4b6e78f 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -499,6 +499,7 @@ "save": "Save Dictionary" }, "dictionary-overview": { + "search": "Search...", "save-changes": "Save Changes", "revert-changes": "Revert" }, diff --git a/apps/red-ui/src/assets/styles/red-editor.scss b/apps/red-ui/src/assets/styles/red-editor.scss index 161f462b0..6045a4d1f 100644 --- a/apps/red-ui/src/assets/styles/red-editor.scss +++ b/apps/red-ui/src/assets/styles/red-editor.scss @@ -6,3 +6,9 @@ background: rgba($primary, 0.2); z-index: 20; } + +.search-marker { + position: absolute; + background: rgba($yellow-1, 0.3); + z-index: 20; +}