Newer
Older
Component, ElementRef, EventEmitter, Input, Output, ViewChild
import { ElementComponent } from '../../directives/element-component.directive';
import { TextElement } from './text-element';
import { ValueChangeElement } from '../../models/uI-element';
<div [class.center-content]="elementModel.positionProps.dynamicPositioning &&
elementModel.positionProps.fixedSize"
[style.width]="elementModel.positionProps.fixedSize ? elementModel.width + 'px' : '100%'"
[style.height]="elementModel.positionProps.fixedSize ? elementModel.height + 'px' : 'auto'">
<app-marking-bar
*ngIf="elementModel.highlightableYellow ||
elementModel.highlightableTurquoise ||
elementModel.highlightableOrange"
[element]="container"
[elementModel]="elementModel"
(applySelection)="applySelection.emit($event)">
</app-marking-bar>
<div #container class="text-container"
[style.background-color]="elementModel.surfaceProps.backgroundColor"
[style.color]="elementModel.fontProps.fontColor"
[style.font-family]="elementModel.fontProps.font"
[style.font-size.px]="elementModel.fontProps.fontSize"
[style.line-height.%]="elementModel.fontProps.lineHeight"
[style.font-weight]="elementModel.fontProps.bold ? 'bold' : ''"
[style.font-style]="elementModel.fontProps.italic ? 'italic' : ''"
[style.text-decoration]="elementModel.fontProps.underline ? 'underline' : ''"
(mouseup)="startSelection.emit($event)"
[innerHTML]="elementModel.text | safeResourceHTML">
`,
styles: [
'::ng-deep .text-container p strong {letter-spacing: 0.04em; font-weight: 600;}', // bold less bold
'::ng-deep .text-container p:empty::after {content: "\\00A0"}', // render empty p
'::ng-deep .text-container h1 {font-weight: bold; font-size: 20px;}',
'::ng-deep .text-container h2 {font-weight: bold; font-size: 18px;}',
'::ng-deep .text-container h3 {font-weight: bold; font-size: 16px;}',
'::ng-deep .text-container h4 {font-weight: normal; font-size: 16px;}',
':host ::ng-deep mark {color: inherit}'
export class TextComponent extends ElementComponent {
@Input() elementModel!: TextElement;
@Output() elementValueChanged = new EventEmitter<ValueChangeElement>();
@Output() startSelection = new EventEmitter<MouseEvent>();
@Output() applySelection = new EventEmitter<{
mode: 'mark' | 'underline' | 'delete',
color: string,
element: HTMLElement
}>();
@ViewChild('container') containerDiv!: ElementRef;