@myoc/element 0.19.527 → 0.19.529

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.
@@ -14,7 +14,7 @@ export type ActionResult = {
14
14
  type ActionFn<TData = any> = (elements: readonly OrderedExcalidrawElement[], appState: Readonly<AppState>, formData: TData | undefined, app: AppClassProperties) => ActionResult | Promise<ActionResult>;
15
15
  export type UpdaterFn = (res: ActionResult) => void;
16
16
  export type ActionFilterFn = (action: Action) => void;
17
- export type ActionName = "copy" | "cut" | "paste" | "copyAsPng" | "copyAsSvg" | "copyText" | "sendBackward" | "bringForward" | "sendToBack" | "bringToFront" | "copyStyles" | "selectAll" | "pasteStyles" | "gridMode" | "objectsSnapMode" | "arrowBinding" | "midpointSnapping" | "stats" | "changeStrokeColor" | "changeBackgroundColor" | "changeBucketFillBackgroundColor" | "changeFillStyle" | "changeStrokeWidth" | "changeSloppiness" | "changeFreedrawMode" | "changeStrokeStyle" | "changeArrowhead" | "changeArrowType" | "changeArrowProperties" | "changeOpacity" | "changeFontSize" | "undo" | "redo" | "finalize" | "changeProjectName" | "changeExportBackground" | "changeExportEmbedScene" | "changeExportScale" | "saveToActiveFile" | "saveFileToDisk" | "loadScene" | "duplicateSelection" | "deleteSelectedElements" | "changeViewBackgroundColor" | "zoomIn" | "zoomOut" | "resetZoom" | "zoomToFit" | "zoomToFitSelection" | "zoomToFitSelectionInViewport" | "changeFontFamily" | "changeTextAlign" | "changeVerticalAlign" | "toggleFullScreen" | "toggleShortcuts" | "group" | "ungroup" | "goToCollaborator" | "changeRoundness" | "alignTop" | "alignBottom" | "alignLeft" | "alignRight" | "alignVerticallyCentered" | "alignHorizontallyCentered" | "distributeHorizontally" | "distributeVertically" | "arrangeElements" | "normaliseElements" | "flipHorizontal" | "flipVertical" | "deselect" | "viewMode" | "exportWithDarkMode" | "toggleTheme" | "increaseFontSize" | "decreaseFontSize" | "unbindText" | "hyperlink" | "bindText" | "unlockAllElements" | "toggleElementLock" | "toggleLinearEditor" | "selectAllElementsInFrame" | "removeAllElementsFromFrame" | "updateFrameRendering" | "createContainerFromText" | "wrapTextInContainer" | "autoResize" | "elementStats" | "searchMenu" | "copyElementLink" | "linkToElement" | "cropEditor" | "wrapSelectionInFrame" | "smartZoom" | "toggleLassoTool" | "toggleShapeSwitch" | "togglePolygon";
17
+ export type ActionName = "copy" | "cut" | "paste" | "copyAsPng" | "copyAsSvg" | "copyText" | "sendBackward" | "bringForward" | "sendToBack" | "bringToFront" | "copyStyles" | "selectAll" | "pasteStyles" | "gridMode" | "objectsSnapMode" | "arrowBinding" | "midpointSnapping" | "stats" | "changeStrokeColor" | "changeBackgroundColor" | "changeBucketFillBackgroundColor" | "changeFillStyle" | "changeStrokeWidth" | "changeSloppiness" | "changeFreedrawMode" | "changeStrokeStyle" | "changeArrowhead" | "changeArrowType" | "changeArrowProperties" | "changeOpacity" | "changeFontSize" | "undo" | "redo" | "finalize" | "changeProjectName" | "changeExportBackground" | "changeExportEmbedScene" | "changeExportScale" | "saveToActiveFile" | "saveFileToDisk" | "loadScene" | "duplicateSelection" | "deleteSelectedElements" | "changeViewBackgroundColor" | "zoomIn" | "zoomOut" | "resetZoom" | "zoomToFit" | "zoomToFitSelection" | "zoomToFitSelectionInViewport" | "changeFontFamily" | "changeTextAlign" | "changeVerticalAlign" | "toggleFullScreen" | "toggleShortcuts" | "group" | "ungroup" | "goToCollaborator" | "changeRoundness" | "alignTop" | "alignBottom" | "alignLeft" | "alignRight" | "alignVerticallyCentered" | "alignHorizontallyCentered" | "distributeHorizontally" | "distributeVertically" | "arrangeElements" | "normaliseElements" | "flipHorizontal" | "flipVertical" | "deselect" | "viewMode" | "exportWithDarkMode" | "toggleTheme" | "increaseFontSize" | "decreaseFontSize" | "unbindText" | "hyperlink" | "bindText" | "unlockAllElements" | "toggleElementLock" | "toggleLinearEditor" | "selectAllElementsInFrame" | "removeAllElementsFromFrame" | "updateFrameRendering" | "createContainerFromText" | "wrapTextInContainer" | "autoResize" | "elementStats" | "searchMenu" | "linkToElement" | "cropEditor" | "wrapSelectionInFrame" | "smartZoom" | "toggleLassoTool" | "toggleShapeSwitch" | "togglePolygon";
18
18
  export type PanelComponentProps = {
19
19
  elements: readonly ExcalidrawElement[];
20
20
  appState: UIAppState;
@@ -457,6 +457,8 @@ declare class App extends React.Component<AppProps, AppState> {
457
457
  private onTouchStart;
458
458
  private onTouchEnd;
459
459
  private insertClipboardContent;
460
+ private containsImagePaste;
461
+ private shouldInsertImageInViewMode;
460
462
  pasteFromClipboard: (event: ClipboardEvent) => Promise<void>;
461
463
  addElementsFromPasteOrLibrary: (opts: {
462
464
  elements: readonly ExcalidrawElement[];
@@ -773,7 +775,9 @@ declare class App extends React.Component<AppProps, AppState> {
773
775
  private getImageStatusActionAtPosition;
774
776
  private isPointInsideImageStatusOverlay;
775
777
  private getElementLinkAtPosition;
778
+ private getElementLinkAtPositionForContextMenu;
776
779
  private handleElementLinkClick;
780
+ private openElementLink;
777
781
  /**
778
782
  * Applies (or clears) the element-link hover affordances — pointer cursor
779
783
  * and tooltip — based on the current `hitLinkElement`. Returns whether a
@@ -902,6 +906,7 @@ declare class App extends React.Component<AppProps, AppState> {
902
906
  private maybeHandleCrop;
903
907
  private maybeHandleResize;
904
908
  private getImageContextMenuItems;
909
+ private getElementLinkContextMenuItems;
905
910
  private getContextMenuItems;
906
911
  private handleWheel;
907
912
  getTextWysiwygSnappedToCenterPosition(x: number, y: number, appState: AppState, container?: ExcalidrawTextContainer | null): {
@@ -723,6 +723,24 @@ export interface ExcalidrawProps {
723
723
  pointersMap: Gesture["pointers"];
724
724
  }) => void;
725
725
  onPaste?: (data: ClipboardData, event: ClipboardEvent | null) => Promise<boolean> | boolean;
726
+ /**
727
+ * Controls image paste/drop while the editor is in view mode and not
728
+ * `viewModeOnly`.
729
+ *
730
+ * - `exit-view-mode`: leave view mode and insert the image.
731
+ * - `reject`: keep view mode and call `onViewModeImageInsertRejected`.
732
+ *
733
+ * `viewModeOnly` always rejects because view mode is forced.
734
+ *
735
+ * @default "exit-view-mode"
736
+ */
737
+ viewModeImageInsertBehavior?: "exit-view-mode" | "reject";
738
+ onViewModeImageInsertRejected?: (payload: {
739
+ source: "paste" | "drop";
740
+ files: readonly File[];
741
+ data?: ClipboardData;
742
+ event: ClipboardEvent | React.DragEvent<HTMLDivElement> | null;
743
+ }) => void;
726
744
  /**
727
745
  * Called when element(s) are duplicated so you can listen or modify as
728
746
  * needed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myoc/element",
3
- "version": "0.19.527",
3
+ "version": "0.19.529",
4
4
  "type": "module",
5
5
  "types": "./dist/types/element/src/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -64,9 +64,9 @@
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.527",
68
- "@excalidraw/fractional-indexing": "npm:@myoc/fractional-indexing@0.19.527",
69
- "@excalidraw/math": "npm:@myoc/math@0.19.527",
67
+ "@excalidraw/common": "npm:@myoc/common@0.19.529",
68
+ "@excalidraw/fractional-indexing": "npm:@myoc/fractional-indexing@0.19.529",
69
+ "@excalidraw/math": "npm:@myoc/math@0.19.529",
70
70
  "thumbhash": "0.1.1"
71
71
  }
72
72
  }
@@ -1,212 +0,0 @@
1
- export declare const actionCopyElementLink: {
2
- name: "copyElementLink";
3
- label: string;
4
- icon: import("react/jsx-runtime").JSX.Element;
5
- trackEvent: {
6
- category: "element";
7
- };
8
- perform: (elements: readonly import("@excalidraw/element/types").OrderedExcalidrawElement[], appState: Readonly<import("../types").AppState>, _: unknown, app: import("../types").AppClassProperties) => Promise<{
9
- appState: {
10
- toast: {
11
- message: string;
12
- closable: true;
13
- };
14
- };
15
- captureUpdate: "EVENTUALLY";
16
- elements?: undefined;
17
- app?: undefined;
18
- } | {
19
- appState: Readonly<import("../types").AppState>;
20
- elements: readonly import("@excalidraw/element/types").OrderedExcalidrawElement[];
21
- app: import("../types").AppClassProperties;
22
- captureUpdate: "EVENTUALLY";
23
- }>;
24
- predicate: (elements: readonly import("@excalidraw/element/types").ExcalidrawElement[], appState: import("../types").AppState) => boolean;
25
- } & {
26
- keyTest?: undefined;
27
- };
28
- export declare const actionLinkToElement: {
29
- name: "linkToElement";
30
- label: string;
31
- icon: import("react/jsx-runtime").JSX.Element;
32
- perform: (elements: readonly import("@excalidraw/element/types").OrderedExcalidrawElement[], appState: Readonly<import("../types").AppState>, _: unknown, app: import("../types").AppClassProperties) => {
33
- elements: readonly import("@excalidraw/element/types").OrderedExcalidrawElement[];
34
- appState: Readonly<import("../types").AppState>;
35
- app: import("../types").AppClassProperties;
36
- captureUpdate: "EVENTUALLY";
37
- } | {
38
- appState: {
39
- openDialog: {
40
- name: "elementLinkSelector";
41
- sourceElementId: string;
42
- };
43
- contextMenu: {
44
- items: import("../components/ContextMenu").ContextMenuItems;
45
- top: number;
46
- left: number;
47
- } | null;
48
- showWelcomeScreen: boolean;
49
- isLoading: boolean;
50
- myocSimplifiedMode: boolean;
51
- dontResizeLimitMBs: number;
52
- hideMainMenus: boolean;
53
- wheelZoomsOnDefault?: boolean;
54
- arrangeConfiguration: {
55
- algorithm: import("@excalidraw/element/types").ArrangeAlgorithms;
56
- gap: number;
57
- };
58
- normaliseConfiguration: {
59
- mode: import("../types").NormaliseMode;
60
- metric: import("../types").NormaliseMetric;
61
- };
62
- errorMessage: React.ReactNode;
63
- activeEmbeddable: {
64
- element: import("@excalidraw/element/types").NonDeletedExcalidrawElement;
65
- state: "hover" | "active";
66
- } | null;
67
- newElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawNonSelectionElement> | null;
68
- resizingElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
69
- multiElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawLinearElement> | null;
70
- selectionElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
71
- isBindingEnabled: boolean;
72
- boxSelectionMode: import("../types").BoxSelectionMode;
73
- bindingPreference: "enabled" | "disabled";
74
- isMidpointSnappingEnabled: boolean;
75
- suggestedBinding: {
76
- element: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement>;
77
- midPoint?: import("@excalidraw/math").GlobalPoint;
78
- } | null;
79
- hoveredArrowTextAnchor: {
80
- elementId: import("@excalidraw/element/types").ExcalidrawArrowElement["id"];
81
- anchor: "start" | "end" | "label";
82
- } | null;
83
- frameToHighlight: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawFrameLikeElement> | null;
84
- frameRendering: {
85
- enabled: boolean;
86
- name: boolean;
87
- outline: boolean;
88
- clip: boolean;
89
- };
90
- editingFrame: import("@excalidraw/element/types").ExcalidrawFrameLikeElement["id"] | null;
91
- elementsToHighlight: readonly import("@excalidraw/element/types").NonDeletedExcalidrawElement[] | null;
92
- editingTextElement: import("@excalidraw/element/types").ExcalidrawTextElement | null;
93
- activeTool: {
94
- lastActiveTool: import("../types").ActiveTool | null;
95
- locked: boolean;
96
- fromSelection: boolean;
97
- } & import("../types").ActiveTool;
98
- preferredSelectionTool: {
99
- type: "selection" | "lasso";
100
- initialized: boolean;
101
- };
102
- penMode: boolean;
103
- penDetected: boolean;
104
- exportBackground: boolean;
105
- exportEmbedScene: boolean;
106
- exportWithDarkMode: boolean;
107
- exportScale: number;
108
- currentItemStrokeColor: string;
109
- currentItemBackgroundColor: string;
110
- currentItemFillStyle: import("@excalidraw/element/types").ExcalidrawElement["fillStyle"];
111
- currentItemStrokeWidthKey: import("@excalidraw/common").StrokeWidthKey;
112
- currentItemStrokeStyle: import("@excalidraw/element/types").ExcalidrawElement["strokeStyle"];
113
- currentItemRoughness: number;
114
- currentItemStrokeVariability: import("@excalidraw/element/types").StrokeVariability;
115
- currentItemOpacity: number;
116
- currentItemFontFamily: import("@excalidraw/element/types").FontFamilyValues;
117
- currentItemFontSize: number;
118
- currentItemTextAlign: import("@excalidraw/element/types").TextAlign;
119
- currentItemStartArrowhead: import("@excalidraw/element/types").Arrowhead | null;
120
- currentItemEndArrowhead: import("@excalidraw/element/types").Arrowhead | null;
121
- currentHoveredFontFamily: import("@excalidraw/element/types").FontFamilyValues | null;
122
- currentItemRoundness: import("@excalidraw/element/types").StrokeRoundness;
123
- currentItemArrowType: "sharp" | "round" | "elbow";
124
- viewBackgroundColor: string;
125
- scrollX: number;
126
- scrollY: number;
127
- scrollConstraints: import("../types").ScrollConstraints | null;
128
- cursorButton: "up" | "down";
129
- scrolledOutside: boolean;
130
- name: string | null;
131
- isResizing: boolean;
132
- isRotating: boolean;
133
- zoom: import("../types").Zoom;
134
- openMenu: "canvas" | null;
135
- openPopup: "canvasBackground" | "elementBackground" | "elementStroke" | "fontFamily" | "compactTextProperties" | "compactStrokeStyles" | "compactOtherProperties" | "compactArrowProperties" | null;
136
- openSidebar: {
137
- name: import("../types").SidebarName;
138
- tab?: import("../types").SidebarTabName;
139
- } | null;
140
- defaultSidebarDockedPreference: boolean;
141
- lastPointerDownWith: import("@excalidraw/element/types").PointerType;
142
- selectedElementIds: Readonly<{
143
- [id: string]: true;
144
- }>;
145
- hoveredElementIds: Readonly<{
146
- [id: string]: true;
147
- }>;
148
- previousSelectedElementIds: {
149
- [id: string]: true;
150
- };
151
- selectedElementsAreBeingDragged: boolean;
152
- shouldCacheIgnoreZoom: boolean;
153
- toast: {
154
- message: React.ReactNode;
155
- closable?: boolean;
156
- duration?: number;
157
- } | null;
158
- zenModeEnabled: boolean;
159
- theme: import("@excalidraw/element/types").Theme;
160
- gridSize: number;
161
- gridStep: number;
162
- gridModeEnabled: boolean;
163
- viewModeEnabled: boolean;
164
- viewModeOnly: boolean;
165
- selectedGroupIds: {
166
- [groupId: string]: boolean;
167
- };
168
- editingGroupId: import("@excalidraw/element/types").GroupId | null;
169
- width: number;
170
- height: number;
171
- offsetTop: number;
172
- offsetLeft: number;
173
- fileHandle: FileSystemFileHandle | null;
174
- collaborators: Map<import("../types").SocketId, import("../types").Collaborator>;
175
- stats: {
176
- open: boolean;
177
- panels: number;
178
- };
179
- showHyperlinkPopup: false | "info" | "editor";
180
- selectedLinearElement: import("@excalidraw/element").LinearElementEditor | null;
181
- snapLines: readonly import("../snapping").SnapLine[];
182
- originSnapOffset: {
183
- x: number;
184
- y: number;
185
- } | null;
186
- objectsSnapModeEnabled: boolean;
187
- isCropping: boolean;
188
- croppingElementId: import("@excalidraw/element/types").ExcalidrawElement["id"] | null;
189
- searchMatches: Readonly<{
190
- focusedId: import("@excalidraw/element/types").ExcalidrawElement["id"] | null;
191
- matches: readonly import("../types").SearchMatch[];
192
- }> | null;
193
- activeLockedId: string | null;
194
- lockedMultiSelections: {
195
- [groupId: string]: true;
196
- };
197
- bindMode: import("@excalidraw/element/types").BindMode;
198
- colorTopPicks: {
199
- elementStroke: readonly string[] | null;
200
- elementBackground: readonly string[] | null;
201
- bucketFill: readonly string[] | null;
202
- };
203
- };
204
- captureUpdate: "IMMEDIATELY";
205
- elements?: undefined;
206
- app?: undefined;
207
- };
208
- predicate: (elements: readonly import("@excalidraw/element/types").ExcalidrawElement[], appState: import("../types").AppState, appProps: import("../types").ExcalidrawProps, app: import("../types").AppClassProperties) => boolean;
209
- trackEvent: false;
210
- } & {
211
- keyTest?: undefined;
212
- };