-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(edit-contentlet): Allow User Write Code #26045
* dev: add monao editor * dev: set monaco editor * dev: make editor cover space available * test: cover DottBinaryFieldEditorComponent test cases * dev: add type/mimeType validation * clean up * dev: build binary field and add validation message for file name * test: fix broken test * dev: hide old edit file on new binary field * Feedback: Freddy's suggestion
- Loading branch information
1 parent
fff1da4
commit ebc9007
Showing
17 changed files
with
643 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
core-web/libs/contenttype-fields/src/lib/fields/binary-field/binary-field.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...ds/binary-field/components/dot-binary-field-editor/dot-binary-field-editor.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<form class="editor-mode__form" [formGroup]="form" (ngSubmit)="onSubmit()"> | ||
<div class="editor-mode__input-container"> | ||
<label class="editor-mode__label" for="file-name"> | ||
<span class="editor-mode__label-text">File Name</span> | ||
</label> | ||
<input | ||
id="file-name" | ||
type="text" | ||
pInputText | ||
formControlName="name" | ||
autocomplete="off" | ||
pInputText | ||
placeholder="Ex. template.html" /> | ||
<div class="error-message"> | ||
<dot-field-validation-message | ||
[patternErrorMessage]="'dot.binary.field.error.type.file.not.extension'" | ||
[field]="form.get('name')" | ||
data-testId="error-message"></dot-field-validation-message> | ||
</div> | ||
</div> | ||
<div class="binary-field__editor-container"> | ||
<ngx-monaco-editor | ||
class="binary-field__code-editor" | ||
#editorRef | ||
[ngClass]="{ 'binary-field__code-editor--disabled': form.disabled }" | ||
[options]="editorOptions" | ||
formControlName="content" | ||
data-testId="code-editor"></ngx-monaco-editor> | ||
|
||
<div class="editor-mode__helper" [ngClass]="{ 'editor-mode__helper--visible': mimeType }"> | ||
<i class="pi pi-info-circle"></i> | ||
<small>Mime Type: {{ mimeType }}</small> | ||
</div> | ||
</div> | ||
<div class="editor-mode__actions"> | ||
<p-button | ||
[label]="'dot.common.cancel' | dm" | ||
(click)="cancel.emit()" | ||
styleClass="p-button-outlined" | ||
type="button" | ||
aria-label="Cancel button" | ||
data-testId="cancel-button"></p-button> | ||
|
||
<p-button | ||
[label]="'dot.common.save' | dm" | ||
type="submit" | ||
aria-label="Import button" | ||
data-testId="import-button"></p-button> | ||
</div> | ||
</form> |
82 changes: 82 additions & 0 deletions
82
...ds/binary-field/components/dot-binary-field-editor/dot-binary-field-editor.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
@use "variables" as *; | ||
|
||
.binary-field__editor-container { | ||
display: flex; | ||
justify-content: center; | ||
align-items: flex-start; | ||
flex-direction: column; | ||
flex: 1; | ||
width: 100%; | ||
gap: $spacing-1; | ||
} | ||
|
||
.binary-field__code-editor { | ||
border: 1px solid $color-palette-gray-400; // Input | ||
display: block; | ||
flex-grow: 1; | ||
width: 100%; | ||
min-height: 20rem; | ||
border-radius: $border-radius-md; | ||
overflow: auto; | ||
} | ||
|
||
.binary-field__code-editor--disabled { | ||
background-color: $color-palette-gray-200; | ||
opacity: 0.5; | ||
|
||
&::ng-deep { | ||
.monaco-mouse-cursor-text, | ||
.overflow-guard { | ||
cursor: not-allowed; | ||
} | ||
} | ||
} | ||
|
||
.editor-mode__form { | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: flex-start; | ||
} | ||
|
||
.editor-mode__input-container { | ||
width: 100%; | ||
display: flex; | ||
gap: $spacing-1; | ||
flex-direction: column; | ||
} | ||
|
||
.editor-mode__input { | ||
width: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.editor-mode__actions { | ||
width: 100%; | ||
display: flex; | ||
gap: $spacing-1; | ||
align-items: center; | ||
justify-content: flex-end; | ||
} | ||
|
||
.editor-mode__helper { | ||
display: flex; | ||
justify-content: flex-start; | ||
align-items: center; | ||
gap: $spacing-1; | ||
color: $color-palette-gray-700; | ||
font-weight: $font-size-sm; | ||
visibility: hidden; | ||
} | ||
|
||
.editor-mode__helper--visible { | ||
visibility: visible; | ||
} | ||
|
||
.error-message { | ||
min-height: $spacing-4; // Fix height to avoid jumping | ||
justify-content: flex-start; | ||
display: flex; | ||
} |
Oops, something went wrong.