@firestitch/block-editor 12.4.5 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/esm2020/app/components/artboard/artboard.component.mjs +87 -0
  2. package/esm2020/app/components/block/block.component.mjs +547 -0
  3. package/esm2020/app/components/block-editor/block-editor.component.mjs +82 -0
  4. package/esm2020/app/components/group/group-dialog.component.mjs +47 -0
  5. package/esm2020/app/components/layers-reorder-dialog/layers-reorder-dialog.component.mjs +42 -0
  6. package/esm2020/app/components/sidebar/sidebar.component.mjs +353 -0
  7. package/{esm2015/app/directives/block-editor-margin.directive.js → esm2020/app/directives/block-editor-margin.directive.mjs} +4 -4
  8. package/{esm2015/app/directives/block-editor-sidebar-panel.directive.js → esm2020/app/directives/block-editor-sidebar-panel.directive.mjs} +4 -4
  9. package/{esm2015/app/fs-block-editor.module.js → esm2020/app/fs-block-editor.module.mjs} +5 -5
  10. package/{esm2015/app/pipes/create-image-url.pipe.js → esm2020/app/pipes/create-image-url.pipe.mjs} +4 -4
  11. package/esm2020/app/services/block-editor.service.mjs +287 -0
  12. package/{esm2015/app/services/blocks-store.service.js → esm2020/app/services/blocks-store.service.mjs} +4 -4
  13. package/fesm2015/firestitch-block-editor.mjs +1654 -0
  14. package/fesm2015/firestitch-block-editor.mjs.map +1 -0
  15. package/fesm2020/firestitch-block-editor.mjs +1687 -0
  16. package/fesm2020/firestitch-block-editor.mjs.map +1 -0
  17. package/package.json +21 -8
  18. package/bundles/firestitch-block-editor.umd.js +0 -2260
  19. package/bundles/firestitch-block-editor.umd.js.map +0 -1
  20. package/esm2015/app/components/artboard/artboard.component.js +0 -89
  21. package/esm2015/app/components/block/block.component.js +0 -550
  22. package/esm2015/app/components/block-editor/block-editor.component.js +0 -86
  23. package/esm2015/app/components/group/group-dialog.component.js +0 -48
  24. package/esm2015/app/components/layers-reorder-dialog/layers-reorder-dialog.component.js +0 -46
  25. package/esm2015/app/components/sidebar/sidebar.component.js +0 -349
  26. package/esm2015/app/services/block-editor.service.js +0 -265
  27. package/fesm2015/firestitch-block-editor.js +0 -1675
  28. package/fesm2015/firestitch-block-editor.js.map +0 -1
  29. /package/{esm2015/app/components/block/index.js → esm2020/app/components/block/index.mjs} +0 -0
  30. /package/{esm2015/app/components/group/index.js → esm2020/app/components/group/index.mjs} +0 -0
  31. /package/{esm2015/app/components/index.js → esm2020/app/components/index.mjs} +0 -0
  32. /package/{esm2015/app/components/layers-reorder-dialog/index.js → esm2020/app/components/layers-reorder-dialog/index.mjs} +0 -0
  33. /package/{esm2015/app/components/sidebar/index.js → esm2020/app/components/sidebar/index.mjs} +0 -0
  34. /package/{esm2015/app/consts/block-formats.const.js → esm2020/app/consts/block-formats.const.mjs} +0 -0
  35. /package/{esm2015/app/consts/block-types.const.js → esm2020/app/consts/block-types.const.mjs} +0 -0
  36. /package/{esm2015/app/consts/index.js → esm2020/app/consts/index.mjs} +0 -0
  37. /package/{esm2015/app/directives/index.js → esm2020/app/directives/index.mjs} +0 -0
  38. /package/{esm2015/app/enums/block-format.enum.js → esm2020/app/enums/block-format.enum.mjs} +0 -0
  39. /package/{esm2015/app/enums/block-type.enum.js → esm2020/app/enums/block-type.enum.mjs} +0 -0
  40. /package/{esm2015/app/enums/index.js → esm2020/app/enums/index.mjs} +0 -0
  41. /package/{esm2015/app/interfaces/block-editor-config.js → esm2020/app/interfaces/block-editor-config.mjs} +0 -0
  42. /package/{esm2015/app/interfaces/block-group.js → esm2020/app/interfaces/block-group.mjs} +0 -0
  43. /package/{esm2015/app/interfaces/block.js → esm2020/app/interfaces/block.mjs} +0 -0
  44. /package/{esm2015/app/interfaces/index.js → esm2020/app/interfaces/index.mjs} +0 -0
  45. /package/{esm2015/app/services/index.js → esm2020/app/services/index.mjs} +0 -0
  46. /package/{esm2015/firestitch-block-editor.js → esm2020/firestitch-block-editor.mjs} +0 -0
  47. /package/{esm2015/public_api.js → esm2020/public_api.mjs} +0 -0
@@ -1,1675 +0,0 @@
1
- import * as i17 from '@angular/common';
2
- import { DOCUMENT, CommonModule } from '@angular/common';
3
- import * as i0 from '@angular/core';
4
- import { Component, ChangeDetectionStrategy, Inject, Directive, Input, Injectable, Pipe, ViewChild, HostBinding, HostListener, EventEmitter, ContentChildren, Output, ViewChildren, ElementRef, NgModule } from '@angular/core';
5
- import * as i5 from '@angular/forms';
6
- import { FormsModule } from '@angular/forms';
7
- import * as i7$1 from '@angular/cdk/drag-drop';
8
- import { moveItemInArray, DragDropModule } from '@angular/cdk/drag-drop';
9
- import * as i4 from '@angular/material/button';
10
- import { MatButtonModule } from '@angular/material/button';
11
- import * as i12 from '@angular/material/checkbox';
12
- import { MatCheckboxModule } from '@angular/material/checkbox';
13
- import * as i9 from '@angular/material/form-field';
14
- import { MatFormFieldModule } from '@angular/material/form-field';
15
- import * as i3 from '@angular/material/icon';
16
- import { MatIconModule } from '@angular/material/icon';
17
- import * as i7 from '@angular/material/input';
18
- import { MatInputModule } from '@angular/material/input';
19
- import * as i4$1 from '@angular/material/list';
20
- import { MatListModule } from '@angular/material/list';
21
- import * as i10 from '@angular/material/select';
22
- import { MatSelectModule } from '@angular/material/select';
23
- import * as i18 from '@angular/material/tooltip';
24
- import { MatTooltipModule } from '@angular/material/tooltip';
25
- import { FsAutocompleteModule } from '@firestitch/autocomplete';
26
- import * as i14 from '@firestitch/colorpicker';
27
- import { FsColorPickerModule } from '@firestitch/colorpicker';
28
- import * as i2 from '@firestitch/dialog';
29
- import { FsDialogModule } from '@firestitch/dialog';
30
- import * as i6$1 from '@firestitch/file';
31
- import { FsFileModule } from '@firestitch/file';
32
- import * as i2$1 from '@firestitch/font-picker';
33
- import { FsFontPickerModule } from '@firestitch/font-picker';
34
- import * as i6 from '@firestitch/form';
35
- import { FsFormModule } from '@firestitch/form';
36
- import * as i20 from '@firestitch/mask';
37
- import { FsMaskModule } from '@firestitch/mask';
38
- import { FsMenuModule } from '@firestitch/menu';
39
- import * as i2$3 from '@firestitch/zoom-pan';
40
- import { FsZoomPanComponent, FsZoomPanModule } from '@firestitch/zoom-pan';
41
- import * as i1 from '@angular/material/dialog';
42
- import { MAT_DIALOG_DATA } from '@angular/material/dialog';
43
- import { guid, index, round } from '@firestitch/common';
44
- import { of, Subject, BehaviorSubject, throwError, from, fromEvent } from 'rxjs';
45
- import * as i8 from '@angular/cdk/text-field';
46
- import { filter, map, takeUntil, switchMap, tap, mapTo, groupBy, debounceTime, mergeAll, skip, delay } from 'rxjs/operators';
47
- import * as i3$1 from '@firestitch/prompt';
48
- import * as i5$1 from '@angular/material/divider';
49
- import Moveable from 'moveable';
50
- import * as i1$1 from '@firestitch/api';
51
- import * as i2$2 from '@firestitch/clipboard';
52
- import * as i3$2 from '@firestitch/message';
53
- import * as i11 from '@angular/material/core';
54
-
55
- class GroupDialogComponent {
56
- constructor(_data, _dialogRef) {
57
- this._data = _data;
58
- this._dialogRef = _dialogRef;
59
- this.save = () => {
60
- if (this.blockGroup.name) {
61
- }
62
- else {
63
- this.blockGroup = Object.assign(Object.assign({}, this.blockGroup), { name: guid() });
64
- this._blockEditor.blockGroups.push(this.blockGroup);
65
- }
66
- this._dialogRef.close(this.blockGroup);
67
- return of(true);
68
- };
69
- }
70
- ngOnInit() {
71
- this._blockEditor = this._data.blockEditor;
72
- this.blockGroup = this._data.blockGroup || {};
73
- this.block = this._data.block;
74
- }
75
- }
76
- GroupDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: GroupDialogComponent, deps: [{ token: MAT_DIALOG_DATA }, { token: i1.MatDialogRef }], target: i0.ɵɵFactoryTarget.Component });
77
- GroupDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: GroupDialogComponent, selector: "ng-component", ngImport: i0, template: "<form fsForm [submit]=\"save\">\n <fs-dialog>\n <h1 mat-dialog-title>Group</h1>\n <mat-dialog-content>\n <mat-form-field class=\"full-width\">\n <textarea\n matInput\n [cdkTextareaAutosize]=\"true\"\n [(ngModel)]=\"blockGroup.label\"\n name=\"groupLabel\"\n [required]=\"true\"\n placeholder=\"Group Label\">\n </textarea>\n </mat-form-field>\n <mat-form-field class=\"full-width\">\n <mat-label>Group Description</mat-label>\n <textarea\n matInput\n [cdkTextareaAutosize]=\"true\"\n [(ngModel)]=\"blockGroup.description\"\n name=\"groupDescription\">\n </textarea>\n </mat-form-field> \n </mat-dialog-content>\n <mat-dialog-actions>\n <button \n mat-button \n type=\"submit\"\n color=\"primary\">\n Save\n </button>\n <button \n mat-button \n type=\"button\"\n mat-dialog-close>\n Cancel\n </button>\n </mat-dialog-actions>\n </fs-dialog>\n</form>", styles: [""], components: [{ type: i2.FsDialogComponent, selector: "fs-dialog", inputs: ["mobileMode"] }, { type: i9.MatFormField, selector: "mat-form-field", inputs: ["color", "floatLabel", "appearance", "hideRequiredMarker", "hintLabel"], exportAs: ["matFormField"] }, { type: i4.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i5.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i5.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i5.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i6.FsFormDirective, selector: "[fsForm]", inputs: ["wrapperSelector", "messageSelector", "hintSelector", "labelSelector", "autocomplete", "shortcuts", "confirm", "confirmDialog", "confirmDrawer", "confirmBrowser", "confirmTabs", "dirtySubmitButton", "submit", "successDelay", "errorDelay", "tabGroup", "deactivationGuard"], outputs: ["fsForm", "invalid", "valid", "submitted", "reseted", "cleared"] }, { type: i1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { type: i1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { type: i7.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["id", "disabled", "required", "type", "value", "readonly", "placeholder", "errorStateMatcher", "aria-describedby"], exportAs: ["matInput"] }, { type: i8.CdkTextareaAutosize, selector: "textarea[cdkTextareaAutosize]", inputs: ["cdkAutosizeMinRows", "cdkAutosizeMaxRows", "cdkTextareaAutosize", "placeholder"], exportAs: ["cdkTextareaAutosize"] }, { type: i5.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i5.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i6.FsFormRequiredDirective, selector: "[fsFormRequired],[ngModel][required]", inputs: ["fsFormRequired", "required", "fsFormRequiredMessage"] }, { type: i5.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i9.MatLabel, selector: "mat-label" }, { type: i6.FsFormNoFsValidatorsDirective, selector: "[ngModel]:not([required]):not([fsFormRequired]):not([fsFormCompare]):not([fsFormDateRange]):not([fsFormEmail]):not([fsFormEmails]):not([fsFormFunction]):not([fsFormGreater]):not([fsFormInteger]):not([fsFormLesser]):not([fsFormMax]):not([fsFormMaxLength]):not([fsFormMin]):not([fsFormMinLength]):not([fsFormNumeric]):not([fsFormPattern]):not([fsFormPhone]):not([fsFormUrl]):not([validate])" }, { type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }, { type: i6.FsButtonDirective, selector: "[mat-raised-button],[mat-button],[mat-flat-button],[mat-stroked-button]", inputs: ["name", "dirtySubmit", "form"] }, { type: i1.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["type", "mat-dialog-close", "aria-label", "matDialogClose"], exportAs: ["matDialogClose"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
78
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: GroupDialogComponent, decorators: [{
79
- type: Component,
80
- args: [{
81
- templateUrl: './group-dialog.component.html',
82
- styleUrls: ['./group-dialog.component.scss'],
83
- changeDetection: ChangeDetectionStrategy.OnPush,
84
- }]
85
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
86
- type: Inject,
87
- args: [MAT_DIALOG_DATA]
88
- }] }, { type: i1.MatDialogRef }]; } });
89
-
90
- class FsBlockEditorMarginDirective {
91
- constructor(_elementRef) {
92
- this._elementRef = _elementRef;
93
- }
94
- get element() {
95
- return this._elementRef.nativeElement;
96
- }
97
- }
98
- FsBlockEditorMarginDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorMarginDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
99
- FsBlockEditorMarginDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorMarginDirective, selector: "[fsBlockEditorMargin]", ngImport: i0 });
100
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorMarginDirective, decorators: [{
101
- type: Directive,
102
- args: [{
103
- selector: '[fsBlockEditorMargin]'
104
- }]
105
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
106
-
107
- class FsBlockEditorSidebarPanelDirective {
108
- constructor(templateRef) {
109
- this.templateRef = templateRef;
110
- this.show = true;
111
- }
112
- }
113
- FsBlockEditorSidebarPanelDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorSidebarPanelDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
114
- FsBlockEditorSidebarPanelDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorSidebarPanelDirective, selector: "[fsBlockEditorSidebarPanel]", inputs: { label: "label", show: "show" }, ngImport: i0 });
115
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorSidebarPanelDirective, decorators: [{
116
- type: Directive,
117
- args: [{
118
- selector: '[fsBlockEditorSidebarPanel]',
119
- }]
120
- }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; }, propDecorators: { label: [{
121
- type: Input
122
- }], show: [{
123
- type: Input
124
- }] } });
125
-
126
- var BlockType;
127
- (function (BlockType) {
128
- BlockType["Rectangle"] = "rectangle";
129
- BlockType["ShortText"] = "shorttext";
130
- BlockType["LongText"] = "longtext";
131
- BlockType["Image"] = "image";
132
- BlockType["RadioButton"] = "radiobutton";
133
- BlockType["Checkbox"] = "checkbox";
134
- BlockType["Signature"] = "signature";
135
- BlockType["Pdf"] = "pdf";
136
- BlockType["Date"] = "date";
137
- })(BlockType || (BlockType = {}));
138
-
139
- var BlockFormat;
140
- (function (BlockFormat) {
141
- BlockFormat["Date"] = "date";
142
- BlockFormat["YYYYMMDD"] = "YYYY/MM/DD";
143
- BlockFormat["Currency"] = "currency";
144
- BlockFormat["Number"] = "number";
145
- })(BlockFormat || (BlockFormat = {}));
146
-
147
- const BlockTypes = [
148
- { value: BlockType.Rectangle, name: 'Rectangle', icon: 'crop_5_4', type: 'draw' },
149
- { value: BlockType.ShortText, name: 'Short Text', icon: 'short_text', type: 'form' },
150
- { value: BlockType.LongText, name: 'Long Text', icon: 'subject', type: 'form' },
151
- { value: BlockType.RadioButton, name: 'Radio Button', icon: 'radio_button_checked', type: 'form' },
152
- { value: BlockType.Checkbox, name: 'Checkbox', icon: 'check_box', type: 'form' },
153
- { value: BlockType.Date, name: 'Date', icon: 'calendar_today', type: 'form' },
154
- { value: BlockType.Signature, name: 'Signature', icon: 'draw', type: 'form' },
155
- { value: BlockType.Image, name: 'Image', icon: 'image', accept: 'image/*', type: 'draw' },
156
- { value: BlockType.Pdf, name: 'Pdf', icon: 'picture_as_pdf', accept: 'application/pdf', type: 'draw' },
157
- ];
158
-
159
- class LayersReorderDialogComponent {
160
- constructor(_dialogData, _dialogRef) {
161
- this._dialogData = _dialogData;
162
- this._dialogRef = _dialogRef;
163
- this.blockTypeIcons = index(BlockTypes, 'value', 'icon');
164
- this._init(_dialogData);
165
- }
166
- swapItems(event) {
167
- moveItemInArray(this.blocks, event.previousIndex, event.currentIndex);
168
- }
169
- done() {
170
- this._dialogRef.close(this.blocks.reverse());
171
- }
172
- _init(data) {
173
- this.blocks = data.blocks;
174
- }
175
- }
176
- LayersReorderDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LayersReorderDialogComponent, deps: [{ token: MAT_DIALOG_DATA }, { token: i1.MatDialogRef }], target: i0.ɵɵFactoryTarget.Component });
177
- LayersReorderDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: LayersReorderDialogComponent, selector: "ng-component", ngImport: i0, template: "<fs-dialog>\n <h1 mat-dialog-title><mat-icon>swap_vert</mat-icon> Reorder Blocks</h1>\n <mat-dialog-content>\n <mat-list cdkDropList (cdkDropListDropped)=\"swapItems($event)\">\n <mat-divider></mat-divider>\n <ng-container *ngFor=\"let block of blocks\">\n <mat-list-item cdkDrag cdkDragLockAxis=\"y\">\n <mat-icon cdkDragHandle>drag_handle</mat-icon>\n <mat-icon>\n {{ blockTypeIcons[block.type] }}\n </mat-icon>\n <span class=\"block-label\">\n {{ block.label || block.content || 'No Content'}} \n </span>\n </mat-list-item>\n <mat-divider></mat-divider>\n </ng-container>\n </mat-list>\n </mat-dialog-content>\n <mat-dialog-actions>\n <button mat-button color=\"primary\" (click)=\"done()\">Done</button>\n </mat-dialog-actions>\n</fs-dialog>\n", styles: ["h1{display:flex}.mat-icon{margin-right:20px}.block-label{min-width:200px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:1000px}.cdk-drag-preview{display:flex;padding-left:15px!important;background:#fff;box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.cdk-drag-preview ::ng-deep .mat-list-item-content{display:flex;flex-direction:row;align-items:center;font-size:16px}.cdk-drag-handle{cursor:grab}.cdk-drag-placeholder{opacity:.2}\n"], components: [{ type: i2.FsDialogComponent, selector: "fs-dialog", inputs: ["mobileMode"] }, { type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i4$1.MatList, selector: "mat-list, mat-action-list", inputs: ["disableRipple", "disabled"], exportAs: ["matList"] }, { type: i5$1.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { type: i4$1.MatListItem, selector: "mat-list-item, a[mat-list-item], button[mat-list-item]", inputs: ["disableRipple", "disabled"], exportAs: ["matListItem"] }, { type: i4.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { type: i1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { type: i7$1.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "id", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListAutoScrollDisabled", "cdkDropListOrientation", "cdkDropListLockAxis", "cdkDropListData", "cdkDropListAutoScrollStep"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { type: i17.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7$1.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragDisabled", "cdkDragStartDelay", "cdkDragLockAxis", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragBoundary", "cdkDragRootElement", "cdkDragPreviewContainer", "cdkDragData", "cdkDragFreeDragPosition"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { type: i7$1.CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }, { type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }, { type: i6.FsButtonDirective, selector: "[mat-raised-button],[mat-button],[mat-flat-button],[mat-stroked-button]", inputs: ["name", "dirtySubmit", "form"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
178
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LayersReorderDialogComponent, decorators: [{
179
- type: Component,
180
- args: [{
181
- templateUrl: './layers-reorder-dialog.component.html',
182
- styleUrls: ['./layers-reorder-dialog.component.scss'],
183
- changeDetection: ChangeDetectionStrategy.OnPush,
184
- }]
185
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
186
- type: Inject,
187
- args: [MAT_DIALOG_DATA]
188
- }] }, { type: i1.MatDialogRef }]; } });
189
-
190
- var EventType;
191
- (function (EventType) {
192
- EventType["Add"] = "add";
193
- EventType["Change"] = "change";
194
- EventType["Remove"] = "remove";
195
- EventType["Update"] = "update";
196
- })(EventType || (EventType = {}));
197
- class BlocksStore {
198
- constructor() {
199
- this._eventBus$ = new Subject();
200
- this._blocks$ = new BehaviorSubject([]);
201
- this._destroy$ = new Subject();
202
- }
203
- get blocks() {
204
- return [
205
- ...this._blocks$.getValue(),
206
- ];
207
- }
208
- get blocks$() {
209
- return this._blocks$.asObservable();
210
- }
211
- get blockAdded$() {
212
- return this._eventBus$
213
- .pipe(filter(({ type }) => type === EventType.Add), map(({ value }) => value));
214
- }
215
- get blockChanged$() {
216
- return this._eventBus$
217
- .pipe(filter(({ type }) => type === EventType.Change), map(({ value }) => value));
218
- }
219
- get blockUpdated$() {
220
- return this._eventBus$
221
- .pipe(filter(({ type }) => type === EventType.Update), map(({ value }) => value));
222
- }
223
- get blockRemoved$() {
224
- return this._eventBus$
225
- .pipe(filter(({ type }) => type === EventType.Remove), map(({ value }) => value));
226
- }
227
- ngOnDestroy() {
228
- this._destroy$.next();
229
- this._destroy$.complete();
230
- }
231
- init(blocks) {
232
- blocks
233
- .forEach((block) => {
234
- this._appendBlock(block);
235
- });
236
- }
237
- blockExists(block) {
238
- const index = this.blocks.findIndex((b) => {
239
- return b.guid === block.guid;
240
- });
241
- return index !== -1;
242
- }
243
- blockAdd(block) {
244
- this._appendBlock(block);
245
- }
246
- blockChange(block) {
247
- this._dispatchEvent(EventType.Change, block);
248
- }
249
- blockUpdate(block) {
250
- this._dispatchEvent(EventType.Update, block);
251
- }
252
- blockRemove(targetBlocks) {
253
- const blocks = this.blocks;
254
- if (!Array.isArray(targetBlocks)) {
255
- targetBlocks = [targetBlocks];
256
- }
257
- targetBlocks.forEach((block) => {
258
- const index = blocks
259
- .findIndex((b) => b.guid === block.guid);
260
- if (index !== -1) {
261
- blocks.splice(index, 1);
262
- this._dispatchEvent(EventType.Remove, block);
263
- }
264
- });
265
- this._setBlocks(blocks);
266
- }
267
- _setBlocks(blocks) {
268
- this._blocks$.next([...blocks]);
269
- }
270
- _appendBlock(block) {
271
- const blocks = [
272
- ...this.blocks,
273
- block,
274
- ];
275
- this._deduplicateIndexesFor(blocks);
276
- this._setBlocks(blocks);
277
- this._dispatchEvent(EventType.Add, block);
278
- }
279
- _dispatchEvent(type, value) {
280
- this._eventBus$.next({
281
- type,
282
- value,
283
- });
284
- }
285
- _deduplicateIndexesFor(blocks) {
286
- blocks.forEach((block, index) => {
287
- block.index = index;
288
- });
289
- }
290
- }
291
- BlocksStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlocksStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
292
- BlocksStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlocksStore });
293
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlocksStore, decorators: [{
294
- type: Injectable
295
- }] });
296
-
297
- class BlockEditorService {
298
- constructor(_store, _dialog, _prompt) {
299
- this._store = _store;
300
- this._dialog = _dialog;
301
- this._prompt = _prompt;
302
- this.blockGroups = [];
303
- this._selectedBlocks$ = new BehaviorSubject([]);
304
- this._blockComponents$ = new BehaviorSubject([]);
305
- this._blockClippable$ = new BehaviorSubject(null);
306
- this._destroy$ = new Subject();
307
- }
308
- get blockComponents$() {
309
- return this._blockComponents$.asObservable();
310
- }
311
- set blockComponents(blockComponents) {
312
- this._blockComponents$.next(blockComponents);
313
- }
314
- init(config) {
315
- this.config = config;
316
- this._store.init(config.blocks);
317
- this._initBlockGroups();
318
- this._initBlockChange();
319
- }
320
- blockAdd(block) {
321
- if (!this.config.blockAdd) {
322
- console.warn('[BlockEditor] Config "blockAdd" is not defined');
323
- return;
324
- }
325
- block = this._initBlock(block);
326
- this.config.blockAdd(block)
327
- .pipe(takeUntil(this._destroy$))
328
- .subscribe((newBlock) => {
329
- this._store.blockAdd(newBlock);
330
- });
331
- }
332
- blockUpload(block, fsFile) {
333
- if (!this.config.blockUpload) {
334
- return throwError('[BlockEditor] Config "blockUpload" is not defined');
335
- }
336
- const existing = this._store.blockExists(block);
337
- if (!existing) {
338
- block = this._initBlock(block);
339
- }
340
- return from(fsFile.imageInfo)
341
- .pipe(switchMap((imageInfo) => {
342
- if (!existing && (imageInfo === null || imageInfo === void 0 ? void 0 : imageInfo.height) && (imageInfo === null || imageInfo === void 0 ? void 0 : imageInfo.width)) {
343
- const ratio = imageInfo.height / imageInfo.width;
344
- block.width = this.config.width * .4;
345
- block.height = block.width * ratio;
346
- }
347
- return this.config.blockUpload(block, fsFile.file);
348
- }), tap((newBlock) => {
349
- if (existing) {
350
- this._store.blockUpdate(Object.assign(Object.assign({}, block), newBlock));
351
- }
352
- else {
353
- this.blockAdd(newBlock);
354
- }
355
- }), takeUntil(this._destroy$));
356
- }
357
- blockRemove(block) {
358
- this._store.blockRemove(block);
359
- }
360
- get blocks$() {
361
- return this._store.blocks$;
362
- }
363
- get blockChanged$() {
364
- return this._store.blockChanged$;
365
- }
366
- get blockUpdated$() {
367
- return this._store.blockUpdated$;
368
- }
369
- get blockClippable$() {
370
- return this._blockClippable$.asObservable();
371
- }
372
- set blockClippable(value) {
373
- this._blockClippable$.next(value);
374
- }
375
- get blockAdded$() {
376
- return this._store.blockAdded$;
377
- }
378
- get blockRemoved$() {
379
- return this._store.blockRemoved$;
380
- }
381
- get blocks() {
382
- return this._store.blocks;
383
- }
384
- blockChange(block) {
385
- this._store.blockChange(block);
386
- }
387
- applyBlockGroup(block, blockGroup) {
388
- block.name = blockGroup === null || blockGroup === void 0 ? void 0 : blockGroup.name;
389
- block.description = blockGroup === null || blockGroup === void 0 ? void 0 : blockGroup.description;
390
- block.label = blockGroup === null || blockGroup === void 0 ? void 0 : blockGroup.label;
391
- this.blockChange(block);
392
- }
393
- isSelectedBlock(block) {
394
- return this.selectedBlocks.indexOf(block) !== -1;
395
- }
396
- indexOf(block) {
397
- return this.blocks.map((e) => e.guid).indexOf(block.guid);
398
- }
399
- selectedBlockComponentChangeProperty(values) {
400
- this.selectedBlocks
401
- .forEach((block) => {
402
- Object.keys(values)
403
- .forEach((name) => {
404
- block[name] = values[name];
405
- });
406
- this.blockChange(block);
407
- });
408
- }
409
- blockGroupChangeProperty(blockGroup, values) {
410
- this.blocks
411
- .filter((block) => block.name === blockGroup.name)
412
- .forEach((block) => {
413
- Object.keys(values)
414
- .forEach((name) => {
415
- block[name] = values[name];
416
- });
417
- this.blockChange(block);
418
- });
419
- }
420
- get selectedBlocks$() {
421
- return this._selectedBlocks$;
422
- }
423
- set selectedBlock(block) {
424
- this.selectedBlocks = [block];
425
- }
426
- set selectedBlocks(blocks) {
427
- this._selectedBlocks$.next(blocks);
428
- if (this.config.blocksSelect) {
429
- this.config.blocksSelect(blocks);
430
- }
431
- }
432
- get selectedBlocks() {
433
- return this._selectedBlocks$.getValue();
434
- }
435
- saveSelection() {
436
- const selection = window.getSelection();
437
- this._selectionRange = selection.getRangeAt(0);
438
- }
439
- restoreSelection() {
440
- if (this._selectionRange) {
441
- const selection = window.getSelection();
442
- selection.removeAllRanges();
443
- selection.addRange(this._selectionRange);
444
- }
445
- }
446
- hasSelectionRange() {
447
- return this._selectionRange && (this._selectionRange.baseOffset - this._selectionRange.focusOffset) > 0;
448
- }
449
- registerContainer(container) {
450
- this.container = container;
451
- }
452
- registerMargin(margin) {
453
- this.margin = margin;
454
- }
455
- removeBlocks(blocks) {
456
- this._prompt.confirm({
457
- title: 'Confirm',
458
- template: 'Are you sure your would like to delete this block?',
459
- })
460
- .pipe(switchMap(() => this.config.blocksRemove ? this.config.blocksRemove(blocks) : throwError('config.blocksRemove is not configured')), takeUntil(this._destroy$))
461
- .subscribe(() => {
462
- blocks.forEach((block) => {
463
- this.blockRemove(block);
464
- });
465
- this.selectedBlocks = [];
466
- });
467
- }
468
- openReorderDialog() {
469
- const blocks = this.blocks
470
- .sort((blockA, blockB) => (blockA.index - blockB.index))
471
- .reverse();
472
- this._dialog
473
- .open(LayersReorderDialogComponent, {
474
- data: {
475
- blocks,
476
- },
477
- })
478
- .afterClosed()
479
- .pipe(filter((b) => !!b), switchMap((b) => this.config.blocksReorder(b)
480
- .pipe(mapTo(blocks))), takeUntil(this._destroy$))
481
- .subscribe((b) => {
482
- b
483
- .forEach((block, index) => {
484
- block.index = index;
485
- });
486
- });
487
- }
488
- ngOnDestroy() {
489
- this._destroy$.next();
490
- this._destroy$.complete();
491
- }
492
- _initBlockGroups() {
493
- this.blockGroups = Object.values(this._store.blocks
494
- .reduce((accum, block) => {
495
- if (block.name) {
496
- const existing = accum[block.name] || {};
497
- accum[block.name] = {
498
- label: block.label || existing.label,
499
- description: block.description || existing.description,
500
- name: block.name,
501
- };
502
- }
503
- return accum;
504
- }, {}));
505
- }
506
- _initBlockChange() {
507
- if (this.config.blockChange) {
508
- this.blockChanged$
509
- .pipe(groupBy((block) => (block.guid)), map((group) => group.pipe(debounceTime(250))), mergeAll())
510
- .subscribe((block) => {
511
- this.config.blockChange(block);
512
- });
513
- }
514
- }
515
- _initBlock(block) {
516
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
517
- let newBlock = Object.assign(Object.assign({}, block), { shapeBottomLeft: (_a = block.shapeBottomLeft) !== null && _a !== void 0 ? _a : 'round', shapeTopLeft: (_b = block.shapeTopLeft) !== null && _b !== void 0 ? _b : 'round', shapeTopRight: (_c = block.shapeTopRight) !== null && _c !== void 0 ? _c : 'round', shapeBottomRight: (_d = block.shapeBottomRight) !== null && _d !== void 0 ? _d : 'round', verticalAlign: (_e = block.verticalAlign) !== null && _e !== void 0 ? _e : 'top', horizontalAlign: (_f = block.horizontalAlign) !== null && _f !== void 0 ? _f : 'left', index: block.guid ? block.index : this._store.blocks.length, guid: block.guid || guid('xxxxxxxxxxxx'), keepRatio: (_g = block.keepRatio) !== null && _g !== void 0 ? _g : [
518
- BlockType.Checkbox,
519
- BlockType.RadioButton,
520
- BlockType.Pdf,
521
- ]
522
- .indexOf(block.type) !== -1 });
523
- let width = (this.config.width * .333).toFixed(2);
524
- let height = width / 2;
525
- if (newBlock.type === BlockType.Rectangle) {
526
- newBlock = Object.assign(Object.assign({}, newBlock), { borderColor: (_h = newBlock.borderColor) !== null && _h !== void 0 ? _h : '#cccccc', borderWidth: (_j = newBlock.borderWidth) !== null && _j !== void 0 ? _j : 1 });
527
- }
528
- else if (newBlock.type === BlockType.Checkbox || newBlock.type === BlockType.RadioButton) {
529
- width = .25;
530
- height = .25;
531
- }
532
- else {
533
- width = 2;
534
- height = .5;
535
- }
536
- //get max tabindex
537
- // newBlock.tabIndex = this._lastTabIndex + 1;
538
- // this.updateTabIndex(newBlock.tabIndex);
539
- return Object.assign({ top: height, left: width, width,
540
- height }, newBlock);
541
- }
542
- }
543
- BlockEditorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService, deps: [{ token: BlocksStore }, { token: i2.FsDialog }, { token: i3$1.FsPrompt }], target: i0.ɵɵFactoryTarget.Injectable });
544
- BlockEditorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService });
545
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService, decorators: [{
546
- type: Injectable
547
- }], ctorParameters: function () { return [{ type: BlocksStore }, { type: i2.FsDialog }, { type: i3$1.FsPrompt }]; } });
548
-
549
- const BlockFormats = [
550
- { value: BlockFormat.Number, name: 'Number', blockTypes: [BlockType.ShortText, BlockType.LongText] },
551
- { value: BlockFormat.Currency, name: 'Currency', blockTypes: [BlockType.ShortText, BlockType.LongText] },
552
- { value: BlockFormat.Date, name: 'Date', blockTypes: [BlockType.Date] },
553
- { value: BlockFormat.YYYYMMDD, name: 'YYYY/MM/DD', blockTypes: [BlockType.Date] },
554
- ];
555
-
556
- class CreateImageUrlPipe {
557
- constructor(_api) {
558
- this._api = _api;
559
- }
560
- transform(url) {
561
- return this._api.createApiFile(url).safeDataUrl;
562
- }
563
- }
564
- CreateImageUrlPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: CreateImageUrlPipe, deps: [{ token: i1$1.FsApi }], target: i0.ɵɵFactoryTarget.Pipe });
565
- CreateImageUrlPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: CreateImageUrlPipe, name: "createImageUrl" });
566
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: CreateImageUrlPipe, decorators: [{
567
- type: Pipe,
568
- args: [{ name: 'createImageUrl' }]
569
- }], ctorParameters: function () { return [{ type: i1$1.FsApi }]; } });
570
-
571
- class FsBlockComponent {
572
- constructor(_blockEditor, _elementRef, _cdRef, _fontPickerService) {
573
- this._blockEditor = _blockEditor;
574
- this._elementRef = _elementRef;
575
- this._cdRef = _cdRef;
576
- this._fontPickerService = _fontPickerService;
577
- this.transformating = false;
578
- this.BlockType = BlockType;
579
- this._editable = false;
580
- this._transformable = false;
581
- this._destroy$ = new Subject();
582
- }
583
- set block(block) {
584
- this._block = block;
585
- this._block.resizable = !this.hasType([BlockType.Checkbox, BlockType.RadioButton]);
586
- this._block.rotatable = !this.hasType([BlockType.Checkbox, BlockType.RadioButton]);
587
- this._block.scalable = !this.hasType([BlockType.Checkbox, BlockType.RadioButton]);
588
- if (this.moveable) {
589
- this._updateMoveable();
590
- }
591
- this.typeForm = BlockTypes
592
- .some((blockType) => {
593
- return blockType.type === 'form' && blockType.value === this.block.type;
594
- });
595
- }
596
- get block() {
597
- return this._block;
598
- }
599
- keydown(event) {
600
- if (event.target === document.body && this.selected) {
601
- if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].indexOf(event.key) !== -1) {
602
- this._move(event);
603
- }
604
- if (['Delete', 'Backspace'].indexOf(event.key) !== -1) {
605
- this._delete(event);
606
- }
607
- }
608
- }
609
- get el() {
610
- return this.element.nativeElement;
611
- }
612
- get moveable() {
613
- return this._moveable;
614
- }
615
- hasType(types) {
616
- return types.includes(this.block.type);
617
- }
618
- get editable() {
619
- return this._editable;
620
- }
621
- set editable(value) {
622
- this._editable = value;
623
- if (!value) {
624
- this.deselectContent();
625
- }
626
- }
627
- get styleTop() {
628
- const top = this.block.top;
629
- return `${top}${this.unit}`;
630
- }
631
- get styleLeft() {
632
- const left = this.block.left;
633
- return `${left}${this.unit}`;
634
- }
635
- get styleWidth() {
636
- let width = this.block.width;
637
- if (this.block.clipPath) {
638
- width -= (this.block.width * this.block.clipPath.values[1] / 100) +
639
- (this.block.width * this.block.clipPath.values[3] / 100);
640
- }
641
- return `${width}${this.unit}`;
642
- }
643
- get styleHeight() {
644
- let height = this.block.height;
645
- if (this.block.clipPath) {
646
- height -= (this.block.height * this.block.clipPath.values[0] / 100) +
647
- (this.block.height * this.block.clipPath.values[2] / 100);
648
- }
649
- return `${height}${this.unit}`;
650
- }
651
- get styleImageHeight() {
652
- const height = this.block.height;
653
- if (this.block.clipPath) {
654
- const values = this.block.clipPath.values || {};
655
- }
656
- return `${height}${this.unit}`;
657
- }
658
- get styleImageWidth() {
659
- const width = this.block.width;
660
- if (this.block.clipPath) {
661
- const values = this.block.clipPath.values || {};
662
- }
663
- return `${width}${this.unit}`;
664
- }
665
- get styleImageTop() {
666
- let top = 0;
667
- if (this.block.clipPath) {
668
- const values = this.block.clipPath.values || {};
669
- top = (values[0] / 100) * this.block.width * -1;
670
- }
671
- return `${top}${this.unit}`;
672
- }
673
- get styleImageLeft() {
674
- let left = 0;
675
- if (this.block.clipPath) {
676
- const values = this.block.clipPath.values || {};
677
- left = (values[3] / 100) * this.block.width * -1;
678
- }
679
- return `${left}${this.unit}`;
680
- }
681
- get styleClipPath() {
682
- if (!this.block.clipPath) {
683
- return null;
684
- }
685
- const values = this.block.clipPath.values || {};
686
- const top = values[0] / 100 * this.block.height;
687
- const right = (values[1]) / 100 * this.block.width;
688
- const bottom = (values[2]) / 100 * this.block.height;
689
- const left = values[3] / 100 * this.block.width;
690
- const clipPath = `inset(${top}${this.unit} ${right}${this.unit} ${bottom}${this.unit} ${left}${this.unit})`;
691
- return clipPath;
692
- }
693
- get styleBoxShadow() {
694
- if (!this.block.shadowColor) {
695
- return null;
696
- }
697
- const shadow = `${this.block.shadowX}pt ${(this.block.shadowY || 0)}pt ${(this.block.shadowBlur || 0)}pt ${(this.block.shadowSpread || 0)}pt ${this.block.shadowColor}`;
698
- return shadow;
699
- }
700
- set elementGuidelines(value) {
701
- this.moveable.elementGuidelines = value;
702
- }
703
- get clippable() {
704
- return !!this.moveable.clippable;
705
- }
706
- set clippable(value) {
707
- this.moveable.clippable = value;
708
- if (this.selected) {
709
- this.moveable.resizable = !value;
710
- this.moveable.rotatable = !value;
711
- this.moveable.scalable = !value;
712
- }
713
- }
714
- get transformable() {
715
- return this._transformable;
716
- }
717
- set transformable(value) {
718
- this._transformable = value;
719
- this._updateMoveable();
720
- }
721
- set rotate(value) {
722
- this.moveable.request('rotatable', { rotate: parseFloat(value) }, true);
723
- this.moveable.updateRect();
724
- }
725
- set index(value) {
726
- this.block.index = value;
727
- }
728
- set keepRatio(value) {
729
- this.moveable.keepRatio = value;
730
- }
731
- markForCheck() {
732
- this._cdRef.markForCheck();
733
- }
734
- ngOnInit() {
735
- this.unit = this._blockEditor.config.unit;
736
- this.content = this.block.content;
737
- this.block.shadowOpacity = this.block.shadowOpacity || 100;
738
- this._blockEditor.selectedBlocks$
739
- .pipe(skip(1), takeUntil(this._destroy$))
740
- .subscribe((blocks) => {
741
- this.selected = blocks
742
- .some((block) => block.guid === this.block.guid);
743
- this.transformable = true;
744
- this._cdRef.markForCheck();
745
- });
746
- this._blockEditor.blockClippable$
747
- .pipe(filter(() => this.selected), takeUntil(this._destroy$))
748
- .subscribe((clippable) => {
749
- this.clippable = clippable;
750
- this._cdRef.markForCheck();
751
- });
752
- this._blockEditor.blockAdded$
753
- .pipe(takeUntil(this._destroy$))
754
- .subscribe(() => {
755
- this._cdRef.markForCheck();
756
- });
757
- this._blockEditor.blockUpdated$
758
- .pipe(filter((block) => block.guid === this.block.guid), takeUntil(this._destroy$))
759
- .subscribe((block) => {
760
- this.block = block;
761
- this._cdRef.markForCheck();
762
- });
763
- this._blockEditor.blockChanged$
764
- .pipe(filter((block) => block.guid === this.block.guid), takeUntil(this._destroy$))
765
- .subscribe((block) => {
766
- this.block = block;
767
- this._cdRef.markForCheck();
768
- });
769
- }
770
- ngAfterViewInit() {
771
- setTimeout(() => {
772
- this._initEvents();
773
- this._initFont();
774
- this._initMoveable();
775
- this._setTransform();
776
- this._initElementGuidelines();
777
- this.rotate = this.block.rotate;
778
- });
779
- }
780
- pxToIn(px) {
781
- return this.round(px / 96, 2);
782
- }
783
- round(value, decimals) {
784
- return parseFloat(value.toFixed(decimals));
785
- }
786
- deselect() {
787
- this.editable = false;
788
- this.clippable = false;
789
- this.transformable = false;
790
- this.disableContentEdit();
791
- }
792
- disableContentEdit() {
793
- this.editable = false;
794
- }
795
- deselectContent() {
796
- if (window.getSelection) {
797
- if (window.getSelection().empty) {
798
- window.getSelection().empty();
799
- }
800
- else if (window.getSelection().removeAllRanges) {
801
- window.getSelection().removeAllRanges();
802
- }
803
- }
804
- }
805
- selectTextAll() {
806
- const range = document.createRange();
807
- range.selectNodeContents(this.contentEditable.nativeElement);
808
- const sel = window.getSelection();
809
- sel.removeAllRanges();
810
- sel.addRange(range);
811
- }
812
- ngOnDestroy() {
813
- //this._blockEditor.destroyBlock(this.block);
814
- this._destroy$.next();
815
- this._destroy$.complete();
816
- }
817
- _setTransform(transforms = []) {
818
- transforms = transforms !== null && transforms !== void 0 ? transforms : [];
819
- this.el.style.transform = transforms.join(' ');
820
- }
821
- _triggerChanged() {
822
- this._blockEditor.blockChange(this.block);
823
- }
824
- _updateMoveable() {
825
- const value = !this.block.lock && this.selected;
826
- this.keepRatio = this.block.keepRatio;
827
- this.rotate = this.block.rotate;
828
- this.moveable.resizable = this.block.resizable && value;
829
- this.moveable.rotatable = this.block.rotatable && value;
830
- this.moveable.scalable = this.block.scalable && value;
831
- }
832
- _initElementGuidelines() {
833
- this._blockEditor.blockComponents$
834
- .pipe(takeUntil(this._destroy$))
835
- .subscribe((blockComponents) => {
836
- this.moveable.elementGuidelines = blockComponents
837
- .filter((blockComponent) => this !== blockComponent)
838
- .map((blockComponent) => blockComponent.el);
839
- });
840
- }
841
- _initMoveable() {
842
- this._moveable = new Moveable(this._elementRef.nativeElement, {
843
- target: this.el,
844
- container: this._blockEditor.container,
845
- draggable: true,
846
- resizable: false,
847
- scalable: false,
848
- rotatable: false,
849
- warpable: false,
850
- origin: false,
851
- clipRelative: true,
852
- clipArea: true,
853
- keepRatio: this.block.keepRatio,
854
- snappable: true,
855
- snapDirections: { left: true, top: true, right: true, bottom: true, center: true, middle: true },
856
- elementSnapDirections: { left: true, top: true, right: true, bottom: true, center: true, middle: true },
857
- edge: false,
858
- throttleDrag: 1,
859
- throttleScale: 0.01,
860
- throttleRotate: 1,
861
- throttleResize: 1,
862
- snapDistFormat: (v, type) => `${this.round(v / 96, 2)}`,
863
- });
864
- this._updateMoveable();
865
- this.moveable
866
- .on('clip', (e) => {
867
- this.moveable.keepRatio = false;
868
- e.target.style.clipPath = e.clipStyle;
869
- this.block.clipPath = {
870
- type: 'inset',
871
- values: e.clipStyles
872
- .map((value) => {
873
- const n = Number(value.replace('%', ''));
874
- return n > 0 ? n : 0;
875
- }),
876
- };
877
- })
878
- .on('clipEnd', (e) => {
879
- this.moveable.keepRatio = true;
880
- e.target.style.clipPath = null;
881
- this._triggerChanged();
882
- setTimeout(() => {
883
- this.moveable.updateRect();
884
- }, 100);
885
- })
886
- .on('dragStart', () => {
887
- this.disableContentEdit();
888
- this.transformating = true;
889
- this._cdRef.markForCheck();
890
- })
891
- .on('drag', ({ target, left, top }) => {
892
- target.style.left = `${this.pxToIn(left)}${this.unit}`;
893
- target.style.top = `${this.pxToIn(top)}${this.unit}`;
894
- this.block.top = this.pxToIn(top);
895
- this.block.left = this.pxToIn(left);
896
- })
897
- .on('dragEnd', () => {
898
- this.transformating = false;
899
- this._triggerChanged();
900
- this._cdRef.markForCheck();
901
- })
902
- .on('resizeStart', () => {
903
- this.disableContentEdit();
904
- this.zoompan.disable();
905
- this.transformating = true;
906
- this._cdRef.markForCheck();
907
- })
908
- .on('resize', ({ target, width, height, dist, delta, direction }) => {
909
- width = this.pxToIn(width);
910
- height = this.pxToIn(height);
911
- if (delta[0]) {
912
- this.block.width = width;
913
- target.style.width = `${width}${this.unit}`;
914
- }
915
- if (delta[1]) {
916
- this.block.height = height;
917
- target.style.height = `${height}${this.unit}`;
918
- }
919
- const transform = [0, 0];
920
- if (direction[1] === -1) {
921
- transform[1] = dist[1] * -1;
922
- }
923
- if (direction[0] === -1) {
924
- transform[0] = dist[0] * -1;
925
- }
926
- this._setTransform([`translate(${transform[0]}px, ${transform[1]}px)`]);
927
- })
928
- .on('resizeEnd', ({ target }) => {
929
- const matrix = new WebKitCSSMatrix(target.style.transform);
930
- this.block.top = parseFloat(target.style.top) + this.pxToIn(matrix.m42);
931
- this.block.left = parseFloat(target.style.left) + this.pxToIn(matrix.m41);
932
- this._setTransform();
933
- this._triggerChanged();
934
- this.zoompan.enable();
935
- this.transformating = false;
936
- this._cdRef.markForCheck();
937
- target.style.top = `${this.block.top}in`;
938
- target.style.left = `${this.block.left}in`;
939
- target.style.width = `${this.block.width}in`;
940
- target.style.height = `${this.block.height}in`;
941
- this.moveable.updateRect();
942
- })
943
- .on('rotateStart', ({ inputEvent }) => {
944
- if (inputEvent) {
945
- this.zoompan.disable();
946
- this.disableContentEdit();
947
- this.transformating = true;
948
- this._cdRef.markForCheck();
949
- }
950
- })
951
- .on('rotate', ({ inputEvent, transform, rotation }) => {
952
- this.el.style.transform = transform;
953
- this.block.rotate = rotation % 360;
954
- if (inputEvent) {
955
- this.zoompan.enable();
956
- }
957
- })
958
- .on('rotateEnd', ({ inputEvent }) => {
959
- if (inputEvent) {
960
- this.transformating = false;
961
- this._cdRef.markForCheck();
962
- this._triggerChanged();
963
- }
964
- });
965
- }
966
- _initFont() {
967
- if (this.block.fontFamily) {
968
- this._fontPickerService.importFont(this.block.fontFamily);
969
- }
970
- }
971
- _initEvents() {
972
- fromEvent(this.contentEditable.nativeElement, 'paste')
973
- .pipe(takeUntil(this._destroy$))
974
- .subscribe((e) => {
975
- e.preventDefault();
976
- const clipboardData = e.clipboardData;
977
- const text = clipboardData.getData('Text');
978
- const range = document.getSelection().getRangeAt(0);
979
- range.deleteContents();
980
- const textNode = document.createTextNode(text);
981
- range.insertNode(textNode);
982
- range.selectNodeContents(textNode);
983
- range.collapse(false);
984
- const selection = window.getSelection();
985
- selection.removeAllRanges();
986
- selection.addRange(range);
987
- this.block.content = this.contentEditable.nativeElement.innerHTML;
988
- this._triggerChanged();
989
- });
990
- fromEvent(this.contentEditable.nativeElement, 'input')
991
- .pipe(takeUntil(this._destroy$)).subscribe((event) => {
992
- this.block.content = event.target.innerHTML;
993
- this._triggerChanged();
994
- });
995
- fromEvent(this.el, 'mousedown')
996
- .pipe(takeUntil(this._destroy$))
997
- .subscribe((event) => {
998
- if (this.block.lock) {
999
- event.preventDefault();
1000
- event.stopImmediatePropagation();
1001
- event.stopPropagation();
1002
- }
1003
- else {
1004
- this.zoompan.disable();
1005
- }
1006
- if (!this.moveable.clippable) {
1007
- if (this.editable) {
1008
- if (this.contentElement.nativeElement.isSameNode(event.target)) {
1009
- event.preventDefault();
1010
- event.stopImmediatePropagation();
1011
- event.stopPropagation();
1012
- }
1013
- }
1014
- else {
1015
- this._blockEditor.selectedBlock = this.block;
1016
- }
1017
- }
1018
- });
1019
- fromEvent(this.el, 'mouseup')
1020
- .pipe(takeUntil(this._destroy$)).subscribe(() => {
1021
- this.zoompan.enable();
1022
- });
1023
- fromEvent(this.el, 'dblclick')
1024
- .pipe(filter(() => (!this.editable)), takeUntil(this._destroy$))
1025
- .subscribe((event) => {
1026
- if (this.block.readonly) {
1027
- event.preventDefault();
1028
- }
1029
- else {
1030
- this.editable = true;
1031
- this._cdRef.markForCheck();
1032
- setTimeout(() => {
1033
- this.selectTextAll();
1034
- });
1035
- }
1036
- });
1037
- }
1038
- _move(event) {
1039
- if (!this.selected ||
1040
- this.editable) {
1041
- return;
1042
- }
1043
- event.preventDefault();
1044
- const inchPixel = 1 / 100;
1045
- switch (event.key) {
1046
- case 'ArrowUp':
1047
- this.block.top = round(this.block.top - inchPixel, 2);
1048
- break;
1049
- case 'ArrowDown':
1050
- this.block.top = round(this.block.top + inchPixel, 2);
1051
- break;
1052
- case 'ArrowLeft':
1053
- this.block.left = round(this.block.left - inchPixel, 2);
1054
- break;
1055
- case 'ArrowRight':
1056
- this.block.left = round(this.block.left + inchPixel, 2);
1057
- break;
1058
- }
1059
- this._blockEditor.blockChange(this.block);
1060
- }
1061
- _delete(event) {
1062
- var _a, _b;
1063
- if (this.selected &&
1064
- !this.editable &&
1065
- ((_a = event.target) === null || _a === void 0 ? void 0 : _a.nodeName) !== 'INPUT' &&
1066
- ((_b = event.target) === null || _b === void 0 ? void 0 : _b.nodeName) !== 'TEXTAREA') {
1067
- event.preventDefault();
1068
- this._blockEditor.removeBlocks([this.block]);
1069
- }
1070
- }
1071
- }
1072
- FsBlockComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockComponent, deps: [{ token: BlockEditorService }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i2$1.FsFontPickerService }], target: i0.ɵɵFactoryTarget.Component });
1073
- FsBlockComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockComponent, selector: "fs-block", inputs: { block: "block", html: "html", zoompan: "zoompan" }, host: { listeners: { "document:keydown": "keydown($event)" }, properties: { "class.transforming": "this.transformating" } }, viewQueries: [{ propertyName: "element", first: true, predicate: ["element"], descendants: true, static: true }, { propertyName: "contentElement", first: true, predicate: ["contentElement"], descendants: true, static: true }, { propertyName: "contentEditable", first: true, predicate: ["contentEditable"], descendants: true, static: true }], ngImport: i0, template: "<div\n #element\n [class]=\"'block ' + 'block-' + block.type\"\n [style.top]=\"styleTop\"\n [style.left]=\"styleLeft\"\n [style.width]=\"styleWidth\"\n [style.height]=\"styleHeight\"\n [ngClass]=\"{ \n editable: editable, \n readonly: block.readonly,\n required: block.required,\n lock: block.lock,\n selected: selected\n }\"\n [style.zIndex]=\"block.index\">\n <div\n #contentElement\n class=\"content\"\n [style.borderColor]=\"block.borderColor\"\n [style.borderWidth]=\"block.borderWidth ? block.borderWidth + 'pt' : ''\"\n [style.borderStyle]=\"block.borderColor ? 'solid' : 'dashed'\"\n [style.textAlign]=\"block.horizontalAlign\"\n [style.fontStyle]=\"block.italic ? 'italic' : ''\"\n [style.fontFamily]=\"block.fontFamily || ''\"\n [style.fontSize]=\"block.fontSize ? block.fontSize + 'pt' : ''\"\n [style.lineHeight]=\"block.lineHeight ? block.lineHeight + 'pt' : ''\"\n [style.color]=\"block.fontColor\"\n [style.fontWeight]=\"block.bold ? 'bold' : ''\"\n [style.textDecoration]=\"block.underline ? 'underline' : ''\"\n [style.paddingTop]=\"block.paddingTop ? block.paddingTop + 'in' : ''\"\n [style.paddingBottom]=\"block.paddingBottom ? block.paddingBottom + 'in' : ''\"\n [style.paddingLeft]=\"block.paddingLeft ? block.paddingLeft + 'in' : ''\"\n [style.paddingRight]=\"block.paddingRight ? block.paddingRight + 'in' : ''\"\n [style.backgroundColor]=\"block.backgroundColor\"\n [style.borderBottomLeftRadius]=\"block.shapeRadius && block.shapeBottomLeft === 'round' ? block.shapeRadius + '%' : ''\"\n [style.borderBottomRightRadius]=\"block.shapeRadius && block.shapeBottomRight === 'round' ? block.shapeRadius + '%' : ''\"\n [style.borderTopRightRadius]=\"block.shapeRadius && block.shapeTopRight === 'round' ? block.shapeRadius + '%' : ''\"\n [style.borderTopLeftRadius]=\"block.shapeRadius && block.shapeTopLeft === 'round' ? block.shapeRadius + '%' : ''\"\n [style.boxShadow]=\"styleBoxShadow\"\n [ngClass]=\"{\n 'editable': editable,\n 'vertical-align-center': block.verticalAlign === 'center',\n 'vertical-align-bottom': block.verticalAlign === 'bottom'\n }\">\n <ng-container *ngIf=\"block.imageUrl && ((block.imageUrl | createImageUrl) | async) as src\">\n <img \n [style.opacity]=\"block.imageOpacity ? block.imageOpacity/100 : 1\"\n [src]=\"src\">\n </ng-container>\n <ng-container *ngIf=\"block.type === BlockType.LongText || block.type === BlockType.ShortText || block.type === BlockType.Date\">\n {{block.label || block.name}}\n </ng-container>\n <div\n #contentEditable\n [contentEditable]=\"editable && !typeForm\"\n class=\"content-editable\"\n [innerHTML]=\"content\">\n </div>\n </div>\n <div class=\"outline\"></div>\n</div>\n", styles: [":host ::ng-deep .moveable-control{width:10px!important;height:10px!important;margin-top:-5px!important;margin-left:-5px!important}:host.transforming ::ng-deep .moveable-control,:host.transforming ::ng-deep .moveable-rotation{display:none}.block{position:absolute;display:block;outline:none;-webkit-user-select:none;user-select:none;cursor:pointer;box-sizing:border-box}.block.selected{border-color:#31a2ff95}.block.block-shorttext,.block.block-longtext,.block.block-date,.block.block-radiobutton,.block.block-signature,.block.block-checkbox{background-color:#aab5e1cc;color:#585555;font-size:12px}.block.block-radiobutton{border-radius:50%}.block.required{background-color:#f7adaa}.block .content-editable{outline:none;position:relative;z-index:100}.block.editable .content-editable{cursor:text}.block .content{flex-direction:column;height:100%;display:flex;border:0px solid transparent;position:relative;box-sizing:border-box;overflow:hidden}.block .content fs-html-editor{width:100%}.block .content.vertical-align-center{justify-content:center}.block .content.vertical-align-bottom{justify-content:flex-end}.block .content img{width:100%;height:100%;position:absolute}.block.selected .outline,.block:hover .outline{border:1px solid rgba(68,170,255,.7);position:absolute;top:0;left:0;bottom:0;right:0;-webkit-user-select:none;user-select:none}.block.selected.lock .outline,.block:hover.lock .outline{border-color:#e4181866;border-style:dashed}:host ::ng-deep fs-html-editor .bottom-line,:host ::ng-deep fs-html-editor .fr-toolbar{display:none!important}:host ::ng-deep fs-html-editor .fr-wrapper{background:none!important;border:none!important}:host ::ng-deep .moveable-line:not(.moveable-rotation-line):not(.moveable-guideline){background:transparent!important}\n"], directives: [{ type: i17.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i17.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i17.AsyncPipe, "createImageUrl": CreateImageUrlPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
1074
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockComponent, decorators: [{
1075
- type: Component,
1076
- args: [{
1077
- selector: 'fs-block',
1078
- templateUrl: './block.component.html',
1079
- styleUrls: ['./block.component.scss'],
1080
- changeDetection: ChangeDetectionStrategy.OnPush,
1081
- }]
1082
- }], ctorParameters: function () { return [{ type: BlockEditorService }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i2$1.FsFontPickerService }]; }, propDecorators: { element: [{
1083
- type: ViewChild,
1084
- args: ['element', { static: true }]
1085
- }], contentElement: [{
1086
- type: ViewChild,
1087
- args: ['contentElement', { static: true }]
1088
- }], contentEditable: [{
1089
- type: ViewChild,
1090
- args: ['contentEditable', { static: true }]
1091
- }], block: [{
1092
- type: Input,
1093
- args: ['block']
1094
- }], html: [{
1095
- type: Input
1096
- }], zoompan: [{
1097
- type: Input
1098
- }], transformating: [{
1099
- type: HostBinding,
1100
- args: ['class.transforming']
1101
- }], keydown: [{
1102
- type: HostListener,
1103
- args: ['document:keydown', ['$event']]
1104
- }] } });
1105
-
1106
- class SidebarComponent {
1107
- constructor(_el, _blockEditor, _cdRef, _clipboard, _message, _prompt, _dialog, _document) {
1108
- this._el = _el;
1109
- this._blockEditor = _blockEditor;
1110
- this._cdRef = _cdRef;
1111
- this._clipboard = _clipboard;
1112
- this._message = _message;
1113
- this._prompt = _prompt;
1114
- this._dialog = _dialog;
1115
- this._document = _document;
1116
- this.zoomCenter = new EventEmitter();
1117
- this.BlockTypes = BlockTypes;
1118
- this.blockTypeNames = index(BlockTypes, 'value', 'name');
1119
- this.blockTypeIcons = index(BlockTypes, 'value', 'icon');
1120
- this.clippable = false;
1121
- this.BlockType = BlockType;
1122
- this.formats = [];
1123
- this._destroy$ = new Subject();
1124
- this.validate = (formControl) => {
1125
- if (this._blockEditor.config.defaultValidation) {
1126
- return this._blockEditor.config.defaultValidation(this.block, formControl.value);
1127
- }
1128
- return of(true);
1129
- };
1130
- }
1131
- get el() {
1132
- return this._el.nativeElement;
1133
- }
1134
- get blockGroups() {
1135
- return this._blockEditor.blockGroups;
1136
- }
1137
- get blockTypeForm() {
1138
- return this.block.type === BlockType.LongText ||
1139
- this.block.type === BlockType.ShortText ||
1140
- this.block.type === BlockType.RadioButton ||
1141
- this.block.type === BlockType.Checkbox ||
1142
- this.block.type === BlockType.Date ||
1143
- this.block.type === BlockType.Signature;
1144
- }
1145
- ngOnInit() {
1146
- this._blockEditor.selectedBlocks$
1147
- .pipe(takeUntil(this._destroy$))
1148
- .subscribe((blocks) => {
1149
- this.block = blocks[0] ? blocks[0] : null;
1150
- this.blockGroup = null;
1151
- if (this.block) {
1152
- this.formats = BlockFormats
1153
- .filter((blockFormat) => (blockFormat.blockTypes.indexOf(this.block.type) !== -1));
1154
- if (this.block.name) {
1155
- this.blockGroup = this._blockEditor.blockGroups
1156
- .find((blockGroup) => {
1157
- return this.block.name === blockGroup.name;
1158
- });
1159
- }
1160
- }
1161
- this._cdRef.markForCheck();
1162
- });
1163
- this._blockEditor.blockChanged$
1164
- .pipe(filter((block) => block === this.block), takeUntil(this._destroy$))
1165
- .subscribe(() => {
1166
- this._cdRef.markForCheck();
1167
- });
1168
- if (this._blockEditor.config.blocksReorder) {
1169
- this.blocksReordered = () => {
1170
- var _a;
1171
- (_a = this._document.defaultView) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
1172
- this._blockEditor.openReorderDialog();
1173
- };
1174
- }
1175
- }
1176
- blockGroupChange(blockGroup) {
1177
- this._blockEditor.applyBlockGroup(this.block, blockGroup);
1178
- }
1179
- blockRequired(value) {
1180
- const values = { required: value, readonly: false };
1181
- if (this.blockGroup) {
1182
- this._blockEditor.blockGroupChangeProperty(this.blockGroup, values);
1183
- }
1184
- else {
1185
- this.blockChangeProperty(values);
1186
- }
1187
- }
1188
- blockReadonly(value) {
1189
- const values = { readonly: value, required: false };
1190
- if (this.blockGroup) {
1191
- this._blockEditor.blockGroupChangeProperty(this.blockGroup, values);
1192
- }
1193
- else {
1194
- this.blockChangeProperty(values);
1195
- }
1196
- }
1197
- blockGroupEdit(event) {
1198
- event.preventDefault();
1199
- event.stopImmediatePropagation();
1200
- this.blockGroupDialog(this.blockGroup)
1201
- .subscribe((blockGroup) => {
1202
- this._blockEditor.blocks
1203
- .filter((block) => block.name === blockGroup.name)
1204
- .forEach((block) => {
1205
- this._blockEditor.applyBlockGroup(block, blockGroup);
1206
- });
1207
- });
1208
- }
1209
- blockGroupCreate(event) {
1210
- event.preventDefault();
1211
- event.stopImmediatePropagation();
1212
- this.blockGroupDialog()
1213
- .subscribe((blockGroup) => {
1214
- this._blockEditor.applyBlockGroup(this.block, blockGroup);
1215
- this.blockGroup = blockGroup;
1216
- this._cdRef.markForCheck();
1217
- });
1218
- }
1219
- blockGroupDialog(blockGroup) {
1220
- return this._dialog.open(GroupDialogComponent, {
1221
- data: {
1222
- block: this.block,
1223
- blockEditor: this._blockEditor,
1224
- blockGroup,
1225
- },
1226
- })
1227
- .afterClosed()
1228
- .pipe(filter((block) => !!block), takeUntil(this._destroy$));
1229
- }
1230
- fontChanged(font) {
1231
- this._blockEditor.selectedBlockComponentChangeProperty({ fontFamily: font });
1232
- }
1233
- verticalAlignClick(value) {
1234
- this._blockEditor.selectedBlockComponentChangeProperty({ verticalAlign: value });
1235
- }
1236
- boldClick() {
1237
- this._blockEditor.selectedBlockComponentChangeProperty({ bold: !this.block.bold });
1238
- }
1239
- toggleLock() {
1240
- this._blockEditor.selectedBlockComponentChangeProperty({ lock: !this.block.lock });
1241
- }
1242
- fontColorChange(value) {
1243
- this._blockEditor.selectedBlockComponentChangeProperty({ fontColor: value });
1244
- }
1245
- italicClick() {
1246
- this._blockEditor.selectedBlockComponentChangeProperty({ italic: !this.block.italic });
1247
- }
1248
- underlineClick() {
1249
- this._blockEditor.selectedBlockComponentChangeProperty({ underline: !this.block.underline });
1250
- }
1251
- backgroundColorChange(value) {
1252
- this._blockEditor.selectedBlockComponentChangeProperty({ backgroundColor: value });
1253
- }
1254
- shadowColorChange(value) {
1255
- this._blockEditor.selectedBlockComponentChangeProperty({ shadowColor: value });
1256
- }
1257
- paddingAllChange(value) {
1258
- value = this.validNumeric(value) ? value : null;
1259
- this.block.paddingTop = value;
1260
- this.block.paddingLeft = value;
1261
- this.block.paddingBottom = value;
1262
- this.block.paddingRight = value;
1263
- this._blockEditor.selectedBlocks
1264
- .forEach((block) => {
1265
- this._blockEditor.blockChange(block);
1266
- });
1267
- }
1268
- paddingKeypress(event, name) {
1269
- this.block.padding = null;
1270
- this.numericInputKeypress(event, name);
1271
- }
1272
- paddingAllKeypress(event, unit = .1) {
1273
- if (event.code === 'ArrowUp' || event.code === 'ArrowDown') {
1274
- this.block.padding = (this.block.padding) + ((event.code === 'ArrowDown' ? -1 : 1) * unit);
1275
- this.paddingAllChange(this.block.padding);
1276
- }
1277
- }
1278
- borderColorChange(value) {
1279
- this._blockEditor.selectedBlockComponentChangeProperty({ borderColor: value });
1280
- }
1281
- toggleKeepRatio() {
1282
- this._blockEditor.selectedBlockComponentChangeProperty({ keepRatio: !this.block.keepRatio });
1283
- }
1284
- horizontalAlignClick(value) {
1285
- this._blockEditor.selectedBlockComponentChangeProperty({ horizontalAlign: value });
1286
- }
1287
- shapeRound(name) {
1288
- const value = this.block[name] === 'round' ? 'square' : 'round';
1289
- this._blockEditor.selectedBlockComponentChangeProperty({ [name]: value });
1290
- }
1291
- numberChange(value, name) {
1292
- value = this.validNumeric(value) ? value : null;
1293
- this._blockEditor.selectedBlockComponentChangeProperty({ [name]: value });
1294
- }
1295
- imageRemove() {
1296
- this._blockEditor.selectedBlockComponentChangeProperty({ imageUrl: null });
1297
- }
1298
- imageClip() {
1299
- this.clippable = !this.clippable;
1300
- this._blockEditor.blockClippable = true;
1301
- }
1302
- blockChangeProperty(values) {
1303
- this._blockEditor.selectedBlockComponentChangeProperty(values);
1304
- }
1305
- blockDuplicateClick() {
1306
- const selectedBlock = this._blockEditor.selectedBlocks[0];
1307
- const block = Object.assign(Object.assign({}, selectedBlock), { id: null, data: null, guid: null, top: selectedBlock.top + selectedBlock.height + .1 });
1308
- this._blockEditor.blockAdd(block);
1309
- }
1310
- blockRemoveClick() {
1311
- this._blockEditor.removeBlocks(this._blockEditor.selectedBlocks);
1312
- }
1313
- blockUpload(block, fsFile) {
1314
- this._blockEditor.blockUpload(block, fsFile)
1315
- .subscribe();
1316
- }
1317
- blockAdd(type) {
1318
- if (type === BlockType.Pdf || type === BlockType.Image) {
1319
- return;
1320
- }
1321
- const block = {
1322
- type,
1323
- shadowX: 2,
1324
- shadowY: 2,
1325
- shadowBlur: 4,
1326
- };
1327
- this._blockEditor.blockAdd(block);
1328
- }
1329
- layerMove(direction) {
1330
- this._blockEditor.blocks.forEach((block) => {
1331
- if (this._blockEditor.isSelectedBlock(block)) {
1332
- block.index += (999 * direction);
1333
- }
1334
- });
1335
- const sorted = this._blockEditor.blocks
1336
- .sort((a, b) => {
1337
- return a.index > b.index ? 1 : -1;
1338
- });
1339
- sorted
1340
- .forEach((block, idx) => {
1341
- block.index = idx;
1342
- this._blockEditor.blockChange(block);
1343
- });
1344
- if (this.config.blocksLevelChanged) {
1345
- this.config.blocksLevelChanged(sorted.map((block) => block));
1346
- }
1347
- }
1348
- exportBlocks() {
1349
- const blocks = JSON.stringify(this._blockEditor.blocks);
1350
- this._clipboard.copy(blocks, { showMessage: false });
1351
- this._message.success('Exported blocks to clipboard');
1352
- }
1353
- importBlocks() {
1354
- this._prompt.input({
1355
- title: 'Import blocks',
1356
- })
1357
- .subscribe((blocks) => {
1358
- blocks = JSON.parse(blocks);
1359
- blocks
1360
- .forEach((block) => {
1361
- block = Object.assign(Object.assign({}, block), { guid: guid(), imageUrl: null });
1362
- this._blockEditor.blockAdd(block);
1363
- });
1364
- this._message
1365
- .success(`Imported ${blocks.length} ${blocks.length === 1 ? 'block' : 'blocks'}`);
1366
- });
1367
- }
1368
- layerUp() {
1369
- this.layerMove(1);
1370
- }
1371
- layerDown() {
1372
- this.layerMove(-1);
1373
- }
1374
- inputFocus(event) {
1375
- event.target.select();
1376
- }
1377
- numericInputKeypress(event, name, unit = .1) {
1378
- if (event.code === 'ArrowUp' || event.code === 'ArrowDown') {
1379
- this.block[name] = round(Number(this.block[name] || 0) +
1380
- ((event.code === 'ArrowDown' ? -1 : 1) * unit), 3);
1381
- this._blockEditor.selectedBlockComponentChangeProperty({ [name]: this.block[name] });
1382
- }
1383
- }
1384
- ngOnDestroy() {
1385
- this._destroy$.next();
1386
- this._destroy$.complete();
1387
- }
1388
- validNumeric(value) {
1389
- return !value || !!String(value).match(/^\d*\.?\d*$/);
1390
- }
1391
- }
1392
- SidebarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SidebarComponent, deps: [{ token: i0.ElementRef }, { token: BlockEditorService }, { token: i0.ChangeDetectorRef }, { token: i2$2.FsClipboard }, { token: i3$2.FsMessage }, { token: i3$1.FsPrompt }, { token: i1.MatDialog }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Component });
1393
- SidebarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SidebarComponent, selector: "sidebar", inputs: { config: "config", blocks: "blocks", zoompan: "zoompan" }, outputs: { zoomCenter: "zoomCenter" }, queries: [{ propertyName: "sidebarPanels", predicate: FsBlockEditorSidebarPanelDirective }], ngImport: i0, template: "<div class=\"sidebar\">\n <form fsForm>\n <div class=\"sidebar-panel\"> \n <div class=\"sidebar-label\">Elements</div>\n <div class=\"sidebar-row\">\n <ng-container *ngFor=\"let blockType of BlockTypes\">\n <ng-container *ngIf=\"blockType.type === 'draw'\">\n <ng-container [ngSwitch]=\"blockType.value\">\n <ng-container *ngSwitchCase=\"BlockType.Pdf\">\n <ng-container [ngTemplateOutlet]=\"addFile\" [ngTemplateOutletContext]=\"{ type: BlockType.Pdf }\"></ng-container>\n </ng-container>\n <ng-container *ngSwitchCase=\"BlockType.Image\">\n <ng-container [ngTemplateOutlet]=\"addFile\" [ngTemplateOutletContext]=\"{ type: BlockType.Rectangle }\"></ng-container>\n </ng-container>\n <ng-container *ngSwitchDefault>\n <ng-container \n [ngTemplateOutlet]=\"addButton\" \n [ngTemplateOutletContext]=\"{ blockType: blockType }\">\n </ng-container>\n </ng-container>\n </ng-container>\n\n <ng-template #addFile let-type=\"type\">\n <fs-file \n (select)=\"blockUpload({ type: type, keepRatio: true, borderWidth: 0 }, $event)\" \n [accept]=\"blockType.accept\">\n <ng-container [ngTemplateOutlet]=\"addButton\" [ngTemplateOutletContext]=\"{ blockType: blockType }\"></ng-container>\n </fs-file>\n </ng-template>\n </ng-container>\n </ng-container>\n </div>\n </div>\n\n <div class=\"sidebar-panel\">\n <div class=\"sidebar-label\">Form</div>\n <div class=\"sidebar-row\">\n <ng-container *ngFor=\"let blockType of BlockTypes\">\n <ng-container *ngIf=\"blockType.type === 'form'\">\n <ng-container \n [ngTemplateOutlet]=\"addButton\" \n [ngTemplateOutletContext]=\"{ blockType: blockType }\">\n </ng-container>\n </ng-container>\n </ng-container>\n </div>\n </div> \n\n <div class=\"sidebar-panel\">\n <div class=\"sidebar-label\">Tools</div>\n <div class=\"sidebar-row\">\n <ng-container *ngIf=\"block\">\n <button\n class=\"layer-up\"\n mat-icon-button\n color=\"basic\"\n type=\"button\"\n (click)=\"layerUp()\"\n [matTooltip]=\"'Increase layer'\">\n <mat-icon>arrow_back</mat-icon>\n <mat-icon>layers</mat-icon>\n </button>\n <button\n class=\"layer-down\"\n mat-icon-button\n color=\"basic\"\n type=\"button\"\n (click)=\"layerDown()\"\n [matTooltip]=\"'Decrease layer'\">\n <mat-icon>arrow_back</mat-icon>\n <mat-icon>layers</mat-icon>\n </button>\n <button\n mat-icon-button\n color=\"basic\"\n type=\"button\"\n (click)=\"toggleLock()\"\n [matTooltip]=\"block.lock ? 'Unlock' : 'Lock'\">\n <mat-icon>{{block.lock ? 'lock_outline' : 'lock_open'}}</mat-icon>\n </button>\n <button\n mat-icon-button\n color=\"basic\"\n type=\"button\"\n [matTooltip]=\"'Duplicate block'\"\n (click)=\"blockDuplicateClick()\">\n <mat-icon>content_copy</mat-icon>\n </button>\n <button\n mat-icon-button\n color=\"basic\"\n type=\"button\"\n [matTooltip]=\"'Delete block'\"\n (click)=\"blockRemoveClick()\">\n <mat-icon>delete_outline</mat-icon>\n </button> \n </ng-container>\n <ng-container *ngIf=\"blocksReordered\">\n <button\n class=\"reorder-layers\"\n mat-icon-button\n color=\"basic\"\n type=\"button\"\n (click)=\"blocksReordered()\"\n [matTooltip]=\"'Reorder blocks'\">\n <mat-icon>swap_vert</mat-icon>\n </button>\n </ng-container>\n <button\n mat-icon-button\n color=\"basic\"\n type=\"button\"\n matTooltip=\"Reset zoom\"\n (click)=\"zoomCenter.emit()\">\n <mat-icon>crop_free</mat-icon>\n </button>\n </div>\n </div>\n <ng-container *ngIf=\"block\">\n <div class=\"sidebar-panel info-panel\">\n <div class=\"sidebar-label\">Info</div>\n <div class=\"sidebar-row field-gap\">\n <mat-form-field class=\"form-field-padless form-field-prefix\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.left\"\n name=\"left\"\n fsMaskNumber\n scale=\"5\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'left', .01)\"\n (ngModelChange)=\"numberChange($event, 'left')\">\n <span matPrefix>X</span>\n </mat-form-field>\n <mat-form-field class=\"form-field-padless form-field-prefix\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.top\"\n name=\"top\"\n fsMaskNumber\n scale=\"5\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'top', .01)\"\n (ngModelChange)=\"numberChange($event, 'top')\">\n <span matPrefix>Y</span>\n </mat-form-field>\n <mat-form-field class=\"form-field-padless form-field-prefix rotate\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.rotate\"\n name=\"rotate\"\n fsMaskNumber\n scale=\"5\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'rotate', 1)\"\n (ngModelChange)=\"numberChange($event, 'rotate')\">\n <span matPrefix>R</span>\n </mat-form-field>\n </div>\n\n <div class=\"sidebar-row field-gap\">\n <mat-form-field class=\"form-field-padless form-field-prefix\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.width\"\n name=\"width\"\n fsMaskNumber\n scale=\"5\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'width', .01)\"\n (ngModelChange)=\"numberChange($event, 'width')\">\n <span matPrefix>W</span>\n </mat-form-field>\n\n <div>\n <a (click)=\"toggleKeepRatio()\" class=\"keep-ratio\">\n <mat-icon>{{block.keepRatio ? 'lock_outline' : 'lock_open'}}</mat-icon>\n </a>\n </div>\n <mat-form-field class=\"form-field-padless form-field-prefix\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.height\"\n name=\"height\"\n fsMaskNumber\n scale=\"5\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'height', .01)\"\n (ngModelChange)=\"numberChange($event, 'height')\">\n <span matPrefix>H</span>\n </mat-form-field>\n </div>\n </div>\n <ng-container\n *ngIf=\"blockTypeForm\">\n <div class=\"sidebar-panel block-form-panel\">\n <div class=\"sidebar-label\">\n <mat-icon>{{blockTypeIcons[block.type]}}</mat-icon>\n {{blockTypeNames[block.type]}}\n </div>\n <div class=\"sidebar-row\">\n\n <ng-container *ngIf=\"block.type === BlockType.RadioButton; else nameField\">\n <div class=\"group-block\">\n <mat-form-field class=\"full-width\" class=\"full-width\">\n <mat-label>Group</mat-label>\n <mat-select\n [(ngModel)]=\"blockGroup\"\n (ngModelChange)=\"blockGroupChange($event)\"\n name=\"group\">\n <ng-container *ngIf=\"blockGroups.length\">\n <mat-option [value]=\"null\">\n None\n </mat-option>\n </ng-container>\n <mat-option\n *ngFor=\"let item of blockGroups\"\n [value]=\"item\">\n {{ item.label }}\n </mat-option>\n <mat-option \n [value]=\"null\"\n (click)=\"blockGroupCreate($event)\">\n Create Group\n </mat-option>\n </mat-select> \n </mat-form-field>\n <ng-container *ngIf=\"blockGroup\">\n <a \n (click)=\"blockGroupEdit($event)\">\n <mat-icon>edit</mat-icon>\n </a>\n </ng-container>\n </div>\n </ng-container>\n \n <mat-form-field class=\"full-width\">\n <input\n matInput\n [ngModel]=\"block.label\"\n name=\"label\"\n placeholder=\"Label\"\n (ngModelChange)=\"blockChangeProperty({ label: $event })\">\n </mat-form-field>\n\n <ng-container *ngIf=\"block.type !== BlockType.RadioButton\">\n <mat-form-field class=\"full-width\">\n <textarea\n matInput\n [cdkTextareaAutosize]=\"true\"\n [ngModel]=\"block.description\"\n name=\"description\"\n placeholder=\"Description\"\n (ngModelChange)=\"blockChangeProperty({ description: $event })\">\n </textarea>\n </mat-form-field>\n </ng-container>\n\n <mat-form-field\n *ngIf=\"formats.length\"\n class=\"full-width\">\n <mat-label>Format</mat-label>\n <mat-select\n [(ngModel)]=\"block.format\"\n name=\"format\"\n (ngModelChange)=\"blockChangeProperty({ format: $event })\"> \n <mat-option [value]=\"null\">\n None\n </mat-option>\n <mat-option\n *ngFor=\"let item of formats\"\n [value]=\"item.value\">\n {{ item.name }}\n </mat-option>\n </mat-select>\n </mat-form-field>\n\n <ng-container\n *ngIf=\"block.type === BlockType.LongText || block.type === BlockType.ShortText || block.type === BlockType.Date\">\n <mat-form-field class=\"full-width\">\n <textarea\n matInput\n [cdkTextareaAutosize]=\"true\"\n [ngModel]=\"block.default\"\n name=\"default\"\n [validate]=\"validate\"\n placeholder=\"Default\"\n (ngModelChange)=\"blockChangeProperty({ default: $event })\">\n </textarea>\n </mat-form-field>\n </ng-container>\n\n <ng-container *ngIf=\"block.type === BlockType.LongText || block.type === BlockType.ShortText\">\n <mat-form-field class=\"full-width\">\n <textarea\n matInput\n [cdkTextareaAutosize]=\"true\"\n [ngModel]=\"block.formula\"\n name=\"formula\"\n placeholder=\"Formula\"\n (ngModelChange)=\"blockChangeProperty({ formula: $event })\">\n </textarea>\n </mat-form-field>\n </ng-container>\n\n <ng-template #nameField>\n <mat-form-field class=\"full-width\">\n <input\n matInput\n [ngModel]=\"block.name\"\n name=\"name\"\n placeholder=\"Name\"\n (ngModelChange)=\"blockChangeProperty({ name: $event })\">\n </mat-form-field>\n </ng-template>\n\n <div class=\"form-field-options\">\n <mat-checkbox\n name=\"required\"\n [(ngModel)]=\"block.required\"\n (ngModelChange)=\"blockRequired($event)\">\n Required\n </mat-checkbox>\n\n <mat-checkbox\n name=\"readonly\"\n [(ngModel)]=\"block.readonly\"\n (ngModelChange)=\"blockReadonly($event)\">\n Readonly\n </mat-checkbox>\n </div>\n </div>\n </div>\n </ng-container>\n <ng-container *ngIf=\"block.type === BlockType.Rectangle || block.type === BlockType.Image || block.type === BlockType.Pdf\">\n <div class=\"sidebar-panel typography-panel\">\n <div class=\"sidebar-label\">Typography</div>\n <div class=\"sidebar-row field-gap\">\n <fs-font-picker \n [(ngModel)]=\"block.fontFamily\" \n (ngModelChange)=\"fontChanged($event)\"\n name=\"fontfamily\">\n </fs-font-picker>\n <fs-color-picker-chip\n (changed)=\"fontColorChange($event)\"\n [color]=\"block.fontColor\">\n </fs-color-picker-chip>\n\n <mat-form-field class=\"form-field-padless form-field-prefix font-size\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.fontSize\"\n name=\"fontSize\"\n fsMaskNumber\n scale=\"5\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'fontSize', 1)\"\n (ngModelChange)=\"numberChange($event, 'fontSize')\"\n placeholder=\"Size\">\n <span matPrefix *ngIf=\"block.fontSize\">S</span>\n </mat-form-field>\n\n <mat-form-field class=\"form-field-padless form-field-prefix line-height\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.lineHeight\"\n name=\"lineHeight\"\n fsMaskNumber\n scale=\"5\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'lineHeight', 1)\"\n (ngModelChange)=\"numberChange($event, 'lineHeight')\"\n placeholder=\"Line\">\n <span matPrefix *ngIf=\"block.lineHeight\">L</span>\n </mat-form-field>\n\n <button\n mat-icon-button\n class=\"toggle-button\"\n color=\"basic\"\n type=\"button\"\n [ngClass]=\"{ selected: block.bold }\"\n (click)=\"boldClick()\">\n <mat-icon>format_bold</mat-icon>\n </button>\n <button\n mat-icon-button\n class=\"toggle-button\"\n color=\"basic\"\n type=\"button\"\n [ngClass]=\"{ selected: block.italic }\"\n (click)=\"italicClick()\">\n <mat-icon>format_italic</mat-icon>\n </button>\n <button\n mat-icon-button\n class=\"toggle-button\"\n color=\"basic\"\n type=\"button\"\n [ngClass]=\"{ selected: block.underline }\"\n (click)=\"underlineClick()\">\n <mat-icon>format_underline</mat-icon>\n </button>\n </div>\n\n <div class=\"sidebar-row align-row field-gap\">\n <button\n mat-icon-button\n class=\"toggle-button\"\n color=\"basic\"\n type=\"button\"\n [ngClass]=\"{ selected: block.horizontalAlign === 'left' }\"\n (click)=\"horizontalAlignClick('left')\">\n <mat-icon>format_align_left</mat-icon>\n </button>\n <button\n mat-icon-button\n class=\"toggle-button\"\n color=\"basic\"\n type=\"button\"\n [ngClass]=\"{ selected: block.horizontalAlign === 'center' }\"\n (click)=\"horizontalAlignClick('center')\">\n <mat-icon>format_align_center</mat-icon>\n </button>\n <button\n mat-icon-button\n class=\"toggle-button\"\n color=\"basic\"\n type=\"button\"\n [ngClass]=\"{ selected: block.horizontalAlign === 'justify' }\"\n (click)=\"horizontalAlignClick('justify')\">\n <mat-icon>format_align_justify</mat-icon>\n </button>\n <button\n mat-icon-button\n class=\"toggle-button\"\n color=\"basic\"\n type=\"button\"\n [ngClass]=\"{ selected: block.horizontalAlign === 'right' }\"\n (click)=\"horizontalAlignClick('right')\">\n <mat-icon>format_align_right</mat-icon>\n </button>\n <button\n mat-icon-button\n class=\"toggle-button\"\n color=\"basic\"\n type=\"button\"\n [ngClass]=\"{ selected: block.verticalAlign === 'top' }\"\n (click)=\"verticalAlignClick('top')\">\n <mat-icon>vertical_align_top</mat-icon>\n </button>\n <button\n mat-icon-button\n class=\"toggle-button\"\n color=\"basic\"\n type=\"button\"\n [ngClass]=\"{ selected: block.verticalAlign === 'center' }\"\n (click)=\"verticalAlignClick('center')\">\n <mat-icon>vertical_align_center</mat-icon>\n </button>\n <button\n mat-icon-button\n class=\"toggle-button\"\n color=\"basic\"\n type=\"button\"\n [ngClass]=\"{ selected: block.verticalAlign === 'bottom' }\"\n (click)=\"verticalAlignClick('bottom')\">\n <mat-icon>vertical_align_bottom</mat-icon>\n </button>\n </div>\n </div>\n <div class=\"sidebar-panel\">\n <div class=\"sidebar-label\">Border</div>\n\n <div class=\"sidebar-row field-gap\">\n <fs-color-picker-chip\n (changed)=\"borderColorChange($event)\"\n [color]=\"block.borderColor\">\n </fs-color-picker-chip>\n\n <mat-form-field class=\"form-field-padless form-field-prefix border-width\" floatLabel=\"never\">\n <input\n matInput\n [(ngModel)]=\"block.borderWidth\"\n name=\"borderWidth\"\n fsMaskNumber\n scale=\"5\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'borderWidth', 1)\"\n (ngModelChange)=\"numberChange($event, 'borderWidth')\"\n placeholder=\"Width\">\n <span matPrefix *ngIf=\"block.borderWidth\">W</span>\n </mat-form-field>\n </div>\n </div>\n <div class=\"sidebar-panel\">\n <div class=\"sidebar-label\">Shape</div>\n\n <div class=\"sidebar-row field-gap\">\n <fs-color-picker-chip\n (changed)=\"backgroundColorChange($event)\"\n [color]=\"block.backgroundColor\">\n </fs-color-picker-chip>\n\n <mat-form-field class=\"form-field-padless form-field-prefix shape-radius\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.shapeRadius\"\n name=\"shapeRadius\"\n fsMaskNumber\n scale=\"5\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'shapeRadius', 1)\"\n (ngModelChange)=\"numberChange($event, 'shapeRadius')\"\n placeholder=\"Radius\">\n <span matPrefix *ngIf=\"block.shapeRadius\">R</span>\n </mat-form-field>\n\n <div class=\"shape-corners\">\n <div\n class=\"shape-corner shape-corner-top-left\"\n [ngClass]=\"{ round: block.shapeTopLeft === 'round' }\"\n (click)=\"shapeRound('shapeTopLeft')\"></div>\n <div\n class=\"shape-corner shape-corner-top-right\"\n [ngClass]=\"{ round: block.shapeTopRight === 'round' }\"\n (click)=\"shapeRound('shapeTopRight')\"></div>\n <div\n class=\"shape-corner shape-corner-bottom-left\"\n [ngClass]=\"{ round: block.shapeBottomLeft === 'round' }\"\n (click)=\"shapeRound('shapeBottomLeft')\"></div>\n <div\n class=\"shape-corner shape-corner-bottom-right\"\n [ngClass]=\"{ round: block.shapeBottomRight === 'round' }\"\n (click)=\"shapeRound('shapeBottomRight')\"></div>\n </div>\n </div>\n </div>\n <div class=\"sidebar-panel shadow-panel\">\n <div class=\"sidebar-label\">Shadow</div>\n\n <div class=\"sidebar-row field-gap\">\n <fs-color-picker-chip\n (changed)=\"shadowColorChange($event)\"\n [color]=\"block.shadowColor\">\n </fs-color-picker-chip>\n\n <mat-form-field class=\"form-field-padless form-field-prefix shadow-x\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.shadowX\"\n name=\"shadowX\"\n fsMaskNumber\n scale=\"5\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'shadowX')\"\n (ngModelChange)=\"numberChange($event, 'shadowX')\">\n <span matPrefix>X</span>\n </mat-form-field>\n <mat-form-field class=\"form-field-padless form-field-prefix shadow-y\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.shadowY\"\n name=\"shadowY\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'shadowY')\"\n (ngModelChange)=\"numberChange($event, 'shadowY')\">\n <span matPrefix>Y</span>\n </mat-form-field>\n <mat-form-field class=\"form-field-padless form-field-prefix shadow-blur\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.shadowBlur\"\n name=\"shadowBlur\"\n placeholder=\"Blur\"\n fsMaskNumber\n scale=\"5\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'shadowBlur')\"\n (ngModelChange)=\"numberChange($event, 'shadowBlur')\">\n <span matPrefix *ngIf=\"block.shadowBlur\">B</span>\n </mat-form-field>\n <mat-form-field class=\"form-field-padless form-field-prefix shadow-spread\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.shadowSpread\"\n name=\"shadowSpread\"\n placeholder=\"Spread\"\n fsMaskNumber\n scale=\"5\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'shadowSpread')\"\n (ngModelChange)=\"numberChange($event, 'shadowSpread')\">\n <span matPrefix *ngIf=\"block.shadowSpread\">S</span>\n </mat-form-field>\n <!-- <mat-form-field class=\"form-field-padless\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.shadowOpacity\"\n name=\"shadowOpacity\"\n placeholder=\"Opacity\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'shadowOpacity')\"\n (ngModelChange)=\"numberChange($event, 'shadowOpacity')\">\n <span matPrefix *ngIf=\"block.shadowOpacity\">O</span>\n </mat-form-field> -->\n </div>\n </div>\n <ng-container *ngIf=\"block.type === BlockType.Rectangle\">\n <div class=\"sidebar-panel\">\n <div class=\"sidebar-label\">Image</div>\n <div class=\"sidebar-row image-row\">\n <fs-file (select)=\"blockUpload(block, $event)\">\n <button\n type=\"button\"\n mat-icon-button>\n <mat-icon>cloud_upload</mat-icon>\n </button>\n </fs-file>\n <ng-container *ngIf=\"block.imageUrl\">\n <button\n mat-icon-button\n color=\"basic\"\n type=\"button\"\n (click)=\"imageRemove()\">\n <mat-icon>clear</mat-icon>\n </button>\n <button\n mat-icon-button\n class=\"toggle-button\"\n color=\"basic\"\n type=\"button\"\n [ngClass]=\"{ selected: clippable }\"\n (click)=\"imageClip()\">\n <mat-icon>crop</mat-icon>\n </button>\n\n <mat-form-field class=\"form-field-padless opacity\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.imageOpacity\"\n fsMaskNumber\n scale=\"5\"\n name=\"imageOpacity\"\n placeholder=\"Opacity\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'imageOpacity', 1)\"\n (ngModelChange)=\"numberChange($event, 'imageOpacity')\">\n <span matPrefix *ngIf=\"block.imageOpacity\">O</span>\n </mat-form-field>\n </ng-container>\n </div>\n </div>\n </ng-container> \n <div class=\"sidebar-panel\">\n <div class=\"sidebar-label\">Padding</div>\n <div class=\"sidebar-row padding-row field-gap\">\n\n <mat-form-field class=\"form-field-padless form-field-prefix\" floatLabel=\"never\">\n <input\n matInput\n [(ngModel)]=\"block.padding\"\n name=\"padding\"\n fsMaskNumber\n scale=\"5\"\n (focus)=\"inputFocus($event)\"\n (ngModelChange)=\"paddingAllChange($event)\"\n (keydown)=\"paddingAllKeypress($event, 1)\"\n placeholder=\"All\">\n <span matPrefix *ngIf=\"block.padding\">A</span>\n </mat-form-field>\n\n <mat-form-field class=\"form-field-padless form-field-prefix\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.paddingTop\"\n name=\"paddingTop\"\n fsMaskNumber\n scale=\"5\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"paddingKeypress($event, 'paddingTop')\"\n (ngModelChange)=\"numberChange($event, 'paddingTop')\"\n placeholder=\"Top\">\n <span matPrefix *ngIf=\"block.paddingTop\">T</span>\n </mat-form-field>\n\n <mat-form-field class=\"form-field-padless form-field-prefix\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.paddingBottom\"\n name=\"paddingBottom\"\n fsMaskNumber\n scale=\"5\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"paddingKeypress($event, 'paddingBottom')\"\n (ngModelChange)=\"numberChange($event, 'paddingBottom')\"\n placeholder=\"Bottom\">\n <span matPrefix *ngIf=\"block.paddingBottom\">B</span>\n </mat-form-field>\n\n <mat-form-field class=\"form-field-padless form-field-prefix\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.paddingLeft\"\n name=\"paddingLeft\"\n fsMaskNumber\n scale=\"5\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"paddingKeypress($event, 'paddingLeft')\"\n (ngModelChange)=\"numberChange($event, 'paddingLeft')\"\n placeholder=\"Left\">\n <span matPrefix *ngIf=\"block.paddingLeft\">L</span>\n </mat-form-field>\n\n <mat-form-field class=\"form-field-padless form-field-prefix\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.paddingRight\"\n name=\"paddingRight\"\n fsMaskNumber\n scale=\"5\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"paddingKeypress($event, 'paddingRight')\"\n (ngModelChange)=\"numberChange($event, 'paddingRight')\"\n placeholder=\"Right\">\n <span matPrefix *ngIf=\"block.paddingRight\">R</span>\n </mat-form-field>\n </div>\n </div> \n </ng-container> \n </ng-container>\n <div class=\"sidebar-panel\">\n <div class=\"sidebar-label\">Utilities</div>\n <div class=\"sidebar-row padding-row\">\n <button\n mat-icon-button\n color=\"basic\"\n type=\"button\"\n (click)=\"exportBlocks()\"\n [matTooltip]=\"'Export blocks'\">\n <mat-icon>download</mat-icon>\n </button>\n <button\n mat-icon-button\n color=\"basic\"\n type=\"button\"\n (click)=\"importBlocks()\"\n [matTooltip]=\"'Import blocks'\">\n <mat-icon>upload</mat-icon>\n </button>\n </div>\n </div> \n\n <ng-container *ngFor=\"let sidebarPanel of sidebarPanels\">\n <div div class=\"sidebar-panel\" *ngIf=\"sidebarPanel.show\">\n <div class=\"sidebar-label\">{{sidebarPanel.label}}</div>\n <ng-container\n [ngTemplateOutlet]=\"sidebarPanel.templateRef\"\n [ngTemplateOutletContext]=\"{ block: block }\"></ng-container>\n </div>\n </ng-container>\n </form>\n</div>\n<ng-template #addButton let-blockType=\"blockType\">\n <button\n type=\"button\"\n mat-icon-button\n [matTooltip]=\"'Add ' + blockType.name\"\n (click)=\"blockAdd(blockType.value)\">\n <mat-icon>{{blockType.icon}}</mat-icon>\n </button>\n</ng-template>", styles: [".sidebar{width:320px;font-size:14px;height:100%;overflow:auto;background-color:#fff;padding:0 10px 10px;box-shadow:0 1px 3px 1px #0003;z-index:1;position:relative;box-sizing:border-box}.sidebar form{height:100%}.sidebar .sidebar-row{display:flex;flex-direction:row;flex-wrap:wrap;align-items:center}.sidebar .sidebar-row+.sidebar-row{margin-top:12px}.sidebar .sidebar-row fs-color-picker-chip{margin-left:6px}.sidebar .sidebar-row.padding-row{flex-wrap:unset}.sidebar .sidebar-row.padding-row ::ng-deep .mat-form-field{width:20%;min-width:0}.sidebar .sidebar-row.image-row{margin-bottom:-5px}.sidebar .sidebar-row.image-row .opacity{width:60px;margin-left:10px}.sidebar .sidebar-row ::ng-deep .mat-checkbox,.sidebar .sidebar-row ::ng-deep .mat-form-field{font-size:12px}.sidebar .sidebar-row.field-gap>*:not(.mat-icon-button):not(fs-file){margin-right:11px}.sidebar .sidebar-row.field-gap>*:not(.mat-icon-button):not(fs-file):last-child{margin-right:0}.sidebar .layer-up ::ng-deep .mat-button-wrapper,.sidebar .layer-down ::ng-deep .mat-button-wrapper{position:relative}.sidebar .layer-up ::ng-deep .mat-button-wrapper mat-icon:first-child,.sidebar .layer-down ::ng-deep .mat-button-wrapper mat-icon:first-child{position:absolute;transform:rotate(90deg) scale(.5);top:-7px;color:#fff}.sidebar .layer-down mat-icon:first-child{transform:rotate(270deg) scale(.6)}.sidebar .padding{width:45px}.sidebar .line-height,.sidebar .font-size{width:45px}.sidebar .border-width{width:50px}.sidebar .shape-radius{width:60px}.sidebar .shape-corners{display:grid;grid-template-columns:1fr 1fr;grid-column-gap:1px;column-gap:1px;grid-row-gap:1px;row-gap:1px}.sidebar .shape-corners .shape-corner{height:13px;width:13px;background-color:#ccc;cursor:pointer}.sidebar .shape-corners .shape-corner.round{background-color:#212121}.sidebar .shape-corners .shape-corner.round.shape-corner-top-right{border-top-right-radius:50%}.sidebar .shape-corners .shape-corner.round.shape-corner-top-left{border-top-left-radius:50%}.sidebar .shape-corners .shape-corner.round.shape-corner-bottom-left{border-bottom-left-radius:50%}.sidebar .shape-corners .shape-corner.round.shape-corner-bottom-right{border-bottom-right-radius:50%}.sidebar button.toggle-button:not(.selected) mat-icon{color:#ccc}.sidebar .group-block{width:100%;display:flex;align-items:center}.sidebar .group-block a{margin-left:5px;color:inherit}.sidebar .group-block a mat-icon{transform:scale(.8)}.sidebar .sidebar-panel{padding:10px}.sidebar .sidebar-panel+.sidebar-panel{border-top:1px solid #dadada}.sidebar .sidebar-panel.block-form-panel .sidebar-label{display:flex;align-items:center}.sidebar .sidebar-panel.block-form-panel .sidebar-label mat-icon{transform:scale(.8);color:inherit;margin-left:-5px}.sidebar .sidebar-panel.block-form-panel .form-field-options mat-checkbox{display:block}.sidebar .sidebar-panel.block-form-panel .form-field-options mat-checkbox+mat-checkbox{margin-top:2px}.sidebar .sidebar-panel.info-panel .mat-form-field{width:60px}.sidebar .sidebar-panel.info-panel .mat-form-field.rotate{width:50px}.sidebar .sidebar-panel.shadow-panel .mat-form-field{width:41px}.sidebar .sidebar-panel.shadow-panel .mat-form-field.shadow-x,.sidebar .sidebar-panel.shadow-panel .mat-form-field.shadow-y{width:40px}.sidebar .sidebar-panel.shadow-panel .mat-form-field.shadow-blur{width:50px}.sidebar .sidebar-panel.shadow-panel .mat-form-field.shadow-spread{width:60px}.sidebar .sidebar-panel.typography-panel fs-font-picker{width:100%}.sidebar .sidebar-panel.typography-panel .style-row{margin-bottom:-10px}.sidebar .sidebar-panel.typography-panel .align-row{margin-bottom:-5px}.sidebar .sidebar-panel.typography-panel .align-row .mat-icon-button{width:35px;height:35px;line-height:35px}.sidebar .sidebar-panel .sidebar-label{font-size:11px;margin-bottom:7px;color:#9e9e9e}.sidebar .sidebar-panel .keep-ratio{color:inherit;transform:scale(.85);display:block}.full-width{width:100%}:host ::ng-deep .mat-form-field-appearance-outline.form-field-prefix .mat-form-field-suffix,:host ::ng-deep .mat-form-field-appearance-outline.form-field-prefix .mat-form-field-prefix{top:0}:host ::ng-deep .mat-form-field-prefix{color:#9e9e9e;margin-right:3px;font-size:85%}\n"], components: [{ type: i6$1.FsFileComponent, selector: "fs-file", inputs: ["minHeight", "minWidth", "orientate", "multiple", "capture", "allowClick", "allowDrop", "accept", "disabled", "imageWidth", "imageHeight", "imageQuality"], outputs: ["select", "error", "clicked", "declined"] }, { type: i4.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i9.MatFormField, selector: "mat-form-field", inputs: ["color", "floatLabel", "appearance", "hideRequiredMarker", "hintLabel"], exportAs: ["matFormField"] }, { type: i10.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i11.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: i12.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex", "aria-label", "aria-labelledby", "id", "labelPosition", "name", "required", "checked", "disabled", "indeterminate", "aria-describedby", "value"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { type: i2$1.FsFontPickerComponent, selector: "fs-font-picker" }, { type: i14.FsColorPickerChipComponent, selector: "fs-color-picker-chip", inputs: ["color", "showClear"], outputs: ["changed"] }], directives: [{ type: i5.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i5.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i5.NgForm, selector: "form:not([ngNoForm]):not([formGroup]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i6.FsFormDirective, selector: "[fsForm]", inputs: ["wrapperSelector", "messageSelector", "hintSelector", "labelSelector", "autocomplete", "shortcuts", "confirm", "confirmDialog", "confirmDrawer", "confirmBrowser", "confirmTabs", "dirtySubmitButton", "submit", "successDelay", "errorDelay", "tabGroup", "deactivationGuard"], outputs: ["fsForm", "invalid", "valid", "submitted", "reseted", "cleared"] }, { type: i17.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i17.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i17.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i17.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i17.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i17.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { type: i18.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { type: i7.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["id", "disabled", "required", "type", "value", "readonly", "placeholder", "errorStateMatcher", "aria-describedby"], exportAs: ["matInput"] }, { type: i5.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i20.FsMaskNumberDirective, selector: "[fsMaskNumber]" }, { type: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i5.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i6.FsFormNoFsValidatorsDirective, selector: "[ngModel]:not([required]):not([fsFormRequired]):not([fsFormCompare]):not([fsFormDateRange]):not([fsFormEmail]):not([fsFormEmails]):not([fsFormFunction]):not([fsFormGreater]):not([fsFormInteger]):not([fsFormLesser]):not([fsFormMax]):not([fsFormMaxLength]):not([fsFormMin]):not([fsFormMinLength]):not([fsFormNumeric]):not([fsFormPattern]):not([fsFormPhone]):not([fsFormUrl]):not([validate])" }, { type: i9.MatPrefix, selector: "[matPrefix]" }, { type: i9.MatLabel, selector: "mat-label" }, { type: i8.CdkTextareaAutosize, selector: "textarea[cdkTextareaAutosize]", inputs: ["cdkAutosizeMinRows", "cdkAutosizeMaxRows", "cdkTextareaAutosize", "placeholder"], exportAs: ["cdkTextareaAutosize"] }, { type: i6.FsFormValidateDirective, selector: "[validate]", inputs: ["validate", "validateData", "validateOnSubmit"] }, { type: i17.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1394
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SidebarComponent, decorators: [{
1395
- type: Component,
1396
- args: [{
1397
- selector: 'sidebar',
1398
- templateUrl: './sidebar.component.html',
1399
- styleUrls: ['./sidebar.component.scss'],
1400
- changeDetection: ChangeDetectionStrategy.OnPush,
1401
- }]
1402
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }, { type: i0.ChangeDetectorRef }, { type: i2$2.FsClipboard }, { type: i3$2.FsMessage }, { type: i3$1.FsPrompt }, { type: i1.MatDialog }, { type: undefined, decorators: [{
1403
- type: Inject,
1404
- args: [DOCUMENT]
1405
- }] }]; }, propDecorators: { sidebarPanels: [{
1406
- type: ContentChildren,
1407
- args: [FsBlockEditorSidebarPanelDirective]
1408
- }], config: [{
1409
- type: Input
1410
- }], blocks: [{
1411
- type: Input
1412
- }], zoompan: [{
1413
- type: Input
1414
- }], zoomCenter: [{
1415
- type: Output
1416
- }] } });
1417
-
1418
- class ArtboardComponent {
1419
- constructor(_el, _blockEditor, _cdRef) {
1420
- this._el = _el;
1421
- this._blockEditor = _blockEditor;
1422
- this._cdRef = _cdRef;
1423
- this.blocks = [];
1424
- this._destroy$ = new Subject();
1425
- }
1426
- get el() {
1427
- return this._el.nativeElement;
1428
- }
1429
- ngOnInit() {
1430
- this.config = Object.assign(Object.assign({}, this.config), { unit: 'in' });
1431
- this._blockEditor.registerContainer(this.artboard.nativeElement);
1432
- this._blockEditor.registerMargin(this.marginContainer.nativeElement);
1433
- this._blockEditor.blocks$
1434
- .pipe(takeUntil(this._destroy$))
1435
- .subscribe((blocks) => {
1436
- this.blocks = blocks;
1437
- this._cdRef.markForCheck();
1438
- });
1439
- this._blockEditor.blockAdded$
1440
- .pipe(delay(300), takeUntil(this._destroy$))
1441
- .subscribe((block) => {
1442
- this._blockEditor.selectedBlocks = [block];
1443
- this._cdRef.markForCheck();
1444
- });
1445
- }
1446
- ngAfterViewInit() {
1447
- this.blockComponents
1448
- .changes
1449
- .pipe(takeUntil(this._destroy$))
1450
- .subscribe(() => {
1451
- this._blockEditor.blockComponents = this.blockComponents.toArray();
1452
- });
1453
- this._blockEditor.blockComponents = this.blockComponents.toArray();
1454
- }
1455
- ngOnDestroy() {
1456
- this._destroy$.next();
1457
- this._destroy$.complete();
1458
- }
1459
- }
1460
- ArtboardComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ArtboardComponent, deps: [{ token: i0.ElementRef }, { token: BlockEditorService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
1461
- ArtboardComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: ArtboardComponent, selector: "app-artboard", inputs: { config: "config", zoompan: "zoompan" }, queries: [{ propertyName: "sidebarPanels", predicate: FsBlockEditorSidebarPanelDirective }], viewQueries: [{ propertyName: "artboard", first: true, predicate: ["artboard"], descendants: true, static: true }, { propertyName: "marginContainer", first: true, predicate: ["marginContainer"], descendants: true, static: true }, { propertyName: "sidebar", first: true, predicate: SidebarComponent, descendants: true, static: true }, { propertyName: "blockComponents", predicate: FsBlockComponent, descendants: true }, { propertyName: "margins", predicate: FsBlockEditorMarginDirective, descendants: true }], ngImport: i0, template: "<div\n #artboard\n class=\"artboard mat-elevation-z4 deselectable\"\n [style.width]=\"config.width + config.unit\"\n [style.height]=\"config.height + config.unit\">\n <fs-block\n *ngFor=\"let block of blocks\"\n [zoompan]=\"zoompan\"\n [block]=\"block\">\n </fs-block>\n <div class=\"margin margin-top\" *ngIf=\"config.marginTop\" [style.top]=\"config.marginTop + 'in'\"></div>\n <div class=\"margin margin-left\" *ngIf=\"config.marginLeft\" [style.left]=\"config.marginLeft + 'in'\"></div>\n <div class=\"margin margin-bottom\" *ngIf=\"config.marginBottom\" [style.bottom]=\"config.marginBottom + 'in'\"></div>\n <div class=\"margin margin-right\" *ngIf=\"config.marginRight\" [style.right]=\"config.marginRight + 'in'\"></div>\n <div\n #marginContainer\n class=\"margin-container\"\n [style.top]=\"config.marginTop + 'in'\"\n [style.right]=\"config.marginRight + 'in'\"\n [style.bottom]=\"config.marginBottom + 'in'\"\n [style.left]=\"config.marginLeft + 'in'\">\n </div>\n</div> \n\n", styles: [".artboard{position:relative;display:inline-flex;background-color:#fff}.artboard .margin-container{position:absolute;z-index:-1}.artboard .margin{position:absolute;border-color:#ff85bd5e;border-style:dashed;border-width:0px}.artboard .margin.margin-top,.artboard .margin.margin-bottom{width:100%;border-top-width:1px}.artboard .margin.margin-left,.artboard .margin.margin-right{height:100%;border-left-width:1px}\n"], components: [{ type: FsBlockComponent, selector: "fs-block", inputs: ["block", "html", "zoompan"] }], directives: [{ type: i17.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i17.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1462
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ArtboardComponent, decorators: [{
1463
- type: Component,
1464
- args: [{
1465
- selector: 'app-artboard',
1466
- templateUrl: 'artboard.component.html',
1467
- styleUrls: ['artboard.component.scss'],
1468
- changeDetection: ChangeDetectionStrategy.OnPush,
1469
- }]
1470
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { sidebarPanels: [{
1471
- type: ContentChildren,
1472
- args: [FsBlockEditorSidebarPanelDirective]
1473
- }], blockComponents: [{
1474
- type: ViewChildren,
1475
- args: [FsBlockComponent]
1476
- }], artboard: [{
1477
- type: ViewChild,
1478
- args: ['artboard', { static: true }]
1479
- }], marginContainer: [{
1480
- type: ViewChild,
1481
- args: ['marginContainer', { static: true }]
1482
- }], margins: [{
1483
- type: ViewChildren,
1484
- args: [FsBlockEditorMarginDirective]
1485
- }], sidebar: [{
1486
- type: ViewChild,
1487
- args: [SidebarComponent, { static: true }]
1488
- }], config: [{
1489
- type: Input
1490
- }], zoompan: [{
1491
- type: Input
1492
- }] } });
1493
-
1494
- class FsBlockEditorComponent {
1495
- constructor(_el, _blockEditor) {
1496
- this._el = _el;
1497
- this._blockEditor = _blockEditor;
1498
- this._destroy$ = new Subject();
1499
- }
1500
- get el() {
1501
- return this._el.nativeElement;
1502
- }
1503
- ngOnInit() {
1504
- this.config = Object.assign(Object.assign({}, this.config), { unit: 'in' });
1505
- this._blockEditor.init(this.config);
1506
- this._blockEditor.blocks$
1507
- .pipe(takeUntil(this._destroy$))
1508
- .subscribe((blocks) => {
1509
- this.blocks = blocks;
1510
- });
1511
- setTimeout(() => {
1512
- this.zoomCenter();
1513
- });
1514
- }
1515
- zoomCenter() {
1516
- this.zoompan.center(this.artboard.nativeElement, { vertical: false });
1517
- }
1518
- editorContainerClick(event) {
1519
- if (event.target.classList.contains('deselectable') ||
1520
- event.target.classList.contains('fs-zoom-pan-container')) {
1521
- this.zoompan.enable();
1522
- this._blockEditor.selectedBlocks = [];
1523
- }
1524
- }
1525
- ngOnDestroy() {
1526
- this._destroy$.next();
1527
- this._destroy$.complete();
1528
- }
1529
- }
1530
- FsBlockEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorComponent, deps: [{ token: i0.ElementRef }, { token: BlockEditorService }], target: i0.ɵɵFactoryTarget.Component });
1531
- FsBlockEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorComponent, selector: "fs-block-editor", inputs: { config: "config" }, providers: [
1532
- BlockEditorService,
1533
- BlocksStore,
1534
- ], queries: [{ propertyName: "sidebarPanels", predicate: FsBlockEditorSidebarPanelDirective }], viewQueries: [{ propertyName: "zoompan", first: true, predicate: FsZoomPanComponent, descendants: true, static: true }, { propertyName: "artboardContainer", first: true, predicate: ["artboardContainer"], descendants: true, static: true }, { propertyName: "sidebar", first: true, predicate: SidebarComponent, descendants: true, static: true }, { propertyName: "artboard", first: true, predicate: ArtboardComponent, descendants: true, read: ElementRef }], ngImport: i0, template: "<div \n class=\"editor-container deselectable\"\n (mousedown)=\"editorContainerClick($event)\">\n <div\n #artboardContainer\n class=\"artboard-container deselectable\">\n <div #zoomPanContaner class=\"zoom-pan-container deselectable\">\n <fs-zoom-pan \n class=\"deselectable\"\n [zoomMax]=\"5\"\n [top]=\"10\">\n <ng-template fsZoomPanContent>\n <app-artboard \n [zoompan]=\"zoompan\"\n [config]=\"config\">\n </app-artboard>\n </ng-template>\n </fs-zoom-pan>\n </div>\n </div>\n <sidebar\n [config]=\"config\"\n [blocks]=\"blocks\"\n (zoomCenter)=\"zoomCenter()\">\n </sidebar>\n</div>\n", styles: [".editor-container{display:flex;flex-direction:row;position:relative;height:100%;background:#d8d8d8;overflow:hidden}.editor-container .artboard-container{display:flex;flex-grow:1;min-width:0;border:1px solid #ececec}.editor-container .zoom-pan-container{flex:1}fs-zoom-pan{height:100%}\n"], components: [{ type: i2$3.FsZoomPanComponent, selector: "fs-zoom-pan", inputs: ["zoomMax", "zoomMin", "zoomDefault", "top", "left"], outputs: ["moved", "zoomed"] }, { type: ArtboardComponent, selector: "app-artboard", inputs: ["config", "zoompan"] }, { type: SidebarComponent, selector: "sidebar", inputs: ["config", "blocks", "zoompan"], outputs: ["zoomCenter"] }], directives: [{ type: i2$3.FsZoomPanContentDirective, selector: "[fsZoomPanContent]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1535
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorComponent, decorators: [{
1536
- type: Component,
1537
- args: [{
1538
- selector: 'fs-block-editor',
1539
- templateUrl: './block-editor.component.html',
1540
- styleUrls: ['./block-editor.component.scss'],
1541
- changeDetection: ChangeDetectionStrategy.OnPush,
1542
- providers: [
1543
- BlockEditorService,
1544
- BlocksStore,
1545
- ],
1546
- }]
1547
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }]; }, propDecorators: { sidebarPanels: [{
1548
- type: ContentChildren,
1549
- args: [FsBlockEditorSidebarPanelDirective]
1550
- }], zoompan: [{
1551
- type: ViewChild,
1552
- args: [FsZoomPanComponent, { static: true }]
1553
- }], artboardContainer: [{
1554
- type: ViewChild,
1555
- args: ['artboardContainer', { static: true }]
1556
- }], sidebar: [{
1557
- type: ViewChild,
1558
- args: [SidebarComponent, { static: true }]
1559
- }], artboard: [{
1560
- type: ViewChild,
1561
- args: [ArtboardComponent, { read: ElementRef }]
1562
- }], config: [{
1563
- type: Input
1564
- }] } });
1565
-
1566
- class FsBlockEditorModule {
1567
- static forRoot() {
1568
- return {
1569
- ngModule: FsBlockEditorModule,
1570
- };
1571
- }
1572
- }
1573
- FsBlockEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1574
- FsBlockEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, declarations: [FsBlockComponent,
1575
- FsBlockEditorComponent,
1576
- FsBlockEditorSidebarPanelDirective,
1577
- FsBlockEditorMarginDirective,
1578
- SidebarComponent,
1579
- ArtboardComponent,
1580
- LayersReorderDialogComponent,
1581
- CreateImageUrlPipe,
1582
- GroupDialogComponent], imports: [CommonModule,
1583
- FormsModule,
1584
- DragDropModule,
1585
- MatIconModule,
1586
- MatButtonModule,
1587
- MatInputModule,
1588
- MatFormFieldModule,
1589
- MatCheckboxModule,
1590
- MatTooltipModule,
1591
- MatSelectModule,
1592
- MatListModule,
1593
- FsFileModule,
1594
- FsColorPickerModule,
1595
- FsMenuModule,
1596
- FsZoomPanModule,
1597
- FsFormModule,
1598
- FsMaskModule,
1599
- FsFontPickerModule,
1600
- FsAutocompleteModule,
1601
- FsDialogModule], exports: [FsBlockComponent,
1602
- FsBlockEditorComponent,
1603
- FsBlockEditorSidebarPanelDirective] });
1604
- FsBlockEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, imports: [[
1605
- CommonModule,
1606
- FormsModule,
1607
- DragDropModule,
1608
- MatIconModule,
1609
- MatButtonModule,
1610
- MatInputModule,
1611
- MatFormFieldModule,
1612
- MatCheckboxModule,
1613
- MatTooltipModule,
1614
- MatSelectModule,
1615
- MatListModule,
1616
- FsFileModule,
1617
- FsColorPickerModule,
1618
- FsMenuModule,
1619
- FsZoomPanModule,
1620
- FsFormModule,
1621
- FsMaskModule,
1622
- FsFontPickerModule,
1623
- FsAutocompleteModule,
1624
- FsDialogModule,
1625
- ]] });
1626
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, decorators: [{
1627
- type: NgModule,
1628
- args: [{
1629
- imports: [
1630
- CommonModule,
1631
- FormsModule,
1632
- DragDropModule,
1633
- MatIconModule,
1634
- MatButtonModule,
1635
- MatInputModule,
1636
- MatFormFieldModule,
1637
- MatCheckboxModule,
1638
- MatTooltipModule,
1639
- MatSelectModule,
1640
- MatListModule,
1641
- FsFileModule,
1642
- FsColorPickerModule,
1643
- FsMenuModule,
1644
- FsZoomPanModule,
1645
- FsFormModule,
1646
- FsMaskModule,
1647
- FsFontPickerModule,
1648
- FsAutocompleteModule,
1649
- FsDialogModule,
1650
- ],
1651
- exports: [
1652
- FsBlockComponent,
1653
- FsBlockEditorComponent,
1654
- FsBlockEditorSidebarPanelDirective,
1655
- ],
1656
- declarations: [
1657
- FsBlockComponent,
1658
- FsBlockEditorComponent,
1659
- FsBlockEditorSidebarPanelDirective,
1660
- FsBlockEditorMarginDirective,
1661
- SidebarComponent,
1662
- ArtboardComponent,
1663
- LayersReorderDialogComponent,
1664
- CreateImageUrlPipe,
1665
- GroupDialogComponent,
1666
- ],
1667
- }]
1668
- }] });
1669
-
1670
- /**
1671
- * Generated bundle index. Do not edit.
1672
- */
1673
-
1674
- export { BlockType, BlockTypes, FsBlockComponent, FsBlockEditorComponent, FsBlockEditorModule, FsBlockEditorSidebarPanelDirective };
1675
- //# sourceMappingURL=firestitch-block-editor.js.map