bill преди 2 месеца
родител
ревизия
c4c36227d2
променени са 4 файла, в които са добавени 23 реда и са изтрити 6 реда
  1. 6 2
      src/core/hook/use-expose.ts
  2. 4 1
      src/core/hook/use-mouse-status.ts
  3. 8 2
      src/core/hook/use-selection.ts
  4. 5 1
      src/example/fuse/views/tabulation/index.vue

+ 6 - 2
src/core/hook/use-expose.ts

@@ -31,7 +31,7 @@ import { themeColor } from "@/constant";
 import { getImage, isSvgString } from "@/utils/resource.ts";
 import { useResourceHandler } from "./use-fetch.ts";
 import { useConfig } from "./use-config.ts";
-import { useSelectionRevise } from "./use-selection.ts";
+import { useExcludeSelection, useSelectionRevise } from "./use-selection.ts";
 import { useFormalLayer, useGetFormalChildren } from "./use-layer.ts";
 import { components, DrawItem } from "../components/index.ts";
 import { useProportion } from "./use-proportion.ts";
@@ -84,6 +84,7 @@ export const useShortcutKey = () => {
   // 自动退出添加模式
   const { quitDrawShape, enterDrawShape } = useInteractiveDrawShapeAPI();
   const interactiveProps = useInteractiveProps();
+  
   const store = useStore();
   useListener(
     "contextmenu",
@@ -107,6 +108,7 @@ export const useShortcutKey = () => {
   const status = useMouseShapesStatus();
   const getChildren = useGetFormalChildren();
   const operMode = useOperMode();
+  const eSelection = useExcludeSelection()
   const getShapeBelong = useGetShapeBelong()
   useListener(
     "keydown",
@@ -185,7 +187,8 @@ export const useShortcutKey = () => {
         if (status.selects.length) {
           status.selects = [];
         } else {
-          status.selects = getChildren();
+          
+          status.selects = getChildren().filter(shape => !eSelection.value.includes(shape.id()));
         }
       }
     },
@@ -314,6 +317,7 @@ export const useExpose = installGlobalVar(() => {
     },
     getViewBoxPositionPixel: useGetViewBoxPositionPixel(),
     viewer,
+    excludeSelection: useExcludeSelection(),
     runHook: useRunHook(),
     presetAdd: interactiveProps,
     config: useConfig(),

+ 4 - 1
src/core/hook/use-mouse-status.ts

@@ -25,6 +25,7 @@ import { Group } from "konva/lib/Group";
 import { usePause } from "./use-pause.ts";
 import { lineLen, Pos } from "@/utils/math.ts";
 import { useFormalLayer } from "./use-layer.ts";
+import { useExcludeSelection } from "./use-selection.ts";
 
 const stageHoverMap = new WeakMap<
   Stage,
@@ -235,6 +236,7 @@ export const useMouseShapesStatus = installGlobalVar(() => {
   const selects = ref([]) as Ref<EntityShape[]>;
   const actives = ref([]) as Ref<EntityShape[]>;
   const operMode = useOperMode();
+  const eSelection = useExcludeSelection()
   const pointerIsTransformerInner = usePointerIsTransformerInner();
 
   const init = (stage: Stage) => {
@@ -295,11 +297,12 @@ export const useMouseShapesStatus = installGlobalVar(() => {
             return;
           }
           if (operMode.value.mulSelection) {
-            if (!target) return;
+            if (!target || eSelection.value.includes(target.id())) return;
             actives.value = [];
             const ndx = selects.value.findIndex(
               (item) => item.id() === target?.id()
             );
+            
             if (~ndx) {
               selects.value.splice(ndx, 1);
             } else {

+ 8 - 2
src/core/hook/use-selection.ts

@@ -104,8 +104,11 @@ export const normalSelectItems = (
   ).map((id) => store.getItemById(id)!);
 };
 
+export const useExcludeSelection = installGlobalVar(() => ref<string[]>([]))
+
 export const useSelection = installGlobalVar(() => {
   const layer = useHelperLayer();
+  const eSelection = useExcludeSelection()
   const getChildren = useGetFormalChildren();
   const box = new Rect({
     stroke: themeColor, 
@@ -128,6 +131,7 @@ export const useSelection = installGlobalVar(() => {
 
     for (let i = 0; i < shapeBoxs.length; i++) {
       if (
+        
         Util.haveIntersection(boxRect, shapeBoxs[i]) &&
         !isRectContained(shapeBoxs[i], boxRect) &&
         shapes[i] !== toRaw(transformer)
@@ -165,7 +169,7 @@ export const useSelection = installGlobalVar(() => {
   };
 
   const updateInitData = () => {
-    shapes = getChildren();
+    shapes = getChildren().filter(shape => !eSelection.value.includes(shape.id()));
     shapeBoxs = shapes.map((shape) => shape.getClientRect());
   };
 
@@ -323,6 +327,7 @@ export const useSelectionRevise = () => {
   const mParts = useMountParts();
   const status = useMouseShapesStatus();
   const store = useStore();
+  const eSelection = useExcludeSelection()
 
   const { addShapes, delShapes, watchSelection } = useWatchSelection();
 
@@ -332,7 +337,7 @@ export const useSelectionRevise = () => {
   const filterSelect = debounce(() => {
     const children = getFormatChildren();
     const mouseSelects = status.selects.filter((shape) =>
-      children.includes(shape)
+      !eSelection.value.includes(shape.id()) && children.includes(shape)
     );
     status.selects = mouseSelects;
   }, 16);
@@ -357,6 +362,7 @@ export const useSelectionRevise = () => {
         status.selects = Array.from(
           addShapes(new Set(initSelections), rectSelects)
         );
+        // filterSelect()
       }
     }
   );

+ 5 - 1
src/example/fuse/views/tabulation/index.vue

@@ -49,7 +49,6 @@ import { StoreData } from "@/core/store/store";
 import { getImageSize } from "@/utils/shape";
 import { tabCustomStyle } from "../defStyle";
 import { defaultLayer } from "@/constant";
-import { useViewBoxPixelRect } from "@/core/hook/use-viewer";
 
 const uploadResourse = window.platform.uploadResourse;
 const full = ref(false);
@@ -140,6 +139,11 @@ watch(draw, (draw, _, onCleanup) => {
 const cover = computed(
   () => draw.value?.store.items.find((item) => item.key === tableCoverKey) as ImageData
 );
+watchEffect(() => {
+  if (cover.value && draw.value) {
+    draw.value.excludeSelection.push(cover.value.id);
+  }
+});
 const coverScale = computed({
   get: () =>
     cover.value &&