|
|
|
@ -6,7 +6,7 @@ import React, { useState } from 'react';
|
|
|
|
import { Button } from 'antd';
|
|
|
|
import { Button } from 'antd';
|
|
|
|
import { ModalWrapper } from '../Modal';
|
|
|
|
import { ModalWrapper } from '../Modal';
|
|
|
|
import { useGlobalKeyDown } from '@/hooks/useGlobalKeyDown';
|
|
|
|
import { useGlobalKeyDown } from '@/hooks/useGlobalKeyDown';
|
|
|
|
import { isEnterHotkey } from '@/utils/hot-key';
|
|
|
|
import { isEnterHotkey, isEscHotkey } from '@/utils/hot-key';
|
|
|
|
|
|
|
|
|
|
|
|
const createImage = (url: string): Promise<HTMLImageElement> =>
|
|
|
|
const createImage = (url: string): Promise<HTMLImageElement> =>
|
|
|
|
new Promise((resolve, reject) => {
|
|
|
|
new Promise((resolve, reject) => {
|
|
|
|
@ -102,6 +102,7 @@ function getCroppedImg(
|
|
|
|
export const ModalAvatarCropper: React.FC<{
|
|
|
|
export const ModalAvatarCropper: React.FC<{
|
|
|
|
imageUrl: string;
|
|
|
|
imageUrl: string;
|
|
|
|
onConfirm: (croppedImageBlobUrl: string) => void;
|
|
|
|
onConfirm: (croppedImageBlobUrl: string) => void;
|
|
|
|
|
|
|
|
onCancel: () => void;
|
|
|
|
}> = React.memo((props) => {
|
|
|
|
}> = React.memo((props) => {
|
|
|
|
const [crop, setCrop] = useState({ x: 0, y: 0 });
|
|
|
|
const [crop, setCrop] = useState({ x: 0, y: 0 });
|
|
|
|
const [zoom, setZoom] = useState(1);
|
|
|
|
const [zoom, setZoom] = useState(1);
|
|
|
|
@ -110,6 +111,9 @@ export const ModalAvatarCropper: React.FC<{
|
|
|
|
useGlobalKeyDown((e) => {
|
|
|
|
useGlobalKeyDown((e) => {
|
|
|
|
if (isEnterHotkey(e)) {
|
|
|
|
if (isEnterHotkey(e)) {
|
|
|
|
handleConfirm();
|
|
|
|
handleConfirm();
|
|
|
|
|
|
|
|
} else if (isEscHotkey(e)) {
|
|
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
props.onCancel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|