-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from LHRUN/dev
Feature/1.5.4
- Loading branch information
Showing
10 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
# 1.5.4 | ||
|
||
### Feat | ||
|
||
- add eraser config | ||
|
||
# 1.5.3 | ||
|
||
### Feat | ||
|
||
- upload image | ||
- add image segmentation | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/components/toolPanel/selectConfig/eraserConfig/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { useMemo, FC } from 'react' | ||
import { paintBoard } from '@/utils/paintBoard' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
interface IProps { | ||
refreshCount: number | ||
} | ||
|
||
const EraserConfig: FC<IProps> = ({ refreshCount }) => { | ||
const { t } = useTranslation() | ||
|
||
const erasableControl = useMemo(() => { | ||
let show = false | ||
let erasable = true | ||
const objects = paintBoard.canvas?.getActiveObjects() | ||
|
||
if (objects?.length) { | ||
show = true | ||
erasable = !objects?.every((obj) => obj?.erasable === false) | ||
} | ||
|
||
return { | ||
show, | ||
erasable | ||
} | ||
}, [refreshCount]) | ||
|
||
const updateObjectErasable = () => { | ||
const objects = paintBoard.canvas?.getActiveObjects() | ||
if (objects?.length) { | ||
objects?.forEach((obj) => { | ||
obj.erasable = !erasableControl.erasable | ||
}) | ||
paintBoard.canvas?.fire('selection:updated') | ||
paintBoard.render() | ||
} | ||
} | ||
|
||
return ( | ||
<> | ||
{erasableControl.show && ( | ||
<> | ||
<div className="font-bold font-fredokaOne mt-3 text-sm"> | ||
{t('eraserConfig.eraser')} | ||
</div> | ||
<div className="mt-1 flex items-center w-full"> | ||
<div className="font-fredokaOne text-xs mr-3"> | ||
{t('eraserConfig.erasable')} | ||
</div> | ||
<input | ||
type="checkbox" | ||
className="toggle toggle-success" | ||
checked={erasableControl.erasable} | ||
onChange={updateObjectErasable} | ||
/> | ||
</div> | ||
</> | ||
)} | ||
</> | ||
) | ||
} | ||
|
||
export default EraserConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,5 +174,9 @@ | |
"rotate": "旋转", | ||
"scale": "缩放", | ||
"size": "尺寸" | ||
}, | ||
"eraserConfig": { | ||
"eraser": "橡皮擦", | ||
"erasable": "可擦除" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters