@myoc/element 0.19.511 → 0.19.513

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.
@@ -231,6 +231,7 @@ export declare const EXPORT_SCALES: number[];
231
231
  export declare const DEFAULT_EXPORT_PADDING = 10;
232
232
  export declare const DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT = 1440;
233
233
  export declare const MAX_ALLOWED_FILE_BYTES: number;
234
+ export declare const DEFAULT_IMAGE_OPTIONS: AppProps["imageOptions"];
234
235
  export declare const SVG_NS = "http://www.w3.org/2000/svg";
235
236
  export declare const SVG_DOCUMENT_PREAMBLE = "<?xml version=\"1.0\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
236
237
  export declare const ENCRYPTION_KEY_BITS = 128;
@@ -1,6 +1,5 @@
1
1
  import { LaserPointer } from "@excalidraw/laser-pointer";
2
2
  import type { LaserPointerOptions } from "@excalidraw/laser-pointer";
3
- import type { AnimationFrameHandler } from "./animation-frame-handler";
4
3
  import type App from "./components/App";
5
4
  export interface Trail {
6
5
  start(container: SVGSVGElement): void;
@@ -15,7 +14,6 @@ export interface AnimatedTrailOptions {
15
14
  animateTrail?: boolean;
16
15
  }
17
16
  export declare class AnimatedTrail implements Trail {
18
- private animationFrameHandler;
19
17
  protected app: App;
20
18
  private options;
21
19
  private currentTrail?;
@@ -23,9 +21,12 @@ export declare class AnimatedTrail implements Trail {
23
21
  private container?;
24
22
  private trailElement;
25
23
  private trailAnimation?;
26
- constructor(animationFrameHandler: AnimationFrameHandler, app: App, options: Partial<LaserPointerOptions> & Partial<AnimatedTrailOptions>);
24
+ private key;
25
+ private static counter;
26
+ constructor(app: App, options: Partial<LaserPointerOptions> & Partial<AnimatedTrailOptions>);
27
27
  get hasCurrentTrail(): boolean;
28
28
  hasLastPoint(x: number, y: number): boolean;
29
+ private cleanup;
29
30
  start(container?: SVGSVGElement): void;
30
31
  stop(): void;
31
32
  startPath(x: number, y: number): void;
@@ -1,24 +1,23 @@
1
1
  import React from "react";
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";
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";
4
4
  import { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
5
- import type { ExcalidrawElement, NonDeleted, NonDeletedExcalidrawElement, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, ExcalidrawEmbeddableElement, Ordered, SceneElementsMap } from "@excalidraw/element/types";
5
+ import type { ExcalidrawElement, ExcalidrawEmbeddableElement, ExcalidrawFrameLikeElement, ExcalidrawIframeElement, NonDeleted, NonDeletedExcalidrawElement, Ordered, SceneElementsMap } from "@excalidraw/element/types";
6
6
  import type { Mutable } from "@excalidraw/common/utility-types";
7
7
  import { ActionManager } from "../actions/manager";
8
- import { AnimationFrameHandler } from "../animation-frame-handler";
9
8
  import { History } from "../history";
10
- import { Fonts } from "../fonts";
11
9
  import { type WritableAtom } from "../editor-jotai";
10
+ import { Fonts } from "../fonts";
11
+ import { LaserTrails } from "../laserTrails";
12
12
  import { Renderer } from "../scene/Renderer";
13
- import { LaserTrails } from "../laser-trails";
14
13
  import { isOverScrollBars } from "../scene/scrollbars";
15
14
  import { LassoTrail } from "../lasso";
16
15
  import { EraserTrail } from "../eraser";
17
16
  import { type OnStateChange } from "./AppStateObserver";
18
17
  import type { ExportedElements } from "../data";
19
- import type { AppClassProperties, AppProps, AppState, ExcalidrawImperativeAPI, BinaryFiles, SceneData, FrameNameBoundsCache, SidebarName, SidebarTabName, ToolType, OnUserFollowedPayload, ExcalidrawImperativeAPIEventMap, GenerateDiagramToCode, NullableGridSize, Offsets } from "../types";
20
18
  import type { RoughCanvas } from "roughjs/bin/canvas";
21
19
  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";
22
21
  declare const editorLifecycleEventBehavior: {
23
22
  readonly "editor:mount": {
24
23
  readonly cardinality: "once";
@@ -129,7 +128,6 @@ declare class App extends React.Component<AppProps, AppState> {
129
128
  x: number;
130
129
  y: number;
131
130
  };
132
- animationFrameHandler: AnimationFrameHandler;
133
131
  laserTrails: LaserTrails;
134
132
  eraserTrail: EraserTrail;
135
133
  lassoTrail: LassoTrail;
@@ -1,5 +1,5 @@
1
1
  import "./SVGLayer.scss";
2
- import type { Trail } from "../animated-trail";
2
+ import type { Trail } from "../animatedTrail";
3
3
  type SVGLayerProps = {
4
4
  trails: Trail[];
5
5
  };
@@ -1,10 +1,9 @@
1
- import { AnimatedTrail } from "../animated-trail";
2
- import type { AnimationFrameHandler } from "../animation-frame-handler";
1
+ import { AnimatedTrail } from "../animatedTrail";
3
2
  import type App from "../components/App";
4
3
  export declare class EraserTrail extends AnimatedTrail {
5
4
  private elementsToErase;
6
5
  private groupsToErase;
7
- constructor(animationFrameHandler: AnimationFrameHandler, app: App);
6
+ constructor(app: App);
8
7
  startPath(x: number, y: number): void;
9
8
  addPointToPath(x: number, y: number, restore?: boolean): string[];
10
9
  private updateElementsToBeErased;
@@ -1,20 +1,18 @@
1
- import { AnimatedTrail } from "./animated-trail";
2
- import type { Trail } from "./animated-trail";
3
- import type { AnimationFrameHandler } from "./animation-frame-handler";
1
+ import { AnimatedTrail } from "./animatedTrail";
2
+ import type { Trail } from "./animatedTrail";
4
3
  import type App from "./components/App";
5
4
  export declare class LaserTrails implements Trail {
6
- private animationFrameHandler;
7
5
  private app;
8
6
  localTrail: AnimatedTrail;
9
7
  private collabTrails;
10
8
  private container?;
11
- constructor(animationFrameHandler: AnimationFrameHandler, app: App);
9
+ constructor(app: App);
12
10
  private getTrailOptions;
13
11
  startPath(x: number, y: number): void;
14
12
  addPointToPath(x: number, y: number): void;
15
13
  endPath(): void;
16
14
  start(container: SVGSVGElement): void;
17
15
  stop(): void;
18
- onFrame(): void;
19
- private updateCollabTrails;
16
+ private stopCollabTrails;
17
+ updateCollabTrails(collaborators: App["state"]["collaborators"]): void;
20
18
  }
@@ -1,5 +1,4 @@
1
- import { type AnimationFrameHandler } from "../animation-frame-handler";
2
- import { AnimatedTrail } from "../animated-trail";
1
+ import { AnimatedTrail } from "../animatedTrail";
3
2
  import type App from "../components/App";
4
3
  export declare class LassoTrail extends AnimatedTrail {
5
4
  private intersectedElements;
@@ -7,7 +6,7 @@ export declare class LassoTrail extends AnimatedTrail {
7
6
  private elementsSegments;
8
7
  private canvasTranslate;
9
8
  private keepPreviousSelection;
10
- constructor(animationFrameHandler: AnimationFrameHandler, app: App);
9
+ constructor(app: App);
11
10
  startPath(x: number, y: number, keepPreviousSelection?: boolean): void;
12
11
  selectElementsFromIds: (ids: string[]) => void;
13
12
  addPointToPath: (x: number, y: number, keepPreviousSelection?: boolean) => void;
@@ -3,9 +3,12 @@ export type Animation<R extends object> = (params: {
3
3
  state?: R;
4
4
  }) => R | null | undefined;
5
5
  export declare class AnimationController {
6
- private static isRunning;
6
+ private static scheduledFrame;
7
7
  private static animations;
8
8
  static start<R extends object>(key: string, animation: Animation<R>): void;
9
+ private static scheduleNextFrame;
10
+ private static cancelScheduledFrame;
11
+ private static cancelScheduledFrameIfIdle;
9
12
  private static tick;
10
13
  static running(key: string): boolean;
11
14
  static cancel(key: string): void;
@@ -521,6 +521,10 @@ export interface ExcalidrawProps {
521
521
  editorPreferences?: EditorPreferences;
522
522
  onEditorPreferencesChange?: (next: EditorPreferences) => void;
523
523
  UIOptions?: Partial<UIOptions>;
524
+ /**
525
+ * dimensions and size constraints for inserted images
526
+ */
527
+ imageOptions?: ImageOptions;
524
528
  detectScroll?: boolean;
525
529
  handleKeyboardGlobally?: boolean;
526
530
  autoFocus?: boolean;
@@ -577,6 +581,10 @@ export type ExportOpts = {
577
581
  onExportToBackend?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles) => void;
578
582
  renderCustomUI?: (exportedElements: readonly NonDeletedExcalidrawElement[], appState: UIAppState, files: BinaryFiles, canvas: HTMLCanvasElement) => JSX.Element;
579
583
  };
584
+ export type ImageOptions = Partial<{
585
+ maxWidthOrHeight: number;
586
+ maxFileSizeBytes: number;
587
+ }>;
580
588
  export type CanvasActions = Partial<{
581
589
  changeViewBackgroundColor: boolean;
582
590
  export: false | ExportOpts;
@@ -605,6 +613,7 @@ export type AppProps = Merge<ExcalidrawProps, {
605
613
  export: ExportOpts;
606
614
  };
607
615
  }>;
616
+ imageOptions: Required<ImageOptions>;
608
617
  wheelZoomsOnDefault?: boolean;
609
618
  detectScroll: boolean;
610
619
  handleKeyboardGlobally: boolean;
@@ -727,6 +736,9 @@ export type ExcalidrawMountPayload = {
727
736
  excalidrawAPI: ExcalidrawImperativeAPI;
728
737
  container: HTMLDivElement | null;
729
738
  };
739
+ export type AddImageElementsToSceneOptions = {
740
+ waitFor?: "inserted" | "painted";
741
+ };
730
742
  export type ExcalidrawImperativeAPIEventMap = {
731
743
  "editor:mount": [payload: ExcalidrawMountPayload];
732
744
  "editor:initialize": [api: ExcalidrawImperativeAPI];
@@ -754,7 +766,7 @@ export interface ExcalidrawImperativeAPI {
754
766
  refresh: InstanceType<typeof App>["refresh"];
755
767
  setToast: InstanceType<typeof App>["setToast"];
756
768
  addFiles: (data: BinaryFileData[]) => void;
757
- addImageElementsToScene: (imageFiles: File[], sceneX: number, sceneY: number) => Promise<void>;
769
+ addImageElementsToScene: (imageFiles: File[], sceneX: number, sceneY: number, options?: AddImageElementsToSceneOptions) => Promise<void>;
758
770
  id: string;
759
771
  setActiveTool: InstanceType<typeof App>["setActiveTool"];
760
772
  setCursor: InstanceType<typeof App>["setCursor"];
@@ -125,3 +125,4 @@ export declare const pointScaleFromOrigin: <P extends GlobalPoint | LocalPoint>(
125
125
  * @returns TRUE if q is indeed between p and r
126
126
  */
127
127
  export declare const isPointWithinBounds: <P extends GlobalPoint | LocalPoint>(p: P, q: P, r: P) => boolean;
128
+ export declare const isValidPoint: (point: unknown) => point is LocalPoint;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myoc/element",
3
- "version": "0.19.511",
3
+ "version": "0.19.513",
4
4
  "type": "module",
5
5
  "types": "./dist/types/element/src/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -64,8 +64,8 @@
64
64
  "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types"
65
65
  },
66
66
  "dependencies": {
67
- "@excalidraw/common": "npm:@myoc/common@0.19.511",
68
- "@excalidraw/fractional-indexing": "npm:@myoc/fractional-indexing@0.19.511",
69
- "@excalidraw/math": "npm:@myoc/math@0.19.511"
67
+ "@excalidraw/common": "npm:@myoc/common@0.19.513",
68
+ "@excalidraw/fractional-indexing": "npm:@myoc/fractional-indexing@0.19.513",
69
+ "@excalidraw/math": "npm:@myoc/math@0.19.513"
70
70
  }
71
71
  }
@@ -1,16 +0,0 @@
1
- export type AnimationCallback = (timestamp: number) => void | boolean;
2
- export type AnimationTarget = {
3
- callback: AnimationCallback;
4
- stopped: boolean;
5
- };
6
- export declare class AnimationFrameHandler {
7
- private targets;
8
- private rafIds;
9
- register(key: object, callback: AnimationCallback): void;
10
- start(key: object): void;
11
- stop(key: object): void;
12
- private constructFrame;
13
- private scheduleFrame;
14
- private cancelFrame;
15
- private onFrame;
16
- }