@firestitch/block-editor 12.3.22 → 12.3.23
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/artboard/artboard.component.d.ts +4 -4
- package/app/components/block/block.component.d.ts +5 -3
- package/app/components/layers-reorder-dialog/layers-reorder-dialog.component.d.ts +3 -2
- package/app/interfaces/block.d.ts +3 -0
- package/app/services/block-editor.service.d.ts +2 -2
- package/app/services/blocks-store.service.d.ts +2 -0
- package/bundles/firestitch-block-editor.umd.js +151 -122
- package/bundles/firestitch-block-editor.umd.js.map +1 -1
- package/esm2015/app/components/artboard/artboard.component.js +12 -11
- package/esm2015/app/components/block/block.component.js +47 -27
- package/esm2015/app/components/layers-reorder-dialog/layers-reorder-dialog.component.js +6 -6
- package/esm2015/app/components/sidebar/sidebar.component.js +10 -10
- package/esm2015/app/interfaces/block.js +1 -1
- package/esm2015/app/services/block-editor.service.js +14 -24
- package/esm2015/app/services/blocks-store.service.js +10 -4
- package/fesm2015/firestitch-block-editor.js +127 -111
- package/fesm2015/firestitch-block-editor.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i13 from '@angular/common';
|
|
2
2
|
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { Injectable, Component, ChangeDetectionStrategy, Input, Inject, Pipe, ViewChild, HostBinding,
|
|
4
|
+
import { Injectable, Component, ChangeDetectionStrategy, Input, Directive, Inject, Pipe, ViewChild, HostBinding, EventEmitter, ContentChildren, Output, ViewChildren, ElementRef, HostListener, NgModule } from '@angular/core';
|
|
5
5
|
import * as i16 from '@angular/forms';
|
|
6
6
|
import { FormsModule } from '@angular/forms';
|
|
7
7
|
import * as i15 from '@angular/material/input';
|
|
@@ -35,12 +35,12 @@ import * as i10 from '@firestitch/autocomplete';
|
|
|
35
35
|
import { FsAutocompleteModule } from '@firestitch/autocomplete';
|
|
36
36
|
import * as i1 from '@angular/common/http';
|
|
37
37
|
import { throwError, Subject, BehaviorSubject, from, fromEvent } from 'rxjs';
|
|
38
|
-
import { map, filter, groupBy, debounceTime, mergeAll, takeUntil, switchMap, tap, delay } from 'rxjs/operators';
|
|
39
|
-
import
|
|
38
|
+
import { map, filter, groupBy, debounceTime, mergeAll, takeUntil, switchMap, tap, skip, delay } from 'rxjs/operators';
|
|
39
|
+
import { index, guid, round } from '@firestitch/common';
|
|
40
40
|
import * as i1$1 from '@angular/material/dialog';
|
|
41
41
|
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
|
42
|
-
import { index, guid, round } from '@firestitch/common';
|
|
43
42
|
import * as i5 from '@angular/material/divider';
|
|
43
|
+
import Moveable from 'moveable';
|
|
44
44
|
import * as i1$2 from '@firestitch/api';
|
|
45
45
|
import * as i2$1 from '@firestitch/prompt';
|
|
46
46
|
import * as i8 from '@angular/material/core';
|
|
@@ -106,6 +106,42 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
106
106
|
type: Input
|
|
107
107
|
}] } });
|
|
108
108
|
|
|
109
|
+
class FsBlockEditorMarginDirective {
|
|
110
|
+
constructor(_elementRef) {
|
|
111
|
+
this._elementRef = _elementRef;
|
|
112
|
+
}
|
|
113
|
+
get element() {
|
|
114
|
+
return this._elementRef.nativeElement;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
FsBlockEditorMarginDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorMarginDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
118
|
+
FsBlockEditorMarginDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorMarginDirective, selector: "[fsBlockEditorMargin]", ngImport: i0 });
|
|
119
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorMarginDirective, decorators: [{
|
|
120
|
+
type: Directive,
|
|
121
|
+
args: [{
|
|
122
|
+
selector: '[fsBlockEditorMargin]'
|
|
123
|
+
}]
|
|
124
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
|
|
125
|
+
|
|
126
|
+
class FsBlockEditorSidebarPanelDirective {
|
|
127
|
+
constructor(templateRef) {
|
|
128
|
+
this.templateRef = templateRef;
|
|
129
|
+
this.show = true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
FsBlockEditorSidebarPanelDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorSidebarPanelDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
133
|
+
FsBlockEditorSidebarPanelDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorSidebarPanelDirective, selector: "[fsBlockEditorSidebarPanel]", inputs: { label: "label", show: "show" }, ngImport: i0 });
|
|
134
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorSidebarPanelDirective, decorators: [{
|
|
135
|
+
type: Directive,
|
|
136
|
+
args: [{
|
|
137
|
+
selector: '[fsBlockEditorSidebarPanel]'
|
|
138
|
+
}]
|
|
139
|
+
}], ctorParameters: function () { return [{ type: i0.TemplateRef }]; }, propDecorators: { label: [{
|
|
140
|
+
type: Input
|
|
141
|
+
}], show: [{
|
|
142
|
+
type: Input
|
|
143
|
+
}] } });
|
|
144
|
+
|
|
109
145
|
var BlockType;
|
|
110
146
|
(function (BlockType) {
|
|
111
147
|
BlockType["Rectangle"] = "rectangle";
|
|
@@ -146,17 +182,17 @@ class LayersReorderDialogComponent {
|
|
|
146
182
|
this._init(_dialogData);
|
|
147
183
|
}
|
|
148
184
|
swapItems(event) {
|
|
149
|
-
moveItemInArray(this.
|
|
185
|
+
moveItemInArray(this.blocks, event.previousIndex, event.currentIndex);
|
|
150
186
|
}
|
|
151
187
|
done() {
|
|
152
|
-
this._dialogRef.close(this.
|
|
188
|
+
this._dialogRef.close(this.blocks);
|
|
153
189
|
}
|
|
154
190
|
_init(data) {
|
|
155
|
-
this.
|
|
191
|
+
this.blocks = data.blocks;
|
|
156
192
|
}
|
|
157
193
|
}
|
|
158
194
|
LayersReorderDialogComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LayersReorderDialogComponent, deps: [{ token: MAT_DIALOG_DATA }, { token: i1$1.MatDialogRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
159
|
-
LayersReorderDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: LayersReorderDialogComponent, selector: "ng-component", ngImport: i0, template: "<fs-dialog>\n <h1 mat-dialog-title><mat-icon>swap_vert</mat-icon> Reorder
|
|
195
|
+
LayersReorderDialogComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: LayersReorderDialogComponent, selector: "ng-component", ngImport: i0, template: "<fs-dialog>\n <h1 mat-dialog-title><mat-icon>swap_vert</mat-icon> Reorder Blocks</h1>\n <mat-dialog-content>\n <mat-list cdkDropList (cdkDropListDropped)=\"swapItems($event)\">\n <mat-divider></mat-divider>\n <ng-container *ngFor=\"let block of blocks\">\n <mat-list-item cdkDrag cdkDragLockAxis=\"y\">\n <mat-icon cdkDragHandle>drag_handle</mat-icon>\n <mat-icon>\n {{ blockTypeIcons[block.type] }}\n </mat-icon>\n <span class=\"block-label\">\n {{ block.label || block.content || 'No Content'}} \n </span>\n </mat-list-item>\n <mat-divider></mat-divider>\n </ng-container>\n </mat-list>\n </mat-dialog-content>\n <mat-dialog-actions>\n <button mat-button color=\"primary\" (click)=\"done()\">Done</button>\n </mat-dialog-actions>\n</fs-dialog>\n", styles: ["h1{display:flex}.mat-icon{margin-right:20px}.block-label{min-width:200px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:1000px}.cdk-drag-preview{display:flex;padding-left:15px!important;background:#fff;box-shadow:0 5px 5px -3px #0003,0 8px 10px 1px #00000024,0 3px 14px 2px #0000001f}.cdk-drag-preview ::ng-deep .mat-list-item-content{display:flex;flex-direction:row;align-items:center;font-size:16px}.cdk-drag-handle{cursor:grab}.cdk-drag-placeholder{opacity:.2}\n"], components: [{ type: i2.FsDialogComponent, selector: "fs-dialog", inputs: ["mobileMode"] }, { type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i4.MatList, selector: "mat-list, mat-action-list", inputs: ["disableRipple", "disabled"], exportAs: ["matList"] }, { type: i5.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { type: i4.MatListItem, selector: "mat-list-item, a[mat-list-item], button[mat-list-item]", inputs: ["disableRipple", "disabled"], exportAs: ["matListItem"] }, { type: i6.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i1$1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { type: i1$1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { type: i7.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "id", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListAutoScrollDisabled", "cdkDropListOrientation", "cdkDropListLockAxis", "cdkDropListData", "cdkDropListAutoScrollStep"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { type: i13.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragDisabled", "cdkDragStartDelay", "cdkDragLockAxis", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragBoundary", "cdkDragRootElement", "cdkDragPreviewContainer", "cdkDragData", "cdkDragFreeDragPosition"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { type: i7.CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }, { type: i1$1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
160
196
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LayersReorderDialogComponent, decorators: [{
|
|
161
197
|
type: Component,
|
|
162
198
|
args: [{
|
|
@@ -174,6 +210,7 @@ var EventType;
|
|
|
174
210
|
EventType["Add"] = "add";
|
|
175
211
|
EventType["Change"] = "change";
|
|
176
212
|
EventType["Remove"] = "remove";
|
|
213
|
+
EventType["Update"] = "update";
|
|
177
214
|
})(EventType || (EventType = {}));
|
|
178
215
|
class BlocksStore {
|
|
179
216
|
constructor() {
|
|
@@ -198,6 +235,10 @@ class BlocksStore {
|
|
|
198
235
|
return this._eventBus$
|
|
199
236
|
.pipe(filter(({ type }) => type === EventType.Change), map(({ value }) => value));
|
|
200
237
|
}
|
|
238
|
+
get blockUpdated$() {
|
|
239
|
+
return this._eventBus$
|
|
240
|
+
.pipe(filter(({ type }) => type === EventType.Update), map(({ value }) => value));
|
|
241
|
+
}
|
|
201
242
|
get blockRemoved$() {
|
|
202
243
|
return this._eventBus$
|
|
203
244
|
.pipe(filter(({ type }) => type === EventType.Remove), map(({ value }) => value));
|
|
@@ -253,9 +294,7 @@ class BlocksStore {
|
|
|
253
294
|
return this._config.blockUpload(block, fsFile.file);
|
|
254
295
|
}), tap((newBlock) => {
|
|
255
296
|
if (existing) {
|
|
256
|
-
|
|
257
|
-
blocks[blocks.indexOf(block)] = newBlock;
|
|
258
|
-
this._setBlocks(blocks);
|
|
297
|
+
this.blockUpdate(Object.assign(Object.assign({}, block), newBlock));
|
|
259
298
|
}
|
|
260
299
|
else {
|
|
261
300
|
this._appendBlock(newBlock);
|
|
@@ -265,6 +304,9 @@ class BlocksStore {
|
|
|
265
304
|
blockChange(block) {
|
|
266
305
|
this._dispatchEvent(EventType.Change, block);
|
|
267
306
|
}
|
|
307
|
+
blockUpdate(block) {
|
|
308
|
+
this._dispatchEvent(EventType.Update, block);
|
|
309
|
+
}
|
|
268
310
|
blockRemove(targetBlocks) {
|
|
269
311
|
const blocks = this.blocks;
|
|
270
312
|
if (!Array.isArray(targetBlocks)) {
|
|
@@ -369,10 +411,6 @@ class BlockEditorService {
|
|
|
369
411
|
get blockComponents() {
|
|
370
412
|
return Array.from(this._blockComponents.values());
|
|
371
413
|
}
|
|
372
|
-
get selectedComponentBlocks() {
|
|
373
|
-
return this.blockComponents
|
|
374
|
-
.filter((blockComponent) => this.selectedBlocks.indexOf(blockComponent.block) !== -1);
|
|
375
|
-
}
|
|
376
414
|
init(config) {
|
|
377
415
|
this.config = config;
|
|
378
416
|
this._store.init(Object.assign({}, this.config));
|
|
@@ -399,6 +437,9 @@ class BlockEditorService {
|
|
|
399
437
|
get blockChanged$() {
|
|
400
438
|
return this._store.blockChanged$;
|
|
401
439
|
}
|
|
440
|
+
get blockUpdated$() {
|
|
441
|
+
return this._store.blockUpdated$;
|
|
442
|
+
}
|
|
402
443
|
get blockClippable$() {
|
|
403
444
|
return this._blockClippable$;
|
|
404
445
|
}
|
|
@@ -421,7 +462,7 @@ class BlockEditorService {
|
|
|
421
462
|
this._store.blockChange(block);
|
|
422
463
|
}
|
|
423
464
|
isSelectedBlock(block) {
|
|
424
|
-
return this.selectedBlocks.indexOf(block
|
|
465
|
+
return this.selectedBlocks.indexOf(block) !== -1;
|
|
425
466
|
}
|
|
426
467
|
indexOf(block) {
|
|
427
468
|
return this.blocks.map((e) => e.guid).indexOf(block.guid);
|
|
@@ -440,15 +481,6 @@ class BlockEditorService {
|
|
|
440
481
|
this.selectedBlocks = [block];
|
|
441
482
|
}
|
|
442
483
|
set selectedBlocks(blocks) {
|
|
443
|
-
this.blockComponents
|
|
444
|
-
.forEach((blockComponent) => {
|
|
445
|
-
if (blocks.indexOf(blockComponent.block) !== -1) {
|
|
446
|
-
blockComponent.select();
|
|
447
|
-
}
|
|
448
|
-
else {
|
|
449
|
-
blockComponent.deselect();
|
|
450
|
-
}
|
|
451
|
-
});
|
|
452
484
|
this._selectedBlocks$.next(blocks);
|
|
453
485
|
if (this.config.blocksSelected) {
|
|
454
486
|
this.config.blocksSelected(blocks);
|
|
@@ -485,23 +517,23 @@ class BlockEditorService {
|
|
|
485
517
|
this.margin = margin;
|
|
486
518
|
}
|
|
487
519
|
openReorderDialog() {
|
|
488
|
-
const
|
|
489
|
-
.sort((
|
|
520
|
+
const blocks = this.blocks
|
|
521
|
+
.sort((blockA, blockB) => (blockA.index - blockB.index))
|
|
490
522
|
.reverse();
|
|
491
523
|
this._dialog
|
|
492
524
|
.open(LayersReorderDialogComponent, {
|
|
493
525
|
data: {
|
|
494
|
-
|
|
526
|
+
blocks,
|
|
495
527
|
}
|
|
496
528
|
})
|
|
497
529
|
.afterClosed()
|
|
498
|
-
.pipe(filter((
|
|
499
|
-
.subscribe((
|
|
500
|
-
|
|
530
|
+
.pipe(filter((blocks) => !!blocks), takeUntil(this._destroy$))
|
|
531
|
+
.subscribe((blocks) => {
|
|
532
|
+
blocks
|
|
501
533
|
.reverse()
|
|
502
|
-
.forEach((
|
|
503
|
-
|
|
504
|
-
this._store.blockChange(
|
|
534
|
+
.forEach((block, index) => {
|
|
535
|
+
block.index = index;
|
|
536
|
+
this._store.blockChange(block);
|
|
505
537
|
this._store.updateTabIndex(index);
|
|
506
538
|
});
|
|
507
539
|
});
|
|
@@ -544,12 +576,28 @@ class FsBlockComponent {
|
|
|
544
576
|
this._transformable = false;
|
|
545
577
|
this._destroy$ = new Subject();
|
|
546
578
|
}
|
|
579
|
+
set block(block) {
|
|
580
|
+
this._block = block;
|
|
581
|
+
this._block.resizable = !this.hasType([BlockType.Checkbox, BlockType.RadioButton]);
|
|
582
|
+
this._block.rotatable = !this.hasType([BlockType.Checkbox, BlockType.RadioButton]);
|
|
583
|
+
this._block.scalable = !this.hasType([BlockType.Checkbox, BlockType.RadioButton]);
|
|
584
|
+
if (this.moveable) {
|
|
585
|
+
this._updateMoveable();
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
;
|
|
589
|
+
get block() {
|
|
590
|
+
return this._block;
|
|
591
|
+
}
|
|
547
592
|
get el() {
|
|
548
593
|
return this.element.nativeElement;
|
|
549
594
|
}
|
|
550
595
|
get moveable() {
|
|
551
596
|
return this._moveable;
|
|
552
597
|
}
|
|
598
|
+
hasType(types) {
|
|
599
|
+
return types.includes(this.block.type);
|
|
600
|
+
}
|
|
553
601
|
get editable() {
|
|
554
602
|
return this._editable;
|
|
555
603
|
}
|
|
@@ -650,13 +698,8 @@ class FsBlockComponent {
|
|
|
650
698
|
return this._transformable;
|
|
651
699
|
}
|
|
652
700
|
set transformable(value) {
|
|
653
|
-
if (this.block.lock) {
|
|
654
|
-
value = false;
|
|
655
|
-
}
|
|
656
701
|
this._transformable = value;
|
|
657
|
-
this.
|
|
658
|
-
this.moveable.rotatable = value;
|
|
659
|
-
this.moveable.scalable = value;
|
|
702
|
+
this._updateMoveable();
|
|
660
703
|
}
|
|
661
704
|
set rotate(value) {
|
|
662
705
|
this.moveable.request('rotatable', { rotate: parseFloat(value) }, true);
|
|
@@ -677,9 +720,10 @@ class FsBlockComponent {
|
|
|
677
720
|
this.block.shadowOpacity = this.block.shadowOpacity || 100;
|
|
678
721
|
this._initFonts();
|
|
679
722
|
this._blockEditor.selectedBlocks$
|
|
680
|
-
.pipe(takeUntil(this._destroy$))
|
|
723
|
+
.pipe(skip(1), takeUntil(this._destroy$))
|
|
681
724
|
.subscribe((blocks) => {
|
|
682
725
|
this.selected = blocks.includes(this.block);
|
|
726
|
+
this.transformable = true;
|
|
683
727
|
this._cdRef.markForCheck();
|
|
684
728
|
});
|
|
685
729
|
this._blockEditor.blockClippable$
|
|
@@ -693,13 +737,16 @@ class FsBlockComponent {
|
|
|
693
737
|
.subscribe(() => {
|
|
694
738
|
this._cdRef.markForCheck();
|
|
695
739
|
});
|
|
740
|
+
this._blockEditor.blockUpdated$
|
|
741
|
+
.pipe(filter((block) => block.guid === this.block.guid), takeUntil(this._destroy$))
|
|
742
|
+
.subscribe((block) => {
|
|
743
|
+
this.block = block;
|
|
744
|
+
this._cdRef.markForCheck();
|
|
745
|
+
});
|
|
696
746
|
this._blockEditor.blockChanged$
|
|
697
747
|
.pipe(filter((block) => block.guid === this.block.guid), takeUntil(this._destroy$))
|
|
698
748
|
.subscribe((block) => {
|
|
699
|
-
this.block =
|
|
700
|
-
this.keepRatio = block.keepRatio;
|
|
701
|
-
this.rotate = this.block.rotate;
|
|
702
|
-
this._updateMoveable();
|
|
749
|
+
this.block = block;
|
|
703
750
|
this._cdRef.markForCheck();
|
|
704
751
|
});
|
|
705
752
|
}
|
|
@@ -723,9 +770,6 @@ class FsBlockComponent {
|
|
|
723
770
|
round(value, decimals) {
|
|
724
771
|
return parseFloat(value.toFixed(decimals));
|
|
725
772
|
}
|
|
726
|
-
select() {
|
|
727
|
-
this.transformable = true;
|
|
728
|
-
}
|
|
729
773
|
deselect() {
|
|
730
774
|
this.editable = false;
|
|
731
775
|
this.clippable = false;
|
|
@@ -745,7 +789,7 @@ class FsBlockComponent {
|
|
|
745
789
|
}
|
|
746
790
|
}
|
|
747
791
|
}
|
|
748
|
-
|
|
792
|
+
selectTextAll() {
|
|
749
793
|
const range = document.createRange();
|
|
750
794
|
range.selectNodeContents(this.contentEditable.nativeElement);
|
|
751
795
|
const sel = window.getSelection();
|
|
@@ -770,11 +814,12 @@ class FsBlockComponent {
|
|
|
770
814
|
.filter((el) => !el.isSameNode(this.el));
|
|
771
815
|
}
|
|
772
816
|
_updateMoveable() {
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
817
|
+
const value = !this.block.lock && this.selected;
|
|
818
|
+
this.keepRatio = this.block.keepRatio;
|
|
819
|
+
this.rotate = this.block.rotate;
|
|
820
|
+
this.moveable.resizable = this.block.resizable && value;
|
|
821
|
+
this.moveable.rotatable = this.block.rotatable && value;
|
|
822
|
+
this.moveable.scalable = this.block.scalable && value;
|
|
778
823
|
}
|
|
779
824
|
_initMoveable() {
|
|
780
825
|
this._moveable = new Moveable(this._elementRef.nativeElement, {
|
|
@@ -928,8 +973,14 @@ class FsBlockComponent {
|
|
|
928
973
|
this._triggerChanged();
|
|
929
974
|
});
|
|
930
975
|
fromEvent(this.el, 'mousedown')
|
|
931
|
-
.pipe(takeUntil(this._destroy$))
|
|
932
|
-
|
|
976
|
+
.pipe(takeUntil(this._destroy$))
|
|
977
|
+
.subscribe((event) => {
|
|
978
|
+
if (this.block.lock) {
|
|
979
|
+
event.preventDefault();
|
|
980
|
+
event.stopImmediatePropagation();
|
|
981
|
+
event.stopPropagation();
|
|
982
|
+
}
|
|
983
|
+
else {
|
|
933
984
|
this.zoompan.disable();
|
|
934
985
|
}
|
|
935
986
|
if (!this.moveable.clippable) {
|
|
@@ -959,7 +1010,7 @@ class FsBlockComponent {
|
|
|
959
1010
|
this.editable = true;
|
|
960
1011
|
this._cdRef.markForCheck();
|
|
961
1012
|
setTimeout(() => {
|
|
962
|
-
this.
|
|
1013
|
+
this.selectTextAll();
|
|
963
1014
|
});
|
|
964
1015
|
}
|
|
965
1016
|
});
|
|
@@ -971,7 +1022,7 @@ class FsBlockComponent {
|
|
|
971
1022
|
}
|
|
972
1023
|
}
|
|
973
1024
|
FsBlockComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockComponent, deps: [{ token: BlockEditorService }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: GoogleFontService }], target: i0.ɵɵFactoryTarget.Component });
|
|
974
|
-
FsBlockComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockComponent, selector: "fs-block", inputs: { block: "block", html: "html", zoompan: "zoompan" }, host: { properties: { "class.transforming": "this.transformating" } }, viewQueries: [{ propertyName: "element", first: true, predicate: ["element"], descendants: true, static: true }, { propertyName: "contentElement", first: true, predicate: ["contentElement"], descendants: true, static: true }, { propertyName: "contentEditable", first: true, predicate: ["contentEditable"], descendants: true, static: true }], ngImport: i0, template: "<div\n #element\n [class]=\"'block ' + 'block-' + block.type\"\n [style.top]=\"styleTop\"\n [style.left]=\"styleLeft\"\n [style.width]=\"styleWidth\"\n [style.height]=\"styleHeight\"\n [ngClass]=\"{ \n editable: editable, \n readonly: block.readonly,\n required: block.required,\n lock: block.lock,\n selected: selected\n }\"\n [style.zIndex]=\"block.index\">\n <div\n #contentElement\n class=\"content\"\n [style.borderColor]=\"block.borderColor\"\n [style.borderWidth]=\"block.borderWidth ? block.borderWidth + 'pt' : ''\"\n [style.borderStyle]=\"block.borderColor ? 'solid' : 'dashed'\"\n [style.textAlign]=\"block.horizontalAlign\"\n [style.fontStyle]=\"block.italic ? 'italic' : ''\"\n [style.fontFamily]=\"block.fontFamily || ''\"\n [style.fontSize]=\"block.fontSize ? block.fontSize + 'pt' : ''\"\n [style.lineHeight]=\"block.lineHeight ? block.lineHeight + 'pt' : ''\"\n [style.color]=\"block.fontColor\"\n [style.fontWeight]=\"block.bold ? 'bold' : ''\"\n [style.textDecoration]=\"block.underline ? 'underline' : ''\"\n [style.paddingTop]=\"block.paddingTop ? block.paddingTop + 'in' : ''\"\n [style.paddingBottom]=\"block.paddingBottom ? block.paddingBottom + 'in' : ''\"\n [style.paddingLeft]=\"block.paddingLeft ? block.paddingLeft + 'in' : ''\"\n [style.paddingRight]=\"block.paddingRight ? block.paddingRight + 'in' : ''\"\n [style.backgroundColor]=\"block.backgroundColor\"\n [style.borderBottomLeftRadius]=\"block.shapeRadius && block.shapeBottomLeft === 'round' ? block.shapeRadius + '%' : ''\"\n [style.borderBottomRightRadius]=\"block.shapeRadius && block.shapeBottomRight === 'round' ? block.shapeRadius + '%' : ''\"\n [style.borderTopRightRadius]=\"block.shapeRadius && block.shapeTopRight === 'round' ? block.shapeRadius + '%' : ''\"\n [style.borderTopLeftRadius]=\"block.shapeRadius && block.shapeTopLeft === 'round' ? block.shapeRadius + '%' : ''\"\n [style.boxShadow]=\"styleBoxShadow\"\n [ngClass]=\"{\n 'editable': editable,\n 'vertical-align-center': block.verticalAlign === 'center',\n 'vertical-align-bottom': block.verticalAlign === 'bottom'\n }\">\n <ng-container [ngSwitch]=\"block.type\">\n <ng-container *ngIf=\"block.imageUrl && ((block.imageUrl | createImageUrl) | async) as src\">\n <img \n [style.opacity]=\"block.imageOpacity ? block.imageOpacity/100 : 1\"\n [src]=\"src\">\n </ng-container>\n\n </ng-container>\n <ng-container *ngIf=\"block.type === BlockType.LongText || block.type === BlockType.ShortText || block.type === BlockType.RadioButton || block.type === BlockType.Checkbox || block.type === BlockType.Date\">\n {{block.label || block.name}}\n </ng-container>\n <div\n #contentEditable\n [contentEditable]=\"editable\"\n class=\"content-editable\"\n [innerHTML]=\"content\">\n </div>\n </div>\n <div class=\"outline\"></div>\n</div>\n", styles: [":host ::ng-deep .moveable-control{width:10px!important;height:10px!important;margin-top:-5px!important;margin-left:-5px!important}:host.transforming ::ng-deep .moveable-control,:host.transforming ::ng-deep .moveable-rotation{display:none}.block{position:absolute;display:block;outline:none;-webkit-user-select:none;user-select:none;cursor:pointer;box-sizing:border-box}.block.selected{border-color:#31a2ff95}.block.block-shorttext,.block.block-longtext,.block.block-date,.block.block-radiobutton,.block.block-signature,.block.block-checkbox{background-color:#aab5e1cc;color:#585555;font-size:12px}.block.block-radiobutton{border-radius:50%}.block.required{background-color:#f7adaa}.block .content-editable{outline:none;position:relative;
|
|
1025
|
+
FsBlockComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockComponent, selector: "fs-block", inputs: { block: "block", html: "html", zoompan: "zoompan" }, host: { properties: { "class.transforming": "this.transformating" } }, viewQueries: [{ propertyName: "element", first: true, predicate: ["element"], descendants: true, static: true }, { propertyName: "contentElement", first: true, predicate: ["contentElement"], descendants: true, static: true }, { propertyName: "contentEditable", first: true, predicate: ["contentEditable"], descendants: true, static: true }], ngImport: i0, template: "<div\n #element\n [class]=\"'block ' + 'block-' + block.type\"\n [style.top]=\"styleTop\"\n [style.left]=\"styleLeft\"\n [style.width]=\"styleWidth\"\n [style.height]=\"styleHeight\"\n [ngClass]=\"{ \n editable: editable, \n readonly: block.readonly,\n required: block.required,\n lock: block.lock,\n selected: selected\n }\"\n [style.zIndex]=\"block.index\">\n <div\n #contentElement\n class=\"content\"\n [style.borderColor]=\"block.borderColor\"\n [style.borderWidth]=\"block.borderWidth ? block.borderWidth + 'pt' : ''\"\n [style.borderStyle]=\"block.borderColor ? 'solid' : 'dashed'\"\n [style.textAlign]=\"block.horizontalAlign\"\n [style.fontStyle]=\"block.italic ? 'italic' : ''\"\n [style.fontFamily]=\"block.fontFamily || ''\"\n [style.fontSize]=\"block.fontSize ? block.fontSize + 'pt' : ''\"\n [style.lineHeight]=\"block.lineHeight ? block.lineHeight + 'pt' : ''\"\n [style.color]=\"block.fontColor\"\n [style.fontWeight]=\"block.bold ? 'bold' : ''\"\n [style.textDecoration]=\"block.underline ? 'underline' : ''\"\n [style.paddingTop]=\"block.paddingTop ? block.paddingTop + 'in' : ''\"\n [style.paddingBottom]=\"block.paddingBottom ? block.paddingBottom + 'in' : ''\"\n [style.paddingLeft]=\"block.paddingLeft ? block.paddingLeft + 'in' : ''\"\n [style.paddingRight]=\"block.paddingRight ? block.paddingRight + 'in' : ''\"\n [style.backgroundColor]=\"block.backgroundColor\"\n [style.borderBottomLeftRadius]=\"block.shapeRadius && block.shapeBottomLeft === 'round' ? block.shapeRadius + '%' : ''\"\n [style.borderBottomRightRadius]=\"block.shapeRadius && block.shapeBottomRight === 'round' ? block.shapeRadius + '%' : ''\"\n [style.borderTopRightRadius]=\"block.shapeRadius && block.shapeTopRight === 'round' ? block.shapeRadius + '%' : ''\"\n [style.borderTopLeftRadius]=\"block.shapeRadius && block.shapeTopLeft === 'round' ? block.shapeRadius + '%' : ''\"\n [style.boxShadow]=\"styleBoxShadow\"\n [ngClass]=\"{\n 'editable': editable,\n 'vertical-align-center': block.verticalAlign === 'center',\n 'vertical-align-bottom': block.verticalAlign === 'bottom'\n }\">\n <ng-container [ngSwitch]=\"block.type\">\n <ng-container *ngIf=\"block.imageUrl && ((block.imageUrl | createImageUrl) | async) as src\">\n <img \n [style.opacity]=\"block.imageOpacity ? block.imageOpacity/100 : 1\"\n [src]=\"src\">\n </ng-container>\n\n </ng-container>\n <ng-container *ngIf=\"block.type === BlockType.LongText || block.type === BlockType.ShortText || block.type === BlockType.RadioButton || block.type === BlockType.Checkbox || block.type === BlockType.Date\">\n {{block.label || block.name}}\n </ng-container>\n <div\n #contentEditable\n [contentEditable]=\"editable\"\n class=\"content-editable\"\n [innerHTML]=\"content\">\n </div>\n </div>\n <div class=\"outline\"></div>\n</div>\n", styles: [":host ::ng-deep .moveable-control{width:10px!important;height:10px!important;margin-top:-5px!important;margin-left:-5px!important}:host.transforming ::ng-deep .moveable-control,:host.transforming ::ng-deep .moveable-rotation{display:none}.block{position:absolute;display:block;outline:none;-webkit-user-select:none;user-select:none;cursor:pointer;box-sizing:border-box}.block.selected{border-color:#31a2ff95}.block.block-shorttext,.block.block-longtext,.block.block-date,.block.block-radiobutton,.block.block-signature,.block.block-checkbox{background-color:#aab5e1cc;color:#585555;font-size:12px}.block.block-radiobutton{border-radius:50%}.block.required{background-color:#f7adaa}.block .content-editable{outline:none;position:relative;height:100%;width:100%;z-index:100}.block.editable .content-editable{cursor:text}.block .content{flex-direction:column;height:100%;display:flex;border:0px solid transparent;position:relative;box-sizing:border-box;overflow:hidden}.block .content fs-html-editor{width:100%}.block .content.vertical-align-center{justify-content:center}.block .content.vertical-align-bottom{justify-content:flex-end}.block .content img{width:100%;height:100%;position:absolute}.block.selected .outline,.block:hover .outline{border:1px solid rgba(68,170,255,.7);position:absolute;top:0;left:0;bottom:0;right:0;-webkit-user-select:none;user-select:none}.block.selected.lock .outline,.block:hover.lock .outline{border-color:#e4181866;border-style:dashed}:host ::ng-deep fs-html-editor .bottom-line,:host ::ng-deep fs-html-editor .fr-toolbar{display:none!important}:host ::ng-deep fs-html-editor .fr-wrapper{background:none!important;border:none!important}:host ::ng-deep .moveable-line:not(.moveable-rotation-line):not(.moveable-guideline){background:transparent!important}\n"], directives: [{ type: i13.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i13.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i13.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i13.AsyncPipe, "createImageUrl": CreateImageUrlPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
975
1026
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockComponent, decorators: [{
|
|
976
1027
|
type: Component,
|
|
977
1028
|
args: [{
|
|
@@ -990,7 +1041,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
990
1041
|
type: ViewChild,
|
|
991
1042
|
args: ['contentEditable', { static: true }]
|
|
992
1043
|
}], block: [{
|
|
993
|
-
type: Input
|
|
1044
|
+
type: Input,
|
|
1045
|
+
args: ['block']
|
|
994
1046
|
}], html: [{
|
|
995
1047
|
type: Input
|
|
996
1048
|
}], zoompan: [{
|
|
@@ -1000,42 +1052,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
1000
1052
|
args: ['class.transforming']
|
|
1001
1053
|
}] } });
|
|
1002
1054
|
|
|
1003
|
-
class FsBlockEditorSidebarPanelDirective {
|
|
1004
|
-
constructor(templateRef) {
|
|
1005
|
-
this.templateRef = templateRef;
|
|
1006
|
-
this.show = true;
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
FsBlockEditorSidebarPanelDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorSidebarPanelDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1010
|
-
FsBlockEditorSidebarPanelDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorSidebarPanelDirective, selector: "[fsBlockEditorSidebarPanel]", inputs: { label: "label", show: "show" }, ngImport: i0 });
|
|
1011
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorSidebarPanelDirective, decorators: [{
|
|
1012
|
-
type: Directive,
|
|
1013
|
-
args: [{
|
|
1014
|
-
selector: '[fsBlockEditorSidebarPanel]'
|
|
1015
|
-
}]
|
|
1016
|
-
}], ctorParameters: function () { return [{ type: i0.TemplateRef }]; }, propDecorators: { label: [{
|
|
1017
|
-
type: Input
|
|
1018
|
-
}], show: [{
|
|
1019
|
-
type: Input
|
|
1020
|
-
}] } });
|
|
1021
|
-
|
|
1022
|
-
class FsBlockEditorMarginDirective {
|
|
1023
|
-
constructor(_elementRef) {
|
|
1024
|
-
this._elementRef = _elementRef;
|
|
1025
|
-
}
|
|
1026
|
-
get element() {
|
|
1027
|
-
return this._elementRef.nativeElement;
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
FsBlockEditorMarginDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorMarginDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1031
|
-
FsBlockEditorMarginDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FsBlockEditorMarginDirective, selector: "[fsBlockEditorMargin]", ngImport: i0 });
|
|
1032
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FsBlockEditorMarginDirective, decorators: [{
|
|
1033
|
-
type: Directive,
|
|
1034
|
-
args: [{
|
|
1035
|
-
selector: '[fsBlockEditorMargin]'
|
|
1036
|
-
}]
|
|
1037
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
|
|
1038
|
-
|
|
1039
1055
|
const BlockFormats = [
|
|
1040
1056
|
{ value: BlockFormat.Number, name: 'Number', blockTypes: [BlockType.ShortText, BlockType.LongText] },
|
|
1041
1057
|
{ value: BlockFormat.Currency, name: 'Currency', blockTypes: [BlockType.ShortText, BlockType.LongText] },
|
|
@@ -1190,20 +1206,20 @@ class SidebarComponent {
|
|
|
1190
1206
|
this._blockEditor.blockAdd(block);
|
|
1191
1207
|
}
|
|
1192
1208
|
layerMove(direction) {
|
|
1193
|
-
this._blockEditor.
|
|
1194
|
-
if (this._blockEditor.isSelectedBlock(
|
|
1195
|
-
|
|
1209
|
+
this._blockEditor.blocks.forEach((block) => {
|
|
1210
|
+
if (this._blockEditor.isSelectedBlock(block)) {
|
|
1211
|
+
block.index += (999 * direction);
|
|
1196
1212
|
}
|
|
1197
1213
|
});
|
|
1198
|
-
const sorted = this._blockEditor.
|
|
1199
|
-
return a.
|
|
1214
|
+
const sorted = this._blockEditor.blocks.sort((a, b) => {
|
|
1215
|
+
return a.index > b.index ? 1 : -1;
|
|
1200
1216
|
});
|
|
1201
|
-
sorted.forEach((
|
|
1202
|
-
|
|
1203
|
-
|
|
1217
|
+
sorted.forEach((block, index) => {
|
|
1218
|
+
block.index = index;
|
|
1219
|
+
this._blockEditor.blockChange(block);
|
|
1204
1220
|
});
|
|
1205
1221
|
if (this.config.blocksLevelChanged) {
|
|
1206
|
-
this.config.blocksLevelChanged(sorted.map((
|
|
1222
|
+
this.config.blocksLevelChanged(sorted.map((block) => block));
|
|
1207
1223
|
}
|
|
1208
1224
|
}
|
|
1209
1225
|
layerUp() {
|
|
@@ -1295,23 +1311,23 @@ class ArtboardComponent {
|
|
|
1295
1311
|
.subscribe((event) => {
|
|
1296
1312
|
event.preventDefault();
|
|
1297
1313
|
const inchPixel = 1 / 100;
|
|
1298
|
-
this._blockEditor.
|
|
1299
|
-
.forEach((
|
|
1314
|
+
this._blockEditor.selectedBlocks
|
|
1315
|
+
.forEach((block) => {
|
|
1300
1316
|
switch (event.key) {
|
|
1301
1317
|
case 'ArrowUp':
|
|
1302
|
-
|
|
1318
|
+
block.top = round(block.top - inchPixel, 2);
|
|
1303
1319
|
break;
|
|
1304
1320
|
case 'ArrowDown':
|
|
1305
|
-
|
|
1321
|
+
block.top = round(block.top + inchPixel, 2);
|
|
1306
1322
|
break;
|
|
1307
1323
|
case 'ArrowLeft':
|
|
1308
|
-
|
|
1324
|
+
block.left = round(block.left - inchPixel, 2);
|
|
1309
1325
|
break;
|
|
1310
1326
|
case 'ArrowRight':
|
|
1311
|
-
|
|
1327
|
+
block.left = round(block.left + inchPixel, 2);
|
|
1312
1328
|
break;
|
|
1313
1329
|
}
|
|
1314
|
-
this._blockEditor.blockChange(
|
|
1330
|
+
this._blockEditor.blockChange(block);
|
|
1315
1331
|
});
|
|
1316
1332
|
});
|
|
1317
1333
|
}
|