@firestitch/block-editor 12.3.20 → 12.3.22
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/services/block-editor.service.d.ts +1 -1
- package/app/services/blocks-store.service.d.ts +1 -1
- package/bundles/firestitch-block-editor.umd.js +19 -12
- package/bundles/firestitch-block-editor.umd.js.map +1 -1
- package/esm2015/app/components/block/block.component.js +3 -2
- package/esm2015/app/components/sidebar/sidebar.component.js +4 -3
- package/esm2015/app/services/block-editor.service.js +2 -2
- package/esm2015/app/services/blocks-store.service.js +16 -11
- package/fesm2015/firestitch-block-editor.js +20 -13
- package/fesm2015/firestitch-block-editor.js.map +1 -1
- package/package.json +1 -1
|
@@ -24,7 +24,7 @@ export declare class BlockEditorService implements OnDestroy {
|
|
|
24
24
|
get selectedComponentBlocks(): FsBlockComponent[];
|
|
25
25
|
init(config: BlockEditorConfig): void;
|
|
26
26
|
blockAdd(block: Block): void;
|
|
27
|
-
blockUpload(block: Block, fsFile: FsFile):
|
|
27
|
+
blockUpload(block: Block, fsFile: FsFile): Observable<Block>;
|
|
28
28
|
blockRemove(block: Block): void;
|
|
29
29
|
removeSelectedBlocks(): void;
|
|
30
30
|
get blocks$(): Observable<Block[]>;
|
|
@@ -19,7 +19,7 @@ export declare class BlocksStore implements OnDestroy {
|
|
|
19
19
|
init(config: BlockEditorConfig): void;
|
|
20
20
|
blockExists(block: Block): boolean;
|
|
21
21
|
blockAdd(block: Block): void;
|
|
22
|
-
blockUpload(block: Block, fsFile: FsFile):
|
|
22
|
+
blockUpload(block: Block, fsFile: FsFile): Observable<Block>;
|
|
23
23
|
blockChange(block: Block): void;
|
|
24
24
|
blockRemove(targetBlocks: Block | Block[]): void;
|
|
25
25
|
isReordableBlock(block: Block): boolean;
|
|
@@ -604,12 +604,13 @@
|
|
|
604
604
|
BlocksStore.prototype.blockUpload = function (block, fsFile) {
|
|
605
605
|
var _this = this;
|
|
606
606
|
if (!this._config.blockUpload) {
|
|
607
|
-
|
|
608
|
-
return;
|
|
607
|
+
return rxjs.throwError('[BlockEditor] Config "blockUpload" is not defined');
|
|
609
608
|
}
|
|
610
609
|
var existing = this.blockExists(block);
|
|
611
|
-
|
|
612
|
-
|
|
610
|
+
if (!existing) {
|
|
611
|
+
block = this._createBlock(block);
|
|
612
|
+
}
|
|
613
|
+
return rxjs.from(fsFile.imageInfo)
|
|
613
614
|
.pipe(operators.switchMap(function (imageInfo) {
|
|
614
615
|
if (!existing && (imageInfo === null || imageInfo === void 0 ? void 0 : imageInfo.height) && (imageInfo === null || imageInfo === void 0 ? void 0 : imageInfo.width)) {
|
|
615
616
|
var ratio = imageInfo.height / imageInfo.width;
|
|
@@ -617,12 +618,16 @@
|
|
|
617
618
|
block.height = block.width * ratio;
|
|
618
619
|
}
|
|
619
620
|
return _this._config.blockUpload(block, fsFile.file);
|
|
620
|
-
}), operators.
|
|
621
|
-
|
|
622
|
-
|
|
621
|
+
}), operators.tap(function (newBlock) {
|
|
622
|
+
if (existing) {
|
|
623
|
+
var blocks = _this._blocks$.getValue();
|
|
624
|
+
blocks[blocks.indexOf(block)] = newBlock;
|
|
625
|
+
_this._setBlocks(blocks);
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
623
628
|
_this._appendBlock(newBlock);
|
|
624
629
|
}
|
|
625
|
-
});
|
|
630
|
+
}), operators.takeUntil(this._destroy$));
|
|
626
631
|
};
|
|
627
632
|
BlocksStore.prototype.blockChange = function (block) {
|
|
628
633
|
this._dispatchEvent(EventType.Change, block);
|
|
@@ -753,7 +758,7 @@
|
|
|
753
758
|
this._store.blockAdd(block);
|
|
754
759
|
};
|
|
755
760
|
BlockEditorService.prototype.blockUpload = function (block, fsFile) {
|
|
756
|
-
this._store.blockUpload(block, fsFile);
|
|
761
|
+
return this._store.blockUpload(block, fsFile);
|
|
757
762
|
};
|
|
758
763
|
BlockEditorService.prototype.blockRemove = function (block) {
|
|
759
764
|
this._store.blockRemove(block);
|
|
@@ -1192,8 +1197,9 @@
|
|
|
1192
1197
|
_this._cdRef.markForCheck();
|
|
1193
1198
|
});
|
|
1194
1199
|
this._blockEditor.blockChanged$
|
|
1195
|
-
.pipe(operators.filter(function (block) { return block === _this.block; }), operators.takeUntil(this._destroy$))
|
|
1200
|
+
.pipe(operators.filter(function (block) { return block.guid === _this.block.guid; }), operators.takeUntil(this._destroy$))
|
|
1196
1201
|
.subscribe(function (block) {
|
|
1202
|
+
_this.block = Object.assign(Object.assign({}, _this.block), block);
|
|
1197
1203
|
_this.keepRatio = block.keepRatio;
|
|
1198
1204
|
_this.rotate = _this.block.rotate;
|
|
1199
1205
|
_this._updateMoveable();
|
|
@@ -1697,8 +1703,9 @@
|
|
|
1697
1703
|
}
|
|
1698
1704
|
};
|
|
1699
1705
|
SidebarComponent.prototype.blockUpload = function (block, fsFile) {
|
|
1700
|
-
this._blockEditor
|
|
1701
|
-
.
|
|
1706
|
+
this._blockEditor.blockUpload(block, fsFile)
|
|
1707
|
+
.subscribe(function (newBlock) {
|
|
1708
|
+
});
|
|
1702
1709
|
};
|
|
1703
1710
|
SidebarComponent.prototype.blockAdd = function (type) {
|
|
1704
1711
|
if (type === exports.BlockType.Pdf || type === exports.BlockType.Image) {
|