@firestitch/block-editor 12.0.0 → 12.0.1
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.
- package/app/components/block/block.component.d.ts +72 -78
- package/app/components/block-editor/block-editor.component.d.ts +37 -37
- package/app/components/sidebar/sidebar.component.d.ts +61 -61
- package/app/directives/block-editor-margin.directive.d.ts +9 -9
- package/app/directives/block-editor-sidebar-panel.directive.d.ts +10 -10
- package/app/fs-block-editor.module.d.ts +21 -22
- package/app/interfaces/block-editor-config.d.ts +18 -18
- package/app/interfaces/block.d.ts +37 -37
- package/app/services/block-editor.service.d.ts +36 -36
- package/bundles/firestitch-block-editor.umd.js +1440 -1458
- package/bundles/firestitch-block-editor.umd.js.map +1 -1
- package/esm2015/app/components/block/block.component.js +354 -370
- package/esm2015/app/components/block-editor/block-editor.component.js +140 -140
- package/esm2015/app/components/sidebar/sidebar.component.js +298 -298
- package/esm2015/app/directives/block-editor-margin.directive.js +18 -18
- package/esm2015/app/directives/block-editor-sidebar-panel.directive.js +20 -20
- package/esm2015/app/fs-block-editor.module.js +75 -79
- package/esm2015/app/interfaces/block-editor-config.js +1 -1
- package/esm2015/app/interfaces/block.js +1 -1
- package/esm2015/app/services/block-editor.service.js +98 -98
- package/esm2015/firestitch-block-editor.js +4 -4
- package/esm2015/public_api.js +7 -7
- package/fesm2015/firestitch-block-editor.js +939 -958
- package/fesm2015/firestitch-block-editor.js.map +1 -1
- package/firestitch-block-editor.d.ts +5 -5
- package/package.json +1 -5
- package/public_api.d.ts +6 -6
|
@@ -12,7 +12,6 @@ import * as i4 from '@angular/material/form-field';
|
|
|
12
12
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
13
13
|
import * as i3 from '@angular/material/icon';
|
|
14
14
|
import { MatIconModule } from '@angular/material/icon';
|
|
15
|
-
import { FsHtmlEditorComponent, FsHtmlEditorModule } from '@firestitch/html-editor';
|
|
16
15
|
import * as i5 from '@firestitch/colorpicker';
|
|
17
16
|
import { FsColorPickerModule } from '@firestitch/colorpicker';
|
|
18
17
|
import * as i6 from '@firestitch/file';
|
|
@@ -22,979 +21,961 @@ import Moveable from 'moveable';
|
|
|
22
21
|
import { BehaviorSubject, Subject, fromEvent } from 'rxjs';
|
|
23
22
|
import { guid } from '@firestitch/common';
|
|
24
23
|
|
|
25
|
-
class BlockEditorService {
|
|
26
|
-
constructor() {
|
|
27
|
-
this.blockComponents = [];
|
|
28
|
-
this._blocks$ = new BehaviorSubject([]);
|
|
29
|
-
this._selectedBlockComponents$ = new BehaviorSubject([]);
|
|
30
|
-
}
|
|
31
|
-
get elementGuidelines() {
|
|
32
|
-
return [
|
|
33
|
-
...this.blockComponents.map((block) => {
|
|
34
|
-
return block.el;
|
|
35
|
-
}),
|
|
36
|
-
this.container,
|
|
37
|
-
this.margin,
|
|
38
|
-
];
|
|
39
|
-
}
|
|
40
|
-
addBlock(block) {
|
|
41
|
-
this.blocks$.next([...this.blocks, this.sanitizeBlock(block)]);
|
|
42
|
-
}
|
|
43
|
-
removeBlock(block) {
|
|
44
|
-
const index = this.indexOf(block);
|
|
45
|
-
if (index !== -1) {
|
|
46
|
-
this.blocks.splice(index, 1);
|
|
47
|
-
this.blocks$.next(this.blocks);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
get blocks$() {
|
|
51
|
-
return this._blocks$;
|
|
52
|
-
}
|
|
53
|
-
get blocks() {
|
|
54
|
-
return this.blocks$.getValue();
|
|
55
|
-
}
|
|
56
|
-
set blocks(blocks) {
|
|
57
|
-
this._blocks$.next(blocks);
|
|
58
|
-
}
|
|
59
|
-
isSelectedBlock(block) {
|
|
60
|
-
return this.selectedBlockComponents.indexOf(block) !== -1;
|
|
61
|
-
}
|
|
62
|
-
indexOf(block) {
|
|
63
|
-
return this.blocks.map((e) => e.reference).indexOf(block.reference);
|
|
64
|
-
}
|
|
65
|
-
set selectedBlockComponents(blocks) {
|
|
66
|
-
this.blockComponents.forEach((block) => {
|
|
67
|
-
block.editable = false;
|
|
68
|
-
block.transformable = blocks.indexOf(block) !== -1;
|
|
69
|
-
});
|
|
70
|
-
this._selectedBlockComponents$.next(blocks);
|
|
71
|
-
}
|
|
72
|
-
get selectedBlockComponents() {
|
|
73
|
-
return this._selectedBlockComponents$.getValue();
|
|
74
|
-
}
|
|
75
|
-
get selectedBlocks() {
|
|
76
|
-
return this.selectedBlockComponents.map((blockComponent) => blockComponent.block);
|
|
77
|
-
}
|
|
78
|
-
get selectedBlockComponents$() {
|
|
79
|
-
return this._selectedBlockComponents$;
|
|
80
|
-
}
|
|
81
|
-
saveSelection() {
|
|
82
|
-
const selection = window.getSelection();
|
|
83
|
-
this._selectionRange = selection.getRangeAt(0);
|
|
84
|
-
}
|
|
85
|
-
restoreSelection() {
|
|
86
|
-
if (this._selectionRange) {
|
|
87
|
-
const selection = window.getSelection();
|
|
88
|
-
selection.removeAllRanges();
|
|
89
|
-
selection.addRange(this._selectionRange);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
hasSelectionRange() {
|
|
93
|
-
return this._selectionRange && (this._selectionRange.baseOffset - this._selectionRange.focusOffset) > 0;
|
|
94
|
-
}
|
|
95
|
-
registerBlock(block) {
|
|
96
|
-
this.blockComponents.push(block);
|
|
97
|
-
this.blockComponents.forEach((item) => {
|
|
98
|
-
const blocks = this.elementGuidelines
|
|
99
|
-
.filter((el) => {
|
|
100
|
-
return !el.isSameNode(item.el);
|
|
101
|
-
});
|
|
102
|
-
item.elementGuidelines = blocks;
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
registerContainer(container) {
|
|
106
|
-
this.container = container;
|
|
107
|
-
}
|
|
108
|
-
registerMargin(margin) {
|
|
109
|
-
this.margin = margin;
|
|
110
|
-
}
|
|
111
|
-
sanitizeBlock(block) {
|
|
112
|
-
return Object.assign({ shapeBottomLeft: 'round', shapeTopLeft: 'round', shapeTopRight: 'round', shapeBottomRight: 'round', verticalAlign: 'top', horizontalAlign: 'left' }, block);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
BlockEditorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
116
|
-
BlockEditorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService });
|
|
117
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService, decorators: [{
|
|
118
|
-
type: Injectable
|
|
24
|
+
class BlockEditorService {
|
|
25
|
+
constructor() {
|
|
26
|
+
this.blockComponents = [];
|
|
27
|
+
this._blocks$ = new BehaviorSubject([]);
|
|
28
|
+
this._selectedBlockComponents$ = new BehaviorSubject([]);
|
|
29
|
+
}
|
|
30
|
+
get elementGuidelines() {
|
|
31
|
+
return [
|
|
32
|
+
...this.blockComponents.map((block) => {
|
|
33
|
+
return block.el;
|
|
34
|
+
}),
|
|
35
|
+
this.container,
|
|
36
|
+
this.margin,
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
addBlock(block) {
|
|
40
|
+
this.blocks$.next([...this.blocks, this.sanitizeBlock(block)]);
|
|
41
|
+
}
|
|
42
|
+
removeBlock(block) {
|
|
43
|
+
const index = this.indexOf(block);
|
|
44
|
+
if (index !== -1) {
|
|
45
|
+
this.blocks.splice(index, 1);
|
|
46
|
+
this.blocks$.next(this.blocks);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
get blocks$() {
|
|
50
|
+
return this._blocks$;
|
|
51
|
+
}
|
|
52
|
+
get blocks() {
|
|
53
|
+
return this.blocks$.getValue();
|
|
54
|
+
}
|
|
55
|
+
set blocks(blocks) {
|
|
56
|
+
this._blocks$.next(blocks);
|
|
57
|
+
}
|
|
58
|
+
isSelectedBlock(block) {
|
|
59
|
+
return this.selectedBlockComponents.indexOf(block) !== -1;
|
|
60
|
+
}
|
|
61
|
+
indexOf(block) {
|
|
62
|
+
return this.blocks.map((e) => e.reference).indexOf(block.reference);
|
|
63
|
+
}
|
|
64
|
+
set selectedBlockComponents(blocks) {
|
|
65
|
+
this.blockComponents.forEach((block) => {
|
|
66
|
+
block.editable = false;
|
|
67
|
+
block.transformable = blocks.indexOf(block) !== -1;
|
|
68
|
+
});
|
|
69
|
+
this._selectedBlockComponents$.next(blocks);
|
|
70
|
+
}
|
|
71
|
+
get selectedBlockComponents() {
|
|
72
|
+
return this._selectedBlockComponents$.getValue();
|
|
73
|
+
}
|
|
74
|
+
get selectedBlocks() {
|
|
75
|
+
return this.selectedBlockComponents.map((blockComponent) => blockComponent.block);
|
|
76
|
+
}
|
|
77
|
+
get selectedBlockComponents$() {
|
|
78
|
+
return this._selectedBlockComponents$;
|
|
79
|
+
}
|
|
80
|
+
saveSelection() {
|
|
81
|
+
const selection = window.getSelection();
|
|
82
|
+
this._selectionRange = selection.getRangeAt(0);
|
|
83
|
+
}
|
|
84
|
+
restoreSelection() {
|
|
85
|
+
if (this._selectionRange) {
|
|
86
|
+
const selection = window.getSelection();
|
|
87
|
+
selection.removeAllRanges();
|
|
88
|
+
selection.addRange(this._selectionRange);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
hasSelectionRange() {
|
|
92
|
+
return this._selectionRange && (this._selectionRange.baseOffset - this._selectionRange.focusOffset) > 0;
|
|
93
|
+
}
|
|
94
|
+
registerBlock(block) {
|
|
95
|
+
this.blockComponents.push(block);
|
|
96
|
+
this.blockComponents.forEach((item) => {
|
|
97
|
+
const blocks = this.elementGuidelines
|
|
98
|
+
.filter((el) => {
|
|
99
|
+
return !el.isSameNode(item.el);
|
|
100
|
+
});
|
|
101
|
+
item.elementGuidelines = blocks;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
registerContainer(container) {
|
|
105
|
+
this.container = container;
|
|
106
|
+
}
|
|
107
|
+
registerMargin(margin) {
|
|
108
|
+
this.margin = margin;
|
|
109
|
+
}
|
|
110
|
+
sanitizeBlock(block) {
|
|
111
|
+
return Object.assign({ shapeBottomLeft: 'round', shapeTopLeft: 'round', shapeTopRight: 'round', shapeBottomRight: 'round', verticalAlign: 'top', horizontalAlign: 'left' }, block);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
BlockEditorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
115
|
+
BlockEditorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService });
|
|
116
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BlockEditorService, decorators: [{
|
|
117
|
+
type: Injectable
|
|
119
118
|
}], ctorParameters: function () { return []; } });
|
|
120
119
|
|
|
121
|
-
class FsBlockComponent {
|
|
122
|
-
constructor(_service, _elementRef, _cdRef) {
|
|
123
|
-
this._service = _service;
|
|
124
|
-
this._elementRef = _elementRef;
|
|
125
|
-
this._cdRef = _cdRef;
|
|
126
|
-
this.changed = new EventEmitter();
|
|
127
|
-
this.
|
|
128
|
-
this.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
this.
|
|
158
|
-
this.moveable.draggable = value;
|
|
159
|
-
this.moveable.
|
|
160
|
-
this.moveable.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
this.
|
|
182
|
-
this.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
this.
|
|
188
|
-
this.
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
this.
|
|
194
|
-
this.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
this.
|
|
200
|
-
this.
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
this.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
this.block.
|
|
222
|
-
this.block.
|
|
223
|
-
this.block.
|
|
224
|
-
this.
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
this.
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
this.
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
this.
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
.
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
this.
|
|
360
|
-
})
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
if (
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
this.
|
|
391
|
-
this.
|
|
392
|
-
}).on('
|
|
393
|
-
|
|
394
|
-
this.
|
|
395
|
-
this.
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}], contentElement: [{
|
|
466
|
-
type: ViewChild,
|
|
467
|
-
args: ['contentElement', { static: true }]
|
|
468
|
-
}], contentEditable: [{
|
|
469
|
-
type: ViewChild,
|
|
470
|
-
args: ['contentEditable', { static: true }]
|
|
471
|
-
}], htmlEditor: [{
|
|
472
|
-
type: ViewChild,
|
|
473
|
-
args: [FsHtmlEditorComponent]
|
|
474
|
-
}], block: [{
|
|
475
|
-
type: Input
|
|
476
|
-
}], html: [{
|
|
477
|
-
type: Input
|
|
478
|
-
}], changed: [{
|
|
479
|
-
type: Output
|
|
120
|
+
class FsBlockComponent {
|
|
121
|
+
constructor(_service, _elementRef, _cdRef) {
|
|
122
|
+
this._service = _service;
|
|
123
|
+
this._elementRef = _elementRef;
|
|
124
|
+
this._cdRef = _cdRef;
|
|
125
|
+
this.changed = new EventEmitter();
|
|
126
|
+
this._editable = false;
|
|
127
|
+
this._destroy$ = new Subject();
|
|
128
|
+
}
|
|
129
|
+
get el() {
|
|
130
|
+
return this.element.nativeElement;
|
|
131
|
+
}
|
|
132
|
+
get moveable() {
|
|
133
|
+
return this._moveable;
|
|
134
|
+
}
|
|
135
|
+
get editable() {
|
|
136
|
+
return this._editable;
|
|
137
|
+
}
|
|
138
|
+
set elementGuidelines(value) {
|
|
139
|
+
this._moveable.elementGuidelines = value;
|
|
140
|
+
}
|
|
141
|
+
set editable(value) {
|
|
142
|
+
this._editable = value;
|
|
143
|
+
if (!value) {
|
|
144
|
+
this.deselectContent();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
set clippable(value) {
|
|
148
|
+
this._moveable.clippable = value;
|
|
149
|
+
}
|
|
150
|
+
get transformable() {
|
|
151
|
+
return this._transformable;
|
|
152
|
+
}
|
|
153
|
+
set transformable(value) {
|
|
154
|
+
this._transformable = value;
|
|
155
|
+
this.moveable.draggable = value;
|
|
156
|
+
this.moveable.resizable = value;
|
|
157
|
+
this.moveable.draggable = value;
|
|
158
|
+
this.moveable.roundable = value;
|
|
159
|
+
this.moveable.rotatable = value;
|
|
160
|
+
}
|
|
161
|
+
set lineHeight(value) {
|
|
162
|
+
this.block.lineHeight = value;
|
|
163
|
+
this._triggerChanged();
|
|
164
|
+
}
|
|
165
|
+
set borderWidth(value) {
|
|
166
|
+
this.block.borderWidth = value;
|
|
167
|
+
this._triggerChanged();
|
|
168
|
+
}
|
|
169
|
+
set fontSize(value) {
|
|
170
|
+
this.block.fontSize = value;
|
|
171
|
+
this._triggerChanged();
|
|
172
|
+
}
|
|
173
|
+
set backgroundColor(value) {
|
|
174
|
+
this.block.backgroundColor = value;
|
|
175
|
+
this._triggerChanged();
|
|
176
|
+
}
|
|
177
|
+
set width(value) {
|
|
178
|
+
this.block.width = parseFloat(value);
|
|
179
|
+
this.element.nativeElement.style.width = `${this.block.width}${this.unit}`;
|
|
180
|
+
this._moveable.updateRect();
|
|
181
|
+
this._triggerChanged();
|
|
182
|
+
}
|
|
183
|
+
set height(value) {
|
|
184
|
+
this.block.height = parseFloat(value);
|
|
185
|
+
this.element.nativeElement.style.height = `${this.block.height}${this.unit}`;
|
|
186
|
+
this._moveable.updateRect();
|
|
187
|
+
this._triggerChanged();
|
|
188
|
+
}
|
|
189
|
+
set top(value) {
|
|
190
|
+
this.block.top = parseFloat(value);
|
|
191
|
+
this.element.nativeElement.style.top = `${this.block.top}${this.unit}`;
|
|
192
|
+
this._moveable.updateRect();
|
|
193
|
+
this._triggerChanged();
|
|
194
|
+
}
|
|
195
|
+
set left(value) {
|
|
196
|
+
this.block.left = parseFloat(value);
|
|
197
|
+
this.element.nativeElement.style.left = `${this.block.left}${this.unit}`;
|
|
198
|
+
this._moveable.updateRect();
|
|
199
|
+
this._triggerChanged();
|
|
200
|
+
}
|
|
201
|
+
set rotate(value) {
|
|
202
|
+
this.block.rotate = parseFloat(value);
|
|
203
|
+
this._moveable.request('rotatable', { rotate: this.block.rotate }, true);
|
|
204
|
+
this._triggerChanged();
|
|
205
|
+
}
|
|
206
|
+
set shapeRadius(value) {
|
|
207
|
+
this.block.shapeRadius = value;
|
|
208
|
+
this._triggerChanged();
|
|
209
|
+
}
|
|
210
|
+
set index(value) {
|
|
211
|
+
this.block.index = value;
|
|
212
|
+
}
|
|
213
|
+
set borderColor(value) {
|
|
214
|
+
this.block.borderColor = value;
|
|
215
|
+
this._triggerChanged();
|
|
216
|
+
}
|
|
217
|
+
set paddingAll(value) {
|
|
218
|
+
this.block.padding = value;
|
|
219
|
+
this.block.paddingTop = null;
|
|
220
|
+
this.block.paddingBottom = null;
|
|
221
|
+
this.block.paddingLeft = null;
|
|
222
|
+
this.block.paddingRight = null;
|
|
223
|
+
this._triggerChanged();
|
|
224
|
+
}
|
|
225
|
+
padding(name, value) {
|
|
226
|
+
this.block[name] = value;
|
|
227
|
+
this.block.padding = null;
|
|
228
|
+
this._triggerChanged();
|
|
229
|
+
}
|
|
230
|
+
set imageUrl(value) {
|
|
231
|
+
this.block.imageUrl = value;
|
|
232
|
+
this._triggerChanged();
|
|
233
|
+
}
|
|
234
|
+
set fontColor(value) {
|
|
235
|
+
this.block.fontColor = value;
|
|
236
|
+
this._triggerChanged();
|
|
237
|
+
}
|
|
238
|
+
set verticalAlign(value) {
|
|
239
|
+
this.block.verticalAlign = value;
|
|
240
|
+
this._triggerChanged();
|
|
241
|
+
}
|
|
242
|
+
shapeRound(name, value) {
|
|
243
|
+
this.block[name] = value;
|
|
244
|
+
this._triggerChanged();
|
|
245
|
+
}
|
|
246
|
+
set horizontalAlign(value) {
|
|
247
|
+
this.block.horizontalAlign = value;
|
|
248
|
+
this._triggerChanged();
|
|
249
|
+
}
|
|
250
|
+
set italic(value) {
|
|
251
|
+
this.block.italic = value;
|
|
252
|
+
this._triggerChanged();
|
|
253
|
+
}
|
|
254
|
+
get italic() {
|
|
255
|
+
return this.block.italic;
|
|
256
|
+
}
|
|
257
|
+
set bold(value) {
|
|
258
|
+
this.block.bold = value;
|
|
259
|
+
this._triggerChanged();
|
|
260
|
+
}
|
|
261
|
+
get bold() {
|
|
262
|
+
return this.block.bold;
|
|
263
|
+
}
|
|
264
|
+
set underline(value) {
|
|
265
|
+
this.block.underline = value;
|
|
266
|
+
this._triggerChanged();
|
|
267
|
+
}
|
|
268
|
+
get underline() {
|
|
269
|
+
return this.block.underline;
|
|
270
|
+
}
|
|
271
|
+
updateRect() {
|
|
272
|
+
this.moveable.updateRect();
|
|
273
|
+
}
|
|
274
|
+
markForCheck() {
|
|
275
|
+
this._cdRef.markForCheck();
|
|
276
|
+
}
|
|
277
|
+
ngOnInit() {
|
|
278
|
+
this.block = this._service.sanitizeBlock(this.block);
|
|
279
|
+
this.unit = this._service.config.unit;
|
|
280
|
+
this.content = this.block.content;
|
|
281
|
+
}
|
|
282
|
+
ngAfterContentInit() {
|
|
283
|
+
this.el.style.width = this.block.width + this.unit;
|
|
284
|
+
this.el.style.height = this.block.height + this.unit;
|
|
285
|
+
this.el.style.top = this.block.top + this.unit;
|
|
286
|
+
this.el.style.left = this.block.left + this.unit;
|
|
287
|
+
this._setTransform();
|
|
288
|
+
fromEvent(this.contentEditable.nativeElement, 'input')
|
|
289
|
+
.pipe(takeUntil(this._destroy$)).subscribe((event) => {
|
|
290
|
+
this.block.content = event.target.innerHTML;
|
|
291
|
+
this._triggerChanged();
|
|
292
|
+
});
|
|
293
|
+
fromEvent(this.el, 'mousedown')
|
|
294
|
+
.pipe(takeUntil(this._destroy$), filter(() => !this.block.readonly)).subscribe((event) => {
|
|
295
|
+
if (this.editable) {
|
|
296
|
+
if (this.contentElement.nativeElement.isSameNode(event.target)) {
|
|
297
|
+
event.preventDefault();
|
|
298
|
+
event.stopImmediatePropagation();
|
|
299
|
+
event.stopPropagation();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
this._service.selectedBlockComponents = [this];
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
fromEvent(this.el, 'dblclick')
|
|
307
|
+
.pipe(filter(() => (!this.editable)), takeUntil(this._destroy$))
|
|
308
|
+
.subscribe((event) => {
|
|
309
|
+
if (this.block.readonly) {
|
|
310
|
+
event.preventDefault();
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
this.editable = true;
|
|
314
|
+
this._cdRef.markForCheck();
|
|
315
|
+
setTimeout(() => {
|
|
316
|
+
this.selectAll();
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
this._moveable = new Moveable(this._elementRef.nativeElement, {
|
|
321
|
+
target: this.el,
|
|
322
|
+
container: this._service.container,
|
|
323
|
+
draggable: false,
|
|
324
|
+
resizable: false,
|
|
325
|
+
scalable: false,
|
|
326
|
+
rotatable: false,
|
|
327
|
+
warpable: false,
|
|
328
|
+
origin: false,
|
|
329
|
+
keepRatio: false,
|
|
330
|
+
snappable: true,
|
|
331
|
+
snapHorizontal: true,
|
|
332
|
+
snapVertical: true,
|
|
333
|
+
snapCenter: true,
|
|
334
|
+
snapElement: true,
|
|
335
|
+
edge: false,
|
|
336
|
+
throttleDrag: 1,
|
|
337
|
+
throttleScale: 0.01,
|
|
338
|
+
throttleRotate: 1,
|
|
339
|
+
throttleResize: 1,
|
|
340
|
+
});
|
|
341
|
+
this._service.registerBlock(this);
|
|
342
|
+
this._moveable
|
|
343
|
+
.on('clip', e => {
|
|
344
|
+
this.block.clipPath = e.clipStyle;
|
|
345
|
+
e.target.style.clipPath = e.clipStyle;
|
|
346
|
+
this._triggerChanged();
|
|
347
|
+
});
|
|
348
|
+
this._moveable.on('dragStart', ({ target, clientX, clientY }) => {
|
|
349
|
+
this.editable = false;
|
|
350
|
+
}).on('drag', ({ target, left, top }) => {
|
|
351
|
+
target.style.left = this.pxToIn(left) + this.unit;
|
|
352
|
+
target.style.top = this.pxToIn(top) + this.unit;
|
|
353
|
+
this.block.top = this.pxToIn(top);
|
|
354
|
+
this.block.left = this.pxToIn(left);
|
|
355
|
+
this._triggerChanged();
|
|
356
|
+
});
|
|
357
|
+
this._moveable.on('resizeStart', ({ target, clientX, clientY }) => {
|
|
358
|
+
this.editable = false;
|
|
359
|
+
}).on('resize', ({ target, width, height, dist, delta, direction }) => {
|
|
360
|
+
width = this.pxToIn(width);
|
|
361
|
+
height = this.pxToIn(height);
|
|
362
|
+
if (delta[0]) {
|
|
363
|
+
this.block.width = width;
|
|
364
|
+
target.style.width = width + this.unit;
|
|
365
|
+
}
|
|
366
|
+
if (delta[1]) {
|
|
367
|
+
this.block.height = height;
|
|
368
|
+
target.style.height = height + this.unit;
|
|
369
|
+
}
|
|
370
|
+
const transform = [0, 0];
|
|
371
|
+
if (direction[1] === -1) {
|
|
372
|
+
transform[1] = dist[1] * -1;
|
|
373
|
+
}
|
|
374
|
+
if (direction[0] === -1) {
|
|
375
|
+
transform[0] = dist[0] * -1;
|
|
376
|
+
}
|
|
377
|
+
this._setTransform([`translate(${transform[0]}px, ${transform[1]}px)`]);
|
|
378
|
+
this._triggerChanged();
|
|
379
|
+
}).on('resizeEnd', ({ target }) => {
|
|
380
|
+
const matrix = new WebKitCSSMatrix(target.style.transform);
|
|
381
|
+
this.block.top = parseFloat(target.style.top) + this.pxToIn(matrix.m42);
|
|
382
|
+
this.block.left = parseFloat(target.style.left) + this.pxToIn(matrix.m41);
|
|
383
|
+
target.style.top = this.block.top + this.unit;
|
|
384
|
+
target.style.left = this.block.left + this.unit;
|
|
385
|
+
this._setTransform();
|
|
386
|
+
this._triggerChanged();
|
|
387
|
+
});
|
|
388
|
+
this._moveable.on('rotateStart', ({ target, clientX, clientY }) => {
|
|
389
|
+
this.editable = false;
|
|
390
|
+
this._rotateStart = this.block.rotate || 0;
|
|
391
|
+
}).on('rotate', ({ rotate, transform }) => {
|
|
392
|
+
this.block.rotate = this._rotateStart + rotate;
|
|
393
|
+
this.el.style.transform = transform;
|
|
394
|
+
this._triggerChanged();
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
pxToIn(px) {
|
|
398
|
+
return this.round(px / 96, 2);
|
|
399
|
+
}
|
|
400
|
+
round(value, decimals) {
|
|
401
|
+
return parseFloat(value.toFixed(decimals));
|
|
402
|
+
}
|
|
403
|
+
deselect() {
|
|
404
|
+
this.transformable = false;
|
|
405
|
+
this.editable = false;
|
|
406
|
+
}
|
|
407
|
+
deselectContent() {
|
|
408
|
+
if (window.getSelection) {
|
|
409
|
+
if (window.getSelection().empty) {
|
|
410
|
+
window.getSelection().empty();
|
|
411
|
+
}
|
|
412
|
+
else if (window.getSelection().removeAllRanges) {
|
|
413
|
+
window.getSelection().removeAllRanges();
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
selectAll() {
|
|
418
|
+
const range = document.createRange();
|
|
419
|
+
range.selectNodeContents(this.contentEditable.nativeElement);
|
|
420
|
+
const sel = window.getSelection();
|
|
421
|
+
sel.removeAllRanges();
|
|
422
|
+
sel.addRange(range);
|
|
423
|
+
}
|
|
424
|
+
ngOnDestroy() {
|
|
425
|
+
this._destroy$.next();
|
|
426
|
+
this._destroy$.complete();
|
|
427
|
+
}
|
|
428
|
+
_setTransform(transforms = []) {
|
|
429
|
+
transforms = transforms !== null && transforms !== void 0 ? transforms : [];
|
|
430
|
+
if (this.block.rotate) {
|
|
431
|
+
transforms.push(`rotate(${this.block.rotate}deg)`);
|
|
432
|
+
}
|
|
433
|
+
this.el.style.transform = transforms.join(' ');
|
|
434
|
+
}
|
|
435
|
+
_triggerChanged() {
|
|
436
|
+
this.changed.emit(this.block);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
FsBlockComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockComponent, deps: [{ token: BlockEditorService }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
440
|
+
FsBlockComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockComponent, selector: "fs-block", inputs: { block: "block", html: "html" }, outputs: { changed: "changed" }, viewQueries: [{ propertyName: "element", first: true, predicate: ["element"], descendants: true, static: true }, { propertyName: "contentElement", first: true, predicate: ["contentElement"], descendants: true, static: true }, { propertyName: "contentEditable", first: true, predicate: ["contentEditable"], descendants: true, static: true }], ngImport: i0, template: "<div\n #element\n class=\"block\"\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", styles: [".block{position:absolute;display:block;outline:none;-webkit-user-select:none;user-select:none}.block:not(.readonly){cursor:pointer}.block .content-editable{outline:none;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:none!important;border:none!important}:host ::ng-deep .moveable-line:not(.moveable-rotation-line):not(.moveable-guideline){background:transparent!important}\n"], directives: [{ type: i7.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
441
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockComponent, decorators: [{
|
|
442
|
+
type: Component,
|
|
443
|
+
args: [{
|
|
444
|
+
selector: 'fs-block',
|
|
445
|
+
templateUrl: 'block.component.html',
|
|
446
|
+
styleUrls: ['block.component.scss'],
|
|
447
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
448
|
+
}]
|
|
449
|
+
}], ctorParameters: function () { return [{ type: BlockEditorService }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { element: [{
|
|
450
|
+
type: ViewChild,
|
|
451
|
+
args: ['element', { static: true }]
|
|
452
|
+
}], contentElement: [{
|
|
453
|
+
type: ViewChild,
|
|
454
|
+
args: ['contentElement', { static: true }]
|
|
455
|
+
}], contentEditable: [{
|
|
456
|
+
type: ViewChild,
|
|
457
|
+
args: ['contentEditable', { static: true }]
|
|
458
|
+
}], block: [{
|
|
459
|
+
type: Input
|
|
460
|
+
}], html: [{
|
|
461
|
+
type: Input
|
|
462
|
+
}], changed: [{
|
|
463
|
+
type: Output
|
|
480
464
|
}] } });
|
|
481
465
|
|
|
482
|
-
class FsBlockEditorSidebarPanelDirective {
|
|
483
|
-
constructor(templateRef) {
|
|
484
|
-
this.templateRef = templateRef;
|
|
485
|
-
this.show = true;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
FsBlockEditorSidebarPanelDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorSidebarPanelDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
489
|
-
FsBlockEditorSidebarPanelDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorSidebarPanelDirective, selector: "[fsBlockEditorSidebarPanel]", inputs: { label: "label", show: "show" }, ngImport: i0 });
|
|
490
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorSidebarPanelDirective, decorators: [{
|
|
491
|
-
type: Directive,
|
|
492
|
-
args: [{
|
|
493
|
-
selector: '[fsBlockEditorSidebarPanel]'
|
|
494
|
-
}]
|
|
495
|
-
}], ctorParameters: function () { return [{ type: i0.TemplateRef }]; }, propDecorators: { label: [{
|
|
496
|
-
type: Input
|
|
497
|
-
}], show: [{
|
|
498
|
-
type: Input
|
|
466
|
+
class FsBlockEditorSidebarPanelDirective {
|
|
467
|
+
constructor(templateRef) {
|
|
468
|
+
this.templateRef = templateRef;
|
|
469
|
+
this.show = true;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
FsBlockEditorSidebarPanelDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorSidebarPanelDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
473
|
+
FsBlockEditorSidebarPanelDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorSidebarPanelDirective, selector: "[fsBlockEditorSidebarPanel]", inputs: { label: "label", show: "show" }, ngImport: i0 });
|
|
474
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorSidebarPanelDirective, decorators: [{
|
|
475
|
+
type: Directive,
|
|
476
|
+
args: [{
|
|
477
|
+
selector: '[fsBlockEditorSidebarPanel]'
|
|
478
|
+
}]
|
|
479
|
+
}], ctorParameters: function () { return [{ type: i0.TemplateRef }]; }, propDecorators: { label: [{
|
|
480
|
+
type: Input
|
|
481
|
+
}], show: [{
|
|
482
|
+
type: Input
|
|
499
483
|
}] } });
|
|
500
484
|
|
|
501
|
-
class FsBlockEditorMarginDirective {
|
|
502
|
-
constructor(_elementRef) {
|
|
503
|
-
this._elementRef = _elementRef;
|
|
504
|
-
}
|
|
505
|
-
get element() {
|
|
506
|
-
return this._elementRef.nativeElement;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
FsBlockEditorMarginDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorMarginDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
510
|
-
FsBlockEditorMarginDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorMarginDirective, selector: "[fsBlockEditorMargin]", ngImport: i0 });
|
|
511
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorMarginDirective, decorators: [{
|
|
512
|
-
type: Directive,
|
|
513
|
-
args: [{
|
|
514
|
-
selector: '[fsBlockEditorMargin]'
|
|
515
|
-
}]
|
|
485
|
+
class FsBlockEditorMarginDirective {
|
|
486
|
+
constructor(_elementRef) {
|
|
487
|
+
this._elementRef = _elementRef;
|
|
488
|
+
}
|
|
489
|
+
get element() {
|
|
490
|
+
return this._elementRef.nativeElement;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
FsBlockEditorMarginDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorMarginDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
494
|
+
FsBlockEditorMarginDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorMarginDirective, selector: "[fsBlockEditorMargin]", ngImport: i0 });
|
|
495
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorMarginDirective, decorators: [{
|
|
496
|
+
type: Directive,
|
|
497
|
+
args: [{
|
|
498
|
+
selector: '[fsBlockEditorMargin]'
|
|
499
|
+
}]
|
|
516
500
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
|
|
517
501
|
|
|
518
|
-
class SidebarComponent {
|
|
519
|
-
constructor(_el, _service, _cdRef) {
|
|
520
|
-
this._el = _el;
|
|
521
|
-
this._service = _service;
|
|
522
|
-
this._cdRef = _cdRef;
|
|
523
|
-
this._destroy$ = new Subject();
|
|
524
|
-
}
|
|
525
|
-
get changeDetector() {
|
|
526
|
-
return this._cdRef;
|
|
527
|
-
}
|
|
528
|
-
get el() {
|
|
529
|
-
return this._el.nativeElement;
|
|
530
|
-
}
|
|
531
|
-
ngOnInit() {
|
|
532
|
-
this._service.selectedBlockComponents$
|
|
533
|
-
.pipe(takeUntil(this._destroy$))
|
|
534
|
-
.subscribe((blocks) => {
|
|
535
|
-
this.clippable = false;
|
|
536
|
-
this.block = blocks[0] ? blocks[0].block : null;
|
|
537
|
-
this.changeDetector.markForCheck();
|
|
538
|
-
if (this.config.blocksSelected) {
|
|
539
|
-
this.config.blocksSelected(blocks.map((block) => block.block));
|
|
540
|
-
}
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
verticalAlignClick(value) {
|
|
544
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
545
|
-
block.verticalAlign = value;
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
boldClick() {
|
|
549
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
550
|
-
block.bold = !block.bold;
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
fontColorChange(value) {
|
|
554
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
555
|
-
block.fontColor = value;
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
lineHeightChange(value) {
|
|
559
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
560
|
-
if (this.validNumeric(value)) {
|
|
561
|
-
block.lineHeight = value || null;
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
fontSizeChange(value) {
|
|
566
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
567
|
-
if (this.validNumeric(value)) {
|
|
568
|
-
block.fontSize = value || null;
|
|
569
|
-
}
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
borderWidthChange(value) {
|
|
573
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
574
|
-
if (this.validNumeric(value)) {
|
|
575
|
-
block.borderWidth = value || null;
|
|
576
|
-
}
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
italicClick() {
|
|
580
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
581
|
-
block.italic = !block.italic;
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
underlineClick() {
|
|
585
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
586
|
-
block.underline = !block.underline;
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
backgroundColorChange(value) {
|
|
590
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
591
|
-
block.backgroundColor = value;
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
widthChange(value) {
|
|
595
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
596
|
-
if (this.validNumeric(value)) {
|
|
597
|
-
block.width = value;
|
|
598
|
-
}
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
heightChange(value) {
|
|
602
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
603
|
-
if (this.validNumeric(value)) {
|
|
604
|
-
block.height = value;
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
topChange(value) {
|
|
609
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
610
|
-
if (this.validNumeric(value)) {
|
|
611
|
-
block.top = value;
|
|
612
|
-
}
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
leftChange(value) {
|
|
616
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
617
|
-
if (this.validNumeric(value)) {
|
|
618
|
-
block.left = value;
|
|
619
|
-
}
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
|
-
rotateChange(value) {
|
|
623
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
624
|
-
if (this.validNumeric(value)) {
|
|
625
|
-
block.rotate = value;
|
|
626
|
-
}
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
paddingChange(name, value) {
|
|
630
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
631
|
-
if (this.validNumeric(value)) {
|
|
632
|
-
block.padding(name, value || null);
|
|
633
|
-
}
|
|
634
|
-
});
|
|
635
|
-
}
|
|
636
|
-
paddingAllChange(value) {
|
|
637
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
638
|
-
if (this.validNumeric(value)) {
|
|
639
|
-
block.paddingAll = value;
|
|
640
|
-
}
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
borderColorChange(value) {
|
|
644
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
645
|
-
block.borderColor = value;
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
horizontalAlignClick(value) {
|
|
649
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
650
|
-
block.horizontalAlign = value;
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
shapeRound(value) {
|
|
654
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
655
|
-
block.shapeRound(value, block.block[value] === 'round' ? 'square' : 'round');
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
|
-
imageRemove() {
|
|
659
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
660
|
-
block.imageUrl = null;
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
imageClip() {
|
|
664
|
-
this.clippable = !this.clippable;
|
|
665
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
666
|
-
block.clippable = this.clippable;
|
|
667
|
-
});
|
|
668
|
-
}
|
|
669
|
-
shapeRadiusChange(value) {
|
|
670
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
671
|
-
block.shapeRadius = value;
|
|
672
|
-
});
|
|
673
|
-
}
|
|
674
|
-
fileSelect(fsFile) {
|
|
675
|
-
if (this.config.fileUpload) {
|
|
676
|
-
this.config.fileUpload(fsFile.file)
|
|
677
|
-
.subscribe((value) => {
|
|
678
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
679
|
-
block.imageUrl = value;
|
|
680
|
-
});
|
|
681
|
-
});
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
blockRemoveClick() {
|
|
685
|
-
if (this.config.blocksRemoved) {
|
|
686
|
-
this.config.blocksRemoved(this._service.selectedBlocks)
|
|
687
|
-
.pipe(takeUntil(this._destroy$))
|
|
688
|
-
.subscribe(() => {
|
|
689
|
-
this._service.selectedBlocks.forEach((block) => {
|
|
690
|
-
this._service.removeBlock(block);
|
|
691
|
-
});
|
|
692
|
-
this._service.selectedBlockComponents = [];
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
blockAddClick() {
|
|
697
|
-
const width = (this.config.width * .333).toFixed(2);
|
|
698
|
-
const height = (this.config.height * .333).toFixed(2);
|
|
699
|
-
const reference = guid();
|
|
700
|
-
const block = {
|
|
701
|
-
type: 'text',
|
|
702
|
-
reference,
|
|
703
|
-
top: height,
|
|
704
|
-
left: width,
|
|
705
|
-
width: width,
|
|
706
|
-
height: height,
|
|
707
|
-
};
|
|
708
|
-
if (this.config.blockAdded) {
|
|
709
|
-
this.config.blockAdded(block)
|
|
710
|
-
.pipe(takeUntil(this._destroy$))
|
|
711
|
-
.subscribe((block) => {
|
|
712
|
-
this.addBlock(block);
|
|
713
|
-
this.changeDetector.markForCheck();
|
|
714
|
-
this.blockAdded
|
|
715
|
-
.pipe(take(1), takeUntil(this._destroy$))
|
|
716
|
-
.subscribe((blockComponent) => {
|
|
717
|
-
this._service.selectedBlockComponents = [blockComponent];
|
|
718
|
-
});
|
|
719
|
-
});
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
addBlock(block) {
|
|
723
|
-
this._service.addBlock(block);
|
|
724
|
-
this._updateIndexes();
|
|
725
|
-
}
|
|
726
|
-
_updateIndexes() {
|
|
727
|
-
const sort = this.blocks.slice().sort((a, b) => {
|
|
728
|
-
return a.index > b.index ? 1 : -1;
|
|
729
|
-
});
|
|
730
|
-
sort.forEach((block, index) => {
|
|
731
|
-
this.blocks.find((item) => {
|
|
732
|
-
return block.reference === item.reference;
|
|
733
|
-
}).index = index;
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
layerMove(direction) {
|
|
737
|
-
this._service.blockComponents.forEach((blockComponent) => {
|
|
738
|
-
if (this._service.isSelectedBlock(blockComponent)) {
|
|
739
|
-
blockComponent.block.index + (999 * direction);
|
|
740
|
-
}
|
|
741
|
-
});
|
|
742
|
-
const sorted = this._service.blockComponents.sort((a, b) => {
|
|
743
|
-
return a.index > b.index ? 1 : -1;
|
|
744
|
-
});
|
|
745
|
-
sorted.forEach((item, index) => {
|
|
746
|
-
item.block.index = index;
|
|
747
|
-
item.markForCheck();
|
|
748
|
-
});
|
|
749
|
-
if (this.config.blocksLevelChanged) {
|
|
750
|
-
this.config.blocksLevelChanged(sorted.map((item) => item.block));
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
layerUp() {
|
|
754
|
-
this.layerMove(1);
|
|
755
|
-
}
|
|
756
|
-
layerDown() {
|
|
757
|
-
this.layerMove(-1);
|
|
758
|
-
}
|
|
759
|
-
getBlock(reference) {
|
|
760
|
-
return this._service.blocks.find((block) => {
|
|
761
|
-
return block.reference === reference;
|
|
762
|
-
});
|
|
763
|
-
}
|
|
764
|
-
blockChanged(block) {
|
|
765
|
-
if (this.config.blockChanged) {
|
|
766
|
-
this.config.blockChanged(block);
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
inputFocus(event) {
|
|
770
|
-
event.target.select();
|
|
771
|
-
}
|
|
772
|
-
ngOnDestroy() {
|
|
773
|
-
this._destroy$.next();
|
|
774
|
-
this._destroy$.complete();
|
|
775
|
-
}
|
|
776
|
-
validNumeric(value) {
|
|
777
|
-
return !value || !!String(value).match(/^\d*\.?\d*$/);
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
SidebarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SidebarComponent, deps: [{ token: i0.ElementRef }, { token: BlockEditorService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
781
|
-
SidebarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SidebarComponent, selector: "sidebar", inputs: { config: "config", blocks: "blocks", blockAdded: "blockAdded" }, queries: [{ propertyName: "sidebarPanels", predicate: FsBlockEditorSidebarPanelDirective }], ngImport: i0, 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", 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 .mat-form-field-prefix,.sidebar .sidebar-row ::ng-deep .field-label{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-up ::ng-deep .mat-button-wrapper,.sidebar .layer-down ::ng-deep .mat-button-wrapper{position:relative}.sidebar .layer-up ::ng-deep .mat-button-wrapper mat-icon:first-child,.sidebar .layer-down ::ng-deep .mat-button-wrapper mat-icon:first-child{position:absolute;transform:rotate(90deg) scale(.6);top:-6px;color:#fff}.sidebar .layer-down mat-icon:first-child{transform:rotate(270deg) scale(.6)}.sidebar .padding{width:45px}.sidebar .line-height,.sidebar .font-size,.sidebar .border-width{width:45px}.sidebar .shape-radius{width:50px}.sidebar .shape-corners{display:grid;grid-template-columns:1fr 1fr;grid-column-gap:1px;column-gap:1px;grid-row-gap:1px;row-gap:1px}.sidebar .shape-corners .shape-corner{height:13px;width:13px;background-color:#ccc;cursor:pointer}.sidebar .shape-corners .shape-corner.round.shape-corner-top-right{border-top-right-radius:50%}.sidebar .shape-corners .shape-corner.round.shape-corner-top-left{border-top-left-radius:50%}.sidebar .shape-corners .shape-corner.round.shape-corner-bottom-left{border-bottom-left-radius:50%}.sidebar .shape-corners .shape-corner.round.shape-corner-bottom-right{border-bottom-right-radius:50%}.sidebar button.toggle-button:not(.selected) mat-icon{color:#ccc}.sidebar .sidebar-panel{padding:10px;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}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i4.MatFormField, selector: "mat-form-field", inputs: ["color", "floatLabel", "appearance", "hideRequiredMarker", "hintLabel"], exportAs: ["matFormField"] }, { type: i5.FsColorPickerChipComponent, selector: "fs-color-picker-chip", inputs: ["color"], outputs: ["changed"] }, { type: i6.FsFileComponent, selector: "fs-file", inputs: ["minHeight", "minWidth", "multiple", "capture", "allowClick", "allowDrop", "accept", "disabled", "imageWidth", "imageHeight", "imageQuality"], outputs: ["select", "error", "clicked", "declined"] }], directives: [{ type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i8.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["id", "disabled", "required", "type", "value", "readonly", "placeholder", "errorStateMatcher", "aria-describedby"], exportAs: ["matInput"] }, { type: i9.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i9.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i9.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i4.MatPrefix, selector: "[matPrefix]" }, { type: i7.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
782
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SidebarComponent, decorators: [{
|
|
783
|
-
type: Component,
|
|
784
|
-
args: [{
|
|
785
|
-
selector: 'sidebar',
|
|
786
|
-
templateUrl: 'sidebar.component.html',
|
|
787
|
-
styleUrls: ['sidebar.component.scss'],
|
|
788
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
789
|
-
}]
|
|
790
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { sidebarPanels: [{
|
|
791
|
-
type: ContentChildren,
|
|
792
|
-
args: [FsBlockEditorSidebarPanelDirective]
|
|
793
|
-
}], config: [{
|
|
794
|
-
type: Input
|
|
795
|
-
}], blocks: [{
|
|
796
|
-
type: Input
|
|
797
|
-
}], blockAdded: [{
|
|
798
|
-
type: Input
|
|
502
|
+
class SidebarComponent {
|
|
503
|
+
constructor(_el, _service, _cdRef) {
|
|
504
|
+
this._el = _el;
|
|
505
|
+
this._service = _service;
|
|
506
|
+
this._cdRef = _cdRef;
|
|
507
|
+
this._destroy$ = new Subject();
|
|
508
|
+
}
|
|
509
|
+
get changeDetector() {
|
|
510
|
+
return this._cdRef;
|
|
511
|
+
}
|
|
512
|
+
get el() {
|
|
513
|
+
return this._el.nativeElement;
|
|
514
|
+
}
|
|
515
|
+
ngOnInit() {
|
|
516
|
+
this._service.selectedBlockComponents$
|
|
517
|
+
.pipe(takeUntil(this._destroy$))
|
|
518
|
+
.subscribe((blocks) => {
|
|
519
|
+
this.clippable = false;
|
|
520
|
+
this.block = blocks[0] ? blocks[0].block : null;
|
|
521
|
+
this.changeDetector.markForCheck();
|
|
522
|
+
if (this.config.blocksSelected) {
|
|
523
|
+
this.config.blocksSelected(blocks.map((block) => block.block));
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
verticalAlignClick(value) {
|
|
528
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
529
|
+
block.verticalAlign = value;
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
boldClick() {
|
|
533
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
534
|
+
block.bold = !block.bold;
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
fontColorChange(value) {
|
|
538
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
539
|
+
block.fontColor = value;
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
lineHeightChange(value) {
|
|
543
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
544
|
+
if (this.validNumeric(value)) {
|
|
545
|
+
block.lineHeight = value || null;
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
fontSizeChange(value) {
|
|
550
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
551
|
+
if (this.validNumeric(value)) {
|
|
552
|
+
block.fontSize = value || null;
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
borderWidthChange(value) {
|
|
557
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
558
|
+
if (this.validNumeric(value)) {
|
|
559
|
+
block.borderWidth = value || null;
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
italicClick() {
|
|
564
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
565
|
+
block.italic = !block.italic;
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
underlineClick() {
|
|
569
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
570
|
+
block.underline = !block.underline;
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
backgroundColorChange(value) {
|
|
574
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
575
|
+
block.backgroundColor = value;
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
widthChange(value) {
|
|
579
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
580
|
+
if (this.validNumeric(value)) {
|
|
581
|
+
block.width = value;
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
heightChange(value) {
|
|
586
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
587
|
+
if (this.validNumeric(value)) {
|
|
588
|
+
block.height = value;
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
topChange(value) {
|
|
593
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
594
|
+
if (this.validNumeric(value)) {
|
|
595
|
+
block.top = value;
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
leftChange(value) {
|
|
600
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
601
|
+
if (this.validNumeric(value)) {
|
|
602
|
+
block.left = value;
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
rotateChange(value) {
|
|
607
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
608
|
+
if (this.validNumeric(value)) {
|
|
609
|
+
block.rotate = value;
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
paddingChange(name, value) {
|
|
614
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
615
|
+
if (this.validNumeric(value)) {
|
|
616
|
+
block.padding(name, value || null);
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
paddingAllChange(value) {
|
|
621
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
622
|
+
if (this.validNumeric(value)) {
|
|
623
|
+
block.paddingAll = value;
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
borderColorChange(value) {
|
|
628
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
629
|
+
block.borderColor = value;
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
horizontalAlignClick(value) {
|
|
633
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
634
|
+
block.horizontalAlign = value;
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
shapeRound(value) {
|
|
638
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
639
|
+
block.shapeRound(value, block.block[value] === 'round' ? 'square' : 'round');
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
imageRemove() {
|
|
643
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
644
|
+
block.imageUrl = null;
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
imageClip() {
|
|
648
|
+
this.clippable = !this.clippable;
|
|
649
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
650
|
+
block.clippable = this.clippable;
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
shapeRadiusChange(value) {
|
|
654
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
655
|
+
block.shapeRadius = value;
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
fileSelect(fsFile) {
|
|
659
|
+
if (this.config.fileUpload) {
|
|
660
|
+
this.config.fileUpload(fsFile.file)
|
|
661
|
+
.subscribe((value) => {
|
|
662
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
663
|
+
block.imageUrl = value;
|
|
664
|
+
});
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
blockRemoveClick() {
|
|
669
|
+
if (this.config.blocksRemoved) {
|
|
670
|
+
this.config.blocksRemoved(this._service.selectedBlocks)
|
|
671
|
+
.pipe(takeUntil(this._destroy$))
|
|
672
|
+
.subscribe(() => {
|
|
673
|
+
this._service.selectedBlocks.forEach((block) => {
|
|
674
|
+
this._service.removeBlock(block);
|
|
675
|
+
});
|
|
676
|
+
this._service.selectedBlockComponents = [];
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
blockAddClick() {
|
|
681
|
+
const width = (this.config.width * .333).toFixed(2);
|
|
682
|
+
const height = (this.config.height * .333).toFixed(2);
|
|
683
|
+
const reference = guid();
|
|
684
|
+
const block = {
|
|
685
|
+
type: 'text',
|
|
686
|
+
reference,
|
|
687
|
+
top: height,
|
|
688
|
+
left: width,
|
|
689
|
+
width: width,
|
|
690
|
+
height: height,
|
|
691
|
+
};
|
|
692
|
+
if (this.config.blockAdded) {
|
|
693
|
+
this.config.blockAdded(block)
|
|
694
|
+
.pipe(takeUntil(this._destroy$))
|
|
695
|
+
.subscribe((block) => {
|
|
696
|
+
this.addBlock(block);
|
|
697
|
+
this.changeDetector.markForCheck();
|
|
698
|
+
this.blockAdded
|
|
699
|
+
.pipe(take(1), takeUntil(this._destroy$))
|
|
700
|
+
.subscribe((blockComponent) => {
|
|
701
|
+
this._service.selectedBlockComponents = [blockComponent];
|
|
702
|
+
});
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
addBlock(block) {
|
|
707
|
+
this._service.addBlock(block);
|
|
708
|
+
this._updateIndexes();
|
|
709
|
+
}
|
|
710
|
+
_updateIndexes() {
|
|
711
|
+
const sort = this.blocks.slice().sort((a, b) => {
|
|
712
|
+
return a.index > b.index ? 1 : -1;
|
|
713
|
+
});
|
|
714
|
+
sort.forEach((block, index) => {
|
|
715
|
+
this.blocks.find((item) => {
|
|
716
|
+
return block.reference === item.reference;
|
|
717
|
+
}).index = index;
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
layerMove(direction) {
|
|
721
|
+
this._service.blockComponents.forEach((blockComponent) => {
|
|
722
|
+
if (this._service.isSelectedBlock(blockComponent)) {
|
|
723
|
+
blockComponent.block.index + (999 * direction);
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
const sorted = this._service.blockComponents.sort((a, b) => {
|
|
727
|
+
return a.index > b.index ? 1 : -1;
|
|
728
|
+
});
|
|
729
|
+
sorted.forEach((item, index) => {
|
|
730
|
+
item.block.index = index;
|
|
731
|
+
item.markForCheck();
|
|
732
|
+
});
|
|
733
|
+
if (this.config.blocksLevelChanged) {
|
|
734
|
+
this.config.blocksLevelChanged(sorted.map((item) => item.block));
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
layerUp() {
|
|
738
|
+
this.layerMove(1);
|
|
739
|
+
}
|
|
740
|
+
layerDown() {
|
|
741
|
+
this.layerMove(-1);
|
|
742
|
+
}
|
|
743
|
+
getBlock(reference) {
|
|
744
|
+
return this._service.blocks.find((block) => {
|
|
745
|
+
return block.reference === reference;
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
blockChanged(block) {
|
|
749
|
+
if (this.config.blockChanged) {
|
|
750
|
+
this.config.blockChanged(block);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
inputFocus(event) {
|
|
754
|
+
event.target.select();
|
|
755
|
+
}
|
|
756
|
+
ngOnDestroy() {
|
|
757
|
+
this._destroy$.next();
|
|
758
|
+
this._destroy$.complete();
|
|
759
|
+
}
|
|
760
|
+
validNumeric(value) {
|
|
761
|
+
return !value || !!String(value).match(/^\d*\.?\d*$/);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
SidebarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SidebarComponent, deps: [{ token: i0.ElementRef }, { token: BlockEditorService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
765
|
+
SidebarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SidebarComponent, selector: "sidebar", inputs: { config: "config", blocks: "blocks", blockAdded: "blockAdded" }, queries: [{ propertyName: "sidebarPanels", predicate: FsBlockEditorSidebarPanelDirective }], ngImport: i0, 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", 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 .mat-form-field-prefix,.sidebar .sidebar-row ::ng-deep .field-label{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-up ::ng-deep .mat-button-wrapper,.sidebar .layer-down ::ng-deep .mat-button-wrapper{position:relative}.sidebar .layer-up ::ng-deep .mat-button-wrapper mat-icon:first-child,.sidebar .layer-down ::ng-deep .mat-button-wrapper mat-icon:first-child{position:absolute;transform:rotate(90deg) scale(.6);top:-6px;color:#fff}.sidebar .layer-down mat-icon:first-child{transform:rotate(270deg) scale(.6)}.sidebar .padding{width:45px}.sidebar .line-height,.sidebar .font-size,.sidebar .border-width{width:45px}.sidebar .shape-radius{width:50px}.sidebar .shape-corners{display:grid;grid-template-columns:1fr 1fr;grid-column-gap:1px;column-gap:1px;grid-row-gap:1px;row-gap:1px}.sidebar .shape-corners .shape-corner{height:13px;width:13px;background-color:#ccc;cursor:pointer}.sidebar .shape-corners .shape-corner.round.shape-corner-top-right{border-top-right-radius:50%}.sidebar .shape-corners .shape-corner.round.shape-corner-top-left{border-top-left-radius:50%}.sidebar .shape-corners .shape-corner.round.shape-corner-bottom-left{border-bottom-left-radius:50%}.sidebar .shape-corners .shape-corner.round.shape-corner-bottom-right{border-bottom-right-radius:50%}.sidebar button.toggle-button:not(.selected) mat-icon{color:#ccc}.sidebar .sidebar-panel{padding:10px;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}\n"], components: [{ type: i2.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i4.MatFormField, selector: "mat-form-field", inputs: ["color", "floatLabel", "appearance", "hideRequiredMarker", "hintLabel"], exportAs: ["matFormField"] }, { type: i5.FsColorPickerChipComponent, selector: "fs-color-picker-chip", inputs: ["color"], outputs: ["changed"] }, { type: i6.FsFileComponent, selector: "fs-file", inputs: ["minHeight", "minWidth", "multiple", "capture", "allowClick", "allowDrop", "accept", "disabled", "imageWidth", "imageHeight", "imageQuality"], outputs: ["select", "error", "clicked", "declined"] }], directives: [{ type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i8.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["id", "disabled", "required", "type", "value", "readonly", "placeholder", "errorStateMatcher", "aria-describedby"], exportAs: ["matInput"] }, { type: i9.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i9.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i9.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i4.MatPrefix, selector: "[matPrefix]" }, { type: i7.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
766
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SidebarComponent, decorators: [{
|
|
767
|
+
type: Component,
|
|
768
|
+
args: [{
|
|
769
|
+
selector: 'sidebar',
|
|
770
|
+
templateUrl: 'sidebar.component.html',
|
|
771
|
+
styleUrls: ['sidebar.component.scss'],
|
|
772
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
773
|
+
}]
|
|
774
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { sidebarPanels: [{
|
|
775
|
+
type: ContentChildren,
|
|
776
|
+
args: [FsBlockEditorSidebarPanelDirective]
|
|
777
|
+
}], config: [{
|
|
778
|
+
type: Input
|
|
779
|
+
}], blocks: [{
|
|
780
|
+
type: Input
|
|
781
|
+
}], blockAdded: [{
|
|
782
|
+
type: Input
|
|
799
783
|
}] } });
|
|
800
784
|
|
|
801
|
-
class FsBlockEditorComponent {
|
|
802
|
-
constructor(_el, _service, _cdRef, _differs) {
|
|
803
|
-
this._el = _el;
|
|
804
|
-
this._service = _service;
|
|
805
|
-
this._cdRef = _cdRef;
|
|
806
|
-
this._differs = _differs;
|
|
807
|
-
this.blockAdded = new EventEmitter();
|
|
808
|
-
this.blockRemoved = new EventEmitter();
|
|
809
|
-
this._destroy$ = new Subject();
|
|
810
|
-
this._differ = _differs.find([]).create(null);
|
|
811
|
-
}
|
|
812
|
-
get el() {
|
|
813
|
-
return this._el.nativeElement;
|
|
814
|
-
}
|
|
815
|
-
ngOnInit() {
|
|
816
|
-
this.config = Object.assign(Object.assign({}, this.config), { unit: 'in' });
|
|
817
|
-
this._service.registerContainer(this.artboard.nativeElement);
|
|
818
|
-
this._service.registerMargin(this.marginContainer.nativeElement);
|
|
819
|
-
this._service.blocks = this.config.blocks;
|
|
820
|
-
this._service.config = this.config;
|
|
821
|
-
this._service.blocks$
|
|
822
|
-
.pipe(takeUntil(this._destroy$))
|
|
823
|
-
.subscribe((blocks) => {
|
|
824
|
-
this.blocks = blocks;
|
|
825
|
-
});
|
|
826
|
-
fromEvent(window, 'keydown')
|
|
827
|
-
.pipe(takeUntil(this._destroy$), filter((event) => {
|
|
828
|
-
return !!event.key.match(/^Arrow/) && !!this._service.selectedBlockComponents.length;
|
|
829
|
-
}))
|
|
830
|
-
.subscribe((event) => {
|
|
831
|
-
event.preventDefault();
|
|
832
|
-
const inchPixel = 1 / 100;
|
|
833
|
-
this._service.selectedBlockComponents.forEach((blockComponent) => {
|
|
834
|
-
switch (event.key) {
|
|
835
|
-
case 'ArrowUp':
|
|
836
|
-
blockComponent.top = blockComponent.block.top - inchPixel;
|
|
837
|
-
break;
|
|
838
|
-
case 'ArrowDown':
|
|
839
|
-
blockComponent.top = blockComponent.block.top + inchPixel;
|
|
840
|
-
break;
|
|
841
|
-
case 'ArrowLeft':
|
|
842
|
-
blockComponent.left = blockComponent.block.left - inchPixel;
|
|
843
|
-
break;
|
|
844
|
-
case 'ArrowRight':
|
|
845
|
-
blockComponent.left = blockComponent.block.left + inchPixel;
|
|
846
|
-
break;
|
|
847
|
-
}
|
|
848
|
-
});
|
|
849
|
-
});
|
|
850
|
-
}
|
|
851
|
-
artboardClick(event) {
|
|
852
|
-
if (event.target.isSameNode(this.artboard.nativeElement) ||
|
|
853
|
-
event.target.isSameNode(this.artboardContainer.nativeElement)) {
|
|
854
|
-
this._service.selectedBlockComponents.forEach((block) => {
|
|
855
|
-
block.deselect();
|
|
856
|
-
block.markForCheck();
|
|
857
|
-
});
|
|
858
|
-
this._service.selectedBlockComponents = [];
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
blockChanged(block) {
|
|
862
|
-
this.sidebar.changeDetector.markForCheck();
|
|
863
|
-
if (this.config.blockChanged) {
|
|
864
|
-
this.config.blockChanged(block);
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
ngAfterViewInit() {
|
|
868
|
-
this.blockComponents.changes.subscribe((changes) => {
|
|
869
|
-
const changeDiff = this._differ.diff(changes);
|
|
870
|
-
if (changeDiff) {
|
|
871
|
-
changeDiff.forEachAddedItem((change) => {
|
|
872
|
-
this.blockAdded.emit(change.item);
|
|
873
|
-
});
|
|
874
|
-
changeDiff.forEachRemovedItem((change) => {
|
|
875
|
-
this.blockRemoved.emit(change.item);
|
|
876
|
-
});
|
|
877
|
-
}
|
|
878
|
-
});
|
|
879
|
-
}
|
|
880
|
-
ngOnDestroy() {
|
|
881
|
-
this._destroy$.next();
|
|
882
|
-
this._destroy$.complete();
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
FsBlockEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorComponent, deps: [{ token: i0.ElementRef }, { token: BlockEditorService }, { token: i0.ChangeDetectorRef }, { token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Component });
|
|
886
|
-
FsBlockEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorComponent, selector: "fs-block-editor", inputs: { config: "config" }, outputs: { blockAdded: "blockAdded", blockRemoved: "blockRemoved" }, providers: [
|
|
887
|
-
BlockEditorService,
|
|
888
|
-
], queries: [{ propertyName: "sidebarPanels", predicate: FsBlockEditorSidebarPanelDirective }], viewQueries: [{ propertyName: "artboard", first: true, predicate: ["artboard"], descendants: true, static: true }, { propertyName: "marginContainer", first: true, predicate: ["marginContainer"], descendants: true, static: true }, { propertyName: "artboardContainer", first: true, predicate: ["artboardContainer"], descendants: true, static: true }, { propertyName: "sidebar", first: true, predicate: SidebarComponent, descendants: true, static: true }, { propertyName: "blockComponents", predicate: FsBlockComponent, descendants: true }, { propertyName: "margins", predicate: FsBlockEditorMarginDirective, descendants: true }], ngImport: i0, template: "<div 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", 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-color:#ff85bd5e;border-style:dashed;border-width:0px}.editor-container .artboard-container .artboard .margin.margin-top,.editor-container .artboard-container .artboard .margin.margin-bottom{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}\n"], components: [{ type: FsBlockComponent, selector: "fs-block", inputs: ["block", "html"], outputs: ["changed"] }, { type: SidebarComponent, selector: "sidebar", inputs: ["config", "blocks", "blockAdded"] }], directives: [{ type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
889
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorComponent, decorators: [{
|
|
890
|
-
type: Component,
|
|
891
|
-
args: [{
|
|
892
|
-
selector: 'fs-block-editor',
|
|
893
|
-
templateUrl: 'block-editor.component.html',
|
|
894
|
-
styleUrls: ['block-editor.component.scss'],
|
|
895
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
896
|
-
providers: [
|
|
897
|
-
BlockEditorService,
|
|
898
|
-
]
|
|
899
|
-
}]
|
|
900
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }, { type: i0.ChangeDetectorRef }, { type: i0.IterableDiffers }]; }, propDecorators: { sidebarPanels: [{
|
|
901
|
-
type: ContentChildren,
|
|
902
|
-
args: [FsBlockEditorSidebarPanelDirective]
|
|
903
|
-
}], blockComponents: [{
|
|
904
|
-
type: ViewChildren,
|
|
905
|
-
args: [FsBlockComponent]
|
|
906
|
-
}], artboard: [{
|
|
907
|
-
type: ViewChild,
|
|
908
|
-
args: ['artboard', { static: true }]
|
|
909
|
-
}], marginContainer: [{
|
|
910
|
-
type: ViewChild,
|
|
911
|
-
args: ['marginContainer', { static: true }]
|
|
912
|
-
}], margins: [{
|
|
913
|
-
type: ViewChildren,
|
|
914
|
-
args: [FsBlockEditorMarginDirective]
|
|
915
|
-
}], artboardContainer: [{
|
|
916
|
-
type: ViewChild,
|
|
917
|
-
args: ['artboardContainer', { static: true }]
|
|
918
|
-
}], sidebar: [{
|
|
919
|
-
type: ViewChild,
|
|
920
|
-
args: [SidebarComponent, { static: true }]
|
|
921
|
-
}], config: [{
|
|
922
|
-
type: Input
|
|
923
|
-
}], blockAdded: [{
|
|
924
|
-
type: Output
|
|
925
|
-
}], blockRemoved: [{
|
|
926
|
-
type: Output
|
|
785
|
+
class FsBlockEditorComponent {
|
|
786
|
+
constructor(_el, _service, _cdRef, _differs) {
|
|
787
|
+
this._el = _el;
|
|
788
|
+
this._service = _service;
|
|
789
|
+
this._cdRef = _cdRef;
|
|
790
|
+
this._differs = _differs;
|
|
791
|
+
this.blockAdded = new EventEmitter();
|
|
792
|
+
this.blockRemoved = new EventEmitter();
|
|
793
|
+
this._destroy$ = new Subject();
|
|
794
|
+
this._differ = _differs.find([]).create(null);
|
|
795
|
+
}
|
|
796
|
+
get el() {
|
|
797
|
+
return this._el.nativeElement;
|
|
798
|
+
}
|
|
799
|
+
ngOnInit() {
|
|
800
|
+
this.config = Object.assign(Object.assign({}, this.config), { unit: 'in' });
|
|
801
|
+
this._service.registerContainer(this.artboard.nativeElement);
|
|
802
|
+
this._service.registerMargin(this.marginContainer.nativeElement);
|
|
803
|
+
this._service.blocks = this.config.blocks;
|
|
804
|
+
this._service.config = this.config;
|
|
805
|
+
this._service.blocks$
|
|
806
|
+
.pipe(takeUntil(this._destroy$))
|
|
807
|
+
.subscribe((blocks) => {
|
|
808
|
+
this.blocks = blocks;
|
|
809
|
+
});
|
|
810
|
+
fromEvent(window, 'keydown')
|
|
811
|
+
.pipe(takeUntil(this._destroy$), filter((event) => {
|
|
812
|
+
return !!event.key.match(/^Arrow/) && !!this._service.selectedBlockComponents.length;
|
|
813
|
+
}))
|
|
814
|
+
.subscribe((event) => {
|
|
815
|
+
event.preventDefault();
|
|
816
|
+
const inchPixel = 1 / 100;
|
|
817
|
+
this._service.selectedBlockComponents.forEach((blockComponent) => {
|
|
818
|
+
switch (event.key) {
|
|
819
|
+
case 'ArrowUp':
|
|
820
|
+
blockComponent.top = blockComponent.block.top - inchPixel;
|
|
821
|
+
break;
|
|
822
|
+
case 'ArrowDown':
|
|
823
|
+
blockComponent.top = blockComponent.block.top + inchPixel;
|
|
824
|
+
break;
|
|
825
|
+
case 'ArrowLeft':
|
|
826
|
+
blockComponent.left = blockComponent.block.left - inchPixel;
|
|
827
|
+
break;
|
|
828
|
+
case 'ArrowRight':
|
|
829
|
+
blockComponent.left = blockComponent.block.left + inchPixel;
|
|
830
|
+
break;
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
artboardClick(event) {
|
|
836
|
+
if (event.target.isSameNode(this.artboard.nativeElement) ||
|
|
837
|
+
event.target.isSameNode(this.artboardContainer.nativeElement)) {
|
|
838
|
+
this._service.selectedBlockComponents.forEach((block) => {
|
|
839
|
+
block.deselect();
|
|
840
|
+
block.markForCheck();
|
|
841
|
+
});
|
|
842
|
+
this._service.selectedBlockComponents = [];
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
blockChanged(block) {
|
|
846
|
+
this.sidebar.changeDetector.markForCheck();
|
|
847
|
+
if (this.config.blockChanged) {
|
|
848
|
+
this.config.blockChanged(block);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
ngAfterViewInit() {
|
|
852
|
+
this.blockComponents.changes.subscribe((changes) => {
|
|
853
|
+
const changeDiff = this._differ.diff(changes);
|
|
854
|
+
if (changeDiff) {
|
|
855
|
+
changeDiff.forEachAddedItem((change) => {
|
|
856
|
+
this.blockAdded.emit(change.item);
|
|
857
|
+
});
|
|
858
|
+
changeDiff.forEachRemovedItem((change) => {
|
|
859
|
+
this.blockRemoved.emit(change.item);
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
ngOnDestroy() {
|
|
865
|
+
this._destroy$.next();
|
|
866
|
+
this._destroy$.complete();
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
FsBlockEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorComponent, deps: [{ token: i0.ElementRef }, { token: BlockEditorService }, { token: i0.ChangeDetectorRef }, { token: i0.IterableDiffers }], target: i0.ɵɵFactoryTarget.Component });
|
|
870
|
+
FsBlockEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorComponent, selector: "fs-block-editor", inputs: { config: "config" }, outputs: { blockAdded: "blockAdded", blockRemoved: "blockRemoved" }, providers: [
|
|
871
|
+
BlockEditorService,
|
|
872
|
+
], queries: [{ propertyName: "sidebarPanels", predicate: FsBlockEditorSidebarPanelDirective }], viewQueries: [{ propertyName: "artboard", first: true, predicate: ["artboard"], descendants: true, static: true }, { propertyName: "marginContainer", first: true, predicate: ["marginContainer"], descendants: true, static: true }, { propertyName: "artboardContainer", first: true, predicate: ["artboardContainer"], descendants: true, static: true }, { propertyName: "sidebar", first: true, predicate: SidebarComponent, descendants: true, static: true }, { propertyName: "blockComponents", predicate: FsBlockComponent, descendants: true }, { propertyName: "margins", predicate: FsBlockEditorMarginDirective, descendants: true }], ngImport: i0, template: "<div 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", 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-color:#ff85bd5e;border-style:dashed;border-width:0px}.editor-container .artboard-container .artboard .margin.margin-top,.editor-container .artboard-container .artboard .margin.margin-bottom{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}\n"], components: [{ type: FsBlockComponent, selector: "fs-block", inputs: ["block", "html"], outputs: ["changed"] }, { type: SidebarComponent, selector: "sidebar", inputs: ["config", "blocks", "blockAdded"] }], directives: [{ type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
873
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorComponent, decorators: [{
|
|
874
|
+
type: Component,
|
|
875
|
+
args: [{
|
|
876
|
+
selector: 'fs-block-editor',
|
|
877
|
+
templateUrl: 'block-editor.component.html',
|
|
878
|
+
styleUrls: ['block-editor.component.scss'],
|
|
879
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
880
|
+
providers: [
|
|
881
|
+
BlockEditorService,
|
|
882
|
+
]
|
|
883
|
+
}]
|
|
884
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: BlockEditorService }, { type: i0.ChangeDetectorRef }, { type: i0.IterableDiffers }]; }, propDecorators: { sidebarPanels: [{
|
|
885
|
+
type: ContentChildren,
|
|
886
|
+
args: [FsBlockEditorSidebarPanelDirective]
|
|
887
|
+
}], blockComponents: [{
|
|
888
|
+
type: ViewChildren,
|
|
889
|
+
args: [FsBlockComponent]
|
|
890
|
+
}], artboard: [{
|
|
891
|
+
type: ViewChild,
|
|
892
|
+
args: ['artboard', { static: true }]
|
|
893
|
+
}], marginContainer: [{
|
|
894
|
+
type: ViewChild,
|
|
895
|
+
args: ['marginContainer', { static: true }]
|
|
896
|
+
}], margins: [{
|
|
897
|
+
type: ViewChildren,
|
|
898
|
+
args: [FsBlockEditorMarginDirective]
|
|
899
|
+
}], artboardContainer: [{
|
|
900
|
+
type: ViewChild,
|
|
901
|
+
args: ['artboardContainer', { static: true }]
|
|
902
|
+
}], sidebar: [{
|
|
903
|
+
type: ViewChild,
|
|
904
|
+
args: [SidebarComponent, { static: true }]
|
|
905
|
+
}], config: [{
|
|
906
|
+
type: Input
|
|
907
|
+
}], blockAdded: [{
|
|
908
|
+
type: Output
|
|
909
|
+
}], blockRemoved: [{
|
|
910
|
+
type: Output
|
|
927
911
|
}] } });
|
|
928
912
|
|
|
929
|
-
class FsBlockEditorModule {
|
|
930
|
-
static forRoot() {
|
|
931
|
-
return {
|
|
932
|
-
ngModule: FsBlockEditorModule,
|
|
933
|
-
};
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
FsBlockEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
937
|
-
FsBlockEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, declarations: [FsBlockComponent,
|
|
938
|
-
FsBlockEditorComponent,
|
|
939
|
-
FsBlockEditorSidebarPanelDirective,
|
|
940
|
-
FsBlockEditorMarginDirective,
|
|
941
|
-
SidebarComponent], imports: [CommonModule,
|
|
942
|
-
FormsModule,
|
|
943
|
-
MatIconModule,
|
|
944
|
-
MatButtonModule,
|
|
945
|
-
MatInputModule,
|
|
946
|
-
MatFormFieldModule,
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
SidebarComponent,
|
|
988
|
-
],
|
|
989
|
-
}]
|
|
913
|
+
class FsBlockEditorModule {
|
|
914
|
+
static forRoot() {
|
|
915
|
+
return {
|
|
916
|
+
ngModule: FsBlockEditorModule,
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
FsBlockEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
921
|
+
FsBlockEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, declarations: [FsBlockComponent,
|
|
922
|
+
FsBlockEditorComponent,
|
|
923
|
+
FsBlockEditorSidebarPanelDirective,
|
|
924
|
+
FsBlockEditorMarginDirective,
|
|
925
|
+
SidebarComponent], imports: [CommonModule,
|
|
926
|
+
FormsModule,
|
|
927
|
+
MatIconModule,
|
|
928
|
+
MatButtonModule,
|
|
929
|
+
MatInputModule,
|
|
930
|
+
MatFormFieldModule,
|
|
931
|
+
FsFileModule,
|
|
932
|
+
FsColorPickerModule], exports: [FsBlockComponent,
|
|
933
|
+
FsBlockEditorComponent,
|
|
934
|
+
FsBlockEditorSidebarPanelDirective] });
|
|
935
|
+
FsBlockEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, imports: [[
|
|
936
|
+
CommonModule,
|
|
937
|
+
FormsModule,
|
|
938
|
+
MatIconModule,
|
|
939
|
+
MatButtonModule,
|
|
940
|
+
MatInputModule,
|
|
941
|
+
MatFormFieldModule,
|
|
942
|
+
FsFileModule,
|
|
943
|
+
FsColorPickerModule,
|
|
944
|
+
]] });
|
|
945
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorModule, decorators: [{
|
|
946
|
+
type: NgModule,
|
|
947
|
+
args: [{
|
|
948
|
+
imports: [
|
|
949
|
+
CommonModule,
|
|
950
|
+
FormsModule,
|
|
951
|
+
MatIconModule,
|
|
952
|
+
MatButtonModule,
|
|
953
|
+
MatInputModule,
|
|
954
|
+
MatFormFieldModule,
|
|
955
|
+
FsFileModule,
|
|
956
|
+
FsColorPickerModule,
|
|
957
|
+
],
|
|
958
|
+
exports: [
|
|
959
|
+
FsBlockComponent,
|
|
960
|
+
FsBlockEditorComponent,
|
|
961
|
+
FsBlockEditorSidebarPanelDirective,
|
|
962
|
+
],
|
|
963
|
+
declarations: [
|
|
964
|
+
FsBlockComponent,
|
|
965
|
+
FsBlockEditorComponent,
|
|
966
|
+
FsBlockEditorSidebarPanelDirective,
|
|
967
|
+
FsBlockEditorMarginDirective,
|
|
968
|
+
SidebarComponent,
|
|
969
|
+
],
|
|
970
|
+
}]
|
|
990
971
|
}] });
|
|
991
972
|
|
|
992
|
-
/*
|
|
993
|
-
* Public API Surface of fs-menu
|
|
973
|
+
/*
|
|
974
|
+
* Public API Surface of fs-menu
|
|
994
975
|
*/
|
|
995
976
|
|
|
996
|
-
/**
|
|
997
|
-
* Generated bundle index. Do not edit.
|
|
977
|
+
/**
|
|
978
|
+
* Generated bundle index. Do not edit.
|
|
998
979
|
*/
|
|
999
980
|
|
|
1000
981
|
export { FsBlockComponent, FsBlockEditorComponent, FsBlockEditorModule, FsBlockEditorSidebarPanelDirective };
|