preview test while editing

This commit is contained in:
2020-06-14 15:05:03 +02:00
parent 55200dc742
commit 96566379eb
4 changed files with 16 additions and 3 deletions

View File

@@ -68,7 +68,9 @@ export class TextRenderingService {
const type = hasMatches ? LineType.chord : LineType.text; const type = hasMatches ? LineType.chord : LineType.text;
const line = {type, text, chords: hasMatches ? cords : undefined}; const line = {type, text, chords: hasMatches ? cords : undefined};
return transpose ? this.transposeService.transpose(line, transpose.baseKey, transpose.targetKey) : line; return transpose
? this.transposeService.transpose(line, transpose.baseKey, transpose.targetKey)
: this.transposeService.renderChords(line);
} }
private getSectionTypeOfLine(line: string): SectionType { private getSectionTypeOfLine(line: string): SectionType {
@@ -107,7 +109,7 @@ export class TextRenderingService {
const chordCount = chords.reduce((acc: number, cur: Chord) => acc + cur.length, 0); const chordCount = chords.reduce((acc: number, cur: Chord) => acc + cur.length, 0);
const lineCount = chordLine.replace(/\s/g, "").length; const lineCount = chordLine.replace(/\s/g, "").length;
const isChrod = chordCount * 2 > lineCount; const isChrod = chordCount * 1.2 > lineCount;
return isChrod ? chords : []; return isChrod ? chords : [];
} }

View File

@@ -23,6 +23,13 @@ export class TransposeService {
return {...line, text: renderedLine, chords}; return {...line, text: renderedLine, chords};
} }
public renderChords(line: Line): Line {
if (line.type !== LineType.chord) return line;
const renderedLine = this.renderLine(line.chords);
return {...line, text: renderedLine};
}
public getDistance(baseKey: string, targetKey: string): number { public getDistance(baseKey: string, targetKey: string): number {
const scale = getScaleType(baseKey); const scale = getScaleType(baseKey);
return ( return (

View File

@@ -37,6 +37,8 @@
formControlName="text" matInput></textarea> formControlName="text" matInput></textarea>
</mat-form-field> </mat-form-field>
<div *ngIf="songtextFocus" class="song-text-help"> <div *ngIf="songtextFocus" class="song-text-help">
<h3>Vorschau</h3>
<app-song-text [text]="form.value.text" chordMode="show"></app-song-text>
<h3>Hinweise zur Bearbeitung</h3> <h3>Hinweise zur Bearbeitung</h3>
<h4>Aufbau</h4> <h4>Aufbau</h4>
Der Liedtext wird hintereinander weg geschrieben. Dabei werden Strophen, Refrain und Bridge jeweils durch Der Liedtext wird hintereinander weg geschrieben. Dabei werden Strophen, Refrain und Bridge jeweils durch
@@ -58,7 +60,7 @@
<pre> <pre>
Dur: C D E Dur: C D E
Moll: c d e Moll: c d e
Kreuz/B-Tonarten: C# f# Eb (Erlaubt ist auch B statt Hb) Kreuz/B-Tonarten: C# f# Eb (Hb muss als B angegeben werden)
Basstöne: C/E D/C Basstöne: C/E D/C
Obertöne: c7 E9 f#maj7 Obertöne: c7 E9 f#maj7
</pre> </pre>

View File

@@ -25,6 +25,7 @@ import {MatTooltipModule} from '@angular/material/tooltip';
import {SaveDialogComponent} from './edit-song/save-dialog/save-dialog.component'; import {SaveDialogComponent} from './edit-song/save-dialog/save-dialog.component';
import {MatDialogModule} from '@angular/material/dialog'; import {MatDialogModule} from '@angular/material/dialog';
import {HistoryComponent} from './history/history.component'; import {HistoryComponent} from './history/history.component';
import {SongTextModule} from '../../../../widget-modules/components/song-text/song-text.module';
@NgModule({ @NgModule({
@@ -54,6 +55,7 @@ import {HistoryComponent} from './history/history.component';
ButtonModule, ButtonModule,
MatTooltipModule, MatTooltipModule,
MatDialogModule, MatDialogModule,
SongTextModule,
] ]
}) })