@firestitch/block-editor 9.0.9 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/app/components/block/block.component.d.ts +78 -72
  2. package/app/components/block-editor/block-editor.component.d.ts +37 -30
  3. package/app/components/sidebar/sidebar.component.d.ts +61 -58
  4. package/app/directives/block-editor-margin.directive.d.ts +9 -6
  5. package/app/directives/block-editor-sidebar-panel.directive.d.ts +10 -7
  6. package/app/fs-block-editor.module.d.ts +22 -4
  7. package/app/interfaces/block-editor-config.d.ts +18 -18
  8. package/app/interfaces/block.d.ts +37 -37
  9. package/app/services/block-editor.service.d.ts +36 -33
  10. package/bundles/firestitch-block-editor.umd.js +1491 -1321
  11. package/bundles/firestitch-block-editor.umd.js.map +1 -1
  12. package/esm2015/app/components/block/block.component.js +370 -374
  13. package/esm2015/app/components/block-editor/block-editor.component.js +141 -106
  14. package/esm2015/app/components/sidebar/sidebar.component.js +299 -308
  15. package/esm2015/app/directives/block-editor-margin.directive.js +19 -21
  16. package/esm2015/app/directives/block-editor-sidebar-panel.directive.js +21 -27
  17. package/esm2015/app/fs-block-editor.module.js +79 -53
  18. package/esm2015/app/interfaces/block-editor-config.js +2 -1
  19. package/esm2015/app/interfaces/block.js +2 -1
  20. package/esm2015/app/services/block-editor.service.js +99 -99
  21. package/esm2015/firestitch-block-editor.js +5 -8
  22. package/esm2015/public_api.js +8 -8
  23. package/fesm2015/firestitch-block-editor.js +976 -936
  24. package/fesm2015/firestitch-block-editor.js.map +1 -1
  25. package/firestitch-block-editor.d.ts +5 -7
  26. package/package.json +7 -10
  27. package/public_api.d.ts +6 -6
  28. package/bundles/firestitch-block-editor.umd.min.js +0 -2
  29. package/bundles/firestitch-block-editor.umd.min.js.map +0 -1
  30. package/esm5/app/components/block/block.component.js +0 -488
  31. package/esm5/app/components/block-editor/block-editor.component.js +0 -112
  32. package/esm5/app/components/sidebar/sidebar.component.js +0 -334
  33. package/esm5/app/directives/block-editor-margin.directive.js +0 -26
  34. package/esm5/app/directives/block-editor-sidebar-panel.directive.js +0 -28
  35. package/esm5/app/fs-block-editor.module.js +0 -57
  36. package/esm5/app/interfaces/block-editor-config.js +0 -1
  37. package/esm5/app/interfaces/block.js +0 -1
  38. package/esm5/app/services/block-editor.service.js +0 -124
  39. package/esm5/firestitch-block-editor.js +0 -8
  40. package/esm5/public_api.js +0 -8
  41. package/fesm5/firestitch-block-editor.js +0 -1142
  42. package/fesm5/firestitch-block-editor.js.map +0 -1
  43. package/firestitch-block-editor.metadata.json +0 -1
@@ -1,1142 +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, 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, skipWhile, 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
- set: function (value) {
191
- this.moveable.draggable = value;
192
- this.moveable.resizable = value;
193
- this.moveable.draggable = value;
194
- this.moveable.roundable = value;
195
- this.moveable.rotatable = value;
196
- },
197
- enumerable: true,
198
- configurable: true
199
- });
200
- Object.defineProperty(FsBlockComponent.prototype, "lineHeight", {
201
- set: function (value) {
202
- this.block.lineHeight = value;
203
- this._triggerChanged();
204
- },
205
- enumerable: true,
206
- configurable: true
207
- });
208
- Object.defineProperty(FsBlockComponent.prototype, "borderWidth", {
209
- set: function (value) {
210
- this.block.borderWidth = value;
211
- this._triggerChanged();
212
- },
213
- enumerable: true,
214
- configurable: true
215
- });
216
- Object.defineProperty(FsBlockComponent.prototype, "fontSize", {
217
- set: function (value) {
218
- this.block.fontSize = value;
219
- this._triggerChanged();
220
- },
221
- enumerable: true,
222
- configurable: true
223
- });
224
- Object.defineProperty(FsBlockComponent.prototype, "backgroundColor", {
225
- set: function (value) {
226
- this.block.backgroundColor = value;
227
- this._triggerChanged();
228
- },
229
- enumerable: true,
230
- configurable: true
231
- });
232
- Object.defineProperty(FsBlockComponent.prototype, "width", {
233
- set: function (value) {
234
- this.element.nativeElement.style.width = "" + value + this.unit;
235
- this.block.width = value;
236
- this._moveable.updateRect();
237
- this._triggerChanged();
238
- },
239
- enumerable: true,
240
- configurable: true
241
- });
242
- Object.defineProperty(FsBlockComponent.prototype, "height", {
243
- set: function (value) {
244
- this.element.nativeElement.style.height = "" + value + this.unit;
245
- this.block.height = value;
246
- this._moveable.updateRect();
247
- this._triggerChanged();
248
- },
249
- enumerable: true,
250
- configurable: true
251
- });
252
- Object.defineProperty(FsBlockComponent.prototype, "top", {
253
- set: function (value) {
254
- this.element.nativeElement.style.top = "" + value + this.unit;
255
- this.block.top = value;
256
- this._moveable.updateRect();
257
- this._triggerChanged();
258
- },
259
- enumerable: true,
260
- configurable: true
261
- });
262
- Object.defineProperty(FsBlockComponent.prototype, "left", {
263
- set: function (value) {
264
- this.element.nativeElement.style.left = "" + value + this.unit;
265
- this.block.left = value;
266
- this._moveable.updateRect();
267
- this._triggerChanged();
268
- },
269
- enumerable: true,
270
- configurable: true
271
- });
272
- Object.defineProperty(FsBlockComponent.prototype, "rotate", {
273
- set: function (value) {
274
- this._moveable.request('rotatable', { rotate: value }, true);
275
- this.block.rotate = value;
276
- this._triggerChanged();
277
- },
278
- enumerable: true,
279
- configurable: true
280
- });
281
- Object.defineProperty(FsBlockComponent.prototype, "shapeRadius", {
282
- set: function (value) {
283
- this.block.shapeRadius = value;
284
- this._triggerChanged();
285
- },
286
- enumerable: true,
287
- configurable: true
288
- });
289
- Object.defineProperty(FsBlockComponent.prototype, "index", {
290
- set: function (value) {
291
- this.block.index = value;
292
- },
293
- enumerable: true,
294
- configurable: true
295
- });
296
- Object.defineProperty(FsBlockComponent.prototype, "borderColor", {
297
- set: function (value) {
298
- this.block.borderColor = value;
299
- this._triggerChanged();
300
- },
301
- enumerable: true,
302
- configurable: true
303
- });
304
- Object.defineProperty(FsBlockComponent.prototype, "paddingAll", {
305
- set: function (value) {
306
- this.block.padding = value;
307
- this.block.paddingTop = null;
308
- this.block.paddingBottom = null;
309
- this.block.paddingLeft = null;
310
- this.block.paddingRight = null;
311
- this._triggerChanged();
312
- },
313
- enumerable: true,
314
- configurable: true
315
- });
316
- FsBlockComponent.prototype.padding = function (name, value) {
317
- this.block[name] = value;
318
- this.block.padding = null;
319
- this._triggerChanged();
320
- };
321
- Object.defineProperty(FsBlockComponent.prototype, "imageUrl", {
322
- set: function (value) {
323
- this.block.imageUrl = value;
324
- this._triggerChanged();
325
- },
326
- enumerable: true,
327
- configurable: true
328
- });
329
- Object.defineProperty(FsBlockComponent.prototype, "fontColor", {
330
- set: function (value) {
331
- this.block.fontColor = value;
332
- this._triggerChanged();
333
- },
334
- enumerable: true,
335
- configurable: true
336
- });
337
- Object.defineProperty(FsBlockComponent.prototype, "verticalAlign", {
338
- set: function (value) {
339
- this.block.verticalAlign = value;
340
- this._triggerChanged();
341
- },
342
- enumerable: true,
343
- configurable: true
344
- });
345
- FsBlockComponent.prototype.shapeRound = function (name, value) {
346
- this.block[name] = value;
347
- this._triggerChanged();
348
- };
349
- Object.defineProperty(FsBlockComponent.prototype, "horizontalAlign", {
350
- set: function (value) {
351
- this.block.horizontalAlign = value;
352
- this._triggerChanged();
353
- },
354
- enumerable: true,
355
- configurable: true
356
- });
357
- Object.defineProperty(FsBlockComponent.prototype, "italic", {
358
- get: function () {
359
- return this.block.italic;
360
- },
361
- set: function (value) {
362
- this.block.italic = value;
363
- this._triggerChanged();
364
- },
365
- enumerable: true,
366
- configurable: true
367
- });
368
- Object.defineProperty(FsBlockComponent.prototype, "bold", {
369
- get: function () {
370
- return this.block.bold;
371
- },
372
- set: function (value) {
373
- this.block.bold = value;
374
- this._triggerChanged();
375
- },
376
- enumerable: true,
377
- configurable: true
378
- });
379
- Object.defineProperty(FsBlockComponent.prototype, "underline", {
380
- get: function () {
381
- return this.block.underline;
382
- },
383
- set: function (value) {
384
- this.block.underline = value;
385
- this._triggerChanged();
386
- },
387
- enumerable: true,
388
- configurable: true
389
- });
390
- FsBlockComponent.prototype.markForCheck = function () {
391
- this._cdRef.markForCheck();
392
- };
393
- FsBlockComponent.prototype.ngOnInit = function () {
394
- this.block = this._service.sanitizeBlock(this.block);
395
- this.unit = this._service.config.unit;
396
- this.content = this.block.content;
397
- this.htmlConfig = {
398
- autofocus: false,
399
- froalaConfig: {}
400
- };
401
- };
402
- FsBlockComponent.prototype.saveSelectedElements = function () {
403
- this._selectedElements = this.htmlEditor.editor.selection.blocks();
404
- };
405
- FsBlockComponent.prototype.clearSelectedElements = function () {
406
- this._selectedElements = [];
407
- };
408
- FsBlockComponent.prototype.ngAfterContentInit = function () {
409
- var _this = this;
410
- this.el.style.width = this.block.width + this.unit;
411
- this.el.style.height = this.block.height + this.unit;
412
- this.el.style.top = this.block.top + this.unit;
413
- this.el.style.left = this.block.left + this.unit;
414
- this._setTransform();
415
- fromEvent(this.contentEditable.nativeElement, 'input')
416
- .pipe(takeUntil(this._destroy$)).subscribe(function (event) {
417
- _this.block.content = event.target.innerHTML;
418
- _this._triggerChanged();
419
- });
420
- fromEvent(this.el, 'mousedown')
421
- .pipe(takeUntil(this._destroy$)).subscribe(function (event) {
422
- if (_this.editable) {
423
- if (_this.contentElement.nativeElement.isSameNode(event.target)) {
424
- event.preventDefault();
425
- event.stopImmediatePropagation();
426
- event.stopPropagation();
427
- }
428
- }
429
- else {
430
- _this._service.selectedBlockComponents = [_this];
431
- }
432
- });
433
- fromEvent(this.el, 'dblclick')
434
- .pipe(skipWhile(function () {
435
- return _this.editable;
436
- }), takeUntil(this._destroy$))
437
- .subscribe(function (e) {
438
- _this.editable = true;
439
- setTimeout(function () {
440
- _this.selectAll();
441
- });
442
- });
443
- this._moveable = new Moveable(this._elementRef.nativeElement, {
444
- target: this.el,
445
- container: this._service.container,
446
- draggable: false,
447
- resizable: false,
448
- scalable: false,
449
- rotatable: false,
450
- warpable: false,
451
- origin: false,
452
- keepRatio: false,
453
- snappable: true,
454
- snapHorizontal: true,
455
- snapVertical: true,
456
- snapCenter: true,
457
- snapElement: true,
458
- edge: false,
459
- throttleDrag: 1,
460
- throttleScale: 0.01,
461
- throttleRotate: 1,
462
- throttleResize: 1,
463
- });
464
- this._service.registerBlock(this);
465
- this._moveable
466
- .on('clip', function (e) {
467
- _this.block.clipPath = e.clipStyle;
468
- e.target.style.clipPath = e.clipStyle;
469
- _this._triggerChanged();
470
- });
471
- this._moveable.on('dragStart', function (_a) {
472
- var target = _a.target, clientX = _a.clientX, clientY = _a.clientY;
473
- _this.editable = false;
474
- }).on('drag', function (_a) {
475
- var target = _a.target, left = _a.left, top = _a.top;
476
- target.style.left = _this.pxToIn(left) + _this.unit;
477
- target.style.top = _this.pxToIn(top) + _this.unit;
478
- _this.block.top = _this.pxToIn(top);
479
- _this.block.left = _this.pxToIn(left);
480
- _this._triggerChanged();
481
- });
482
- this._moveable.on('resizeStart', function (_a) {
483
- var target = _a.target, clientX = _a.clientX, clientY = _a.clientY;
484
- _this.editable = false;
485
- }).on('resize', function (_a) {
486
- var target = _a.target, width = _a.width, height = _a.height, dist = _a.dist, delta = _a.delta, direction = _a.direction;
487
- width = _this.pxToIn(width);
488
- height = _this.pxToIn(height);
489
- if (delta[0]) {
490
- _this.block.width = width;
491
- target.style.width = width + _this.unit;
492
- }
493
- if (delta[1]) {
494
- _this.block.height = height;
495
- target.style.height = height + _this.unit;
496
- }
497
- var transform = [0, 0];
498
- if (direction[1] === -1) {
499
- transform[1] = dist[1] * -1;
500
- }
501
- if (direction[0] === -1) {
502
- transform[0] = dist[0] * -1;
503
- }
504
- _this._setTransform(["translate(" + transform[0] + "px, " + transform[1] + "px)"]);
505
- _this._triggerChanged();
506
- }).on('resizeEnd', function (_a) {
507
- var target = _a.target;
508
- var matrix = new WebKitCSSMatrix(target.style.transform);
509
- _this.block.top = parseFloat(target.style.top) + _this.pxToIn(matrix.m42);
510
- _this.block.left = parseFloat(target.style.left) + _this.pxToIn(matrix.m41);
511
- target.style.top = _this.block.top + _this.unit;
512
- target.style.left = _this.block.left + _this.unit;
513
- _this._setTransform();
514
- _this._triggerChanged();
515
- });
516
- this._moveable.on('rotateStart', function (_a) {
517
- var target = _a.target, clientX = _a.clientX, clientY = _a.clientY;
518
- _this.editable = false;
519
- _this._rotateStart = _this.block.rotate || 0;
520
- }).on('rotate', function (_a) {
521
- var rotate = _a.rotate, transform = _a.transform;
522
- _this.block.rotate = _this._rotateStart + rotate;
523
- _this.el.style.transform = transform;
524
- _this._triggerChanged();
525
- });
526
- };
527
- FsBlockComponent.prototype.pxToIn = function (px) {
528
- return this.round(px / 96, 2);
529
- };
530
- FsBlockComponent.prototype.round = function (value, decimals) {
531
- return parseFloat(value.toFixed(decimals));
532
- };
533
- FsBlockComponent.prototype.deselect = function () {
534
- this.transformable = false;
535
- this.editable = false;
536
- };
537
- FsBlockComponent.prototype.deselectContent = function () {
538
- if (window.getSelection) {
539
- if (window.getSelection().empty) {
540
- window.getSelection().empty();
541
- }
542
- else if (window.getSelection().removeAllRanges) {
543
- window.getSelection().removeAllRanges();
544
- }
545
- }
546
- };
547
- FsBlockComponent.prototype.selectAll = function () {
548
- var range = document.createRange();
549
- //const el = this.htmlEditor.editor.$el.get(0);
550
- range.selectNodeContents(this.contentEditable.nativeElement);
551
- var sel = window.getSelection();
552
- sel.removeAllRanges();
553
- sel.addRange(range);
554
- };
555
- FsBlockComponent.prototype.ngOnDestroy = function () {
556
- this._destroy$.next();
557
- this._destroy$.complete();
558
- };
559
- FsBlockComponent.prototype._setTransform = function (transforms) {
560
- if (transforms === void 0) { transforms = []; }
561
- transforms = (transforms !== null && transforms !== void 0 ? transforms : []);
562
- if (this.block.rotate) {
563
- transforms.push("rotate(" + this.block.rotate + "deg)");
564
- }
565
- this.el.style.transform = transforms.join(' ');
566
- };
567
- FsBlockComponent.prototype._triggerChanged = function () {
568
- this.changed.emit(this.block);
569
- };
570
- FsBlockComponent.ctorParameters = function () { return [
571
- { type: BlockEditorService },
572
- { type: ElementRef },
573
- { type: ChangeDetectorRef }
574
- ]; };
575
- __decorate([
576
- ViewChild('element', { static: true }),
577
- __metadata("design:type", ElementRef)
578
- ], FsBlockComponent.prototype, "element", void 0);
579
- __decorate([
580
- ViewChild('contentElement', { static: true }),
581
- __metadata("design:type", ElementRef)
582
- ], FsBlockComponent.prototype, "contentElement", void 0);
583
- __decorate([
584
- ViewChild('contentEditable', { static: true }),
585
- __metadata("design:type", ElementRef)
586
- ], FsBlockComponent.prototype, "contentEditable", void 0);
587
- __decorate([
588
- ViewChild(FsHtmlEditorComponent),
589
- __metadata("design:type", FsHtmlEditorComponent)
590
- ], FsBlockComponent.prototype, "htmlEditor", void 0);
591
- __decorate([
592
- Input(),
593
- __metadata("design:type", Object)
594
- ], FsBlockComponent.prototype, "block", void 0);
595
- __decorate([
596
- Input(),
597
- __metadata("design:type", String)
598
- ], FsBlockComponent.prototype, "html", void 0);
599
- __decorate([
600
- Output(),
601
- __metadata("design:type", Object)
602
- ], FsBlockComponent.prototype, "changed", void 0);
603
- FsBlockComponent = __decorate([
604
- Component({
605
- selector: 'fs-block',
606
- template: "<div\n #element\n class=\"block\"\n [ngClass]=\"{ editable: editable }\">\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=\"true\"\n class=\"content-editable\"\n [innerHTML]=\"content\">\n </div>\n </div>\n</div>\n",
607
- changeDetection: ChangeDetectionStrategy.OnPush,
608
- styles: [".block{position:absolute;display:block;outline:0;cursor:pointer}.block .content-editable{outline:0;position:relative;z-index:1}.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}.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}"]
609
- }),
610
- __metadata("design:paramtypes", [BlockEditorService,
611
- ElementRef,
612
- ChangeDetectorRef])
613
- ], FsBlockComponent);
614
- return FsBlockComponent;
615
- }());
616
-
617
- var FsBlockEditorSidebarPanelDirective = /** @class */ (function () {
618
- function FsBlockEditorSidebarPanelDirective(templateRef) {
619
- this.templateRef = templateRef;
620
- this.show = true;
621
- }
622
- FsBlockEditorSidebarPanelDirective.ctorParameters = function () { return [
623
- { type: TemplateRef }
624
- ]; };
625
- __decorate([
626
- Input(),
627
- __metadata("design:type", String)
628
- ], FsBlockEditorSidebarPanelDirective.prototype, "label", void 0);
629
- __decorate([
630
- Input(),
631
- __metadata("design:type", Object)
632
- ], FsBlockEditorSidebarPanelDirective.prototype, "show", void 0);
633
- FsBlockEditorSidebarPanelDirective = __decorate([
634
- Directive({
635
- selector: '[fsBlockEditorSidebarPanel]'
636
- }),
637
- __metadata("design:paramtypes", [TemplateRef])
638
- ], FsBlockEditorSidebarPanelDirective);
639
- return FsBlockEditorSidebarPanelDirective;
640
- }());
641
-
642
- var FsBlockEditorMarginDirective = /** @class */ (function () {
643
- function FsBlockEditorMarginDirective(_elementRef) {
644
- this._elementRef = _elementRef;
645
- }
646
- Object.defineProperty(FsBlockEditorMarginDirective.prototype, "element", {
647
- get: function () {
648
- return this._elementRef.nativeElement;
649
- },
650
- enumerable: true,
651
- configurable: true
652
- });
653
- FsBlockEditorMarginDirective.ctorParameters = function () { return [
654
- { type: ElementRef }
655
- ]; };
656
- FsBlockEditorMarginDirective = __decorate([
657
- Directive({
658
- selector: '[fsBlockEditorMargin]'
659
- }),
660
- __metadata("design:paramtypes", [ElementRef])
661
- ], FsBlockEditorMarginDirective);
662
- return FsBlockEditorMarginDirective;
663
- }());
664
-
665
- var SidebarComponent = /** @class */ (function () {
666
- function SidebarComponent(_el, _service, _cdRef) {
667
- this._el = _el;
668
- this._service = _service;
669
- this._cdRef = _cdRef;
670
- this._destroy$ = new Subject();
671
- }
672
- Object.defineProperty(SidebarComponent.prototype, "changeDetector", {
673
- get: function () {
674
- return this._cdRef;
675
- },
676
- enumerable: true,
677
- configurable: true
678
- });
679
- Object.defineProperty(SidebarComponent.prototype, "el", {
680
- get: function () {
681
- return this._el.nativeElement;
682
- },
683
- enumerable: true,
684
- configurable: true
685
- });
686
- SidebarComponent.prototype.ngOnInit = function () {
687
- var _this = this;
688
- this._service.selectedBlockComponents$
689
- .pipe(takeUntil(this._destroy$))
690
- .subscribe(function (blocks) {
691
- _this.clippable = false;
692
- _this.block = blocks[0] ? blocks[0].block : null;
693
- _this.changeDetector.markForCheck();
694
- if (_this.config.blocksSelected) {
695
- _this.config.blocksSelected(blocks.map(function (block) { return block.block; }));
696
- }
697
- });
698
- };
699
- SidebarComponent.prototype.verticalAlignClick = function (value) {
700
- this._service.selectedBlockComponents.forEach(function (block) {
701
- block.verticalAlign = value;
702
- });
703
- };
704
- SidebarComponent.prototype.boldClick = function () {
705
- this._service.selectedBlockComponents.forEach(function (block) {
706
- block.bold = !block.bold;
707
- });
708
- };
709
- SidebarComponent.prototype.fontColorChange = function (value) {
710
- this._service.selectedBlockComponents.forEach(function (block) {
711
- block.fontColor = value;
712
- });
713
- };
714
- SidebarComponent.prototype.lineHeightChange = function (value) {
715
- var _this = this;
716
- this._service.selectedBlockComponents.forEach(function (block) {
717
- if (_this.validNumeric(value)) {
718
- block.lineHeight = value || null;
719
- }
720
- });
721
- };
722
- SidebarComponent.prototype.fontSizeChange = function (value) {
723
- var _this = this;
724
- this._service.selectedBlockComponents.forEach(function (block) {
725
- if (_this.validNumeric(value)) {
726
- block.fontSize = value || null;
727
- }
728
- });
729
- };
730
- SidebarComponent.prototype.borderWidthChange = function (value) {
731
- var _this = this;
732
- this._service.selectedBlockComponents.forEach(function (block) {
733
- if (_this.validNumeric(value)) {
734
- block.borderWidth = value || null;
735
- }
736
- });
737
- };
738
- SidebarComponent.prototype.italicClick = function () {
739
- this._service.selectedBlockComponents.forEach(function (block) {
740
- block.italic = !block.italic;
741
- });
742
- };
743
- SidebarComponent.prototype.underlineClick = function () {
744
- this._service.selectedBlockComponents.forEach(function (block) {
745
- block.underline = !block.underline;
746
- });
747
- };
748
- SidebarComponent.prototype.backgroundColorChange = function (value) {
749
- this._service.selectedBlockComponents.forEach(function (block) {
750
- block.backgroundColor = value;
751
- });
752
- };
753
- SidebarComponent.prototype.widthChange = function (value) {
754
- var _this = this;
755
- this._service.selectedBlockComponents.forEach(function (block) {
756
- if (_this.validNumeric(value)) {
757
- block.width = value;
758
- }
759
- });
760
- };
761
- SidebarComponent.prototype.heightChange = function (value) {
762
- var _this = this;
763
- this._service.selectedBlockComponents.forEach(function (block) {
764
- if (_this.validNumeric(value)) {
765
- block.height = value;
766
- }
767
- });
768
- };
769
- SidebarComponent.prototype.topChange = function (value) {
770
- var _this = this;
771
- this._service.selectedBlockComponents.forEach(function (block) {
772
- if (_this.validNumeric(value)) {
773
- block.top = value;
774
- }
775
- });
776
- };
777
- SidebarComponent.prototype.leftChange = function (value) {
778
- var _this = this;
779
- this._service.selectedBlockComponents.forEach(function (block) {
780
- if (_this.validNumeric(value)) {
781
- block.left = value;
782
- }
783
- });
784
- };
785
- SidebarComponent.prototype.rotateChange = function (value) {
786
- var _this = this;
787
- this._service.selectedBlockComponents.forEach(function (block) {
788
- if (_this.validNumeric(value)) {
789
- block.rotate = value;
790
- }
791
- });
792
- };
793
- SidebarComponent.prototype.paddingChange = function (name, value) {
794
- var _this = this;
795
- this._service.selectedBlockComponents.forEach(function (block) {
796
- if (_this.validNumeric(value)) {
797
- block.padding(name, value || null);
798
- }
799
- });
800
- };
801
- SidebarComponent.prototype.paddingAllChange = function (value) {
802
- var _this = this;
803
- this._service.selectedBlockComponents.forEach(function (block) {
804
- if (_this.validNumeric(value)) {
805
- block.paddingAll = value;
806
- }
807
- });
808
- };
809
- SidebarComponent.prototype.borderColorChange = function (value) {
810
- this._service.selectedBlockComponents.forEach(function (block) {
811
- block.borderColor = value;
812
- });
813
- };
814
- SidebarComponent.prototype.horizontalAlignClick = function (value) {
815
- this._service.selectedBlockComponents.forEach(function (block) {
816
- block.horizontalAlign = value;
817
- });
818
- };
819
- SidebarComponent.prototype.shapeRound = function (value) {
820
- this._service.selectedBlockComponents.forEach(function (block) {
821
- block.shapeRound(value, block.block[value] === 'round' ? 'square' : 'round');
822
- });
823
- };
824
- SidebarComponent.prototype.imageRemove = function () {
825
- this._service.selectedBlockComponents.forEach(function (block) {
826
- block.imageUrl = null;
827
- });
828
- };
829
- SidebarComponent.prototype.imageClip = function () {
830
- var _this = this;
831
- this.clippable = !this.clippable;
832
- this._service.selectedBlockComponents.forEach(function (block) {
833
- block.clippable = _this.clippable;
834
- });
835
- };
836
- SidebarComponent.prototype.shapeRadiusChange = function (value) {
837
- this._service.selectedBlockComponents.forEach(function (block) {
838
- block.shapeRadius = value;
839
- });
840
- };
841
- SidebarComponent.prototype.fileSelect = function (fsFile) {
842
- var _this = this;
843
- if (this.config.fileUpload) {
844
- this.config.fileUpload(fsFile.file)
845
- .subscribe(function (value) {
846
- _this._service.selectedBlockComponents.forEach(function (block) {
847
- block.imageUrl = value;
848
- });
849
- });
850
- }
851
- };
852
- SidebarComponent.prototype.blockRemoveClick = function () {
853
- var _this = this;
854
- if (this.config.blocksRemoved) {
855
- this.config.blocksRemoved(this._service.selectedBlocks)
856
- .pipe(takeUntil(this._destroy$))
857
- .subscribe(function () {
858
- _this._service.selectedBlocks.forEach(function (block) {
859
- _this._service.removeBlock(block);
860
- });
861
- _this._service.selectedBlockComponents = [];
862
- });
863
- }
864
- };
865
- SidebarComponent.prototype.blockAddClick = function () {
866
- var _this = this;
867
- var width = (this.config.width * .333).toFixed(2);
868
- var height = (this.config.height * .333).toFixed(2);
869
- var reference = guid();
870
- var block = {
871
- type: 'text',
872
- reference: reference,
873
- top: height,
874
- left: width,
875
- width: width,
876
- height: height,
877
- };
878
- if (this.config.blockAdded) {
879
- this.config.blockAdded(block)
880
- .pipe(takeUntil(this._destroy$))
881
- .subscribe(function (block) {
882
- _this.addBlock(block);
883
- _this.changeDetector.markForCheck();
884
- _this.blockComponents.changes
885
- .pipe(take(1), takeUntil(_this._destroy$))
886
- .subscribe(function (queryList) {
887
- var blockComponent = queryList.find(function (item) {
888
- return item.block.reference === reference;
889
- });
890
- if (blockComponent) {
891
- _this._service.selectedBlockComponents = [blockComponent];
892
- }
893
- });
894
- });
895
- }
896
- };
897
- SidebarComponent.prototype.addBlock = function (block) {
898
- this._service.addBlock(block);
899
- this._updateIndexes();
900
- };
901
- SidebarComponent.prototype._updateIndexes = function () {
902
- var _this = this;
903
- var sort = this.blocks.slice().sort(function (a, b) {
904
- return a.index > b.index ? 1 : -1;
905
- });
906
- sort.forEach(function (block, index) {
907
- _this.blocks.find(function (item) {
908
- return block.reference === item.reference;
909
- }).index = index;
910
- });
911
- };
912
- SidebarComponent.prototype.layerMove = function (direction) {
913
- var _this = this;
914
- this._service.blockComponents.forEach(function (blockComponent) {
915
- if (_this._service.isSelectedBlock(blockComponent)) {
916
- blockComponent.block.index + (999 * direction);
917
- }
918
- });
919
- var sorted = this._service.blockComponents.sort(function (a, b) {
920
- return a.index > b.index ? 1 : -1;
921
- });
922
- sorted.forEach(function (item, index) {
923
- item.block.index = index;
924
- item.markForCheck();
925
- });
926
- if (this.config.blocksLevelChanged) {
927
- this.config.blocksLevelChanged(sorted.map(function (item) { return item.block; }));
928
- }
929
- };
930
- SidebarComponent.prototype.layerUp = function () {
931
- this.layerMove(1);
932
- };
933
- SidebarComponent.prototype.layerDown = function () {
934
- this.layerMove(-1);
935
- };
936
- SidebarComponent.prototype.getBlock = function (reference) {
937
- return this._service.blocks.find(function (block) {
938
- return block.reference === reference;
939
- });
940
- };
941
- SidebarComponent.prototype.blockChanged = function (block) {
942
- if (this.config.blockChanged) {
943
- this.config.blockChanged(block);
944
- }
945
- };
946
- SidebarComponent.prototype.inputFocus = function (event) {
947
- event.target.select();
948
- };
949
- SidebarComponent.prototype.ngOnDestroy = function () {
950
- this._destroy$.next();
951
- this._destroy$.complete();
952
- };
953
- SidebarComponent.prototype.validNumeric = function (value) {
954
- return !value || !!String(value).match(/^\d*\.?\d*$/);
955
- };
956
- SidebarComponent.ctorParameters = function () { return [
957
- { type: ElementRef },
958
- { type: BlockEditorService },
959
- { type: ChangeDetectorRef }
960
- ]; };
961
- __decorate([
962
- ContentChildren(FsBlockEditorSidebarPanelDirective),
963
- __metadata("design:type", QueryList)
964
- ], SidebarComponent.prototype, "sidebarPanels", void 0);
965
- __decorate([
966
- Input(),
967
- __metadata("design:type", Object)
968
- ], SidebarComponent.prototype, "config", void 0);
969
- __decorate([
970
- Input(),
971
- __metadata("design:type", Object)
972
- ], SidebarComponent.prototype, "blocks", void 0);
973
- __decorate([
974
- Input(),
975
- __metadata("design:type", QueryList)
976
- ], SidebarComponent.prototype, "blockComponents", void 0);
977
- SidebarComponent = __decorate([
978
- Component({
979
- selector: 'sidebar',
980
- 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",
981
- changeDetection: ChangeDetectionStrategy.OnPush,
982
- 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}"]
983
- }),
984
- __metadata("design:paramtypes", [ElementRef,
985
- BlockEditorService,
986
- ChangeDetectorRef])
987
- ], SidebarComponent);
988
- return SidebarComponent;
989
- }());
990
-
991
- var FsBlockEditorComponent = /** @class */ (function () {
992
- function FsBlockEditorComponent(_el, _service, _cdRef) {
993
- this._el = _el;
994
- this._service = _service;
995
- this._cdRef = _cdRef;
996
- this._destroy$ = new Subject();
997
- }
998
- Object.defineProperty(FsBlockEditorComponent.prototype, "el", {
999
- get: function () {
1000
- return this._el.nativeElement;
1001
- },
1002
- enumerable: true,
1003
- configurable: true
1004
- });
1005
- FsBlockEditorComponent.prototype.ngOnInit = function () {
1006
- var _this = this;
1007
- this.config = __assign(__assign({}, this.config), { unit: 'in' });
1008
- this._service.registerContainer(this.artboard.nativeElement);
1009
- this._service.registerMargin(this.marginContainer.nativeElement);
1010
- this._service.blocks = this.config.blocks;
1011
- this._service.config = this.config;
1012
- this._service.blocks$
1013
- .pipe(takeUntil(this._destroy$))
1014
- .subscribe(function (blocks) {
1015
- _this.blocks = blocks;
1016
- });
1017
- };
1018
- FsBlockEditorComponent.prototype.artboardClick = function (event) {
1019
- if (event.target.isSameNode(this.artboard.nativeElement) ||
1020
- event.target.isSameNode(this.artboardContainer.nativeElement)) {
1021
- this._service.selectedBlockComponents.forEach(function (block) {
1022
- block.deselect();
1023
- });
1024
- this._service.selectedBlockComponents = [];
1025
- }
1026
- };
1027
- FsBlockEditorComponent.prototype.blockChanged = function (block) {
1028
- this.sidebar.changeDetector.markForCheck();
1029
- if (this.config.blockChanged) {
1030
- this.config.blockChanged(block);
1031
- }
1032
- };
1033
- FsBlockEditorComponent.prototype.ngAfterViewInit = function () {
1034
- };
1035
- FsBlockEditorComponent.prototype.ngOnDestroy = function () {
1036
- this._destroy$.next();
1037
- this._destroy$.complete();
1038
- };
1039
- FsBlockEditorComponent.ctorParameters = function () { return [
1040
- { type: ElementRef },
1041
- { type: BlockEditorService },
1042
- { type: ChangeDetectorRef }
1043
- ]; };
1044
- __decorate([
1045
- ContentChildren(FsBlockEditorSidebarPanelDirective),
1046
- __metadata("design:type", QueryList)
1047
- ], FsBlockEditorComponent.prototype, "sidebarPanels", void 0);
1048
- __decorate([
1049
- ViewChildren(FsBlockComponent),
1050
- __metadata("design:type", QueryList)
1051
- ], FsBlockEditorComponent.prototype, "blockComponents", void 0);
1052
- __decorate([
1053
- ViewChild('artboard', { static: true }),
1054
- __metadata("design:type", ElementRef)
1055
- ], FsBlockEditorComponent.prototype, "artboard", void 0);
1056
- __decorate([
1057
- ViewChild('marginContainer', { static: true }),
1058
- __metadata("design:type", ElementRef)
1059
- ], FsBlockEditorComponent.prototype, "marginContainer", void 0);
1060
- __decorate([
1061
- ViewChildren(FsBlockEditorMarginDirective),
1062
- __metadata("design:type", QueryList)
1063
- ], FsBlockEditorComponent.prototype, "margins", void 0);
1064
- __decorate([
1065
- ViewChild('artboardContainer', { static: true }),
1066
- __metadata("design:type", ElementRef)
1067
- ], FsBlockEditorComponent.prototype, "artboardContainer", void 0);
1068
- __decorate([
1069
- ViewChild(SidebarComponent, { static: true }),
1070
- __metadata("design:type", SidebarComponent)
1071
- ], FsBlockEditorComponent.prototype, "sidebar", void 0);
1072
- __decorate([
1073
- Input(),
1074
- __metadata("design:type", Object)
1075
- ], FsBlockEditorComponent.prototype, "config", void 0);
1076
- FsBlockEditorComponent = __decorate([
1077
- Component({
1078
- selector: 'fs-block-editor',
1079
- 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 [blockComponents]=\"blockComponents\">\n </sidebar>\n</div>\n",
1080
- changeDetection: ChangeDetectionStrategy.OnPush,
1081
- providers: [
1082
- BlockEditorService,
1083
- ],
1084
- 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}"]
1085
- }),
1086
- __metadata("design:paramtypes", [ElementRef,
1087
- BlockEditorService,
1088
- ChangeDetectorRef])
1089
- ], FsBlockEditorComponent);
1090
- return FsBlockEditorComponent;
1091
- }());
1092
-
1093
- var FsBlockEditorModule = /** @class */ (function () {
1094
- function FsBlockEditorModule() {
1095
- }
1096
- FsBlockEditorModule_1 = FsBlockEditorModule;
1097
- FsBlockEditorModule.forRoot = function () {
1098
- return {
1099
- ngModule: FsBlockEditorModule_1,
1100
- };
1101
- };
1102
- var FsBlockEditorModule_1;
1103
- FsBlockEditorModule = FsBlockEditorModule_1 = __decorate([
1104
- NgModule({
1105
- imports: [
1106
- CommonModule,
1107
- FormsModule,
1108
- MatIconModule,
1109
- MatButtonModule,
1110
- MatInputModule,
1111
- MatFormFieldModule,
1112
- FsHtmlEditorModule,
1113
- FsFileModule,
1114
- FsColorPickerModule,
1115
- ],
1116
- exports: [
1117
- FsBlockComponent,
1118
- FsBlockEditorComponent,
1119
- FsBlockEditorSidebarPanelDirective,
1120
- ],
1121
- declarations: [
1122
- FsBlockComponent,
1123
- FsBlockEditorComponent,
1124
- FsBlockEditorSidebarPanelDirective,
1125
- FsBlockEditorMarginDirective,
1126
- SidebarComponent,
1127
- ],
1128
- })
1129
- ], FsBlockEditorModule);
1130
- return FsBlockEditorModule;
1131
- }());
1132
-
1133
- /*
1134
- * Public API Surface of fs-menu
1135
- */
1136
-
1137
- /**
1138
- * Generated bundle index. Do not edit.
1139
- */
1140
-
1141
- export { FsBlockComponent, FsBlockEditorComponent, FsBlockEditorModule, FsBlockEditorSidebarPanelDirective, BlockEditorService as ɵa, FsBlockEditorMarginDirective as ɵb, SidebarComponent as ɵc };
1142
- //# sourceMappingURL=firestitch-block-editor.js.map