@zsviczian/excalidraw 0.10.0-obsidian-38 → 0.10.0-obsidian-42

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 (39) hide show
  1. package/dist/excalidraw.development.js +72 -29
  2. package/dist/excalidraw.production.min.js +1 -1
  3. package/package.json +1 -1
  4. package/types/actions/actionAddToLibrary.d.ts +9 -15
  5. package/types/actions/actionCanvas.d.ts +45 -61
  6. package/types/actions/actionClipboard.d.ts +15 -25
  7. package/types/actions/actionDeleteSelected.d.ts +9 -15
  8. package/types/actions/actionExport.d.ts +27 -45
  9. package/types/actions/actionFinalize.d.ts +6 -10
  10. package/types/actions/actionMenu.d.ts +9 -15
  11. package/types/actions/actionProperties.d.ts +36 -60
  12. package/types/actions/actionStyles.d.ts +3 -5
  13. package/types/actions/actionToggleGridMode.d.ts +3 -5
  14. package/types/actions/actionToggleStats.d.ts +3 -5
  15. package/types/actions/actionToggleViewMode.d.ts +3 -5
  16. package/types/actions/actionToggleZenMode.d.ts +3 -5
  17. package/types/actions/actionUnbindText.d.ts +11 -0
  18. package/types/actions/index.d.ts +2 -0
  19. package/types/actions/shortcuts.d.ts +1 -1
  20. package/types/actions/types.d.ts +1 -1
  21. package/types/appState.d.ts +0 -5
  22. package/types/components/App.d.ts +10 -1
  23. package/types/components/LayerUI.d.ts +2 -2
  24. package/types/components/MobileMenu.d.ts +2 -2
  25. package/types/components/PenModeButton.d.ts +3 -3
  26. package/types/components/Tooltip.d.ts +7 -0
  27. package/types/components/icons.d.ts +1 -0
  28. package/types/constants.d.ts +1 -0
  29. package/types/element/Hyperlink.d.ts +117 -0
  30. package/types/element/collision.d.ts +1 -0
  31. package/types/element/linearElementEditor.d.ts +3 -6
  32. package/types/element/newElement.d.ts +3 -2
  33. package/types/element/textWysiwyg.d.ts +1 -3
  34. package/types/element/types.d.ts +1 -0
  35. package/types/keys.d.ts +1 -0
  36. package/types/renderer/renderElement.d.ts +1 -0
  37. package/types/scene/index.d.ts +1 -1
  38. package/types/scene/zoom.d.ts +12 -5
  39. package/types/types.d.ts +10 -10
@@ -168,4 +168,5 @@ export declare const TextAlignRightIcon: React.MemoExoticComponent<({ theme }: {
168
168
  theme: Theme;
169
169
  }) => JSX.Element>;
170
170
  export declare const publishIcon: JSX.Element;
171
+ export declare const editIcon: JSX.Element;
171
172
  export {};
@@ -98,6 +98,7 @@ export declare const TOAST_TIMEOUT = 5000;
98
98
  export declare const VERSION_TIMEOUT = 30000;
99
99
  export declare const SCROLL_TIMEOUT = 100;
100
100
  export declare const ZOOM_STEP = 0.1;
101
+ export declare const HYPERLINK_TOOLTIP_DELAY = 300;
101
102
  export declare const IDLE_THRESHOLD = 60000;
102
103
  export declare const ACTIVE_THRESHOLD = 3000;
103
104
  export declare const MODES: {
@@ -0,0 +1,117 @@
1
+ /// <reference types="react" />
2
+ import { AppState, ExcalidrawProps } from "../types";
3
+ import { NonDeletedExcalidrawElement } from "./types";
4
+ import { Bounds } from "./bounds";
5
+ import "./Hyperlink.scss";
6
+ export declare const EXTERNAL_LINK_IMG: HTMLImageElement;
7
+ export declare const Hyperlink: ({ element, appState, setAppState, onLinkOpen, }: {
8
+ element: NonDeletedExcalidrawElement;
9
+ appState: AppState;
10
+ setAppState: React.Component<any, AppState>["setState"];
11
+ onLinkOpen: ExcalidrawProps["onLinkOpen"];
12
+ }) => JSX.Element | null;
13
+ export declare const normalizeLink: (link: string) => string;
14
+ export declare const isLocalLink: (link: string | null) => boolean;
15
+ export declare const actionLink: {
16
+ name: "link";
17
+ perform: (elements: readonly import("./types").ExcalidrawElement[], appState: Readonly<AppState>) => false | {
18
+ elements: readonly import("./types").ExcalidrawElement[];
19
+ appState: {
20
+ showHyperlinkPopup: "editor";
21
+ isLoading: boolean;
22
+ errorMessage: string | null;
23
+ draggingElement: NonDeletedExcalidrawElement | null;
24
+ resizingElement: NonDeletedExcalidrawElement | null;
25
+ multiElement: import("./types").NonDeleted<import("./types").ExcalidrawLinearElement> | null;
26
+ selectionElement: NonDeletedExcalidrawElement | null;
27
+ isBindingEnabled: boolean;
28
+ startBoundElement: import("./types").NonDeleted<import("./types").ExcalidrawBindableElement> | null;
29
+ suggestedBindings: import("./binding").SuggestedBinding[];
30
+ editingElement: NonDeletedExcalidrawElement | null;
31
+ editingLinearElement: import("./linearElementEditor").LinearElementEditor | null;
32
+ elementType: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw";
33
+ elementLocked: boolean;
34
+ penMode: boolean;
35
+ penDetected: boolean;
36
+ exportBackground: boolean;
37
+ exportEmbedScene: boolean;
38
+ exportWithDarkMode: boolean;
39
+ exportScale: number;
40
+ currentItemStrokeColor: string;
41
+ currentItemBackgroundColor: string;
42
+ currentItemFillStyle: import("./types").FillStyle;
43
+ currentItemStrokeWidth: number;
44
+ currentItemStrokeStyle: import("./types").StrokeStyle;
45
+ currentItemRoughness: number;
46
+ currentItemOpacity: number;
47
+ currentItemFontFamily: number;
48
+ currentItemFontSize: number;
49
+ currentItemTextAlign: import("./types").TextAlign;
50
+ currentItemStrokeSharpness: import("./types").StrokeSharpness;
51
+ currentItemStartArrowhead: import("./types").Arrowhead | null;
52
+ currentItemEndArrowhead: import("./types").Arrowhead | null;
53
+ currentItemLinearStrokeSharpness: import("./types").StrokeSharpness;
54
+ viewBackgroundColor: string;
55
+ scrollX: number;
56
+ scrollY: number;
57
+ cursorButton: "up" | "down";
58
+ scrolledOutside: boolean;
59
+ name: string;
60
+ isResizing: boolean;
61
+ isRotating: boolean;
62
+ zoom: Readonly<{
63
+ value: import("../types").NormalizedZoomValue;
64
+ }>;
65
+ openMenu: "canvas" | "shape" | null;
66
+ openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
67
+ lastPointerDownWith: import("./types").PointerType;
68
+ selectedElementIds: {
69
+ [id: string]: boolean;
70
+ };
71
+ previousSelectedElementIds: {
72
+ [id: string]: boolean;
73
+ };
74
+ shouldCacheIgnoreZoom: boolean;
75
+ showHelpDialog: boolean;
76
+ toastMessage: string | null;
77
+ zenModeEnabled: boolean;
78
+ theme: string;
79
+ gridSize: number | null;
80
+ viewModeEnabled: boolean;
81
+ selectedGroupIds: {
82
+ [groupId: string]: boolean;
83
+ };
84
+ editingGroupId: string | null;
85
+ width: number;
86
+ height: number;
87
+ offsetTop: number;
88
+ offsetLeft: number;
89
+ isLibraryOpen: boolean;
90
+ fileHandle: import("browser-fs-access").FileSystemHandle | null;
91
+ collaborators: Map<string, import("../types").Collaborator>;
92
+ showStats: boolean;
93
+ currentChartType: import("./types").ChartType;
94
+ pasteDialog: {
95
+ shown: false;
96
+ data: null;
97
+ } | {
98
+ shown: true;
99
+ data: import("../charts").Spreadsheet;
100
+ };
101
+ pendingImageElement: import("./types").NonDeleted<import("./types").ExcalidrawImageElement> | null;
102
+ };
103
+ commitToHistory: true;
104
+ };
105
+ keyTest: (event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean;
106
+ contextItemLabel: (elements: readonly import("./types").ExcalidrawElement[], appState: Readonly<AppState>) => "labels.link.edit" | "labels.link.create";
107
+ contextItemPredicate: (elements: readonly import("./types").ExcalidrawElement[], appState: AppState) => boolean;
108
+ PanelComponent: ({ elements, appState, updateData }: import("react").PropsWithChildren<import("../actions/types").PanelComponentProps>) => JSX.Element;
109
+ } & {
110
+ keyTest?: ((event: KeyboardEvent | import("react").KeyboardEvent<Element>) => boolean) | undefined;
111
+ };
112
+ export declare const getContextMenuLabel: (elements: readonly NonDeletedExcalidrawElement[], appState: AppState) => "labels.link.edit" | "labels.link.create";
113
+ export declare const getLinkHandleFromCoords: ([x1, y1, x2, y2]: Bounds, angle: number, appState: AppState) => [x: number, y: number, width: number, height: number];
114
+ export declare const isPointHittingLinkIcon: (element: NonDeletedExcalidrawElement, appState: AppState, [x, y]: readonly [number, number]) => boolean;
115
+ export declare const showHyperlinkTooltip: (element: NonDeletedExcalidrawElement, appState: AppState) => void;
116
+ export declare const hideHyperlinkToolip: () => void;
117
+ export declare const shouldHideLinkPopup: (element: NonDeletedExcalidrawElement, appState: AppState, [clientX, clientY]: readonly [number, number]) => Boolean;
@@ -5,6 +5,7 @@ import { AppState } from "../types";
5
5
  export declare const hitTest: (element: NonDeletedExcalidrawElement, appState: AppState, x: number, y: number) => boolean;
6
6
  export declare const isHittingElementBoundingBoxWithoutHittingElement: (element: NonDeletedExcalidrawElement, appState: AppState, x: number, y: number) => boolean;
7
7
  export declare const isHittingElementNotConsideringBoundingBox: (element: NonDeletedExcalidrawElement, appState: AppState, point: readonly [number, number]) => boolean;
8
+ export declare const isPointHittingElementBoundingBox: (element: NonDeleted<ExcalidrawElement>, [x, y]: readonly [number, number], threshold: number) => boolean;
8
9
  export declare const bindingBorderTest: (element: NonDeleted<ExcalidrawBindableElement>, { x, y }: {
9
10
  x: number;
10
11
  y: number;
@@ -98,7 +98,8 @@ export declare class LinearElementEditor {
98
98
  editingElement: import("./types").NonDeletedExcalidrawElement | null;
99
99
  elementType: "line" | "arrow" | "text" | "selection" | "rectangle" | "diamond" | "ellipse" | "image" | "freedraw";
100
100
  elementLocked: boolean;
101
- penLocked: boolean;
101
+ penMode: boolean;
102
+ penDetected: boolean;
102
103
  exportBackground: boolean;
103
104
  exportEmbedScene: boolean;
104
105
  exportWithDarkMode: boolean;
@@ -127,10 +128,6 @@ export declare class LinearElementEditor {
127
128
  isRotating: boolean;
128
129
  zoom: Readonly<{
129
130
  value: import("../types").NormalizedZoomValue;
130
- translation: Readonly<{
131
- x: number;
132
- y: number;
133
- }>;
134
131
  }>;
135
132
  openMenu: "canvas" | "shape" | null;
136
133
  openPopup: "canvasColorPicker" | "backgroundColorPicker" | "strokeColorPicker" | null;
@@ -146,7 +143,6 @@ export declare class LinearElementEditor {
146
143
  toastMessage: string | null;
147
144
  zenModeEnabled: boolean;
148
145
  theme: string;
149
- /** @returns whether point was dragged */
150
146
  gridSize: number | null;
151
147
  viewModeEnabled: boolean;
152
148
  selectedGroupIds: {
@@ -170,6 +166,7 @@ export declare class LinearElementEditor {
170
166
  data: import("../charts").Spreadsheet;
171
167
  };
172
168
  pendingImageElement: NonDeleted<import("./types").ExcalidrawImageElement> | null;
169
+ showHyperlinkPopup: false | "info" | "editor";
173
170
  };
174
171
  };
175
172
  static deletePoints(element: NonDeleted<ExcalidrawLinearElement>, pointIndices: readonly number[]): void;
@@ -1,6 +1,6 @@
1
1
  import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, GroupId, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawRectangleElement } from "../element/types";
2
2
  import { AppState } from "../types";
3
- declare type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "boundElements" | "seed" | "version" | "versionNonce">;
3
+ declare type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "boundElements" | "seed" | "version" | "versionNonce" | "link">;
4
4
  export declare const newElement: (opts: {
5
5
  type: ExcalidrawGenericElement["type"];
6
6
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawGenericElement>;
@@ -13,11 +13,12 @@ export declare const newTextElement: (opts: {
13
13
  verticalAlign: VerticalAlign;
14
14
  containerId?: ExcalidrawRectangleElement["id"];
15
15
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
16
- export declare const updateTextElement: (element: ExcalidrawTextElement, { text, isDeleted, originalText, rawText, }: {
16
+ export declare const updateTextElement: (element: ExcalidrawTextElement, { text, isDeleted, originalText, rawText, link, }: {
17
17
  text: string;
18
18
  isDeleted?: boolean | undefined;
19
19
  originalText: string;
20
20
  rawText?: string | undefined;
21
+ link?: string | undefined;
21
22
  }) => ExcalidrawTextElement;
22
23
  export declare const newFreeDrawElement: (opts: {
23
24
  type: "freedraw";
@@ -1,9 +1,7 @@
1
1
  import { ExcalidrawElement, ExcalidrawTextElement } from "./types";
2
- import { AppState } from "../types";
3
2
  import App from "../components/App";
4
- export declare const textWysiwyg: ({ id, appState, onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, }: {
3
+ export declare const textWysiwyg: ({ id, onChange, onSubmit, getViewportCoords, element, canvas, excalidrawContainer, app, }: {
5
4
  id: ExcalidrawElement["id"];
6
- appState: AppState;
7
5
  onChange?: ((text: string) => void) | undefined;
8
6
  onSubmit: (data: {
9
7
  text: string;
@@ -50,6 +50,7 @@ declare type _ExcalidrawElementBase = Readonly<{
50
50
  }>[] | null;
51
51
  /** epoch (ms) timestamp of last element update */
52
52
  updated: number;
53
+ link: string | null;
53
54
  }>;
54
55
  export declare type ExcalidrawSelectionElement = _ExcalidrawElementBase & {
55
56
  type: "selection";
package/types/keys.d.ts CHANGED
@@ -58,6 +58,7 @@ export declare const KEYS: {
58
58
  readonly X: "x";
59
59
  readonly Y: "y";
60
60
  readonly Z: "z";
61
+ readonly K: "k";
61
62
  };
62
63
  export declare type Key = keyof typeof KEYS;
63
64
  export declare const isArrowKey: (key: string) => boolean;
@@ -12,6 +12,7 @@ export interface ExcalidrawElementWithCanvas {
12
12
  canvasOffsetX: number;
13
13
  canvasOffsetY: number;
14
14
  }
15
+ export declare const DEFAULT_LINK_SIZE = 14;
15
16
  export declare const getShapeForElement: (element: ExcalidrawElement) => Drawable | Drawable[] | null | undefined;
16
17
  export declare const invalidateShapeForElement: (element: ExcalidrawElement) => boolean;
17
18
  export declare const generateRoughOptions: (element: ExcalidrawElement, continuousPath?: boolean) => Options;
@@ -2,4 +2,4 @@ export { isOverScrollBars } from "./scrollbars";
2
2
  export { isSomeElementSelected, getElementsWithinSelection, getCommonAttributeOfSelectedElements, getSelectedElements, getTargetElements, } from "./selection";
3
3
  export { calculateScrollCenter } from "./scroll";
4
4
  export { hasBackground, hasStrokeWidth, hasStrokeStyle, canHaveArrowheads, canChangeSharpness, getElementAtPosition, getElementContainingPosition, hasText, getElementsAtPosition, } from "./comparisons";
5
- export { getNormalizedZoom, getNewZoom } from "./zoom";
5
+ export { getNormalizedZoom } from "./zoom";
@@ -1,6 +1,13 @@
1
- import { NormalizedZoomValue, PointerCoords, Zoom } from "../types";
2
- export declare const getNewZoom: (newZoomValue: NormalizedZoomValue, prevZoom: Zoom, canvasOffset: {
3
- left: number;
4
- top: number;
5
- }, zoomOnViewportPoint?: PointerCoords) => Zoom;
1
+ import { AppState, NormalizedZoomValue } from "../types";
6
2
  export declare const getNormalizedZoom: (zoom: number) => NormalizedZoomValue;
3
+ export declare const getStateForZoom: ({ viewportX, viewportY, nextZoom, }: {
4
+ viewportX: number;
5
+ viewportY: number;
6
+ nextZoom: NormalizedZoomValue;
7
+ }, appState: AppState) => {
8
+ scrollX: number;
9
+ scrollY: number;
10
+ zoom: {
11
+ value: NormalizedZoomValue;
12
+ };
13
+ };
package/types/types.d.ts CHANGED
@@ -55,7 +55,8 @@ export declare type AppState = {
55
55
  editingLinearElement: LinearElementEditor | null;
56
56
  elementType: typeof SHAPES[number]["value"];
57
57
  elementLocked: boolean;
58
- penLocked: boolean;
58
+ penMode: boolean;
59
+ penDetected: boolean;
59
60
  exportBackground: boolean;
60
61
  exportEmbedScene: boolean;
61
62
  exportWithDarkMode: boolean;
@@ -124,16 +125,13 @@ export declare type AppState = {
124
125
  };
125
126
  /** imageElement waiting to be placed on canvas */
126
127
  pendingImageElement: NonDeleted<ExcalidrawImageElement> | null;
128
+ showHyperlinkPopup: false | "info" | "editor";
127
129
  };
128
130
  export declare type NormalizedZoomValue = number & {
129
131
  _brand: "normalizedZoom";
130
132
  };
131
133
  export declare type Zoom = Readonly<{
132
134
  value: NormalizedZoomValue;
133
- translation: Readonly<{
134
- x: number;
135
- y: number;
136
- }>;
137
135
  }>;
138
136
  export declare type PointerCoords = Readonly<{
139
137
  x: number;
@@ -203,9 +201,10 @@ export interface ExcalidrawProps {
203
201
  onLibraryChange?: (libraryItems: LibraryItems) => void | Promise<any>;
204
202
  autoFocus?: boolean;
205
203
  onBeforeTextEdit?: (textElement: ExcalidrawTextElement) => string;
206
- onBeforeTextSubmit?: (textElement: ExcalidrawTextElement, textToSubmit: string, originalText: string, isDeleted: boolean) => [string, string];
204
+ onBeforeTextSubmit?: (textElement: ExcalidrawTextElement, textToSubmit: string, originalText: string, isDeleted: boolean) => [string, string, string];
207
205
  generateIdForFile?: (file: File) => string | Promise<string>;
208
206
  onThemeChange?: (newTheme: string) => void;
207
+ onLinkOpen?: (link: string, event: MouseEvent) => void;
209
208
  }
210
209
  export declare type SceneData = {
211
210
  elements?: ImportedDataState["elements"];
@@ -334,9 +333,10 @@ export declare type ExcalidrawImperativeAPI = {
334
333
  ready: true;
335
334
  id: string;
336
335
  setLocalFont: (showOnPanel: boolean) => void;
337
- sendBackward: (elements: ExcalidrawElement[]) => void;
338
- bringForward: (elements: ExcalidrawElement[]) => void;
339
- sendToBack: (elements: ExcalidrawElement[]) => void;
340
- bringToFront: (elements: ExcalidrawElement[]) => void;
336
+ selectElements: (elements: readonly ExcalidrawElement[]) => void;
337
+ sendBackward: (elements: readonly ExcalidrawElement[]) => void;
338
+ bringForward: (elements: readonly ExcalidrawElement[]) => void;
339
+ sendToBack: (elements: readonly ExcalidrawElement[]) => void;
340
+ bringToFront: (elements: readonly ExcalidrawElement[]) => void;
341
341
  };
342
342
  export {};