@excalidraw/element 0.18.0-ec07091 → 0.18.0-f2600fe

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.
Files changed (68) hide show
  1. package/dist/dev/index.js +21 -24
  2. package/dist/dev/index.js.map +2 -2
  3. package/dist/prod/index.js +9 -9
  4. package/dist/types/common/src/constants.d.ts +3 -16
  5. package/dist/types/common/src/editorInterface.d.ts +34 -0
  6. package/dist/types/common/src/index.d.ts +1 -0
  7. package/dist/types/common/src/utils.d.ts +0 -2
  8. package/dist/types/element/src/resizeTest.d.ts +5 -4
  9. package/dist/types/element/src/transformHandles.d.ts +5 -4
  10. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +18 -9
  11. package/dist/types/excalidraw/actions/actionBoundText.d.ts +12 -6
  12. package/dist/types/excalidraw/actions/actionCanvas.d.ts +78 -39
  13. package/dist/types/excalidraw/actions/actionClipboard.d.ts +36 -18
  14. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +6 -3
  15. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +19 -10
  16. package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +1 -1
  17. package/dist/types/excalidraw/actions/actionElementLink.d.ts +6 -3
  18. package/dist/types/excalidraw/actions/actionElementLock.d.ts +12 -6
  19. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +6 -3
  20. package/dist/types/excalidraw/actions/actionExport.d.ts +54 -27
  21. package/dist/types/excalidraw/actions/actionFinalize.d.ts +12 -6
  22. package/dist/types/excalidraw/actions/actionFrame.d.ts +24 -12
  23. package/dist/types/excalidraw/actions/actionGroup.d.ts +12 -6
  24. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +6 -3
  25. package/dist/types/excalidraw/actions/actionLink.d.ts +4 -1
  26. package/dist/types/excalidraw/actions/actionMenu.d.ts +7 -372
  27. package/dist/types/excalidraw/actions/actionNavigate.d.ts +12 -6
  28. package/dist/types/excalidraw/actions/actionProperties.d.ts +91 -46
  29. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +6 -3
  30. package/dist/types/excalidraw/actions/actionStyles.d.ts +6 -3
  31. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +6 -3
  32. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +6 -3
  33. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +6 -3
  34. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +6 -3
  35. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +6 -3
  36. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +7 -4
  37. package/dist/types/excalidraw/actions/index.d.ts +1 -1
  38. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  39. package/dist/types/excalidraw/appState.d.ts +5 -2
  40. package/dist/types/excalidraw/components/Actions.d.ts +13 -3
  41. package/dist/types/excalidraw/components/App.d.ts +19 -17
  42. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +1 -2
  43. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
  44. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -1
  45. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -1
  46. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +1 -1
  47. package/dist/types/excalidraw/components/FilledButton.d.ts +1 -1
  48. package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +2 -1
  49. package/dist/types/excalidraw/components/HintViewer.d.ts +4 -3
  50. package/dist/types/excalidraw/components/LayerUI.d.ts +2 -1
  51. package/dist/types/excalidraw/components/MobileMenu.d.ts +3 -5
  52. package/dist/types/excalidraw/components/MobileToolBar.d.ts +11 -0
  53. package/dist/types/excalidraw/components/Popover.d.ts +2 -1
  54. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +1 -2
  55. package/dist/types/excalidraw/components/ToolPopover.d.ts +25 -0
  56. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +3 -2
  57. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +4 -2
  58. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +2 -1
  59. package/dist/types/excalidraw/components/icons.d.ts +5 -1
  60. package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +13 -1
  61. package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +0 -3
  62. package/dist/types/excalidraw/hooks/useOutsideClick.d.ts +3 -1
  63. package/dist/types/excalidraw/index.d.ts +2 -3
  64. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -1
  65. package/dist/types/excalidraw/scene/types.d.ts +3 -3
  66. package/dist/types/excalidraw/shortcut.d.ts +1 -0
  67. package/dist/types/excalidraw/types.d.ts +16 -17
  68. package/package.json +3 -3
@@ -1,9 +1,21 @@
1
1
  /// <reference types="react" />
2
+ import { type EditorInterface } from "@excalidraw/common";
2
3
  import "./LiveCollaborationTrigger.scss";
3
4
  declare const LiveCollaborationTrigger: {
4
- ({ isCollaborating, onSelect, ...rest }: {
5
+ ({ isCollaborating, onSelect, editorInterface, ...rest }: {
5
6
  isCollaborating: boolean;
6
7
  onSelect: () => void;
8
+ editorInterface?: Readonly<{
9
+ formFactor: "phone" | "tablet" | "desktop";
10
+ desktopUIMode: "compact" | "full";
11
+ userAgent: Readonly<{
12
+ isMobileDevice: boolean;
13
+ platform: "other" | "ios" | "android" | "unknown";
14
+ }>;
15
+ isTouchScreen: boolean;
16
+ canFitSidebar: boolean;
17
+ isLandscape: boolean;
18
+ }> | undefined;
7
19
  } & import("react").ButtonHTMLAttributes<HTMLButtonElement>): import("react/jsx-runtime").JSX.Element;
8
20
  displayName: string;
9
21
  };
@@ -25,9 +25,6 @@ declare const MainMenu: React.FC<{
25
25
  order?: number | undefined;
26
26
  onSelect?: ((event: Event) => void) | undefined;
27
27
  children: React.ReactNode;
28
- /**
29
- * Called when any menu item is selected (clicked on).
30
- */
31
28
  shortcut?: string | undefined;
32
29
  hovered?: boolean | undefined;
33
30
  selected?: boolean | undefined;
@@ -1,7 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  export declare function useOutsideClick<T extends HTMLElement>(ref: React.RefObject<T | null>,
3
3
  /** if performance is of concern, memoize the callback */
4
- callback: (event: Event) => void,
4
+ callback: (event: Event & {
5
+ target: T;
6
+ }) => void,
5
7
  /**
6
8
  * Optional callback which is called on every click.
7
9
  *
@@ -20,17 +20,16 @@ export { loadFromBlob, loadSceneOrLibraryFromBlob, loadLibraryFromBlob, } from "
20
20
  export { getFreeDrawSvgPath } from "@excalidraw/element";
21
21
  export { mergeLibraryItems, getLibraryItemsHash } from "./data/library";
22
22
  export { isLinearElement } from "@excalidraw/element";
23
- export { FONT_FAMILY, THEME, MIME_TYPES, ROUNDNESS, DEFAULT_LASER_COLOR, UserIdleState, normalizeLink, } from "@excalidraw/common";
23
+ export { FONT_FAMILY, THEME, MIME_TYPES, ROUNDNESS, DEFAULT_LASER_COLOR, UserIdleState, normalizeLink, sceneCoordsToViewportCoords, viewportCoordsToSceneCoords, getFormFactor, } from "@excalidraw/common";
24
24
  export { mutateElement, newElementWith, bumpVersion, } from "@excalidraw/element";
25
25
  export { CaptureUpdateAction } from "@excalidraw/element";
26
26
  export { parseLibraryTokensFromUrl, useHandleLibrary } from "./data/library";
27
- export { sceneCoordsToViewportCoords, viewportCoordsToSceneCoords, } from "@excalidraw/common";
28
27
  export { Sidebar } from "./components/Sidebar/Sidebar";
29
28
  export { Button } from "./components/Button";
30
29
  export { Footer };
31
30
  export { MainMenu };
32
31
  export { Ellipsify } from "./components/Ellipsify";
33
- export { useDevice } from "./components/App";
32
+ export { useEditorInterface, useStylesPanelMode } from "./components/App";
34
33
  export { WelcomeScreen };
35
34
  export { LiveCollaborationTrigger };
36
35
  export { Stats } from "./components/Stats";
@@ -9,7 +9,7 @@ export declare const renderInteractiveSceneThrottled: {
9
9
  * Interactive scene is the ui-canvas where we render bounding boxes, selections
10
10
  * and other ui stuff.
11
11
  */
12
- export declare const renderInteractiveScene: <U extends ({ canvas, elementsMap, visibleElements, selectedElements, allElementsMap, scale, appState, renderConfig, device, }: InteractiveSceneRenderConfig) => {
12
+ export declare const renderInteractiveScene: <U extends ({ canvas, elementsMap, visibleElements, selectedElements, allElementsMap, scale, appState, renderConfig, editorInterface, }: InteractiveSceneRenderConfig) => {
13
13
  atLeastOneVisibleElement: boolean;
14
14
  elementsMap: RenderableElementsMap;
15
15
  scrollBars?: undefined;
@@ -1,7 +1,7 @@
1
- import type { UserIdleState } from "@excalidraw/common";
1
+ import type { UserIdleState, EditorInterface } from "@excalidraw/common";
2
2
  import type { ExcalidrawElement, NonDeletedElementsMap, NonDeletedExcalidrawElement, NonDeletedSceneElementsMap } from "@excalidraw/element/types";
3
3
  import type { MakeBrand } from "@excalidraw/common/utility-types";
4
- import type { AppClassProperties, AppState, EmbedsValidationStatus, ElementsPendingErasure, InteractiveCanvasAppState, StaticCanvasAppState, SocketId, Device, PendingExcalidrawElements } from "../types";
4
+ import type { AppClassProperties, AppState, EmbedsValidationStatus, ElementsPendingErasure, InteractiveCanvasAppState, StaticCanvasAppState, SocketId, PendingExcalidrawElements } from "../types";
5
5
  import type { RoughCanvas } from "roughjs/bin/canvas";
6
6
  import type { Drawable } from "roughjs/bin/core";
7
7
  export type RenderableElementsMap = NonDeletedElementsMap & MakeBrand<"RenderableElementsMap">;
@@ -69,7 +69,7 @@ export type InteractiveSceneRenderConfig = {
69
69
  scale: number;
70
70
  appState: InteractiveCanvasAppState;
71
71
  renderConfig: InteractiveCanvasRenderConfig;
72
- device: Device;
72
+ editorInterface: EditorInterface;
73
73
  callback: (data: RenderInteractiveSceneCallback) => void;
74
74
  };
75
75
  export type NewElementSceneRenderConfig = {
@@ -0,0 +1 @@
1
+ export declare const getShortcutKey: (shortcut: string) => string;
@@ -1,4 +1,4 @@
1
- import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES } from "@excalidraw/common";
1
+ import type { IMAGE_MIME_TYPES, UserIdleState, throttleRAF, MIME_TYPES, EditorInterface } from "@excalidraw/common";
2
2
  import type { SuggestedBinding } from "@excalidraw/element";
3
3
  import type { LinearElementEditor } from "@excalidraw/element";
4
4
  import type { MaybeTransformHandleType } from "@excalidraw/element";
@@ -221,6 +221,10 @@ export interface AppState {
221
221
  locked: boolean;
222
222
  fromSelection: boolean;
223
223
  } & ActiveTool;
224
+ preferredSelectionTool: {
225
+ type: "selection" | "lasso";
226
+ initialized: boolean;
227
+ };
224
228
  penMode: boolean;
225
229
  penDetected: boolean;
226
230
  exportBackground: boolean;
@@ -251,7 +255,7 @@ export interface AppState {
251
255
  isResizing: boolean;
252
256
  isRotating: boolean;
253
257
  zoom: Zoom;
254
- openMenu: "canvas" | "shape" | null;
258
+ openMenu: "canvas" | null;
255
259
  openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | "compactTextProperties" | "compactStrokeStyles" | "compactOtherProperties" | "compactArrowProperties" | null;
256
260
  openSidebar: {
257
261
  name: SidebarName;
@@ -351,8 +355,6 @@ export interface AppState {
351
355
  lockedMultiSelections: {
352
356
  [groupId: string]: true;
353
357
  };
354
- /** properties sidebar mode - determines whether to show compact or complete sidebar */
355
- stylesPanelMode: "compact" | "full";
356
358
  }
357
359
  export type SearchMatch = {
358
360
  id: string;
@@ -443,6 +445,7 @@ export interface ExcalidrawProps {
443
445
  onDuplicate?: (nextElements: readonly ExcalidrawElement[],
444
446
  /** excludes the duplicated elements */
445
447
  prevElements: readonly ExcalidrawElement[]) => ExcalidrawElement[] | void;
448
+ renderTopLeftUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
446
449
  renderTopRightUI?: (isMobile: boolean, appState: UIAppState) => JSX.Element | null;
447
450
  langCode?: Language["code"];
448
451
  viewModeEnabled?: boolean;
@@ -500,6 +503,12 @@ export type UIOptions = Partial<{
500
503
  tools: {
501
504
  image: boolean;
502
505
  };
506
+ /**
507
+ * Optionally control the editor form factor and desktop UI mode from the host app.
508
+ * If not provided, we will take care of it internally.
509
+ */
510
+ formFactor?: EditorInterface["formFactor"];
511
+ desktopUIMode?: EditorInterface["desktopUIMode"];
503
512
  /** @deprecated does nothing. Will be removed in 0.15 */
504
513
  welcomeScreen?: boolean;
505
514
  }>;
@@ -530,7 +539,7 @@ export type AppClassProperties = {
530
539
  mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
531
540
  }>;
532
541
  files: BinaryFiles;
533
- device: App["device"];
542
+ editorInterface: App["editorInterface"];
534
543
  scene: App["scene"];
535
544
  syncActionResult: App["syncActionResult"];
536
545
  fonts: App["fonts"];
@@ -559,7 +568,7 @@ export type AppClassProperties = {
559
568
  excalidrawContainerValue: App["excalidrawContainerValue"];
560
569
  onPointerUpEmitter: App["onPointerUpEmitter"];
561
570
  updateEditorAtom: App["updateEditorAtom"];
562
- defaultSelectionTool: "selection" | "lasso";
571
+ onPointerDownEmitter: App["onPointerDownEmitter"];
563
572
  };
564
573
  export type PointerDownState = Readonly<{
565
574
  origin: Readonly<{
@@ -645,6 +654,7 @@ export interface ExcalidrawImperativeAPI {
645
654
  setCursor: InstanceType<typeof App>["setCursor"];
646
655
  resetCursor: InstanceType<typeof App>["resetCursor"];
647
656
  toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
657
+ getEditorInterface: () => EditorInterface;
648
658
  /**
649
659
  * Disables rendering of frames (including element clipping), but currently
650
660
  * the frames are still interactive in edit mode. As such, this API should be
@@ -658,17 +668,6 @@ export interface ExcalidrawImperativeAPI {
658
668
  onScrollChange: (callback: (scrollX: number, scrollY: number, zoom: Zoom) => void) => UnsubscribeCallback;
659
669
  onUserFollow: (callback: (payload: OnUserFollowedPayload) => void) => UnsubscribeCallback;
660
670
  }
661
- export type Device = Readonly<{
662
- viewport: {
663
- isMobile: boolean;
664
- isLandscape: boolean;
665
- };
666
- editor: {
667
- isMobile: boolean;
668
- canFitSidebar: boolean;
669
- };
670
- isTouchScreen: boolean;
671
- }>;
672
671
  export type FrameNameBounds = {
673
672
  x: number;
674
673
  y: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@excalidraw/element",
3
- "version": "0.18.0-ec07091",
3
+ "version": "0.18.0-f2600fe",
4
4
  "type": "module",
5
5
  "types": "./dist/types/element/src/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -57,7 +57,7 @@
57
57
  "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types"
58
58
  },
59
59
  "dependencies": {
60
- "@excalidraw/common": "0.18.0-ec07091",
61
- "@excalidraw/math": "0.18.0-ec07091"
60
+ "@excalidraw/common": "0.18.0-f2600fe",
61
+ "@excalidraw/math": "0.18.0-f2600fe"
62
62
  }
63
63
  }