@dwelle/excalidraw 0.5.0-3afd1ef → 0.5.0-3c6f672cd

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 (161) hide show
  1. package/README.md +111 -14
  2. package/dist/dev/{chunk-FAO4JKOU.js → chunk-E46ST234.js} +3646 -1969
  3. package/dist/dev/chunk-E46ST234.js.map +7 -0
  4. package/dist/dev/{chunk-V5BIR3MG.js → chunk-L5TK3F2L.js} +22 -3
  5. package/dist/dev/chunk-L5TK3F2L.js.map +7 -0
  6. package/dist/dev/{chunk-W6ICSA4S.js → chunk-MFBHCRUO.js} +2 -2
  7. package/dist/dev/{chunk-W6ICSA4S.js.map → chunk-MFBHCRUO.js.map} +1 -1
  8. package/dist/dev/components/TTDDialog/{CodeMirrorEditor-BEEYVGBY.js → CodeMirrorEditor-F7FAZ7VK.js} +2 -2
  9. package/dist/dev/data/{image-UAMHR4NR.js → image-H6YUB767.js} +3 -3
  10. package/dist/dev/index.css +133 -67
  11. package/dist/dev/index.css.map +3 -3
  12. package/dist/dev/index.js +5237 -3539
  13. package/dist/dev/index.js.map +4 -4
  14. package/dist/dev/locales/{en-2JUZQ4KZ.js → en-7NUPYLED.js} +4 -2
  15. package/dist/dev/subset-shared.chunk.js +1 -1
  16. package/dist/dev/subset-worker.chunk.js +1 -1
  17. package/dist/prod/chunk-65OI4N5K.js +34 -0
  18. package/dist/prod/{chunk-ALEVGRNC.js → chunk-S3EMY4QR.js} +1 -1
  19. package/dist/prod/{chunk-DDHTQBPG.js → chunk-YI6WNTBI.js} +5 -5
  20. package/dist/prod/components/TTDDialog/{CodeMirrorEditor-OIYENWM6.js → CodeMirrorEditor-PSYIQ7NH.js} +1 -1
  21. package/dist/prod/data/image-CNYDX3MX.js +1 -0
  22. package/dist/prod/index.css +1 -1
  23. package/dist/prod/index.js +31 -29
  24. package/dist/prod/locales/en-WABAEZHC.js +1 -0
  25. package/dist/prod/subset-shared.chunk.js +1 -1
  26. package/dist/prod/subset-worker.chunk.js +1 -1
  27. package/dist/types/common/src/appEventBus.d.ts +27 -0
  28. package/dist/types/common/src/colors.d.ts +1 -1
  29. package/dist/types/common/src/constants.d.ts +9 -7
  30. package/dist/types/common/src/index.d.ts +2 -0
  31. package/dist/types/common/src/utils.d.ts +1 -45
  32. package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
  33. package/dist/types/element/src/Scene.d.ts +5 -3
  34. package/dist/types/element/src/arrowheads.d.ts +3 -0
  35. package/dist/types/element/src/bounds.d.ts +22 -7
  36. package/dist/types/element/src/comparisons.d.ts +1 -0
  37. package/dist/types/element/src/duplicate.d.ts +1 -0
  38. package/dist/types/element/src/frame.d.ts +7 -6
  39. package/dist/types/element/src/groups.d.ts +3 -3
  40. package/dist/types/element/src/index.d.ts +1 -0
  41. package/dist/types/element/src/linearElementEditor.d.ts +2 -2
  42. package/dist/types/element/src/newElement.d.ts +1 -0
  43. package/dist/types/element/src/renderElement.d.ts +7 -4
  44. package/dist/types/element/src/selection.d.ts +8 -4
  45. package/dist/types/element/src/shape.d.ts +1 -1
  46. package/dist/types/element/src/textElement.d.ts +1 -1
  47. package/dist/types/element/src/textWrapping.d.ts +26 -0
  48. package/dist/types/element/src/typeChecks.d.ts +1 -0
  49. package/dist/types/element/src/types.d.ts +10 -1
  50. package/dist/types/element/src/utils.d.ts +1 -1
  51. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +20 -17
  52. package/dist/types/excalidraw/actions/actionBoundText.d.ts +15 -13
  53. package/dist/types/excalidraw/actions/actionCanvas.d.ts +458 -480
  54. package/dist/types/excalidraw/actions/actionClipboard.d.ts +14 -12
  55. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +7 -6
  56. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +22 -19
  57. package/dist/types/excalidraw/actions/actionDeselect.d.ts +161 -0
  58. package/dist/types/excalidraw/actions/actionElementLink.d.ts +7 -6
  59. package/dist/types/excalidraw/actions/actionElementLock.d.ts +15 -13
  60. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +7 -6
  61. package/dist/types/excalidraw/actions/actionExport.d.ts +119 -390
  62. package/dist/types/excalidraw/actions/actionFrame.d.ts +41 -36
  63. package/dist/types/excalidraw/actions/actionGroup.d.ts +30 -28
  64. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +10 -8
  65. package/dist/types/excalidraw/actions/actionLink.d.ts +8 -7
  66. package/dist/types/excalidraw/actions/actionMenu.d.ts +7 -6
  67. package/dist/types/excalidraw/actions/actionProperties.d.ts +26 -15
  68. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +8 -7
  69. package/dist/types/excalidraw/actions/actionStyles.d.ts +7 -5
  70. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
  71. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +8 -7
  72. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +11 -11
  73. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +8 -7
  74. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +8 -7
  75. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +11 -11
  76. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
  77. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +8 -7
  78. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +8 -7
  79. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +8 -7
  80. package/dist/types/excalidraw/actions/index.d.ts +2 -1
  81. package/dist/types/excalidraw/actions/types.d.ts +4 -4
  82. package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
  83. package/dist/types/excalidraw/appState.d.ts +25 -23
  84. package/dist/types/excalidraw/clipboard.d.ts +2 -3
  85. package/dist/types/excalidraw/components/Actions.d.ts +2 -3
  86. package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
  87. package/dist/types/excalidraw/components/App.d.ts +105 -49
  88. package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
  89. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +2 -2
  90. package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
  91. package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
  92. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +1 -1
  93. package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -1
  94. package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
  95. package/dist/types/excalidraw/components/Island.d.ts +7 -0
  96. package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
  97. package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
  98. package/dist/types/excalidraw/components/Range.d.ts +10 -4
  99. package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
  100. package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
  101. package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +1 -1
  102. package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +4 -4
  103. package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +3 -3
  104. package/dist/types/excalidraw/components/TTDDialog/utils/TTDStreamFetch.d.ts +1 -1
  105. package/dist/types/excalidraw/components/Toast.d.ts +8 -4
  106. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +2 -1
  107. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +1 -0
  108. package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
  109. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -1
  110. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -2
  111. package/dist/types/excalidraw/components/icons.d.ts +19 -8
  112. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +7 -3
  113. package/dist/types/excalidraw/components/shapes.d.ts +7 -0
  114. package/dist/types/excalidraw/data/blob.d.ts +153 -150
  115. package/dist/types/excalidraw/data/filesystem.d.ts +3 -5
  116. package/dist/types/excalidraw/data/index.d.ts +2 -3
  117. package/dist/types/excalidraw/data/json.d.ts +87 -77
  118. package/dist/types/excalidraw/data/library.d.ts +1 -1
  119. package/dist/types/excalidraw/data/resave.d.ts +7 -2
  120. package/dist/types/excalidraw/data/restore.d.ts +1 -1
  121. package/dist/types/excalidraw/elementAnimator.d.ts +52 -0
  122. package/dist/types/excalidraw/eraser/index.d.ts +2 -3
  123. package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
  124. package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
  125. package/dist/types/excalidraw/index.d.ts +27 -5
  126. package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
  127. package/dist/types/excalidraw/lasso/index.d.ts +2 -3
  128. package/dist/types/excalidraw/renderer/animation.d.ts +5 -1
  129. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -3
  130. package/dist/types/excalidraw/scene/Renderer.d.ts +426 -19
  131. package/dist/types/excalidraw/scene/index.d.ts +2 -2
  132. package/dist/types/excalidraw/scene/types.d.ts +8 -4
  133. package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
  134. package/dist/types/excalidraw/types.d.ts +294 -44
  135. package/dist/types/excalidraw/viewport.d.ts +316 -0
  136. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +5 -1
  137. package/dist/types/fractional-indexing/src/index.d.ts +29 -0
  138. package/dist/types/laser-pointer/src/index.d.ts +2 -0
  139. package/dist/types/laser-pointer/src/math.d.ts +16 -0
  140. package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
  141. package/dist/types/laser-pointer/src/state.d.ts +35 -0
  142. package/dist/types/math/src/constants.d.ts +0 -1
  143. package/dist/types/math/src/curve.d.ts +4 -1
  144. package/dist/types/math/src/point.d.ts +2 -1
  145. package/package.json +5 -6
  146. package/CHANGELOG.md +0 -2385
  147. package/dist/dev/chunk-FAO4JKOU.js.map +0 -7
  148. package/dist/dev/chunk-V5BIR3MG.js.map +0 -7
  149. package/dist/prod/chunk-RS54KZXC.js +0 -33
  150. package/dist/prod/data/image-QN4A65R4.js +0 -1
  151. package/dist/prod/locales/en-IVA5PAN7.js +0 -1
  152. package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
  153. package/dist/types/excalidraw/scene/scroll.d.ts +0 -18
  154. package/dist/types/excalidraw/scene/scrollConstraints.d.ts +0 -46
  155. package/dist/types/utils/src/bbox.d.ts +0 -9
  156. package/dist/types/utils/src/index.d.ts +0 -4
  157. package/dist/types/utils/src/withinBounds.d.ts +0 -19
  158. package/history.ts +0 -249
  159. /package/dist/dev/components/TTDDialog/{CodeMirrorEditor-BEEYVGBY.js.map → CodeMirrorEditor-F7FAZ7VK.js.map} +0 -0
  160. /package/dist/dev/data/{image-UAMHR4NR.js.map → image-H6YUB767.js.map} +0 -0
  161. /package/dist/dev/locales/{en-2JUZQ4KZ.js.map → en-7NUPYLED.js.map} +0 -0
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Excalidraw
2
2
 
3
- **Excalidraw** is exported as a component to be directly embedded in your project.
3
+ **Excalidraw** is exported as a React component that you can embed directly in your app.
4
4
 
5
5
  ## Installation
6
6
 
7
- Use `npm` or `yarn` to install the package.
7
+ Install the package together with its React peer dependencies.
8
8
 
9
9
  ```bash
10
10
  npm install react react-dom @excalidraw/excalidraw
@@ -12,34 +12,131 @@ npm install react react-dom @excalidraw/excalidraw
12
12
  yarn add react react-dom @excalidraw/excalidraw
13
13
  ```
14
14
 
15
- > **Note**: If you don't want to wait for the next stable release and try out the unreleased changes, use `@excalidraw/excalidraw@next`.
15
+ > **Note**: If you want to try unreleased changes, use `@excalidraw/excalidraw@next`.
16
16
 
17
- #### Self-hosting fonts
17
+ ## Quick start
18
18
 
19
- By default, Excalidraw will try to download all the used fonts from the [CDN](https://esm.run/@excalidraw/excalidraw/dist/prod).
19
+ The minimum working setup has two easy-to-miss requirements:
20
20
 
21
- For self-hosting purposes, you'll have to copy the content of the folder `node_modules/@excalidraw/excalidraw/dist/prod/fonts` to the path where your assets should be served from (i.e. `public/` directory in your project). In that case, you should also set `window.EXCALIDRAW_ASSET_PATH` to the very same path, i.e. `/` in case it's in the root:
21
+ 1. Import the package CSS:
22
22
 
23
- ```js
24
- <script>window.EXCALIDRAW_ASSET_PATH = "/";</script>
23
+ ```ts
24
+ import "@excalidraw/excalidraw/index.css";
25
25
  ```
26
26
 
27
- ### Dimensions of Excalidraw
27
+ 2. Render Excalidraw inside a container with a non-zero height.
28
28
 
29
- Excalidraw takes _100%_ of `width` and `height` of the containing block so make sure the container in which you render Excalidraw has non zero dimensions.
29
+ ```tsx
30
+ import { Excalidraw } from "@excalidraw/excalidraw";
31
+ import "@excalidraw/excalidraw/index.css";
32
+
33
+ export default function App() {
34
+ return (
35
+ <div style={{ height: "100vh" }}>
36
+ <Excalidraw />
37
+ </div>
38
+ );
39
+ }
40
+ ```
41
+
42
+ Excalidraw fills `100%` of the width and height of its parent. If the parent has no height, the canvas will not be visible.
43
+
44
+ ## Next.js / SSR frameworks
45
+
46
+ Excalidraw should be rendered on the client. In SSR frameworks such as Next.js, use a client component and load it dynamically with SSR disabled.
47
+
48
+ ```tsx
49
+ // app/components/ExcalidrawClient.tsx
50
+ "use client";
51
+
52
+ import { Excalidraw } from "@excalidraw/excalidraw";
53
+ import "@excalidraw/excalidraw/index.css";
54
+
55
+ export default function ExcalidrawClient() {
56
+ return (
57
+ <div style={{ height: "100vh" }}>
58
+ <Excalidraw />
59
+ </div>
60
+ );
61
+ }
62
+ ```
63
+
64
+ ```tsx
65
+ // app/page.tsx
66
+ import dynamic from "next/dynamic";
67
+
68
+ const ExcalidrawClient = dynamic(
69
+ () => import("./components/ExcalidrawClient"),
70
+ { ssr: false },
71
+ );
72
+
73
+ export default function Page() {
74
+ return <ExcalidrawClient />;
75
+ }
76
+ ```
77
+
78
+ See the local examples for complete setups:
79
+
80
+ - [examples/with-nextjs](https://github.com/excalidraw/excalidraw/tree/master/examples/with-nextjs)
81
+ - [examples/with-script-in-browser](https://github.com/excalidraw/excalidraw/tree/master/examples/with-script-in-browser)
82
+
83
+ ## LLM / agent tips
84
+
85
+ If an LLM or coding agent is setting up Excalidraw, these shortcuts usually save more time than re-prompting:
86
+
87
+ - Start with a plain `<Excalidraw />` in a `100vh` container. Add refs, `initialData`, persistence, or custom UI only after the base embed works.
88
+ - If the canvas is blank, check the CSS import and parent height first. Those are the two most common integration failures.
89
+ - In Next.js or other SSR frameworks, assume client-only rendering first. Use `"use client"` and `dynamic(..., { ssr: false })` before debugging hydration or `window is not defined` errors.
90
+ - If imports or entrypoints are unclear, inspect `node_modules/@excalidraw/excalidraw/package.json`. The installed package exports are the source of truth.
91
+ - Do not set `window.EXCALIDRAW_ASSET_PATH` unless you are intentionally self-hosting fonts/assets.
92
+ - When docs and generated code drift, copy the nearest working example from this repo, especially `examples/with-nextjs` or `examples/with-script-in-browser`.
93
+
94
+ ## Migrating to `@excalidraw/excalidraw@0.18.x`
95
+
96
+ Version `0.18.x` removes the old `types/`-prefixed deep import paths. If you were importing types from `@excalidraw/excalidraw/types/...`, switch to the new type-only subpaths below.
97
+
98
+ | Old path | New path |
99
+ | --- | --- |
100
+ | `@excalidraw/excalidraw/types/data/transform.js` | `@excalidraw/excalidraw/element/transform` |
101
+ | `@excalidraw/excalidraw/types/data/types.js` | `@excalidraw/excalidraw/data/types` |
102
+ | `@excalidraw/excalidraw/types/element/types.js` | `@excalidraw/excalidraw/element/types` |
103
+ | `@excalidraw/excalidraw/types/utility-types.js` | `@excalidraw/excalidraw/common/utility-types` |
104
+ | `@excalidraw/excalidraw/types/types.js` | `@excalidraw/excalidraw/types` |
105
+
106
+ Drop the `.js` extension. The new package `exports` map resolves these paths without it.
107
+
108
+ These deep subpaths are for `import type` only. Runtime imports should come from the package root, plus `@excalidraw/excalidraw/index.css` for styles.
109
+
110
+ For example:
111
+
112
+ ```ts
113
+ import { exportToSvg } from "@excalidraw/excalidraw";
114
+ ```
115
+
116
+ ## Self-hosting fonts
117
+
118
+ By default, Excalidraw downloads the fonts it needs from the [CDN](https://esm.run/@excalidraw/excalidraw/dist/prod).
119
+
120
+ For self-hosting, copy the contents of `node_modules/@excalidraw/excalidraw/dist/prod/fonts` into the path where your app serves static assets, for example `public/`. Then set `window.EXCALIDRAW_ASSET_PATH` to that same path:
121
+
122
+ ```html
123
+ <script>
124
+ window.EXCALIDRAW_ASSET_PATH = "/";
125
+ </script>
126
+ ```
30
127
 
31
128
  ## Demo
32
129
 
33
- Go to [CodeSandbox](https://codesandbox.io/p/sandbox/github/excalidraw/excalidraw/tree/master/examples/with-script-in-browser) example.
130
+ Try the [CodeSandbox example](https://codesandbox.io/p/sandbox/github/excalidraw/excalidraw/tree/master/examples/with-script-in-browser).
34
131
 
35
132
  ## Integration
36
133
 
37
- Head over to the [docs](https://docs.excalidraw.com/docs/@excalidraw/excalidraw/integration).
134
+ Read the [integration docs](https://docs.excalidraw.com/docs/@excalidraw/excalidraw/integration).
38
135
 
39
136
  ## API
40
137
 
41
- Head over to the [docs](https://docs.excalidraw.com/docs/@excalidraw/excalidraw/api).
138
+ Read the [API docs](https://docs.excalidraw.com/docs/@excalidraw/excalidraw/api).
42
139
 
43
140
  ## Contributing
44
141
 
45
- Head over to the [docs](https://docs.excalidraw.com/docs/@excalidraw/excalidraw/contributing).
142
+ Read the [contributing docs](https://docs.excalidraw.com/docs/@excalidraw/excalidraw/contributing).