fix(label): selected path

This commit is contained in:
zhangheng
2026-04-17 14:08:10 +08:00
parent 8a99be55d1
commit 6c981d465b
3 changed files with 38 additions and 6 deletions

View File

@@ -3947,11 +3947,20 @@ export const usePaperStore = create<PaperState>((set) => ({
const getSelectedPolygonContext = () => {
const activeImage = useBottomToolsStore.getState().activeImage
const lockedEditTarget =
useKeyboardStore.getState().selectedObjectEditTarget
const selectedIds =
useObjectStore.getState().selectedPath[activeImage] || []
if (selectedIds.length !== 1) return null
const selectedId =
lockedEditTarget &&
lockedEditTarget.imageId === activeImage &&
lockedEditTarget.objectType === "polygon"
? lockedEditTarget.objectId
: selectedIds.length === 1
? selectedIds[0]
: null
if (selectedId === null) return null
const selectedId = selectedIds[0]
const targetShapes = usePaperStore
.getState()
.getItemsById(selectedId)
@@ -3959,9 +3968,13 @@ export const usePaperStore = create<PaperState>((set) => ({
if (!targetShapes.length) return null
const operationId = (
targetShapes.find((item) => !!item.data)?.data?.operationId ||
useTopToolsStore.getState().activeOperation ||
""
lockedEditTarget &&
lockedEditTarget.imageId === activeImage &&
lockedEditTarget.objectId === selectedId
? lockedEditTarget.operationId
: targetShapes.find((item) => !!item.data)?.data?.operationId ||
useTopToolsStore.getState().activeOperation ||
""
).toString()
if (!operationId) return null
@@ -4464,7 +4477,10 @@ export const usePaperStore = create<PaperState>((set) => ({
} = {}
) => {
const context = getSelectedPolygonContext()
if (!context) return false
if (!context) {
options.draftPath?.remove()
return false
}
const prevDrawOption = useTopToolsStore.getState().drawOption
const nextDrawOption = mode === "subtract" ? "intersect" : "unite"
const baseShape = createWorkingPolygonShape(context.targetShapes)