Skip to content

Commit b94d3de

Browse files
committed
feat(): update rich text editor
1 parent 74bdf3d commit b94d3de

File tree

9 files changed

+94
-50
lines changed

9 files changed

+94
-50
lines changed

apps/mix-cms/src/app/pages/portal/database-data/database-data.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,9 @@ export class DatabaseDataComponent
353353

354354
const dialogRef = this.dialog.open(RecordFormComponent, {
355355
data: { mixDatabase: value.db, data: undefined },
356-
width: 800,
356+
windowClass: RecordFormComponent.windowClass,
357+
minWidth: RecordFormComponent.minWidth,
358+
maxWidth: RecordFormComponent.maxWidth,
357359
});
358360

359361
dialogRef.afterClosed$.subscribe((value) => {
@@ -375,7 +377,9 @@ export class DatabaseDataComponent
375377

376378
const dialogRef = this.dialog.open(RecordFormComponent, {
377379
data: { mixDatabase: state.db, data: state.data[dataIndex] },
378-
width: 800,
380+
windowClass: RecordFormComponent.windowClass,
381+
minWidth: RecordFormComponent.minWidth,
382+
maxWidth: RecordFormComponent.maxWidth,
379383
});
380384

381385
dialogRef.afterClosed$.subscribe((value) => {
Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
<div class="mix-dialog">
22
<div class="mix-dialog__header">
3-
{{ mode === 'create' ? 'Create' : 'Update'}} record from {{ ref.data.mixDatabase.displayName }}
3+
{{ mode === 'create' ? 'Create' : 'Update' }} record from
4+
{{ ref.data.mixDatabase.displayName }}
45
</div>
56

67
<div class="mix-dialog__content">
78
<form [formGroup]="form">
8-
<formly-form *ngIf="fields.length"
9-
[fields]="fields"
10-
[form]="form"
11-
[model]="modelData"></formly-form>
9+
<formly-form
10+
*ngIf="fields.length"
11+
[fields]="fields"
12+
[form]="form"
13+
[model]="modelData"
14+
></formly-form>
1215
</form>
1316
</div>
1417

15-
<div *ngIf="loadingState$ | async as state"
16-
class="mix-dialog__footer">
17-
<mix-button type="outline"
18-
(click)="ref.close()"
19-
size="m"> Cancel </mix-button>
18+
<div class="mix-dialog__footer">
19+
<mix-button type="outline" (click)="ref.close()" size="m">
20+
Cancel
21+
</mix-button>
2022

21-
<mix-button [loading]="state === 'Loading'"
22-
(click)="onSaveData()"
23-
size="m"> Save </mix-button>
23+
<mix-button
24+
[loading]="loadingState() === 'Loading'"
25+
(click)="onSaveData()"
26+
size="m"
27+
>
28+
Save
29+
</mix-button>
2430
</div>
2531
</div>

libs/mix-share/src/components/record-form/record-form.component.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ import { TuiFileLike } from '@taiga-ui/kit';
2929
changeDetection: ChangeDetectionStrategy.OnPush,
3030
})
3131
export class RecordFormComponent extends BaseComponent implements OnInit {
32-
mixApi = inject(MixApiFacadeService);
33-
ref: DialogRef<
32+
public static windowClass = 'mix-record-form-dialog';
33+
public static minWidth = '800px';
34+
public static maxWidth = '95vw';
35+
36+
public mixApi = inject(MixApiFacadeService);
37+
public ref: DialogRef<
3438
{
3539
mixDatabase: MixDatabase;
3640
data: MixDynamicData | undefined;
@@ -83,7 +87,7 @@ export class RecordFormComponent extends BaseComponent implements OnInit {
8387
},
8488
db.displayName
8589
)
86-
.pipe(this.observerLoadingState())
90+
.pipe(this.observerLoadingStateSignal())
8791
.subscribe((result) => {
8892
this.ref.close(result);
8993
});
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<div class="row mb-4">
2-
<div class="col-md-2">
1+
<div class="formly-control-item">
2+
<div style="min-width: 200px">
33
<span class="content-label mb-1"> {{ title }}:</span>
44
<div class="content-sub-label">{{ description }}</div>
55
</div>
66

7-
<div class="col-md-10">
7+
<div class="flex-grow-1">
88
<ng-content></ng-content>
99
</div>
1010
</div>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.formly-control-item {
2+
display: flex;
3+
gap: 8px;
4+
}
5+
6+
formly-field {
7+
display: block;
8+
9+
&:not(:last-of-type) {
10+
margin-bottom: 1rem;
11+
}
12+
}

libs/mix-ui/src/base/formly-control-layout/formly-control-layout.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { CommonModule } from '@angular/common';
2-
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
2+
import {
3+
ChangeDetectionStrategy,
4+
Component,
5+
Input,
6+
ViewEncapsulation,
7+
} from '@angular/core';
38

49
@Component({
510
selector: 'mix-formly-control-layout',
@@ -8,6 +13,7 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
813
templateUrl: './formly-control-layout.component.html',
914
styleUrls: ['./formly-control-layout.component.scss'],
1015
changeDetection: ChangeDetectionStrategy.OnPush,
16+
encapsulation: ViewEncapsulation.None,
1117
})
1218
export class FormlyControlLayoutComponent {
1319
@Input() title?: string = '';
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
<div class="rich-text-editor"
2-
[ngClass]="{ '--full-width': zoom }">
1+
<div class="rich-text-editor" [ngClass]="{ '--full-width': zoom }">
32
<tui-editor [formControl]="control">
43
{{ placeHolder }}
54
</tui-editor>
65

7-
<mix-button class="rich-text-editor__button"
8-
type="outline"
9-
[iconBtn]="true"
10-
(click)="zoom = !zoom">
11-
<span class="material-symbols-outlined">
12-
{{ zoom ? 'pinch_zoom_in' : 'pinch_zoom_out' }}
6+
<mix-button
7+
class="rich-text-editor__button"
8+
type="outline"
9+
[iconBtn]="true"
10+
(click)="zoom = !zoom"
11+
>
12+
<span class="mix-icon text-xl">
13+
{{ zoom ? 'zoom_in' : 'zoom_out' }}
1314
</span>
1415
</mix-button>
1516
</div>

libs/mix-ui/src/rich-text-editor/rich-text-editor.component.scss

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ tui-editor {
1414

1515
&.--full-width {
1616
position: fixed;
17-
width: 100vw;
18-
height: 100vh;
19-
top: 0;
20-
left: 0;
17+
width: 50vw;
18+
height: calc(100vh - 8px);
19+
top: 4px;
20+
right: 4px;
2121
z-index: 50;
22+
animation: fullwidth-open 0.1s cubic-bezier(0, 0, 0.2, 1);
2223
}
2324

2425
&__button {
@@ -28,3 +29,14 @@ tui-editor {
2829
background-color: #fff;
2930
}
3031
}
32+
33+
@keyframes fullwidth-open {
34+
0% {
35+
opacity: 0.2;
36+
transform: translateX(50%);
37+
}
38+
100% {
39+
transform: translateY(0);
40+
opacity: 1;
41+
}
42+
}

libs/share-styles/src/styles/dialog.scss

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,39 @@ ngneat-dialog {
1414
.ngneat-dialog-backdrop {
1515
.ngneat-dialog-content {
1616
padding: 18px;
17-
animation: unset !important;
17+
// animation: unset !important;
1818
box-shadow: unset !important;
1919
}
2020

21-
animation: unset !important;
22-
}
23-
}
24-
25-
@keyframes dialog-open-2 {
26-
0% {
27-
opacity: 0.5;
28-
transform: scale(0.7);
29-
}
30-
100% {
31-
transform: none;
32-
opacity: 1;
21+
// animation: unset !important;
3322
}
3423
}
3524

3625
.mix-dialog {
3726
&__header {
3827
font-size: 18px;
39-
margin-bottom: 4px;
28+
font-weight: 700;
4029
}
4130

4231
&__content {
4332
margin: 24px 0px;
4433
}
4534

4635
&__footer {
47-
margin-top: 4px;
4836
display: flex;
4937
align-items: center;
50-
gap: 4px;
5138
justify-content: flex-end;
39+
gap: 4px;
40+
}
41+
}
42+
43+
@keyframes dialog-open-2 {
44+
0% {
45+
opacity: 0.5;
46+
transform: scale(0.7);
47+
}
48+
100% {
49+
transform: none;
50+
opacity: 1;
5251
}
5352
}

0 commit comments

Comments
 (0)