@firestitch/block-editor 12.1.7 → 12.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/app/components/artboard/artboard.component.d.ts +35 -35
  2. package/app/components/block/block.component.d.ts +58 -58
  3. package/app/components/block-editor/block-editor.component.d.ts +28 -28
  4. package/app/components/layers-reorder-dialog/layers-reorder-dialog.component.d.ts +15 -0
  5. package/app/components/sidebar/sidebar.component.d.ts +79 -76
  6. package/app/consts/block-formats.const.d.ts +6 -6
  7. package/app/consts/block-types.const.d.ts +12 -12
  8. package/app/consts/index.d.ts +2 -2
  9. package/app/directives/block-editor-margin.directive.d.ts +9 -9
  10. package/app/directives/block-editor-sidebar-panel.directive.d.ts +10 -10
  11. package/app/enums/block-format.enum.d.ts +6 -6
  12. package/app/enums/block-type.enum.d.ts +11 -11
  13. package/app/enums/index.d.ts +2 -2
  14. package/app/fs-block-editor.module.d.ts +31 -27
  15. package/app/interfaces/block-editor-config.d.ts +20 -20
  16. package/app/interfaces/block.d.ts +49 -48
  17. package/app/services/block-editor.service.d.ts +53 -54
  18. package/app/services/blocks-store.service.d.ts +34 -0
  19. package/app/services/index.d.ts +1 -1
  20. package/bundles/firestitch-block-editor.umd.js +1740 -1551
  21. package/bundles/firestitch-block-editor.umd.js.map +1 -1
  22. package/esm2015/app/components/artboard/artboard.component.js +129 -129
  23. package/esm2015/app/components/block/block.component.js +319 -317
  24. package/esm2015/app/components/block-editor/block-editor.component.js +86 -84
  25. package/esm2015/app/components/layers-reorder-dialog/layers-reorder-dialog.component.js +45 -0
  26. package/esm2015/app/components/sidebar/sidebar.component.js +251 -242
  27. package/esm2015/app/consts/block-formats.const.js +7 -7
  28. package/esm2015/app/consts/block-types.const.js +12 -12
  29. package/esm2015/app/consts/index.js +2 -2
  30. package/esm2015/app/directives/block-editor-margin.directive.js +18 -18
  31. package/esm2015/app/directives/block-editor-sidebar-panel.directive.js +20 -20
  32. package/esm2015/app/enums/block-format.enum.js +8 -8
  33. package/esm2015/app/enums/block-type.enum.js +12 -12
  34. package/esm2015/app/enums/index.js +2 -2
  35. package/esm2015/app/fs-block-editor.module.js +113 -98
  36. package/esm2015/app/interfaces/block-editor-config.js +1 -1
  37. package/esm2015/app/interfaces/block.js +2 -2
  38. package/esm2015/app/services/block-editor.service.js +165 -246
  39. package/esm2015/app/services/blocks-store.service.js +174 -0
  40. package/esm2015/app/services/index.js +1 -1
  41. package/esm2015/firestitch-block-editor.js +4 -4
  42. package/esm2015/public_api.js +6 -6
  43. package/fesm2015/firestitch-block-editor.js +1247 -1101
  44. package/fesm2015/firestitch-block-editor.js.map +1 -1
  45. package/firestitch-block-editor.d.ts +5 -5
  46. package/package.json +1 -1
  47. package/public_api.d.ts +8 -8
@@ -3,1142 +3,1288 @@ import { FormsModule } from '@angular/forms';
3
3
  import * as i13 from '@angular/material/input';
4
4
  import { MatInputModule } from '@angular/material/input';
5
5
  import * as i0 from '@angular/core';
6
- import { Injectable, Component, ChangeDetectionStrategy, ViewChild, Input, HostBinding, Directive, EventEmitter, ContentChildren, Output, ViewChildren, ElementRef, NgModule } from '@angular/core';
6
+ import { Injectable, Component, Inject, ChangeDetectionStrategy, ViewChild, Input, HostBinding, Directive, EventEmitter, ContentChildren, Output, ViewChildren, ElementRef, NgModule } from '@angular/core';
7
7
  import * as i11 from '@angular/common';
8
- import { CommonModule } from '@angular/common';
9
- import * as i4 from '@angular/material/button';
8
+ import { DOCUMENT, CommonModule } from '@angular/common';
9
+ import * as i6 from '@angular/material/button';
10
10
  import { MatButtonModule } from '@angular/material/button';
11
- import * as i6 from '@angular/material/form-field';
11
+ import * as i6$1 from '@angular/material/form-field';
12
12
  import { MatFormFieldModule } from '@angular/material/form-field';
13
- import * as i5 from '@angular/material/icon';
13
+ import * as i3 from '@angular/material/icon';
14
14
  import { MatIconModule } from '@angular/material/icon';
15
+ import * as i9 from '@angular/material/checkbox';
16
+ import { MatCheckboxModule } from '@angular/material/checkbox';
17
+ import * as i12 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
+ import * as i4 from '@angular/material/list';
22
+ import { MatListModule } from '@angular/material/list';
23
+ import * as i7 from '@angular/cdk/drag-drop';
24
+ import { moveItemInArray, DragDropModule } from '@angular/cdk/drag-drop';
15
25
  import * as i10 from '@firestitch/colorpicker';
16
26
  import { FsColorPickerModule } from '@firestitch/colorpicker';
17
- import * as i3 from '@firestitch/file';
27
+ import * as i3$1 from '@firestitch/file';
18
28
  import { FsFileModule } from '@firestitch/file';
19
29
  import { FsMenuModule } from '@firestitch/menu';
20
- import * as i2$1 from '@firestitch/zoom-pan';
30
+ import * as i2$2 from '@firestitch/zoom-pan';
21
31
  import { FsZoomPanComponent, FsZoomPanModule } from '@firestitch/zoom-pan';
22
- import { takeUntil, filter, switchMap, delay } from 'rxjs/operators';
32
+ import * as i2 from '@firestitch/dialog';
33
+ import { FsDialogModule } from '@firestitch/dialog';
34
+ import { filter, map, takeUntil, switchMap, delay } from 'rxjs/operators';
23
35
  import Moveable from 'moveable';
24
36
  import { Subject, BehaviorSubject, fromEvent } from 'rxjs';
25
37
  import { guid, index } from '@firestitch/common';
26
- import * as i2 from '@firestitch/prompt';
27
- import * as i7 from '@angular/material/select';
28
- import { MatSelectModule } from '@angular/material/select';
38
+ import * as i1 from '@angular/material/dialog';
39
+ import { MAT_DIALOG_DATA } from '@angular/material/dialog';
40
+ import * as i5 from '@angular/material/divider';
41
+ import * as i2$1 from '@firestitch/prompt';
29
42
  import * as i8 from '@angular/material/core';
30
- import * as i9 from '@angular/material/checkbox';
31
- import { MatCheckboxModule } from '@angular/material/checkbox';
32
- import * as i12 from '@angular/material/tooltip';
33
- import { MatTooltipModule } from '@angular/material/tooltip';
34
43
 
35
- var BlockType;
36
- (function (BlockType) {
37
- BlockType["Rectangle"] = "rectangle";
38
- BlockType["ShortText"] = "shorttext";
39
- BlockType["LongText"] = "longtext";
40
- BlockType["Image"] = "image";
41
- BlockType["RadioButton"] = "radiobutton";
42
- BlockType["Checkbox"] = "checkbox";
43
- BlockType["Signature"] = "signature";
44
- BlockType["Pdf"] = "pdf";
45
- BlockType["Date"] = "date";
44
+ var BlockType;
45
+ (function (BlockType) {
46
+ BlockType["Rectangle"] = "rectangle";
47
+ BlockType["ShortText"] = "shorttext";
48
+ BlockType["LongText"] = "longtext";
49
+ BlockType["Image"] = "image";
50
+ BlockType["RadioButton"] = "radiobutton";
51
+ BlockType["Checkbox"] = "checkbox";
52
+ BlockType["Signature"] = "signature";
53
+ BlockType["Pdf"] = "pdf";
54
+ BlockType["Date"] = "date";
46
55
  })(BlockType || (BlockType = {}));
47
56
 
48
- var BlockFormat;
49
- (function (BlockFormat) {
50
- BlockFormat["Date"] = "date";
51
- BlockFormat["YYYYMMDD"] = "yyyy/MM/dd";
52
- BlockFormat["Currency"] = "currency";
53
- BlockFormat["Number"] = "number";
57
+ var EventType;
58
+ (function (EventType) {
59
+ EventType["Add"] = "add";
60
+ EventType["Change"] = "change";
61
+ EventType["Remove"] = "remove";
62
+ })(EventType || (EventType = {}));
63
+ class BlocksStore {
64
+ constructor() {
65
+ this._lastTabIndex = -1;
66
+ this._eventBus$ = new Subject();
67
+ this._blocks$ = new BehaviorSubject([]);
68
+ this._destroy$ = new Subject();
69
+ }
70
+ get blocks() {
71
+ return [
72
+ ...this._blocks$.getValue(),
73
+ ];
74
+ }
75
+ get blocks$() {
76
+ return this._blocks$.asObservable();
77
+ }
78
+ get blockAdded$() {
79
+ return this._eventBus$
80
+ .pipe(filter(({ type }) => type === EventType.Add), map(({ value }) => value));
81
+ }
82
+ get blockChanged$() {
83
+ return this._eventBus$
84
+ .pipe(filter(({ type }) => type === EventType.Change), map(({ value }) => value));
85
+ }
86
+ get blockRemoved$() {
87
+ return this._eventBus$
88
+ .pipe(filter(({ type }) => type === EventType.Remove), map(({ value }) => value));
89
+ }
90
+ ngOnDestroy() {
91
+ this._destroy$.next();
92
+ this._destroy$.complete();
93
+ }
94
+ init(config) {
95
+ this._config = config;
96
+ this._setBlocks(this._config.blocks);
97
+ }
98
+ blockExists(block) {
99
+ const index = this.blocks.findIndex((b) => {
100
+ return b.guid === block.guid;
101
+ });
102
+ return index !== -1;
103
+ }
104
+ blockAdd(block, initBlock = false) {
105
+ if (!this._config.blockAdd) {
106
+ console.warn('[BlockEditor] Config "blockAdd" is not defined');
107
+ return;
108
+ }
109
+ if (initBlock) {
110
+ block = this._createBlock(block);
111
+ }
112
+ this._config.blockAdd(block)
113
+ .pipe(takeUntil(this._destroy$))
114
+ .subscribe((newBlock) => {
115
+ this._appendBlock(newBlock);
116
+ });
117
+ }
118
+ blockUpload(block, fsFile, initBlock = false) {
119
+ if (!this._config.blockUpload) {
120
+ console.warn('[BlockEditor] Config "blockUpload" is not defined');
121
+ return;
122
+ }
123
+ if (initBlock) {
124
+ block = this._createBlock(block);
125
+ }
126
+ this._config.blockUpload(block, fsFile.file)
127
+ .pipe(takeUntil(this._destroy$))
128
+ .subscribe((newBlock) => {
129
+ this._appendBlock(newBlock);
130
+ });
131
+ }
132
+ blockChange(block) {
133
+ if (this._config.blockChanged) {
134
+ this._config.blockChanged(block);
135
+ }
136
+ this._dispatchEvent(EventType.Change, block);
137
+ }
138
+ blockRemove(targetBlocks) {
139
+ const blocks = this.blocks;
140
+ if (!Array.isArray(targetBlocks)) {
141
+ targetBlocks = [targetBlocks];
142
+ }
143
+ targetBlocks.forEach((block) => {
144
+ const index = blocks
145
+ .findIndex((b) => b.guid === block.guid);
146
+ if (index !== -1) {
147
+ blocks.splice(index, 1);
148
+ this._dispatchEvent(EventType.Remove, block);
149
+ }
150
+ });
151
+ this._setBlocks(blocks);
152
+ }
153
+ isReordableBlock(block) {
154
+ return [
155
+ BlockType.LongText,
156
+ BlockType.ShortText,
157
+ BlockType.RadioButton,
158
+ BlockType.Checkbox,
159
+ BlockType.Date,
160
+ BlockType.Signature,
161
+ ].indexOf(block.type) > -1;
162
+ }
163
+ updateTabIndex(index) {
164
+ this._lastTabIndex = index;
165
+ }
166
+ _setBlocks(blocks) {
167
+ this._blocks$.next([...blocks]);
168
+ blocks
169
+ .filter((b) => this.isReordableBlock(b))
170
+ .forEach((b) => {
171
+ this._lastTabIndex = Math.max(b.tabIndex, this._lastTabIndex);
172
+ });
173
+ }
174
+ _appendBlock(block) {
175
+ const blocks = [
176
+ ...this.blocks,
177
+ block,
178
+ ];
179
+ this._deduplicateIndexesFor(blocks);
180
+ this._setBlocks(blocks);
181
+ this._dispatchEvent(EventType.Add, block);
182
+ }
183
+ _dispatchEvent(type, value) {
184
+ this._eventBus$.next({
185
+ type,
186
+ value,
187
+ });
188
+ }
189
+ _createBlock(block) {
190
+ const newBlock = Object.assign(Object.assign({ shapeBottomLeft: 'round', shapeTopLeft: 'round', shapeTopRight: 'round', shapeBottomRight: 'round', verticalAlign: 'top', horizontalAlign: 'left' }, block), { guid: block.guid || guid('xxxxxxxxxxxx') });
191
+ let width = (this._config.width * .333).toFixed(2);
192
+ let height = width / 2;
193
+ if (newBlock.type === BlockType.Rectangle) {
194
+ newBlock.borderColor = '#cccccc';
195
+ newBlock.borderWidth = 1;
196
+ }
197
+ else if (newBlock.type === BlockType.Checkbox || newBlock.type === BlockType.RadioButton) {
198
+ width = .25;
199
+ height = .25;
200
+ newBlock.keepRatio = true;
201
+ }
202
+ else {
203
+ width = 2;
204
+ height = .5;
205
+ }
206
+ if (this.isReordableBlock(newBlock)) {
207
+ newBlock.tabIndex = this._lastTabIndex + 1;
208
+ this.updateTabIndex(newBlock.tabIndex);
209
+ }
210
+ return Object.assign({ top: height, left: width, width,
211
+ height }, newBlock);
212
+ }
213
+ _deduplicateIndexesFor(blocks) {
214
+ blocks.forEach((block, index) => {
215
+ block.index = index;
216
+ });
217
+ }
218
+ }
219
+ BlocksStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlocksStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
220
+ BlocksStore.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlocksStore });
221
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlocksStore, decorators: [{
222
+ type: Injectable
223
+ }] });
224
+
225
+ var BlockFormat;
226
+ (function (BlockFormat) {
227
+ BlockFormat["Date"] = "date";
228
+ BlockFormat["YYYYMMDD"] = "YYYY/MM/DD";
229
+ BlockFormat["Currency"] = "currency";
230
+ BlockFormat["Number"] = "number";
54
231
  })(BlockFormat || (BlockFormat = {}));
55
232
 
56
- class BlockEditorService {
57
- constructor() {
58
- this._blockChanged$ = new Subject();
59
- this._blockRemoved$ = new Subject();
60
- this._blockAdded$ = new Subject();
61
- this._blocks$ = new BehaviorSubject([]);
62
- this._selectedBlocks$ = new BehaviorSubject([]);
63
- this._blockComponents = new Map();
64
- this._destroy$ = new Subject();
65
- }
66
- get elementGuidelines() {
67
- return [
68
- ...Array.from(this._blockComponents.values())
69
- .map((block) => {
70
- return block.el;
71
- }),
72
- this.container,
73
- this.margin,
74
- ];
75
- }
76
- get blockComponents() {
77
- return Array.from(this._blockComponents.values());
78
- }
79
- get selectedComponentBlocks() {
80
- return this.blockComponents
81
- .filter((blockComponent) => this.selectedBlocks.indexOf(blockComponent.block) !== -1);
82
- }
83
- blockUpload(block, fsFile) {
84
- if (this.config.blockUpload) {
85
- this.config.blockUpload(block, fsFile.file)
86
- .pipe(takeUntil(this._destroy$))
87
- .subscribe((block) => {
88
- const blocks = [
89
- ...this.blocks,
90
- block,
91
- ];
92
- this.blocks = this._updateIndexesFor(blocks);
93
- this._blockAdded$.next(block);
94
- if (this.config.blockAdded) {
95
- this.config.blockAdded(block);
96
- }
97
- //this._updateIndexes();
98
- });
99
- }
100
- }
101
- blockAdd(block) {
102
- if (this.config.blockAdd) {
103
- this.config.blockAdd(block)
104
- .pipe(takeUntil(this._destroy$))
105
- .subscribe((block) => {
106
- const blocks = [
107
- ...this.blocks,
108
- block,
109
- ];
110
- this.blocks = this._updateIndexesFor(blocks);
111
- this._blockAdded$.next(block);
112
- if (this.config.blockAdded) {
113
- this.config.blockAdded(block);
114
- }
115
- //this._updateIndexes();
116
- });
117
- }
118
- }
119
- _updateIndexesFor(blocks) {
120
- blocks.forEach((block, index) => {
121
- block.index = index;
122
- });
123
- return blocks;
124
- }
125
- // private _updateIndexes(): void {
126
- // const sort = this.blocks.slice().sort((a, b) => {
127
- // return a.index > b.index ? 1 : -1;
128
- // })
129
- // sort.forEach((block, index) => {
130
- // this.blocks.find((item) => {
131
- // return block.reference === item.reference;
132
- // }).index = index;
133
- // });
134
- // }
135
- removeBlock(block) {
136
- const index = this.indexOf(block);
137
- if (index !== -1) {
138
- const blocks = this.blocks;
139
- blocks.splice(index, 1);
140
- this.blocks = blocks;
141
- this._blockRemoved$.next(block);
142
- }
143
- }
144
- removeSelectedBlocks() {
145
- this.selectedBlocks.forEach((block) => {
146
- this.removeBlock(block);
147
- });
148
- this.selectedBlocks = [];
149
- }
150
- get blocks$() {
151
- return this._blocks$;
152
- }
153
- get blockChanged$() {
154
- return this._blockChanged$;
155
- }
156
- get blockRemoved$() {
157
- return this._blockRemoved$;
158
- }
159
- get blockAdded$() {
160
- return this._blockAdded$;
161
- }
162
- blockChange(block) {
163
- this._blockChanged$.next(block);
164
- if (this.config.blockChanged) {
165
- this.config.blockChanged(block);
166
- }
167
- }
168
- get blocks() {
169
- return this._blocks$.getValue();
170
- }
171
- set blocks(blocks) {
172
- this._blocks$.next(blocks);
173
- }
174
- isSelectedBlock(block) {
175
- return this.selectedBlocks.indexOf(block.block) !== -1;
176
- }
177
- indexOf(block) {
178
- return this.blocks.map((e) => e.guid).indexOf(block.guid);
179
- }
180
- selectedBlockComponentChangeProperty(value, name) {
181
- if (name === 'index') {
182
- const blocks = this.blocks;
183
- const affectedGUIDs = this.selectedBlocks.map((block) => block.guid);
184
- blocks.forEach((block, index) => {
185
- const guidIndex = affectedGUIDs.indexOf(block.guid);
186
- if (guidIndex !== -1) {
187
- blocks.splice(index, 1);
188
- blocks.splice(+value, 0, block);
189
- block.index = +value;
190
- this.blockChange(block);
191
- }
192
- });
193
- this._updateIndexesFor(blocks);
194
- }
195
- else {
196
- this.selectedBlocks
197
- .forEach((block) => {
198
- block[name] = value;
199
- this.blockChange(block);
200
- });
201
- }
202
- }
203
- get selectedBlocks$() {
204
- return this._selectedBlocks$;
205
- }
206
- set selectedBlock(block) {
207
- this.selectedBlocks = [block];
208
- }
209
- set selectedBlocks(blocks) {
210
- this.blockComponents
211
- .forEach((blockComponent) => {
212
- blockComponent.editable = false;
213
- if (blocks.indexOf(blockComponent.block) !== -1) {
214
- blockComponent.transformable = true;
215
- }
216
- else {
217
- blockComponent.deselect();
218
- }
219
- });
220
- this._selectedBlocks$.next(blocks);
221
- if (this.config.blocksSelected) {
222
- this.config.blocksSelected(blocks);
223
- }
224
- }
225
- get selectedBlocks() {
226
- return this._selectedBlocks$.getValue();
227
- }
228
- saveSelection() {
229
- const selection = window.getSelection();
230
- this._selectionRange = selection.getRangeAt(0);
231
- }
232
- restoreSelection() {
233
- if (this._selectionRange) {
234
- const selection = window.getSelection();
235
- selection.removeAllRanges();
236
- selection.addRange(this._selectionRange);
237
- }
238
- }
239
- hasSelectionRange() {
240
- return this._selectionRange && (this._selectionRange.baseOffset - this._selectionRange.focusOffset) > 0;
241
- }
242
- registerBlock(block, blockComponent) {
243
- this._blockComponents.set(block, blockComponent);
244
- this.blockComponents.push(block);
245
- // Disabled for now
246
- // this.blockComponents.forEach((blockComponent: FsBlockComponent) => {
247
- // const blocks = this.elementGuidelines
248
- // .filter((el) => {
249
- // return !el.isSameNode(blockComponent.el);
250
- // });
251
- // blockComponent.elementGuidelines = blocks;
252
- // });
253
- }
254
- unregisterBlock(block) {
255
- this._blockComponents.delete(block);
256
- }
257
- registerContainer(container) {
258
- this.container = container;
259
- }
260
- registerMargin(margin) {
261
- this.margin = margin;
262
- }
263
- sanitizeNewBlock(block) {
264
- let width = (this.config.width * .333).toFixed(2);
265
- let height = width / 2;
266
- if (block.type === BlockType.Rectangle) {
267
- block.borderColor = '#cccccc';
268
- block.borderWidth = 1;
269
- }
270
- else if (block.type === BlockType.Checkbox || block.type === BlockType.RadioButton) {
271
- width = .25;
272
- height = .25;
273
- block.keepRatio = true;
274
- }
275
- else {
276
- width = 2;
277
- height = .5;
278
- }
279
- return this.sanitizeBlock(Object.assign({ top: height, left: width, width,
280
- height }, block));
281
- }
282
- sanitizeBlock(block) {
283
- return Object.assign(Object.assign({ shapeBottomLeft: 'round', shapeTopLeft: 'round', shapeTopRight: 'round', shapeBottomRight: 'round', verticalAlign: 'top', horizontalAlign: 'left' }, block), { guid: block.guid || guid('xxxxxxxxxxxx') });
284
- }
285
- ngOnDestroy() {
286
- this._destroy$.next();
287
- this._destroy$.complete();
288
- }
289
- }
290
- BlockEditorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
291
- BlockEditorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService });
292
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService, decorators: [{
293
- type: Injectable
294
- }] });
233
+ const BlockTypes = [
234
+ { value: BlockType.Rectangle, name: 'Rectangle', icon: 'crop_5_4' },
235
+ { value: BlockType.ShortText, name: 'Short Text', icon: 'short_text' },
236
+ { value: BlockType.LongText, name: 'Long Text', icon: 'subject' },
237
+ { value: BlockType.RadioButton, name: 'Radio Button', icon: 'radio_button_checked' },
238
+ { value: BlockType.Checkbox, name: 'Checkbox', icon: 'check_box' },
239
+ { value: BlockType.Date, name: 'Date', icon: 'calendar_today' },
240
+ { value: BlockType.Signature, name: 'Signature', icon: 'draw' },
241
+ { value: BlockType.Image, name: 'Image', icon: 'image', accept: 'image/*' },
242
+ { value: BlockType.Pdf, name: 'Pdf', icon: 'picture_as_pdf', accept: 'application/pdf' },
243
+ ];
295
244
 
296
- class FsBlockComponent {
297
- constructor(_blockEditor, _elementRef, _cdRef) {
298
- this._blockEditor = _blockEditor;
299
- this._elementRef = _elementRef;
300
- this._cdRef = _cdRef;
301
- this.transformating = false;
302
- this.BlockType = BlockType;
303
- this._editable = false;
304
- this._transformable = false;
305
- this._destroy$ = new Subject();
306
- }
307
- get el() {
308
- return this.element.nativeElement;
309
- }
310
- get moveable() {
311
- return this._moveable;
312
- }
313
- get editable() {
314
- return this._editable;
315
- }
316
- set elementGuidelines(value) {
317
- this.moveable.elementGuidelines = value;
318
- }
319
- set editable(value) {
320
- this._editable = value;
321
- if (!value) {
322
- this.deselectContent();
323
- }
324
- }
325
- set clippable(value) {
326
- this.moveable.clippable = value;
327
- }
328
- get transformable() {
329
- return this._transformable;
330
- }
331
- set transformable(value) {
332
- this._transformable = value;
333
- this.moveable.draggable = value;
334
- this.moveable.resizable = value;
335
- this.moveable.roundable = value;
336
- this.moveable.rotatable = value;
337
- }
338
- set width(value) {
339
- this.element.nativeElement.style.width = `${parseFloat(value)}${this.unit}`;
340
- this.moveable.updateRect();
341
- }
342
- set height(value) {
343
- this.element.nativeElement.style.height = `${parseFloat(value)}${this.unit}`;
344
- this.moveable.updateRect();
345
- }
346
- set top(value) {
347
- this.element.nativeElement.style.top = `${parseFloat(value)}${this.unit}`;
348
- this.moveable.updateRect();
349
- }
350
- set left(value) {
351
- this.element.nativeElement.style.left = `${parseFloat(value)}${this.unit}`;
352
- this.moveable.updateRect();
353
- }
354
- set rotate(value) {
355
- this.moveable.request('rotatable', { rotate: parseFloat(value) }, true);
356
- this.moveable.updateRect();
357
- }
358
- set index(value) {
359
- this.block.index = value;
360
- }
361
- set keepRatio(value) {
362
- this.moveable.keepRatio = value;
363
- }
364
- markForCheck() {
365
- this._cdRef.markForCheck();
366
- }
367
- ngOnInit() {
368
- this.unit = this._blockEditor.config.unit;
369
- this.content = this.block.content;
370
- this._blockEditor.blockChanged$
371
- .pipe(filter((block) => block === this.block), takeUntil(this._destroy$))
372
- .subscribe((block) => {
373
- this.keepRatio = block.keepRatio;
374
- this.width = block.width;
375
- this.height = block.height;
376
- this.top = block.top;
377
- this.left = block.left;
378
- this._cdRef.markForCheck();
379
- });
380
- }
381
- ngAfterContentInit() {
382
- setTimeout(() => {
383
- this._initEvents();
384
- this._initMoveable();
385
- this._setTransform();
386
- this.width = this.block.width;
387
- this.height = this.block.height;
388
- this.top = this.block.top;
389
- this.left = this.block.left;
390
- this._blockEditor.registerBlock(this.block, this);
391
- });
392
- }
393
- pxToIn(px) {
394
- return this.round(px / 96, 2);
395
- }
396
- round(value, decimals) {
397
- return parseFloat(value.toFixed(decimals));
398
- }
399
- deselect() {
400
- this.transformable = false;
401
- this.editable = false;
402
- }
403
- deselectContent() {
404
- if (window.getSelection) {
405
- if (window.getSelection().empty) {
406
- window.getSelection().empty();
407
- }
408
- else if (window.getSelection().removeAllRanges) {
409
- window.getSelection().removeAllRanges();
410
- }
411
- }
412
- }
413
- selectAll() {
414
- const range = document.createRange();
415
- range.selectNodeContents(this.contentEditable.nativeElement);
416
- const sel = window.getSelection();
417
- sel.removeAllRanges();
418
- sel.addRange(range);
419
- }
420
- ngOnDestroy() {
421
- this._blockEditor.unregisterBlock(this.block);
422
- this._destroy$.next();
423
- this._destroy$.complete();
424
- }
425
- _setTransform(transforms = []) {
426
- transforms = transforms !== null && transforms !== void 0 ? transforms : [];
427
- if (this.block.rotate) {
428
- transforms.push(`rotate(${this.block.rotate}deg)`);
429
- }
430
- this.el.style.transform = transforms.join(' ');
431
- }
432
- _triggerChanged() {
433
- this._blockEditor.blockChange(this.block);
434
- }
435
- _initMoveable() {
436
- this._moveable = new Moveable(this._elementRef.nativeElement, {
437
- target: this.el,
438
- container: this._blockEditor.container,
439
- draggable: false,
440
- resizable: false,
441
- scalable: false,
442
- rotatable: false,
443
- warpable: false,
444
- origin: false,
445
- keepRatio: this.block.keepRatio,
446
- snappable: true,
447
- edge: false,
448
- throttleDrag: 1,
449
- throttleScale: 0.01,
450
- throttleRotate: 1,
451
- throttleResize: 1,
452
- });
453
- this.moveable
454
- .on('clip', (e) => {
455
- this.block.clipPath = e.clipStyle;
456
- e.target.style.clipPath = e.clipStyle;
457
- this._triggerChanged();
458
- });
459
- this.moveable
460
- .on('dragStart', () => {
461
- this.editable = false;
462
- this.transformating = true;
463
- this._cdRef.markForCheck();
464
- })
465
- .on('drag', ({ target, left, top }) => {
466
- target.style.left = this.pxToIn(left) + this.unit;
467
- target.style.top = this.pxToIn(top) + this.unit;
468
- this.block.top = this.pxToIn(top);
469
- this.block.left = this.pxToIn(left);
470
- this._triggerChanged();
471
- })
472
- .on('dragEnd', () => {
473
- this.transformating = false;
474
- this._cdRef.markForCheck();
475
- })
476
- .on('resizeStart', () => {
477
- this.editable = false;
478
- this.zoompan.disable();
479
- this.transformating = true;
480
- this._cdRef.markForCheck();
481
- })
482
- .on('resize', ({ target, width, height, dist, delta, direction }) => {
483
- width = this.pxToIn(width);
484
- height = this.pxToIn(height);
485
- if (delta[0]) {
486
- this.block.width = width;
487
- target.style.width = width + this.unit;
488
- }
489
- if (delta[1]) {
490
- this.block.height = height;
491
- target.style.height = height + this.unit;
492
- }
493
- const transform = [0, 0];
494
- if (direction[1] === -1) {
495
- transform[1] = dist[1] * -1;
496
- }
497
- if (direction[0] === -1) {
498
- transform[0] = dist[0] * -1;
499
- }
500
- this._setTransform([`translate(${transform[0]}px, ${transform[1]}px)`]);
501
- this._triggerChanged();
502
- })
503
- .on('resizeEnd', ({ target }) => {
504
- const matrix = new WebKitCSSMatrix(target.style.transform);
505
- this.block.top = parseFloat(target.style.top) + this.pxToIn(matrix.m42);
506
- this.block.left = parseFloat(target.style.left) + this.pxToIn(matrix.m41);
507
- target.style.top = this.block.top + this.unit;
508
- target.style.left = this.block.left + this.unit;
509
- this._setTransform();
510
- this._triggerChanged();
511
- this.zoompan.enable();
512
- this.transformating = false;
513
- this._cdRef.markForCheck();
514
- })
515
- .on('rotateStart', () => {
516
- this.zoompan.disable();
517
- this.editable = false;
518
- this._rotateStart = this.block.rotate || 0;
519
- this.transformating = true;
520
- this._cdRef.markForCheck();
521
- })
522
- .on('rotate', ({ rotate, transform }) => {
523
- this.block.rotate = this._rotateStart + rotate;
524
- this.el.style.transform = transform;
525
- this._triggerChanged();
526
- this.zoompan.enable();
527
- })
528
- .on('rotateEnd', () => {
529
- this.transformating = false;
530
- this._cdRef.markForCheck();
531
- });
532
- }
533
- _initEvents() {
534
- fromEvent(this.contentEditable.nativeElement, 'input')
535
- .pipe(takeUntil(this._destroy$)).subscribe((event) => {
536
- this.block.content = event.target.innerHTML;
537
- this._triggerChanged();
538
- });
539
- fromEvent(this.el, 'mousedown')
540
- .pipe(takeUntil(this._destroy$), filter(() => !this.block.readonly)).subscribe((event) => {
541
- this.zoompan.disable();
542
- if (this.editable) {
543
- if (this.contentElement.nativeElement.isSameNode(event.target)) {
544
- event.preventDefault();
545
- event.stopImmediatePropagation();
546
- event.stopPropagation();
547
- }
548
- }
549
- else {
550
- this._blockEditor.selectedBlock = this.block;
551
- }
552
- });
553
- fromEvent(this.el, 'mouseup')
554
- .pipe(takeUntil(this._destroy$), filter(() => !this.block.readonly)).subscribe(() => {
555
- this.zoompan.enable();
556
- });
557
- fromEvent(this.el, 'dblclick')
558
- .pipe(filter(() => (!this.editable)), takeUntil(this._destroy$))
559
- .subscribe((event) => {
560
- if (this.block.readonly) {
561
- event.preventDefault();
562
- }
563
- else {
564
- this.editable = true;
565
- this._cdRef.markForCheck();
566
- setTimeout(() => {
567
- this.selectAll();
568
- });
569
- }
570
- });
571
- }
572
- }
573
- 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 }], target: i0.ɵɵFactoryTarget.Component });
574
- 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 [ngClass]=\"{ \n editable: editable, \n readonly: block.readonly,\n required: block.required\n }\">\n <div\n #contentElement\n class=\"content\"\n [style.zIndex]=\"block.index\"\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.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 + unit : ''\"\n [style.paddingBottom]=\"block.paddingBottom ? block.paddingBottom + unit : ''\"\n [style.paddingLeft]=\"block.paddingLeft ? block.paddingLeft + unit : ''\"\n [style.paddingRight]=\"block.paddingRight ? block.paddingRight + unit : ''\"\n [style.padding]=\"block.padding ? block.padding + unit : ''\"\n [style.clipPath]=\"block.clipPath\"\n [style.backgroundColor]=\"block.backgroundColor\"\n [style.borderBottomLeftRadius]=\"block.shapeRadius && block.shapeBottomLeft === 'round' ? block.shapeRadius + unit : ''\"\n [style.borderBottomRightRadius]=\"block.shapeRadius && block.shapeBottomRight === 'round' ? block.shapeRadius + unit : ''\"\n [style.borderTopRightRadius]=\"block.shapeRadius && block.shapeTopRight === 'round' ? block.shapeRadius + unit : ''\"\n [style.borderTopLeftRadius]=\"block.shapeRadius && block.shapeTopLeft === 'round' ? block.shapeRadius + unit : ''\"\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 *ngSwitchCase=\"BlockType.Pdf\">\n <img [src]=\"block.imageUrl\">\n </ng-container>\n <img [src]=\"block.imageUrl\" *ngIf=\"block.imageUrl\">\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>\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}.block:not(.readonly){cursor:pointer}.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}.block.editable .content-editable{cursor:text}.block .content{flex-direction:column;height:100%;display:flex;border:1px 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}: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: i11.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i11.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i11.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
575
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockComponent, decorators: [{
576
- type: Component,
577
- args: [{
578
- selector: 'fs-block',
579
- templateUrl: 'block.component.html',
580
- styleUrls: ['block.component.scss'],
581
- changeDetection: ChangeDetectionStrategy.OnPush,
582
- }]
583
- }], ctorParameters: function () { return [{ type: BlockEditorService }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { element: [{
584
- type: ViewChild,
585
- args: ['element', { static: true }]
586
- }], contentElement: [{
587
- type: ViewChild,
588
- args: ['contentElement', { static: true }]
589
- }], contentEditable: [{
590
- type: ViewChild,
591
- args: ['contentEditable', { static: true }]
592
- }], block: [{
593
- type: Input
594
- }], html: [{
595
- type: Input
596
- }], zoompan: [{
597
- type: Input
598
- }], transformating: [{
599
- type: HostBinding,
600
- args: ['class.transforming']
601
- }] } });
245
+ class LayersReorderDialogComponent {
246
+ constructor(_dialogData, _dialogRef) {
247
+ this._dialogRef = _dialogRef;
248
+ this.blockTypeIcons = index(BlockTypes, 'value', 'icon');
249
+ this._init(_dialogData);
250
+ }
251
+ swapItems(event) {
252
+ moveItemInArray(this.fields, event.previousIndex, event.currentIndex);
253
+ }
254
+ done() {
255
+ this._dialogRef.close(this.fields);
256
+ }
257
+ _init(data) {
258
+ this.fields = data.fields;
259
+ }
260
+ }
261
+ 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 });
262
+ 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 field of fields\">\n <mat-list-item cdkDrag cdkDragLockAxis=\"y\">\n <mat-icon cdkDragHandle>drag_handle</mat-icon>\n <mat-icon>\n {{ blockTypeIcons[field.block.type] }}\n </mat-icon>\n <span class=\"block-label\">\n {{ field.block.label || 'no label' }}\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}.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: i11.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]" }] });
263
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LayersReorderDialogComponent, decorators: [{
264
+ type: Component,
265
+ args: [{
266
+ templateUrl: './layers-reorder-dialog.component.html',
267
+ styleUrls: [
268
+ './layers-reorder-dialog.component.scss',
269
+ ]
270
+ }]
271
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
272
+ type: Inject,
273
+ args: [MAT_DIALOG_DATA]
274
+ }] }, { type: i1.MatDialogRef }]; } });
275
+
276
+ class BlockEditorService {
277
+ constructor(_store, _dialog) {
278
+ this._store = _store;
279
+ this._dialog = _dialog;
280
+ this._selectedBlocks$ = new BehaviorSubject([]);
281
+ this._blockComponents = new Map();
282
+ this._destroy$ = new Subject();
283
+ }
284
+ get blockComponents() {
285
+ return Array.from(this._blockComponents.values());
286
+ }
287
+ get selectedComponentBlocks() {
288
+ return this.blockComponents
289
+ .filter((blockComponent) => this.selectedBlocks.indexOf(blockComponent.block) !== -1);
290
+ }
291
+ init(config) {
292
+ this.config = config;
293
+ this._store.init(Object.assign({}, this.config));
294
+ }
295
+ blockAdd(block, newBlock = false) {
296
+ this._store.blockAdd(block, newBlock);
297
+ }
298
+ blockUpload(block, fsFile, newBlock = false) {
299
+ this._store.blockUpload(block, fsFile, false);
300
+ }
301
+ _updateIndexesFor(blocks) {
302
+ blocks.forEach((block, index) => {
303
+ block.index = index;
304
+ });
305
+ return blocks;
306
+ }
307
+ blockRemove(block) {
308
+ this._store.blockRemove(block);
309
+ }
310
+ removeSelectedBlocks() {
311
+ this.selectedBlocks
312
+ .forEach((block) => {
313
+ this.blockRemove(block);
314
+ });
315
+ this.selectedBlocks = [];
316
+ }
317
+ get blocks$() {
318
+ return this._store.blocks$;
319
+ }
320
+ get blockChanged$() {
321
+ return this._store.blockChanged$;
322
+ }
323
+ get blockAdded$() {
324
+ return this._store.blockAdded$;
325
+ }
326
+ get blockRemoved$() {
327
+ return this._store.blockRemoved$;
328
+ }
329
+ get blocks() {
330
+ return this._store.blocks;
331
+ }
332
+ blockChange(block) {
333
+ this._store.blockChange(block);
334
+ }
335
+ isSelectedBlock(block) {
336
+ return this.selectedBlocks.indexOf(block.block) !== -1;
337
+ }
338
+ indexOf(block) {
339
+ return this.blocks.map((e) => e.guid).indexOf(block.guid);
340
+ }
341
+ selectedBlockComponentChangeProperty(value, name) {
342
+ this.selectedBlocks
343
+ .forEach((block) => {
344
+ block[name] = value;
345
+ this.blockChange(block);
346
+ });
347
+ }
348
+ get selectedBlocks$() {
349
+ return this._selectedBlocks$;
350
+ }
351
+ set selectedBlock(block) {
352
+ this.selectedBlocks = [block];
353
+ }
354
+ set selectedBlocks(blocks) {
355
+ this.blockComponents
356
+ .forEach((blockComponent) => {
357
+ blockComponent.editable = false;
358
+ if (blocks.indexOf(blockComponent.block) !== -1) {
359
+ blockComponent.transformable = true;
360
+ }
361
+ else {
362
+ blockComponent.deselect();
363
+ }
364
+ });
365
+ this._selectedBlocks$.next(blocks);
366
+ if (this.config.blocksSelected) {
367
+ this.config.blocksSelected(blocks);
368
+ }
369
+ }
370
+ get selectedBlocks() {
371
+ return this._selectedBlocks$.getValue();
372
+ }
373
+ saveSelection() {
374
+ const selection = window.getSelection();
375
+ this._selectionRange = selection.getRangeAt(0);
376
+ }
377
+ restoreSelection() {
378
+ if (this._selectionRange) {
379
+ const selection = window.getSelection();
380
+ selection.removeAllRanges();
381
+ selection.addRange(this._selectionRange);
382
+ }
383
+ }
384
+ hasSelectionRange() {
385
+ return this._selectionRange && (this._selectionRange.baseOffset - this._selectionRange.focusOffset) > 0;
386
+ }
387
+ registerBlock(block, blockComponent) {
388
+ this._blockComponents.set(block, blockComponent);
389
+ this.blockComponents.push(block);
390
+ }
391
+ unregisterBlock(block) {
392
+ this._blockComponents.delete(block);
393
+ }
394
+ registerContainer(container) {
395
+ this.container = container;
396
+ }
397
+ registerMargin(margin) {
398
+ this.margin = margin;
399
+ }
400
+ openReorderDialog() {
401
+ const reordableFields = this.blockComponents
402
+ .filter((blockCmp) => {
403
+ return this._store.isReordableBlock(blockCmp.block);
404
+ });
405
+ this._dialog
406
+ .open(LayersReorderDialogComponent, {
407
+ data: {
408
+ fields: reordableFields,
409
+ }
410
+ })
411
+ .afterClosed()
412
+ .pipe(takeUntil(this._destroy$))
413
+ .subscribe((fields) => {
414
+ fields.forEach((blockCmp, index) => {
415
+ blockCmp.block.tabIndex = index;
416
+ this._store.blockChange(blockCmp.block);
417
+ this._store.updateTabIndex(index);
418
+ });
419
+ });
420
+ }
421
+ ngOnDestroy() {
422
+ this._destroy$.next();
423
+ this._destroy$.complete();
424
+ }
425
+ }
426
+ 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 });
427
+ BlockEditorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService });
428
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService, decorators: [{
429
+ type: Injectable
430
+ }], ctorParameters: function () { return [{ type: BlocksStore }, { type: i2.FsDialog }]; } });
602
431
 
603
- class FsBlockEditorSidebarPanelDirective {
604
- constructor(templateRef) {
605
- this.templateRef = templateRef;
606
- this.show = true;
607
- }
608
- }
609
- FsBlockEditorSidebarPanelDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorSidebarPanelDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
610
- FsBlockEditorSidebarPanelDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorSidebarPanelDirective, selector: "[fsBlockEditorSidebarPanel]", inputs: { label: "label", show: "show" }, ngImport: i0 });
611
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorSidebarPanelDirective, decorators: [{
612
- type: Directive,
613
- args: [{
614
- selector: '[fsBlockEditorSidebarPanel]'
615
- }]
616
- }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; }, propDecorators: { label: [{
617
- type: Input
618
- }], show: [{
619
- type: Input
432
+ class FsBlockComponent {
433
+ constructor(_blockEditor, _elementRef, _cdRef) {
434
+ this._blockEditor = _blockEditor;
435
+ this._elementRef = _elementRef;
436
+ this._cdRef = _cdRef;
437
+ this.transformating = false;
438
+ this.BlockType = BlockType;
439
+ this._editable = false;
440
+ this._transformable = false;
441
+ this._destroy$ = new Subject();
442
+ }
443
+ get el() {
444
+ return this.element.nativeElement;
445
+ }
446
+ get moveable() {
447
+ return this._moveable;
448
+ }
449
+ get editable() {
450
+ return this._editable;
451
+ }
452
+ set elementGuidelines(value) {
453
+ this.moveable.elementGuidelines = value;
454
+ }
455
+ set editable(value) {
456
+ this._editable = value;
457
+ if (!value) {
458
+ this.deselectContent();
459
+ }
460
+ }
461
+ set clippable(value) {
462
+ this.moveable.clippable = value;
463
+ }
464
+ get transformable() {
465
+ return this._transformable;
466
+ }
467
+ set transformable(value) {
468
+ this._transformable = value;
469
+ this.moveable.draggable = value;
470
+ this.moveable.resizable = value;
471
+ this.moveable.roundable = value;
472
+ this.moveable.rotatable = value;
473
+ }
474
+ set width(value) {
475
+ this.element.nativeElement.style.width = `${parseFloat(value)}${this.unit}`;
476
+ this.moveable.updateRect();
477
+ }
478
+ set height(value) {
479
+ this.element.nativeElement.style.height = `${parseFloat(value)}${this.unit}`;
480
+ this.moveable.updateRect();
481
+ }
482
+ set top(value) {
483
+ this.block.top = parseFloat(value);
484
+ this.element.nativeElement.style.top = `${this.block.top}${this.unit}`;
485
+ this.moveable.updateRect();
486
+ }
487
+ set left(value) {
488
+ this.block.left = parseFloat(value);
489
+ this.element.nativeElement.style.left = `${this.block.left}${this.unit}`;
490
+ this.moveable.updateRect();
491
+ }
492
+ set rotate(value) {
493
+ this.moveable.request('rotatable', { rotate: parseFloat(value) }, true);
494
+ this.moveable.updateRect();
495
+ }
496
+ set index(value) {
497
+ this.block.index = value;
498
+ }
499
+ set keepRatio(value) {
500
+ this.moveable.keepRatio = value;
501
+ }
502
+ markForCheck() {
503
+ this._cdRef.markForCheck();
504
+ }
505
+ ngOnInit() {
506
+ this.unit = this._blockEditor.config.unit;
507
+ this.content = this.block.content;
508
+ this._blockEditor.blockChanged$
509
+ .pipe(filter((block) => block === this.block), takeUntil(this._destroy$))
510
+ .subscribe((block) => {
511
+ this.keepRatio = block.keepRatio;
512
+ this.width = block.width;
513
+ this.height = block.height;
514
+ this.top = block.top;
515
+ this.left = block.left;
516
+ this._cdRef.markForCheck();
517
+ });
518
+ }
519
+ ngAfterContentInit() {
520
+ setTimeout(() => {
521
+ this._initEvents();
522
+ this._initMoveable();
523
+ this._setTransform();
524
+ this.width = this.block.width;
525
+ this.height = this.block.height;
526
+ this.top = this.block.top;
527
+ this.left = this.block.left;
528
+ this._blockEditor.registerBlock(this.block, this);
529
+ });
530
+ }
531
+ pxToIn(px) {
532
+ return this.round(px / 96, 2);
533
+ }
534
+ round(value, decimals) {
535
+ return parseFloat(value.toFixed(decimals));
536
+ }
537
+ deselect() {
538
+ this.transformable = false;
539
+ this.editable = false;
540
+ }
541
+ deselectContent() {
542
+ if (window.getSelection) {
543
+ if (window.getSelection().empty) {
544
+ window.getSelection().empty();
545
+ }
546
+ else if (window.getSelection().removeAllRanges) {
547
+ window.getSelection().removeAllRanges();
548
+ }
549
+ }
550
+ }
551
+ selectAll() {
552
+ const range = document.createRange();
553
+ range.selectNodeContents(this.contentEditable.nativeElement);
554
+ const sel = window.getSelection();
555
+ sel.removeAllRanges();
556
+ sel.addRange(range);
557
+ }
558
+ ngOnDestroy() {
559
+ this._blockEditor.unregisterBlock(this.block);
560
+ this._destroy$.next();
561
+ this._destroy$.complete();
562
+ }
563
+ _setTransform(transforms = []) {
564
+ transforms = transforms !== null && transforms !== void 0 ? transforms : [];
565
+ if (this.block.rotate) {
566
+ transforms.push(`rotate(${this.block.rotate}deg)`);
567
+ }
568
+ this.el.style.transform = transforms.join(' ');
569
+ }
570
+ _triggerChanged() {
571
+ this._blockEditor.blockChange(this.block);
572
+ }
573
+ _initMoveable() {
574
+ this._moveable = new Moveable(this._elementRef.nativeElement, {
575
+ target: this.el,
576
+ container: this._blockEditor.container,
577
+ draggable: false,
578
+ resizable: false,
579
+ scalable: false,
580
+ rotatable: false,
581
+ warpable: false,
582
+ origin: false,
583
+ keepRatio: this.block.keepRatio,
584
+ snappable: true,
585
+ edge: false,
586
+ throttleDrag: 1,
587
+ throttleScale: 0.01,
588
+ throttleRotate: 1,
589
+ throttleResize: 1,
590
+ });
591
+ this.moveable
592
+ .on('clip', (e) => {
593
+ this.block.clipPath = e.clipStyle;
594
+ e.target.style.clipPath = e.clipStyle;
595
+ this._triggerChanged();
596
+ });
597
+ this.moveable
598
+ .on('dragStart', () => {
599
+ this.editable = false;
600
+ this.transformating = true;
601
+ this._cdRef.markForCheck();
602
+ })
603
+ .on('drag', ({ target, left, top }) => {
604
+ target.style.left = this.pxToIn(left) + this.unit;
605
+ target.style.top = this.pxToIn(top) + this.unit;
606
+ this.block.top = this.pxToIn(top);
607
+ this.block.left = this.pxToIn(left);
608
+ this._triggerChanged();
609
+ })
610
+ .on('dragEnd', () => {
611
+ this.transformating = false;
612
+ this._cdRef.markForCheck();
613
+ })
614
+ .on('resizeStart', () => {
615
+ this.editable = false;
616
+ this.zoompan.disable();
617
+ this.transformating = true;
618
+ this._cdRef.markForCheck();
619
+ })
620
+ .on('resize', ({ target, width, height, dist, delta, direction }) => {
621
+ width = this.pxToIn(width);
622
+ height = this.pxToIn(height);
623
+ if (delta[0]) {
624
+ this.block.width = width;
625
+ target.style.width = width + this.unit;
626
+ }
627
+ if (delta[1]) {
628
+ this.block.height = height;
629
+ target.style.height = height + this.unit;
630
+ }
631
+ const transform = [0, 0];
632
+ if (direction[1] === -1) {
633
+ transform[1] = dist[1] * -1;
634
+ }
635
+ if (direction[0] === -1) {
636
+ transform[0] = dist[0] * -1;
637
+ }
638
+ this._setTransform([`translate(${transform[0]}px, ${transform[1]}px)`]);
639
+ this._triggerChanged();
640
+ })
641
+ .on('resizeEnd', ({ target }) => {
642
+ const matrix = new WebKitCSSMatrix(target.style.transform);
643
+ this.block.top = parseFloat(target.style.top) + this.pxToIn(matrix.m42);
644
+ this.block.left = parseFloat(target.style.left) + this.pxToIn(matrix.m41);
645
+ target.style.top = this.block.top + this.unit;
646
+ target.style.left = this.block.left + this.unit;
647
+ this._setTransform();
648
+ this._triggerChanged();
649
+ this.zoompan.enable();
650
+ this.transformating = false;
651
+ this._cdRef.markForCheck();
652
+ })
653
+ .on('rotateStart', () => {
654
+ this.zoompan.disable();
655
+ this.editable = false;
656
+ this._rotateStart = this.block.rotate || 0;
657
+ this.transformating = true;
658
+ this._cdRef.markForCheck();
659
+ })
660
+ .on('rotate', ({ rotate, transform }) => {
661
+ this.block.rotate = this._rotateStart + rotate;
662
+ this.el.style.transform = transform;
663
+ this._triggerChanged();
664
+ this.zoompan.enable();
665
+ })
666
+ .on('rotateEnd', () => {
667
+ this.transformating = false;
668
+ this._cdRef.markForCheck();
669
+ });
670
+ }
671
+ _initEvents() {
672
+ fromEvent(this.contentEditable.nativeElement, 'input')
673
+ .pipe(takeUntil(this._destroy$)).subscribe((event) => {
674
+ this.block.content = event.target.innerHTML;
675
+ this._triggerChanged();
676
+ });
677
+ fromEvent(this.el, 'mousedown')
678
+ .pipe(takeUntil(this._destroy$)).subscribe((event) => {
679
+ this.zoompan.disable();
680
+ if (this.editable) {
681
+ if (this.contentElement.nativeElement.isSameNode(event.target)) {
682
+ event.preventDefault();
683
+ event.stopImmediatePropagation();
684
+ event.stopPropagation();
685
+ }
686
+ }
687
+ else {
688
+ this._blockEditor.selectedBlock = this.block;
689
+ }
690
+ });
691
+ fromEvent(this.el, 'mouseup')
692
+ .pipe(takeUntil(this._destroy$)).subscribe(() => {
693
+ this.zoompan.enable();
694
+ });
695
+ fromEvent(this.el, 'dblclick')
696
+ .pipe(filter(() => (!this.editable)), takeUntil(this._destroy$))
697
+ .subscribe((event) => {
698
+ if (this.block.readonly) {
699
+ event.preventDefault();
700
+ }
701
+ else {
702
+ this.editable = true;
703
+ this._cdRef.markForCheck();
704
+ setTimeout(() => {
705
+ this.selectAll();
706
+ });
707
+ }
708
+ });
709
+ }
710
+ }
711
+ 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 }], target: i0.ɵɵFactoryTarget.Component });
712
+ 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 [ngClass]=\"{ \n editable: editable, \n readonly: block.readonly,\n required: block.required\n }\">\n <div\n #contentElement\n class=\"content\"\n [style.zIndex]=\"block.index\"\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.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 + unit : ''\"\n [style.paddingBottom]=\"block.paddingBottom ? block.paddingBottom + unit : ''\"\n [style.paddingLeft]=\"block.paddingLeft ? block.paddingLeft + unit : ''\"\n [style.paddingRight]=\"block.paddingRight ? block.paddingRight + unit : ''\"\n [style.padding]=\"block.padding ? block.padding + unit : ''\"\n [style.clipPath]=\"block.clipPath\"\n [style.backgroundColor]=\"block.backgroundColor\"\n [style.borderBottomLeftRadius]=\"block.shapeRadius && block.shapeBottomLeft === 'round' ? block.shapeRadius + unit : ''\"\n [style.borderBottomRightRadius]=\"block.shapeRadius && block.shapeBottomRight === 'round' ? block.shapeRadius + unit : ''\"\n [style.borderTopRightRadius]=\"block.shapeRadius && block.shapeTopRight === 'round' ? block.shapeRadius + unit : ''\"\n [style.borderTopLeftRadius]=\"block.shapeRadius && block.shapeTopLeft === 'round' ? block.shapeRadius + unit : ''\"\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 *ngSwitchCase=\"BlockType.Pdf\">\n <img [src]=\"block.imageUrl\">\n </ng-container>\n <img [src]=\"block.imageUrl\" *ngIf=\"block.imageUrl\">\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>\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}.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}.block.editable .content-editable{cursor:text}.block .content{flex-direction:column;height:100%;display:flex;border:1px 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}: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: i11.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i11.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i11.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
713
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockComponent, decorators: [{
714
+ type: Component,
715
+ args: [{
716
+ selector: 'fs-block',
717
+ templateUrl: 'block.component.html',
718
+ styleUrls: ['block.component.scss'],
719
+ changeDetection: ChangeDetectionStrategy.OnPush,
720
+ }]
721
+ }], ctorParameters: function () { return [{ type: BlockEditorService }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { element: [{
722
+ type: ViewChild,
723
+ args: ['element', { static: true }]
724
+ }], contentElement: [{
725
+ type: ViewChild,
726
+ args: ['contentElement', { static: true }]
727
+ }], contentEditable: [{
728
+ type: ViewChild,
729
+ args: ['contentEditable', { static: true }]
730
+ }], block: [{
731
+ type: Input
732
+ }], html: [{
733
+ type: Input
734
+ }], zoompan: [{
735
+ type: Input
736
+ }], transformating: [{
737
+ type: HostBinding,
738
+ args: ['class.transforming']
620
739
  }] } });
621
740
 
622
- const BlockTypes = [
623
- { value: BlockType.Rectangle, name: 'Rectangle', icon: 'crop_5_4' },
624
- { value: BlockType.ShortText, name: 'Short Text', icon: 'short_text' },
625
- { value: BlockType.LongText, name: 'Long Text', icon: 'subject' },
626
- { value: BlockType.RadioButton, name: 'Radio Button', icon: 'radio_button_checked' },
627
- { value: BlockType.Checkbox, name: 'Checkbox', icon: 'check_box' },
628
- { value: BlockType.Date, name: 'Date', icon: 'calendar_today' },
629
- { value: BlockType.Signature, name: 'Signature', icon: 'draw' },
630
- { value: BlockType.Image, name: 'Image', icon: 'image', accept: 'image/*' },
631
- { value: BlockType.Pdf, name: 'Pdf', icon: 'picture_as_pdf', accept: 'application/pdf' },
632
- ];
741
+ class FsBlockEditorSidebarPanelDirective {
742
+ constructor(templateRef) {
743
+ this.templateRef = templateRef;
744
+ this.show = true;
745
+ }
746
+ }
747
+ FsBlockEditorSidebarPanelDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorSidebarPanelDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
748
+ FsBlockEditorSidebarPanelDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorSidebarPanelDirective, selector: "[fsBlockEditorSidebarPanel]", inputs: { label: "label", show: "show" }, ngImport: i0 });
749
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorSidebarPanelDirective, decorators: [{
750
+ type: Directive,
751
+ args: [{
752
+ selector: '[fsBlockEditorSidebarPanel]'
753
+ }]
754
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; }, propDecorators: { label: [{
755
+ type: Input
756
+ }], show: [{
757
+ type: Input
758
+ }] } });
633
759
 
634
- const BlockFormats = [
635
- { value: BlockFormat.Number, name: 'Number', blockTypes: [BlockType.ShortText, BlockType.LongText] },
636
- { value: BlockFormat.Currency, name: 'Currency', blockTypes: [BlockType.ShortText, BlockType.LongText] },
637
- { value: BlockFormat.Date, name: 'Date', blockTypes: [BlockType.Date] },
638
- { value: BlockFormat.YYYYMMDD, name: 'YYYY/MM/DD', blockTypes: [BlockType.Date] },
760
+ const BlockFormats = [
761
+ { value: BlockFormat.Number, name: 'Number', blockTypes: [BlockType.ShortText, BlockType.LongText] },
762
+ { value: BlockFormat.Currency, name: 'Currency', blockTypes: [BlockType.ShortText, BlockType.LongText] },
763
+ { value: BlockFormat.Date, name: 'Date', blockTypes: [BlockType.Date] },
764
+ { value: BlockFormat.YYYYMMDD, name: 'YYYY/MM/DD', blockTypes: [BlockType.Date] },
639
765
  ];
640
766
 
641
- class SidebarComponent {
642
- constructor(_el, _blockEditor, _cdRef, _prompt) {
643
- this._el = _el;
644
- this._blockEditor = _blockEditor;
645
- this._cdRef = _cdRef;
646
- this._prompt = _prompt;
647
- this.zoomCenter = new EventEmitter();
648
- this.BlockTypes = BlockTypes;
649
- this.blockTypeNames = index(BlockTypes, 'value', 'name');
650
- this.BlockType = BlockType;
651
- this.formats = [];
652
- this._destroy$ = new Subject();
653
- }
654
- get el() {
655
- return this._el.nativeElement;
656
- }
657
- ngOnInit() {
658
- this._blockEditor.selectedBlocks$
659
- .pipe(takeUntil(this._destroy$))
660
- .subscribe((blocks) => {
661
- this.clippable = false;
662
- this.block = blocks[0] ? blocks[0] : null;
663
- this.formats = BlockFormats
664
- .filter((blockFormat) => { var _a; return (blockFormat.blockTypes.indexOf((_a = this.block) === null || _a === void 0 ? void 0 : _a.type) !== -1); });
665
- this._cdRef.markForCheck();
666
- });
667
- this._blockEditor.blockChanged$
668
- .pipe(filter((block) => block === this.block), takeUntil(this._destroy$))
669
- .subscribe(() => {
670
- this._cdRef.markForCheck();
671
- });
672
- }
673
- verticalAlignClick(value) {
674
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'verticalAlign');
675
- }
676
- boldClick() {
677
- this._blockEditor.selectedBlockComponentChangeProperty(!this.block.bold, 'bold');
678
- }
679
- fontColorChange(value) {
680
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'fontColor');
681
- }
682
- lineHeightChange(value) {
683
- value = this.validNumeric(value) ? value : null;
684
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'lineHeight');
685
- }
686
- fontSizeChange(value) {
687
- value = this.validNumeric(value) ? value : null;
688
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'fontSize');
689
- }
690
- borderWidthChange(value) {
691
- value = this.validNumeric(value) ? value : null;
692
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'borderWidth');
693
- }
694
- italicClick() {
695
- this._blockEditor.selectedBlockComponentChangeProperty(!this.block.italic, 'italic');
696
- }
697
- underlineClick() {
698
- this._blockEditor.selectedBlockComponentChangeProperty(!this.block.underline, 'underline');
699
- }
700
- backgroundColorChange(value) {
701
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'backgroundColor');
702
- }
703
- widthChange(value) {
704
- value = this.validNumeric(value) ? value : null;
705
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'width');
706
- }
707
- heightChange(value) {
708
- value = this.validNumeric(value) ? value : null;
709
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'height');
710
- }
711
- topChange(value) {
712
- value = this.validNumeric(value) ? value : null;
713
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'top');
714
- }
715
- leftChange(value) {
716
- value = this.validNumeric(value) ? value : null;
717
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'left');
718
- }
719
- rotateChange(value) {
720
- value = this.validNumeric(value) ? value : null;
721
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'rotate');
722
- }
723
- paddingChange(name, value) {
724
- value = this.validNumeric(value) ? value : null;
725
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'padding');
726
- }
727
- paddingAllChange(value) {
728
- value = this.validNumeric(value) ? value : null;
729
- this.block.paddingTop = value;
730
- this.block.paddingLeft = value;
731
- this.block.paddingBottom = value;
732
- this.block.paddingRight = value;
733
- this.paddingChange('top', value);
734
- this.paddingChange('left', value);
735
- this.paddingChange('right', value);
736
- this.paddingChange('bottom', value);
737
- }
738
- borderColorChange(value) {
739
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'borderColor');
740
- }
741
- toggleKeepRatio() {
742
- this._blockEditor.selectedBlockComponentChangeProperty(!this.block.keepRatio, 'keepRatio');
743
- }
744
- horizontalAlignClick(value) {
745
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'horizontalAlign');
746
- }
747
- shapeRound(name) {
748
- const value = this.block[name] === 'round' ? 'square' : 'round';
749
- this._blockEditor.selectedBlockComponentChangeProperty(value, name);
750
- }
751
- imageRemove() {
752
- this._blockEditor.selectedBlockComponentChangeProperty(null, 'imageUrl');
753
- }
754
- imageClip() {
755
- this.clippable = !this.clippable;
756
- this._blockEditor.selectedBlockComponentChangeProperty(this.clippable, 'clippable');
757
- }
758
- shapeRadiusChange(value) {
759
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'shapeRadius');
760
- }
761
- blockChangeProperty(value, name) {
762
- this._blockEditor.selectedBlockComponentChangeProperty(value, name);
763
- }
764
- imageSelect(fsFile) {
765
- if (this.config.imageUpload) {
766
- this.config.imageUpload(fsFile.file)
767
- .subscribe((value) => {
768
- this._blockEditor.selectedBlockComponentChangeProperty(value, 'imageUrl');
769
- });
770
- }
771
- }
772
- blockRemoveClick() {
773
- if (this.config.blocksRemove) {
774
- this._prompt.confirm({
775
- title: 'Confirm',
776
- template: 'Are you sure your would like to delete this block?',
777
- })
778
- .pipe(switchMap(() => this.config.blocksRemove(this._blockEditor.selectedBlocks)), takeUntil(this._destroy$))
779
- .subscribe(() => {
780
- this._blockEditor.removeSelectedBlocks();
781
- });
782
- }
783
- }
784
- blockUpload(blockType, fsFile) {
785
- const block = this._blockEditor.sanitizeNewBlock({
786
- type: blockType,
787
- });
788
- this._blockEditor.blockUpload(block, fsFile);
789
- }
790
- blockAdd(type) {
791
- if (type === BlockType.Pdf || type === BlockType.Image) {
792
- return;
793
- }
794
- const block = this._blockEditor.sanitizeNewBlock({
795
- type,
796
- });
797
- this._blockEditor.blockAdd(block);
798
- }
799
- layerMove(direction) {
800
- this._blockEditor.blockComponents.forEach((blockComponent) => {
801
- if (this._blockEditor.isSelectedBlock(blockComponent)) {
802
- blockComponent.block.index += (999 * direction);
803
- }
804
- });
805
- const sorted = this._blockEditor.blockComponents.sort((a, b) => {
806
- return a.block.index > b.block.index ? 1 : -1;
807
- });
808
- sorted.forEach((item, index) => {
809
- item.block.index = index;
810
- item.markForCheck();
811
- });
812
- if (this.config.blocksLevelChanged) {
813
- this.config.blocksLevelChanged(sorted.map((item) => item.block));
814
- }
815
- }
816
- layerUp() {
817
- this.layerMove(1);
818
- }
819
- layerDown() {
820
- this.layerMove(-1);
821
- }
822
- blockChanged(block) {
823
- if (this.config.blockChanged) {
824
- this.config.blockChanged(block);
825
- }
826
- }
827
- inputFocus(event) {
828
- event.target.select();
829
- }
830
- ngOnDestroy() {
831
- this._destroy$.next();
832
- this._destroy$.complete();
833
- }
834
- validNumeric(value) {
835
- return !value || !!String(value).match(/^\d*\.?\d*$/);
836
- }
837
- }
838
- 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.FsPrompt }], target: i0.ɵɵFactoryTarget.Component });
839
- 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 [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 *ngTemplateOutlet=\"addButton\"></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\"></ng-container>\n </fs-file>\n </ng-template>\n\n <ng-template #addButton>\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>\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 <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 </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 (ngModelChange)=\"leftChange($event)\">\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 (ngModelChange)=\"topChange($event)\">\n <span matPrefix>Y</span>\n </mat-form-field>\n <mat-form-field class=\"form-field-padless\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.rotate || 0\"\n name=\"rotate\"\n (focus)=\"inputFocus($event)\"\n (ngModelChange)=\"rotateChange($event)\">\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 (ngModelChange)=\"widthChange($event)\">\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 (ngModelChange)=\"heightChange($event)\">\n <span matPrefix>H</span>\n </mat-form-field>\n </div>\n </div>\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 <div class=\"sidebar-panel form-field-panel\">\n <div class=\"sidebar-label\">{{blockTypeNames[block.type]}} Field</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 [matTextareaAutosize]=\"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 *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 [matTextareaAutosize]=\"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 [matTextareaAutosize]=\"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 [matTextareaAutosize]=\"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 [matTextareaAutosize]=\"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 <mat-form-field class=\"form-field-padless-bottom full-width\">\n <mat-label>Index</mat-label>\n <input\n matInput\n [(ngModel)]=\"block.index\"\n name=\"index\"\n (ngModelChange)=\"blockChangeProperty($event, 'index')\">\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-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 (ngModelChange)=\"fontSizeChange($event)\"\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 (ngModelChange)=\"lineHeightChange($event)\"\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 === '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 (ngModelChange)=\"borderWidthChange($event)\"\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 (ngModelChange)=\"shapeRadiusChange($event)\"\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 <ng-container *ngIf=\"block.type !== BlockType.Pdf\">\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 type=\"button\" mat-icon-button><mat-icon>cloud_upload</mat-icon></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 </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 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 (ngModelChange)=\"paddingChange('paddingTop',$event)\"\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 (ngModelChange)=\"paddingChange('paddingBottom',$event)\"\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 (ngModelChange)=\"paddingChange('paddingLeft',$event)\"\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 (ngModelChange)=\"paddingChange('paddingRight',$event)\"\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", 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 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 ::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.form-field-panel mat-form-field+mat-form-field{margin-top:12px}.sidebar .sidebar-panel.form-field-panel .form-field-options{margin-top:11px}.sidebar .sidebar-panel.form-field-panel .form-field-options mat-checkbox{display:block}.sidebar .sidebar-panel.form-field-panel .form-field-options mat-checkbox+mat-checkbox{margin-top:2px}.sidebar .sidebar-panel.info-panel .sidebar-row+.sidebar-row{margin-top:12px}.sidebar .sidebar-panel.info-panel .sidebar-row .mat-form-field{width:41px}.sidebar .sidebar-panel.typography-panel .style-row{margin-bottom:-10px}.sidebar .sidebar-panel.typography-panel .align-row{margin-bottom:-5px}.sidebar .sidebar-panel .sidebar-label{font-size:11px;margin-bottom:3px;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.FsFileComponent, selector: "fs-file", inputs: ["minHeight", "minWidth", "multiple", "capture", "allowClick", "allowDrop", "accept", "disabled", "imageWidth", "imageHeight", "imageQuality"], outputs: ["select", "error", "clicked", "declined"] }, { type: i4.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i6.MatFormField, selector: "mat-form-field", inputs: ["color", "floatLabel", "appearance", "hideRequiredMarker", "hintLabel"], exportAs: ["matFormField"] }, { type: i7.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.FsColorPickerChipComponent, selector: "fs-color-picker-chip", inputs: ["color"], outputs: ["changed"] }], directives: [{ type: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i11.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i11.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i11.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i11.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { type: i12.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i13.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: i14.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: i14.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i14.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i6.MatPrefix, selector: "[matPrefix]" }, { type: i13.MatTextareaAutosize, selector: "textarea[mat-autosize], textarea[matTextareaAutosize]", inputs: ["cdkAutosizeMinRows", "cdkAutosizeMaxRows", "matAutosizeMinRows", "matAutosizeMaxRows", "mat-autosize", "matTextareaAutosize"], exportAs: ["matTextareaAutosize"] }, { type: i6.MatLabel, selector: "mat-label" }, { type: i11.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
840
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SidebarComponent, decorators: [{
841
- type: Component,
842
- args: [{
843
- selector: 'sidebar',
844
- templateUrl: 'sidebar.component.html',
845
- styleUrls: ['sidebar.component.scss'],
846
- changeDetection: ChangeDetectionStrategy.OnPush,
847
- }]
848
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }, { type: i0.ChangeDetectorRef }, { type: i2.FsPrompt }]; }, propDecorators: { sidebarPanels: [{
849
- type: ContentChildren,
850
- args: [FsBlockEditorSidebarPanelDirective]
851
- }], config: [{
852
- type: Input
853
- }], blocks: [{
854
- type: Input
855
- }], zoomCenter: [{
856
- type: Output
767
+ class SidebarComponent {
768
+ constructor(_el, _blockEditor, _cdRef, _prompt, _document) {
769
+ this._el = _el;
770
+ this._blockEditor = _blockEditor;
771
+ this._cdRef = _cdRef;
772
+ this._prompt = _prompt;
773
+ this._document = _document;
774
+ this.zoomCenter = new EventEmitter();
775
+ this.BlockTypes = BlockTypes;
776
+ this.blockTypeNames = index(BlockTypes, 'value', 'name');
777
+ this.blockTypeIcons = index(BlockTypes, 'value', 'icon');
778
+ this.BlockType = BlockType;
779
+ this.formats = [];
780
+ this._destroy$ = new Subject();
781
+ }
782
+ get el() {
783
+ return this._el.nativeElement;
784
+ }
785
+ ngOnInit() {
786
+ this._blockEditor.selectedBlocks$
787
+ .pipe(takeUntil(this._destroy$))
788
+ .subscribe((blocks) => {
789
+ this.clippable = false;
790
+ this.block = blocks[0] ? blocks[0] : null;
791
+ this.formats = BlockFormats
792
+ .filter((blockFormat) => { var _a; return (blockFormat.blockTypes.indexOf((_a = this.block) === null || _a === void 0 ? void 0 : _a.type) !== -1); });
793
+ this._cdRef.markForCheck();
794
+ });
795
+ this._blockEditor.blockChanged$
796
+ .pipe(filter((block) => block === this.block), takeUntil(this._destroy$))
797
+ .subscribe(() => {
798
+ this._cdRef.markForCheck();
799
+ });
800
+ }
801
+ verticalAlignClick(value) {
802
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'verticalAlign');
803
+ }
804
+ boldClick() {
805
+ this._blockEditor.selectedBlockComponentChangeProperty(!this.block.bold, 'bold');
806
+ }
807
+ fontColorChange(value) {
808
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'fontColor');
809
+ }
810
+ lineHeightChange(value) {
811
+ value = this.validNumeric(value) ? value : null;
812
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'lineHeight');
813
+ }
814
+ fontSizeChange(value) {
815
+ value = this.validNumeric(value) ? value : null;
816
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'fontSize');
817
+ }
818
+ borderWidthChange(value) {
819
+ value = this.validNumeric(value) ? value : null;
820
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'borderWidth');
821
+ }
822
+ italicClick() {
823
+ this._blockEditor.selectedBlockComponentChangeProperty(!this.block.italic, 'italic');
824
+ }
825
+ underlineClick() {
826
+ this._blockEditor.selectedBlockComponentChangeProperty(!this.block.underline, 'underline');
827
+ }
828
+ backgroundColorChange(value) {
829
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'backgroundColor');
830
+ }
831
+ widthChange(value) {
832
+ value = this.validNumeric(value) ? value : null;
833
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'width');
834
+ }
835
+ heightChange(value) {
836
+ value = this.validNumeric(value) ? value : null;
837
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'height');
838
+ }
839
+ topChange(value) {
840
+ value = this.validNumeric(value) ? value : null;
841
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'top');
842
+ }
843
+ leftChange(value) {
844
+ value = this.validNumeric(value) ? value : null;
845
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'left');
846
+ }
847
+ rotateChange(value) {
848
+ value = this.validNumeric(value) ? value : null;
849
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'rotate');
850
+ }
851
+ paddingChange(name, value) {
852
+ value = this.validNumeric(value) ? value : null;
853
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'padding');
854
+ }
855
+ paddingAllChange(value) {
856
+ value = this.validNumeric(value) ? value : null;
857
+ this.block.paddingTop = value;
858
+ this.block.paddingLeft = value;
859
+ this.block.paddingBottom = value;
860
+ this.block.paddingRight = value;
861
+ this.paddingChange('top', value);
862
+ this.paddingChange('left', value);
863
+ this.paddingChange('right', value);
864
+ this.paddingChange('bottom', value);
865
+ }
866
+ borderColorChange(value) {
867
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'borderColor');
868
+ }
869
+ toggleKeepRatio() {
870
+ this._blockEditor.selectedBlockComponentChangeProperty(!this.block.keepRatio, 'keepRatio');
871
+ }
872
+ horizontalAlignClick(value) {
873
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'horizontalAlign');
874
+ }
875
+ shapeRound(name) {
876
+ const value = this.block[name] === 'round' ? 'square' : 'round';
877
+ this._blockEditor.selectedBlockComponentChangeProperty(value, name);
878
+ }
879
+ imageRemove() {
880
+ this._blockEditor.selectedBlockComponentChangeProperty(null, 'imageUrl');
881
+ }
882
+ imageClip() {
883
+ this.clippable = !this.clippable;
884
+ this._blockEditor.selectedBlockComponentChangeProperty(this.clippable, 'clippable');
885
+ }
886
+ shapeRadiusChange(value) {
887
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'shapeRadius');
888
+ }
889
+ blockChangeProperty(value, name) {
890
+ this._blockEditor.selectedBlockComponentChangeProperty(value, name);
891
+ }
892
+ imageSelect(fsFile) {
893
+ if (this.config.imageUpload) {
894
+ this.config.imageUpload(fsFile.file)
895
+ .subscribe((value) => {
896
+ this._blockEditor.selectedBlockComponentChangeProperty(value, 'imageUrl');
897
+ });
898
+ }
899
+ }
900
+ blockRemoveClick() {
901
+ if (this.config.blocksRemove) {
902
+ this._prompt.confirm({
903
+ title: 'Confirm',
904
+ template: 'Are you sure your would like to delete this block?',
905
+ })
906
+ .pipe(switchMap(() => this.config.blocksRemove(this._blockEditor.selectedBlocks)), takeUntil(this._destroy$))
907
+ .subscribe(() => {
908
+ this._blockEditor.removeSelectedBlocks();
909
+ });
910
+ }
911
+ }
912
+ blockUpload(type, fsFile) {
913
+ this._blockEditor.blockUpload({
914
+ type,
915
+ }, fsFile, true);
916
+ }
917
+ blockAdd(type) {
918
+ if (type === BlockType.Pdf || type === BlockType.Image) {
919
+ return;
920
+ }
921
+ this._blockEditor.blockAdd({
922
+ type,
923
+ }, true);
924
+ }
925
+ layerMove(direction) {
926
+ this._blockEditor.blockComponents.forEach((blockComponent) => {
927
+ if (this._blockEditor.isSelectedBlock(blockComponent)) {
928
+ blockComponent.block.index += (999 * direction);
929
+ }
930
+ });
931
+ const sorted = this._blockEditor.blockComponents.sort((a, b) => {
932
+ return a.block.index > b.block.index ? 1 : -1;
933
+ });
934
+ sorted.forEach((item, index) => {
935
+ item.block.index = index;
936
+ item.markForCheck();
937
+ });
938
+ if (this.config.blocksLevelChanged) {
939
+ this.config.blocksLevelChanged(sorted.map((item) => item.block));
940
+ }
941
+ }
942
+ layerUp() {
943
+ this.layerMove(1);
944
+ }
945
+ layerDown() {
946
+ this.layerMove(-1);
947
+ }
948
+ reorderLayers() {
949
+ var _a;
950
+ (_a = this._document.defaultView) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
951
+ this._blockEditor.openReorderDialog();
952
+ }
953
+ blockChanged(block) {
954
+ if (this.config.blockChanged) {
955
+ this.config.blockChanged(block);
956
+ }
957
+ }
958
+ inputFocus(event) {
959
+ event.target.select();
960
+ }
961
+ ngOnDestroy() {
962
+ this._destroy$.next();
963
+ this._destroy$.complete();
964
+ }
965
+ validNumeric(value) {
966
+ return !value || !!String(value).match(/^\d*\.?\d*$/);
967
+ }
968
+ }
969
+ 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: DOCUMENT }], target: i0.ɵɵFactoryTarget.Component });
970
+ 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 [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 *ngTemplateOutlet=\"addButton\"></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\"></ng-container>\n </fs-file>\n </ng-template>\n\n <ng-template #addButton>\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>\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 <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 <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>\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 (ngModelChange)=\"leftChange($event)\">\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 (ngModelChange)=\"topChange($event)\">\n <span matPrefix>Y</span>\n </mat-form-field>\n <mat-form-field class=\"form-field-padless\" floatLabel=\"never\">\n <input\n matInput\n [ngModel]=\"block.rotate || 0\"\n name=\"rotate\"\n (focus)=\"inputFocus($event)\"\n (ngModelChange)=\"rotateChange($event)\">\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 (ngModelChange)=\"widthChange($event)\">\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 (ngModelChange)=\"heightChange($event)\">\n <span matPrefix>H</span>\n </mat-form-field>\n </div>\n </div>\n <ng-container *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]}}</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 [matTextareaAutosize]=\"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 *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 [matTextareaAutosize]=\"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 [matTextareaAutosize]=\"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 [matTextareaAutosize]=\"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 [matTextareaAutosize]=\"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-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 (ngModelChange)=\"fontSizeChange($event)\"\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 (ngModelChange)=\"lineHeightChange($event)\"\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 === '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 (ngModelChange)=\"borderWidthChange($event)\"\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 (ngModelChange)=\"shapeRadiusChange($event)\"\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 <ng-container *ngIf=\"block.type !== BlockType.Pdf\">\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 type=\"button\" mat-icon-button><mat-icon>cloud_upload</mat-icon></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 </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 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 (ngModelChange)=\"paddingChange('paddingTop',$event)\"\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 (ngModelChange)=\"paddingChange('paddingBottom',$event)\"\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 (ngModelChange)=\"paddingChange('paddingLeft',$event)\"\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 (ngModelChange)=\"paddingChange('paddingRight',$event)\"\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", 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 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 ::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 .sidebar-row+.sidebar-row{margin-top:12px}.sidebar .sidebar-panel.info-panel .sidebar-row .mat-form-field{width:41px}.sidebar .sidebar-panel.typography-panel .style-row{margin-bottom:-10px}.sidebar .sidebar-panel.typography-panel .align-row{margin-bottom:-5px}.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", "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.FsColorPickerChipComponent, selector: "fs-color-picker-chip", inputs: ["color"], outputs: ["changed"] }], directives: [{ type: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i11.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i11.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i11.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i11.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { type: i12.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i13.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: i14.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: i14.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i14.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i6$1.MatPrefix, selector: "[matPrefix]" }, { type: i13.MatTextareaAutosize, selector: "textarea[mat-autosize], textarea[matTextareaAutosize]", inputs: ["cdkAutosizeMinRows", "cdkAutosizeMaxRows", "matAutosizeMinRows", "matAutosizeMaxRows", "mat-autosize", "matTextareaAutosize"], exportAs: ["matTextareaAutosize"] }, { type: i6$1.MatLabel, selector: "mat-label" }, { type: i11.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
971
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SidebarComponent, decorators: [{
972
+ type: Component,
973
+ args: [{
974
+ selector: 'sidebar',
975
+ templateUrl: 'sidebar.component.html',
976
+ styleUrls: ['sidebar.component.scss'],
977
+ changeDetection: ChangeDetectionStrategy.OnPush,
978
+ }]
979
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }, { type: i0.ChangeDetectorRef }, { type: i2$1.FsPrompt }, { type: undefined, decorators: [{
980
+ type: Inject,
981
+ args: [DOCUMENT]
982
+ }] }]; }, propDecorators: { sidebarPanels: [{
983
+ type: ContentChildren,
984
+ args: [FsBlockEditorSidebarPanelDirective]
985
+ }], config: [{
986
+ type: Input
987
+ }], blocks: [{
988
+ type: Input
989
+ }], zoomCenter: [{
990
+ type: Output
857
991
  }] } });
858
992
 
859
- class FsBlockEditorMarginDirective {
860
- constructor(_elementRef) {
861
- this._elementRef = _elementRef;
862
- }
863
- get element() {
864
- return this._elementRef.nativeElement;
865
- }
866
- }
867
- FsBlockEditorMarginDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorMarginDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
868
- FsBlockEditorMarginDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorMarginDirective, selector: "[fsBlockEditorMargin]", ngImport: i0 });
869
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorMarginDirective, decorators: [{
870
- type: Directive,
871
- args: [{
872
- selector: '[fsBlockEditorMargin]'
873
- }]
993
+ class FsBlockEditorMarginDirective {
994
+ constructor(_elementRef) {
995
+ this._elementRef = _elementRef;
996
+ }
997
+ get element() {
998
+ return this._elementRef.nativeElement;
999
+ }
1000
+ }
1001
+ FsBlockEditorMarginDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorMarginDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
1002
+ FsBlockEditorMarginDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorMarginDirective, selector: "[fsBlockEditorMargin]", ngImport: i0 });
1003
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorMarginDirective, decorators: [{
1004
+ type: Directive,
1005
+ args: [{
1006
+ selector: '[fsBlockEditorMargin]'
1007
+ }]
874
1008
  }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
875
1009
 
876
- class ArtboardComponent {
877
- constructor(_el, _blockEditor, _cdRef, _differs) {
878
- this._el = _el;
879
- this._blockEditor = _blockEditor;
880
- this._cdRef = _cdRef;
881
- this._differs = _differs;
882
- this.blocks = [];
883
- this._destroy$ = new Subject();
884
- this._differ = _differs.find([]).create(null);
885
- }
886
- get el() {
887
- return this._el.nativeElement;
888
- }
889
- ngOnInit() {
890
- this.config = Object.assign(Object.assign({}, this.config), { unit: 'in' });
891
- this._blockEditor.registerContainer(this.artboard.nativeElement);
892
- this._blockEditor.registerMargin(this.marginContainer.nativeElement);
893
- this._blockEditor.blocks$
894
- .pipe(takeUntil(this._destroy$))
895
- .subscribe((blocks) => {
896
- this.blocks = blocks;
897
- this._cdRef.markForCheck();
898
- });
899
- this._blockEditor.blockAdded$
900
- .pipe(delay(300), takeUntil(this._destroy$))
901
- .subscribe((block) => {
902
- this._blockEditor.selectedBlocks = [block];
903
- this._cdRef.markForCheck();
904
- });
905
- fromEvent(window, 'keydown')
906
- .pipe(takeUntil(this._destroy$), filter((event) => {
907
- return !!event.key.match(/^Arrow/) && !!this._blockEditor.selectedBlocks.length;
908
- }))
909
- .subscribe((event) => {
910
- event.preventDefault();
911
- const inchPixel = 1 / 100;
912
- this._blockEditor.selectedComponentBlocks
913
- .forEach((blockComponent) => {
914
- switch (event.key) {
915
- case 'ArrowUp':
916
- blockComponent.top = blockComponent.block.top - inchPixel;
917
- break;
918
- case 'ArrowDown':
919
- blockComponent.top = blockComponent.block.top + inchPixel;
920
- break;
921
- case 'ArrowLeft':
922
- blockComponent.left = blockComponent.block.left - inchPixel;
923
- break;
924
- case 'ArrowRight':
925
- blockComponent.left = blockComponent.block.left + inchPixel;
926
- break;
927
- }
928
- });
929
- });
930
- }
931
- blockChanged(block) {
932
- if (this.config.blockChanged) {
933
- this.config.blockChanged(block);
934
- }
935
- }
936
- ngAfterViewInit() {
937
- // this.blockComponents.changes
938
- // .pipe(
939
- // takeUntil(this._destroy$),
940
- // )
941
- // .subscribe((changes) => {
942
- // const changeDiff = this._differ.diff(changes);
943
- // if (changeDiff) {
944
- // changeDiff.forEachAddedItem((change) => {
945
- // //this.blockAdded.emit(change.item);
946
- // });
947
- // changeDiff.forEachRemovedItem((change) => {
948
- // //this.blockRemoved.emit(change.item);
949
- // });
950
- // }
951
- // });
952
- }
953
- ngOnDestroy() {
954
- this._destroy$.next();
955
- this._destroy$.complete();
956
- }
957
- }
958
- 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 }, { token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Component });
959
- 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: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
960
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ArtboardComponent, decorators: [{
961
- type: Component,
962
- args: [{
963
- selector: 'app-artboard',
964
- templateUrl: 'artboard.component.html',
965
- styleUrls: ['artboard.component.scss'],
966
- changeDetection: ChangeDetectionStrategy.OnPush,
967
- }]
968
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }, { type: i0.ChangeDetectorRef }, { type: i0.IterableDiffers }]; }, propDecorators: { sidebarPanels: [{
969
- type: ContentChildren,
970
- args: [FsBlockEditorSidebarPanelDirective]
971
- }], blockComponents: [{
972
- type: ViewChildren,
973
- args: [FsBlockComponent]
974
- }], artboard: [{
975
- type: ViewChild,
976
- args: ['artboard', { static: true }]
977
- }], marginContainer: [{
978
- type: ViewChild,
979
- args: ['marginContainer', { static: true }]
980
- }], margins: [{
981
- type: ViewChildren,
982
- args: [FsBlockEditorMarginDirective]
983
- }], sidebar: [{
984
- type: ViewChild,
985
- args: [SidebarComponent, { static: true }]
986
- }], config: [{
987
- type: Input
988
- }], zoompan: [{
989
- type: Input
1010
+ class ArtboardComponent {
1011
+ constructor(_el, _blockEditor, _cdRef, _differs) {
1012
+ this._el = _el;
1013
+ this._blockEditor = _blockEditor;
1014
+ this._cdRef = _cdRef;
1015
+ this._differs = _differs;
1016
+ this.blocks = [];
1017
+ this._destroy$ = new Subject();
1018
+ this._differ = _differs.find([]).create(null);
1019
+ }
1020
+ get el() {
1021
+ return this._el.nativeElement;
1022
+ }
1023
+ ngOnInit() {
1024
+ this.config = Object.assign(Object.assign({}, this.config), { unit: 'in' });
1025
+ this._blockEditor.registerContainer(this.artboard.nativeElement);
1026
+ this._blockEditor.registerMargin(this.marginContainer.nativeElement);
1027
+ this._blockEditor.blocks$
1028
+ .pipe(takeUntil(this._destroy$))
1029
+ .subscribe((blocks) => {
1030
+ this.blocks = blocks;
1031
+ this._cdRef.markForCheck();
1032
+ });
1033
+ this._blockEditor.blockAdded$
1034
+ .pipe(delay(300), takeUntil(this._destroy$))
1035
+ .subscribe((block) => {
1036
+ this._blockEditor.selectedBlocks = [block];
1037
+ this._cdRef.markForCheck();
1038
+ });
1039
+ fromEvent(window, 'keydown')
1040
+ .pipe(filter((event) => {
1041
+ return ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].indexOf(event.key) !== -1;
1042
+ }), takeUntil(this._destroy$))
1043
+ .subscribe((event) => {
1044
+ event.preventDefault();
1045
+ const inchPixel = 1 / 100;
1046
+ this._blockEditor.selectedComponentBlocks
1047
+ .forEach((blockComponent) => {
1048
+ switch (event.key) {
1049
+ case 'ArrowUp':
1050
+ blockComponent.top = blockComponent.block.top - inchPixel;
1051
+ break;
1052
+ case 'ArrowDown':
1053
+ blockComponent.top = blockComponent.block.top + inchPixel;
1054
+ break;
1055
+ case 'ArrowLeft':
1056
+ blockComponent.left = blockComponent.block.left - inchPixel;
1057
+ break;
1058
+ case 'ArrowRight':
1059
+ blockComponent.left = blockComponent.block.left + inchPixel;
1060
+ break;
1061
+ }
1062
+ });
1063
+ });
1064
+ }
1065
+ blockChanged(block) {
1066
+ if (this.config.blockChanged) {
1067
+ this.config.blockChanged(block);
1068
+ }
1069
+ }
1070
+ ngAfterViewInit() {
1071
+ // this.blockComponents.changes
1072
+ // .pipe(
1073
+ // takeUntil(this._destroy$),
1074
+ // )
1075
+ // .subscribe((changes) => {
1076
+ // const changeDiff = this._differ.diff(changes);
1077
+ // if (changeDiff) {
1078
+ // changeDiff.forEachAddedItem((change) => {
1079
+ // //this.blockAdded.emit(change.item);
1080
+ // });
1081
+ // changeDiff.forEachRemovedItem((change) => {
1082
+ // //this.blockRemoved.emit(change.item);
1083
+ // });
1084
+ // }
1085
+ // });
1086
+ }
1087
+ ngOnDestroy() {
1088
+ this._destroy$.next();
1089
+ this._destroy$.complete();
1090
+ }
1091
+ }
1092
+ 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 }, { token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Component });
1093
+ 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: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1094
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ArtboardComponent, decorators: [{
1095
+ type: Component,
1096
+ args: [{
1097
+ selector: 'app-artboard',
1098
+ templateUrl: 'artboard.component.html',
1099
+ styleUrls: ['artboard.component.scss'],
1100
+ changeDetection: ChangeDetectionStrategy.OnPush,
1101
+ }]
1102
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }, { type: i0.ChangeDetectorRef }, { type: i0.IterableDiffers }]; }, propDecorators: { sidebarPanels: [{
1103
+ type: ContentChildren,
1104
+ args: [FsBlockEditorSidebarPanelDirective]
1105
+ }], blockComponents: [{
1106
+ type: ViewChildren,
1107
+ args: [FsBlockComponent]
1108
+ }], artboard: [{
1109
+ type: ViewChild,
1110
+ args: ['artboard', { static: true }]
1111
+ }], marginContainer: [{
1112
+ type: ViewChild,
1113
+ args: ['marginContainer', { static: true }]
1114
+ }], margins: [{
1115
+ type: ViewChildren,
1116
+ args: [FsBlockEditorMarginDirective]
1117
+ }], sidebar: [{
1118
+ type: ViewChild,
1119
+ args: [SidebarComponent, { static: true }]
1120
+ }], config: [{
1121
+ type: Input
1122
+ }], zoompan: [{
1123
+ type: Input
990
1124
  }] } });
991
1125
 
992
- class FsBlockEditorComponent {
993
- constructor(_el, _blockEditor) {
994
- this._el = _el;
995
- this._blockEditor = _blockEditor;
996
- this._destroy$ = new Subject();
997
- }
998
- get el() {
999
- return this._el.nativeElement;
1000
- }
1001
- ngOnInit() {
1002
- this.config = Object.assign(Object.assign({}, this.config), { unit: 'in' });
1003
- this._blockEditor.blocks = this.config.blocks;
1004
- this._blockEditor.config = this.config;
1005
- this._blockEditor.blocks$
1006
- .pipe(takeUntil(this._destroy$))
1007
- .subscribe((blocks) => {
1008
- this.blocks = blocks;
1009
- });
1010
- setTimeout(() => {
1011
- this.zoomCenter();
1012
- });
1013
- }
1014
- zoomCenter() {
1015
- this.zoompan.center(this.artboard.nativeElement, { vertical: false });
1016
- }
1017
- editorContainerClick(event) {
1018
- if (event.target.classList.contains('deselectable') ||
1019
- event.target.classList.contains('fs-zoom-pan-container')) {
1020
- this.zoompan.enable();
1021
- this._blockEditor.selectedBlocks = [];
1022
- }
1023
- }
1024
- ngOnDestroy() {
1025
- this._destroy$.next();
1026
- this._destroy$.complete();
1027
- }
1028
- }
1029
- 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 });
1030
- FsBlockEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorComponent, selector: "fs-block-editor", inputs: { config: "config" }, providers: [
1031
- BlockEditorService,
1032
- ], 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$1.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$1.FsZoomPanContentDirective, selector: "[fsZoomPanContent]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1033
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorComponent, decorators: [{
1034
- type: Component,
1035
- args: [{
1036
- selector: 'fs-block-editor',
1037
- templateUrl: 'block-editor.component.html',
1038
- styleUrls: ['block-editor.component.scss'],
1039
- changeDetection: ChangeDetectionStrategy.OnPush,
1040
- providers: [
1041
- BlockEditorService,
1042
- ]
1043
- }]
1044
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }]; }, propDecorators: { sidebarPanels: [{
1045
- type: ContentChildren,
1046
- args: [FsBlockEditorSidebarPanelDirective]
1047
- }], zoompan: [{
1048
- type: ViewChild,
1049
- args: [FsZoomPanComponent, { static: true }]
1050
- }], artboardContainer: [{
1051
- type: ViewChild,
1052
- args: ['artboardContainer', { static: true }]
1053
- }], sidebar: [{
1054
- type: ViewChild,
1055
- args: [SidebarComponent, { static: true }]
1056
- }], artboard: [{
1057
- type: ViewChild,
1058
- args: [ArtboardComponent, { read: ElementRef }]
1059
- }], config: [{
1060
- type: Input
1126
+ class FsBlockEditorComponent {
1127
+ constructor(_el, _blockEditor) {
1128
+ this._el = _el;
1129
+ this._blockEditor = _blockEditor;
1130
+ this._destroy$ = new Subject();
1131
+ }
1132
+ get el() {
1133
+ return this._el.nativeElement;
1134
+ }
1135
+ ngOnInit() {
1136
+ this.config = Object.assign(Object.assign({}, this.config), { unit: 'in' });
1137
+ this._blockEditor.init(this.config);
1138
+ this._blockEditor.blocks$
1139
+ .pipe(takeUntil(this._destroy$))
1140
+ .subscribe((blocks) => {
1141
+ this.blocks = blocks;
1142
+ });
1143
+ setTimeout(() => {
1144
+ this.zoomCenter();
1145
+ });
1146
+ }
1147
+ zoomCenter() {
1148
+ this.zoompan.center(this.artboard.nativeElement, { vertical: false });
1149
+ }
1150
+ editorContainerClick(event) {
1151
+ if (event.target.classList.contains('deselectable') ||
1152
+ event.target.classList.contains('fs-zoom-pan-container')) {
1153
+ this.zoompan.enable();
1154
+ this._blockEditor.selectedBlocks = [];
1155
+ }
1156
+ }
1157
+ ngOnDestroy() {
1158
+ this._destroy$.next();
1159
+ this._destroy$.complete();
1160
+ }
1161
+ }
1162
+ 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 });
1163
+ FsBlockEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorComponent, selector: "fs-block-editor", inputs: { config: "config" }, providers: [
1164
+ BlockEditorService,
1165
+ BlocksStore,
1166
+ ], 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 });
1167
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorComponent, decorators: [{
1168
+ type: Component,
1169
+ args: [{
1170
+ selector: 'fs-block-editor',
1171
+ templateUrl: 'block-editor.component.html',
1172
+ styleUrls: ['block-editor.component.scss'],
1173
+ changeDetection: ChangeDetectionStrategy.OnPush,
1174
+ providers: [
1175
+ BlockEditorService,
1176
+ BlocksStore,
1177
+ ]
1178
+ }]
1179
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }]; }, propDecorators: { sidebarPanels: [{
1180
+ type: ContentChildren,
1181
+ args: [FsBlockEditorSidebarPanelDirective]
1182
+ }], zoompan: [{
1183
+ type: ViewChild,
1184
+ args: [FsZoomPanComponent, { static: true }]
1185
+ }], artboardContainer: [{
1186
+ type: ViewChild,
1187
+ args: ['artboardContainer', { static: true }]
1188
+ }], sidebar: [{
1189
+ type: ViewChild,
1190
+ args: [SidebarComponent, { static: true }]
1191
+ }], artboard: [{
1192
+ type: ViewChild,
1193
+ args: [ArtboardComponent, { read: ElementRef }]
1194
+ }], config: [{
1195
+ type: Input
1061
1196
  }] } });
1062
1197
 
1063
- class FsBlockEditorModule {
1064
- static forRoot() {
1065
- return {
1066
- ngModule: FsBlockEditorModule,
1067
- };
1068
- }
1069
- }
1070
- FsBlockEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1071
- FsBlockEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, declarations: [FsBlockComponent,
1072
- FsBlockEditorComponent,
1073
- FsBlockEditorSidebarPanelDirective,
1074
- FsBlockEditorMarginDirective,
1075
- SidebarComponent,
1076
- ArtboardComponent], imports: [CommonModule,
1077
- FormsModule,
1078
- MatIconModule,
1079
- MatButtonModule,
1080
- MatInputModule,
1081
- MatFormFieldModule,
1082
- MatCheckboxModule,
1083
- MatTooltipModule,
1084
- MatSelectModule,
1085
- FsFileModule,
1086
- FsColorPickerModule,
1087
- FsMenuModule,
1088
- FsZoomPanModule], exports: [FsBlockComponent,
1089
- FsBlockEditorComponent,
1090
- FsBlockEditorSidebarPanelDirective] });
1091
- FsBlockEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, imports: [[
1092
- CommonModule,
1093
- FormsModule,
1094
- MatIconModule,
1095
- MatButtonModule,
1096
- MatInputModule,
1097
- MatFormFieldModule,
1098
- MatCheckboxModule,
1099
- MatTooltipModule,
1100
- MatSelectModule,
1101
- FsFileModule,
1102
- FsColorPickerModule,
1103
- FsMenuModule,
1104
- FsZoomPanModule,
1105
- ]] });
1106
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, decorators: [{
1107
- type: NgModule,
1108
- args: [{
1109
- imports: [
1110
- CommonModule,
1111
- FormsModule,
1112
- MatIconModule,
1113
- MatButtonModule,
1114
- MatInputModule,
1115
- MatFormFieldModule,
1116
- MatCheckboxModule,
1117
- MatTooltipModule,
1118
- MatSelectModule,
1119
- FsFileModule,
1120
- FsColorPickerModule,
1121
- FsMenuModule,
1122
- FsZoomPanModule,
1123
- ],
1124
- exports: [
1125
- FsBlockComponent,
1126
- FsBlockEditorComponent,
1127
- FsBlockEditorSidebarPanelDirective,
1128
- ],
1129
- declarations: [
1130
- FsBlockComponent,
1131
- FsBlockEditorComponent,
1132
- FsBlockEditorSidebarPanelDirective,
1133
- FsBlockEditorMarginDirective,
1134
- SidebarComponent,
1135
- ArtboardComponent,
1136
- ],
1137
- }]
1198
+ class FsBlockEditorModule {
1199
+ static forRoot() {
1200
+ return {
1201
+ ngModule: FsBlockEditorModule,
1202
+ };
1203
+ }
1204
+ }
1205
+ FsBlockEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1206
+ FsBlockEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, declarations: [FsBlockComponent,
1207
+ FsBlockEditorComponent,
1208
+ FsBlockEditorSidebarPanelDirective,
1209
+ FsBlockEditorMarginDirective,
1210
+ SidebarComponent,
1211
+ ArtboardComponent,
1212
+ LayersReorderDialogComponent], imports: [CommonModule,
1213
+ FormsModule,
1214
+ MatIconModule,
1215
+ MatButtonModule,
1216
+ MatInputModule,
1217
+ MatFormFieldModule,
1218
+ MatCheckboxModule,
1219
+ MatTooltipModule,
1220
+ MatSelectModule,
1221
+ MatListModule,
1222
+ DragDropModule,
1223
+ FsFileModule,
1224
+ FsColorPickerModule,
1225
+ FsMenuModule,
1226
+ FsZoomPanModule,
1227
+ FsDialogModule], exports: [FsBlockComponent,
1228
+ FsBlockEditorComponent,
1229
+ FsBlockEditorSidebarPanelDirective] });
1230
+ FsBlockEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, imports: [[
1231
+ CommonModule,
1232
+ FormsModule,
1233
+ MatIconModule,
1234
+ MatButtonModule,
1235
+ MatInputModule,
1236
+ MatFormFieldModule,
1237
+ MatCheckboxModule,
1238
+ MatTooltipModule,
1239
+ MatSelectModule,
1240
+ MatListModule,
1241
+ DragDropModule,
1242
+ FsFileModule,
1243
+ FsColorPickerModule,
1244
+ FsMenuModule,
1245
+ FsZoomPanModule,
1246
+ FsDialogModule,
1247
+ ]] });
1248
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, decorators: [{
1249
+ type: NgModule,
1250
+ args: [{
1251
+ imports: [
1252
+ CommonModule,
1253
+ FormsModule,
1254
+ MatIconModule,
1255
+ MatButtonModule,
1256
+ MatInputModule,
1257
+ MatFormFieldModule,
1258
+ MatCheckboxModule,
1259
+ MatTooltipModule,
1260
+ MatSelectModule,
1261
+ MatListModule,
1262
+ DragDropModule,
1263
+ FsFileModule,
1264
+ FsColorPickerModule,
1265
+ FsMenuModule,
1266
+ FsZoomPanModule,
1267
+ FsDialogModule,
1268
+ ],
1269
+ exports: [
1270
+ FsBlockComponent,
1271
+ FsBlockEditorComponent,
1272
+ FsBlockEditorSidebarPanelDirective,
1273
+ ],
1274
+ declarations: [
1275
+ FsBlockComponent,
1276
+ FsBlockEditorComponent,
1277
+ FsBlockEditorSidebarPanelDirective,
1278
+ FsBlockEditorMarginDirective,
1279
+ SidebarComponent,
1280
+ ArtboardComponent,
1281
+ LayersReorderDialogComponent,
1282
+ ],
1283
+ }]
1138
1284
  }] });
1139
1285
 
1140
- /**
1141
- * Generated bundle index. Do not edit.
1286
+ /**
1287
+ * Generated bundle index. Do not edit.
1142
1288
  */
1143
1289
 
1144
1290
  export { BlockType, BlockTypes, FsBlockComponent, FsBlockEditorComponent, FsBlockEditorModule, FsBlockEditorSidebarPanelDirective };