@firestitch/block-editor 9.0.11 → 12.1.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 (55) hide show
  1. package/app/components/artboard/artboard.component.d.ts +35 -0
  2. package/app/components/block/block.component.d.ts +20 -38
  3. package/app/components/block-editor/block-editor.component.d.ts +10 -17
  4. package/app/components/sidebar/sidebar.component.d.ts +29 -12
  5. package/app/consts/block-types.const.d.ts +12 -0
  6. package/app/consts/index.d.ts +1 -0
  7. package/app/directives/block-editor-margin.directive.d.ts +3 -0
  8. package/app/directives/block-editor-sidebar-panel.directive.d.ts +3 -0
  9. package/app/enums/block-type.enum.d.ts +11 -0
  10. package/app/enums/index.d.ts +1 -0
  11. package/app/fs-block-editor.module.d.ts +22 -0
  12. package/app/interfaces/block-editor-config.d.ts +9 -7
  13. package/app/interfaces/block.d.ts +12 -1
  14. package/app/services/block-editor.service.d.ts +34 -14
  15. package/app/services/index.d.ts +1 -0
  16. package/bundles/firestitch-block-editor.umd.js +966 -838
  17. package/bundles/firestitch-block-editor.umd.js.map +1 -1
  18. package/esm2015/app/components/artboard/artboard.component.js +129 -0
  19. package/esm2015/app/components/block/block.component.js +162 -254
  20. package/esm2015/app/components/block-editor/block-editor.component.js +55 -131
  21. package/esm2015/app/components/sidebar/sidebar.component.js +128 -192
  22. package/esm2015/app/consts/block-types.const.js +13 -0
  23. package/esm2015/app/consts/index.js +2 -0
  24. package/esm2015/app/directives/block-editor-margin.directive.js +13 -15
  25. package/esm2015/app/directives/block-editor-sidebar-panel.directive.js +16 -22
  26. package/esm2015/app/enums/block-type.enum.js +13 -0
  27. package/esm2015/app/enums/index.js +2 -0
  28. package/esm2015/app/fs-block-editor.module.js +68 -27
  29. package/esm2015/app/interfaces/block-editor-config.js +2 -1
  30. package/esm2015/app/interfaces/block.js +2 -1
  31. package/esm2015/app/services/block-editor.service.js +140 -33
  32. package/esm2015/app/services/index.js +2 -0
  33. package/esm2015/firestitch-block-editor.js +1 -4
  34. package/esm2015/public_api.js +3 -4
  35. package/fesm2015/firestitch-block-editor.js +665 -626
  36. package/fesm2015/firestitch-block-editor.js.map +1 -1
  37. package/firestitch-block-editor.d.ts +1 -3
  38. package/package.json +6 -12
  39. package/public_api.d.ts +2 -0
  40. package/bundles/firestitch-block-editor.umd.min.js +0 -2
  41. package/bundles/firestitch-block-editor.umd.min.js.map +0 -1
  42. package/esm5/app/components/block/block.component.js +0 -498
  43. package/esm5/app/components/block-editor/block-editor.component.js +0 -163
  44. package/esm5/app/components/sidebar/sidebar.component.js +0 -329
  45. package/esm5/app/directives/block-editor-margin.directive.js +0 -26
  46. package/esm5/app/directives/block-editor-sidebar-panel.directive.js +0 -28
  47. package/esm5/app/fs-block-editor.module.js +0 -57
  48. package/esm5/app/interfaces/block-editor-config.js +0 -1
  49. package/esm5/app/interfaces/block.js +0 -1
  50. package/esm5/app/services/block-editor.service.js +0 -124
  51. package/esm5/firestitch-block-editor.js +0 -8
  52. package/esm5/public_api.js +0 -8
  53. package/fesm5/firestitch-block-editor.js +0 -1198
  54. package/fesm5/firestitch-block-editor.js.map +0 -1
  55. package/firestitch-block-editor.metadata.json +0 -1
@@ -1,1198 +0,0 @@
1
- import { __spread, __assign, __decorate, __metadata } from 'tslib';
2
- import { FormsModule } from '@angular/forms';
3
- import { MatInputModule } from '@angular/material/input';
4
- import { Injectable, EventEmitter, ElementRef, ChangeDetectorRef, ViewChild, Input, Output, Component, ChangeDetectionStrategy, TemplateRef, Directive, ContentChildren, QueryList, IterableDiffers, ViewChildren, NgModule } from '@angular/core';
5
- import { CommonModule } from '@angular/common';
6
- import { MatButtonModule } from '@angular/material/button';
7
- import { MatFormFieldModule } from '@angular/material/form-field';
8
- import { MatIconModule } from '@angular/material/icon';
9
- import { FsHtmlEditorComponent, FsHtmlEditorModule } from '@firestitch/html-editor';
10
- import { FsColorPickerModule } from '@firestitch/colorpicker';
11
- import { FsFileModule } from '@firestitch/file';
12
- import { takeUntil, filter, take } from 'rxjs/operators';
13
- import Moveable from 'moveable';
14
- import { BehaviorSubject, Subject, fromEvent } from 'rxjs';
15
- import { guid } from '@firestitch/common';
16
-
17
- var BlockEditorService = /** @class */ (function () {
18
- function BlockEditorService() {
19
- this.blockComponents = [];
20
- this._blocks$ = new BehaviorSubject([]);
21
- this._selectedBlockComponents$ = new BehaviorSubject([]);
22
- }
23
- Object.defineProperty(BlockEditorService.prototype, "elementGuidelines", {
24
- get: function () {
25
- return __spread(this.blockComponents.map(function (block) {
26
- return block.el;
27
- }), [
28
- this.container,
29
- this.margin,
30
- ]);
31
- },
32
- enumerable: true,
33
- configurable: true
34
- });
35
- BlockEditorService.prototype.addBlock = function (block) {
36
- this.blocks$.next(__spread(this.blocks, [this.sanitizeBlock(block)]));
37
- };
38
- BlockEditorService.prototype.removeBlock = function (block) {
39
- var index = this.indexOf(block);
40
- if (index !== -1) {
41
- this.blocks.splice(index, 1);
42
- this.blocks$.next(this.blocks);
43
- }
44
- };
45
- Object.defineProperty(BlockEditorService.prototype, "blocks$", {
46
- get: function () {
47
- return this._blocks$;
48
- },
49
- enumerable: true,
50
- configurable: true
51
- });
52
- Object.defineProperty(BlockEditorService.prototype, "blocks", {
53
- get: function () {
54
- return this.blocks$.getValue();
55
- },
56
- set: function (blocks) {
57
- this._blocks$.next(blocks);
58
- },
59
- enumerable: true,
60
- configurable: true
61
- });
62
- BlockEditorService.prototype.isSelectedBlock = function (block) {
63
- return this.selectedBlockComponents.indexOf(block) !== -1;
64
- };
65
- BlockEditorService.prototype.indexOf = function (block) {
66
- return this.blocks.map(function (e) { return e.reference; }).indexOf(block.reference);
67
- };
68
- Object.defineProperty(BlockEditorService.prototype, "selectedBlockComponents", {
69
- get: function () {
70
- return this._selectedBlockComponents$.getValue();
71
- },
72
- set: function (blocks) {
73
- this.blockComponents.forEach(function (block) {
74
- block.editable = false;
75
- block.transformable = blocks.indexOf(block) !== -1;
76
- });
77
- this._selectedBlockComponents$.next(blocks);
78
- },
79
- enumerable: true,
80
- configurable: true
81
- });
82
- Object.defineProperty(BlockEditorService.prototype, "selectedBlocks", {
83
- get: function () {
84
- return this.selectedBlockComponents.map(function (blockComponent) { return blockComponent.block; });
85
- },
86
- enumerable: true,
87
- configurable: true
88
- });
89
- Object.defineProperty(BlockEditorService.prototype, "selectedBlockComponents$", {
90
- get: function () {
91
- return this._selectedBlockComponents$;
92
- },
93
- enumerable: true,
94
- configurable: true
95
- });
96
- BlockEditorService.prototype.saveSelection = function () {
97
- var selection = window.getSelection();
98
- this._selectionRange = selection.getRangeAt(0);
99
- };
100
- BlockEditorService.prototype.restoreSelection = function () {
101
- if (this._selectionRange) {
102
- var selection = window.getSelection();
103
- selection.removeAllRanges();
104
- selection.addRange(this._selectionRange);
105
- }
106
- };
107
- BlockEditorService.prototype.hasSelectionRange = function () {
108
- return this._selectionRange && (this._selectionRange.baseOffset - this._selectionRange.focusOffset) > 0;
109
- };
110
- BlockEditorService.prototype.registerBlock = function (block) {
111
- var _this = this;
112
- this.blockComponents.push(block);
113
- this.blockComponents.forEach(function (item) {
114
- var blocks = _this.elementGuidelines
115
- .filter(function (el) {
116
- return !el.isSameNode(item.el);
117
- });
118
- item.elementGuidelines = blocks;
119
- });
120
- };
121
- BlockEditorService.prototype.registerContainer = function (container) {
122
- this.container = container;
123
- };
124
- BlockEditorService.prototype.registerMargin = function (margin) {
125
- this.margin = margin;
126
- };
127
- BlockEditorService.prototype.sanitizeBlock = function (block) {
128
- return __assign({ shapeBottomLeft: 'round', shapeTopLeft: 'round', shapeTopRight: 'round', shapeBottomRight: 'round', verticalAlign: 'top', horizontalAlign: 'left' }, block);
129
- };
130
- BlockEditorService = __decorate([
131
- Injectable(),
132
- __metadata("design:paramtypes", [])
133
- ], BlockEditorService);
134
- return BlockEditorService;
135
- }());
136
-
137
- var FsBlockComponent = /** @class */ (function () {
138
- function FsBlockComponent(_service, _elementRef, _cdRef) {
139
- this._service = _service;
140
- this._elementRef = _elementRef;
141
- this._cdRef = _cdRef;
142
- this.changed = new EventEmitter();
143
- this.htmlConfig = {};
144
- this._editable = false;
145
- this._selectedElements = [];
146
- this._destroy$ = new Subject();
147
- }
148
- Object.defineProperty(FsBlockComponent.prototype, "el", {
149
- get: function () {
150
- return this.element.nativeElement;
151
- },
152
- enumerable: true,
153
- configurable: true
154
- });
155
- Object.defineProperty(FsBlockComponent.prototype, "moveable", {
156
- get: function () {
157
- return this._moveable;
158
- },
159
- enumerable: true,
160
- configurable: true
161
- });
162
- Object.defineProperty(FsBlockComponent.prototype, "editable", {
163
- get: function () {
164
- return this._editable;
165
- },
166
- set: function (value) {
167
- this._editable = value;
168
- if (!value) {
169
- this.deselectContent();
170
- }
171
- },
172
- enumerable: true,
173
- configurable: true
174
- });
175
- Object.defineProperty(FsBlockComponent.prototype, "elementGuidelines", {
176
- set: function (value) {
177
- this._moveable.elementGuidelines = value;
178
- },
179
- enumerable: true,
180
- configurable: true
181
- });
182
- Object.defineProperty(FsBlockComponent.prototype, "clippable", {
183
- set: function (value) {
184
- this._moveable.clippable = value;
185
- },
186
- enumerable: true,
187
- configurable: true
188
- });
189
- Object.defineProperty(FsBlockComponent.prototype, "transformable", {
190
- get: function () {
191
- return this._transformable;
192
- },
193
- set: function (value) {
194
- this._transformable = value;
195
- this.moveable.draggable = value;
196
- this.moveable.resizable = value;
197
- this.moveable.draggable = value;
198
- this.moveable.roundable = value;
199
- this.moveable.rotatable = value;
200
- },
201
- enumerable: true,
202
- configurable: true
203
- });
204
- Object.defineProperty(FsBlockComponent.prototype, "lineHeight", {
205
- set: function (value) {
206
- this.block.lineHeight = value;
207
- this._triggerChanged();
208
- },
209
- enumerable: true,
210
- configurable: true
211
- });
212
- Object.defineProperty(FsBlockComponent.prototype, "borderWidth", {
213
- set: function (value) {
214
- this.block.borderWidth = value;
215
- this._triggerChanged();
216
- },
217
- enumerable: true,
218
- configurable: true
219
- });
220
- Object.defineProperty(FsBlockComponent.prototype, "fontSize", {
221
- set: function (value) {
222
- this.block.fontSize = value;
223
- this._triggerChanged();
224
- },
225
- enumerable: true,
226
- configurable: true
227
- });
228
- Object.defineProperty(FsBlockComponent.prototype, "backgroundColor", {
229
- set: function (value) {
230
- this.block.backgroundColor = value;
231
- this._triggerChanged();
232
- },
233
- enumerable: true,
234
- configurable: true
235
- });
236
- Object.defineProperty(FsBlockComponent.prototype, "width", {
237
- set: function (value) {
238
- this.block.width = parseFloat(value);
239
- this.element.nativeElement.style.width = "" + this.block.width + this.unit;
240
- this._moveable.updateRect();
241
- this._triggerChanged();
242
- },
243
- enumerable: true,
244
- configurable: true
245
- });
246
- Object.defineProperty(FsBlockComponent.prototype, "height", {
247
- set: function (value) {
248
- this.block.height = parseFloat(value);
249
- this.element.nativeElement.style.height = "" + this.block.height + this.unit;
250
- this._moveable.updateRect();
251
- this._triggerChanged();
252
- },
253
- enumerable: true,
254
- configurable: true
255
- });
256
- Object.defineProperty(FsBlockComponent.prototype, "top", {
257
- set: function (value) {
258
- this.block.top = parseFloat(value);
259
- this.element.nativeElement.style.top = "" + this.block.top + this.unit;
260
- this._moveable.updateRect();
261
- this._triggerChanged();
262
- },
263
- enumerable: true,
264
- configurable: true
265
- });
266
- Object.defineProperty(FsBlockComponent.prototype, "left", {
267
- set: function (value) {
268
- this.block.left = parseFloat(value);
269
- this.element.nativeElement.style.left = "" + this.block.left + this.unit;
270
- this._moveable.updateRect();
271
- this._triggerChanged();
272
- },
273
- enumerable: true,
274
- configurable: true
275
- });
276
- Object.defineProperty(FsBlockComponent.prototype, "rotate", {
277
- set: function (value) {
278
- this.block.rotate = parseFloat(value);
279
- this._moveable.request('rotatable', { rotate: this.block.rotate }, true);
280
- this._triggerChanged();
281
- },
282
- enumerable: true,
283
- configurable: true
284
- });
285
- Object.defineProperty(FsBlockComponent.prototype, "shapeRadius", {
286
- set: function (value) {
287
- this.block.shapeRadius = value;
288
- this._triggerChanged();
289
- },
290
- enumerable: true,
291
- configurable: true
292
- });
293
- Object.defineProperty(FsBlockComponent.prototype, "index", {
294
- set: function (value) {
295
- this.block.index = value;
296
- },
297
- enumerable: true,
298
- configurable: true
299
- });
300
- Object.defineProperty(FsBlockComponent.prototype, "borderColor", {
301
- set: function (value) {
302
- this.block.borderColor = value;
303
- this._triggerChanged();
304
- },
305
- enumerable: true,
306
- configurable: true
307
- });
308
- Object.defineProperty(FsBlockComponent.prototype, "paddingAll", {
309
- set: function (value) {
310
- this.block.padding = value;
311
- this.block.paddingTop = null;
312
- this.block.paddingBottom = null;
313
- this.block.paddingLeft = null;
314
- this.block.paddingRight = null;
315
- this._triggerChanged();
316
- },
317
- enumerable: true,
318
- configurable: true
319
- });
320
- FsBlockComponent.prototype.padding = function (name, value) {
321
- this.block[name] = value;
322
- this.block.padding = null;
323
- this._triggerChanged();
324
- };
325
- Object.defineProperty(FsBlockComponent.prototype, "imageUrl", {
326
- set: function (value) {
327
- this.block.imageUrl = value;
328
- this._triggerChanged();
329
- },
330
- enumerable: true,
331
- configurable: true
332
- });
333
- Object.defineProperty(FsBlockComponent.prototype, "fontColor", {
334
- set: function (value) {
335
- this.block.fontColor = value;
336
- this._triggerChanged();
337
- },
338
- enumerable: true,
339
- configurable: true
340
- });
341
- Object.defineProperty(FsBlockComponent.prototype, "verticalAlign", {
342
- set: function (value) {
343
- this.block.verticalAlign = value;
344
- this._triggerChanged();
345
- },
346
- enumerable: true,
347
- configurable: true
348
- });
349
- FsBlockComponent.prototype.shapeRound = function (name, value) {
350
- this.block[name] = value;
351
- this._triggerChanged();
352
- };
353
- Object.defineProperty(FsBlockComponent.prototype, "horizontalAlign", {
354
- set: function (value) {
355
- this.block.horizontalAlign = value;
356
- this._triggerChanged();
357
- },
358
- enumerable: true,
359
- configurable: true
360
- });
361
- Object.defineProperty(FsBlockComponent.prototype, "italic", {
362
- get: function () {
363
- return this.block.italic;
364
- },
365
- set: function (value) {
366
- this.block.italic = value;
367
- this._triggerChanged();
368
- },
369
- enumerable: true,
370
- configurable: true
371
- });
372
- Object.defineProperty(FsBlockComponent.prototype, "bold", {
373
- get: function () {
374
- return this.block.bold;
375
- },
376
- set: function (value) {
377
- this.block.bold = value;
378
- this._triggerChanged();
379
- },
380
- enumerable: true,
381
- configurable: true
382
- });
383
- Object.defineProperty(FsBlockComponent.prototype, "underline", {
384
- get: function () {
385
- return this.block.underline;
386
- },
387
- set: function (value) {
388
- this.block.underline = value;
389
- this._triggerChanged();
390
- },
391
- enumerable: true,
392
- configurable: true
393
- });
394
- FsBlockComponent.prototype.updateRect = function () {
395
- this.moveable.updateRect();
396
- };
397
- FsBlockComponent.prototype.markForCheck = function () {
398
- this._cdRef.markForCheck();
399
- };
400
- FsBlockComponent.prototype.ngOnInit = function () {
401
- this.block = this._service.sanitizeBlock(this.block);
402
- this.unit = this._service.config.unit;
403
- this.content = this.block.content;
404
- this.htmlConfig = {
405
- autofocus: false,
406
- froalaConfig: {}
407
- };
408
- };
409
- FsBlockComponent.prototype.saveSelectedElements = function () {
410
- this._selectedElements = this.htmlEditor.editor.selection.blocks();
411
- };
412
- FsBlockComponent.prototype.clearSelectedElements = function () {
413
- this._selectedElements = [];
414
- };
415
- FsBlockComponent.prototype.ngAfterContentInit = function () {
416
- var _this = this;
417
- this.el.style.width = this.block.width + this.unit;
418
- this.el.style.height = this.block.height + this.unit;
419
- this.el.style.top = this.block.top + this.unit;
420
- this.el.style.left = this.block.left + this.unit;
421
- this._setTransform();
422
- fromEvent(this.contentEditable.nativeElement, 'input')
423
- .pipe(takeUntil(this._destroy$)).subscribe(function (event) {
424
- _this.block.content = event.target.innerHTML;
425
- _this._triggerChanged();
426
- });
427
- fromEvent(this.el, 'mousedown')
428
- .pipe(takeUntil(this._destroy$), filter(function () { return !_this.block.readonly; })).subscribe(function (event) {
429
- if (_this.editable) {
430
- if (_this.contentElement.nativeElement.isSameNode(event.target)) {
431
- event.preventDefault();
432
- event.stopImmediatePropagation();
433
- event.stopPropagation();
434
- }
435
- }
436
- else {
437
- _this._service.selectedBlockComponents = [_this];
438
- }
439
- });
440
- fromEvent(this.el, 'dblclick')
441
- .pipe(filter(function () { return (!_this.editable); }), takeUntil(this._destroy$))
442
- .subscribe(function (event) {
443
- if (_this.block.readonly) {
444
- event.preventDefault();
445
- }
446
- else {
447
- _this.editable = true;
448
- _this._cdRef.markForCheck();
449
- setTimeout(function () {
450
- _this.selectAll();
451
- });
452
- }
453
- });
454
- this._moveable = new Moveable(this._elementRef.nativeElement, {
455
- target: this.el,
456
- container: this._service.container,
457
- draggable: false,
458
- resizable: false,
459
- scalable: false,
460
- rotatable: false,
461
- warpable: false,
462
- origin: false,
463
- keepRatio: false,
464
- snappable: true,
465
- snapHorizontal: true,
466
- snapVertical: true,
467
- snapCenter: true,
468
- snapElement: true,
469
- edge: false,
470
- throttleDrag: 1,
471
- throttleScale: 0.01,
472
- throttleRotate: 1,
473
- throttleResize: 1,
474
- });
475
- this._service.registerBlock(this);
476
- this._moveable
477
- .on('clip', function (e) {
478
- _this.block.clipPath = e.clipStyle;
479
- e.target.style.clipPath = e.clipStyle;
480
- _this._triggerChanged();
481
- });
482
- this._moveable.on('dragStart', function (_a) {
483
- var target = _a.target, clientX = _a.clientX, clientY = _a.clientY;
484
- _this.editable = false;
485
- }).on('drag', function (_a) {
486
- var target = _a.target, left = _a.left, top = _a.top;
487
- target.style.left = _this.pxToIn(left) + _this.unit;
488
- target.style.top = _this.pxToIn(top) + _this.unit;
489
- _this.block.top = _this.pxToIn(top);
490
- _this.block.left = _this.pxToIn(left);
491
- _this._triggerChanged();
492
- });
493
- this._moveable.on('resizeStart', function (_a) {
494
- var target = _a.target, clientX = _a.clientX, clientY = _a.clientY;
495
- _this.editable = false;
496
- }).on('resize', function (_a) {
497
- var target = _a.target, width = _a.width, height = _a.height, dist = _a.dist, delta = _a.delta, direction = _a.direction;
498
- width = _this.pxToIn(width);
499
- height = _this.pxToIn(height);
500
- if (delta[0]) {
501
- _this.block.width = width;
502
- target.style.width = width + _this.unit;
503
- }
504
- if (delta[1]) {
505
- _this.block.height = height;
506
- target.style.height = height + _this.unit;
507
- }
508
- var transform = [0, 0];
509
- if (direction[1] === -1) {
510
- transform[1] = dist[1] * -1;
511
- }
512
- if (direction[0] === -1) {
513
- transform[0] = dist[0] * -1;
514
- }
515
- _this._setTransform(["translate(" + transform[0] + "px, " + transform[1] + "px)"]);
516
- _this._triggerChanged();
517
- }).on('resizeEnd', function (_a) {
518
- var target = _a.target;
519
- var matrix = new WebKitCSSMatrix(target.style.transform);
520
- _this.block.top = parseFloat(target.style.top) + _this.pxToIn(matrix.m42);
521
- _this.block.left = parseFloat(target.style.left) + _this.pxToIn(matrix.m41);
522
- target.style.top = _this.block.top + _this.unit;
523
- target.style.left = _this.block.left + _this.unit;
524
- _this._setTransform();
525
- _this._triggerChanged();
526
- });
527
- this._moveable.on('rotateStart', function (_a) {
528
- var target = _a.target, clientX = _a.clientX, clientY = _a.clientY;
529
- _this.editable = false;
530
- _this._rotateStart = _this.block.rotate || 0;
531
- }).on('rotate', function (_a) {
532
- var rotate = _a.rotate, transform = _a.transform;
533
- _this.block.rotate = _this._rotateStart + rotate;
534
- _this.el.style.transform = transform;
535
- _this._triggerChanged();
536
- });
537
- };
538
- FsBlockComponent.prototype.pxToIn = function (px) {
539
- return this.round(px / 96, 2);
540
- };
541
- FsBlockComponent.prototype.round = function (value, decimals) {
542
- return parseFloat(value.toFixed(decimals));
543
- };
544
- FsBlockComponent.prototype.deselect = function () {
545
- this.transformable = false;
546
- this.editable = false;
547
- };
548
- FsBlockComponent.prototype.deselectContent = function () {
549
- if (window.getSelection) {
550
- if (window.getSelection().empty) {
551
- window.getSelection().empty();
552
- }
553
- else if (window.getSelection().removeAllRanges) {
554
- window.getSelection().removeAllRanges();
555
- }
556
- }
557
- };
558
- FsBlockComponent.prototype.selectAll = function () {
559
- var range = document.createRange();
560
- range.selectNodeContents(this.contentEditable.nativeElement);
561
- var sel = window.getSelection();
562
- sel.removeAllRanges();
563
- sel.addRange(range);
564
- };
565
- FsBlockComponent.prototype.ngOnDestroy = function () {
566
- this._destroy$.next();
567
- this._destroy$.complete();
568
- };
569
- FsBlockComponent.prototype._setTransform = function (transforms) {
570
- if (transforms === void 0) { transforms = []; }
571
- transforms = (transforms !== null && transforms !== void 0 ? transforms : []);
572
- if (this.block.rotate) {
573
- transforms.push("rotate(" + this.block.rotate + "deg)");
574
- }
575
- this.el.style.transform = transforms.join(' ');
576
- };
577
- FsBlockComponent.prototype._triggerChanged = function () {
578
- this.changed.emit(this.block);
579
- };
580
- FsBlockComponent.ctorParameters = function () { return [
581
- { type: BlockEditorService },
582
- { type: ElementRef },
583
- { type: ChangeDetectorRef }
584
- ]; };
585
- __decorate([
586
- ViewChild('element', { static: true }),
587
- __metadata("design:type", ElementRef)
588
- ], FsBlockComponent.prototype, "element", void 0);
589
- __decorate([
590
- ViewChild('contentElement', { static: true }),
591
- __metadata("design:type", ElementRef)
592
- ], FsBlockComponent.prototype, "contentElement", void 0);
593
- __decorate([
594
- ViewChild('contentEditable', { static: true }),
595
- __metadata("design:type", ElementRef)
596
- ], FsBlockComponent.prototype, "contentEditable", void 0);
597
- __decorate([
598
- ViewChild(FsHtmlEditorComponent),
599
- __metadata("design:type", FsHtmlEditorComponent)
600
- ], FsBlockComponent.prototype, "htmlEditor", void 0);
601
- __decorate([
602
- Input(),
603
- __metadata("design:type", Object)
604
- ], FsBlockComponent.prototype, "block", void 0);
605
- __decorate([
606
- Input(),
607
- __metadata("design:type", String)
608
- ], FsBlockComponent.prototype, "html", void 0);
609
- __decorate([
610
- Output(),
611
- __metadata("design:type", Object)
612
- ], FsBlockComponent.prototype, "changed", void 0);
613
- FsBlockComponent = __decorate([
614
- Component({
615
- selector: 'fs-block',
616
- template: "<div\n #element\n class=\"block\"\n [ngClass]=\"{ editable: editable, readonly: block.readonly }\">\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 <img [src]=\"block.imageUrl\" *ngIf=\"block.imageUrl\">\n <div\n #contentEditable\n [contentEditable]=\"editable\"\n class=\"content-editable\"\n [innerHTML]=\"content\">\n </div>\n </div>\n</div>\n",
617
- changeDetection: ChangeDetectionStrategy.OnPush,
618
- styles: [".block{position:absolute;display:block;outline:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.block:not(.readonly){cursor:pointer}.block .content-editable{outline:0;position:relative}.block.editable .content-editable{cursor:text}.block .content{flex-direction:column;height:100%;display:flex;border:1px dashed #c5c5c5;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:0 0!important;border:none!important}:host ::ng-deep .moveable-line:not(.moveable-rotation-line):not(.moveable-guideline){background:0 0!important}"]
619
- }),
620
- __metadata("design:paramtypes", [BlockEditorService,
621
- ElementRef,
622
- ChangeDetectorRef])
623
- ], FsBlockComponent);
624
- return FsBlockComponent;
625
- }());
626
-
627
- var FsBlockEditorSidebarPanelDirective = /** @class */ (function () {
628
- function FsBlockEditorSidebarPanelDirective(templateRef) {
629
- this.templateRef = templateRef;
630
- this.show = true;
631
- }
632
- FsBlockEditorSidebarPanelDirective.ctorParameters = function () { return [
633
- { type: TemplateRef }
634
- ]; };
635
- __decorate([
636
- Input(),
637
- __metadata("design:type", String)
638
- ], FsBlockEditorSidebarPanelDirective.prototype, "label", void 0);
639
- __decorate([
640
- Input(),
641
- __metadata("design:type", Object)
642
- ], FsBlockEditorSidebarPanelDirective.prototype, "show", void 0);
643
- FsBlockEditorSidebarPanelDirective = __decorate([
644
- Directive({
645
- selector: '[fsBlockEditorSidebarPanel]'
646
- }),
647
- __metadata("design:paramtypes", [TemplateRef])
648
- ], FsBlockEditorSidebarPanelDirective);
649
- return FsBlockEditorSidebarPanelDirective;
650
- }());
651
-
652
- var FsBlockEditorMarginDirective = /** @class */ (function () {
653
- function FsBlockEditorMarginDirective(_elementRef) {
654
- this._elementRef = _elementRef;
655
- }
656
- Object.defineProperty(FsBlockEditorMarginDirective.prototype, "element", {
657
- get: function () {
658
- return this._elementRef.nativeElement;
659
- },
660
- enumerable: true,
661
- configurable: true
662
- });
663
- FsBlockEditorMarginDirective.ctorParameters = function () { return [
664
- { type: ElementRef }
665
- ]; };
666
- FsBlockEditorMarginDirective = __decorate([
667
- Directive({
668
- selector: '[fsBlockEditorMargin]'
669
- }),
670
- __metadata("design:paramtypes", [ElementRef])
671
- ], FsBlockEditorMarginDirective);
672
- return FsBlockEditorMarginDirective;
673
- }());
674
-
675
- var SidebarComponent = /** @class */ (function () {
676
- function SidebarComponent(_el, _service, _cdRef) {
677
- this._el = _el;
678
- this._service = _service;
679
- this._cdRef = _cdRef;
680
- this._destroy$ = new Subject();
681
- }
682
- Object.defineProperty(SidebarComponent.prototype, "changeDetector", {
683
- get: function () {
684
- return this._cdRef;
685
- },
686
- enumerable: true,
687
- configurable: true
688
- });
689
- Object.defineProperty(SidebarComponent.prototype, "el", {
690
- get: function () {
691
- return this._el.nativeElement;
692
- },
693
- enumerable: true,
694
- configurable: true
695
- });
696
- SidebarComponent.prototype.ngOnInit = function () {
697
- var _this = this;
698
- this._service.selectedBlockComponents$
699
- .pipe(takeUntil(this._destroy$))
700
- .subscribe(function (blocks) {
701
- _this.clippable = false;
702
- _this.block = blocks[0] ? blocks[0].block : null;
703
- _this.changeDetector.markForCheck();
704
- if (_this.config.blocksSelected) {
705
- _this.config.blocksSelected(blocks.map(function (block) { return block.block; }));
706
- }
707
- });
708
- };
709
- SidebarComponent.prototype.verticalAlignClick = function (value) {
710
- this._service.selectedBlockComponents.forEach(function (block) {
711
- block.verticalAlign = value;
712
- });
713
- };
714
- SidebarComponent.prototype.boldClick = function () {
715
- this._service.selectedBlockComponents.forEach(function (block) {
716
- block.bold = !block.bold;
717
- });
718
- };
719
- SidebarComponent.prototype.fontColorChange = function (value) {
720
- this._service.selectedBlockComponents.forEach(function (block) {
721
- block.fontColor = value;
722
- });
723
- };
724
- SidebarComponent.prototype.lineHeightChange = function (value) {
725
- var _this = this;
726
- this._service.selectedBlockComponents.forEach(function (block) {
727
- if (_this.validNumeric(value)) {
728
- block.lineHeight = value || null;
729
- }
730
- });
731
- };
732
- SidebarComponent.prototype.fontSizeChange = function (value) {
733
- var _this = this;
734
- this._service.selectedBlockComponents.forEach(function (block) {
735
- if (_this.validNumeric(value)) {
736
- block.fontSize = value || null;
737
- }
738
- });
739
- };
740
- SidebarComponent.prototype.borderWidthChange = function (value) {
741
- var _this = this;
742
- this._service.selectedBlockComponents.forEach(function (block) {
743
- if (_this.validNumeric(value)) {
744
- block.borderWidth = value || null;
745
- }
746
- });
747
- };
748
- SidebarComponent.prototype.italicClick = function () {
749
- this._service.selectedBlockComponents.forEach(function (block) {
750
- block.italic = !block.italic;
751
- });
752
- };
753
- SidebarComponent.prototype.underlineClick = function () {
754
- this._service.selectedBlockComponents.forEach(function (block) {
755
- block.underline = !block.underline;
756
- });
757
- };
758
- SidebarComponent.prototype.backgroundColorChange = function (value) {
759
- this._service.selectedBlockComponents.forEach(function (block) {
760
- block.backgroundColor = value;
761
- });
762
- };
763
- SidebarComponent.prototype.widthChange = function (value) {
764
- var _this = this;
765
- this._service.selectedBlockComponents.forEach(function (block) {
766
- if (_this.validNumeric(value)) {
767
- block.width = value;
768
- }
769
- });
770
- };
771
- SidebarComponent.prototype.heightChange = function (value) {
772
- var _this = this;
773
- this._service.selectedBlockComponents.forEach(function (block) {
774
- if (_this.validNumeric(value)) {
775
- block.height = value;
776
- }
777
- });
778
- };
779
- SidebarComponent.prototype.topChange = function (value) {
780
- var _this = this;
781
- this._service.selectedBlockComponents.forEach(function (block) {
782
- if (_this.validNumeric(value)) {
783
- block.top = value;
784
- }
785
- });
786
- };
787
- SidebarComponent.prototype.leftChange = function (value) {
788
- var _this = this;
789
- this._service.selectedBlockComponents.forEach(function (block) {
790
- if (_this.validNumeric(value)) {
791
- block.left = value;
792
- }
793
- });
794
- };
795
- SidebarComponent.prototype.rotateChange = function (value) {
796
- var _this = this;
797
- this._service.selectedBlockComponents.forEach(function (block) {
798
- if (_this.validNumeric(value)) {
799
- block.rotate = value;
800
- }
801
- });
802
- };
803
- SidebarComponent.prototype.paddingChange = function (name, value) {
804
- var _this = this;
805
- this._service.selectedBlockComponents.forEach(function (block) {
806
- if (_this.validNumeric(value)) {
807
- block.padding(name, value || null);
808
- }
809
- });
810
- };
811
- SidebarComponent.prototype.paddingAllChange = function (value) {
812
- var _this = this;
813
- this._service.selectedBlockComponents.forEach(function (block) {
814
- if (_this.validNumeric(value)) {
815
- block.paddingAll = value;
816
- }
817
- });
818
- };
819
- SidebarComponent.prototype.borderColorChange = function (value) {
820
- this._service.selectedBlockComponents.forEach(function (block) {
821
- block.borderColor = value;
822
- });
823
- };
824
- SidebarComponent.prototype.horizontalAlignClick = function (value) {
825
- this._service.selectedBlockComponents.forEach(function (block) {
826
- block.horizontalAlign = value;
827
- });
828
- };
829
- SidebarComponent.prototype.shapeRound = function (value) {
830
- this._service.selectedBlockComponents.forEach(function (block) {
831
- block.shapeRound(value, block.block[value] === 'round' ? 'square' : 'round');
832
- });
833
- };
834
- SidebarComponent.prototype.imageRemove = function () {
835
- this._service.selectedBlockComponents.forEach(function (block) {
836
- block.imageUrl = null;
837
- });
838
- };
839
- SidebarComponent.prototype.imageClip = function () {
840
- var _this = this;
841
- this.clippable = !this.clippable;
842
- this._service.selectedBlockComponents.forEach(function (block) {
843
- block.clippable = _this.clippable;
844
- });
845
- };
846
- SidebarComponent.prototype.shapeRadiusChange = function (value) {
847
- this._service.selectedBlockComponents.forEach(function (block) {
848
- block.shapeRadius = value;
849
- });
850
- };
851
- SidebarComponent.prototype.fileSelect = function (fsFile) {
852
- var _this = this;
853
- if (this.config.fileUpload) {
854
- this.config.fileUpload(fsFile.file)
855
- .subscribe(function (value) {
856
- _this._service.selectedBlockComponents.forEach(function (block) {
857
- block.imageUrl = value;
858
- });
859
- });
860
- }
861
- };
862
- SidebarComponent.prototype.blockRemoveClick = function () {
863
- var _this = this;
864
- if (this.config.blocksRemoved) {
865
- this.config.blocksRemoved(this._service.selectedBlocks)
866
- .pipe(takeUntil(this._destroy$))
867
- .subscribe(function () {
868
- _this._service.selectedBlocks.forEach(function (block) {
869
- _this._service.removeBlock(block);
870
- });
871
- _this._service.selectedBlockComponents = [];
872
- });
873
- }
874
- };
875
- SidebarComponent.prototype.blockAddClick = function () {
876
- var _this = this;
877
- var width = (this.config.width * .333).toFixed(2);
878
- var height = (this.config.height * .333).toFixed(2);
879
- var reference = guid();
880
- var block = {
881
- type: 'text',
882
- reference: reference,
883
- top: height,
884
- left: width,
885
- width: width,
886
- height: height,
887
- };
888
- if (this.config.blockAdded) {
889
- this.config.blockAdded(block)
890
- .pipe(takeUntil(this._destroy$))
891
- .subscribe(function (block) {
892
- _this.addBlock(block);
893
- _this.changeDetector.markForCheck();
894
- _this.blockAdded
895
- .pipe(take(1), takeUntil(_this._destroy$))
896
- .subscribe(function (blockComponent) {
897
- _this._service.selectedBlockComponents = [blockComponent];
898
- });
899
- });
900
- }
901
- };
902
- SidebarComponent.prototype.addBlock = function (block) {
903
- this._service.addBlock(block);
904
- this._updateIndexes();
905
- };
906
- SidebarComponent.prototype._updateIndexes = function () {
907
- var _this = this;
908
- var sort = this.blocks.slice().sort(function (a, b) {
909
- return a.index > b.index ? 1 : -1;
910
- });
911
- sort.forEach(function (block, index) {
912
- _this.blocks.find(function (item) {
913
- return block.reference === item.reference;
914
- }).index = index;
915
- });
916
- };
917
- SidebarComponent.prototype.layerMove = function (direction) {
918
- var _this = this;
919
- this._service.blockComponents.forEach(function (blockComponent) {
920
- if (_this._service.isSelectedBlock(blockComponent)) {
921
- blockComponent.block.index + (999 * direction);
922
- }
923
- });
924
- var sorted = this._service.blockComponents.sort(function (a, b) {
925
- return a.index > b.index ? 1 : -1;
926
- });
927
- sorted.forEach(function (item, index) {
928
- item.block.index = index;
929
- item.markForCheck();
930
- });
931
- if (this.config.blocksLevelChanged) {
932
- this.config.blocksLevelChanged(sorted.map(function (item) { return item.block; }));
933
- }
934
- };
935
- SidebarComponent.prototype.layerUp = function () {
936
- this.layerMove(1);
937
- };
938
- SidebarComponent.prototype.layerDown = function () {
939
- this.layerMove(-1);
940
- };
941
- SidebarComponent.prototype.getBlock = function (reference) {
942
- return this._service.blocks.find(function (block) {
943
- return block.reference === reference;
944
- });
945
- };
946
- SidebarComponent.prototype.blockChanged = function (block) {
947
- if (this.config.blockChanged) {
948
- this.config.blockChanged(block);
949
- }
950
- };
951
- SidebarComponent.prototype.inputFocus = function (event) {
952
- event.target.select();
953
- };
954
- SidebarComponent.prototype.ngOnDestroy = function () {
955
- this._destroy$.next();
956
- this._destroy$.complete();
957
- };
958
- SidebarComponent.prototype.validNumeric = function (value) {
959
- return !value || !!String(value).match(/^\d*\.?\d*$/);
960
- };
961
- SidebarComponent.ctorParameters = function () { return [
962
- { type: ElementRef },
963
- { type: BlockEditorService },
964
- { type: ChangeDetectorRef }
965
- ]; };
966
- __decorate([
967
- ContentChildren(FsBlockEditorSidebarPanelDirective),
968
- __metadata("design:type", QueryList)
969
- ], SidebarComponent.prototype, "sidebarPanels", void 0);
970
- __decorate([
971
- Input(),
972
- __metadata("design:type", Object)
973
- ], SidebarComponent.prototype, "config", void 0);
974
- __decorate([
975
- Input(),
976
- __metadata("design:type", Object)
977
- ], SidebarComponent.prototype, "blocks", void 0);
978
- __decorate([
979
- Input(),
980
- __metadata("design:type", EventEmitter)
981
- ], SidebarComponent.prototype, "blockAdded", void 0);
982
- SidebarComponent = __decorate([
983
- Component({
984
- selector: 'sidebar',
985
- template: "<div class=\"sidebar mat-elevation-z2\">\n <div class=\"sidebar-panel\">\n <div class=\"sidebar-label\">Tools</div>\n <div class=\"sidebar-row\">\n <button\n mat-icon-button\n color=\"basic\"\n type=\"button\"\n (click)=\"blockAddClick()\">\n <mat-icon>add</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>clear</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.width\"\n name=\"width\"\n (focus)=\"inputFocus($event)\"\n (ngModelChange)=\"widthChange($event)\">\n <span matPrefix>W</span>\n </mat-form-field>\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 <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 </div>\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 <div class=\"sidebar-panel\">\n <div class=\"sidebar-label\">Image</div>\n <div class=\"sidebar-row image-row\">\n <fs-file (select)=\"fileSelect($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 <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",
986
- changeDetection: ChangeDetectionStrategy.OnPush,
987
- styles: [".sidebar{width:285px;font-size:14px;height:100%}.sidebar .sidebar-row{display:flex;flex-direction:row;flex-wrap:wrap;align-items:center}.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 .field-label,.sidebar .sidebar-row ::ng-deep .mat-form-field-prefix{color:#a5a5a5;font-size:11px;margin-right:2px}.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-down ::ng-deep .mat-button-wrapper,.sidebar .layer-up ::ng-deep .mat-button-wrapper{position:relative}.sidebar .layer-down ::ng-deep .mat-button-wrapper mat-icon:first-child,.sidebar .layer-up ::ng-deep .mat-button-wrapper mat-icon:first-child{position:absolute;transform:rotate(90deg) scale(.6);top:-6px;color:#fff}.sidebar .layer-down mat-icon:first-child{transform:rotate(270deg) scale(.6)}.sidebar .border-width,.sidebar .font-size,.sidebar .line-height,.sidebar .padding{width:45px}.sidebar .shape-radius{width:50px}.sidebar .shape-corners{display:-ms-grid;display:grid;-ms-grid-columns:1fr 1fr;grid-template-columns:1fr 1fr;-moz-column-gap:1px;column-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;border-bottom:1px solid #dadada}.sidebar .sidebar-panel.info-panel .sidebar-row{justify-content:space-evenly}.sidebar .sidebar-panel.info-panel .sidebar-row .mat-form-field{width:41px}.sidebar .sidebar-panel.info-panel .sidebar-row>{margin:0}.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}"]
988
- }),
989
- __metadata("design:paramtypes", [ElementRef,
990
- BlockEditorService,
991
- ChangeDetectorRef])
992
- ], SidebarComponent);
993
- return SidebarComponent;
994
- }());
995
-
996
- var FsBlockEditorComponent = /** @class */ (function () {
997
- function FsBlockEditorComponent(_el, _service, _cdRef, _differs) {
998
- this._el = _el;
999
- this._service = _service;
1000
- this._cdRef = _cdRef;
1001
- this._differs = _differs;
1002
- this.blockAdded = new EventEmitter();
1003
- this.blockRemoved = new EventEmitter();
1004
- this._destroy$ = new Subject();
1005
- this._differ = _differs.find([]).create(null);
1006
- }
1007
- Object.defineProperty(FsBlockEditorComponent.prototype, "el", {
1008
- get: function () {
1009
- return this._el.nativeElement;
1010
- },
1011
- enumerable: true,
1012
- configurable: true
1013
- });
1014
- FsBlockEditorComponent.prototype.ngOnInit = function () {
1015
- var _this = this;
1016
- this.config = __assign(__assign({}, this.config), { unit: 'in' });
1017
- this._service.registerContainer(this.artboard.nativeElement);
1018
- this._service.registerMargin(this.marginContainer.nativeElement);
1019
- this._service.blocks = this.config.blocks;
1020
- this._service.config = this.config;
1021
- this._service.blocks$
1022
- .pipe(takeUntil(this._destroy$))
1023
- .subscribe(function (blocks) {
1024
- _this.blocks = blocks;
1025
- });
1026
- fromEvent(window, 'keydown')
1027
- .pipe(takeUntil(this._destroy$), filter(function (event) {
1028
- return !!event.key.match(/^Arrow/) && !!_this._service.selectedBlockComponents.length;
1029
- }))
1030
- .subscribe(function (event) {
1031
- event.preventDefault();
1032
- var inchPixel = 1 / 100;
1033
- _this._service.selectedBlockComponents.forEach(function (blockComponent) {
1034
- switch (event.key) {
1035
- case 'ArrowUp':
1036
- blockComponent.top = blockComponent.block.top - inchPixel;
1037
- break;
1038
- case 'ArrowDown':
1039
- blockComponent.top = blockComponent.block.top + inchPixel;
1040
- break;
1041
- case 'ArrowLeft':
1042
- blockComponent.left = blockComponent.block.left - inchPixel;
1043
- break;
1044
- case 'ArrowRight':
1045
- blockComponent.left = blockComponent.block.left + inchPixel;
1046
- break;
1047
- }
1048
- });
1049
- });
1050
- };
1051
- FsBlockEditorComponent.prototype.artboardClick = function (event) {
1052
- if (event.target.isSameNode(this.artboard.nativeElement) ||
1053
- event.target.isSameNode(this.artboardContainer.nativeElement)) {
1054
- this._service.selectedBlockComponents.forEach(function (block) {
1055
- block.deselect();
1056
- block.markForCheck();
1057
- });
1058
- this._service.selectedBlockComponents = [];
1059
- }
1060
- };
1061
- FsBlockEditorComponent.prototype.blockChanged = function (block) {
1062
- this.sidebar.changeDetector.markForCheck();
1063
- if (this.config.blockChanged) {
1064
- this.config.blockChanged(block);
1065
- }
1066
- };
1067
- FsBlockEditorComponent.prototype.ngAfterViewInit = function () {
1068
- var _this = this;
1069
- this.blockComponents.changes.subscribe(function (changes) {
1070
- var changeDiff = _this._differ.diff(changes);
1071
- if (changeDiff) {
1072
- changeDiff.forEachAddedItem(function (change) {
1073
- _this.blockAdded.emit(change.item);
1074
- });
1075
- changeDiff.forEachRemovedItem(function (change) {
1076
- _this.blockRemoved.emit(change.item);
1077
- });
1078
- }
1079
- });
1080
- };
1081
- FsBlockEditorComponent.prototype.ngOnDestroy = function () {
1082
- this._destroy$.next();
1083
- this._destroy$.complete();
1084
- };
1085
- FsBlockEditorComponent.ctorParameters = function () { return [
1086
- { type: ElementRef },
1087
- { type: BlockEditorService },
1088
- { type: ChangeDetectorRef },
1089
- { type: IterableDiffers }
1090
- ]; };
1091
- __decorate([
1092
- ContentChildren(FsBlockEditorSidebarPanelDirective),
1093
- __metadata("design:type", QueryList)
1094
- ], FsBlockEditorComponent.prototype, "sidebarPanels", void 0);
1095
- __decorate([
1096
- ViewChildren(FsBlockComponent),
1097
- __metadata("design:type", QueryList)
1098
- ], FsBlockEditorComponent.prototype, "blockComponents", void 0);
1099
- __decorate([
1100
- ViewChild('artboard', { static: true }),
1101
- __metadata("design:type", ElementRef)
1102
- ], FsBlockEditorComponent.prototype, "artboard", void 0);
1103
- __decorate([
1104
- ViewChild('marginContainer', { static: true }),
1105
- __metadata("design:type", ElementRef)
1106
- ], FsBlockEditorComponent.prototype, "marginContainer", void 0);
1107
- __decorate([
1108
- ViewChildren(FsBlockEditorMarginDirective),
1109
- __metadata("design:type", QueryList)
1110
- ], FsBlockEditorComponent.prototype, "margins", void 0);
1111
- __decorate([
1112
- ViewChild('artboardContainer', { static: true }),
1113
- __metadata("design:type", ElementRef)
1114
- ], FsBlockEditorComponent.prototype, "artboardContainer", void 0);
1115
- __decorate([
1116
- ViewChild(SidebarComponent, { static: true }),
1117
- __metadata("design:type", SidebarComponent)
1118
- ], FsBlockEditorComponent.prototype, "sidebar", void 0);
1119
- __decorate([
1120
- Input(),
1121
- __metadata("design:type", Object)
1122
- ], FsBlockEditorComponent.prototype, "config", void 0);
1123
- __decorate([
1124
- Output(),
1125
- __metadata("design:type", Object)
1126
- ], FsBlockEditorComponent.prototype, "blockAdded", void 0);
1127
- __decorate([
1128
- Output(),
1129
- __metadata("design:type", Object)
1130
- ], FsBlockEditorComponent.prototype, "blockRemoved", void 0);
1131
- FsBlockEditorComponent = __decorate([
1132
- Component({
1133
- selector: 'fs-block-editor',
1134
- template: "<div class=\"editor-container\">\n <div\n #artboardContainer\n class=\"artboard-container\"\n (click)=\"artboardClick($event)\">\n <div\n #artboard\n class=\"artboard mat-elevation-z2\"\n [style.width]=\"config.width + config.unit\"\n [style.height]=\"config.height + config.unit\">\n <fs-block\n *ngFor=\"let block of blocks; trackBy\"\n [block]=\"block\"\n (changed)=\"blockChanged($event)\">\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'\"></div>\n </div>\n </div>\n <sidebar\n [config]=\"config\"\n [blocks]=\"blocks\"\n [blockAdded]=\"blockAdded\">\n </sidebar>\n</div>\n",
1135
- changeDetection: ChangeDetectionStrategy.OnPush,
1136
- providers: [
1137
- BlockEditorService,
1138
- ],
1139
- styles: [".editor-container{display:flex;flex-direction:row;position:relative}.editor-container .artboard-container{display:flex;flex-grow:1;justify-content:center;padding:25px;overflow:auto;min-width:0}.editor-container .artboard-container .artboard{position:relative}.editor-container .artboard-container .artboard .margin-container{position:absolute;z-index:-1}.editor-container .artboard-container .artboard .margin{position:absolute;border:0 dashed #ff85bd5e}.editor-container .artboard-container .artboard .margin.margin-bottom,.editor-container .artboard-container .artboard .margin.margin-top{width:100%;border-top-width:1px}.editor-container .artboard-container .artboard .margin.margin-left,.editor-container .artboard-container .artboard .margin.margin-right{height:100%;border-left-width:1px}"]
1140
- }),
1141
- __metadata("design:paramtypes", [ElementRef,
1142
- BlockEditorService,
1143
- ChangeDetectorRef,
1144
- IterableDiffers])
1145
- ], FsBlockEditorComponent);
1146
- return FsBlockEditorComponent;
1147
- }());
1148
-
1149
- var FsBlockEditorModule = /** @class */ (function () {
1150
- function FsBlockEditorModule() {
1151
- }
1152
- FsBlockEditorModule_1 = FsBlockEditorModule;
1153
- FsBlockEditorModule.forRoot = function () {
1154
- return {
1155
- ngModule: FsBlockEditorModule_1,
1156
- };
1157
- };
1158
- var FsBlockEditorModule_1;
1159
- FsBlockEditorModule = FsBlockEditorModule_1 = __decorate([
1160
- NgModule({
1161
- imports: [
1162
- CommonModule,
1163
- FormsModule,
1164
- MatIconModule,
1165
- MatButtonModule,
1166
- MatInputModule,
1167
- MatFormFieldModule,
1168
- FsHtmlEditorModule,
1169
- FsFileModule,
1170
- FsColorPickerModule,
1171
- ],
1172
- exports: [
1173
- FsBlockComponent,
1174
- FsBlockEditorComponent,
1175
- FsBlockEditorSidebarPanelDirective,
1176
- ],
1177
- declarations: [
1178
- FsBlockComponent,
1179
- FsBlockEditorComponent,
1180
- FsBlockEditorSidebarPanelDirective,
1181
- FsBlockEditorMarginDirective,
1182
- SidebarComponent,
1183
- ],
1184
- })
1185
- ], FsBlockEditorModule);
1186
- return FsBlockEditorModule;
1187
- }());
1188
-
1189
- /*
1190
- * Public API Surface of fs-menu
1191
- */
1192
-
1193
- /**
1194
- * Generated bundle index. Do not edit.
1195
- */
1196
-
1197
- export { FsBlockComponent, FsBlockEditorComponent, FsBlockEditorModule, FsBlockEditorSidebarPanelDirective, BlockEditorService as ɵa, FsBlockEditorMarginDirective as ɵb, SidebarComponent as ɵc };
1198
- //# sourceMappingURL=firestitch-block-editor.js.map