fix(label): selected path
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user