@acorex/components 20.2.42 → 20.2.44
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/fesm2022/acorex-components-image-editor.mjs +37 -28
- package/fesm2022/acorex-components-image-editor.mjs.map +1 -1
- package/fesm2022/acorex-components-number-box.mjs +24 -10
- package/fesm2022/acorex-components-number-box.mjs.map +1 -1
- package/fesm2022/acorex-components-tabs.mjs +8 -4
- package/fesm2022/acorex-components-tabs.mjs.map +1 -1
- package/image-editor/index.d.ts +3 -8
- package/number-box/index.d.ts +2 -1
- package/package.json +7 -7
|
@@ -206,6 +206,7 @@ class AXImageEditorCropperWindowComponent {
|
|
|
206
206
|
this.prevY = signal(0, ...(ngDevMode ? [{ debugName: "prevY" }] : []));
|
|
207
207
|
this.aspectWidth = signal(0, ...(ngDevMode ? [{ debugName: "aspectWidth" }] : []));
|
|
208
208
|
this.aspectHeight = signal(0, ...(ngDevMode ? [{ debugName: "aspectHeight" }] : []));
|
|
209
|
+
this.isMousePressed = signal(false, ...(ngDevMode ? [{ debugName: "isMousePressed" }] : []));
|
|
209
210
|
this.renderer = inject(Renderer2);
|
|
210
211
|
this.platformID = inject(PLATFORM_ID);
|
|
211
212
|
this.#eff = effect(() => {
|
|
@@ -299,6 +300,7 @@ class AXImageEditorCropperWindowComponent {
|
|
|
299
300
|
this.prevY.set(currentY);
|
|
300
301
|
}
|
|
301
302
|
panDown(e) {
|
|
303
|
+
this.isMousePressed.set(true);
|
|
302
304
|
if (this.selectedHandle())
|
|
303
305
|
return;
|
|
304
306
|
this.panState.set(true);
|
|
@@ -306,6 +308,7 @@ class AXImageEditorCropperWindowComponent {
|
|
|
306
308
|
this.prevY.set(e.clientY);
|
|
307
309
|
}
|
|
308
310
|
panUp() {
|
|
311
|
+
this.isMousePressed.set(false);
|
|
309
312
|
if (this.selectedHandle())
|
|
310
313
|
return;
|
|
311
314
|
this.panState.set(false);
|
|
@@ -330,6 +333,8 @@ class AXImageEditorCropperWindowComponent {
|
|
|
330
333
|
this.selectedHandle.set(value);
|
|
331
334
|
}
|
|
332
335
|
changeSizeHandler(e) {
|
|
336
|
+
if (!this.isMousePressed())
|
|
337
|
+
return;
|
|
333
338
|
if (this.panState())
|
|
334
339
|
return;
|
|
335
340
|
if (!this.selectedHandle())
|
|
@@ -473,7 +478,6 @@ class AXImageEditorViewComponent extends MXBaseComponent {
|
|
|
473
478
|
this.canvasElem().nativeElement.width = imageHeight;
|
|
474
479
|
this.canvasElem().nativeElement.height = imageHeight;
|
|
475
480
|
}
|
|
476
|
-
this.canvasElem().nativeElement.style.width = '100%';
|
|
477
481
|
requestAnimationFrame(() => {
|
|
478
482
|
//recalculate width after canvas size change
|
|
479
483
|
const recalculateWidth = this.canvasElem().nativeElement.getClientRects()[0]?.width;
|
|
@@ -653,6 +657,7 @@ class AXImageEditorViewComponent extends MXBaseComponent {
|
|
|
653
657
|
const cropImage = this.canvasElem().nativeElement.toDataURL('image/jpeg', 1);
|
|
654
658
|
this.setInitialImage(cropImage, false);
|
|
655
659
|
this.service.activeToolState.set(null);
|
|
660
|
+
this.saveImageChange();
|
|
656
661
|
}
|
|
657
662
|
/** @ignore */
|
|
658
663
|
rotateImage() {
|
|
@@ -679,23 +684,31 @@ class AXImageEditorViewComponent extends MXBaseComponent {
|
|
|
679
684
|
});
|
|
680
685
|
}
|
|
681
686
|
/** @ignore */
|
|
682
|
-
saveImageChange() {
|
|
687
|
+
async saveImageChange() {
|
|
688
|
+
const canvas = this.canvasElem().nativeElement;
|
|
683
689
|
const newImage = new Image();
|
|
684
690
|
newImage.crossOrigin = 'anonymous';
|
|
685
|
-
newImage.src =
|
|
691
|
+
newImage.src = canvas.toDataURL('image/jpeg', 1);
|
|
686
692
|
this.service.newImage = newImage;
|
|
687
693
|
this.imageEditorHistory.update((prev) => [...prev, newImage]);
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
694
|
+
const canvasToBlob = (type, quality) => {
|
|
695
|
+
return new Promise((resolve, reject) => {
|
|
696
|
+
canvas.toBlob((blob) => {
|
|
697
|
+
if (blob) {
|
|
698
|
+
resolve(blob);
|
|
699
|
+
}
|
|
700
|
+
else {
|
|
701
|
+
reject(new Error(`toBlob returned null for type ${type}`));
|
|
702
|
+
}
|
|
703
|
+
}, type, quality);
|
|
704
|
+
});
|
|
705
|
+
};
|
|
706
|
+
const blobs = await Promise.all([
|
|
707
|
+
canvasToBlob('image/jpeg', 1),
|
|
708
|
+
canvasToBlob('image/png', 1),
|
|
709
|
+
canvasToBlob('image/webp', 1),
|
|
710
|
+
]);
|
|
711
|
+
this.service.imageBlob.set(blobs);
|
|
699
712
|
}
|
|
700
713
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: AXImageEditorViewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
701
714
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.9", type: AXImageEditorViewComponent, isStandalone: true, selector: "ax-image-editor-view", inputs: { showGrid: { classPropertyName: "showGrid", publicName: "showGrid", isSignal: true, isRequired: false, transformFunction: null }, src: { classPropertyName: "src", publicName: "src", isSignal: true, isRequired: false, transformFunction: null } }, providers: [{ provide: AXComponent, useExisting: AXImageEditorViewComponent }], viewQueries: [{ propertyName: "canvasElem", first: true, predicate: ["canvasElem"], descendants: true, isSignal: true }, { propertyName: "cropperWindow", first: true, predicate: ["f"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<canvas\n tabindex=\"1\"\n (pointerdown)=\"mouseDownHandler($event)\"\n (pointerup)=\"mouseUpHandler()\"\n (pointermove)=\"mouseMoveHandler($event)\"\n class=\"ax-canvas-element\"\n #canvasElem\n></canvas>\n\n@if (this.service.activeToolState() === 'crop') {\n <ax-image-editor-cropper-window [showGrid]=\"showGrid()\" #f></ax-image-editor-cropper-window>\n}\n", styles: ["ax-image-editor-view{position:relative;display:flex;justify-content:center;align-items:center;background-color:#fff;width:100%;touch-action:none;overflow:hidden}ax-image-editor-view .ax-canvas-element{cursor:crosshair;background-color:#000}ax-image-editor-view .ax-crop-save{position:absolute;top:0;right:0;margin:1rem}\n"], dependencies: [{ kind: "component", type: AXImageEditorCropperWindowComponent, selector: "ax-image-editor-cropper-window", inputs: ["showGrid"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
@@ -717,21 +730,17 @@ class AXImageEditorContainerComponent extends classes((MXInputBaseValueComponent
|
|
|
717
730
|
this.imageEditorContainer = viewChild('f', ...(ngDevMode ? [{ debugName: "imageEditorContainer" }] : []));
|
|
718
731
|
this.view = contentChild(AXImageEditorViewComponent, ...(ngDevMode ? [{ debugName: "view" }] : []));
|
|
719
732
|
this.aspectRatio = input([], ...(ngDevMode ? [{ debugName: "aspectRatio" }] : []));
|
|
733
|
+
this.#eff = effect(() => {
|
|
734
|
+
void this.service.imageBlob();
|
|
735
|
+
if (this.service.initialImage !== this.service.newImage && this.service.imageBlob().length) {
|
|
736
|
+
this.commitValue(this.service.imageBlob(), true);
|
|
737
|
+
}
|
|
738
|
+
else {
|
|
739
|
+
this.commitValue(null);
|
|
740
|
+
}
|
|
741
|
+
}, ...(ngDevMode ? [{ debugName: "#eff" }] : []));
|
|
720
742
|
}
|
|
721
|
-
|
|
722
|
-
* Saves the current edited image and commits the value to the component.
|
|
723
|
-
* If the image has been modified, it commits the image blob array. If no changes were made, it commits null.
|
|
724
|
-
*
|
|
725
|
-
* @returns void - No return value. The edited image is saved and the onValueChanged event is emitted.
|
|
726
|
-
*/
|
|
727
|
-
save() {
|
|
728
|
-
if (this.service.initialImage !== this.service.newImage) {
|
|
729
|
-
this.commitValue(this.service.imageBlob(), true);
|
|
730
|
-
}
|
|
731
|
-
else {
|
|
732
|
-
this.commitValue(null);
|
|
733
|
-
}
|
|
734
|
-
}
|
|
743
|
+
#eff;
|
|
735
744
|
cropButtonHandler() {
|
|
736
745
|
this.view().cropButtonHandler();
|
|
737
746
|
}
|