fix blockviewer

This commit is contained in:
Çetin 2022-01-06 17:39:33 +03:00
parent 05a37558d5
commit d761428836

View File

@ -18,19 +18,18 @@ enum BlockView {
</span>
<div class="block-actions">
<a tabindex="0" [ngClass]="{'block-action-active': blockView == BlockView.PREVIEW}" (click)="activateView($event, BlockView.PREVIEW)"><span>Preview</span></a>
<a [attr.tabindex]="codeDisabled ? null: '0'" [ngClass]="{'block-action-active': blockView == BlockView.CODE, 'block-action-disabled': codeDisabled}" (click)="activateView($event, BlockView.CODE)">
<i class="pi pi-lock" *ngIf="codeDisabled"></i>
<a [attr.tabindex]="'0'" [ngClass]="{'block-action-active': blockView == BlockView.CODE}" (click)="activateView($event, BlockView.CODE)">
<span>Code</span>
</a>
<a [attr.tabindex]="codeDisabled ? null: '0'" class="block-action-copy" [ngClass]="{'block-action-disabled': codeDisabled}" (click)="copyCode($event)"
pTooltip="Copied to clipboard" tooltipEvent="focus" tooltipPosition="bottom" [tooltipDisabled]="codeDisabled"><i class="pi pi-copy"></i></a>
<a [attr.tabindex]="'0'" class="block-action-copy" (click)="copyCode($event)"
pTooltip="Copied to clipboard" tooltipEvent="focus" tooltipPosition="bottom"><i class="pi pi-copy"></i></a>
</div>
</div>
<div class="block-content">
<div [class]="containerClass" [ngStyle]="previewStyle" *ngIf="blockView == BlockView.PREVIEW">
<ng-content></ng-content>
</div>
<div *ngIf="blockView == BlockView.CODE && !codeDisabled">
<div *ngIf="blockView == BlockView.CODE">
<app-code lang="markup" ngPreserveWhitespaces>{{code}}
</app-code>
</div>
@ -49,7 +48,7 @@ export class BlockViewer {
@Input() previewStyle: string;
@Input() free: boolean = false;
@Input() free: boolean = true;
@Input() new: boolean = false;
@ -58,23 +57,14 @@ export class BlockViewer {
blockView: BlockView = BlockView.PREVIEW;
activateView(event: Event, blockView: BlockView) {
if (!this.codeDisabled) {
this.blockView = blockView;
}
this.blockView = blockView;
event.preventDefault();
}
async copyCode(event: Event) {
if (!this.codeDisabled) {
await navigator.clipboard.writeText(this.code);
}
event.preventDefault();
}
get codeDisabled() {
return this.free ? false : (environment ? environment.production: false);
}
}