From 527697b2fcee85e178d98002b1762a9cf837edeb Mon Sep 17 00:00:00 2001 From: garrettmills Date: Tue, 13 Oct 2020 09:25:03 -0500 Subject: [PATCH] Include code snippets in full-text search (#7) --- src/app/components/editor/code/code.component.ts | 10 +++++----- src/app/components/search/Search.component.scss | 7 ++++++- src/app/components/search/Search.component.ts | 8 ++++++-- src/global.scss | 4 ++++ 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/app/components/editor/code/code.component.ts b/src/app/components/editor/code/code.component.ts index c2908f8..d13c5b2 100644 --- a/src/app/components/editor/code/code.component.ts +++ b/src/app/components/editor/code/code.component.ts @@ -105,7 +105,7 @@ export class CodeComponent implements OnInit { this.loader.create({message: 'Loading code...'}).then(loader => { loader.present().then(() => { this.getInitObservable().subscribe(() => { - this.editorOptions.language = this.dbRecord.language; + this.editorOptions.language = this.dbRecord.Language; this.editorOptions.readOnly = this.readonly; this.onSelectChange(false); loader.dismiss(); @@ -136,7 +136,7 @@ export class CodeComponent implements OnInit { this.api.get(`/code/${this.hostRecord.PageId}/${this.hostRecord.UUID}/get/${this.hostRecord.Value.Value}`).subscribe(res => { this.dbRecord = res.data; this.editorValue = this.dbRecord.code; - this.editorOptions.language = this.dbRecord.language; + this.editorOptions.language = this.dbRecord.Language; this.pendingSetup = false; sub.next(true); sub.complete(); @@ -154,11 +154,11 @@ export class CodeComponent implements OnInit { } this.dbRecord.code = this.editorValue; - this.dbRecord.language = this.editorOptions.language; + this.dbRecord.Language = this.editorOptions.language; this.api.post(`/code/${this.hostRecord.PageId}/${this.hostRecord.UUID}/set/${this.hostRecord.Value.Value}`, this.dbRecord) .subscribe(res => { this.dbRecord = res.data; - this.editorOptions.language = this.dbRecord.language; + this.editorOptions.language = this.dbRecord.Language; this.editorValue = this.dbRecord.code; this.dirty = false; }); @@ -200,7 +200,7 @@ export class CodeComponent implements OnInit { onSelectChange(updateDbRecord = true) { if ( updateDbRecord ) { - this.dbRecord.language = this.editorOptions.language; + this.dbRecord.Language = this.editorOptions.language; } this.editorOptions = {...this.editorOptions}; diff --git a/src/app/components/search/Search.component.scss b/src/app/components/search/Search.component.scss index 7b8c7e4..aea9b27 100644 --- a/src/app/components/search/Search.component.scss +++ b/src/app/components/search/Search.component.scss @@ -22,7 +22,6 @@ &.node { .search-icon { color: var(--noded-background-node); - content: '\f10d'; } } @@ -31,6 +30,12 @@ color: var(--noded-background-db); } } + + &.code { + .search-icon { + color: var(--noded-background-code); + } + } } .search-assoc { diff --git a/src/app/components/search/Search.component.ts b/src/app/components/search/Search.component.ts index 0cc6dae..e7efc0e 100644 --- a/src/app/components/search/Search.component.ts +++ b/src/app/components/search/Search.component.ts @@ -7,11 +7,11 @@ import {Router} from '@angular/router'; export interface SearchResult { title: string; short_title: string; - type: 'page' | 'node'; + type: 'page' | 'node' | 'code'; id: string; associated?: { title: string, - type: 'page' | 'node', + type: 'page', id: string }; } @@ -30,6 +30,7 @@ export class SearchComponent implements OnInit { node: 'fa fa-quote-left', page: 'fa fa-sticky-note', db: 'fa fa-database', + code: 'fa fa-code', }; constructor( @@ -68,6 +69,9 @@ export class SearchComponent implements OnInit { } else if ( result.type === 'node' ) { await this.router.navigate(['/editor', { id: result.associated.id, node_id: result.id }]); await this.dismiss(); + } else if ( result.type === 'code' ) { + await this.router.navigate(['/editor', { id: result.associated.id, node_id: result.id }]); + await this.dismiss(); } } diff --git a/src/global.scss b/src/global.scss index 395b1c2..cb3d4a6 100644 --- a/src/global.scss +++ b/src/global.scss @@ -42,6 +42,10 @@ --noded-background-node: #FB5607; --noded-color-node: white; --noded-background-node-hover: #fc864f; + + --noded-background-code: #FF006E; + --noded-color-code: white; + --noded-background-code-hover: #FF5CA3; } div.picker-wrapper {