diff --git a/src/hooks/useLine.js b/src/hooks/useLine.js index fcf14312..9d1a48eb 100644 --- a/src/hooks/useLine.js +++ b/src/hooks/useLine.js @@ -159,5 +159,6 @@ export const useLine = () => { addPitchText, removePitchText, addPitchTextsByOuterLines, + getLengthByLine, } } diff --git a/src/hooks/usePolygon.js b/src/hooks/usePolygon.js index 39e82210..558bec36 100644 --- a/src/hooks/usePolygon.js +++ b/src/hooks/usePolygon.js @@ -15,6 +15,7 @@ import { flowDisplaySelector } from '@/store/settingAtom' import { fontSelector } from '@/store/fontAtom' import { QLine } from '@/components/fabric/QLine' import { LINE_TYPE, POLYGON_TYPE } from '@/common/common' +import { useLine } from '@/hooks/useLine' export const usePolygon = () => { const canvas = useRecoilValue(canvasState) @@ -24,6 +25,8 @@ export const usePolygon = () => { const currentAngleType = useRecoilValue(currentAngleTypeSelector) const pitchText = useRecoilValue(pitchTextSelector) + const { getLengthByLine } = useLine() + const addPolygon = (points, options, isAddCanvas = true) => { const polygon = new QPolygon(points, { ...options, @@ -1104,7 +1107,7 @@ export const usePolygon = () => { if (!representLine) { representLine = line } else { - if (representLine.length < line.length) { + if (getLengthByLine(representLine) < getLengthByLine(line)) { representLine = line } }