From 6c3ebfe36df76b37b29682d236af4eb48c45858f Mon Sep 17 00:00:00 2001 From: garrettmills Date: Fri, 16 Oct 2020 12:31:26 -0500 Subject: [PATCH] Markdown show up in full-text search results --- .../nodes/markdown/markdown.component.ts | 2 +- src/app/components/search/Search.component.scss | 6 ++++++ src/app/components/search/Search.component.ts | 15 +++++---------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/app/components/nodes/markdown/markdown.component.ts b/src/app/components/nodes/markdown/markdown.component.ts index 758ceae..c81adf3 100644 --- a/src/app/components/nodes/markdown/markdown.component.ts +++ b/src/app/components/nodes/markdown/markdown.component.ts @@ -54,7 +54,7 @@ export class MarkdownComponent extends EditorNodeContract implements OnInit { } public writeChangesToNode(): void | Promise { - this.node.Value.Mode = 'code'; + this.node.Value.Mode = 'markdown'; this.node.Value.Value = this.contents; this.node.value = this.contents; this.savedValue = this.contents; diff --git a/src/app/components/search/Search.component.scss b/src/app/components/search/Search.component.scss index b2d1742..adf0171 100644 --- a/src/app/components/search/Search.component.scss +++ b/src/app/components/search/Search.component.scss @@ -42,6 +42,12 @@ color: var(--noded-background-files); } } + + &.markdown { + .search-icon { + color: var(--noded-background-markdown); + } + } } .search-assoc { diff --git a/src/app/components/search/Search.component.ts b/src/app/components/search/Search.component.ts index 8999fa4..0bc03ae 100644 --- a/src/app/components/search/Search.component.ts +++ b/src/app/components/search/Search.component.ts @@ -59,19 +59,14 @@ export class SearchComponent implements OnInit { } async openResult(result: SearchResult) { + const nodeTypes = [ + 'node', 'code', 'db', 'files', 'markdown', + ]; + if ( result.type === 'page' ) { await this.router.navigate(['/editor', { id: result.id }]); await this.dismiss(); - } 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(); - } else if ( result.type === 'db' ) { - await this.router.navigate(['/editor', { id: result.associated.id, node_id: result.id }]); - await this.dismiss(); - } else if ( result.type === 'files' ) { + } else if ( nodeTypes.includes(result.type) ) { await this.router.navigate(['/editor', { id: result.associated.id, node_id: result.id }]); await this.dismiss(); }