@myoc/math 0.19.513 → 0.19.515

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.
@@ -57,6 +57,7 @@ export declare const newImageElement: (opts: {
57
57
  type: ExcalidrawImageElement["type"];
58
58
  status?: ExcalidrawImageElement["status"];
59
59
  fileId?: ExcalidrawImageElement["fileId"];
60
+ fileName?: ExcalidrawImageElement["fileName"];
60
61
  scale?: ExcalidrawImageElement["scale"];
61
62
  crop?: ExcalidrawImageElement["crop"];
62
63
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawImageElement>;
@@ -129,6 +129,7 @@ export type ImageCrop = {
129
129
  export type ExcalidrawImageElement = _ExcalidrawElementBase & Readonly<{
130
130
  type: "image";
131
131
  fileId: FileId | null;
132
+ fileName: string | null;
132
133
  /** whether respective file is persisted */
133
134
  status: "pending" | "saved" | "error";
134
135
  /** X and Y scale factors <-1, 1>, used for image axis flipping */
@@ -1008,6 +1008,7 @@ export declare const actionWrapSelectionInFrame: {
1008
1008
  }> & Readonly<{
1009
1009
  type: "image";
1010
1010
  fileId: import("@excalidraw/element/types").FileId | null;
1011
+ fileName: string | null;
1011
1012
  status: "pending" | "saved" | "error";
1012
1013
  scale: [number, number];
1013
1014
  crop: import("@excalidraw/element/types").ImageCrop | null;
@@ -499,6 +499,7 @@ export declare const actionTogglePolygon: {
499
499
  }> & Readonly<{
500
500
  type: "image";
501
501
  fileId: import("@excalidraw/element/types").FileId | null;
502
+ fileName: string | null;
502
503
  status: "pending" | "saved" | "error";
503
504
  scale: [number, number];
504
505
  crop: import("@excalidraw/element/types").ImageCrop | null;
@@ -1,23 +1,23 @@
1
1
  import React from "react";
2
- import { AppEventBus, type EditorInterface, Emitter, type EXPORT_IMAGE_TYPES, type StylesPanelMode } from "@excalidraw/common";
3
- import { type ApplyToOptions, type ElementUpdate, FlowChartCreator, Scene, Store, StoreDelta } from "@excalidraw/element";
2
+ import { AppEventBus, type EXPORT_IMAGE_TYPES, Emitter, type EditorInterface, type StylesPanelMode } from "@excalidraw/common";
3
+ import { FlowChartCreator, Scene, Store, type ElementUpdate, StoreDelta, type ApplyToOptions } from "@excalidraw/element";
4
4
  import { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
5
- import type { ExcalidrawElement, ExcalidrawEmbeddableElement, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, NonDeleted, NonDeletedExcalidrawElement, Ordered, SceneElementsMap } from "@excalidraw/element/types";
5
+ import type { ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, ExcalidrawEmbeddableElement, Ordered, SceneElementsMap } from "@excalidraw/element/types";
6
6
  import type { Mutable } from "@excalidraw/common/utility-types";
7
7
  import { ActionManager } from "../actions/manager";
8
8
  import { History } from "../history";
9
- import { type WritableAtom } from "../editor-jotai";
10
9
  import { Fonts } from "../fonts";
11
- import { LaserTrails } from "../laserTrails";
10
+ import { type WritableAtom } from "../editor-jotai";
12
11
  import { Renderer } from "../scene/Renderer";
12
+ import { LaserTrails } from "../laserTrails";
13
13
  import { isOverScrollBars } from "../scene/scrollbars";
14
14
  import { LassoTrail } from "../lasso";
15
15
  import { EraserTrail } from "../eraser";
16
16
  import { type OnStateChange } from "./AppStateObserver";
17
17
  import type { ExportedElements } from "../data";
18
+ import type { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, SceneData, FrameNameBoundsCache, SidebarName, SidebarTabName, ToolType, OnUserFollowedPayload, ExcalidrawImperativeAPIEventMap, GenerateDiagramToCode, NullableGridSize, Offsets } from "../types";
18
19
  import type { RoughCanvas } from "roughjs/bin/canvas";
19
20
  import type { ActionResult } from "../actions/types";
20
- import type { AppClassProperties, AppProps, AppState, BinaryFiles, ExcalidrawImperativeAPI, ExcalidrawImperativeAPIEventMap, FrameNameBoundsCache, GenerateDiagramToCode, NullableGridSize, Offsets, OnUserFollowedPayload, SceneData, SidebarName, SidebarTabName, ToolType } from "../types";
21
21
  declare const editorLifecycleEventBehavior: {
22
22
  readonly "editor:mount": {
23
23
  readonly cardinality: "once";
@@ -592,6 +592,7 @@ declare class App extends React.Component<AppProps, AppState> {
592
592
  private maybeHandleCrop;
593
593
  private maybeHandleResize;
594
594
  private getContextMenuItems;
595
+ private getImageContextMenuItems;
595
596
  private handleWheel;
596
597
  private getTextWysiwygSnappedToCenterPosition;
597
598
  private savePointer;
@@ -2,7 +2,12 @@ import React from "react";
2
2
  import "./ContextMenu.scss";
3
3
  import type { ActionManager } from "../actions/manager";
4
4
  import type { Action } from "../actions/types";
5
- export type ContextMenuItem = typeof CONTEXT_MENU_SEPARATOR | Action;
5
+ export type ContextMenuCustomItem = {
6
+ key: string;
7
+ label: string;
8
+ onSelect: () => void;
9
+ };
10
+ export type ContextMenuItem = typeof CONTEXT_MENU_SEPARATOR | Action | ContextMenuCustomItem;
6
11
  export type ContextMenuItems = (ContextMenuItem | false | null | undefined)[];
7
12
  type ContextMenuProps = {
8
13
  actionManager: ActionManager;
@@ -271,6 +271,7 @@ export declare class Renderer {
271
271
  }> & Readonly<{
272
272
  type: "image";
273
273
  fileId: import("@excalidraw/element/types").FileId | null;
274
+ fileName: string | null;
274
275
  status: "pending" | "saved" | "error";
275
276
  scale: [number, number];
276
277
  crop: import("@excalidraw/element/types").ImageCrop | null;
@@ -9,7 +9,7 @@ import type { Action } from "./actions/types";
9
9
  import type { Spreadsheet } from "./charts";
10
10
  import type { ClipboardData } from "./clipboard";
11
11
  import type App from "./components/App";
12
- import type { ContextMenuItems } from "./components/ContextMenu";
12
+ import type { ContextMenuCustomItem, ContextMenuItems } from "./components/ContextMenu";
13
13
  import type { SnapLine } from "./snapping";
14
14
  import type { ImportedDataState } from "./data/types";
15
15
  import type { Language } from "./i18n";
@@ -83,6 +83,7 @@ export type BinaryFileData = {
83
83
  };
84
84
  export type BinaryFileMetadata = Omit<BinaryFileData, "dataURL">;
85
85
  export type BinaryFiles = Record<ExcalidrawElement["id"], BinaryFileData>;
86
+ export type ImageContextMenuItem = ContextMenuCustomItem;
86
87
  export type ToolType = "selection" | "lasso" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "magicframe" | "embeddable" | "laser";
87
88
  export type ElementOrToolType = ExcalidrawElementType | ToolType | "custom";
88
89
  export type ActiveTool = {
@@ -534,6 +535,7 @@ export interface ExcalidrawProps {
534
535
  onLinkOpen?: (element: NonDeletedExcalidrawElement, event: CustomEvent<{
535
536
  nativeEvent: MouseEvent | React.PointerEvent<HTMLCanvasElement>;
536
537
  }>) => void;
538
+ imageContextMenuItems?: (imageIds: readonly ExcalidrawElement["id"][]) => readonly ImageContextMenuItem[];
537
539
  onPointerDown?: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState) => void;
538
540
  onPointerUp?: (activeTool: AppState["activeTool"], pointerDownState: PointerDownState) => void;
539
541
  onScrollChange?: (scrollX: number, scrollY: number, zoom: Zoom) => void;
@@ -736,9 +738,6 @@ export type ExcalidrawMountPayload = {
736
738
  excalidrawAPI: ExcalidrawImperativeAPI;
737
739
  container: HTMLDivElement | null;
738
740
  };
739
- export type AddImageElementsToSceneOptions = {
740
- waitFor?: "inserted" | "painted";
741
- };
742
741
  export type ExcalidrawImperativeAPIEventMap = {
743
742
  "editor:mount": [payload: ExcalidrawMountPayload];
744
743
  "editor:initialize": [api: ExcalidrawImperativeAPI];
@@ -766,7 +765,10 @@ export interface ExcalidrawImperativeAPI {
766
765
  refresh: InstanceType<typeof App>["refresh"];
767
766
  setToast: InstanceType<typeof App>["setToast"];
768
767
  addFiles: (data: BinaryFileData[]) => void;
769
- addImageElementsToScene: (imageFiles: File[], sceneX: number, sceneY: number, options?: AddImageElementsToSceneOptions) => Promise<void>;
768
+ addImageElementsToScene: (imageFiles: {
769
+ file: File;
770
+ customData: Record<string, any>;
771
+ }[], sceneX: number, sceneY: number) => Promise<void>;
770
772
  id: string;
771
773
  setActiveTool: InstanceType<typeof App>["setActiveTool"];
772
774
  setCursor: InstanceType<typeof App>["setCursor"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myoc/math",
3
- "version": "0.19.513",
3
+ "version": "0.19.515",
4
4
  "type": "module",
5
5
  "types": "./dist/types/math/src/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -62,6 +62,6 @@
62
62
  "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types"
63
63
  },
64
64
  "dependencies": {
65
- "@excalidraw/common": "npm:@myoc/common@0.19.513"
65
+ "@excalidraw/common": "npm:@myoc/common@0.19.515"
66
66
  }
67
67
  }