@8btc/xcanvas 0.0.14-beta.1 → 0.0.14-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -66,6 +66,10 @@ export declare interface XCanvasAPI {
66
66
  * 裁切图片
67
67
  */
68
68
  cropImage: () => void;
69
+ /**
70
+ * 删除选区里的全部元素
71
+ */
72
+ deleteSelection: () => void;
69
73
  }
70
74
 
71
75
  export declare interface XcanvasProps extends ExcalidrawProps {
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { atom, useAtom, useAtomValue, useSetAtom } from "jotai";
3
3
  import { Excalidraw, convertToExcalidrawElements, exportToCanvas } from "@8btc/excalidraw";
4
4
  import { useEffect } from "react";
5
- const version = "0.0.14-beta.1";
5
+ const version = "0.0.14-beta.2";
6
6
  const packageJson = {
7
7
  version
8
8
  };
@@ -414,6 +414,21 @@ function ApiFactory() {
414
414
  croppingElementId: selectedElements[0].id
415
415
  }
416
416
  });
417
+ },
418
+ deleteSelection: () => {
419
+ const appState = excalidrawAPI.getAppState();
420
+ const selectedIds = appState.selectedElementIds;
421
+ const currentElements = excalidrawAPI.getSceneElements();
422
+ const newElements = currentElements.filter((el) => {
423
+ return !selectedIds[el.id];
424
+ });
425
+ excalidrawAPI.updateScene({
426
+ elements: [...newElements],
427
+ appState: {
428
+ ...appState,
429
+ selectedElementIds: {}
430
+ }
431
+ });
417
432
  }
418
433
  });
419
434
  }, [excalidrawAPI, setApi]);
@@ -2,7 +2,7 @@
2
2
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("jotai"), require("@8btc/excalidraw"), require("react")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "jotai", "@8btc/excalidraw", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.XCanvas = {}, global.jsxRuntime, global.Jotai, global.Excalidraw, global.React));
3
3
  })(this, (function(exports2, jsxRuntime, jotai, excalidraw, react) {
4
4
  "use strict";
5
- const version = "0.0.14-beta.1";
5
+ const version = "0.0.14-beta.2";
6
6
  const packageJson = {
7
7
  version
8
8
  };
@@ -414,6 +414,21 @@
414
414
  croppingElementId: selectedElements[0].id
415
415
  }
416
416
  });
417
+ },
418
+ deleteSelection: () => {
419
+ const appState = excalidrawAPI.getAppState();
420
+ const selectedIds = appState.selectedElementIds;
421
+ const currentElements = excalidrawAPI.getSceneElements();
422
+ const newElements = currentElements.filter((el) => {
423
+ return !selectedIds[el.id];
424
+ });
425
+ excalidrawAPI.updateScene({
426
+ elements: [...newElements],
427
+ appState: {
428
+ ...appState,
429
+ selectedElementIds: {}
430
+ }
431
+ });
417
432
  }
418
433
  });
419
434
  }, [excalidrawAPI, setApi]);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8btc/xcanvas",
3
3
  "private": false,
4
- "version": "0.0.14-beta.1",
4
+ "version": "0.0.14-beta.2",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "exports": {