@orangecatai/element 0.0.1 → 0.0.3

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 (127) hide show
  1. package/README.md +1 -1
  2. package/dist/dev/index.js +42 -3
  3. package/dist/dev/index.js.map +2 -2
  4. package/dist/prod/index.js +1 -1
  5. package/dist/types/common/src/keys.d.ts +2 -0
  6. package/dist/types/element/src/arrows/focus.d.ts +1 -1
  7. package/dist/types/element/src/binding.d.ts +3 -3
  8. package/dist/types/element/src/bounds.d.ts +1 -1
  9. package/dist/types/element/src/collision.d.ts +1 -1
  10. package/dist/types/element/src/delta.d.ts +2 -2
  11. package/dist/types/element/src/dragElements.d.ts +1 -1
  12. package/dist/types/element/src/duplicate.d.ts +1 -1
  13. package/dist/types/element/src/embeddable.d.ts +1 -1
  14. package/dist/types/element/src/flowchart.d.ts +1 -1
  15. package/dist/types/element/src/frame.d.ts +4 -4
  16. package/dist/types/element/src/groups.d.ts +1 -1
  17. package/dist/types/element/src/renderElement.d.ts +1 -1
  18. package/dist/types/element/src/selection.d.ts +1 -1
  19. package/dist/types/element/src/shape.d.ts +2 -2
  20. package/dist/types/element/src/store.d.ts +2 -2
  21. package/dist/types/element/src/textElement.d.ts +1 -1
  22. package/dist/types/element/src/transform.d.ts +1 -1
  23. package/dist/types/element/src/utils.d.ts +1 -1
  24. package/dist/types/element/src/zindex.d.ts +1 -1
  25. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +1 -1
  26. package/dist/types/excalidraw/actions/actionCanvas.d.ts +184 -7
  27. package/dist/types/excalidraw/actions/actionClipboard.d.ts +7 -7
  28. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +2 -2
  29. package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +2 -2
  30. package/dist/types/excalidraw/actions/actionElementLink.d.ts +6 -6
  31. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +1 -1
  32. package/dist/types/excalidraw/actions/actionExport.d.ts +9 -9
  33. package/dist/types/excalidraw/actions/actionFrame.d.ts +178 -0
  34. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +7 -7
  35. package/dist/types/excalidraw/actions/actionLink.d.ts +3 -3
  36. package/dist/types/excalidraw/actions/actionMenu.d.ts +1 -1
  37. package/dist/types/excalidraw/actions/actionProperties.d.ts +1 -1
  38. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +4 -4
  39. package/dist/types/excalidraw/actions/actionStyles.d.ts +2 -2
  40. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +4 -4
  41. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +3 -3
  42. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +2 -2
  43. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +4 -4
  44. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +4 -4
  45. package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -8
  46. package/dist/types/excalidraw/actions/index.d.ts +1 -1
  47. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  48. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  49. package/dist/types/excalidraw/appState.d.ts +4 -4
  50. package/dist/types/excalidraw/components/AIChatPanel.d.ts +114 -0
  51. package/dist/types/excalidraw/components/Actions.d.ts +4 -1
  52. package/dist/types/excalidraw/components/App.d.ts +13 -2
  53. package/dist/types/excalidraw/components/CanvasBackgroundSwatch.d.ts +7 -0
  54. package/dist/types/excalidraw/components/ColorPicker/AdvancedColorPicker.d.ts +8 -0
  55. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +2 -2
  56. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +1 -1
  57. package/dist/types/excalidraw/components/ColorPicker/colorConversions.d.ts +27 -0
  58. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +1 -1
  59. package/dist/types/excalidraw/components/DarkModeToggle.d.ts +1 -1
  60. package/dist/types/excalidraw/components/DefaultSidebar.d.ts +2 -2
  61. package/dist/types/excalidraw/components/ElementCanvasButtons.d.ts +1 -1
  62. package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +2 -2
  63. package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -1
  64. package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +1 -1
  65. package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +1 -1
  66. package/dist/types/excalidraw/components/FontPicker/keyboardNavHandlers.d.ts +1 -1
  67. package/dist/types/excalidraw/components/FrameToolbar.d.ts +1 -1
  68. package/dist/types/excalidraw/components/HintViewer.d.ts +1 -1
  69. package/dist/types/excalidraw/components/ImageEditToolbar.d.ts +16 -0
  70. package/dist/types/excalidraw/components/ImageExportDialog.d.ts +1 -1
  71. package/dist/types/excalidraw/components/ImageGeneratorPanel.d.ts +43 -0
  72. package/dist/types/excalidraw/components/ImageQuickEditPanel.d.ts +16 -0
  73. package/dist/types/excalidraw/components/JSONExportDialog.d.ts +1 -1
  74. package/dist/types/excalidraw/components/LayerUI.d.ts +1 -1
  75. package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +2 -2
  76. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -2
  77. package/dist/types/excalidraw/components/Stats/FontSize.d.ts +1 -1
  78. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +1 -1
  79. package/dist/types/excalidraw/components/Stats/MultiFontSize.d.ts +1 -1
  80. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +1 -1
  81. package/dist/types/excalidraw/components/Stats/index.d.ts +1 -1
  82. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +2 -2
  83. package/dist/types/excalidraw/components/TTDDialog/utils/TTDStreamFetch.d.ts +1 -0
  84. package/dist/types/excalidraw/components/ToolButton.d.ts +1 -1
  85. package/dist/types/excalidraw/components/ai-chat/agentLoop.d.ts +112 -0
  86. package/dist/types/excalidraw/components/ai-chat/audioUtils.d.ts +10 -0
  87. package/dist/types/excalidraw/components/ai-chat/canvasTools.d.ts +685 -0
  88. package/dist/types/excalidraw/components/ai-chat/htmlToExcalidraw.d.ts +53 -0
  89. package/dist/types/excalidraw/components/ai-chat/openRouterStream.d.ts +50 -0
  90. package/dist/types/excalidraw/components/ai-chat/reviewerAgent.d.ts +64 -0
  91. package/dist/types/excalidraw/components/auto-resize/AutoResizePanel.d.ts +17 -0
  92. package/dist/types/excalidraw/components/auto-resize/AutoResizePanelHost.d.ts +4 -0
  93. package/dist/types/excalidraw/components/auto-resize/AutoResizeShimmerLayer.d.ts +11 -0
  94. package/dist/types/excalidraw/components/auto-resize/autoResizeEngine.d.ts +144 -0
  95. package/dist/types/excalidraw/components/auto-resize/autoResizePanelStore.d.ts +15 -0
  96. package/dist/types/excalidraw/components/auto-resize/autoResizeStore.d.ts +16 -0
  97. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +1 -1
  98. package/dist/types/excalidraw/components/icons.d.ts +1 -0
  99. package/dist/types/excalidraw/components/image-generation/pendingGenerations.d.ts +30 -0
  100. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +1 -1
  101. package/dist/types/excalidraw/components/template-builder/TemplateBuilderPanelHost.d.ts +4 -0
  102. package/dist/types/excalidraw/components/template-builder/TemplateBuilderTray.d.ts +4 -0
  103. package/dist/types/excalidraw/components/template-builder/slotTypes.d.ts +43 -0
  104. package/dist/types/excalidraw/components/template-builder/templateBuilderStore.d.ts +19 -0
  105. package/dist/types/excalidraw/components/ui/avatar.d.ts +6 -0
  106. package/dist/types/excalidraw/components/ui/button.d.ts +11 -0
  107. package/dist/types/excalidraw/components/ui/chat-container.d.ts +17 -0
  108. package/dist/types/excalidraw/components/ui/code-block.d.ts +16 -0
  109. package/dist/types/excalidraw/components/ui/markdown.d.ts +10 -0
  110. package/dist/types/excalidraw/components/ui/message.d.ts +35 -0
  111. package/dist/types/excalidraw/components/ui/prompt-input.d.ts +28 -0
  112. package/dist/types/excalidraw/components/ui/scroll-button.d.ts +10 -0
  113. package/dist/types/excalidraw/components/ui/textarea.d.ts +3 -0
  114. package/dist/types/excalidraw/components/ui/tooltip.d.ts +7 -0
  115. package/dist/types/excalidraw/data/blob.d.ts +19 -17
  116. package/dist/types/excalidraw/data/json.d.ts +8 -8
  117. package/dist/types/excalidraw/data/library.d.ts +1 -1
  118. package/dist/types/excalidraw/fonts/Fonts.d.ts +19 -2
  119. package/dist/types/excalidraw/i18n.d.ts +1 -1
  120. package/dist/types/excalidraw/index.d.ts +9 -0
  121. package/dist/types/excalidraw/lib/utils.d.ts +2 -0
  122. package/dist/types/excalidraw/types.d.ts +229 -0
  123. package/dist/types/excalidraw/utils/geminiApiKey.d.ts +1 -0
  124. package/dist/types/excalidraw/utils/leonardoApiKey.d.ts +1 -0
  125. package/dist/types/excalidraw/utils/openRouterApiKey.d.ts +1 -0
  126. package/dist/types/excalidraw/utils/removeBgApiKey.d.ts +1 -0
  127. package/package.json +6 -6
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ import { type VariantProps } from "class-variance-authority";
3
+ import type { buttonVariants } from "@/components/ui/button";
4
+ export type ScrollButtonProps = {
5
+ className?: string;
6
+ variant?: VariantProps<typeof buttonVariants>["variant"];
7
+ size?: VariantProps<typeof buttonVariants>["size"];
8
+ } & React.ButtonHTMLAttributes<HTMLButtonElement>;
9
+ declare function ScrollButton({ className, variant, size, ...props }: ScrollButtonProps): import("react/jsx-runtime").JSX.Element;
10
+ export { ScrollButton };
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ declare const Textarea: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref"> & React.RefAttributes<HTMLTextAreaElement>>;
3
+ export { Textarea };
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
3
+ declare const TooltipProvider: React.FC<TooltipPrimitive.TooltipProviderProps>;
4
+ declare const Tooltip: React.FC<TooltipPrimitive.TooltipProps>;
5
+ declare const TooltipTrigger: React.ForwardRefExoticComponent<TooltipPrimitive.TooltipTriggerProps & React.RefAttributes<HTMLButtonElement>>;
6
+ declare const TooltipContent: React.ForwardRefExoticComponent<Omit<TooltipPrimitive.TooltipContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
7
+ export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
@@ -1,6 +1,6 @@
1
1
  import { IMAGE_MIME_TYPES, MIME_TYPES } from "@orangecatai/common";
2
- import type { ValueOf } from "@orangecatai/common/utility-types";
3
2
  import type { ExcalidrawElement, FileId } from "@orangecatai/element/types";
3
+ import type { ValueOf } from "@orangecatai/common/utility-types";
4
4
  import type { AppState, DataURL, LibraryItem } from "../types";
5
5
  import type { FileSystemHandle } from "browser-fs-access";
6
6
  import type { ImportedLibraryData } from "./types";
@@ -21,14 +21,6 @@ fileHandle?: FileSystemHandle | null) => Promise<{
21
21
  data: {
22
22
  elements: import("@orangecatai/element/types").OrderedExcalidrawElement[];
23
23
  appState: {
24
- viewBackgroundColor: string;
25
- theme: import("@orangecatai/element/types").Theme;
26
- frameRendering: {
27
- enabled: boolean;
28
- name: boolean;
29
- outline: boolean;
30
- clip: boolean;
31
- };
32
24
  name: string | null;
33
25
  zoom: import("../types").Zoom;
34
26
  scrollX: number;
@@ -52,6 +44,7 @@ fileHandle?: FileSystemHandle | null) => Promise<{
52
44
  [id: string]: true;
53
45
  }>;
54
46
  frameToHighlight: import("@orangecatai/element/types").NonDeleted<import("@orangecatai/element/types").ExcalidrawFrameLikeElement> | null;
47
+ theme: import("@orangecatai/element/types").Theme;
55
48
  activeTool: {
56
49
  lastActiveTool: import("../types").ActiveTool | null;
57
50
  locked: boolean;
@@ -89,6 +82,12 @@ fileHandle?: FileSystemHandle | null) => Promise<{
89
82
  hoveredElementIds: Readonly<{
90
83
  [id: string]: true;
91
84
  }>;
85
+ frameRendering: {
86
+ enabled: boolean;
87
+ name: boolean;
88
+ outline: boolean;
89
+ clip: boolean;
90
+ };
92
91
  shouldCacheIgnoreZoom: boolean;
93
92
  exportScale: number;
94
93
  currentItemArrowType: "sharp" | "round" | "elbow";
@@ -128,6 +127,7 @@ fileHandle?: FileSystemHandle | null) => Promise<{
128
127
  currentItemEndArrowhead: import("@orangecatai/element/types").Arrowhead | null;
129
128
  currentHoveredFontFamily: import("@orangecatai/element/types").FontFamilyValues | null;
130
129
  currentItemRoundness: import("@orangecatai/element/types").StrokeRoundness;
130
+ viewBackgroundColor: string;
131
131
  cursorButton: "up" | "down";
132
132
  scrolledOutside: boolean;
133
133
  isResizing: boolean;
@@ -188,14 +188,6 @@ localAppState: AppState | null, localElements: readonly ExcalidrawElement[] | nu
188
188
  fileHandle?: FileSystemHandle | null) => Promise<{
189
189
  elements: import("@orangecatai/element/types").OrderedExcalidrawElement[];
190
190
  appState: {
191
- viewBackgroundColor: string;
192
- theme: import("@orangecatai/element/types").Theme;
193
- frameRendering: {
194
- enabled: boolean;
195
- name: boolean;
196
- outline: boolean;
197
- clip: boolean;
198
- };
199
191
  name: string | null;
200
192
  zoom: import("../types").Zoom;
201
193
  scrollX: number;
@@ -219,6 +211,7 @@ fileHandle?: FileSystemHandle | null) => Promise<{
219
211
  [id: string]: true;
220
212
  }>;
221
213
  frameToHighlight: import("@orangecatai/element/types").NonDeleted<import("@orangecatai/element/types").ExcalidrawFrameLikeElement> | null;
214
+ theme: import("@orangecatai/element/types").Theme;
222
215
  activeTool: {
223
216
  lastActiveTool: import("../types").ActiveTool | null;
224
217
  locked: boolean;
@@ -256,6 +249,12 @@ fileHandle?: FileSystemHandle | null) => Promise<{
256
249
  hoveredElementIds: Readonly<{
257
250
  [id: string]: true;
258
251
  }>;
252
+ frameRendering: {
253
+ enabled: boolean;
254
+ name: boolean;
255
+ outline: boolean;
256
+ clip: boolean;
257
+ };
259
258
  shouldCacheIgnoreZoom: boolean;
260
259
  exportScale: number;
261
260
  currentItemArrowType: "sharp" | "round" | "elbow";
@@ -295,6 +294,7 @@ fileHandle?: FileSystemHandle | null) => Promise<{
295
294
  currentItemEndArrowhead: import("@orangecatai/element/types").Arrowhead | null;
296
295
  currentHoveredFontFamily: import("@orangecatai/element/types").FontFamilyValues | null;
297
296
  currentItemRoundness: import("@orangecatai/element/types").StrokeRoundness;
297
+ viewBackgroundColor: string;
298
298
  cursorButton: "up" | "down";
299
299
  scrolledOutside: boolean;
300
300
  isResizing: boolean;
@@ -353,6 +353,8 @@ export declare const generateIdFromFile: (file: File) => Promise<FileId>;
353
353
  /** async. For sync variant, use getDataURL_sync */
354
354
  export declare const getDataURL: (file: Blob | File) => Promise<DataURL>;
355
355
  export declare const getDataURL_sync: (data: string | Uint8Array | ArrayBuffer, mimeType: ValueOf<typeof MIME_TYPES>) => DataURL;
356
+ /** Parses MIME type from a data URL (e.g. data:image/webp;base64,...). */
357
+ export declare const getMimeTypeFromDataURL: (dataURL: string) => string;
356
358
  export declare const dataURLToFile: (dataURL: DataURL, filename?: string) => File;
357
359
  export declare const dataURLToString: (dataURL: DataURL) => string;
358
360
  export declare const resizeImageFile: (file: File, opts: {
@@ -10,14 +10,6 @@ name?: string) => Promise<{
10
10
  export declare const loadFromJSON: (localAppState: AppState, localElements: readonly ExcalidrawElement[] | null) => Promise<{
11
11
  elements: import("@orangecatai/element/types").OrderedExcalidrawElement[];
12
12
  appState: {
13
- viewBackgroundColor: string;
14
- theme: import("@orangecatai/element/types").Theme;
15
- frameRendering: {
16
- enabled: boolean;
17
- name: boolean;
18
- outline: boolean;
19
- clip: boolean;
20
- };
21
13
  name: string | null;
22
14
  zoom: import("../types").Zoom;
23
15
  scrollX: number;
@@ -41,6 +33,7 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
41
33
  [id: string]: true;
42
34
  }>;
43
35
  frameToHighlight: import("@orangecatai/element/types").NonDeleted<import("@orangecatai/element/types").ExcalidrawFrameLikeElement> | null;
36
+ theme: import("@orangecatai/element/types").Theme;
44
37
  activeTool: {
45
38
  lastActiveTool: import("../types").ActiveTool | null;
46
39
  locked: boolean;
@@ -78,6 +71,12 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
78
71
  hoveredElementIds: Readonly<{
79
72
  [id: string]: true;
80
73
  }>;
74
+ frameRendering: {
75
+ enabled: boolean;
76
+ name: boolean;
77
+ outline: boolean;
78
+ clip: boolean;
79
+ };
81
80
  shouldCacheIgnoreZoom: boolean;
82
81
  exportScale: number;
83
82
  currentItemArrowType: "sharp" | "round" | "elbow";
@@ -117,6 +116,7 @@ export declare const loadFromJSON: (localAppState: AppState, localElements: read
117
116
  currentItemEndArrowhead: import("@orangecatai/element/types").Arrowhead | null;
118
117
  currentHoveredFontFamily: import("@orangecatai/element/types").FontFamilyValues | null;
119
118
  currentItemRoundness: import("@orangecatai/element/types").StrokeRoundness;
119
+ viewBackgroundColor: string;
120
120
  cursorButton: "up" | "down";
121
121
  scrolledOutside: boolean;
122
122
  isResizing: boolean;
@@ -1,5 +1,5 @@
1
- import type { ExcalidrawElement } from "@orangecatai/element/types";
2
1
  import type { MaybePromise } from "@orangecatai/common/utility-types";
2
+ import type { ExcalidrawElement } from "@orangecatai/element/types";
3
3
  import type App from "../components/App";
4
4
  import type { LibraryItems, ExcalidrawImperativeAPI, LibraryItemsSource, LibraryItems_anyVersion } from "../types";
5
5
  export type LibraryPersistedData = {
@@ -1,11 +1,15 @@
1
1
  import { type FontMetadata } from "@orangecatai/common";
2
- import type { ExcalidrawElement } from "@orangecatai/element/types";
3
- import type { Scene } from "@orangecatai/element";
4
2
  import { ExcalidrawFontFace } from "./ExcalidrawFontFace";
3
+ import type { Scene } from "@orangecatai/element";
4
+ import type { ExcalidrawElement } from "@orangecatai/element/types";
5
5
  export declare class Fonts {
6
6
  static readonly loadedFontsCache: Set<string>;
7
7
  private static _registered;
8
8
  private static _initialized;
9
+ private static _customFontVersion;
10
+ private static _subscribers;
11
+ static readonly subscribeToCustomFonts: (callback: () => void) => (() => void);
12
+ static readonly getCustomFontVersion: () => number;
9
13
  static get registered(): Map<number, {
10
14
  metadata: FontMetadata;
11
15
  fontFaces: ExcalidrawFontFace[];
@@ -14,6 +18,19 @@ export declare class Fonts {
14
18
  metadata: FontMetadata;
15
19
  fontFaces: ExcalidrawFontFace[];
16
20
  }>;
21
+ /**
22
+ * Register a custom font from a URL into the canvas font system.
23
+ *
24
+ * Use family IDs >= 2000 to avoid collisions with built-in fonts.
25
+ * IDs 1–10 are named fonts, 100 = Xiaolai, 998/999 = generic fallbacks,
26
+ * 1000 = Segoe UI Emoji — all are reserved.
27
+ *
28
+ * Note: custom fonts are registered without a weight/style descriptor
29
+ * because getFontString generates "${size}px ${familyName}" (no weight),
30
+ * so the browser always requests the normal-weight variant. Pass the font
31
+ * file that should render by default for this family ID.
32
+ */
33
+ static registerCustomFont(spec: import("../types").CustomFontSpec): void;
17
34
  private readonly scene;
18
35
  constructor(scene: Scene);
19
36
  /**
@@ -1,5 +1,5 @@
1
- import type { NestedKeyOf } from "@orangecatai/common/utility-types";
2
1
  import fallbackLangData from "./locales/en.json";
2
+ import type { NestedKeyOf } from "@orangecatai/common/utility-types";
3
3
  export interface Language {
4
4
  code: string;
5
5
  label: string;
@@ -6,6 +6,7 @@ import WelcomeScreen from "./components/welcome-screen/WelcomeScreen";
6
6
  import "./css/app.scss";
7
7
  import "./css/styles.scss";
8
8
  import "./fonts/fonts.css";
9
+ import "./css/tailwind.generated.css";
9
10
  import type { ExcalidrawProps } from "./types";
10
11
  export declare const Excalidraw: React.MemoExoticComponent<(props: ExcalidrawProps) => import("react/jsx-runtime").JSX.Element>;
11
12
  export { getSceneVersion, hashElementsVersion, hashString, getNonDeletedElements, } from "@orangecatai/element";
@@ -45,3 +46,11 @@ export { getDataURL } from "./data/blob";
45
46
  export { isElementLink } from "@orangecatai/element";
46
47
  export { setCustomTextMetricsProvider } from "@orangecatai/element";
47
48
  export { CommandPalette } from "./components/CommandPalette/CommandPalette";
49
+ export { AIChatPanel } from "./components/AIChatPanel";
50
+ export type { AIChatPanelProps, AIChatPanelRef, ChatMessage, ChatSession, } from "./components/AIChatPanel";
51
+ export type { ExcalidrawImperativeAPI } from "./types";
52
+ export type { AppState, BinaryFiles, BinaryFileData, ExcalidrawProps, ExcalidrawInitialDataState, LibraryItem, LibraryItems, SceneData, UnsubscribeCallback, } from "./types";
53
+ export type { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, OrderedExcalidrawElement, ExcalidrawElementType, } from "@orangecatai/element/types";
54
+ export type { ImageEditToolbarCallbacks } from "./components/ImageEditToolbar";
55
+ export type { CustomFontSpec, BrandContext } from "./types";
56
+ export type { ReviewerFeedback, ReviewIssue, } from "./components/ai-chat/reviewerAgent";
@@ -0,0 +1,2 @@
1
+ import { type ClassValue } from "clsx";
2
+ export declare function cn(...inputs: ClassValue[]): string;
@@ -430,6 +430,80 @@ export type OnUserFollowedPayload = {
430
430
  userToFollow: UserToFollow;
431
431
  action: "FOLLOW" | "UNFOLLOW";
432
432
  };
433
+ /**
434
+ * Describes a custom font to register in the canvas font system.
435
+ * Use family IDs >= 2000 to avoid collision with built-in fonts.
436
+ * IDs up to 1000 are reserved (1–10 named fonts, 100 CJK, 998/999 generic, 1000 emoji).
437
+ */
438
+ export type CustomFontSpec = {
439
+ /** Unique numeric family ID. Use 2000+ to avoid collisions with built-ins. */
440
+ familyId: number;
441
+ /** CSS font-family name used in @font-face and canvas rendering. */
442
+ name: string;
443
+ /** Absolute URL or data: URL pointing to the font file. */
444
+ url: string;
445
+ /**
446
+ * Informational font-weight (e.g. "400", "700"). Not applied as a CSS
447
+ * descriptor — getFontString never includes weight, so all custom fonts
448
+ * load as the normal-weight variant for their family ID.
449
+ */
450
+ weight?: string;
451
+ };
452
+ /**
453
+ * Optional brand identity context passed to AIChatPanel.
454
+ * When provided, the AI agent uses these guidelines when creating ads.
455
+ */
456
+ export type BrandContext = {
457
+ colors?: {
458
+ primary?: string;
459
+ secondary?: string;
460
+ accent?: string;
461
+ background?: string;
462
+ };
463
+ typography?: {
464
+ headline?: {
465
+ family: string;
466
+ weight?: string;
467
+ /** size_scale from brand kit (e.g. "display", "large", "medium", "small") */
468
+ sizeScale?: string;
469
+ /**
470
+ * Font family ID if a matching custom font was registered via
471
+ * the `customFonts` prop on <Excalidraw>. The agent will pass
472
+ * this number to add_text fontFamily calls.
473
+ */
474
+ fontFamilyId?: number;
475
+ /** Original font file name from brand DNA (e.g. "Avenir-Heavy.otf"). Passed to AI for image generation context. */
476
+ fontName?: string;
477
+ };
478
+ body?: {
479
+ family: string;
480
+ weight?: string;
481
+ sizeScale?: string;
482
+ fontFamilyId?: number;
483
+ /** Original font file name from brand DNA. */
484
+ fontName?: string;
485
+ };
486
+ };
487
+ visualStyle?: string;
488
+ layoutPattern?: string;
489
+ toneOfVoice?: {
490
+ register?: string;
491
+ vocabulary?: string;
492
+ ctaStyle?: string;
493
+ sentenceLength?: string;
494
+ person?: string;
495
+ };
496
+ imagery?: {
497
+ type?: string;
498
+ lighting?: string;
499
+ composition?: string;
500
+ subjects?: string;
501
+ grading?: string;
502
+ depthOfField?: string;
503
+ environment?: string;
504
+ negativeSpace?: string;
505
+ };
506
+ };
433
507
  export interface ExcalidrawProps {
434
508
  onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
435
509
  onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
@@ -491,6 +565,155 @@ export interface ExcalidrawProps {
491
565
  aiEnabled?: boolean;
492
566
  showDeprecatedFonts?: boolean;
493
567
  renderScrollbars?: boolean;
568
+ /**
569
+ * Gemini API key for image generation.
570
+ * When provided, takes precedence over the VITE_APP_GEMINI_API_KEY env variable.
571
+ * Required for image generation when using this package as an npm dependency.
572
+ */
573
+ geminiApiKey?: string;
574
+ /**
575
+ * Leonardo API key for image toolbar upscale action.
576
+ * When provided, takes precedence over the VITE_APP_LEONARDO_API_KEY env variable.
577
+ */
578
+ leonardoApiKey?: string;
579
+ /**
580
+ * OpenRouter API key for auto-resize layout planning.
581
+ * When provided, takes precedence over the VITE_APP_OPEN_ROUTER_API_KEY env variable.
582
+ */
583
+ openRouterApiKey?: string;
584
+ /**
585
+ * remove.bg API key for the remove background toolbar action.
586
+ * When provided, takes precedence over the VITE_APP_REMOVE_BG_API_KEY env variable.
587
+ */
588
+ removeBgApiKey?: string;
589
+ /**
590
+ * Called before any image generation (ImageGeneratorPanel, ImageQuickEditPanel,
591
+ * or agent loop generate_image tool). Return `{ allowed: false }` to block.
592
+ * Host apps use this for credit gating.
593
+ */
594
+ onBeforeImageGen?: () => Promise<{
595
+ allowed: boolean;
596
+ error?: string;
597
+ }>;
598
+ /**
599
+ * Called after a successful image generation from any panel or agent tool.
600
+ */
601
+ onAfterImageGen?: () => void;
602
+ /**
603
+ * Called before an upscale is run (deduct credits, check quota).
604
+ * Return `{ allowed: false, error: "..." }` to block the operation.
605
+ */
606
+ onBeforeUpscale?: () => Promise<{
607
+ allowed: boolean;
608
+ error?: string;
609
+ }>;
610
+ /** Called after a successful upscale. */
611
+ onAfterUpscale?: () => void;
612
+ /**
613
+ * Called before a background removal is run (deduct credits, check quota).
614
+ * Return `{ allowed: false, error: "..." }` to block the operation.
615
+ */
616
+ onBeforeRemoveBg?: () => Promise<{
617
+ allowed: boolean;
618
+ error?: string;
619
+ }>;
620
+ /** Called after a successful background removal. */
621
+ onAfterRemoveBg?: () => void;
622
+ /**
623
+ * Called before each auto-resize dimension is generated (deduct credits, check quota).
624
+ * Return `{ allowed: false, error: "..." }` to skip that dimension.
625
+ */
626
+ onBeforeAutoResize?: () => Promise<{
627
+ allowed: boolean;
628
+ error?: string;
629
+ }>;
630
+ /** Called after each successfully generated auto-resize dimension. */
631
+ onAfterAutoResize?: () => void;
632
+ /**
633
+ * Gemini model ID used for AI image generation — covers both the auto-resize
634
+ * background regeneration and the agent chat `generate_image` tool.
635
+ * Pass the same value here and to `AIChatPanel.agentImageModel` to keep
636
+ * both surfaces on the same model with a single configuration.
637
+ * @default "gemini-3.1-flash-image-preview"
638
+ * @example "gemini-3.1-flash-image-preview"
639
+ */
640
+ agentImageModel?: string;
641
+ /**
642
+ * OpenRouter model tag used by the auto-resize engine for HTML layout
643
+ * generation. This is the LLM call that figures out how to reflow the ad
644
+ * content into the target dimensions before Gemini regenerates the background.
645
+ * @default "google/gemini-3.1-flash-lite-preview"
646
+ * @example "openai/gpt-4o"
647
+ */
648
+ chatModel?: string;
649
+ /**
650
+ * Show the Library sidebar trigger button. Defaults to `false`.
651
+ * Set to `true` to show the library icon in the top-right area.
652
+ */
653
+ showLibraryButton?: boolean;
654
+ /**
655
+ * Callbacks for each action in the image edit toolbar
656
+ * (shown when an image element is selected on canvas).
657
+ * When callbacks are omitted, built-in toolbar actions are used.
658
+ */
659
+ imageEditToolbarCallbacks?: import("./components/ImageEditToolbar").ImageEditToolbarCallbacks;
660
+ /**
661
+ * Custom fonts to register in the canvas font system.
662
+ * Each entry maps a numeric family ID (use 2000+) to a font file URL.
663
+ * Registered fonts become available for text elements whose fontFamily
664
+ * matches the given familyId.
665
+ */
666
+ customFonts?: CustomFontSpec[];
667
+ /**
668
+ * Called when the user saves a template from the Template Builder.
669
+ */
670
+ onSaveTemplate?: (template: {
671
+ name: string;
672
+ campaignTag?: string;
673
+ label?: string;
674
+ width?: number;
675
+ height?: number;
676
+ canvasJson?: string;
677
+ thumbnailDataUrl?: string;
678
+ }) => void;
679
+ /**
680
+ * Fetch all available brand assets for the asset picker (in-canvas swap).
681
+ */
682
+ onFetchAllAssets?: () => Promise<Array<{
683
+ id: string;
684
+ name: string;
685
+ tags: string[];
686
+ assetType: string;
687
+ blobUrl: string;
688
+ }>>;
689
+ /**
690
+ * Search brand assets by query and optional type filter.
691
+ */
692
+ onSearchBrandAssets?: (query: string, type?: string) => Promise<Array<{
693
+ id: string;
694
+ name: string;
695
+ tags: string[];
696
+ assetType: string;
697
+ blobUrl: string;
698
+ }>>;
699
+ /**
700
+ * List brand templates, optionally filtered by campaignTag.
701
+ */
702
+ onListBrandTemplates?: (keywords?: string[]) => Promise<Array<{
703
+ id: string;
704
+ name: string;
705
+ campaignTag?: string;
706
+ label?: string;
707
+ width?: number;
708
+ height?: number;
709
+ thumbnailBlobUrl?: string;
710
+ }>>;
711
+ /**
712
+ * Fetch the full canvas JSON for a specific template by ID.
713
+ */
714
+ onGetTemplateVariant?: (templateId: string) => Promise<{
715
+ canvasJson: string;
716
+ }>;
494
717
  }
495
718
  export type SceneData = {
496
719
  elements?: ImportedDataState["elements"];
@@ -511,6 +734,7 @@ export type CanvasActions = Partial<{
511
734
  saveToActiveFile: boolean;
512
735
  toggleTheme: boolean | null;
513
736
  saveAsImage: boolean;
737
+ scrollBackToContent: boolean;
514
738
  }>;
515
739
  export type UIOptions = Partial<{
516
740
  dockedSidebarBreakpoint: number;
@@ -543,6 +767,7 @@ export type AppProps = Merge<ExcalidrawProps, {
543
767
  export type AppClassProperties = {
544
768
  props: AppProps;
545
769
  state: AppState;
770
+ actionManager: App["actionManager"];
546
771
  interactiveCanvas: HTMLCanvasElement | null;
547
772
  /** static canvas */
548
773
  canvas: HTMLCanvasElement;
@@ -571,6 +796,9 @@ export type AppClassProperties = {
571
796
  setOpenDialog: App["setOpenDialog"];
572
797
  insertEmbeddableElement: App["insertEmbeddableElement"];
573
798
  onMagicframeToolSelect: App["onMagicframeToolSelect"];
799
+ onImageGeneratorSelect: App["onImageGeneratorSelect"];
800
+ insertGeneratedImageIntoFrame: App["insertGeneratedImageIntoFrame"];
801
+ insertGeneratedImageNearElement: App["insertGeneratedImageNearElement"];
574
802
  getName: App["getName"];
575
803
  dismissLinearEditor: App["dismissLinearEditor"];
576
804
  flowChartCreator: App["flowChartCreator"];
@@ -581,6 +809,7 @@ export type AppClassProperties = {
581
809
  visibleElements: App["visibleElements"];
582
810
  excalidrawContainerValue: App["excalidrawContainerValue"];
583
811
  getSceneElements: App["getSceneElements"];
812
+ updateScene: App["updateScene"];
584
813
  onPointerUpEmitter: App["onPointerUpEmitter"];
585
814
  updateEditorAtom: App["updateEditorAtom"];
586
815
  onPointerDownEmitter: App["onPointerDownEmitter"];
@@ -0,0 +1 @@
1
+ export declare function resolveGeminiApiKey(propKey?: string): string;
@@ -0,0 +1 @@
1
+ export declare function resolveLeonardoApiKey(propKey?: string): string;
@@ -0,0 +1 @@
1
+ export declare function resolveOpenRouterApiKey(propKey?: string): string;
@@ -0,0 +1 @@
1
+ export declare function resolveRemoveBgApiKey(propKey?: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orangecatai/element",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "types": "./dist/types/element/src/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -28,7 +28,7 @@
28
28
  "files": [
29
29
  "dist/*"
30
30
  ],
31
- "description": "Excalidraw elements-related logic",
31
+ "description": "OrangeCat adgen-canvas elements-related logic",
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
@@ -56,14 +56,14 @@
56
56
  "last 1 safari version"
57
57
  ]
58
58
  },
59
- "bugs": "https://github.com/yourorg/excalidraw/issues",
60
- "repository": "https://github.com/yourorg/excalidraw",
59
+ "bugs": "https://github.com/Kraken2003/adgen-canvas/issues",
60
+ "repository": "https://github.com/Kraken2003/adgen-canvas",
61
61
  "scripts": {
62
62
  "gen:types": "rimraf types && tsc",
63
63
  "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types"
64
64
  },
65
65
  "dependencies": {
66
- "@orangecatai/common": "0.0.1",
67
- "@orangecatai/math": "0.0.1"
66
+ "@orangecatai/common": "0.0.3",
67
+ "@orangecatai/math": "0.0.2"
68
68
  }
69
69
  }