Skip to content
Snippets Groups Projects
Commit 1b1be7e9 authored by rhenck's avatar rhenck
Browse files

[editor] Refactor TextEditor to optionally show Cloze-buttons

parent b225a5ee
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ import { MAT_DIALOG_DATA } from '@angular/material/dialog'; ...@@ -5,7 +5,7 @@ import { MAT_DIALOG_DATA } from '@angular/material/dialog';
selector: 'app-rich-text-edit-dialog-tinymce', selector: 'app-rich-text-edit-dialog-tinymce',
template: ` template: `
<mat-dialog-content> <mat-dialog-content>
<app-rich-text-editor [(text)]="data.text"></app-rich-text-editor> <app-rich-text-editor [(text)]="data.text" [showCloseElements]="data.showCloseElements"></app-rich-text-editor>
</mat-dialog-content> </mat-dialog-content>
<mat-dialog-actions> <mat-dialog-actions>
<button mat-button [mat-dialog-close]="data.text">{{'save' | translate }}</button> <button mat-button [mat-dialog-close]="data.text">{{'save' | translate }}</button>
...@@ -14,5 +14,5 @@ import { MAT_DIALOG_DATA } from '@angular/material/dialog'; ...@@ -14,5 +14,5 @@ import { MAT_DIALOG_DATA } from '@angular/material/dialog';
` `
}) })
export class RichTextEditDialogComponent { export class RichTextEditDialogComponent {
constructor(@Inject(MAT_DIALOG_DATA) public data: { text: string }) { } constructor(@Inject(MAT_DIALOG_DATA) public data: { text: string, showCloseElements?: boolean }) { }
} }
...@@ -54,6 +54,17 @@ export class DialogService { ...@@ -54,6 +54,17 @@ export class DialogService {
return dialogRef.afterClosed(); return dialogRef.afterClosed();
} }
showClozeTextEditDialog(text: string): Observable<string> {
const dialogRef = this.dialog.open(RichTextEditDialogComponent, {
data: {
text: text,
showCloseElements: true
},
autoFocus: false
});
return dialogRef.afterClosed();
}
showPlayerEditDialog(player: PlayerElement): Observable<PlayerElement> { showPlayerEditDialog(player: PlayerElement): Observable<PlayerElement> {
const dialogRef = this.dialog.open(PlayerEditDialogComponent, { const dialogRef = this.dialog.open(PlayerEditDialogComponent, {
data: { data: {
......
...@@ -200,21 +200,16 @@ ...@@ -200,21 +200,16 @@
<button mat-button (click)="insertSpecialChar('&hearts;')">&hearts;</button> <button mat-button (click)="insertSpecialChar('&hearts;')">&hearts;</button>
<button mat-button (click)="insertSpecialChar('&diams;')">&diams;</button> <button mat-button (click)="insertSpecialChar('&diams;')">&diams;</button>
</mat-menu> </mat-menu>
<!-- <button mat-icon-button [matMenuTriggerFor]="optionsMenu">--> </div>
<!-- <mat-icon>more_vert</mat-icon>--> <div *ngIf="showCloseElements" fxLayout="row" fxLayoutAlign="space-around center" >
<!-- </button>--> <button mat-icon-button matTooltip="\\i" [matTooltipShowDelay]="300"
<!-- <mat-menu #optionsMenu="matMenu">--> (click)="insertSpecialChar('\\i')">
<!-- <mat-form-field>--> <mat-icon>text_fields</mat-icon>
<!-- <mat-label>Absatzabstand</mat-label>--> </button>
<!-- <mat-select matTooltip="Achtung: Gilt nur für zukünftig angelegte Absätze" [matTooltipShowDelay]="300"--> <button mat-icon-button matTooltip="\\z" [matTooltipShowDelay]="300"
<!-- [value]="editor.getAttributes('paragraph').margin?.toString() || '0'"--> (click)="insertSpecialChar('\\z')">
<!-- (click)="$any($event).stopPropagation()" (valueChange)="applyParagraphStyle($event)">--> <mat-icon>drag_indicator</mat-icon>
<!-- <mat-option value="0">0px</mat-option>--> </button>
<!-- <mat-option value="10">10px</mat-option>-->
<!-- <mat-option value="20">20px</mat-option>-->
<!-- </mat-select>-->
<!-- </mat-form-field>-->
<!-- </mat-menu>-->
</div> </div>
</div> </div>
<tiptap-editor [editor]="editor" [ngModel]="text" (ngModelChange)="textChange.emit($event)"> <tiptap-editor [editor]="editor" [ngModel]="text" (ngModelChange)="textChange.emit($event)">
......
...@@ -26,6 +26,7 @@ import { orderedListExtension } from './orderedList-extension'; ...@@ -26,6 +26,7 @@ import { orderedListExtension } from './orderedList-extension';
}) })
export class RichTextEditorComponent implements AfterViewInit { export class RichTextEditorComponent implements AfterViewInit {
@Input() text!: string; @Input() text!: string;
@Input() showCloseElements: boolean | undefined = false;
@Output() textChange = new EventEmitter<string>(); @Output() textChange = new EventEmitter<string>();
selectedFontColor = 'lightgrey'; selectedFontColor = 'lightgrey';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment