thingsboard/ui-ngx/src/app/shared/components/markdown-editor.component.html
2024-10-15 13:23:36 +03:00

51 lines
2.4 KiB
HTML

<!--
Copyright © 2016-2024 The Thingsboard Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div class="markdown-content" [class.tb-edit-mode]="!readonly"
tb-fullscreen [fullscreen]="fullscreen" (fullscreenChanged)="onFullscreen()">
<div style="min-height: 40px;" class="markdown-editor-toolbar flex flex-row items-center justify-start">
<label class="tb-title no-padding" [class]="{'tb-error': !disabled && required && !markdownValue, 'tb-required': !disabled && required}">{{ label }}</label>
<span class="flex-1"></span>
<button [class.!hidden]="editorMode"
type="button"
mat-button (click)="toggleEditMode()">{{ 'markdown.edit' | translate }}</button>
<button [class.!hidden]="!editorMode"
type="button"
mat-button (click)="toggleEditMode()">{{ 'markdown.preview' | translate }}</button>
<div *ngIf = "helpId" [tb-help-popup]="helpId"></div>
<fieldset style="width: initial">
<div matTooltip="{{(fullscreen ? 'fullscreen.exit' : 'fullscreen.expand') | translate}}"
matTooltipPosition="above"
style="border-radius: 50%"
(click)="fullscreen = !fullscreen">
<button type='button' mat-icon-button class="tb-mat-32">
<mat-icon class="material-icons">{{ fullscreen ? 'fullscreen_exit' : 'fullscreen' }}</mat-icon>
</button>
</div>
</fieldset>
</div>
<div [class.!hidden]="readonly || disabled" class="markdown-content-editor">
<div [class.!hidden]="!editorMode" #markdownEditor class="tb-markdown-editor"></div>
<div [class.!hidden]="editorMode" class="tb-markdown-view-container">
<tb-markdown [data]="renderValue" lineNumbers fallbackToPlainMarkdown></tb-markdown>
</div>
</div>
<div *ngIf="readonly || disabled" class="tb-markdown-view-container">
<tb-markdown [data]="renderValue" lineNumbers fallbackToPlainMarkdown></tb-markdown>
</div>
</div>