From b94d3de748dadbf29b8984a204e687319610b75d Mon Sep 17 00:00:00 2001 From: develite98 Date: Tue, 28 Nov 2023 11:45:16 +0700 Subject: [PATCH] feat(): update rich text editor --- .../database-data/database-data.component.ts | 8 +++-- .../record-form/record-form.component.html | 32 +++++++++++-------- .../record-form/record-form.component.ts | 10 ++++-- .../formly-control-layout.component.html | 6 ++-- .../formly-control-layout.component.scss | 12 +++++++ .../formly-control-layout.component.ts | 8 ++++- .../rich-text-editor.component.html | 17 +++++----- .../rich-text-editor.component.scss | 20 +++++++++--- libs/share-styles/src/styles/dialog.scss | 31 +++++++++--------- 9 files changed, 94 insertions(+), 50 deletions(-) diff --git a/apps/mix-cms/src/app/pages/portal/database-data/database-data.component.ts b/apps/mix-cms/src/app/pages/portal/database-data/database-data.component.ts index 4fcb5319..64697911 100644 --- a/apps/mix-cms/src/app/pages/portal/database-data/database-data.component.ts +++ b/apps/mix-cms/src/app/pages/portal/database-data/database-data.component.ts @@ -353,7 +353,9 @@ export class DatabaseDataComponent const dialogRef = this.dialog.open(RecordFormComponent, { data: { mixDatabase: value.db, data: undefined }, - width: 800, + windowClass: RecordFormComponent.windowClass, + minWidth: RecordFormComponent.minWidth, + maxWidth: RecordFormComponent.maxWidth, }); dialogRef.afterClosed$.subscribe((value) => { @@ -375,7 +377,9 @@ export class DatabaseDataComponent const dialogRef = this.dialog.open(RecordFormComponent, { data: { mixDatabase: state.db, data: state.data[dataIndex] }, - width: 800, + windowClass: RecordFormComponent.windowClass, + minWidth: RecordFormComponent.minWidth, + maxWidth: RecordFormComponent.maxWidth, }); dialogRef.afterClosed$.subscribe((value) => { diff --git a/libs/mix-share/src/components/record-form/record-form.component.html b/libs/mix-share/src/components/record-form/record-form.component.html index 507a233f..66cb1705 100644 --- a/libs/mix-share/src/components/record-form/record-form.component.html +++ b/libs/mix-share/src/components/record-form/record-form.component.html @@ -1,25 +1,31 @@
- {{ mode === 'create' ? 'Create' : 'Update'}} record from {{ ref.data.mixDatabase.displayName }} + {{ mode === 'create' ? 'Create' : 'Update' }} record from + {{ ref.data.mixDatabase.displayName }}
- +
- diff --git a/libs/mix-share/src/components/record-form/record-form.component.ts b/libs/mix-share/src/components/record-form/record-form.component.ts index 95e0b68d..a11768c9 100644 --- a/libs/mix-share/src/components/record-form/record-form.component.ts +++ b/libs/mix-share/src/components/record-form/record-form.component.ts @@ -29,8 +29,12 @@ import { TuiFileLike } from '@taiga-ui/kit'; changeDetection: ChangeDetectionStrategy.OnPush, }) export class RecordFormComponent extends BaseComponent implements OnInit { - mixApi = inject(MixApiFacadeService); - ref: DialogRef< + public static windowClass = 'mix-record-form-dialog'; + public static minWidth = '800px'; + public static maxWidth = '95vw'; + + public mixApi = inject(MixApiFacadeService); + public ref: DialogRef< { mixDatabase: MixDatabase; data: MixDynamicData | undefined; @@ -83,7 +87,7 @@ export class RecordFormComponent extends BaseComponent implements OnInit { }, db.displayName ) - .pipe(this.observerLoadingState()) + .pipe(this.observerLoadingStateSignal()) .subscribe((result) => { this.ref.close(result); }); diff --git a/libs/mix-ui/src/base/formly-control-layout/formly-control-layout.component.html b/libs/mix-ui/src/base/formly-control-layout/formly-control-layout.component.html index b66778de..55b5ade5 100644 --- a/libs/mix-ui/src/base/formly-control-layout/formly-control-layout.component.html +++ b/libs/mix-ui/src/base/formly-control-layout/formly-control-layout.component.html @@ -1,10 +1,10 @@ -
-
+
+
{{ description }}
-
+
diff --git a/libs/mix-ui/src/base/formly-control-layout/formly-control-layout.component.scss b/libs/mix-ui/src/base/formly-control-layout/formly-control-layout.component.scss index e69de29b..dc0665db 100644 --- a/libs/mix-ui/src/base/formly-control-layout/formly-control-layout.component.scss +++ b/libs/mix-ui/src/base/formly-control-layout/formly-control-layout.component.scss @@ -0,0 +1,12 @@ +.formly-control-item { + display: flex; + gap: 8px; +} + +formly-field { + display: block; + + &:not(:last-of-type) { + margin-bottom: 1rem; + } +} diff --git a/libs/mix-ui/src/base/formly-control-layout/formly-control-layout.component.ts b/libs/mix-ui/src/base/formly-control-layout/formly-control-layout.component.ts index 8306d345..ebeaacaf 100644 --- a/libs/mix-ui/src/base/formly-control-layout/formly-control-layout.component.ts +++ b/libs/mix-ui/src/base/formly-control-layout/formly-control-layout.component.ts @@ -1,5 +1,10 @@ import { CommonModule } from '@angular/common'; -import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { + ChangeDetectionStrategy, + Component, + Input, + ViewEncapsulation, +} from '@angular/core'; @Component({ selector: 'mix-formly-control-layout', @@ -8,6 +13,7 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; templateUrl: './formly-control-layout.component.html', styleUrls: ['./formly-control-layout.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None, }) export class FormlyControlLayoutComponent { @Input() title?: string = ''; diff --git a/libs/mix-ui/src/rich-text-editor/rich-text-editor.component.html b/libs/mix-ui/src/rich-text-editor/rich-text-editor.component.html index 9a971779..49dbe463 100644 --- a/libs/mix-ui/src/rich-text-editor/rich-text-editor.component.html +++ b/libs/mix-ui/src/rich-text-editor/rich-text-editor.component.html @@ -1,15 +1,16 @@ -
+
{{ placeHolder }} - - - {{ zoom ? 'pinch_zoom_in' : 'pinch_zoom_out' }} + + + {{ zoom ? 'zoom_in' : 'zoom_out' }}
diff --git a/libs/mix-ui/src/rich-text-editor/rich-text-editor.component.scss b/libs/mix-ui/src/rich-text-editor/rich-text-editor.component.scss index 29631ed5..fb09b9c8 100644 --- a/libs/mix-ui/src/rich-text-editor/rich-text-editor.component.scss +++ b/libs/mix-ui/src/rich-text-editor/rich-text-editor.component.scss @@ -14,11 +14,12 @@ tui-editor { &.--full-width { position: fixed; - width: 100vw; - height: 100vh; - top: 0; - left: 0; + width: 50vw; + height: calc(100vh - 8px); + top: 4px; + right: 4px; z-index: 50; + animation: fullwidth-open 0.1s cubic-bezier(0, 0, 0.2, 1); } &__button { @@ -28,3 +29,14 @@ tui-editor { background-color: #fff; } } + +@keyframes fullwidth-open { + 0% { + opacity: 0.2; + transform: translateX(50%); + } + 100% { + transform: translateY(0); + opacity: 1; + } +} diff --git a/libs/share-styles/src/styles/dialog.scss b/libs/share-styles/src/styles/dialog.scss index f914cf56..4200cf20 100644 --- a/libs/share-styles/src/styles/dialog.scss +++ b/libs/share-styles/src/styles/dialog.scss @@ -14,29 +14,18 @@ ngneat-dialog { .ngneat-dialog-backdrop { .ngneat-dialog-content { padding: 18px; - animation: unset !important; + // animation: unset !important; box-shadow: unset !important; } - animation: unset !important; - } -} - -@keyframes dialog-open-2 { - 0% { - opacity: 0.5; - transform: scale(0.7); - } - 100% { - transform: none; - opacity: 1; + // animation: unset !important; } } .mix-dialog { &__header { font-size: 18px; - margin-bottom: 4px; + font-weight: 700; } &__content { @@ -44,10 +33,20 @@ ngneat-dialog { } &__footer { - margin-top: 4px; display: flex; align-items: center; - gap: 4px; justify-content: flex-end; + gap: 4px; + } +} + +@keyframes dialog-open-2 { + 0% { + opacity: 0.5; + transform: scale(0.7); + } + 100% { + transform: none; + opacity: 1; } }