@dataclouder/ngx-lessons 0.0.30 → 0.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/fesm2022/dataclouder-ngx-lessons.mjs +1170 -449
  2. package/fesm2022/dataclouder-ngx-lessons.mjs.map +1 -1
  3. package/lib/components/dc-lessons/dc-lesson-card/dc-lesson-card.component.d.ts +2 -2
  4. package/lib/components/dc-lessons/dc-lesson-component-adder/dc-lesson-component-adder.component.d.ts +11 -0
  5. package/lib/components/dc-lessons/dc-lesson-editor/dc-lesson-editor.component.d.ts +39 -38
  6. package/lib/components/dc-lessons/dc-lesson-metadata-editor/dc-lesson-metadata-editor.component.d.ts +22 -0
  7. package/lib/components/dc-lessons/dc-lesson-renderer/dc-lesson-renderer.component.d.ts +32 -37
  8. package/lib/components/dc-lessons/lesson-list/dc-lesson-list.component.d.ts +2 -4
  9. package/lib/components/lesson-mini-components/components/ComponentBuilder.d.ts +7 -2
  10. package/lib/components/lesson-mini-components/components/lessons.clases.d.ts +17 -42
  11. package/lib/components/lesson-mini-components/components/speaker/speaker-builder/speaker-builder.component.d.ts +13 -0
  12. package/lib/components/lesson-mini-components/components/speaker/speaker.component.d.ts +12 -0
  13. package/lib/services/lesson-ai.service.d.ts +18 -0
  14. package/lib/services/lesson-notion.service.d.ts +35 -0
  15. package/lib/services/lesson-utils.service.d.ts +34 -0
  16. package/package.json +3 -2
  17. package/src/lib/components/dc-lessons/dc-lesson-card/dc-lesson-card.component.html +40 -35
  18. package/src/lib/components/dc-lessons/dc-lesson-card/dc-lesson-card.component.scss +15 -2
  19. package/src/lib/components/dc-lessons/dc-lesson-card/dc-lesson-card.component.ts +3 -3
  20. package/src/lib/components/dc-lessons/dc-lesson-component-adder/dc-lesson-component-adder.component.css +1 -0
  21. package/src/lib/components/dc-lessons/dc-lesson-component-adder/dc-lesson-component-adder.component.html +46 -0
  22. package/src/lib/components/dc-lessons/dc-lesson-component-adder/dc-lesson-component-adder.component.ts +52 -0
  23. package/src/lib/components/dc-lessons/dc-lesson-editor/dc-lesson-editor.component.html +54 -92
  24. package/src/lib/components/dc-lessons/dc-lesson-editor/dc-lesson-editor.component.ts +268 -230
  25. package/src/lib/components/dc-lessons/dc-lesson-metadata-editor/dc-lesson-metadata-editor.component.css +1 -0
  26. package/src/lib/components/dc-lessons/dc-lesson-metadata-editor/dc-lesson-metadata-editor.component.html +72 -0
  27. package/src/lib/components/dc-lessons/dc-lesson-metadata-editor/dc-lesson-metadata-editor.component.ts +60 -0
  28. package/src/lib/components/dc-lessons/dc-lesson-renderer/dc-lesson-renderer.component.html +23 -27
  29. package/src/lib/components/dc-lessons/dc-lesson-renderer/dc-lesson-renderer.component.ts +247 -186
  30. package/src/lib/components/dc-lessons/lesson-form/lesson-form.component.ts +2 -2
  31. package/src/lib/components/dc-lessons/lesson-list/dc-lesson-list.component.html +3 -3
  32. package/src/lib/components/dc-lessons/lesson-list/dc-lesson-list.component.ts +5 -5
  33. package/src/lib/components/lesson-mini-components/components/ComponentBuilder.ts +23 -15
  34. package/src/lib/components/lesson-mini-components/components/lessons.clases.ts +32 -66
  35. package/src/lib/components/lesson-mini-components/components/selector/selector-builder/selector-builder.component.html +62 -58
  36. package/src/lib/components/lesson-mini-components/components/selector/selector-builder/selector-builder.component.ts +2 -2
  37. package/src/lib/components/lesson-mini-components/components/selector/selector.component.html +1 -2
  38. package/src/lib/components/lesson-mini-components/components/selector/selector.component.ts +2 -2
  39. package/src/lib/components/lesson-mini-components/components/speaker/speaker-builder/speaker-builder.component.html +5 -27
  40. package/src/lib/components/lesson-mini-components/components/speaker/speaker-builder/speaker-builder.component.ts +38 -25
  41. package/src/lib/components/lesson-mini-components/components/speaker/speaker.component.html +9 -7
  42. package/src/lib/components/lesson-mini-components/components/speaker/speaker.component.ts +30 -26
  43. package/src/lib/components/lesson-mini-components/components/translationSwitcher/translationSwitcher.component.ts +2 -2
  44. package/src/lib/components/lesson-mini-components/components/translationSwitcher/translationSwitcherBuilder/translationSwitcherBuilder.component.ts +2 -2
  45. package/src/lib/services/lesson-ai.service.ts +103 -0
  46. package/src/lib/services/lesson-notion.service.ts +161 -0
  47. package/src/lib/services/lesson-utils.service.ts +181 -0
  48. package/src/lib/components/lesson-mini-components/components/selector/selector-builder/selector-builder.component.spec.ts +0 -25
  49. package/src/lib/components/lesson-mini-components/components/speaker/speaker-builder/speaker-builder.component.spec.ts +0 -25
  50. package/src/lib/components/lesson-mini-components/components/speaker/speaker.component.spec.ts +0 -25
@@ -3,22 +3,24 @@ import { FormBuilder, FormControl } from '@angular/forms';
3
3
  import { DynamicDialogRef } from 'primeng/dynamicdialog';
4
4
 
5
5
  import { LessonComponentBuilders, LessonComponentConfiguration, LessonComponentEnum, LessonCompSettings } from './lessons.clases';
6
+ import { nanoid } from 'nanoid';
6
7
 
7
8
  // Create a type that maps the interface to FormControls
8
9
  export type LessonCompSettingsForm = {
9
10
  [K in keyof Required<LessonCompSettings>]: FormControl<LessonCompSettings[K]>;
10
11
  };
11
12
 
13
+ export interface ComponentBuildData {
14
+ str: string;
15
+ obj: LessonComponentConfiguration;
16
+ }
17
+
12
18
  @Component({
13
19
  selector: 'app-component-builder',
14
20
  template: '<div>no template</div>',
15
21
  })
16
22
  export class ComponentBuilder {
17
- constructor(
18
- protected formBuilder: FormBuilder,
19
- // protected toastrService: ToastService, // protected ref: NbDialogRef<ComponentBuilder>,
20
- protected ref: DynamicDialogRef,
21
- ) {}
23
+ constructor(protected formBuilder: FormBuilder, protected ref: DynamicDialogRef) {}
22
24
 
23
25
  // Sobreescribir si es necesario
24
26
  // public formGroup = this.formBuilder.group<LessonCompSettings>({});
@@ -46,7 +48,7 @@ export class ComponentBuilder {
46
48
  return <LessonComponentEnum>name;
47
49
  }
48
50
 
49
- private getCode(): string {
51
+ protected getCode(): LessonComponentConfiguration {
50
52
  const data = this.formGroup.value;
51
53
  // Deleting null values
52
54
  Object.keys(data).forEach((key) => {
@@ -54,21 +56,27 @@ export class ComponentBuilder {
54
56
  delete data[key];
55
57
  }
56
58
  });
57
- const id = Math.random().toString(36).substring(7);
58
- const code: LessonComponentConfiguration = { id: id, component: this.questionType, settings: { ...data } as unknown as LessonCompSettings };
59
- return `~${JSON.stringify(code)}~`;
59
+ const code: LessonComponentConfiguration = { component: this.questionType, settings: { ...data } as unknown as LessonCompSettings };
60
+ return code;
60
61
  }
61
62
 
62
63
  public showCode() {
63
64
  const code = this.getCode();
64
- alert(code);
65
+ const stringCode = `~${JSON.stringify(code)}~`;
66
+ alert(stringCode);
65
67
  }
66
68
 
67
- public async copyToClipboard() {
69
+ public getComponentData(): ComponentBuildData {
68
70
  const code = this.getCode();
69
- await navigator.clipboard.writeText(code);
70
- // this.toastrService.info('Control + V para pegar', 'Se copió al portapapeles');
71
- // this.ref.close();
72
- this.ref.close(code);
71
+ const id = nanoid().replace(/-/g, '_');
72
+ code.id = id;
73
+ return { str: `~${JSON.stringify(code)}~`, obj: code };
74
+ }
75
+
76
+ // TODO: for now copyToClipboard is the that that closes modal and return data.
77
+ public async copyToClipboard() {
78
+ const data = this.getComponentData();
79
+ await navigator.clipboard.writeText(data.str);
80
+ this.ref.close(data);
73
81
  }
74
82
  }
@@ -9,7 +9,8 @@ import { TextWriterBuiderComponent } from './text-writer/text-writer-buider/text
9
9
  import { TextWriterComponent } from './text-writer/text-writer.component';
10
10
  import { TranslationSwitcherBuilderComponent } from './translationSwitcher/translationSwitcherBuilder/translationSwitcherBuilder.component';
11
11
  import { TranslationSwitcherComponent } from './translationSwitcher/translationSwitcher.component';
12
- // import { SpeakerComponent } from './speaker/speaker.component';
12
+ import { SpeakerBuilderComponent } from './speaker/speaker-builder/speaker-builder.component';
13
+ import { SpeakerComponent } from './speaker/speaker.component';
13
14
 
14
15
  export type LessonComponentsType = 'selector' | 'speaker' | 'text-writer' | 'verb-summary' | 'word-summary';
15
16
 
@@ -24,7 +25,7 @@ export enum LessonComponentEnum {
24
25
 
25
26
  export const LessonComponentBuilders = {
26
27
  [LessonComponentEnum.Selector]: SelectorBuilderComponent,
27
- // [LessonComponentEnum.Speaker]: SpeakerBuilderComponent,
28
+ [LessonComponentEnum.Speaker]: SpeakerBuilderComponent,
28
29
  [LessonComponentEnum.TextWriter]: TextWriterBuiderComponent,
29
30
  // [LessonComponentEnum.VerbSummary]: VerbSummaryBuilderComponent,
30
31
  // [LessonComponentEnum.WordSummary]: WordSummaryBuilderComponent,
@@ -33,7 +34,7 @@ export const LessonComponentBuilders = {
33
34
 
34
35
  export const LessonComponents = {
35
36
  [LessonComponentEnum.Selector]: SelectorComponent,
36
- // [LessonComponentEnum.Speaker]: SpeakerComponent,
37
+ [LessonComponentEnum.Speaker]: SpeakerComponent,
37
38
  [LessonComponentEnum.TextWriter]: TextWriterComponent,
38
39
  // [LessonComponentEnum.VerbSummary]: VerbSummaryComponent,
39
40
  // [LessonComponentEnum.WordSummary]: WordSummaryComponent,
@@ -52,10 +53,12 @@ export interface LessonCompSettings {
52
53
  hint?: string;
53
54
  explanation?: string;
54
55
  }
55
- export interface LessonComponentConfiguration {
56
- id: string;
56
+ // Make LessonComponentConfiguration generic for settings
57
+ export interface LessonComponentConfiguration<T extends LessonCompSettings = LessonCompSettings> {
58
+ id?: string;
57
59
  component: LessonComponentEnum;
58
- settings: LessonCompSettings;
60
+ settings?: T; // for component that need and standards
61
+ inputs?: Record<string, any>; // for whatever component.
59
62
  }
60
63
 
61
64
  export interface StorageFile {
@@ -68,13 +71,15 @@ export interface AudioStorage extends StorageFile {
68
71
  text?: string;
69
72
  voiceType?: string;
70
73
  }
71
- export interface SpeakerCompConfiguration extends LessonComponentConfiguration {
74
+ // Make SpeakerCompConfiguration extend the generic base interface
75
+ export interface SpeakerCompConfiguration extends LessonComponentConfiguration<LessonCompSettings & { voice: string }> {
72
76
  audio: AudioStorage;
73
- settings: LessonCompSettings & { voice: string };
77
+ // settings is now inherited correctly via the generic type argument
74
78
  }
75
79
 
76
80
  export interface LessonComponentInterface {
77
- config: LessonComponentConfiguration;
81
+ // Update config to use the generic form
82
+ config: LessonComponentConfiguration<any>;
78
83
 
79
84
  control?: UntypedFormControl;
80
85
 
@@ -89,20 +94,8 @@ export interface LessonComponentInterface {
89
94
 
90
95
  export const LESSONS_TOKEN = new InjectionToken<LessonsAbstractService>('Lessons Service');
91
96
 
92
- // export enum LessonComponentEnum {
93
- // Selector = 'selector',
94
- // Speaker = 'speaker',
95
- // TextWriter = 'textWriter',
96
- // VerbSummary = 'verbSummary',
97
- // WordSummary = 'wordSummary',
98
- // TranslationSwitcher = 'translationSwitcher',
99
- // }
100
-
101
- export interface StorageFile {
102
- bucket: string;
103
- url: string;
104
- path: string; // path where the file is in the storage
105
- }
97
+ // Removed duplicate LessonComponentEnum definition
98
+ // Removed duplicate StorageFile definition
106
99
 
107
100
  export interface ImgStorageData extends StorageFile {
108
101
  fullPath: string; // path + name
@@ -112,19 +105,15 @@ export interface ImgStorageData extends StorageFile {
112
105
 
113
106
  export type LessonImage = ImgStorageData & { type: string };
114
107
 
115
- // export interface LessonCompSettings {
116
- // response: string;
117
- // responses: string; // en caso de que haya multiples respuestas
118
- // options: string[]; // optiones para visualizar
119
- // text: string;
120
- // hint: string;
121
- // explanation: string;
122
- // }
108
+ // Removed duplicate LessonCompSettings definition
109
+ // Removed duplicate LessonComponentConfiguration definition
123
110
 
124
- export interface LessonComponentConfiguration {
125
- id: string;
126
- component: LessonComponentEnum;
127
- settings: LessonCompSettings;
111
+ // New way of render components
112
+ export interface DynamicContentComponent {
113
+ id: string; // duplicated id
114
+ component: LessonComponentEnum; // name of the component
115
+ inputs: Record<string, any>;
116
+ config: LessonComponentConfiguration<any>;
128
117
  }
129
118
 
130
119
  type StorageType = StorageFile & { type: string };
@@ -151,7 +140,9 @@ export interface ILesson {
151
140
  authorEmail: string;
152
141
  tags: string[];
153
142
  media: Media;
154
- components: Array<LessonComponentConfiguration>;
143
+ // Update components array to use generic form
144
+ components: Array<LessonComponentConfiguration<any>>;
145
+ dynamicComponents: Record<string, DynamicContentComponent>;
155
146
  baseLang: string;
156
147
  targetLang: string;
157
148
 
@@ -197,36 +188,11 @@ export function provideLessonsService(serviceImplementation: Type<LessonsAbstrac
197
188
  // return null;
198
189
  // }
199
190
 
200
- export interface LessonComponentConfiguration {
201
- id: string;
202
- component: LessonComponentEnum;
203
- settings: LessonCompSettings;
204
- }
205
-
206
- export interface StorageFile {
207
- bucket: string;
208
- url: string;
209
- path: string; // path where the file is in the storage
210
- }
211
-
212
- export interface AudioStorage extends StorageFile {
213
- text?: string;
214
- voiceType?: string;
215
- }
216
-
217
- export interface SpeakerCompConfiguration extends LessonComponentConfiguration {
218
- audio: AudioStorage;
219
- settings: LessonCompSettings & { voice: string };
220
- }
221
-
222
- export interface LessonComponentInterface {
223
- config: LessonComponentConfiguration;
224
-
225
- control?: UntypedFormControl;
226
-
227
- validate?(): boolean | null;
228
- evaluate?(): boolean | null;
229
- }
191
+ // Removed duplicate LessonComponentConfiguration definition
192
+ // Removed duplicate StorageFile definition
193
+ // Removed duplicate AudioStorage definition
194
+ // Removed duplicate SpeakerCompConfiguration definition
195
+ // Removed duplicate LessonComponentInterface definition
230
196
 
231
197
  // export const LessonComponents = {
232
198
  // [LessonComponentEnum.Selector]: 1,
@@ -1,58 +1,62 @@
1
- <div>
2
- <div>
3
- <p-message>Construcción del componente de Selección, sirve para hacer una pregunta y mostrar varias opciones, ejemplo:</p-message>
4
- </div>
5
-
6
- <div>
7
- <span>En que año llegó cristobal colon a america?</span>
8
- <app-selector [config]="sampleConfig"></app-selector>
9
- </div>
10
-
11
- <hr />
12
-
13
- <div>
14
- <form class="builder-form" [formGroup]="formGroup">
15
- <input class="form-input" type="text" pInputText fullWidth formControlName="response" placeholder="Respuesta Correcta..." />
16
- <br />
17
-
18
- <input class="form-input" type="" pInputText fullWidth formControlName="hint" placeholder="Escribe una pista para esta pregunta" />
19
-
20
- <br />
21
- <input
22
- class="form-input"
23
- type="text"
24
- pInputText
25
- fullWidth
26
- formControlName="explanation"
27
- placeholder="Excribe una explicación para la respuesta" />
28
-
29
- <hr />
30
- <h6>Opciones</h6>
31
-
32
- <div class="form-group" formArrayName="options">
33
- <div
34
- style="display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 10px; flex-direction: column"
35
- *ngFor="let item of optionsForm.controls; let i = index">
36
- <div>
37
- <input type="text" pInputText fullWidth [formControlName]="i" />
38
- <p-button (click)="deleteFormArrayByIndex('options', i)" icon="pi pi-times" severity="danger"></p-button>
39
- </div>
40
- </div>
41
- </div>
42
-
43
- <p-button (click)="pushControlToFormArray('options')" label="Agregar Opción" [text]="true" severity="help"></p-button>
44
- </form>
45
-
46
- <!-- <button nbButton (click)="isRendered = !isRendered"> Renderizar </button> -->
47
-
48
- <div *ngIf="isRendered">
49
- <!-- TODO: probably i need to pass some params -->
50
- <app-selector></app-selector>
51
- </div>
52
- </div>
53
-
54
- <div>
55
- <p-button (click)="copyToClipboard()" [disabled]="formGroup.invalid" label="Copia Código" [rounded]="true"></p-button>
56
- <p-button (click)="showCode()" [disabled]="formGroup.invalid" label="Mostrar" [rounded]="true" severity="secondary"></p-button>
57
- </div>
58
- </div>
1
+ <div>
2
+ <div>
3
+ <p-message>Construcción del componente de Selección, sirve para hacer una pregunta y mostrar varias opciones, ejemplo:</p-message>
4
+ </div>
5
+
6
+ <div>
7
+ <span>En que año llegó cristobal colon a america?</span>
8
+ <app-selector [config]="sampleConfig"></app-selector>
9
+ </div>
10
+
11
+ <hr />
12
+
13
+ <div>
14
+ <form class="builder-form" [formGroup]="formGroup">
15
+ <input class="form-input" type="text" pInputText fullWidth formControlName="response" placeholder="Respuesta Correcta..." />
16
+ <br />
17
+
18
+ <input class="form-input" type="" pInputText fullWidth formControlName="hint" placeholder="Escribe una pista para esta pregunta" />
19
+
20
+ <br />
21
+ <input
22
+ class="form-input"
23
+ type="text"
24
+ pInputText
25
+ fullWidth
26
+ formControlName="explanation"
27
+ placeholder="Excribe una explicación para la respuesta" />
28
+
29
+ <hr />
30
+ <h6>Opciones</h6>
31
+
32
+ <div class="form-group" formArrayName="options">
33
+ @for (item of optionsForm.controls; track item; let i = $index) {
34
+ <div
35
+ style="display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 10px; flex-direction: column"
36
+ >
37
+ <div>
38
+ <input type="text" pInputText fullWidth [formControlName]="i" />
39
+ <p-button (click)="deleteFormArrayByIndex('options', i)" icon="pi pi-times" severity="danger"></p-button>
40
+ </div>
41
+ </div>
42
+ }
43
+ </div>
44
+
45
+ <p-button (click)="pushControlToFormArray('options')" label="Agregar Opción" [text]="true" severity="help"></p-button>
46
+ </form>
47
+
48
+ <!-- <button nbButton (click)="isRendered = !isRendered"> Renderizar </button> -->
49
+
50
+ @if (isRendered) {
51
+ <div>
52
+ <!-- TODO: probably i need to pass some params -->
53
+ <app-selector></app-selector>
54
+ </div>
55
+ }
56
+ </div>
57
+
58
+ <div>
59
+ <p-button (click)="copyToClipboard()" [disabled]="formGroup.invalid" label="Copia Código" [rounded]="true"></p-button>
60
+ <p-button (click)="showCode()" [disabled]="formGroup.invalid" label="Mostrar" [rounded]="true" severity="secondary"></p-button>
61
+ </div>
62
+ </div>
@@ -1,6 +1,6 @@
1
1
  import { Component, OnInit } from '@angular/core';
2
2
  import { UntypedFormArray, FormsModule, ReactiveFormsModule, FormBuilder } from '@angular/forms';
3
- import { NgFor, NgIf } from '@angular/common';
3
+
4
4
 
5
5
  import { InputTextModule } from 'primeng/inputtext';
6
6
  import { ButtonModule } from 'primeng/button';
@@ -16,7 +16,7 @@ import { LessonComponentConfiguration, LessonComponentEnum } from '../../lessons
16
16
  templateUrl: './selector-builder.component.html',
17
17
  styleUrls: ['./selector-builder.component.scss'],
18
18
  standalone: true,
19
- imports: [FormsModule, ReactiveFormsModule, NgFor, NgIf, SelectorComponent, InputTextModule, ButtonModule, MessageModule],
19
+ imports: [FormsModule, ReactiveFormsModule, SelectorComponent, InputTextModule, ButtonModule, MessageModule],
20
20
  })
21
21
  export class SelectorBuilderComponent extends ComponentBuilder implements OnInit {
22
22
  constructor(
@@ -1,2 +1 @@
1
- <p-dropdown [class]="status" placeholder="Selecciona" [options]="config.settings.options" [formControl]="control"
2
- [showClear]="true"></p-dropdown>
1
+ <p-select [class]="status" placeholder="Selecciona" [options]="config.settings.options" [formControl]="control"></p-select>
@@ -1,7 +1,7 @@
1
1
  import { Component, Input } from '@angular/core';
2
2
 
3
3
  import { FormsModule, ReactiveFormsModule } from '@angular/forms';
4
- import { DropdownModule } from 'primeng/dropdown';
4
+ import { SelectModule } from 'primeng/select';
5
5
 
6
6
  import { ComponentWithForm } from '../ComponentWithForm';
7
7
  import { LessonComponentConfiguration, LessonComponentInterface } from '../lessons.clases';
@@ -11,7 +11,7 @@ import { LessonComponentConfiguration, LessonComponentInterface } from '../lesso
11
11
  templateUrl: './selector.component.html',
12
12
  styleUrls: ['./selector.component.scss'],
13
13
  standalone: true,
14
- imports: [FormsModule, ReactiveFormsModule, DropdownModule],
14
+ imports: [FormsModule, ReactiveFormsModule, SelectModule],
15
15
  })
16
16
  export class SelectorComponent extends ComponentWithForm implements LessonComponentInterface {
17
17
  public isFilled = false;
@@ -3,33 +3,11 @@
3
3
  <h5>Constructor de Speaker</h5>
4
4
  </div>
5
5
 
6
- <form [formGroup]="formGroup">
7
- <input type="text" pInputText fullWidth formControlName="text" placeholder="Texto..." />
6
+ <lib-ngx-tts (ttsGenerated)="handleTtsGenerated($event)"></lib-ngx-tts>
8
7
 
9
- <br>
10
- <p-dropdown [options]="voiceOptions" optionLabel="name" optionValue="id" [showClear]="true" placeholder="Voz"
11
- formControlName="voice">
12
-
13
- <ng-template let-voice pTemplate="item">
14
- <div class="flex align-items-center gap-2">
15
- <div>{{ voice.provider }}</div>
16
- -
17
- <div>{{ voice.name }}</div>
18
- </div>
19
- </ng-template>
20
- </p-dropdown>
21
-
22
- </form>
23
-
24
- <br>
25
- <br>
26
- <br>
27
-
28
- <br>
8
+ <br />
29
9
  <div>
30
- <p-button (click)="copyToClipboard()" [disabled]="formGroup.invalid" label="Copia Código"
31
- [rounded]="true"></p-button>
32
- <p-button (click)="showCode()" [disabled]="formGroup.invalid" label="Mostrar" [rounded]="true"
33
- severity="secondary"></p-button>
10
+ <p-button (click)="copyToClipboard()" [disabled]="formGroup.invalid" label="Copia Código" [rounded]="true"></p-button>
11
+ <p-button (click)="showCode()" [disabled]="!tts()" label="Mostrar" [rounded]="true" severity="secondary"></p-button>
34
12
  </div>
35
- </div>
13
+ </div>
@@ -1,27 +1,40 @@
1
- // import { Component } from '@angular/core';
2
- // import { UntypedFormBuilder, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
3
- // import { ComponentBuilder } from '../../ComponentBuilder';
4
- // import { ButtonModule } from 'primeng/button';
5
- // import { InputTextModule } from 'primeng/inputtext';
6
- // import { DropdownModule } from 'primeng/dropdown';
7
- // import { DynamicDialogRef } from 'primeng/dynamicdialog';
1
+ import { Component, signal } from '@angular/core';
2
+ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
3
+ import { ComponentBuilder } from '../../ComponentBuilder';
4
+ import { ButtonModule } from 'primeng/button';
5
+ import { InputTextModule } from 'primeng/inputtext';
6
+ import { DropdownModule } from 'primeng/dropdown';
7
+ import { NgxTtsComponent, TTSGenerated } from '@dataclouder/ngx-tts';
8
+ import { LessonComponentConfiguration, LessonCompSettings } from '../../lessons.clases';
8
9
 
9
- // @Component({
10
- // selector: 'app-speaker-builder',
11
- // templateUrl: './speaker-builder.component.html',
12
- // styleUrls: ['./speaker-builder.component.scss'],
13
- // standalone: true,
14
- // imports: [FormsModule, ReactiveFormsModule, InputTextModule, ButtonModule, DropdownModule],
15
- // })
16
- // export class SpeakerBuilderComponent extends ComponentBuilder {
17
- // public override formGroup = this.formBuilder.group({ text: ['', Validators.required], voice: [''] });
18
- // public voiceOptions = VoiceOptions;
10
+ @Component({
11
+ selector: 'app-speaker-builder',
12
+ templateUrl: './speaker-builder.component.html',
13
+ styleUrls: ['./speaker-builder.component.scss'],
14
+ standalone: true,
15
+ imports: [FormsModule, ReactiveFormsModule, InputTextModule, ButtonModule, DropdownModule, NgxTtsComponent],
16
+ })
17
+ export class SpeakerBuilderComponent extends ComponentBuilder {
18
+ public tts = signal<TTSGenerated | undefined>(undefined);
19
19
 
20
- // constructor(
21
- // protected override formBuilder: UntypedFormBuilder,
22
- // // protected override toastrService: ToastService, // protected ref: NbDialogRef<ComponentBuilder>,
23
- // protected override ref: DynamicDialogRef,
24
- // ) {
25
- // super(formBuilder, null);
26
- // }
27
- // }
20
+ public handleTtsGenerated(event: TTSGenerated): void {
21
+ console.log('TTS generated:', event);
22
+ this.tts.set(event);
23
+ }
24
+
25
+ // Update return type and add settings object
26
+ protected override getCode(): LessonComponentConfiguration<LessonCompSettings & { voice: string }> {
27
+ const ttsValue = this.tts();
28
+ if (!ttsValue) {
29
+ // Handle the case where tts is undefined, maybe throw an error or return a default config
30
+ console.error('TTS data is not generated yet.');
31
+ // Depending on requirements, you might return a default/empty config or throw
32
+ return { component: this.questionType, inputs: {} }; // Example: return empty inputs
33
+ }
34
+ const code: LessonComponentConfiguration<LessonCompSettings & { voice: string }> = {
35
+ component: this.questionType,
36
+ inputs: { tts: ttsValue },
37
+ };
38
+ return code;
39
+ }
40
+ }
@@ -1,7 +1,9 @@
1
- <!-- <nb-tag (click)="speach()" class="lisen" status="control" size="small" appearance="filled"
2
- [text]="settings.text"></nb-tag> -->
3
-
4
- <button pButton style="padding: 0px 2px;" severity="help" size="small" (click)="speach()" [label]="config.settings.text"
5
- [text]="true" [rounded]="true"></button>
6
-
7
- <!-- <p-button label="Secondary" [outlined]="true" ></p-button> -->
1
+ <button
2
+ pButton
3
+ style="padding: 0px 2px"
4
+ severity="help"
5
+ size="small"
6
+ (click)="speach()"
7
+ [label]="config?.settings?.text"
8
+ [text]="true"
9
+ [rounded]="true"></button>
@@ -1,29 +1,33 @@
1
1
  // ❌ can use this until i copy services to this lib
2
- // import { Component, Input, OnInit } from '@angular/core';
3
- // import { ButtonModule } from 'primeng/button';
4
- // import { SpeakerCompConfiguration } from '../lessons.clases';
2
+ import { Component, Input, OnInit } from '@angular/core';
3
+ import { ButtonModule } from 'primeng/button';
4
+ import { SpeakerCompConfiguration } from '../lessons.clases';
5
+ import { TTSGenerated } from '@dataclouder/ngx-tts';
5
6
 
6
- // @Component({
7
- // selector: 'app-speaker',
8
- // templateUrl: './speaker.component.html',
9
- // styleUrls: ['./speaker.component.scss'],
10
- // standalone: true,
11
- // imports: [ButtonModule],
12
- // })
13
- // export class SpeakerComponent implements OnInit {
14
- // @Input() config: SpeakerCompConfiguration;
7
+ // import { CONVERSATION_AI_TOKEN } from '@dataclouder/ngx-agent-cards';
8
+ @Component({
9
+ selector: 'app-speaker',
10
+ templateUrl: './speaker.component.html',
11
+ styleUrls: ['./speaker.component.scss'],
12
+ standalone: true,
13
+ imports: [ButtonModule],
14
+ })
15
+ export class SpeakerComponent implements OnInit {
16
+ ngOnInit(): void {
17
+ // throw new Error('Method not implemented.');
18
+ }
19
+ @Input() config: SpeakerCompConfiguration;
20
+ @Input() tts: TTSGenerated | undefined;
15
21
 
16
- // voiceOptions = VoiceOptions;
17
-
18
- // constructor(private speachService: SpeechService, private audioService: AudioService) {}
19
-
20
- // ngOnInit(): void {}
21
-
22
- // public speach() {
23
- // if (this.config.audio) {
24
- // this.audioService.playAudio(this.config.audio.url);
25
- // } else {
26
- // this.speachService.speach(this.config.settings.text);
27
- // }
28
- // }
29
- // }
22
+ // voiceOptions = VoiceOptions;
23
+ // constructor(private speachService: SpeechService, private audioService: AudioService) {}
24
+ // ngOnInit(): void {}
25
+ public speach() {
26
+ console.log('should speech but will do in next version');
27
+ // if (this.config.audio) {
28
+ // this.audioService.playAudio(this.config.audio.url);
29
+ // } else {
30
+ // this.speachService.speach(this.config.settings.text);
31
+ // }
32
+ }
33
+ }
@@ -1,5 +1,5 @@
1
1
  import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
2
- import { CommonModule } from '@angular/common';
2
+
3
3
 
4
4
  import { ButtonModule } from 'primeng/button';
5
5
 
@@ -8,7 +8,7 @@ import { SpeakerCompConfiguration } from '../lessons.clases';
8
8
  @Component({
9
9
  selector: 'app-translation-switcher',
10
10
  standalone: true,
11
- imports: [CommonModule, ButtonModule],
11
+ imports: [ButtonModule],
12
12
  templateUrl: './translationSwitcher.component.html',
13
13
  styleUrl: './translationSwitcher.component.css',
14
14
  changeDetection: ChangeDetectionStrategy.Default,
@@ -1,6 +1,6 @@
1
1
  import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
2
2
  import { FormsModule, ReactiveFormsModule, FormBuilder } from '@angular/forms';
3
- import { CommonModule } from '@angular/common';
3
+
4
4
 
5
5
  import { ButtonModule } from 'primeng/button';
6
6
  import { InputTextModule } from 'primeng/inputtext';
@@ -11,7 +11,7 @@ import { ComponentBuilder } from '../../ComponentBuilder';
11
11
  @Component({
12
12
  selector: 'app-translation-switcher-builder',
13
13
  standalone: true,
14
- imports: [CommonModule, FormsModule, ReactiveFormsModule, ButtonModule, InputTextModule],
14
+ imports: [FormsModule, ReactiveFormsModule, ButtonModule, InputTextModule],
15
15
  templateUrl: './translationSwitcherBuilder.component.html',
16
16
  styleUrl: './translationSwitcherBuilder.component.css',
17
17
  changeDetection: ChangeDetectionStrategy.OnPush,