Include code snippets in full-text search (#7)
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Garrett Mills 2020-10-13 09:25:03 -05:00
parent 28d6986eea
commit 527697b2fc
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246
4 changed files with 21 additions and 8 deletions

View File

@ -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};

View File

@ -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 {

View File

@ -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();
}
}

View File

@ -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 {