@myoc/excalidraw 0.19.535 → 0.19.536

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.
@@ -1 +1 @@
1
- import{a,b,c,d}from"./chunk-Z5NKEFVG.js";import"./chunk-PLDSWNV5.js";import"./chunk-SRAX5OIU.js";export{a as Commands,b as subsetToBase64,c as subsetToBinary,d as toBase64};
1
+ import{a,b,c,d}from"./chunk-Z5NKEFVG.js";import"./chunk-U2M5DXIZ.js";import"./chunk-SRAX5OIU.js";export{a as Commands,b as subsetToBase64,c as subsetToBinary,d as toBase64};
@@ -1 +1 @@
1
- import{a as r,c as t}from"./chunk-Z5NKEFVG.js";import"./chunk-PLDSWNV5.js";import"./chunk-SRAX5OIU.js";var s=import.meta.url?new URL(import.meta.url):void 0;typeof window>"u"&&typeof self<"u"&&(self.onmessage=async e=>{switch(e.data.command){case r.Subset:let a=await t(e.data.arrayBuffer,e.data.codePoints);self.postMessage(a,{transfer:[a]});break}});export{s as WorkerUrl};
1
+ import{a as r,c as t}from"./chunk-Z5NKEFVG.js";import"./chunk-U2M5DXIZ.js";import"./chunk-SRAX5OIU.js";var s=import.meta.url?new URL(import.meta.url):void 0;typeof window>"u"&&typeof self<"u"&&(self.onmessage=async e=>{switch(e.data.command){case r.Subset:let a=await t(e.data.arrayBuffer,e.data.codePoints);self.postMessage(a,{transfer:[a]});break}});export{s as WorkerUrl};
@@ -168,6 +168,7 @@ export declare const actionDeselect: {
168
168
  captureUpdate: "IMMEDIATELY";
169
169
  };
170
170
  keyTest: (event: import("react").KeyboardEvent<Element> | KeyboardEvent, appState: AppState, _: readonly import("@excalidraw/element/types").ExcalidrawElement[], app: AppClassProperties) => boolean;
171
+ keyCondition: (event: import("react").KeyboardEvent<Element> | KeyboardEvent, appState: AppState, _: readonly import("@excalidraw/element/types").ExcalidrawElement[], app: AppClassProperties) => boolean;
171
172
  } & {
172
173
  keyTest?: ((event: import("react").KeyboardEvent<Element> | KeyboardEvent, appState: AppState, _: readonly import("@excalidraw/element/types").ExcalidrawElement[], app: AppClassProperties) => boolean) | undefined;
173
174
  };
@@ -187,6 +187,7 @@ export declare const actionToggleElementLock: {
187
187
  captureUpdate: "IMMEDIATELY";
188
188
  };
189
189
  keyTest: (event: import("react").KeyboardEvent<Element> | KeyboardEvent, appState: AppState, elements: readonly ExcalidrawElement[], app: import("../types").AppClassProperties) => boolean;
190
+ keyCondition: (_event: import("react").KeyboardEvent<Element> | KeyboardEvent, appState: AppState, _elements: readonly ExcalidrawElement[], app: import("../types").AppClassProperties) => boolean;
190
191
  } & {
191
192
  keyTest?: ((event: import("react").KeyboardEvent<Element> | KeyboardEvent, appState: AppState, elements: readonly ExcalidrawElement[], app: import("../types").AppClassProperties) => boolean) | undefined;
192
193
  };
@@ -33,6 +33,8 @@ export interface Action<TData = any> {
33
33
  perform: ActionFn<TData>;
34
34
  keyPriority?: number;
35
35
  keyTest?: (event: React.KeyboardEvent | KeyboardEvent, appState: AppState, elements: readonly ExcalidrawElement[], app: AppClassProperties) => boolean;
36
+ /** Additional state guard retained when a host overrides `keyTest`'s keys. */
37
+ keyCondition?: (event: React.KeyboardEvent | KeyboardEvent, appState: AppState, elements: readonly ExcalidrawElement[], app: AppClassProperties) => boolean;
36
38
  predicate?: (elements: readonly ExcalidrawElement[], appState: AppState, appProps: ExcalidrawProps, app: AppClassProperties) => boolean;
37
39
  checked?: (appState: Readonly<UIAppState>) => boolean;
38
40
  trackEvent: false | {
@@ -560,6 +560,7 @@ declare class App extends React.Component<AppProps, AppState> {
560
560
  force?: boolean;
561
561
  }) => boolean;
562
562
  private updateCurrentCursorPosition;
563
+ private matchesShortcut;
563
564
  private onKeyDown;
564
565
  private onKeyUp;
565
566
  setActiveTool: (tool: ({
@@ -51,6 +51,7 @@ export declare const getToolLetter: (type: ToolbarToolType) => string | undefine
51
51
  /** human-readable shortcut hint, e.g. "R", used in tooltips & aria */
52
52
  export declare const getToolShortcut: (type: ToolbarToolType) => string | undefined;
53
53
  export declare const findShapeByKey: (key: string, app: AppClassProperties, shiftKey?: boolean) => "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "lasso" | "eraser" | "hand" | "laser" | "autoshape" | "bucketfill" | null;
54
+ export declare const findShapeByKeyboardEvent: (event: KeyboardEvent | React.KeyboardEvent, app: AppClassProperties) => "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "image" | "frame" | "freedraw" | "lasso" | "eraser" | "hand" | "laser" | "autoshape" | "bucketfill" | null;
54
55
  /**
55
56
  * Whether a toolbar entry activating the given tool renders disabled — true
56
57
  * when the active tool is host-controlled (`props.activeTool`) and the entry
@@ -44,6 +44,7 @@ export { LiveCollaborationTrigger };
44
44
  export { Stats } from "./components/Stats";
45
45
  export { DefaultSidebar } from "./components/DefaultSidebar";
46
46
  export type { ViewportStatusFrame } from "./types";
47
+ export type { KeyboardShortcut, KeyboardShortcutCommand, KeyboardShortcutOverrides, } from "./keyboardShortcuts";
47
48
  export { zoomToFitBounds, DEFAULT_OVERSCROLL } from "./viewport";
48
49
  export { getCommonBounds, getVisibleSceneBounds, convertToExcalidrawElements, } from "@excalidraw/element";
49
50
  export { elementsOverlappingBBox } from "@excalidraw/element";
@@ -0,0 +1,27 @@
1
+ import type { ActionName } from "./actions/types";
2
+ type KeyboardShortcutModifiers = {
3
+ ctrlOrCmd?: boolean;
4
+ ctrl?: boolean;
5
+ meta?: boolean;
6
+ alt?: boolean;
7
+ shift?: boolean;
8
+ };
9
+ export type KeyboardShortcut = KeyboardShortcutModifiers & ({
10
+ /** `KeyboardEvent.key` (case-insensitive for single letters). */
11
+ key: string;
12
+ code?: never;
13
+ } | {
14
+ /** `KeyboardEvent.code`, useful for layout-independent shortcuts. */
15
+ code: string;
16
+ key?: never;
17
+ });
18
+ export type KeyboardShortcutCommand = ActionName | `tool:${"hand" | "selection" | "rectangle" | "diamond" | "ellipse" | "arrow" | "line" | "freedraw" | "text" | "image" | "eraser" | "frame" | "autoshape" | "embeddable" | "laser" | "bucketfill" | "lasso"}` | "toolLock" | "strokeEyeDropper" | "backgroundEyeDropper" | "helpDialog" | "imageExport" | "elementStroke" | "elementBackground" | "fontFamily";
19
+ /**
20
+ * A partial, controlled set of shortcut overrides. Missing commands retain
21
+ * Excalidraw's defaults; an empty array explicitly disables a command.
22
+ */
23
+ export type KeyboardShortcutOverrides = Partial<Record<KeyboardShortcutCommand, readonly KeyboardShortcut[]>>;
24
+ export declare const matchesKeyboardShortcut: (event: Pick<KeyboardEvent, "key" | "code" | "ctrlKey" | "metaKey" | "altKey" | "shiftKey">, shortcut: KeyboardShortcut) => boolean;
25
+ export declare const matchesKeyboardShortcuts: (event: Parameters<typeof matchesKeyboardShortcut>[0], shortcuts: readonly KeyboardShortcut[]) => boolean;
26
+ export declare const formatKeyboardShortcut: (shortcut: KeyboardShortcut) => string;
27
+ export {};
@@ -687,6 +687,12 @@ export type UIConfig = {
687
687
  };
688
688
  export interface ExcalidrawProps {
689
689
  className?: string;
690
+ /**
691
+ * Controlled keyboard shortcut overrides. Omitted commands retain their
692
+ * Excalidraw defaults; pass an empty array to disable a command. Excalidraw
693
+ * does not persist this value.
694
+ */
695
+ keyboardShortcuts?: import("./keyboardShortcuts").KeyboardShortcutOverrides;
690
696
  onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
691
697
  onThemeChange?: (theme: Theme | "system") => void;
692
698
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myoc/excalidraw",
3
- "version": "0.19.535",
3
+ "version": "0.19.536",
4
4
  "type": "module",
5
5
  "types": "./dist/types/excalidraw/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -82,10 +82,10 @@
82
82
  },
83
83
  "dependencies": {
84
84
  "@braintree/sanitize-url": "6.0.2",
85
- "@excalidraw/common": "npm:@myoc/common@0.19.535",
86
- "@excalidraw/element": "npm:@myoc/element@0.19.535",
85
+ "@excalidraw/common": "npm:@myoc/common@0.19.536",
86
+ "@excalidraw/element": "npm:@myoc/element@0.19.536",
87
87
  "@excalidraw/laser-pointer": "1.3.1",
88
- "@excalidraw/math": "npm:@myoc/math@0.19.535",
88
+ "@excalidraw/math": "npm:@myoc/math@0.19.536",
89
89
  "@excalidraw/random-username": "1.1.0",
90
90
  "@lezer/highlight": "^1.0.0",
91
91
  "browser-fs-access": "0.38.0",
@@ -1 +0,0 @@
1
- import{U as a,V as b,W as c}from"../chunk-N4AOPKJK.js";import"../chunk-PLDSWNV5.js";import"../chunk-SRAX5OIU.js";export{c as decodePngMetadata,b as encodePngMetadata,a as getTEXtChunk};