@firestitch/block-editor 12.3.18 → 12.3.20

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 (59) hide show
  1. package/app/components/artboard/artboard.component.d.ts +31 -31
  2. package/app/components/block/block.component.d.ts +71 -71
  3. package/app/components/block-editor/block-editor.component.d.ts +29 -28
  4. package/app/components/font/font.component.d.ts +12 -12
  5. package/app/components/font/index.d.ts +1 -1
  6. package/app/components/index.d.ts +1 -1
  7. package/app/components/layers-reorder-dialog/layers-reorder-dialog.component.d.ts +15 -15
  8. package/app/components/sidebar/sidebar.component.d.ts +80 -81
  9. package/app/consts/block-formats.const.d.ts +6 -6
  10. package/app/consts/block-types.const.d.ts +14 -14
  11. package/app/consts/index.d.ts +2 -2
  12. package/app/directives/block-editor-margin.directive.d.ts +9 -9
  13. package/app/directives/block-editor-sidebar-panel.directive.d.ts +10 -10
  14. package/app/enums/block-format.enum.d.ts +6 -6
  15. package/app/enums/block-type.enum.d.ts +11 -11
  16. package/app/enums/index.d.ts +2 -2
  17. package/app/fs-block-editor.module.d.ts +34 -33
  18. package/app/interfaces/block-editor-config.d.ts +18 -19
  19. package/app/interfaces/block.d.ts +63 -63
  20. package/app/interfaces/index.d.ts +2 -2
  21. package/app/pipes/create-image-url.pipe.d.ts +10 -0
  22. package/app/services/block-editor.service.d.ts +57 -57
  23. package/app/services/blocks-store.service.d.ts +34 -34
  24. package/app/services/google-font.service.d.ts +15 -15
  25. package/app/services/index.d.ts +2 -2
  26. package/bundles/firestitch-block-editor.umd.js +2015 -2000
  27. package/bundles/firestitch-block-editor.umd.js.map +1 -1
  28. package/esm2015/app/components/artboard/artboard.component.js +108 -108
  29. package/esm2015/app/components/block/block.component.js +478 -477
  30. package/esm2015/app/components/block-editor/block-editor.component.js +96 -86
  31. package/esm2015/app/components/font/font.component.js +31 -31
  32. package/esm2015/app/components/font/index.js +1 -1
  33. package/esm2015/app/components/index.js +1 -1
  34. package/esm2015/app/components/layers-reorder-dialog/layers-reorder-dialog.component.js +43 -43
  35. package/esm2015/app/components/sidebar/sidebar.component.js +242 -249
  36. package/esm2015/app/consts/block-formats.const.js +7 -7
  37. package/esm2015/app/consts/block-types.const.js +12 -12
  38. package/esm2015/app/consts/index.js +2 -2
  39. package/esm2015/app/directives/block-editor-margin.directive.js +18 -18
  40. package/esm2015/app/directives/block-editor-sidebar-panel.directive.js +20 -20
  41. package/esm2015/app/enums/block-format.enum.js +7 -7
  42. package/esm2015/app/enums/block-type.enum.js +12 -12
  43. package/esm2015/app/enums/index.js +2 -2
  44. package/esm2015/app/fs-block-editor.module.js +129 -126
  45. package/esm2015/app/interfaces/block-editor-config.js +2 -2
  46. package/esm2015/app/interfaces/block.js +1 -1
  47. package/esm2015/app/interfaces/index.js +2 -2
  48. package/esm2015/app/pipes/create-image-url.pipe.js +19 -0
  49. package/esm2015/app/services/block-editor.service.js +170 -170
  50. package/esm2015/app/services/blocks-store.service.js +188 -190
  51. package/esm2015/app/services/google-font.service.js +37 -37
  52. package/esm2015/app/services/index.js +2 -2
  53. package/esm2015/firestitch-block-editor.js +4 -4
  54. package/esm2015/public_api.js +6 -6
  55. package/fesm2015/firestitch-block-editor.js +1481 -1462
  56. package/fesm2015/firestitch-block-editor.js.map +1 -1
  57. package/firestitch-block-editor.d.ts +5 -5
  58. package/package.json +1 -1
  59. package/public_api.d.ts +8 -8
@@ -1,1517 +1,1536 @@
1
+ import * as i13 from '@angular/common';
2
+ import { DOCUMENT, CommonModule } from '@angular/common';
3
+ import * as i0 from '@angular/core';
4
+ import { Injectable, Component, ChangeDetectionStrategy, Input, Inject, Pipe, ViewChild, HostBinding, Directive, EventEmitter, ContentChildren, Output, ViewChildren, ElementRef, HostListener, NgModule } from '@angular/core';
1
5
  import * as i16 from '@angular/forms';
2
6
  import { FormsModule } from '@angular/forms';
3
7
  import * as i15 from '@angular/material/input';
4
8
  import { MatInputModule } from '@angular/material/input';
5
- import * as i0 from '@angular/core';
6
- import { Injectable, Component, ChangeDetectionStrategy, Inject, ViewChild, Input, HostBinding, Directive, EventEmitter, ContentChildren, Output, ViewChildren, ElementRef, NgModule } from '@angular/core';
7
- import * as i13 from '@angular/common';
8
- import { DOCUMENT, CommonModule } from '@angular/common';
9
+ import * as i7 from '@angular/cdk/drag-drop';
10
+ import { moveItemInArray, DragDropModule } from '@angular/cdk/drag-drop';
9
11
  import * as i6 from '@angular/material/button';
10
12
  import { MatButtonModule } from '@angular/material/button';
13
+ import * as i9 from '@angular/material/checkbox';
14
+ import { MatCheckboxModule } from '@angular/material/checkbox';
11
15
  import * as i6$1 from '@angular/material/form-field';
12
16
  import { MatFormFieldModule } from '@angular/material/form-field';
13
17
  import * as i3 from '@angular/material/icon';
14
18
  import { MatIconModule } from '@angular/material/icon';
15
- import * as i9 from '@angular/material/checkbox';
16
- import { MatCheckboxModule } from '@angular/material/checkbox';
17
- import * as i14 from '@angular/material/tooltip';
18
- import { MatTooltipModule } from '@angular/material/tooltip';
19
- import * as i7$1 from '@angular/material/select';
20
- import { MatSelectModule } from '@angular/material/select';
21
19
  import * as i4 from '@angular/material/list';
22
20
  import { MatListModule } from '@angular/material/list';
23
- import * as i7 from '@angular/cdk/drag-drop';
24
- import { moveItemInArray, DragDropModule } from '@angular/cdk/drag-drop';
21
+ import * as i7$1 from '@angular/material/select';
22
+ import { MatSelectModule } from '@angular/material/select';
23
+ import * as i14 from '@angular/material/tooltip';
24
+ import { MatTooltipModule } from '@angular/material/tooltip';
25
25
  import * as i12 from '@firestitch/colorpicker';
26
26
  import { FsColorPickerModule } from '@firestitch/colorpicker';
27
+ import * as i2 from '@firestitch/dialog';
28
+ import { FsDialogModule } from '@firestitch/dialog';
27
29
  import * as i3$1 from '@firestitch/file';
28
30
  import { FsFileModule } from '@firestitch/file';
29
31
  import { FsMenuModule } from '@firestitch/menu';
30
32
  import * as i2$2 from '@firestitch/zoom-pan';
31
33
  import { FsZoomPanComponent, FsZoomPanModule } from '@firestitch/zoom-pan';
32
- import * as i2 from '@firestitch/dialog';
33
- import { FsDialogModule } from '@firestitch/dialog';
34
- import { filter, map, groupBy, debounceTime, mergeAll, takeUntil, switchMap, delay } from 'rxjs/operators';
34
+ import * as i10 from '@firestitch/autocomplete';
35
+ import { FsAutocompleteModule } from '@firestitch/autocomplete';
36
+ import * as i1 from '@angular/common/http';
37
+ import { throwError, Subject, BehaviorSubject, from, fromEvent } from 'rxjs';
38
+ import { map, filter, groupBy, debounceTime, mergeAll, takeUntil, switchMap, delay } from 'rxjs/operators';
35
39
  import Moveable from 'moveable';
36
- import { Subject, BehaviorSubject, from, throwError, fromEvent } from 'rxjs';
37
- import { guid, index, round } from '@firestitch/common';
38
- import * as i1 from '@angular/material/dialog';
40
+ import * as i1$1 from '@angular/material/dialog';
39
41
  import { MAT_DIALOG_DATA } from '@angular/material/dialog';
42
+ import { index, guid, round } from '@firestitch/common';
40
43
  import * as i5 from '@angular/material/divider';
41
- import * as i1$1 from '@angular/common/http';
44
+ import * as i1$2 from '@firestitch/api';
42
45
  import * as i2$1 from '@firestitch/prompt';
43
46
  import * as i8 from '@angular/material/core';
44
- import * as i10 from '@firestitch/autocomplete';
45
- import { FsAutocompleteModule } from '@firestitch/autocomplete';
46
47
  import * as i17 from '@angular/cdk/text-field';
47
48
 
48
- var BlockType;
49
- (function (BlockType) {
50
- BlockType["Rectangle"] = "rectangle";
51
- BlockType["ShortText"] = "shorttext";
52
- BlockType["LongText"] = "longtext";
53
- BlockType["Image"] = "image";
54
- BlockType["RadioButton"] = "radiobutton";
55
- BlockType["Checkbox"] = "checkbox";
56
- BlockType["Signature"] = "signature";
57
- BlockType["Pdf"] = "pdf";
58
- BlockType["Date"] = "date";
49
+ class GoogleFontService {
50
+ constructor(httpClient) {
51
+ this.httpClient = httpClient;
52
+ this._apiKey = 'AIzaSyAoT2RLzCSFUb148F4uLXyAuquAzjcjyGk';
53
+ }
54
+ loadFont(font) {
55
+ var link = document.createElement('link');
56
+ link.rel = 'stylesheet';
57
+ link.href = `https://fonts.googleapis.com/css2?family=${font.family}&family=Tangerine&display=swap`;
58
+ document.getElementsByTagName('head')[0].appendChild(link);
59
+ }
60
+ getItems() {
61
+ if (this._fonts$) {
62
+ return this._fonts$.asObservable();
63
+ }
64
+ if (!this._apiKey) {
65
+ return throwError(`Error: api key was not provided to the google fonts service`);
66
+ }
67
+ const url = `https://www.googleapis.com/webfonts/v1/webfonts?key=${this._apiKey}`;
68
+ return this.httpClient.get(url)
69
+ .pipe(map((response) => response.items
70
+ .map((item) => {
71
+ return { family: item.family };
72
+ })));
73
+ }
74
+ }
75
+ GoogleFontService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: GoogleFontService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
76
+ GoogleFontService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: GoogleFontService });
77
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: GoogleFontService, decorators: [{
78
+ type: Injectable
79
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });
80
+
81
+ class FontComponent {
82
+ constructor(_el, _googleFontService) {
83
+ this._el = _el;
84
+ this._googleFontService = _googleFontService;
85
+ }
86
+ ngOnInit() {
87
+ var observer = new IntersectionObserver((entries) => {
88
+ if (entries[0].isIntersecting === true) {
89
+ this._googleFontService.loadFont(this.font);
90
+ }
91
+ }, { threshold: [0] });
92
+ observer.observe(this._el.nativeElement);
93
+ }
94
+ }
95
+ FontComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FontComponent, deps: [{ token: i0.ElementRef }, { token: GoogleFontService }], target: i0.ɵɵFactoryTarget.Component });
96
+ FontComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FontComponent, selector: "app-font", inputs: { font: "font" }, ngImport: i0, template: "<div\n [style.fontFamily]=\"font.family\">\n {{font.family}}\n</div>\n", styles: [""], changeDetection: i0.ChangeDetectionStrategy.OnPush });
97
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FontComponent, decorators: [{
98
+ type: Component,
99
+ args: [{
100
+ selector: 'app-font',
101
+ templateUrl: 'font.component.html',
102
+ styleUrls: ['font.component.scss'],
103
+ changeDetection: ChangeDetectionStrategy.OnPush,
104
+ }]
105
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: GoogleFontService }]; }, propDecorators: { font: [{
106
+ type: Input
107
+ }] } });
108
+
109
+ var BlockType;
110
+ (function (BlockType) {
111
+ BlockType["Rectangle"] = "rectangle";
112
+ BlockType["ShortText"] = "shorttext";
113
+ BlockType["LongText"] = "longtext";
114
+ BlockType["Image"] = "image";
115
+ BlockType["RadioButton"] = "radiobutton";
116
+ BlockType["Checkbox"] = "checkbox";
117
+ BlockType["Signature"] = "signature";
118
+ BlockType["Pdf"] = "pdf";
119
+ BlockType["Date"] = "date";
59
120
  })(BlockType || (BlockType = {}));
60
121
 
61
- var BlockFormat;
62
- (function (BlockFormat) {
63
- BlockFormat["Date"] = "date";
64
- BlockFormat["YYYYMMDD"] = "YYYY/MM/DD";
65
- BlockFormat["Currency"] = "currency";
66
- BlockFormat["Number"] = "number";
122
+ var BlockFormat;
123
+ (function (BlockFormat) {
124
+ BlockFormat["Date"] = "date";
125
+ BlockFormat["YYYYMMDD"] = "YYYY/MM/DD";
126
+ BlockFormat["Currency"] = "currency";
127
+ BlockFormat["Number"] = "number";
67
128
  })(BlockFormat || (BlockFormat = {}));
68
129
 
69
- var EventType;
70
- (function (EventType) {
71
- EventType["Add"] = "add";
72
- EventType["Change"] = "change";
73
- EventType["Remove"] = "remove";
74
- })(EventType || (EventType = {}));
75
- class BlocksStore {
76
- constructor() {
77
- this._lastTabIndex = -1;
78
- this._eventBus$ = new Subject();
79
- this._blocks$ = new BehaviorSubject([]);
80
- this._destroy$ = new Subject();
81
- }
82
- get blocks() {
83
- return [
84
- ...this._blocks$.getValue(),
85
- ];
86
- }
87
- get blocks$() {
88
- return this._blocks$.asObservable();
89
- }
90
- get blockAdded$() {
91
- return this._eventBus$
92
- .pipe(filter(({ type }) => type === EventType.Add), map(({ value }) => value));
93
- }
94
- get blockChanged$() {
95
- return this._eventBus$
96
- .pipe(filter(({ type }) => type === EventType.Change), map(({ value }) => value));
97
- }
98
- get blockRemoved$() {
99
- return this._eventBus$
100
- .pipe(filter(({ type }) => type === EventType.Remove), map(({ value }) => value));
101
- }
102
- ngOnDestroy() {
103
- this._destroy$.next();
104
- this._destroy$.complete();
105
- }
106
- init(config) {
107
- this._config = config;
108
- this._setBlocks(this._config.blocks);
109
- if (this._config.blockChanged) {
110
- this.blockChanged$
111
- .pipe(groupBy((block) => (block.guid)), map((group) => group.pipe(debounceTime(250))), mergeAll())
112
- .subscribe((block) => {
113
- this._config.blockChanged(block);
114
- });
115
- }
116
- }
117
- blockExists(block) {
118
- const index = this.blocks.findIndex((b) => {
119
- return b.guid === block.guid;
120
- });
121
- return index !== -1;
122
- }
123
- blockAdd(block, initBlock = false) {
124
- if (!this._config.blockAdd) {
125
- console.warn('[BlockEditor] Config "blockAdd" is not defined');
126
- return;
127
- }
128
- if (initBlock) {
129
- block = this._createBlock(block);
130
- }
131
- this._config.blockAdd(block)
132
- .pipe(takeUntil(this._destroy$))
133
- .subscribe((newBlock) => {
134
- this._appendBlock(newBlock);
135
- });
136
- }
137
- blockUpload(block, fsFile, initBlock = false) {
138
- if (!this._config.blockUpload) {
139
- console.warn('[BlockEditor] Config "blockUpload" is not defined');
140
- return;
141
- }
142
- if (initBlock) {
143
- block = this._createBlock(block);
144
- }
145
- from(fsFile.imageInfo)
146
- .pipe(switchMap((imageInfo) => {
147
- if ((imageInfo === null || imageInfo === void 0 ? void 0 : imageInfo.height) && (imageInfo === null || imageInfo === void 0 ? void 0 : imageInfo.width)) {
148
- const ratio = imageInfo.height / imageInfo.width;
149
- block.width = this._config.width * .4;
150
- block.height = block.width * ratio;
151
- }
152
- return this._config.blockUpload(block, fsFile.file);
153
- }), takeUntil(this._destroy$))
154
- .subscribe((newBlock) => {
155
- this._appendBlock(newBlock);
156
- });
157
- }
158
- blockChange(block) {
159
- this._dispatchEvent(EventType.Change, block);
160
- }
161
- blockRemove(targetBlocks) {
162
- const blocks = this.blocks;
163
- if (!Array.isArray(targetBlocks)) {
164
- targetBlocks = [targetBlocks];
165
- }
166
- targetBlocks.forEach((block) => {
167
- const index = blocks
168
- .findIndex((b) => b.guid === block.guid);
169
- if (index !== -1) {
170
- blocks.splice(index, 1);
171
- this._dispatchEvent(EventType.Remove, block);
172
- }
173
- });
174
- this._setBlocks(blocks);
175
- }
176
- isReordableBlock(block) {
177
- return [
178
- BlockType.LongText,
179
- BlockType.ShortText,
180
- BlockType.RadioButton,
181
- BlockType.Checkbox,
182
- BlockType.Date,
183
- BlockType.Signature,
184
- ].indexOf(block.type) > -1;
185
- }
186
- updateTabIndex(index) {
187
- this._lastTabIndex = index;
188
- }
189
- _setBlocks(blocks) {
190
- this._blocks$.next([...blocks]);
191
- blocks
192
- .filter((b) => this.isReordableBlock(b))
193
- .forEach((b) => {
194
- this._lastTabIndex = Math.max(b.tabIndex, this._lastTabIndex);
195
- });
196
- }
197
- _appendBlock(block) {
198
- const blocks = [
199
- ...this.blocks,
200
- block,
201
- ];
202
- this._deduplicateIndexesFor(blocks);
203
- this._setBlocks(blocks);
204
- this._dispatchEvent(EventType.Add, block);
205
- }
206
- _dispatchEvent(type, value) {
207
- this._eventBus$.next({
208
- type,
209
- value,
210
- });
211
- }
212
- _createBlock(block) {
213
- const newBlock = Object.assign(Object.assign({ shapeBottomLeft: 'round', shapeTopLeft: 'round', shapeTopRight: 'round', shapeBottomRight: 'round', verticalAlign: 'top', horizontalAlign: 'left' }, block), { guid: block.guid || guid('xxxxxxxxxxxx'), keepRatio: [
214
- BlockType.Checkbox,
215
- BlockType.RadioButton,
216
- BlockType.Image,
217
- BlockType.Pdf,
218
- ]
219
- .indexOf(block.type) !== -1 });
220
- let width = (this._config.width * .333).toFixed(2);
221
- let height = width / 2;
222
- if (newBlock.type === BlockType.Rectangle) {
223
- newBlock.borderColor = '#cccccc';
224
- newBlock.borderWidth = 1;
225
- }
226
- else if (newBlock.type === BlockType.Checkbox || newBlock.type === BlockType.RadioButton) {
227
- width = .25;
228
- height = .25;
229
- }
230
- else {
231
- width = 2;
232
- height = .5;
233
- }
234
- if (this.isReordableBlock(newBlock)) {
235
- newBlock.tabIndex = this._lastTabIndex + 1;
236
- this.updateTabIndex(newBlock.tabIndex);
237
- }
238
- return Object.assign({ top: height, left: width, width,
239
- height }, newBlock);
240
- }
241
- _deduplicateIndexesFor(blocks) {
242
- blocks.forEach((block, index) => {
243
- block.index = index;
244
- });
245
- }
246
- }
247
- BlocksStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlocksStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
248
- BlocksStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlocksStore });
249
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlocksStore, decorators: [{
250
- type: Injectable
251
- }] });
252
-
253
- const BlockTypes = [
254
- { value: BlockType.Rectangle, name: 'Rectangle', icon: 'crop_5_4', type: 'draw' },
255
- { value: BlockType.ShortText, name: 'Short Text', icon: 'short_text', type: 'form' },
256
- { value: BlockType.LongText, name: 'Long Text', icon: 'subject', type: 'form' },
257
- { value: BlockType.RadioButton, name: 'Radio Button', icon: 'radio_button_checked', type: 'form' },
258
- { value: BlockType.Checkbox, name: 'Checkbox', icon: 'check_box', type: 'form' },
259
- { value: BlockType.Date, name: 'Date', icon: 'calendar_today', type: 'form' },
260
- { value: BlockType.Signature, name: 'Signature', icon: 'draw', type: 'form' },
261
- { value: BlockType.Image, name: 'Image', icon: 'image', accept: 'image/*', type: 'draw' },
262
- { value: BlockType.Pdf, name: 'Pdf', icon: 'picture_as_pdf', accept: 'application/pdf', type: 'draw' },
130
+ const BlockTypes = [
131
+ { value: BlockType.Rectangle, name: 'Rectangle', icon: 'crop_5_4', type: 'draw' },
132
+ { value: BlockType.ShortText, name: 'Short Text', icon: 'short_text', type: 'form' },
133
+ { value: BlockType.LongText, name: 'Long Text', icon: 'subject', type: 'form' },
134
+ { value: BlockType.RadioButton, name: 'Radio Button', icon: 'radio_button_checked', type: 'form' },
135
+ { value: BlockType.Checkbox, name: 'Checkbox', icon: 'check_box', type: 'form' },
136
+ { value: BlockType.Date, name: 'Date', icon: 'calendar_today', type: 'form' },
137
+ { value: BlockType.Signature, name: 'Signature', icon: 'draw', type: 'form' },
138
+ { value: BlockType.Image, name: 'Image', icon: 'image', accept: 'image/*', type: 'draw' },
139
+ { value: BlockType.Pdf, name: 'Pdf', icon: 'picture_as_pdf', accept: 'application/pdf', type: 'draw' },
263
140
  ];
264
141
 
265
- class LayersReorderDialogComponent {
266
- constructor(_dialogData, _dialogRef) {
267
- this._dialogRef = _dialogRef;
268
- this.blockTypeIcons = index(BlockTypes, 'value', 'icon');
269
- this._init(_dialogData);
270
- }
271
- swapItems(event) {
272
- moveItemInArray(this.blockComponents, event.previousIndex, event.currentIndex);
273
- }
274
- done() {
275
- this._dialogRef.close(this.blockComponents);
276
- }
277
- _init(data) {
278
- this.blockComponents = data.blockComponents;
279
- }
280
- }
281
- 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 });
282
- 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 Fields</h1>\n <mat-dialog-content>\n <mat-list cdkDropList (cdkDropListDropped)=\"swapItems($event)\">\n <mat-divider></mat-divider>\n <ng-container *ngFor=\"let blockComponent of blockComponents\">\n <mat-list-item cdkDrag cdkDragLockAxis=\"y\">\n <mat-icon cdkDragHandle>drag_handle</mat-icon>\n <mat-icon>\n {{ blockTypeIcons[blockComponent.block.type] }}\n </mat-icon>\n <span class=\"block-label\">\n {{ blockComponent.block.label || blockComponent.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.MatList, selector: "mat-list, mat-action-list", inputs: ["disableRipple", "disabled"], exportAs: ["matList"] }, { type: i5.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { type: i4.MatListItem, selector: "mat-list-item, a[mat-list-item], button[mat-list-item]", inputs: ["disableRipple", "disabled"], exportAs: ["matListItem"] }, { type: i6.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.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: i13.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.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.CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }, { type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
283
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LayersReorderDialogComponent, decorators: [{
284
- type: Component,
285
- args: [{
286
- templateUrl: './layers-reorder-dialog.component.html',
287
- styleUrls: ['./layers-reorder-dialog.component.scss'],
288
- changeDetection: ChangeDetectionStrategy.OnPush,
289
- }]
290
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
291
- type: Inject,
292
- args: [MAT_DIALOG_DATA]
293
- }] }, { type: i1.MatDialogRef }]; } });
142
+ class LayersReorderDialogComponent {
143
+ constructor(_dialogData, _dialogRef) {
144
+ this._dialogRef = _dialogRef;
145
+ this.blockTypeIcons = index(BlockTypes, 'value', 'icon');
146
+ this._init(_dialogData);
147
+ }
148
+ swapItems(event) {
149
+ moveItemInArray(this.blockComponents, event.previousIndex, event.currentIndex);
150
+ }
151
+ done() {
152
+ this._dialogRef.close(this.blockComponents);
153
+ }
154
+ _init(data) {
155
+ this.blockComponents = data.blockComponents;
156
+ }
157
+ }
158
+ LayersReorderDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LayersReorderDialogComponent, deps: [{ token: MAT_DIALOG_DATA }, { token: i1$1.MatDialogRef }], target: i0.ɵɵFactoryTarget.Component });
159
+ 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 Fields</h1>\n <mat-dialog-content>\n <mat-list cdkDropList (cdkDropListDropped)=\"swapItems($event)\">\n <mat-divider></mat-divider>\n <ng-container *ngFor=\"let blockComponent of blockComponents\">\n <mat-list-item cdkDrag cdkDragLockAxis=\"y\">\n <mat-icon cdkDragHandle>drag_handle</mat-icon>\n <mat-icon>\n {{ blockTypeIcons[blockComponent.block.type] }}\n </mat-icon>\n <span class=\"block-label\">\n {{ blockComponent.block.label || blockComponent.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.MatList, selector: "mat-list, mat-action-list", inputs: ["disableRipple", "disabled"], exportAs: ["matList"] }, { type: i5.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { type: i4.MatListItem, selector: "mat-list-item, a[mat-list-item], button[mat-list-item]", inputs: ["disableRipple", "disabled"], exportAs: ["matListItem"] }, { type: i6.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$1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { type: i1$1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { type: i7.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: i13.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.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.CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }, { type: i1$1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
160
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LayersReorderDialogComponent, decorators: [{
161
+ type: Component,
162
+ args: [{
163
+ templateUrl: './layers-reorder-dialog.component.html',
164
+ styleUrls: ['./layers-reorder-dialog.component.scss'],
165
+ changeDetection: ChangeDetectionStrategy.OnPush,
166
+ }]
167
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
168
+ type: Inject,
169
+ args: [MAT_DIALOG_DATA]
170
+ }] }, { type: i1$1.MatDialogRef }]; } });
294
171
 
295
- class BlockEditorService {
296
- constructor(_store, _dialog) {
297
- this._store = _store;
298
- this._dialog = _dialog;
299
- this._selectedBlocks$ = new BehaviorSubject([]);
300
- this._blockComponents = new Map();
301
- this._blockClippable$ = new BehaviorSubject(null);
302
- this._destroy$ = new Subject();
303
- this._blockInited$ = new Subject();
304
- }
305
- get blockComponents() {
306
- return Array.from(this._blockComponents.values());
307
- }
308
- get selectedComponentBlocks() {
309
- return this.blockComponents
310
- .filter((blockComponent) => this.selectedBlocks.indexOf(blockComponent.block) !== -1);
311
- }
312
- init(config) {
313
- this.config = config;
314
- this._store.init(Object.assign({}, this.config));
315
- }
316
- blockAdd(block, newBlock = false) {
317
- this._store.blockAdd(block, newBlock);
318
- }
319
- blockUpload(block, fsFile, newBlock = false) {
320
- this._store.blockUpload(block, fsFile, true);
321
- }
322
- blockRemove(block) {
323
- this._store.blockRemove(block);
324
- }
325
- removeSelectedBlocks() {
326
- this.selectedBlocks
327
- .forEach((block) => {
328
- this.blockRemove(block);
329
- });
330
- this.selectedBlocks = [];
331
- }
332
- get blocks$() {
333
- return this._store.blocks$;
334
- }
335
- get blockChanged$() {
336
- return this._store.blockChanged$;
337
- }
338
- get blockClippable$() {
339
- return this._blockClippable$;
340
- }
341
- set blockClippable(value) {
342
- this._blockClippable$.next(value);
343
- }
344
- get blockAdded$() {
345
- return this._store.blockAdded$;
346
- }
347
- get blockInited$() {
348
- return this._blockInited$;
349
- }
350
- get blockRemoved$() {
351
- return this._store.blockRemoved$;
352
- }
353
- get blocks() {
354
- return this._store.blocks;
355
- }
356
- blockChange(block) {
357
- this._store.blockChange(block);
358
- }
359
- isSelectedBlock(block) {
360
- return this.selectedBlocks.indexOf(block.block) !== -1;
361
- }
362
- indexOf(block) {
363
- return this.blocks.map((e) => e.guid).indexOf(block.guid);
364
- }
365
- selectedBlockComponentChangeProperty(value, name) {
366
- this.selectedBlocks
367
- .forEach((block) => {
368
- block[name] = value;
369
- this.blockChange(block);
370
- });
371
- }
372
- get selectedBlocks$() {
373
- return this._selectedBlocks$;
374
- }
375
- set selectedBlock(block) {
376
- this.selectedBlocks = [block];
377
- }
378
- set selectedBlocks(blocks) {
379
- this.blockComponents
380
- .forEach((blockComponent) => {
381
- if (blocks.indexOf(blockComponent.block) !== -1) {
382
- blockComponent.select();
383
- }
384
- else {
385
- blockComponent.deselect();
386
- }
387
- });
388
- this._selectedBlocks$.next(blocks);
389
- if (this.config.blocksSelected) {
390
- this.config.blocksSelected(blocks);
391
- }
392
- }
393
- get selectedBlocks() {
394
- return this._selectedBlocks$.getValue();
395
- }
396
- saveSelection() {
397
- const selection = window.getSelection();
398
- this._selectionRange = selection.getRangeAt(0);
399
- }
400
- restoreSelection() {
401
- if (this._selectionRange) {
402
- const selection = window.getSelection();
403
- selection.removeAllRanges();
404
- selection.addRange(this._selectionRange);
405
- }
406
- }
407
- hasSelectionRange() {
408
- return this._selectionRange && (this._selectionRange.baseOffset - this._selectionRange.focusOffset) > 0;
409
- }
410
- initBlock(block, blockComponent) {
411
- this._blockComponents.set(block, blockComponent);
412
- this._blockInited$.next(block);
413
- }
414
- destroyBlock(block) {
415
- this._blockComponents.delete(block);
416
- }
417
- registerContainer(container) {
418
- this.container = container;
419
- }
420
- registerMargin(margin) {
421
- this.margin = margin;
422
- }
423
- openReorderDialog() {
424
- const blockComponents = this.blockComponents
425
- .sort((blockCmpA, blockCmpB) => (blockCmpA.block.index - blockCmpB.block.index))
426
- .reverse();
427
- this._dialog
428
- .open(LayersReorderDialogComponent, {
429
- data: {
430
- blockComponents,
431
- }
432
- })
433
- .afterClosed()
434
- .pipe(filter((blockComponents) => !!blockComponents), takeUntil(this._destroy$))
435
- .subscribe((blockComponents) => {
436
- blockComponents
437
- .reverse()
438
- .forEach((blockCmp, index) => {
439
- blockCmp.block.index = index;
440
- this._store.blockChange(blockCmp.block);
441
- this._store.updateTabIndex(index);
442
- });
443
- });
444
- }
445
- ngOnDestroy() {
446
- this._destroy$.next();
447
- this._destroy$.complete();
448
- }
449
- }
450
- BlockEditorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService, deps: [{ token: BlocksStore }, { token: i2.FsDialog }], target: i0.ɵɵFactoryTarget.Injectable });
451
- BlockEditorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService });
452
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService, decorators: [{
453
- type: Injectable
172
+ var EventType;
173
+ (function (EventType) {
174
+ EventType["Add"] = "add";
175
+ EventType["Change"] = "change";
176
+ EventType["Remove"] = "remove";
177
+ })(EventType || (EventType = {}));
178
+ class BlocksStore {
179
+ constructor() {
180
+ this._lastTabIndex = -1;
181
+ this._eventBus$ = new Subject();
182
+ this._blocks$ = new BehaviorSubject([]);
183
+ this._destroy$ = new Subject();
184
+ }
185
+ get blocks() {
186
+ return [
187
+ ...this._blocks$.getValue(),
188
+ ];
189
+ }
190
+ get blocks$() {
191
+ return this._blocks$.asObservable();
192
+ }
193
+ get blockAdded$() {
194
+ return this._eventBus$
195
+ .pipe(filter(({ type }) => type === EventType.Add), map(({ value }) => value));
196
+ }
197
+ get blockChanged$() {
198
+ return this._eventBus$
199
+ .pipe(filter(({ type }) => type === EventType.Change), map(({ value }) => value));
200
+ }
201
+ get blockRemoved$() {
202
+ return this._eventBus$
203
+ .pipe(filter(({ type }) => type === EventType.Remove), map(({ value }) => value));
204
+ }
205
+ ngOnDestroy() {
206
+ this._destroy$.next();
207
+ this._destroy$.complete();
208
+ }
209
+ init(config) {
210
+ this._config = config;
211
+ this._setBlocks(this._config.blocks);
212
+ if (this._config.blockChanged) {
213
+ this.blockChanged$
214
+ .pipe(groupBy((block) => (block.guid)), map((group) => group.pipe(debounceTime(250))), mergeAll())
215
+ .subscribe((block) => {
216
+ this._config.blockChanged(block);
217
+ });
218
+ }
219
+ }
220
+ blockExists(block) {
221
+ const index = this.blocks.findIndex((b) => {
222
+ return b.guid === block.guid;
223
+ });
224
+ return index !== -1;
225
+ }
226
+ blockAdd(block) {
227
+ if (!this._config.blockAdd) {
228
+ console.warn('[BlockEditor] Config "blockAdd" is not defined');
229
+ return;
230
+ }
231
+ block = this._createBlock(block);
232
+ this._config.blockAdd(block)
233
+ .pipe(takeUntil(this._destroy$))
234
+ .subscribe((newBlock) => {
235
+ this._appendBlock(newBlock);
236
+ });
237
+ }
238
+ blockUpload(block, fsFile) {
239
+ if (!this._config.blockUpload) {
240
+ console.warn('[BlockEditor] Config "blockUpload" is not defined');
241
+ return;
242
+ }
243
+ const existing = this.blockExists(block);
244
+ block = this._createBlock(block);
245
+ from(fsFile.imageInfo)
246
+ .pipe(switchMap((imageInfo) => {
247
+ if (!existing && (imageInfo === null || imageInfo === void 0 ? void 0 : imageInfo.height) && (imageInfo === null || imageInfo === void 0 ? void 0 : imageInfo.width)) {
248
+ const ratio = imageInfo.height / imageInfo.width;
249
+ block.width = this._config.width * .4;
250
+ block.height = block.width * ratio;
251
+ }
252
+ return this._config.blockUpload(block, fsFile.file);
253
+ }), takeUntil(this._destroy$))
254
+ .subscribe((newBlock) => {
255
+ if (!existing) {
256
+ this._appendBlock(newBlock);
257
+ }
258
+ });
259
+ }
260
+ blockChange(block) {
261
+ this._dispatchEvent(EventType.Change, block);
262
+ }
263
+ blockRemove(targetBlocks) {
264
+ const blocks = this.blocks;
265
+ if (!Array.isArray(targetBlocks)) {
266
+ targetBlocks = [targetBlocks];
267
+ }
268
+ targetBlocks.forEach((block) => {
269
+ const index = blocks
270
+ .findIndex((b) => b.guid === block.guid);
271
+ if (index !== -1) {
272
+ blocks.splice(index, 1);
273
+ this._dispatchEvent(EventType.Remove, block);
274
+ }
275
+ });
276
+ this._setBlocks(blocks);
277
+ }
278
+ isReordableBlock(block) {
279
+ return [
280
+ BlockType.LongText,
281
+ BlockType.ShortText,
282
+ BlockType.RadioButton,
283
+ BlockType.Checkbox,
284
+ BlockType.Date,
285
+ BlockType.Signature,
286
+ ].indexOf(block.type) > -1;
287
+ }
288
+ updateTabIndex(index) {
289
+ this._lastTabIndex = index;
290
+ }
291
+ _setBlocks(blocks) {
292
+ this._blocks$.next([...blocks]);
293
+ blocks
294
+ .filter((b) => this.isReordableBlock(b))
295
+ .forEach((b) => {
296
+ this._lastTabIndex = Math.max(b.tabIndex, this._lastTabIndex);
297
+ });
298
+ }
299
+ _appendBlock(block) {
300
+ const blocks = [
301
+ ...this.blocks,
302
+ block,
303
+ ];
304
+ this._deduplicateIndexesFor(blocks);
305
+ this._setBlocks(blocks);
306
+ this._dispatchEvent(EventType.Add, block);
307
+ }
308
+ _dispatchEvent(type, value) {
309
+ this._eventBus$.next({
310
+ type,
311
+ value,
312
+ });
313
+ }
314
+ _createBlock(block) {
315
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
316
+ 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', guid: block.guid || guid('xxxxxxxxxxxx'), keepRatio: (_g = block.keepRatio) !== null && _g !== void 0 ? _g : [
317
+ BlockType.Checkbox,
318
+ BlockType.RadioButton,
319
+ BlockType.Pdf,
320
+ ]
321
+ .indexOf(block.type) !== -1 });
322
+ let width = (this._config.width * .333).toFixed(2);
323
+ let height = width / 2;
324
+ if (newBlock.type === BlockType.Rectangle) {
325
+ 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 });
326
+ }
327
+ else if (newBlock.type === BlockType.Checkbox || newBlock.type === BlockType.RadioButton) {
328
+ width = .25;
329
+ height = .25;
330
+ }
331
+ else {
332
+ width = 2;
333
+ height = .5;
334
+ }
335
+ if (this.isReordableBlock(newBlock)) {
336
+ newBlock.tabIndex = this._lastTabIndex + 1;
337
+ this.updateTabIndex(newBlock.tabIndex);
338
+ }
339
+ return Object.assign({ top: height, left: width, width,
340
+ height }, newBlock);
341
+ }
342
+ _deduplicateIndexesFor(blocks) {
343
+ blocks.forEach((block, index) => {
344
+ block.index = index;
345
+ });
346
+ }
347
+ }
348
+ BlocksStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlocksStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
349
+ BlocksStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlocksStore });
350
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlocksStore, decorators: [{
351
+ type: Injectable
352
+ }] });
353
+
354
+ class BlockEditorService {
355
+ constructor(_store, _dialog) {
356
+ this._store = _store;
357
+ this._dialog = _dialog;
358
+ this._selectedBlocks$ = new BehaviorSubject([]);
359
+ this._blockComponents = new Map();
360
+ this._blockClippable$ = new BehaviorSubject(null);
361
+ this._destroy$ = new Subject();
362
+ this._blockInited$ = new Subject();
363
+ }
364
+ get blockComponents() {
365
+ return Array.from(this._blockComponents.values());
366
+ }
367
+ get selectedComponentBlocks() {
368
+ return this.blockComponents
369
+ .filter((blockComponent) => this.selectedBlocks.indexOf(blockComponent.block) !== -1);
370
+ }
371
+ init(config) {
372
+ this.config = config;
373
+ this._store.init(Object.assign({}, this.config));
374
+ }
375
+ blockAdd(block) {
376
+ this._store.blockAdd(block);
377
+ }
378
+ blockUpload(block, fsFile) {
379
+ this._store.blockUpload(block, fsFile);
380
+ }
381
+ blockRemove(block) {
382
+ this._store.blockRemove(block);
383
+ }
384
+ removeSelectedBlocks() {
385
+ this.selectedBlocks
386
+ .forEach((block) => {
387
+ this.blockRemove(block);
388
+ });
389
+ this.selectedBlocks = [];
390
+ }
391
+ get blocks$() {
392
+ return this._store.blocks$;
393
+ }
394
+ get blockChanged$() {
395
+ return this._store.blockChanged$;
396
+ }
397
+ get blockClippable$() {
398
+ return this._blockClippable$;
399
+ }
400
+ set blockClippable(value) {
401
+ this._blockClippable$.next(value);
402
+ }
403
+ get blockAdded$() {
404
+ return this._store.blockAdded$;
405
+ }
406
+ get blockInited$() {
407
+ return this._blockInited$;
408
+ }
409
+ get blockRemoved$() {
410
+ return this._store.blockRemoved$;
411
+ }
412
+ get blocks() {
413
+ return this._store.blocks;
414
+ }
415
+ blockChange(block) {
416
+ this._store.blockChange(block);
417
+ }
418
+ isSelectedBlock(block) {
419
+ return this.selectedBlocks.indexOf(block.block) !== -1;
420
+ }
421
+ indexOf(block) {
422
+ return this.blocks.map((e) => e.guid).indexOf(block.guid);
423
+ }
424
+ selectedBlockComponentChangeProperty(value, name) {
425
+ this.selectedBlocks
426
+ .forEach((block) => {
427
+ block[name] = value;
428
+ this.blockChange(block);
429
+ });
430
+ }
431
+ get selectedBlocks$() {
432
+ return this._selectedBlocks$;
433
+ }
434
+ set selectedBlock(block) {
435
+ this.selectedBlocks = [block];
436
+ }
437
+ set selectedBlocks(blocks) {
438
+ this.blockComponents
439
+ .forEach((blockComponent) => {
440
+ if (blocks.indexOf(blockComponent.block) !== -1) {
441
+ blockComponent.select();
442
+ }
443
+ else {
444
+ blockComponent.deselect();
445
+ }
446
+ });
447
+ this._selectedBlocks$.next(blocks);
448
+ if (this.config.blocksSelected) {
449
+ this.config.blocksSelected(blocks);
450
+ }
451
+ }
452
+ get selectedBlocks() {
453
+ return this._selectedBlocks$.getValue();
454
+ }
455
+ saveSelection() {
456
+ const selection = window.getSelection();
457
+ this._selectionRange = selection.getRangeAt(0);
458
+ }
459
+ restoreSelection() {
460
+ if (this._selectionRange) {
461
+ const selection = window.getSelection();
462
+ selection.removeAllRanges();
463
+ selection.addRange(this._selectionRange);
464
+ }
465
+ }
466
+ hasSelectionRange() {
467
+ return this._selectionRange && (this._selectionRange.baseOffset - this._selectionRange.focusOffset) > 0;
468
+ }
469
+ initBlock(block, blockComponent) {
470
+ this._blockComponents.set(block, blockComponent);
471
+ this._blockInited$.next(block);
472
+ }
473
+ destroyBlock(block) {
474
+ this._blockComponents.delete(block);
475
+ }
476
+ registerContainer(container) {
477
+ this.container = container;
478
+ }
479
+ registerMargin(margin) {
480
+ this.margin = margin;
481
+ }
482
+ openReorderDialog() {
483
+ const blockComponents = this.blockComponents
484
+ .sort((blockCmpA, blockCmpB) => (blockCmpA.block.index - blockCmpB.block.index))
485
+ .reverse();
486
+ this._dialog
487
+ .open(LayersReorderDialogComponent, {
488
+ data: {
489
+ blockComponents,
490
+ }
491
+ })
492
+ .afterClosed()
493
+ .pipe(filter((blockComponents) => !!blockComponents), takeUntil(this._destroy$))
494
+ .subscribe((blockComponents) => {
495
+ blockComponents
496
+ .reverse()
497
+ .forEach((blockCmp, index) => {
498
+ blockCmp.block.index = index;
499
+ this._store.blockChange(blockCmp.block);
500
+ this._store.updateTabIndex(index);
501
+ });
502
+ });
503
+ }
504
+ ngOnDestroy() {
505
+ this._destroy$.next();
506
+ this._destroy$.complete();
507
+ }
508
+ }
509
+ BlockEditorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService, deps: [{ token: BlocksStore }, { token: i2.FsDialog }], target: i0.ɵɵFactoryTarget.Injectable });
510
+ BlockEditorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService });
511
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService, decorators: [{
512
+ type: Injectable
454
513
  }], ctorParameters: function () { return [{ type: BlocksStore }, { type: i2.FsDialog }]; } });
455
514
 
456
- class GoogleFontService {
457
- constructor(httpClient) {
458
- this.httpClient = httpClient;
459
- this._apiKey = 'AIzaSyAoT2RLzCSFUb148F4uLXyAuquAzjcjyGk';
460
- }
461
- loadFont(font) {
462
- var link = document.createElement('link');
463
- link.rel = 'stylesheet';
464
- link.href = `https://fonts.googleapis.com/css2?family=${font.family}&family=Tangerine&display=swap`;
465
- document.getElementsByTagName('head')[0].appendChild(link);
466
- }
467
- getItems() {
468
- if (this._fonts$) {
469
- return this._fonts$.asObservable();
470
- }
471
- if (!this._apiKey) {
472
- return throwError(`Error: api key was not provided to the google fonts service`);
473
- }
474
- const url = `https://www.googleapis.com/webfonts/v1/webfonts?key=${this._apiKey}`;
475
- return this.httpClient.get(url)
476
- .pipe(map((response) => response.items
477
- .map((item) => {
478
- return { family: item.family };
479
- })));
480
- }
481
- }
482
- GoogleFontService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: GoogleFontService, deps: [{ token: i1$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
483
- GoogleFontService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: GoogleFontService });
484
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: GoogleFontService, decorators: [{
485
- type: Injectable
486
- }], ctorParameters: function () { return [{ type: i1$1.HttpClient }]; } });
515
+ class CreateImageUrlPipe {
516
+ constructor(_api) {
517
+ this._api = _api;
518
+ }
519
+ transform(url) {
520
+ return this._api.createApiFile(url).safeDataUrl;
521
+ }
522
+ }
523
+ CreateImageUrlPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: CreateImageUrlPipe, deps: [{ token: i1$2.FsApi }], target: i0.ɵɵFactoryTarget.Pipe });
524
+ CreateImageUrlPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: CreateImageUrlPipe, name: "createImageUrl" });
525
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: CreateImageUrlPipe, decorators: [{
526
+ type: Pipe,
527
+ args: [{ name: 'createImageUrl' }]
528
+ }], ctorParameters: function () { return [{ type: i1$2.FsApi }]; } });
487
529
 
488
- class FsBlockComponent {
489
- constructor(_blockEditor, _elementRef, _cdRef, _googleFontService) {
490
- this._blockEditor = _blockEditor;
491
- this._elementRef = _elementRef;
492
- this._cdRef = _cdRef;
493
- this._googleFontService = _googleFontService;
494
- this.transformating = false;
495
- this.BlockType = BlockType;
496
- this._editable = false;
497
- this._transformable = false;
498
- this._destroy$ = new Subject();
499
- }
500
- get el() {
501
- return this.element.nativeElement;
502
- }
503
- get moveable() {
504
- return this._moveable;
505
- }
506
- get editable() {
507
- return this._editable;
508
- }
509
- get styleTop() {
510
- let top = this.block.top;
511
- return `${top}${this.unit}`;
512
- }
513
- get styleLeft() {
514
- let left = this.block.left;
515
- return `${left}${this.unit}`;
516
- }
517
- get styleWidth() {
518
- let width = this.block.width;
519
- if (this.block.clipPath) {
520
- width -= (this.block.width * this.block.clipPath.values[1] / 100) + (this.block.width * this.block.clipPath.values[3] / 100);
521
- }
522
- return `${width}${this.unit}`;
523
- }
524
- get styleHeight() {
525
- let height = this.block.height;
526
- if (this.block.clipPath) {
527
- height -= (this.block.height * this.block.clipPath.values[0] / 100) + (this.block.height * this.block.clipPath.values[2] / 100);
528
- }
529
- return `${height}${this.unit}`;
530
- }
531
- get styleImageHeight() {
532
- let height = this.block.height;
533
- if (this.block.clipPath) {
534
- const values = this.block.clipPath.values || {};
535
- //height += (values[0]/100 * height) + (values[2]/100 * height);
536
- }
537
- return `${height}${this.unit}`;
538
- }
539
- get styleImageWidth() {
540
- let width = this.block.width;
541
- if (this.block.clipPath) {
542
- const values = this.block.clipPath.values || {};
543
- //width += (values[1]/100 * width) + (values[3]/100 * width);
544
- }
545
- return `${width}${this.unit}`;
546
- }
547
- get styleImageTop() {
548
- let top = 0;
549
- if (this.block.clipPath) {
550
- const values = this.block.clipPath.values || {};
551
- top = (values[0] / 100) * this.block.width * -1;
552
- }
553
- return `${top}${this.unit}`;
554
- }
555
- get styleImageLeft() {
556
- let left = 0;
557
- if (this.block.clipPath) {
558
- const values = this.block.clipPath.values || {};
559
- left = (values[3] / 100) * this.block.width * -1;
560
- }
561
- return `${left}${this.unit}`;
562
- }
563
- get styleClipPath() {
564
- if (!this.block.clipPath) {
565
- return null;
566
- }
567
- const values = this.block.clipPath.values || {};
568
- const top = values[0] / 100 * this.block.height;
569
- const right = (values[1]) / 100 * this.block.width;
570
- const bottom = (values[2]) / 100 * this.block.height;
571
- const left = values[3] / 100 * this.block.width;
572
- const clipPath = `inset(${top}${this.unit} ${right}${this.unit} ${bottom}${this.unit} ${left}${this.unit})`;
573
- return clipPath;
574
- }
575
- get styleBoxShadow() {
576
- if (!this.block.shadowColor) {
577
- return null;
578
- }
579
- const shadow = `${this.block.shadowX}pt ${(this.block.shadowY || 0)}pt ${(this.block.shadowBlur || 0)}pt ${(this.block.shadowSpread || 0)}pt ${this.block.shadowColor}`;
580
- return shadow;
581
- }
582
- set elementGuidelines(value) {
583
- this.moveable.elementGuidelines = value;
584
- }
585
- set editable(value) {
586
- this._editable = value;
587
- if (!value) {
588
- this.deselectContent();
589
- }
590
- }
591
- get clippable() {
592
- return !!this.moveable.clippable;
593
- }
594
- set clippable(value) {
595
- this.moveable.clippable = value;
596
- if (this.selected) {
597
- this.moveable.resizable = !value;
598
- this.moveable.rotatable = !value;
599
- this.moveable.scalable = !value;
600
- }
601
- }
602
- get transformable() {
603
- return this._transformable;
604
- }
605
- set transformable(value) {
606
- if (this.block.lock) {
607
- value = false;
608
- }
609
- this._transformable = value;
610
- this.moveable.resizable = value;
611
- this.moveable.rotatable = value;
612
- this.moveable.scalable = value;
613
- }
614
- set rotate(value) {
615
- this.moveable.request('rotatable', { rotate: parseFloat(value) }, true);
616
- this.moveable.updateRect();
617
- }
618
- set index(value) {
619
- this.block.index = value;
620
- }
621
- set keepRatio(value) {
622
- this.moveable.keepRatio = value;
623
- }
624
- markForCheck() {
625
- this._cdRef.markForCheck();
626
- }
627
- ngOnInit() {
628
- this.unit = this._blockEditor.config.unit;
629
- this.content = this.block.content;
630
- this.block.shadowOpacity = this.block.shadowOpacity || 100;
631
- this._initFonts();
632
- this._blockEditor.selectedBlocks$
633
- .pipe(takeUntil(this._destroy$))
634
- .subscribe((blocks) => {
635
- this.selected = blocks.includes(this.block);
636
- this._cdRef.markForCheck();
637
- });
638
- this._blockEditor.blockClippable$
639
- .pipe(filter(() => this.selected), takeUntil(this._destroy$))
640
- .subscribe((clippable) => {
641
- this.clippable = clippable;
642
- this._cdRef.markForCheck();
643
- });
644
- this._blockEditor.blockAdded$
645
- .pipe(takeUntil(this._destroy$))
646
- .subscribe(() => {
647
- this._cdRef.markForCheck();
648
- });
649
- this._blockEditor.blockChanged$
650
- .pipe(filter((block) => block === this.block), takeUntil(this._destroy$))
651
- .subscribe((block) => {
652
- this.keepRatio = block.keepRatio;
653
- this.rotate = this.block.rotate;
654
- this._updateMoveable();
655
- this._cdRef.markForCheck();
656
- });
657
- }
658
- ngAfterContentInit() {
659
- setTimeout(() => {
660
- this._initEvents();
661
- this._initMoveable();
662
- this._setTransform();
663
- this.rotate = this.block.rotate;
664
- this._blockEditor.initBlock(this.block, this);
665
- this._blockEditor.blockInited$
666
- .pipe(takeUntil(this._destroy$))
667
- .subscribe(() => {
668
- this._updateElementGuidelines();
669
- });
670
- });
671
- }
672
- pxToIn(px) {
673
- return this.round(px / 96, 2);
674
- }
675
- round(value, decimals) {
676
- return parseFloat(value.toFixed(decimals));
677
- }
678
- select() {
679
- this.transformable = true;
680
- }
681
- deselect() {
682
- this.editable = false;
683
- this.clippable = false;
684
- this.transformable = false;
685
- this.disableContentEdit();
686
- }
687
- disableContentEdit() {
688
- this.editable = false;
689
- }
690
- deselectContent() {
691
- if (window.getSelection) {
692
- if (window.getSelection().empty) {
693
- window.getSelection().empty();
694
- }
695
- else if (window.getSelection().removeAllRanges) {
696
- window.getSelection().removeAllRanges();
697
- }
698
- }
699
- }
700
- selectAll() {
701
- const range = document.createRange();
702
- range.selectNodeContents(this.contentEditable.nativeElement);
703
- const sel = window.getSelection();
704
- sel.removeAllRanges();
705
- sel.addRange(range);
706
- }
707
- ngOnDestroy() {
708
- this._blockEditor.destroyBlock(this.block);
709
- this._destroy$.next();
710
- this._destroy$.complete();
711
- }
712
- _setTransform(transforms = []) {
713
- transforms = transforms !== null && transforms !== void 0 ? transforms : [];
714
- this.el.style.transform = transforms.join(' ');
715
- }
716
- _triggerChanged() {
717
- this._blockEditor.blockChange(this.block);
718
- }
719
- _updateElementGuidelines() {
720
- this.moveable.elementGuidelines = this._blockEditor.blockComponents
721
- .map((blockComponent) => blockComponent.el)
722
- .filter((el) => !el.isSameNode(this.el));
723
- }
724
- _updateMoveable() {
725
- this._moveable.draggable = !this.block.lock;
726
- if (this.selected) {
727
- this._moveable.resizable = !this.block.lock;
728
- this._moveable.rotatable = !this.block.lock;
729
- }
730
- }
731
- _initMoveable() {
732
- this._moveable = new Moveable(this._elementRef.nativeElement, {
733
- target: this.el,
734
- container: this._blockEditor.container,
735
- draggable: true,
736
- resizable: false,
737
- scalable: false,
738
- rotatable: false,
739
- warpable: false,
740
- origin: false,
741
- clipRelative: true,
742
- clipArea: true,
743
- keepRatio: this.block.keepRatio,
744
- snappable: true,
745
- snapDirections: { left: true, top: true, right: true, bottom: true, center: true, middle: true },
746
- elementSnapDirections: { left: true, top: true, right: true, bottom: true, center: true, middle: true },
747
- edge: false,
748
- throttleDrag: 1,
749
- throttleScale: 0.01,
750
- throttleRotate: 1,
751
- throttleResize: 1,
752
- snapDistFormat: (v, type) => `${this.round(v / 96, 2)}`,
753
- });
754
- this._updateElementGuidelines();
755
- this._updateMoveable();
756
- this.moveable
757
- .on('clip', (e) => {
758
- this.moveable.keepRatio = false;
759
- e.target.style.clipPath = e.clipStyle;
760
- this.block.clipPath = {
761
- type: 'inset',
762
- values: e.clipStyles
763
- .map((value) => {
764
- const number = Number(value.replace('%', ''));
765
- return number > 0 ? number : 0;
766
- }),
767
- };
768
- })
769
- .on('clipEnd', (e) => {
770
- this.moveable.keepRatio = true;
771
- e.target.style.clipPath = null;
772
- this._triggerChanged();
773
- setTimeout(() => {
774
- this.moveable.updateRect();
775
- }, 100);
776
- })
777
- .on('dragStart', () => {
778
- this.disableContentEdit();
779
- this.transformating = true;
780
- this._cdRef.markForCheck();
781
- })
782
- .on('drag', ({ target, left, top }) => {
783
- target.style.left = this.pxToIn(left) + this.unit;
784
- target.style.top = this.pxToIn(top) + this.unit;
785
- this.block.top = this.pxToIn(top);
786
- this.block.left = this.pxToIn(left);
787
- })
788
- .on('dragEnd', () => {
789
- this.transformating = false;
790
- this._triggerChanged();
791
- this._cdRef.markForCheck();
792
- })
793
- .on('resizeStart', () => {
794
- this.disableContentEdit();
795
- this.zoompan.disable();
796
- this.transformating = true;
797
- this._cdRef.markForCheck();
798
- })
799
- .on('resize', ({ target, width, height, dist, delta, direction }) => {
800
- width = this.pxToIn(width);
801
- height = this.pxToIn(height);
802
- if (delta[0]) {
803
- this.block.width = width;
804
- target.style.width = width + this.unit;
805
- }
806
- if (delta[1]) {
807
- this.block.height = height;
808
- target.style.height = height + this.unit;
809
- }
810
- const transform = [0, 0];
811
- if (direction[1] === -1) {
812
- transform[1] = dist[1] * -1;
813
- }
814
- if (direction[0] === -1) {
815
- transform[0] = dist[0] * -1;
816
- }
817
- this._setTransform([`translate(${transform[0]}px, ${transform[1]}px)`]);
818
- })
819
- .on('resizeEnd', ({ target }) => {
820
- const matrix = new WebKitCSSMatrix(target.style.transform);
821
- this.block.top = parseFloat(target.style.top) + this.pxToIn(matrix.m42);
822
- this.block.left = parseFloat(target.style.left) + this.pxToIn(matrix.m41);
823
- this._setTransform();
824
- this._triggerChanged();
825
- this.zoompan.enable();
826
- this.transformating = false;
827
- this._cdRef.markForCheck();
828
- target.style.top = `${this.block.top}in`;
829
- target.style.left = `${this.block.left}in`;
830
- target.style.width = `${this.block.width}in`;
831
- target.style.height = `${this.block.height}in`;
832
- this.moveable.updateRect();
833
- })
834
- .on('rotateStart', ({ inputEvent }) => {
835
- if (inputEvent) {
836
- this.zoompan.disable();
837
- this.disableContentEdit();
838
- this.transformating = true;
839
- this._cdRef.markForCheck();
840
- }
841
- })
842
- .on('rotate', ({ inputEvent, transform, rotation }) => {
843
- this.el.style.transform = transform;
844
- this.block.rotate = rotation % 360;
845
- if (inputEvent) {
846
- this.zoompan.enable();
847
- }
848
- })
849
- .on('rotateEnd', ({ inputEvent }) => {
850
- if (inputEvent) {
851
- this.transformating = false;
852
- this._cdRef.markForCheck();
853
- this._triggerChanged();
854
- }
855
- });
856
- }
857
- _initEvents() {
858
- fromEvent(this.contentEditable.nativeElement, 'paste')
859
- .pipe(takeUntil(this._destroy$))
860
- .subscribe((e) => {
861
- e.preventDefault();
862
- const clipboardData = e.clipboardData;
863
- const text = clipboardData.getData('Text');
864
- ;
865
- const range = document.getSelection().getRangeAt(0);
866
- range.deleteContents();
867
- const textNode = document.createTextNode(text);
868
- range.insertNode(textNode);
869
- range.selectNodeContents(textNode);
870
- range.collapse(false);
871
- const selection = window.getSelection();
872
- selection.removeAllRanges();
873
- selection.addRange(range);
874
- this.block.content = this.contentEditable.nativeElement.innerHTML;
875
- this._triggerChanged();
876
- });
877
- fromEvent(this.contentEditable.nativeElement, 'input')
878
- .pipe(takeUntil(this._destroy$)).subscribe((event) => {
879
- this.block.content = event.target.innerHTML;
880
- this._triggerChanged();
881
- });
882
- fromEvent(this.el, 'mousedown')
883
- .pipe(takeUntil(this._destroy$)).subscribe((event) => {
884
- if (!this.block.lock) {
885
- this.zoompan.disable();
886
- }
887
- if (!this.moveable.clippable) {
888
- if (this.editable) {
889
- if (this.contentElement.nativeElement.isSameNode(event.target)) {
890
- event.preventDefault();
891
- event.stopImmediatePropagation();
892
- event.stopPropagation();
893
- }
894
- }
895
- else {
896
- this._blockEditor.selectedBlock = this.block;
897
- }
898
- }
899
- });
900
- fromEvent(this.el, 'mouseup')
901
- .pipe(takeUntil(this._destroy$)).subscribe(() => {
902
- this.zoompan.enable();
903
- });
904
- fromEvent(this.el, 'dblclick')
905
- .pipe(filter(() => (!this.editable)), takeUntil(this._destroy$))
906
- .subscribe((event) => {
907
- if (this.block.readonly) {
908
- event.preventDefault();
909
- }
910
- else {
911
- this.editable = true;
912
- this._cdRef.markForCheck();
913
- setTimeout(() => {
914
- this.selectAll();
915
- });
916
- }
917
- });
918
- }
919
- _initFonts() {
920
- if (this.block.fontFamily) {
921
- this._googleFontService.loadFont({ family: this.block.fontFamily });
922
- }
923
- }
924
- }
925
- 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: GoogleFontService }], target: i0.ɵɵFactoryTarget.Component });
926
- 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: { 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 [ngSwitch]=\"block.type\">\n <ng-container *ngIf=\"block.imageUrl\">\n <img \n [style.opacity]=\"block.imageOpacity ? block.imageOpacity/100 : 1\"\n [src]=\"block.imageUrl\">\n </ng-container>\n </ng-container>\n <ng-container *ngIf=\"block.type === BlockType.LongText || block.type === BlockType.ShortText || block.type === BlockType.RadioButton || block.type === BlockType.Checkbox || block.type === BlockType.Date\">\n {{block.label || block.name}}\n </ng-container>\n <div\n #contentEditable\n [contentEditable]=\"editable\"\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;margin:-1px}.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}.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: i13.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i13.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i13.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
927
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockComponent, decorators: [{
928
- type: Component,
929
- args: [{
930
- selector: 'fs-block',
931
- templateUrl: 'block.component.html',
932
- styleUrls: ['block.component.scss'],
933
- changeDetection: ChangeDetectionStrategy.OnPush,
934
- }]
935
- }], ctorParameters: function () { return [{ type: BlockEditorService }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: GoogleFontService }]; }, propDecorators: { element: [{
936
- type: ViewChild,
937
- args: ['element', { static: true }]
938
- }], contentElement: [{
939
- type: ViewChild,
940
- args: ['contentElement', { static: true }]
941
- }], contentEditable: [{
942
- type: ViewChild,
943
- args: ['contentEditable', { static: true }]
944
- }], block: [{
945
- type: Input
946
- }], html: [{
947
- type: Input
948
- }], zoompan: [{
949
- type: Input
950
- }], transformating: [{
951
- type: HostBinding,
952
- args: ['class.transforming']
530
+ class FsBlockComponent {
531
+ constructor(_blockEditor, _elementRef, _cdRef, _googleFontService) {
532
+ this._blockEditor = _blockEditor;
533
+ this._elementRef = _elementRef;
534
+ this._cdRef = _cdRef;
535
+ this._googleFontService = _googleFontService;
536
+ this.transformating = false;
537
+ this.BlockType = BlockType;
538
+ this._editable = false;
539
+ this._transformable = false;
540
+ this._destroy$ = new Subject();
541
+ }
542
+ get el() {
543
+ return this.element.nativeElement;
544
+ }
545
+ get moveable() {
546
+ return this._moveable;
547
+ }
548
+ get editable() {
549
+ return this._editable;
550
+ }
551
+ get styleTop() {
552
+ let top = this.block.top;
553
+ return `${top}${this.unit}`;
554
+ }
555
+ get styleLeft() {
556
+ let left = this.block.left;
557
+ return `${left}${this.unit}`;
558
+ }
559
+ get styleWidth() {
560
+ let width = this.block.width;
561
+ if (this.block.clipPath) {
562
+ width -= (this.block.width * this.block.clipPath.values[1] / 100) + (this.block.width * this.block.clipPath.values[3] / 100);
563
+ }
564
+ return `${width}${this.unit}`;
565
+ }
566
+ get styleHeight() {
567
+ let height = this.block.height;
568
+ if (this.block.clipPath) {
569
+ height -= (this.block.height * this.block.clipPath.values[0] / 100) + (this.block.height * this.block.clipPath.values[2] / 100);
570
+ }
571
+ return `${height}${this.unit}`;
572
+ }
573
+ get styleImageHeight() {
574
+ let height = this.block.height;
575
+ if (this.block.clipPath) {
576
+ const values = this.block.clipPath.values || {};
577
+ //height += (values[0]/100 * height) + (values[2]/100 * height);
578
+ }
579
+ return `${height}${this.unit}`;
580
+ }
581
+ get styleImageWidth() {
582
+ let width = this.block.width;
583
+ if (this.block.clipPath) {
584
+ const values = this.block.clipPath.values || {};
585
+ //width += (values[1]/100 * width) + (values[3]/100 * width);
586
+ }
587
+ return `${width}${this.unit}`;
588
+ }
589
+ get styleImageTop() {
590
+ let top = 0;
591
+ if (this.block.clipPath) {
592
+ const values = this.block.clipPath.values || {};
593
+ top = (values[0] / 100) * this.block.width * -1;
594
+ }
595
+ return `${top}${this.unit}`;
596
+ }
597
+ get styleImageLeft() {
598
+ let left = 0;
599
+ if (this.block.clipPath) {
600
+ const values = this.block.clipPath.values || {};
601
+ left = (values[3] / 100) * this.block.width * -1;
602
+ }
603
+ return `${left}${this.unit}`;
604
+ }
605
+ get styleClipPath() {
606
+ if (!this.block.clipPath) {
607
+ return null;
608
+ }
609
+ const values = this.block.clipPath.values || {};
610
+ const top = values[0] / 100 * this.block.height;
611
+ const right = (values[1]) / 100 * this.block.width;
612
+ const bottom = (values[2]) / 100 * this.block.height;
613
+ const left = values[3] / 100 * this.block.width;
614
+ const clipPath = `inset(${top}${this.unit} ${right}${this.unit} ${bottom}${this.unit} ${left}${this.unit})`;
615
+ return clipPath;
616
+ }
617
+ get styleBoxShadow() {
618
+ if (!this.block.shadowColor) {
619
+ return null;
620
+ }
621
+ const shadow = `${this.block.shadowX}pt ${(this.block.shadowY || 0)}pt ${(this.block.shadowBlur || 0)}pt ${(this.block.shadowSpread || 0)}pt ${this.block.shadowColor}`;
622
+ return shadow;
623
+ }
624
+ set elementGuidelines(value) {
625
+ this.moveable.elementGuidelines = value;
626
+ }
627
+ set editable(value) {
628
+ this._editable = value;
629
+ if (!value) {
630
+ this.deselectContent();
631
+ }
632
+ }
633
+ get clippable() {
634
+ return !!this.moveable.clippable;
635
+ }
636
+ set clippable(value) {
637
+ this.moveable.clippable = value;
638
+ if (this.selected) {
639
+ this.moveable.resizable = !value;
640
+ this.moveable.rotatable = !value;
641
+ this.moveable.scalable = !value;
642
+ }
643
+ }
644
+ get transformable() {
645
+ return this._transformable;
646
+ }
647
+ set transformable(value) {
648
+ if (this.block.lock) {
649
+ value = false;
650
+ }
651
+ this._transformable = value;
652
+ this.moveable.resizable = value;
653
+ this.moveable.rotatable = value;
654
+ this.moveable.scalable = value;
655
+ }
656
+ set rotate(value) {
657
+ this.moveable.request('rotatable', { rotate: parseFloat(value) }, true);
658
+ this.moveable.updateRect();
659
+ }
660
+ set index(value) {
661
+ this.block.index = value;
662
+ }
663
+ set keepRatio(value) {
664
+ this.moveable.keepRatio = value;
665
+ }
666
+ markForCheck() {
667
+ this._cdRef.markForCheck();
668
+ }
669
+ ngOnInit() {
670
+ this.unit = this._blockEditor.config.unit;
671
+ this.content = this.block.content;
672
+ this.block.shadowOpacity = this.block.shadowOpacity || 100;
673
+ this._initFonts();
674
+ this._blockEditor.selectedBlocks$
675
+ .pipe(takeUntil(this._destroy$))
676
+ .subscribe((blocks) => {
677
+ this.selected = blocks.includes(this.block);
678
+ this._cdRef.markForCheck();
679
+ });
680
+ this._blockEditor.blockClippable$
681
+ .pipe(filter(() => this.selected), takeUntil(this._destroy$))
682
+ .subscribe((clippable) => {
683
+ this.clippable = clippable;
684
+ this._cdRef.markForCheck();
685
+ });
686
+ this._blockEditor.blockAdded$
687
+ .pipe(takeUntil(this._destroy$))
688
+ .subscribe(() => {
689
+ this._cdRef.markForCheck();
690
+ });
691
+ this._blockEditor.blockChanged$
692
+ .pipe(filter((block) => block === this.block), takeUntil(this._destroy$))
693
+ .subscribe((block) => {
694
+ this.keepRatio = block.keepRatio;
695
+ this.rotate = this.block.rotate;
696
+ this._updateMoveable();
697
+ this._cdRef.markForCheck();
698
+ });
699
+ }
700
+ ngAfterContentInit() {
701
+ setTimeout(() => {
702
+ this._initEvents();
703
+ this._initMoveable();
704
+ this._setTransform();
705
+ this.rotate = this.block.rotate;
706
+ this._blockEditor.initBlock(this.block, this);
707
+ this._blockEditor.blockInited$
708
+ .pipe(takeUntil(this._destroy$))
709
+ .subscribe(() => {
710
+ this._updateElementGuidelines();
711
+ });
712
+ });
713
+ }
714
+ pxToIn(px) {
715
+ return this.round(px / 96, 2);
716
+ }
717
+ round(value, decimals) {
718
+ return parseFloat(value.toFixed(decimals));
719
+ }
720
+ select() {
721
+ this.transformable = true;
722
+ }
723
+ deselect() {
724
+ this.editable = false;
725
+ this.clippable = false;
726
+ this.transformable = false;
727
+ this.disableContentEdit();
728
+ }
729
+ disableContentEdit() {
730
+ this.editable = false;
731
+ }
732
+ deselectContent() {
733
+ if (window.getSelection) {
734
+ if (window.getSelection().empty) {
735
+ window.getSelection().empty();
736
+ }
737
+ else if (window.getSelection().removeAllRanges) {
738
+ window.getSelection().removeAllRanges();
739
+ }
740
+ }
741
+ }
742
+ selectAll() {
743
+ const range = document.createRange();
744
+ range.selectNodeContents(this.contentEditable.nativeElement);
745
+ const sel = window.getSelection();
746
+ sel.removeAllRanges();
747
+ sel.addRange(range);
748
+ }
749
+ ngOnDestroy() {
750
+ this._blockEditor.destroyBlock(this.block);
751
+ this._destroy$.next();
752
+ this._destroy$.complete();
753
+ }
754
+ _setTransform(transforms = []) {
755
+ transforms = transforms !== null && transforms !== void 0 ? transforms : [];
756
+ this.el.style.transform = transforms.join(' ');
757
+ }
758
+ _triggerChanged() {
759
+ this._blockEditor.blockChange(this.block);
760
+ }
761
+ _updateElementGuidelines() {
762
+ this.moveable.elementGuidelines = this._blockEditor.blockComponents
763
+ .map((blockComponent) => blockComponent.el)
764
+ .filter((el) => !el.isSameNode(this.el));
765
+ }
766
+ _updateMoveable() {
767
+ this._moveable.draggable = !this.block.lock;
768
+ if (this.selected) {
769
+ this._moveable.resizable = !this.block.lock;
770
+ this._moveable.rotatable = !this.block.lock;
771
+ }
772
+ }
773
+ _initMoveable() {
774
+ this._moveable = new Moveable(this._elementRef.nativeElement, {
775
+ target: this.el,
776
+ container: this._blockEditor.container,
777
+ draggable: true,
778
+ resizable: false,
779
+ scalable: false,
780
+ rotatable: false,
781
+ warpable: false,
782
+ origin: false,
783
+ clipRelative: true,
784
+ clipArea: true,
785
+ keepRatio: this.block.keepRatio,
786
+ snappable: true,
787
+ snapDirections: { left: true, top: true, right: true, bottom: true, center: true, middle: true },
788
+ elementSnapDirections: { left: true, top: true, right: true, bottom: true, center: true, middle: true },
789
+ edge: false,
790
+ throttleDrag: 1,
791
+ throttleScale: 0.01,
792
+ throttleRotate: 1,
793
+ throttleResize: 1,
794
+ snapDistFormat: (v, type) => `${this.round(v / 96, 2)}`,
795
+ });
796
+ this._updateElementGuidelines();
797
+ this._updateMoveable();
798
+ this.moveable
799
+ .on('clip', (e) => {
800
+ this.moveable.keepRatio = false;
801
+ e.target.style.clipPath = e.clipStyle;
802
+ this.block.clipPath = {
803
+ type: 'inset',
804
+ values: e.clipStyles
805
+ .map((value) => {
806
+ const number = Number(value.replace('%', ''));
807
+ return number > 0 ? number : 0;
808
+ }),
809
+ };
810
+ })
811
+ .on('clipEnd', (e) => {
812
+ this.moveable.keepRatio = true;
813
+ e.target.style.clipPath = null;
814
+ this._triggerChanged();
815
+ setTimeout(() => {
816
+ this.moveable.updateRect();
817
+ }, 100);
818
+ })
819
+ .on('dragStart', () => {
820
+ this.disableContentEdit();
821
+ this.transformating = true;
822
+ this._cdRef.markForCheck();
823
+ })
824
+ .on('drag', ({ target, left, top }) => {
825
+ target.style.left = this.pxToIn(left) + this.unit;
826
+ target.style.top = this.pxToIn(top) + this.unit;
827
+ this.block.top = this.pxToIn(top);
828
+ this.block.left = this.pxToIn(left);
829
+ })
830
+ .on('dragEnd', () => {
831
+ this.transformating = false;
832
+ this._triggerChanged();
833
+ this._cdRef.markForCheck();
834
+ })
835
+ .on('resizeStart', () => {
836
+ this.disableContentEdit();
837
+ this.zoompan.disable();
838
+ this.transformating = true;
839
+ this._cdRef.markForCheck();
840
+ })
841
+ .on('resize', ({ target, width, height, dist, delta, direction }) => {
842
+ width = this.pxToIn(width);
843
+ height = this.pxToIn(height);
844
+ if (delta[0]) {
845
+ this.block.width = width;
846
+ target.style.width = width + this.unit;
847
+ }
848
+ if (delta[1]) {
849
+ this.block.height = height;
850
+ target.style.height = height + this.unit;
851
+ }
852
+ const transform = [0, 0];
853
+ if (direction[1] === -1) {
854
+ transform[1] = dist[1] * -1;
855
+ }
856
+ if (direction[0] === -1) {
857
+ transform[0] = dist[0] * -1;
858
+ }
859
+ this._setTransform([`translate(${transform[0]}px, ${transform[1]}px)`]);
860
+ })
861
+ .on('resizeEnd', ({ target }) => {
862
+ const matrix = new WebKitCSSMatrix(target.style.transform);
863
+ this.block.top = parseFloat(target.style.top) + this.pxToIn(matrix.m42);
864
+ this.block.left = parseFloat(target.style.left) + this.pxToIn(matrix.m41);
865
+ this._setTransform();
866
+ this._triggerChanged();
867
+ this.zoompan.enable();
868
+ this.transformating = false;
869
+ this._cdRef.markForCheck();
870
+ target.style.top = `${this.block.top}in`;
871
+ target.style.left = `${this.block.left}in`;
872
+ target.style.width = `${this.block.width}in`;
873
+ target.style.height = `${this.block.height}in`;
874
+ this.moveable.updateRect();
875
+ })
876
+ .on('rotateStart', ({ inputEvent }) => {
877
+ if (inputEvent) {
878
+ this.zoompan.disable();
879
+ this.disableContentEdit();
880
+ this.transformating = true;
881
+ this._cdRef.markForCheck();
882
+ }
883
+ })
884
+ .on('rotate', ({ inputEvent, transform, rotation }) => {
885
+ this.el.style.transform = transform;
886
+ this.block.rotate = rotation % 360;
887
+ if (inputEvent) {
888
+ this.zoompan.enable();
889
+ }
890
+ })
891
+ .on('rotateEnd', ({ inputEvent }) => {
892
+ if (inputEvent) {
893
+ this.transformating = false;
894
+ this._cdRef.markForCheck();
895
+ this._triggerChanged();
896
+ }
897
+ });
898
+ }
899
+ _initEvents() {
900
+ fromEvent(this.contentEditable.nativeElement, 'paste')
901
+ .pipe(takeUntil(this._destroy$))
902
+ .subscribe((e) => {
903
+ e.preventDefault();
904
+ const clipboardData = e.clipboardData;
905
+ const text = clipboardData.getData('Text');
906
+ ;
907
+ const range = document.getSelection().getRangeAt(0);
908
+ range.deleteContents();
909
+ const textNode = document.createTextNode(text);
910
+ range.insertNode(textNode);
911
+ range.selectNodeContents(textNode);
912
+ range.collapse(false);
913
+ const selection = window.getSelection();
914
+ selection.removeAllRanges();
915
+ selection.addRange(range);
916
+ this.block.content = this.contentEditable.nativeElement.innerHTML;
917
+ this._triggerChanged();
918
+ });
919
+ fromEvent(this.contentEditable.nativeElement, 'input')
920
+ .pipe(takeUntil(this._destroy$)).subscribe((event) => {
921
+ this.block.content = event.target.innerHTML;
922
+ this._triggerChanged();
923
+ });
924
+ fromEvent(this.el, 'mousedown')
925
+ .pipe(takeUntil(this._destroy$)).subscribe((event) => {
926
+ if (!this.block.lock) {
927
+ this.zoompan.disable();
928
+ }
929
+ if (!this.moveable.clippable) {
930
+ if (this.editable) {
931
+ if (this.contentElement.nativeElement.isSameNode(event.target)) {
932
+ event.preventDefault();
933
+ event.stopImmediatePropagation();
934
+ event.stopPropagation();
935
+ }
936
+ }
937
+ else {
938
+ this._blockEditor.selectedBlock = this.block;
939
+ }
940
+ }
941
+ });
942
+ fromEvent(this.el, 'mouseup')
943
+ .pipe(takeUntil(this._destroy$)).subscribe(() => {
944
+ this.zoompan.enable();
945
+ });
946
+ fromEvent(this.el, 'dblclick')
947
+ .pipe(filter(() => (!this.editable)), takeUntil(this._destroy$))
948
+ .subscribe((event) => {
949
+ if (this.block.readonly) {
950
+ event.preventDefault();
951
+ }
952
+ else {
953
+ this.editable = true;
954
+ this._cdRef.markForCheck();
955
+ setTimeout(() => {
956
+ this.selectAll();
957
+ });
958
+ }
959
+ });
960
+ }
961
+ _initFonts() {
962
+ if (this.block.fontFamily) {
963
+ this._googleFontService.loadFont({ family: this.block.fontFamily });
964
+ }
965
+ }
966
+ }
967
+ 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: GoogleFontService }], target: i0.ɵɵFactoryTarget.Component });
968
+ 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: { 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 [ngSwitch]=\"block.type\">\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\n </ng-container>\n <ng-container *ngIf=\"block.type === BlockType.LongText || block.type === BlockType.ShortText || block.type === BlockType.RadioButton || block.type === BlockType.Checkbox || block.type === BlockType.Date\">\n {{block.label || block.name}}\n </ng-container>\n <div\n #contentEditable\n [contentEditable]=\"editable\"\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;margin:-1px}.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}.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: i13.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i13.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i13.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i13.AsyncPipe, "createImageUrl": CreateImageUrlPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
969
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockComponent, decorators: [{
970
+ type: Component,
971
+ args: [{
972
+ selector: 'fs-block',
973
+ templateUrl: 'block.component.html',
974
+ styleUrls: ['block.component.scss'],
975
+ changeDetection: ChangeDetectionStrategy.OnPush,
976
+ }]
977
+ }], ctorParameters: function () { return [{ type: BlockEditorService }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: GoogleFontService }]; }, propDecorators: { element: [{
978
+ type: ViewChild,
979
+ args: ['element', { static: true }]
980
+ }], contentElement: [{
981
+ type: ViewChild,
982
+ args: ['contentElement', { static: true }]
983
+ }], contentEditable: [{
984
+ type: ViewChild,
985
+ args: ['contentEditable', { static: true }]
986
+ }], block: [{
987
+ type: Input
988
+ }], html: [{
989
+ type: Input
990
+ }], zoompan: [{
991
+ type: Input
992
+ }], transformating: [{
993
+ type: HostBinding,
994
+ args: ['class.transforming']
953
995
  }] } });
954
996
 
955
- class FsBlockEditorSidebarPanelDirective {
956
- constructor(templateRef) {
957
- this.templateRef = templateRef;
958
- this.show = true;
959
- }
960
- }
961
- FsBlockEditorSidebarPanelDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorSidebarPanelDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
962
- FsBlockEditorSidebarPanelDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorSidebarPanelDirective, selector: "[fsBlockEditorSidebarPanel]", inputs: { label: "label", show: "show" }, ngImport: i0 });
963
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorSidebarPanelDirective, decorators: [{
964
- type: Directive,
965
- args: [{
966
- selector: '[fsBlockEditorSidebarPanel]'
967
- }]
968
- }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; }, propDecorators: { label: [{
969
- type: Input
970
- }], show: [{
971
- type: Input
997
+ class FsBlockEditorSidebarPanelDirective {
998
+ constructor(templateRef) {
999
+ this.templateRef = templateRef;
1000
+ this.show = true;
1001
+ }
1002
+ }
1003
+ FsBlockEditorSidebarPanelDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorSidebarPanelDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
1004
+ FsBlockEditorSidebarPanelDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorSidebarPanelDirective, selector: "[fsBlockEditorSidebarPanel]", inputs: { label: "label", show: "show" }, ngImport: i0 });
1005
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorSidebarPanelDirective, decorators: [{
1006
+ type: Directive,
1007
+ args: [{
1008
+ selector: '[fsBlockEditorSidebarPanel]'
1009
+ }]
1010
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; }, propDecorators: { label: [{
1011
+ type: Input
1012
+ }], show: [{
1013
+ type: Input
972
1014
  }] } });
973
1015
 
974
- class FsBlockEditorMarginDirective {
975
- constructor(_elementRef) {
976
- this._elementRef = _elementRef;
977
- }
978
- get element() {
979
- return this._elementRef.nativeElement;
980
- }
981
- }
982
- FsBlockEditorMarginDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorMarginDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
983
- FsBlockEditorMarginDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorMarginDirective, selector: "[fsBlockEditorMargin]", ngImport: i0 });
984
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorMarginDirective, decorators: [{
985
- type: Directive,
986
- args: [{
987
- selector: '[fsBlockEditorMargin]'
988
- }]
1016
+ class FsBlockEditorMarginDirective {
1017
+ constructor(_elementRef) {
1018
+ this._elementRef = _elementRef;
1019
+ }
1020
+ get element() {
1021
+ return this._elementRef.nativeElement;
1022
+ }
1023
+ }
1024
+ FsBlockEditorMarginDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorMarginDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
1025
+ FsBlockEditorMarginDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorMarginDirective, selector: "[fsBlockEditorMargin]", ngImport: i0 });
1026
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorMarginDirective, decorators: [{
1027
+ type: Directive,
1028
+ args: [{
1029
+ selector: '[fsBlockEditorMargin]'
1030
+ }]
989
1031
  }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
990
1032
 
991
- const BlockFormats = [
992
- { value: BlockFormat.Number, name: 'Number', blockTypes: [BlockType.ShortText, BlockType.LongText] },
993
- { value: BlockFormat.Currency, name: 'Currency', blockTypes: [BlockType.ShortText, BlockType.LongText] },
994
- { value: BlockFormat.Date, name: 'Date', blockTypes: [BlockType.Date] },
995
- { value: BlockFormat.YYYYMMDD, name: 'YYYY/MM/DD', blockTypes: [BlockType.Date] },
1033
+ const BlockFormats = [
1034
+ { value: BlockFormat.Number, name: 'Number', blockTypes: [BlockType.ShortText, BlockType.LongText] },
1035
+ { value: BlockFormat.Currency, name: 'Currency', blockTypes: [BlockType.ShortText, BlockType.LongText] },
1036
+ { value: BlockFormat.Date, name: 'Date', blockTypes: [BlockType.Date] },
1037
+ { value: BlockFormat.YYYYMMDD, name: 'YYYY/MM/DD', blockTypes: [BlockType.Date] },
996
1038
  ];
997
1039
 
998
- class FontComponent {
999
- constructor(_el, _googleFontService) {
1000
- this._el = _el;
1001
- this._googleFontService = _googleFontService;
1002
- }
1003
- ngOnInit() {
1004
- var observer = new IntersectionObserver((entries) => {
1005
- if (entries[0].isIntersecting === true) {
1006
- this._googleFontService.loadFont(this.font);
1007
- }
1008
- }, { threshold: [0] });
1009
- observer.observe(this._el.nativeElement);
1010
- }
1011
- }
1012
- FontComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FontComponent, deps: [{ token: i0.ElementRef }, { token: GoogleFontService }], target: i0.ɵɵFactoryTarget.Component });
1013
- FontComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FontComponent, selector: "app-font", inputs: { font: "font" }, ngImport: i0, template: "<div\n [style.fontFamily]=\"font.family\">\n {{font.family}}\n</div>\n", styles: [""], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1014
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FontComponent, decorators: [{
1015
- type: Component,
1016
- args: [{
1017
- selector: 'app-font',
1018
- templateUrl: 'font.component.html',
1019
- styleUrls: ['font.component.scss'],
1020
- changeDetection: ChangeDetectionStrategy.OnPush,
1021
- }]
1022
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: GoogleFontService }]; }, propDecorators: { font: [{
1023
- type: Input
1024
- }] } });
1025
-
1026
- class SidebarComponent {
1027
- constructor(_el, _blockEditor, _cdRef, _prompt, _googleFontService, _document) {
1028
- this._el = _el;
1029
- this._blockEditor = _blockEditor;
1030
- this._cdRef = _cdRef;
1031
- this._prompt = _prompt;
1032
- this._googleFontService = _googleFontService;
1033
- this._document = _document;
1034
- this.zoomCenter = new EventEmitter();
1035
- this.BlockTypes = BlockTypes;
1036
- this.blockTypeNames = index(BlockTypes, 'value', 'name');
1037
- this.blockTypeIcons = index(BlockTypes, 'value', 'icon');
1038
- this.clippable = false;
1039
- this.BlockType = BlockType;
1040
- this.formats = [];
1041
- this._destroy$ = new Subject();
1042
- this.fontFetch = (value) => {
1043
- return this._googleFontService.getItems();
1044
- };
1045
- this.fontDisplayWith = (value) => {
1046
- return value === null || value === void 0 ? void 0 : value.family;
1047
- };
1048
- }
1049
- get el() {
1050
- return this._el.nativeElement;
1051
- }
1052
- ngOnInit() {
1053
- this._blockEditor.selectedBlocks$
1054
- .pipe(takeUntil(this._destroy$))
1055
- .subscribe((blocks) => {
1056
- this.block = blocks[0] ? blocks[0] : null;
1057
- this.formats = BlockFormats
1058
- .filter((blockFormat) => { var _a; return (blockFormat.blockTypes.indexOf((_a = this.block) === null || _a === void 0 ? void 0 : _a.type) !== -1); });
1059
- this._cdRef.markForCheck();
1060
- });
1061
- this._blockEditor.blockChanged$
1062
- .pipe(filter((block) => block === this.block), takeUntil(this._destroy$))
1063
- .subscribe(() => {
1064
- this._cdRef.markForCheck();
1065
- });
1066
- }
1067
- fontChanged(font) {
1068
- this._blockEditor.selectedBlockComponentChangeProperty(font === null || font === void 0 ? void 0 : font.family, 'fontFamily');
1069
- }
1070
- verticalAlignClick(value) {
1071
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'verticalAlign');
1072
- }
1073
- boldClick() {
1074
- this._blockEditor.selectedBlockComponentChangeProperty(!this.block.bold, 'bold');
1075
- }
1076
- toggleLock() {
1077
- this._blockEditor.selectedBlockComponentChangeProperty(!this.block.lock, 'lock');
1078
- }
1079
- fontColorChange(value) {
1080
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'fontColor');
1081
- }
1082
- italicClick() {
1083
- this._blockEditor.selectedBlockComponentChangeProperty(!this.block.italic, 'italic');
1084
- }
1085
- underlineClick() {
1086
- this._blockEditor.selectedBlockComponentChangeProperty(!this.block.underline, 'underline');
1087
- }
1088
- backgroundColorChange(value) {
1089
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'backgroundColor');
1090
- }
1091
- shadowColorChange(value) {
1092
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'shadowColor');
1093
- }
1094
- paddingAllChange(value) {
1095
- value = this.validNumeric(value) ? value : null;
1096
- this.block.paddingTop = value;
1097
- this.block.paddingLeft = value;
1098
- this.block.paddingBottom = value;
1099
- this.block.paddingRight = value;
1100
- this._blockEditor.selectedBlocks
1101
- .forEach((block) => {
1102
- this._blockEditor.blockChange(block);
1103
- });
1104
- }
1105
- paddingKeypress(event, name) {
1106
- this.block.padding = null;
1107
- this.numericInputKeypress(event, name, 1);
1108
- }
1109
- paddingAllKeypress(event, unit = 1) {
1110
- if (event.code === 'ArrowUp' || event.code === 'ArrowDown') {
1111
- this.block.padding = round(Number(this.block.padding || 0) + ((event.code === 'ArrowDown' ? -1 : 1) * unit), 3);
1112
- this.paddingAllChange(this.block.padding);
1113
- }
1114
- }
1115
- borderColorChange(value) {
1116
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'borderColor');
1117
- }
1118
- toggleKeepRatio() {
1119
- this._blockEditor.selectedBlockComponentChangeProperty(!this.block.keepRatio, 'keepRatio');
1120
- }
1121
- horizontalAlignClick(value) {
1122
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'horizontalAlign');
1123
- }
1124
- shapeRound(name) {
1125
- const value = this.block[name] === 'round' ? 'square' : 'round';
1126
- this._blockEditor.selectedBlockComponentChangeProperty(value, name);
1127
- }
1128
- numberChange(value, name) {
1129
- value = this.validNumeric(value) ? Number(value) : null;
1130
- this._blockEditor.selectedBlockComponentChangeProperty(value, name);
1131
- }
1132
- imageRemove() {
1133
- this._blockEditor.selectedBlockComponentChangeProperty(null, 'imageUrl');
1134
- }
1135
- imageClip() {
1136
- this.clippable = !this.clippable;
1137
- this._blockEditor.blockClippable = true;
1138
- }
1139
- blockChangeProperty(value, name) {
1140
- this._blockEditor.selectedBlockComponentChangeProperty(value, name);
1141
- }
1142
- imageSelect(fsFile) {
1143
- if (this.config.imageUpload) {
1144
- this.config.imageUpload(fsFile.file)
1145
- .subscribe((value) => {
1146
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'imageUrl');
1147
- });
1148
- }
1149
- }
1150
- blockRemoveClick() {
1151
- var _a;
1152
- if (this.config.blocksRemove && ((_a = this._blockEditor.selectedBlocks) === null || _a === void 0 ? void 0 : _a.length)) {
1153
- this._prompt.confirm({
1154
- title: 'Confirm',
1155
- template: 'Are you sure your would like to delete this block?',
1156
- })
1157
- .pipe(switchMap(() => this.config.blocksRemove(this._blockEditor.selectedBlocks)), takeUntil(this._destroy$))
1158
- .subscribe(() => {
1159
- this._blockEditor.removeSelectedBlocks();
1160
- });
1161
- }
1162
- }
1163
- blockUpload(type, fsFile) {
1164
- this._blockEditor.blockUpload({ type }, fsFile, true);
1165
- }
1166
- blockAdd(type) {
1167
- if (type === BlockType.Pdf || type === BlockType.Image) {
1168
- return;
1169
- }
1170
- const block = {
1171
- type,
1172
- shadowX: 2,
1173
- shadowY: 2,
1174
- shadowBlur: 4,
1175
- };
1176
- this._blockEditor.blockAdd(block, true);
1177
- }
1178
- layerMove(direction) {
1179
- this._blockEditor.blockComponents.forEach((blockComponent) => {
1180
- if (this._blockEditor.isSelectedBlock(blockComponent)) {
1181
- blockComponent.block.index += (999 * direction);
1182
- }
1183
- });
1184
- const sorted = this._blockEditor.blockComponents.sort((a, b) => {
1185
- return a.block.index > b.block.index ? 1 : -1;
1186
- });
1187
- sorted.forEach((item, index) => {
1188
- item.block.index = index;
1189
- item.markForCheck();
1190
- });
1191
- if (this.config.blocksLevelChanged) {
1192
- this.config.blocksLevelChanged(sorted.map((item) => item.block));
1193
- }
1194
- }
1195
- layerUp() {
1196
- this.layerMove(1);
1197
- }
1198
- layerDown() {
1199
- this.layerMove(-1);
1200
- }
1201
- reorderLayers() {
1202
- var _a;
1203
- (_a = this._document.defaultView) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
1204
- this._blockEditor.openReorderDialog();
1205
- }
1206
- inputFocus(event) {
1207
- event.target.select();
1208
- }
1209
- numericInputKeypress(event, name, unit = 1) {
1210
- if (event.code === 'ArrowUp' || event.code === 'ArrowDown') {
1211
- this.block[name] = round(Number(this.block[name] || 0) + ((event.code === 'ArrowDown' ? -1 : 1) * unit), 3);
1212
- this._blockEditor.selectedBlockComponentChangeProperty(this.block[name], name);
1213
- }
1214
- }
1215
- ngOnDestroy() {
1216
- this._destroy$.next();
1217
- this._destroy$.complete();
1218
- }
1219
- validNumeric(value) {
1220
- return !value || !!String(value).match(/^\d*\.?\d*$/);
1221
- }
1222
- }
1223
- 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$1.FsPrompt }, { token: GoogleFontService }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Component });
1224
- SidebarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SidebarComponent, selector: "sidebar", inputs: { config: "config", blocks: "blocks" }, outputs: { zoomCenter: "zoomCenter" }, queries: [{ propertyName: "sidebarPanels", predicate: FsBlockEditorSidebarPanelDirective }], ngImport: i0, template: "<div class=\"sidebar\">\n <div class=\"sidebar-panel\">\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\"></ng-container>\n </ng-container>\n <ng-container *ngSwitchCase=\"BlockType.Image\">\n <ng-container *ngTemplateOutlet=\"addFile\"></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>\n <fs-file (select)=\"blockUpload(blockType.value, $event)\" [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-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-row\">\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 <button\n class=\"reorder-layers\"\n mat-icon-button\n color=\"basic\"\n type=\"button\"\n (click)=\"reorderLayers()\">\n <mat-icon>swap_vert</mat-icon>\n </button>\n <ng-container *ngIf=\"block\">\n <button\n mat-icon-button\n color=\"basic\"\n type=\"button\"\n (click)=\"blockRemoveClick()\">\n <mat-icon>delete_outline</mat-icon>\n </button>\n <button\n class=\"layer-up\"\n mat-icon-button\n color=\"basic\"\n type=\"button\"\n (click)=\"layerUp()\">\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 <mat-icon>arrow_back</mat-icon>\n <mat-icon>layers</mat-icon>\n </button>\n\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\n </ng-container>\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\">\n <mat-form-field class=\"form-field-padless\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.left\"\n name=\"left\"\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\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.top\"\n name=\"top\"\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 rotate\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.rotate\"\n name=\"rotate\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'rotate')\"\n (ngModelChange)=\"numberChange($event, 'rotate')\">\n <span matPrefix>R</span>\n </mat-form-field>\n </div>\n\n <div class=\"sidebar-row\">\n <mat-form-field class=\"form-field-padless\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.width\"\n name=\"width\"\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\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.height\"\n name=\"height\"\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=\"block.type === BlockType.LongText || block.type === BlockType.ShortText || block.type === BlockType.RadioButton || block.type === BlockType.Checkbox || block.type === BlockType.Date || block.type === BlockType.Signature\">\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 <mat-form-field class=\"form-field-padless-bottom full-width\">\n <input\n matInput\n [ngModel]=\"block.label\"\n name=\"label\"\n placeholder=\"Label\"\n (ngModelChange)=\"blockChangeProperty($event, 'label')\">\n </mat-form-field>\n\n <ng-container *ngIf=\"block.type !== BlockType.Checkbox && block.type !== BlockType.RadioButton\">\n <mat-form-field class=\"form-field-padless-bottom full-width\">\n <textarea\n matInput\n [cdkTextareaAutosize]=\"true\"\n [ngModel]=\"block.description\"\n name=\"description\"\n placeholder=\"Description\"\n (ngModelChange)=\"blockChangeProperty($event, 'description')\">\n </textarea>\n </mat-form-field>\n </ng-container>\n\n <mat-form-field\n *ngIf=\"formats.length\"\n class=\"form-field-padless-bottom full-width\">\n <mat-label>Format</mat-label>\n <mat-select\n [(ngModel)]=\"block.format\"\n name=\"format\"\n (ngModelChange)=\"blockChangeProperty($event, 'format')\">\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=\"form-field-padless-bottom full-width\">\n <textarea\n matInput\n [cdkTextareaAutosize]=\"true\"\n [ngModel]=\"block.default\"\n name=\"default\"\n placeholder=\"Default\"\n (ngModelChange)=\"blockChangeProperty($event, 'default')\">\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=\"form-field-padless-bottom full-width\">\n <textarea\n matInput\n [cdkTextareaAutosize]=\"true\"\n [ngModel]=\"block.formula\"\n name=\"formula\"\n placeholder=\"Formula\"\n (ngModelChange)=\"blockChangeProperty($event, 'formula')\">\n </textarea>\n </mat-form-field>\n </ng-container>\n\n <ng-container *ngIf=\"block.type === BlockType.RadioButton || block.type === BlockType.Checkbox\">\n <mat-form-field class=\"form-field-padless-bottom full-width\">\n <textarea\n matInput\n [cdkTextareaAutosize]=\"true\"\n [ngModel]=\"block.groupLabel\"\n name=\"groupLabel\"\n placeholder=\"Group Label\"\n (ngModelChange)=\"blockChangeProperty($event, 'groupLabel')\">\n </textarea>\n </mat-form-field>\n\n <mat-form-field class=\"form-field-padless-bottom full-width\">\n <mat-label>Group Description</mat-label>\n <textarea\n matInput\n [cdkTextareaAutosize]=\"true\"\n [ngModel]=\"block.groupDescription\"\n name=\"groupDescription\"\n (ngModelChange)=\"blockChangeProperty($event, 'groupDescription')\">\n </textarea>\n </mat-form-field>\n </ng-container>\n\n <mat-form-field class=\"form-field-padless-bottom full-width\">\n <input\n matInput\n [ngModel]=\"block.name\"\n name=\"name\"\n placeholder=\"Name\"\n (ngModelChange)=\"blockChangeProperty($event, 'name')\">\n </mat-form-field>\n\n <div class=\"form-field-options\">\n <mat-checkbox\n name=\"required\"\n [(ngModel)]=\"block.required\"\n (ngModelChange)=\"blockChangeProperty($event, 'required')\">\n Required\n </mat-checkbox>\n\n <mat-checkbox\n name=\"readonly\"\n [(ngModel)]=\"block.readonly\"\n (ngModelChange)=\"blockChangeProperty($event, 'readonly')\">\n Readonly\n </mat-checkbox>\n </div>\n </div>\n </div>\n </ng-container>\n <div class=\"sidebar-panel typography-panel\">\n <div class=\"sidebar-label\">Typography</div>\n <div class=\"sidebar-row\">\n <fs-autocomplete\n [fetch]=\"fontFetch\"\n [fetchOnFocus]=\"true\"\n [displayWith]=\"fontDisplayWith\"\n [ngModel]=\"block.fontFamily ? { family: block.fontFamily } : null\"\n placeholder=\"Font\"\n [panelClass]=\"'font-autocomplete-panel'\"\n (ngModelChange)=\"fontChanged($event)\"\n name=\"fontfamily\">\n <ng-template fsAutocompleteTemplate let-data=\"data\">\n <app-font [font]=\"data\"></app-font>\n </ng-template>\n </fs-autocomplete>\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 font-size\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.fontSize\"\n name=\"fontSize\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'fontSize')\"\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 line-height\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.lineHeight\"\n name=\"lineHeight\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'lineHeight')\"\n (ngModelChange)=\"numberChange($event, 'lineHeight')\"\n placeholder=\"Line\">\n <span matPrefix *ngIf=\"block.lineHeight\">L</span>\n </mat-form-field>\n </div>\n\n <div class=\"sidebar-row style-row\">\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\">\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\">\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 border-width\" floatLabel=\"never\">\n <input\n matInput\n [(ngModel)]=\"block.borderWidth\"\n name=\"borderWidth\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'borderWidth')\"\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\n <div class=\"sidebar-panel\">\n <div class=\"sidebar-label\">Shape</div>\n\n <div class=\"sidebar-row\">\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 shape-radius\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.shapeRadius\"\n name=\"shapeRadius\"\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\n <div class=\"sidebar-panel shadow-panel\">\n <div class=\"sidebar-label\">Shadow</div>\n\n <div class=\"sidebar-row\">\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 shadow-x\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.shadowX\"\n name=\"shadowX\"\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 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 shadow-blur\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.shadowBlur\"\n name=\"shadowBlur\"\n placeholder=\"Blur\"\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\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.shadowSpread\"\n name=\"shadowSpread\"\n placeholder=\"Spread\"\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\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)=\"imageSelect($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 name=\"imageOpacity\"\n placeholder=\"Opacity\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'imageOpacity')\"\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\">\n\n <mat-form-field class=\"form-field-padless\" floatLabel=\"never\">\n <input\n matInput\n [(ngModel)]=\"block.padding\"\n name=\"padding\"\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\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.paddingTop\"\n name=\"paddingTop\"\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\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.paddingBottom\"\n name=\"paddingBottom\"\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\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.paddingLeft\"\n name=\"paddingLeft\"\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\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.paddingRight\"\n name=\"paddingRight\"\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\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</div>\n\n\n\n\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:285px;font-size:14px;height:100%;overflow:auto;background-color:#fff;padding:0 10px 10px;box-shadow:-1px 1px 4px 3px #0003;z-index:1;position:relative;box-sizing:border-box}.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:55px;margin-left:10px}.sidebar .sidebar-row ::ng-deep .mat-checkbox,.sidebar .sidebar-row ::ng-deep .mat-form-field{font-size:12px}.sidebar .sidebar-row>*:not(.mat-icon-button):not(fs-file){margin-right:11px}.sidebar .sidebar-row>*: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,.sidebar .border-width{width:45px}.sidebar .shape-radius{width:50px}.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.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 .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 mat-form-field+mat-form-field{margin-top:12px}.sidebar .sidebar-panel.block-form-panel .form-field-options{margin-top:11px}.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:40px}.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,.sidebar .sidebar-panel.shadow-panel .mat-form-field.shadow-blur{width:26px}.sidebar .sidebar-panel.typography-panel fs-autocomplete{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-prefix{color:#9e9e9e;margin-right:3px;font-size:85%}\n"], components: [{ type: i3$1.FsFileComponent, selector: "fs-file", inputs: ["minHeight", "minWidth", "orientate", "multiple", "capture", "allowClick", "allowDrop", "accept", "disabled", "imageWidth", "imageHeight", "imageQuality"], outputs: ["select", "error", "clicked", "declined"] }, { type: i6.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: i6$1.MatFormField, selector: "mat-form-field", inputs: ["color", "floatLabel", "appearance", "hideRequiredMarker", "hintLabel"], exportAs: ["matFormField"] }, { type: i7$1.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i8.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: i9.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: i10.FsAutocompleteComponent, selector: "fs-autocomplete", inputs: ["fetch", "placeholder", "displayWith", "fetchOnFocus", "readonly", "required", "disabled", "appearance", "hint", "panelWidth", "panelClass", "showClear"], outputs: ["cleared", "opened", "closed"] }, { type: FontComponent, selector: "app-font", inputs: ["font"] }, { type: i12.FsColorPickerChipComponent, selector: "fs-color-picker-chip", inputs: ["color", "showClear"], outputs: ["changed"] }], directives: [{ type: i13.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i13.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i13.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i13.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i13.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i13.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { type: i14.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { type: i15.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: i16.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: i16.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i16.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i6$1.MatPrefix, selector: "[matPrefix]" }, { type: i17.CdkTextareaAutosize, selector: "textarea[cdkTextareaAutosize]", inputs: ["cdkAutosizeMinRows", "cdkAutosizeMaxRows", "cdkTextareaAutosize", "placeholder"], exportAs: ["cdkTextareaAutosize"] }, { type: i6$1.MatLabel, selector: "mat-label" }, { type: i10.FsAutocompleteTemplateDirective, selector: "[fsAutocompleteTemplate]" }, { type: i13.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1225
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SidebarComponent, decorators: [{
1226
- type: Component,
1227
- args: [{
1228
- selector: 'sidebar',
1229
- templateUrl: 'sidebar.component.html',
1230
- styleUrls: ['sidebar.component.scss'],
1231
- changeDetection: ChangeDetectionStrategy.OnPush,
1232
- }]
1233
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }, { type: i0.ChangeDetectorRef }, { type: i2$1.FsPrompt }, { type: GoogleFontService }, { type: undefined, decorators: [{
1234
- type: Inject,
1235
- args: [DOCUMENT]
1236
- }] }]; }, propDecorators: { sidebarPanels: [{
1237
- type: ContentChildren,
1238
- args: [FsBlockEditorSidebarPanelDirective]
1239
- }], config: [{
1240
- type: Input
1241
- }], blocks: [{
1242
- type: Input
1243
- }], zoomCenter: [{
1244
- type: Output
1040
+ class SidebarComponent {
1041
+ constructor(_el, _blockEditor, _cdRef, _prompt, _googleFontService, _document) {
1042
+ this._el = _el;
1043
+ this._blockEditor = _blockEditor;
1044
+ this._cdRef = _cdRef;
1045
+ this._prompt = _prompt;
1046
+ this._googleFontService = _googleFontService;
1047
+ this._document = _document;
1048
+ this.zoomCenter = new EventEmitter();
1049
+ this.BlockTypes = BlockTypes;
1050
+ this.blockTypeNames = index(BlockTypes, 'value', 'name');
1051
+ this.blockTypeIcons = index(BlockTypes, 'value', 'icon');
1052
+ this.clippable = false;
1053
+ this.BlockType = BlockType;
1054
+ this.formats = [];
1055
+ this._destroy$ = new Subject();
1056
+ this.fontFetch = (value) => {
1057
+ return this._googleFontService.getItems();
1058
+ };
1059
+ this.fontDisplayWith = (value) => {
1060
+ return value === null || value === void 0 ? void 0 : value.family;
1061
+ };
1062
+ }
1063
+ get el() {
1064
+ return this._el.nativeElement;
1065
+ }
1066
+ ngOnInit() {
1067
+ this._blockEditor.selectedBlocks$
1068
+ .pipe(takeUntil(this._destroy$))
1069
+ .subscribe((blocks) => {
1070
+ this.block = blocks[0] ? blocks[0] : null;
1071
+ this.formats = BlockFormats
1072
+ .filter((blockFormat) => { var _a; return (blockFormat.blockTypes.indexOf((_a = this.block) === null || _a === void 0 ? void 0 : _a.type) !== -1); });
1073
+ this._cdRef.markForCheck();
1074
+ });
1075
+ this._blockEditor.blockChanged$
1076
+ .pipe(filter((block) => block === this.block), takeUntil(this._destroy$))
1077
+ .subscribe(() => {
1078
+ this._cdRef.markForCheck();
1079
+ });
1080
+ }
1081
+ fontChanged(font) {
1082
+ this._blockEditor.selectedBlockComponentChangeProperty(font === null || font === void 0 ? void 0 : font.family, 'fontFamily');
1083
+ }
1084
+ verticalAlignClick(value) {
1085
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'verticalAlign');
1086
+ }
1087
+ boldClick() {
1088
+ this._blockEditor.selectedBlockComponentChangeProperty(!this.block.bold, 'bold');
1089
+ }
1090
+ toggleLock() {
1091
+ this._blockEditor.selectedBlockComponentChangeProperty(!this.block.lock, 'lock');
1092
+ }
1093
+ fontColorChange(value) {
1094
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'fontColor');
1095
+ }
1096
+ italicClick() {
1097
+ this._blockEditor.selectedBlockComponentChangeProperty(!this.block.italic, 'italic');
1098
+ }
1099
+ underlineClick() {
1100
+ this._blockEditor.selectedBlockComponentChangeProperty(!this.block.underline, 'underline');
1101
+ }
1102
+ backgroundColorChange(value) {
1103
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'backgroundColor');
1104
+ }
1105
+ shadowColorChange(value) {
1106
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'shadowColor');
1107
+ }
1108
+ paddingAllChange(value) {
1109
+ value = this.validNumeric(value) ? value : null;
1110
+ this.block.paddingTop = value;
1111
+ this.block.paddingLeft = value;
1112
+ this.block.paddingBottom = value;
1113
+ this.block.paddingRight = value;
1114
+ this._blockEditor.selectedBlocks
1115
+ .forEach((block) => {
1116
+ this._blockEditor.blockChange(block);
1117
+ });
1118
+ }
1119
+ paddingKeypress(event, name) {
1120
+ this.block.padding = null;
1121
+ this.numericInputKeypress(event, name, 1);
1122
+ }
1123
+ paddingAllKeypress(event, unit = 1) {
1124
+ if (event.code === 'ArrowUp' || event.code === 'ArrowDown') {
1125
+ this.block.padding = round(Number(this.block.padding || 0) + ((event.code === 'ArrowDown' ? -1 : 1) * unit), 3);
1126
+ this.paddingAllChange(this.block.padding);
1127
+ }
1128
+ }
1129
+ borderColorChange(value) {
1130
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'borderColor');
1131
+ }
1132
+ toggleKeepRatio() {
1133
+ this._blockEditor.selectedBlockComponentChangeProperty(!this.block.keepRatio, 'keepRatio');
1134
+ }
1135
+ horizontalAlignClick(value) {
1136
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'horizontalAlign');
1137
+ }
1138
+ shapeRound(name) {
1139
+ const value = this.block[name] === 'round' ? 'square' : 'round';
1140
+ this._blockEditor.selectedBlockComponentChangeProperty(value, name);
1141
+ }
1142
+ numberChange(value, name) {
1143
+ value = this.validNumeric(value) ? Number(value) : null;
1144
+ this._blockEditor.selectedBlockComponentChangeProperty(value, name);
1145
+ }
1146
+ imageRemove() {
1147
+ this._blockEditor.selectedBlockComponentChangeProperty(null, 'imageUrl');
1148
+ }
1149
+ imageClip() {
1150
+ this.clippable = !this.clippable;
1151
+ this._blockEditor.blockClippable = true;
1152
+ }
1153
+ blockChangeProperty(value, name) {
1154
+ this._blockEditor.selectedBlockComponentChangeProperty(value, name);
1155
+ }
1156
+ blockRemoveClick() {
1157
+ var _a;
1158
+ if (this.config.blocksRemove && ((_a = this._blockEditor.selectedBlocks) === null || _a === void 0 ? void 0 : _a.length)) {
1159
+ this._prompt.confirm({
1160
+ title: 'Confirm',
1161
+ template: 'Are you sure your would like to delete this block?',
1162
+ })
1163
+ .pipe(switchMap(() => this.config.blocksRemove(this._blockEditor.selectedBlocks)), takeUntil(this._destroy$))
1164
+ .subscribe(() => {
1165
+ this._blockEditor.removeSelectedBlocks();
1166
+ });
1167
+ }
1168
+ }
1169
+ blockUpload(block, fsFile) {
1170
+ this._blockEditor
1171
+ .blockUpload(block, fsFile);
1172
+ }
1173
+ blockAdd(type) {
1174
+ if (type === BlockType.Pdf || type === BlockType.Image) {
1175
+ return;
1176
+ }
1177
+ const block = {
1178
+ type,
1179
+ shadowX: 2,
1180
+ shadowY: 2,
1181
+ shadowBlur: 4,
1182
+ };
1183
+ this._blockEditor.blockAdd(block);
1184
+ }
1185
+ layerMove(direction) {
1186
+ this._blockEditor.blockComponents.forEach((blockComponent) => {
1187
+ if (this._blockEditor.isSelectedBlock(blockComponent)) {
1188
+ blockComponent.block.index += (999 * direction);
1189
+ }
1190
+ });
1191
+ const sorted = this._blockEditor.blockComponents.sort((a, b) => {
1192
+ return a.block.index > b.block.index ? 1 : -1;
1193
+ });
1194
+ sorted.forEach((item, index) => {
1195
+ item.block.index = index;
1196
+ item.markForCheck();
1197
+ });
1198
+ if (this.config.blocksLevelChanged) {
1199
+ this.config.blocksLevelChanged(sorted.map((item) => item.block));
1200
+ }
1201
+ }
1202
+ layerUp() {
1203
+ this.layerMove(1);
1204
+ }
1205
+ layerDown() {
1206
+ this.layerMove(-1);
1207
+ }
1208
+ reorderLayers() {
1209
+ var _a;
1210
+ (_a = this._document.defaultView) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
1211
+ this._blockEditor.openReorderDialog();
1212
+ }
1213
+ inputFocus(event) {
1214
+ event.target.select();
1215
+ }
1216
+ numericInputKeypress(event, name, unit = 1) {
1217
+ if (event.code === 'ArrowUp' || event.code === 'ArrowDown') {
1218
+ this.block[name] = round(Number(this.block[name] || 0) + ((event.code === 'ArrowDown' ? -1 : 1) * unit), 3);
1219
+ this._blockEditor.selectedBlockComponentChangeProperty(this.block[name], name);
1220
+ }
1221
+ }
1222
+ ngOnDestroy() {
1223
+ this._destroy$.next();
1224
+ this._destroy$.complete();
1225
+ }
1226
+ validNumeric(value) {
1227
+ return !value || !!String(value).match(/^\d*\.?\d*$/);
1228
+ }
1229
+ }
1230
+ 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$1.FsPrompt }, { token: GoogleFontService }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Component });
1231
+ SidebarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SidebarComponent, selector: "sidebar", inputs: { config: "config", blocks: "blocks" }, outputs: { zoomCenter: "zoomCenter" }, queries: [{ propertyName: "sidebarPanels", predicate: FsBlockEditorSidebarPanelDirective }], ngImport: i0, template: "<div class=\"sidebar\">\n <div class=\"sidebar-panel\">\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-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-row\">\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 <button\n class=\"reorder-layers\"\n mat-icon-button\n color=\"basic\"\n type=\"button\"\n (click)=\"reorderLayers()\">\n <mat-icon>swap_vert</mat-icon>\n </button>\n <ng-container *ngIf=\"block\">\n <button\n mat-icon-button\n color=\"basic\"\n type=\"button\"\n (click)=\"blockRemoveClick()\">\n <mat-icon>delete_outline</mat-icon>\n </button>\n <button\n class=\"layer-up\"\n mat-icon-button\n color=\"basic\"\n type=\"button\"\n (click)=\"layerUp()\">\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 <mat-icon>arrow_back</mat-icon>\n <mat-icon>layers</mat-icon>\n </button>\n\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\n </ng-container>\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\">\n <mat-form-field class=\"form-field-padless\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.left\"\n name=\"left\"\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\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.top\"\n name=\"top\"\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 rotate\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.rotate\"\n name=\"rotate\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'rotate')\"\n (ngModelChange)=\"numberChange($event, 'rotate')\">\n <span matPrefix>R</span>\n </mat-form-field>\n </div>\n\n <div class=\"sidebar-row\">\n <mat-form-field class=\"form-field-padless\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.width\"\n name=\"width\"\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\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.height\"\n name=\"height\"\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=\"block.type === BlockType.LongText || block.type === BlockType.ShortText || block.type === BlockType.RadioButton || block.type === BlockType.Checkbox || block.type === BlockType.Date || block.type === BlockType.Signature\">\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 <mat-form-field class=\"form-field-padless-bottom full-width\">\n <input\n matInput\n [ngModel]=\"block.label\"\n name=\"label\"\n placeholder=\"Label\"\n (ngModelChange)=\"blockChangeProperty($event, 'label')\">\n </mat-form-field>\n\n <ng-container *ngIf=\"block.type !== BlockType.Checkbox && block.type !== BlockType.RadioButton\">\n <mat-form-field class=\"form-field-padless-bottom full-width\">\n <textarea\n matInput\n [cdkTextareaAutosize]=\"true\"\n [ngModel]=\"block.description\"\n name=\"description\"\n placeholder=\"Description\"\n (ngModelChange)=\"blockChangeProperty($event, 'description')\">\n </textarea>\n </mat-form-field>\n </ng-container>\n\n <mat-form-field\n *ngIf=\"formats.length\"\n class=\"form-field-padless-bottom full-width\">\n <mat-label>Format</mat-label>\n <mat-select\n [(ngModel)]=\"block.format\"\n name=\"format\"\n (ngModelChange)=\"blockChangeProperty($event, 'format')\">\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=\"form-field-padless-bottom full-width\">\n <textarea\n matInput\n [cdkTextareaAutosize]=\"true\"\n [ngModel]=\"block.default\"\n name=\"default\"\n placeholder=\"Default\"\n (ngModelChange)=\"blockChangeProperty($event, 'default')\">\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=\"form-field-padless-bottom full-width\">\n <textarea\n matInput\n [cdkTextareaAutosize]=\"true\"\n [ngModel]=\"block.formula\"\n name=\"formula\"\n placeholder=\"Formula\"\n (ngModelChange)=\"blockChangeProperty($event, 'formula')\">\n </textarea>\n </mat-form-field>\n </ng-container>\n\n <ng-container *ngIf=\"block.type === BlockType.RadioButton || block.type === BlockType.Checkbox\">\n <mat-form-field class=\"form-field-padless-bottom full-width\">\n <textarea\n matInput\n [cdkTextareaAutosize]=\"true\"\n [ngModel]=\"block.groupLabel\"\n name=\"groupLabel\"\n placeholder=\"Group Label\"\n (ngModelChange)=\"blockChangeProperty($event, 'groupLabel')\">\n </textarea>\n </mat-form-field>\n\n <mat-form-field class=\"form-field-padless-bottom full-width\">\n <mat-label>Group Description</mat-label>\n <textarea\n matInput\n [cdkTextareaAutosize]=\"true\"\n [ngModel]=\"block.groupDescription\"\n name=\"groupDescription\"\n (ngModelChange)=\"blockChangeProperty($event, 'groupDescription')\">\n </textarea>\n </mat-form-field>\n </ng-container>\n\n <mat-form-field class=\"form-field-padless-bottom full-width\">\n <input\n matInput\n [ngModel]=\"block.name\"\n name=\"name\"\n placeholder=\"Name\"\n (ngModelChange)=\"blockChangeProperty($event, 'name')\">\n </mat-form-field>\n\n <div class=\"form-field-options\">\n <mat-checkbox\n name=\"required\"\n [(ngModel)]=\"block.required\"\n (ngModelChange)=\"blockChangeProperty($event, 'required')\">\n Required\n </mat-checkbox>\n\n <mat-checkbox\n name=\"readonly\"\n [(ngModel)]=\"block.readonly\"\n (ngModelChange)=\"blockChangeProperty($event, 'readonly')\">\n Readonly\n </mat-checkbox>\n </div>\n </div>\n </div>\n </ng-container>\n <div class=\"sidebar-panel typography-panel\">\n <div class=\"sidebar-label\">Typography</div>\n <div class=\"sidebar-row\">\n <fs-autocomplete\n [fetch]=\"fontFetch\"\n [fetchOnFocus]=\"true\"\n [displayWith]=\"fontDisplayWith\"\n [ngModel]=\"block.fontFamily ? { family: block.fontFamily } : null\"\n placeholder=\"Font\"\n [panelClass]=\"'font-autocomplete-panel'\"\n (ngModelChange)=\"fontChanged($event)\"\n name=\"fontfamily\">\n <ng-template fsAutocompleteTemplate let-data=\"data\">\n <app-font [font]=\"data\"></app-font>\n </ng-template>\n </fs-autocomplete>\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 font-size\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.fontSize\"\n name=\"fontSize\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'fontSize')\"\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 line-height\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.lineHeight\"\n name=\"lineHeight\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'lineHeight')\"\n (ngModelChange)=\"numberChange($event, 'lineHeight')\"\n placeholder=\"Line\">\n <span matPrefix *ngIf=\"block.lineHeight\">L</span>\n </mat-form-field>\n </div>\n\n <div class=\"sidebar-row style-row\">\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\">\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\">\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 border-width\" floatLabel=\"never\">\n <input\n matInput\n [(ngModel)]=\"block.borderWidth\"\n name=\"borderWidth\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'borderWidth')\"\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\n <div class=\"sidebar-panel\">\n <div class=\"sidebar-label\">Shape</div>\n\n <div class=\"sidebar-row\">\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 shape-radius\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.shapeRadius\"\n name=\"shapeRadius\"\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\n <div class=\"sidebar-panel shadow-panel\">\n <div class=\"sidebar-label\">Shadow</div>\n\n <div class=\"sidebar-row\">\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 shadow-x\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.shadowX\"\n name=\"shadowX\"\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 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 shadow-blur\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.shadowBlur\"\n name=\"shadowBlur\"\n placeholder=\"Blur\"\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\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.shadowSpread\"\n name=\"shadowSpread\"\n placeholder=\"Spread\"\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\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 name=\"imageOpacity\"\n placeholder=\"Opacity\"\n (focus)=\"inputFocus($event)\"\n (keydown)=\"numericInputKeypress($event, 'imageOpacity')\"\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\">\n\n <mat-form-field class=\"form-field-padless\" floatLabel=\"never\">\n <input\n matInput\n [(ngModel)]=\"block.padding\"\n name=\"padding\"\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\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.paddingTop\"\n name=\"paddingTop\"\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\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.paddingBottom\"\n name=\"paddingBottom\"\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\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.paddingLeft\"\n name=\"paddingLeft\"\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\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.paddingRight\"\n name=\"paddingRight\"\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\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</div>\n\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:285px;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 .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:55px;margin-left:10px}.sidebar .sidebar-row ::ng-deep .mat-checkbox,.sidebar .sidebar-row ::ng-deep .mat-form-field{font-size:12px}.sidebar .sidebar-row>*:not(.mat-icon-button):not(fs-file){margin-right:11px}.sidebar .sidebar-row>*: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,.sidebar .border-width{width:45px}.sidebar .shape-radius{width:50px}.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.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 .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 mat-form-field+mat-form-field{margin-top:12px}.sidebar .sidebar-panel.block-form-panel .form-field-options{margin-top:11px}.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:40px}.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,.sidebar .sidebar-panel.shadow-panel .mat-form-field.shadow-blur{width:26px}.sidebar .sidebar-panel.typography-panel fs-autocomplete{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-prefix{color:#9e9e9e;margin-right:3px;font-size:85%}\n"], components: [{ type: i3$1.FsFileComponent, selector: "fs-file", inputs: ["minHeight", "minWidth", "orientate", "multiple", "capture", "allowClick", "allowDrop", "accept", "disabled", "imageWidth", "imageHeight", "imageQuality"], outputs: ["select", "error", "clicked", "declined"] }, { type: i6.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: i6$1.MatFormField, selector: "mat-form-field", inputs: ["color", "floatLabel", "appearance", "hideRequiredMarker", "hintLabel"], exportAs: ["matFormField"] }, { type: i7$1.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i8.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: i9.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: i10.FsAutocompleteComponent, selector: "fs-autocomplete", inputs: ["fetch", "placeholder", "displayWith", "fetchOnFocus", "readonly", "required", "disabled", "appearance", "hint", "panelWidth", "panelClass", "showClear"], outputs: ["cleared", "opened", "closed"] }, { type: FontComponent, selector: "app-font", inputs: ["font"] }, { type: i12.FsColorPickerChipComponent, selector: "fs-color-picker-chip", inputs: ["color", "showClear"], outputs: ["changed"] }], directives: [{ type: i13.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i13.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i13.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i13.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i13.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i13.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { type: i14.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { type: i15.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: i16.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: i16.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i16.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i6$1.MatPrefix, selector: "[matPrefix]" }, { type: i17.CdkTextareaAutosize, selector: "textarea[cdkTextareaAutosize]", inputs: ["cdkAutosizeMinRows", "cdkAutosizeMaxRows", "cdkTextareaAutosize", "placeholder"], exportAs: ["cdkTextareaAutosize"] }, { type: i6$1.MatLabel, selector: "mat-label" }, { type: i10.FsAutocompleteTemplateDirective, selector: "[fsAutocompleteTemplate]" }, { type: i13.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1232
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SidebarComponent, decorators: [{
1233
+ type: Component,
1234
+ args: [{
1235
+ selector: 'sidebar',
1236
+ templateUrl: 'sidebar.component.html',
1237
+ styleUrls: ['sidebar.component.scss'],
1238
+ changeDetection: ChangeDetectionStrategy.OnPush,
1239
+ }]
1240
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }, { type: i0.ChangeDetectorRef }, { type: i2$1.FsPrompt }, { type: GoogleFontService }, { type: undefined, decorators: [{
1241
+ type: Inject,
1242
+ args: [DOCUMENT]
1243
+ }] }]; }, propDecorators: { sidebarPanels: [{
1244
+ type: ContentChildren,
1245
+ args: [FsBlockEditorSidebarPanelDirective]
1246
+ }], config: [{
1247
+ type: Input
1248
+ }], blocks: [{
1249
+ type: Input
1250
+ }], zoomCenter: [{
1251
+ type: Output
1245
1252
  }] } });
1246
1253
 
1247
- class ArtboardComponent {
1248
- constructor(_el, _blockEditor, _cdRef) {
1249
- this._el = _el;
1250
- this._blockEditor = _blockEditor;
1251
- this._cdRef = _cdRef;
1252
- this.blocks = [];
1253
- this._destroy$ = new Subject();
1254
- }
1255
- get el() {
1256
- return this._el.nativeElement;
1257
- }
1258
- ngOnInit() {
1259
- this.config = Object.assign(Object.assign({}, this.config), { unit: 'in' });
1260
- this._blockEditor.registerContainer(this.artboard.nativeElement);
1261
- this._blockEditor.registerMargin(this.marginContainer.nativeElement);
1262
- this._blockEditor.blocks$
1263
- .pipe(takeUntil(this._destroy$))
1264
- .subscribe((blocks) => {
1265
- this.blocks = blocks;
1266
- this._cdRef.markForCheck();
1267
- });
1268
- this._blockEditor.blockAdded$
1269
- .pipe(delay(300), takeUntil(this._destroy$))
1270
- .subscribe((block) => {
1271
- this._blockEditor.selectedBlocks = [block];
1272
- this._cdRef.markForCheck();
1273
- });
1274
- fromEvent(window, 'keydown')
1275
- .pipe(filter((event) => {
1276
- return ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].indexOf(event.key) !== -1;
1277
- }), filter(() => {
1278
- const el = document.activeElement;
1279
- return !(el instanceof HTMLInputElement || (el && el.classList.contains('content-editable')));
1280
- }), takeUntil(this._destroy$))
1281
- .subscribe((event) => {
1282
- event.preventDefault();
1283
- const inchPixel = 1 / 100;
1284
- this._blockEditor.selectedComponentBlocks
1285
- .forEach((blockComponent) => {
1286
- switch (event.key) {
1287
- case 'ArrowUp':
1288
- blockComponent.block.top = blockComponent.block.top - inchPixel;
1289
- break;
1290
- case 'ArrowDown':
1291
- blockComponent.block.top = blockComponent.block.top + inchPixel;
1292
- break;
1293
- case 'ArrowLeft':
1294
- blockComponent.block.left = blockComponent.block.left - inchPixel;
1295
- break;
1296
- case 'ArrowRight':
1297
- blockComponent.block.left = blockComponent.block.left + inchPixel;
1298
- break;
1299
- }
1300
- this._blockEditor.blockChange(blockComponent.block);
1301
- });
1302
- });
1303
- }
1304
- ngOnDestroy() {
1305
- this._destroy$.next();
1306
- this._destroy$.complete();
1307
- }
1308
- }
1309
- 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 });
1310
- 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: i13.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i13.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1311
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ArtboardComponent, decorators: [{
1312
- type: Component,
1313
- args: [{
1314
- selector: 'app-artboard',
1315
- templateUrl: 'artboard.component.html',
1316
- styleUrls: ['artboard.component.scss'],
1317
- changeDetection: ChangeDetectionStrategy.OnPush,
1318
- }]
1319
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { sidebarPanels: [{
1320
- type: ContentChildren,
1321
- args: [FsBlockEditorSidebarPanelDirective]
1322
- }], blockComponents: [{
1323
- type: ViewChildren,
1324
- args: [FsBlockComponent]
1325
- }], artboard: [{
1326
- type: ViewChild,
1327
- args: ['artboard', { static: true }]
1328
- }], marginContainer: [{
1329
- type: ViewChild,
1330
- args: ['marginContainer', { static: true }]
1331
- }], margins: [{
1332
- type: ViewChildren,
1333
- args: [FsBlockEditorMarginDirective]
1334
- }], sidebar: [{
1335
- type: ViewChild,
1336
- args: [SidebarComponent, { static: true }]
1337
- }], config: [{
1338
- type: Input
1339
- }], zoompan: [{
1340
- type: Input
1254
+ class ArtboardComponent {
1255
+ constructor(_el, _blockEditor, _cdRef) {
1256
+ this._el = _el;
1257
+ this._blockEditor = _blockEditor;
1258
+ this._cdRef = _cdRef;
1259
+ this.blocks = [];
1260
+ this._destroy$ = new Subject();
1261
+ }
1262
+ get el() {
1263
+ return this._el.nativeElement;
1264
+ }
1265
+ ngOnInit() {
1266
+ this.config = Object.assign(Object.assign({}, this.config), { unit: 'in' });
1267
+ this._blockEditor.registerContainer(this.artboard.nativeElement);
1268
+ this._blockEditor.registerMargin(this.marginContainer.nativeElement);
1269
+ this._blockEditor.blocks$
1270
+ .pipe(takeUntil(this._destroy$))
1271
+ .subscribe((blocks) => {
1272
+ this.blocks = blocks;
1273
+ this._cdRef.markForCheck();
1274
+ });
1275
+ this._blockEditor.blockAdded$
1276
+ .pipe(delay(300), takeUntil(this._destroy$))
1277
+ .subscribe((block) => {
1278
+ this._blockEditor.selectedBlocks = [block];
1279
+ this._cdRef.markForCheck();
1280
+ });
1281
+ fromEvent(window, 'keydown')
1282
+ .pipe(filter((event) => {
1283
+ return ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].indexOf(event.key) !== -1;
1284
+ }), filter(() => {
1285
+ const el = document.activeElement;
1286
+ return !(el instanceof HTMLInputElement || (el && el.classList.contains('content-editable')));
1287
+ }), takeUntil(this._destroy$))
1288
+ .subscribe((event) => {
1289
+ event.preventDefault();
1290
+ const inchPixel = 1 / 100;
1291
+ this._blockEditor.selectedComponentBlocks
1292
+ .forEach((blockComponent) => {
1293
+ switch (event.key) {
1294
+ case 'ArrowUp':
1295
+ blockComponent.block.top = blockComponent.block.top - inchPixel;
1296
+ break;
1297
+ case 'ArrowDown':
1298
+ blockComponent.block.top = blockComponent.block.top + inchPixel;
1299
+ break;
1300
+ case 'ArrowLeft':
1301
+ blockComponent.block.left = blockComponent.block.left - inchPixel;
1302
+ break;
1303
+ case 'ArrowRight':
1304
+ blockComponent.block.left = blockComponent.block.left + inchPixel;
1305
+ break;
1306
+ }
1307
+ this._blockEditor.blockChange(blockComponent.block);
1308
+ });
1309
+ });
1310
+ }
1311
+ ngOnDestroy() {
1312
+ this._destroy$.next();
1313
+ this._destroy$.complete();
1314
+ }
1315
+ }
1316
+ 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 });
1317
+ 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: i13.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i13.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1318
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ArtboardComponent, decorators: [{
1319
+ type: Component,
1320
+ args: [{
1321
+ selector: 'app-artboard',
1322
+ templateUrl: 'artboard.component.html',
1323
+ styleUrls: ['artboard.component.scss'],
1324
+ changeDetection: ChangeDetectionStrategy.OnPush,
1325
+ }]
1326
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { sidebarPanels: [{
1327
+ type: ContentChildren,
1328
+ args: [FsBlockEditorSidebarPanelDirective]
1329
+ }], blockComponents: [{
1330
+ type: ViewChildren,
1331
+ args: [FsBlockComponent]
1332
+ }], artboard: [{
1333
+ type: ViewChild,
1334
+ args: ['artboard', { static: true }]
1335
+ }], marginContainer: [{
1336
+ type: ViewChild,
1337
+ args: ['marginContainer', { static: true }]
1338
+ }], margins: [{
1339
+ type: ViewChildren,
1340
+ args: [FsBlockEditorMarginDirective]
1341
+ }], sidebar: [{
1342
+ type: ViewChild,
1343
+ args: [SidebarComponent, { static: true }]
1344
+ }], config: [{
1345
+ type: Input
1346
+ }], zoompan: [{
1347
+ type: Input
1341
1348
  }] } });
1342
1349
 
1343
- class FsBlockEditorComponent {
1344
- constructor(_el, _blockEditor) {
1345
- this._el = _el;
1346
- this._blockEditor = _blockEditor;
1347
- this._destroy$ = new Subject();
1348
- }
1349
- get el() {
1350
- return this._el.nativeElement;
1351
- }
1352
- ngOnInit() {
1353
- this.config = Object.assign(Object.assign({}, this.config), { unit: 'in' });
1354
- this._blockEditor.init(this.config);
1355
- this._blockEditor.blocks$
1356
- .pipe(takeUntil(this._destroy$))
1357
- .subscribe((blocks) => {
1358
- this.blocks = blocks;
1359
- });
1360
- setTimeout(() => {
1361
- this.zoomCenter();
1362
- });
1363
- }
1364
- zoomCenter() {
1365
- this.zoompan.center(this.artboard.nativeElement, { vertical: false });
1366
- }
1367
- editorContainerClick(event) {
1368
- if (event.target.classList.contains('deselectable') ||
1369
- event.target.classList.contains('fs-zoom-pan-container')) {
1370
- this.zoompan.enable();
1371
- this._blockEditor.selectedBlocks = [];
1372
- }
1373
- }
1374
- ngOnDestroy() {
1375
- this._destroy$.next();
1376
- this._destroy$.complete();
1377
- }
1378
- }
1379
- 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 });
1380
- FsBlockEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorComponent, selector: "fs-block-editor", inputs: { config: "config" }, providers: [
1381
- BlockEditorService,
1382
- BlocksStore,
1383
- ], 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}.editor-container .zoom-pan-container{flex:1}fs-zoom-pan{height:100%}\n"], components: [{ type: i2$2.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"], outputs: ["zoomCenter"] }], directives: [{ type: i2$2.FsZoomPanContentDirective, selector: "[fsZoomPanContent]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1384
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorComponent, decorators: [{
1385
- type: Component,
1386
- args: [{
1387
- selector: 'fs-block-editor',
1388
- templateUrl: 'block-editor.component.html',
1389
- styleUrls: ['block-editor.component.scss'],
1390
- changeDetection: ChangeDetectionStrategy.OnPush,
1391
- providers: [
1392
- BlockEditorService,
1393
- BlocksStore,
1394
- ]
1395
- }]
1396
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }]; }, propDecorators: { sidebarPanels: [{
1397
- type: ContentChildren,
1398
- args: [FsBlockEditorSidebarPanelDirective]
1399
- }], zoompan: [{
1400
- type: ViewChild,
1401
- args: [FsZoomPanComponent, { static: true }]
1402
- }], artboardContainer: [{
1403
- type: ViewChild,
1404
- args: ['artboardContainer', { static: true }]
1405
- }], sidebar: [{
1406
- type: ViewChild,
1407
- args: [SidebarComponent, { static: true }]
1408
- }], artboard: [{
1409
- type: ViewChild,
1410
- args: [ArtboardComponent, { read: ElementRef }]
1411
- }], config: [{
1412
- type: Input
1350
+ class FsBlockEditorComponent {
1351
+ constructor(_el, _blockEditor) {
1352
+ this._el = _el;
1353
+ this._blockEditor = _blockEditor;
1354
+ this._destroy$ = new Subject();
1355
+ }
1356
+ get el() {
1357
+ return this._el.nativeElement;
1358
+ }
1359
+ ngOnInit() {
1360
+ this.config = Object.assign(Object.assign({}, this.config), { unit: 'in' });
1361
+ this._blockEditor.init(this.config);
1362
+ this._blockEditor.blocks$
1363
+ .pipe(takeUntil(this._destroy$))
1364
+ .subscribe((blocks) => {
1365
+ this.blocks = blocks;
1366
+ });
1367
+ setTimeout(() => {
1368
+ this.zoomCenter();
1369
+ });
1370
+ }
1371
+ zoomCenter() {
1372
+ this.zoompan.center(this.artboard.nativeElement, { vertical: false });
1373
+ }
1374
+ editorContainerKeyDown(event) {
1375
+ var _a;
1376
+ if ((event.key === 'Delete' || event.key === 'Backspace') && ((_a = event.target) === null || _a === void 0 ? void 0 : _a.nodeName) !== 'INPUT') {
1377
+ this.sidebar.blockRemoveClick();
1378
+ event.preventDefault();
1379
+ }
1380
+ }
1381
+ editorContainerClick(event) {
1382
+ if (event.target.classList.contains('deselectable') ||
1383
+ event.target.classList.contains('fs-zoom-pan-container')) {
1384
+ this.zoompan.enable();
1385
+ this._blockEditor.selectedBlocks = [];
1386
+ }
1387
+ }
1388
+ ngOnDestroy() {
1389
+ this._destroy$.next();
1390
+ this._destroy$.complete();
1391
+ }
1392
+ }
1393
+ 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 });
1394
+ FsBlockEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorComponent, selector: "fs-block-editor", inputs: { config: "config" }, host: { listeners: { "document:keydown": "editorContainerKeyDown($event)" } }, providers: [
1395
+ BlockEditorService,
1396
+ BlocksStore,
1397
+ ], 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$2.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"], outputs: ["zoomCenter"] }], directives: [{ type: i2$2.FsZoomPanContentDirective, selector: "[fsZoomPanContent]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1398
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorComponent, decorators: [{
1399
+ type: Component,
1400
+ args: [{
1401
+ selector: 'fs-block-editor',
1402
+ templateUrl: 'block-editor.component.html',
1403
+ styleUrls: ['block-editor.component.scss'],
1404
+ changeDetection: ChangeDetectionStrategy.OnPush,
1405
+ providers: [
1406
+ BlockEditorService,
1407
+ BlocksStore,
1408
+ ]
1409
+ }]
1410
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }]; }, propDecorators: { sidebarPanels: [{
1411
+ type: ContentChildren,
1412
+ args: [FsBlockEditorSidebarPanelDirective]
1413
+ }], zoompan: [{
1414
+ type: ViewChild,
1415
+ args: [FsZoomPanComponent, { static: true }]
1416
+ }], artboardContainer: [{
1417
+ type: ViewChild,
1418
+ args: ['artboardContainer', { static: true }]
1419
+ }], sidebar: [{
1420
+ type: ViewChild,
1421
+ args: [SidebarComponent, { static: true }]
1422
+ }], artboard: [{
1423
+ type: ViewChild,
1424
+ args: [ArtboardComponent, { read: ElementRef }]
1425
+ }], config: [{
1426
+ type: Input
1427
+ }], editorContainerKeyDown: [{
1428
+ type: HostListener,
1429
+ args: ['document:keydown', ['$event']]
1413
1430
  }] } });
1414
1431
 
1415
- class FsBlockEditorModule {
1416
- static forRoot() {
1417
- return {
1418
- ngModule: FsBlockEditorModule,
1419
- };
1420
- }
1421
- }
1422
- FsBlockEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1423
- FsBlockEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, declarations: [FsBlockComponent,
1424
- FsBlockEditorComponent,
1425
- FsBlockEditorSidebarPanelDirective,
1426
- FsBlockEditorMarginDirective,
1427
- SidebarComponent,
1428
- ArtboardComponent,
1429
- LayersReorderDialogComponent,
1430
- FontComponent], imports: [CommonModule,
1431
- FormsModule,
1432
- MatIconModule,
1433
- MatButtonModule,
1434
- MatInputModule,
1435
- MatFormFieldModule,
1436
- MatCheckboxModule,
1437
- MatTooltipModule,
1438
- MatSelectModule,
1439
- MatListModule,
1440
- DragDropModule,
1441
- FsFileModule,
1442
- FsColorPickerModule,
1443
- FsMenuModule,
1444
- FsZoomPanModule,
1445
- FsAutocompleteModule,
1446
- FsDialogModule], exports: [FsBlockComponent,
1447
- FsBlockEditorComponent,
1448
- FsBlockEditorSidebarPanelDirective] });
1449
- FsBlockEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, providers: [
1450
- GoogleFontService,
1451
- ], imports: [[
1452
- CommonModule,
1453
- FormsModule,
1454
- MatIconModule,
1455
- MatButtonModule,
1456
- MatInputModule,
1457
- MatFormFieldModule,
1458
- MatCheckboxModule,
1459
- MatTooltipModule,
1460
- MatSelectModule,
1461
- MatListModule,
1462
- DragDropModule,
1463
- FsFileModule,
1464
- FsColorPickerModule,
1465
- FsMenuModule,
1466
- FsZoomPanModule,
1467
- FsAutocompleteModule,
1468
- FsDialogModule,
1469
- ]] });
1470
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, decorators: [{
1471
- type: NgModule,
1472
- args: [{
1473
- imports: [
1474
- CommonModule,
1475
- FormsModule,
1476
- MatIconModule,
1477
- MatButtonModule,
1478
- MatInputModule,
1479
- MatFormFieldModule,
1480
- MatCheckboxModule,
1481
- MatTooltipModule,
1482
- MatSelectModule,
1483
- MatListModule,
1484
- DragDropModule,
1485
- FsFileModule,
1486
- FsColorPickerModule,
1487
- FsMenuModule,
1488
- FsZoomPanModule,
1489
- FsAutocompleteModule,
1490
- FsDialogModule,
1491
- ],
1492
- exports: [
1493
- FsBlockComponent,
1494
- FsBlockEditorComponent,
1495
- FsBlockEditorSidebarPanelDirective,
1496
- ],
1497
- declarations: [
1498
- FsBlockComponent,
1499
- FsBlockEditorComponent,
1500
- FsBlockEditorSidebarPanelDirective,
1501
- FsBlockEditorMarginDirective,
1502
- SidebarComponent,
1503
- ArtboardComponent,
1504
- LayersReorderDialogComponent,
1505
- FontComponent,
1506
- ],
1507
- providers: [
1508
- GoogleFontService,
1509
- ]
1510
- }]
1432
+ class FsBlockEditorModule {
1433
+ static forRoot() {
1434
+ return {
1435
+ ngModule: FsBlockEditorModule,
1436
+ };
1437
+ }
1438
+ }
1439
+ FsBlockEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1440
+ FsBlockEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, declarations: [FsBlockComponent,
1441
+ FsBlockEditorComponent,
1442
+ FsBlockEditorSidebarPanelDirective,
1443
+ FsBlockEditorMarginDirective,
1444
+ SidebarComponent,
1445
+ ArtboardComponent,
1446
+ LayersReorderDialogComponent,
1447
+ FontComponent,
1448
+ CreateImageUrlPipe], imports: [CommonModule,
1449
+ FormsModule,
1450
+ MatIconModule,
1451
+ MatButtonModule,
1452
+ MatInputModule,
1453
+ MatFormFieldModule,
1454
+ MatCheckboxModule,
1455
+ MatTooltipModule,
1456
+ MatSelectModule,
1457
+ MatListModule,
1458
+ DragDropModule,
1459
+ FsFileModule,
1460
+ FsColorPickerModule,
1461
+ FsMenuModule,
1462
+ FsZoomPanModule,
1463
+ FsAutocompleteModule,
1464
+ FsDialogModule], exports: [FsBlockComponent,
1465
+ FsBlockEditorComponent,
1466
+ FsBlockEditorSidebarPanelDirective] });
1467
+ FsBlockEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, providers: [
1468
+ GoogleFontService,
1469
+ ], imports: [[
1470
+ CommonModule,
1471
+ FormsModule,
1472
+ MatIconModule,
1473
+ MatButtonModule,
1474
+ MatInputModule,
1475
+ MatFormFieldModule,
1476
+ MatCheckboxModule,
1477
+ MatTooltipModule,
1478
+ MatSelectModule,
1479
+ MatListModule,
1480
+ DragDropModule,
1481
+ FsFileModule,
1482
+ FsColorPickerModule,
1483
+ FsMenuModule,
1484
+ FsZoomPanModule,
1485
+ FsAutocompleteModule,
1486
+ FsDialogModule,
1487
+ ]] });
1488
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, decorators: [{
1489
+ type: NgModule,
1490
+ args: [{
1491
+ imports: [
1492
+ CommonModule,
1493
+ FormsModule,
1494
+ MatIconModule,
1495
+ MatButtonModule,
1496
+ MatInputModule,
1497
+ MatFormFieldModule,
1498
+ MatCheckboxModule,
1499
+ MatTooltipModule,
1500
+ MatSelectModule,
1501
+ MatListModule,
1502
+ DragDropModule,
1503
+ FsFileModule,
1504
+ FsColorPickerModule,
1505
+ FsMenuModule,
1506
+ FsZoomPanModule,
1507
+ FsAutocompleteModule,
1508
+ FsDialogModule,
1509
+ ],
1510
+ exports: [
1511
+ FsBlockComponent,
1512
+ FsBlockEditorComponent,
1513
+ FsBlockEditorSidebarPanelDirective,
1514
+ ],
1515
+ declarations: [
1516
+ FsBlockComponent,
1517
+ FsBlockEditorComponent,
1518
+ FsBlockEditorSidebarPanelDirective,
1519
+ FsBlockEditorMarginDirective,
1520
+ SidebarComponent,
1521
+ ArtboardComponent,
1522
+ LayersReorderDialogComponent,
1523
+ FontComponent,
1524
+ CreateImageUrlPipe,
1525
+ ],
1526
+ providers: [
1527
+ GoogleFontService,
1528
+ ]
1529
+ }]
1511
1530
  }] });
1512
1531
 
1513
- /**
1514
- * Generated bundle index. Do not edit.
1532
+ /**
1533
+ * Generated bundle index. Do not edit.
1515
1534
  */
1516
1535
 
1517
1536
  export { BlockType, BlockTypes, FsBlockComponent, FsBlockEditorComponent, FsBlockEditorModule, FsBlockEditorSidebarPanelDirective };