Move all remaining files in src

This commit is contained in:
Deepen Timalsina 2025-04-15 20:54:26 +05:45
parent e75a7b45d6
commit c48d847f62
524 changed files with 538 additions and 547 deletions

View file

@ -5,7 +5,7 @@
**How to use**
```js
import { FONT_FAMILY } from "@excalidraw/excalidraw";
import { FONT_FAMILY } from "@excalidraw/excalidraw/src";
```
`FONT_FAMILY` contains all the font families used in `Excalidraw`. The default families are the following:
@ -23,7 +23,7 @@ Pre-selected family is `FONT_FAMILY.Excalifont`, unless it's overriden with `ini
**How to use**
```js
import { THEME } from "@excalidraw/excalidraw";
import { THEME } from "@excalidraw/excalidraw/src";
```
`THEME` contains all the themes supported by `Excalidraw` as explained below
@ -42,5 +42,5 @@ Defaults to `THEME.LIGHT` unless passed in `initialData.appState.theme`
**How to use **
```js
import { MIME_TYPES } from "@excalidraw/excalidraw";
import { MIME_TYPES } from "@excalidraw/excalidraw/src";
```

View file

@ -25,7 +25,7 @@ convertToExcalidrawElements(
**_How to use_**
```js
import { convertToExcalidrawElements } from "@excalidraw/excalidraw";
import { convertToExcalidrawElements } from "@excalidraw/excalidraw/src";
```
This function converts the Excalidraw Element Skeleton to excalidraw elements which could be then rendered on the canvas. Hence calling this function is necessary before passing it to APIs like [`initialData`](https://docs.excalidraw.com/docs/@excalidraw/excalidraw/api/props/initialdata), [`updateScene`](https://docs.excalidraw.com/docs/@excalidraw/excalidraw/api/props/excalidraw-api#updatescene) if you are using the Skeleton API

View file

@ -193,7 +193,7 @@ const onLinkOpen: ExcalidrawProps["onLinkOpen"] = useCallback(
Determines the `language` of the UI. It should be one of the [available language codes](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/i18n.ts#L14). Defaults to `en` (English). We also export default language and supported languages which you can import as shown below.
```js
import { defaultLang, languages } from "@excalidraw/excalidraw";
import { defaultLang, languages } from "@excalidraw/excalidraw/src";
```
| name | type |

View file

@ -47,7 +47,7 @@ A function which returns the `width`, `height`, and optionally `scale` (defaults
**How to use**
```js
import { exportToCanvas } from "@excalidraw/excalidraw";
import { exportToCanvas } from "@excalidraw/excalidraw/src";
```
This function returns the canvas with the exported elements, appState and dimensions.
@ -122,7 +122,7 @@ exportToBlob(<br/>&nbsp;
**How to use**
```js
import { exportToBlob } from "@excalidraw/excalidraw";
import { exportToBlob } from "@excalidraw/excalidraw/src";
```
Returns a promise which resolves with a [blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob). It internally uses [canvas.ToBlob](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob).
@ -181,7 +181,7 @@ exportToClipboard(<br/>&nbsp;
**How to use**
```js
import { exportToClipboard } from "@excalidraw/excalidraw";
import { exportToClipboard } from "@excalidraw/excalidraw/src";
```
Copies the scene data in the specified format (determined by `type`) to clipboard.

View file

@ -14,7 +14,7 @@ restoreAppState(appState: <a href="https://github.com/excalidraw/excalidraw/blob
**_How to use_**
```js
import { restoreAppState } from "@excalidraw/excalidraw";
import { restoreAppState } from "@excalidraw/excalidraw/src";
```
This function will make sure all the `keys` have appropriate `values` in [appState](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/types.ts#L95) and if any key is missing, it will be set to its `default` value.
@ -58,7 +58,7 @@ The extra optional parameter to configure restored elements. It has the followin
**_How to use_**
```js
import { restoreElements } from "@excalidraw/excalidraw";
import { restoreElements } from "@excalidraw/excalidraw/src";
```
This function will make sure all properties of element is correctly set and if any attribute is missing, it will be set to its default value.
@ -84,7 +84,7 @@ See [`restoreAppState()`](https://github.com/excalidraw/excalidraw/blob/master/p
**_How to use_**
```js
import { restore } from "@excalidraw/excalidraw";
import { restore } from "@excalidraw/excalidraw/src";
```
This function makes sure elements and state is set to appropriate values and set to default value if not present. It is a combination of [restoreElements](#restoreelements) and [restoreAppState](#restoreappstate).
@ -101,7 +101,7 @@ defaultStatus: "published" | "unpublished")
**_How to use_**
```js
import { restoreLibraryItems } from "@excalidraw/excalidraw";
import { restoreLibraryItems } from "@excalidraw/excalidraw/src";
restoreLibraryItems(libraryItems, "unpublished");
```

View file

@ -24,7 +24,7 @@ serializeAsJSON(&#123;<br/>&nbsp;
**How to use**
```js
import { serializeAsJSON } from "@excalidraw/excalidraw";
import { serializeAsJSON } from "@excalidraw/excalidraw/src";
```
### serializeLibraryAsJSON
@ -43,7 +43,7 @@ serializeLibraryAsJSON(
**How to use**
```js
import { serializeLibraryAsJSON } from "@excalidraw/excalidraw";
import { serializeLibraryAsJSON } from "@excalidraw/excalidraw/src";
```
#### isInvisiblySmallElement
@ -59,7 +59,7 @@ isInvisiblySmallElement(element: <a href="https://github.com/excalidraw/excalid
**How to use**
```js
import { isInvisiblySmallElement } from "@excalidraw/excalidraw";
import { isInvisiblySmallElement } from "@excalidraw/excalidraw/src";
```
### loadFromBlob
@ -69,7 +69,7 @@ This function loads the scene data from the blob (or file). If you pass `localAp
**How to use**
```js
import { loadFromBlob } from "@excalidraw/excalidraw";
import { loadFromBlob } from "@excalidraw/excalidraw/src";
const scene = await loadFromBlob(file, null, null);
excalidrawAPI.updateScene(scene);
@ -93,7 +93,7 @@ This function loads the library from the blob. Additonally takes `defaultStatus`
**How to use **
```js
import { loadLibraryFromBlob } from "@excalidraw/excalidraw";
import { loadLibraryFromBlob } from "@excalidraw/excalidraw/src";
```
**_Signature_**
@ -115,7 +115,7 @@ Throws if blob doesn't contain valid `scene` data or `library` data.
**How to use**
```js showLineNumbers
import { loadSceneOrLibraryFromBlob, MIME_TYPES } from "@excalidraw/excalidraw";
import { loadSceneOrLibraryFromBlob, MIME_TYPES } from "@excalidraw/excalidraw/src";
const contents = await loadSceneOrLibraryFromBlob(file, null, null);
if (contents.type === MIME_TYPES.excalidraw) {
@ -143,7 +143,7 @@ This function returns the `free draw` svg path for the element.
**How to use**
```js
import { getFreeDrawSvgPath } from "@excalidraw/excalidraw";
import { getFreeDrawSvgPath } from "@excalidraw/excalidraw/src";
```
**Signature**
@ -159,7 +159,7 @@ This function returns true if the element is `linear` type (`arrow` |`line`) els
**How to use**
```js
import { isLinearElement } from "@excalidraw/excalidraw";
import { isLinearElement } from "@excalidraw/excalidraw/src";
```
**Signature**
@ -175,7 +175,7 @@ This function returns an array of `deleted` elements.
**How to use**
```js
import { getNonDeletedElements } from "@excalidraw/excalidraw";
import { getNonDeletedElements } from "@excalidraw/excalidraw/src";
```
**Signature**
@ -189,7 +189,7 @@ getNonDeletedElements(elements:<a href="https://github.com/excalidraw/excalidraw
This function merges two `LibraryItems` arrays, where unique items from `otherItems` are sorted first in the returned array.
```js
import { mergeLibraryItems } from "@excalidraw/excalidraw";
import { mergeLibraryItems } from "@excalidraw/excalidraw/src";
```
**_Signature_**
@ -208,7 +208,7 @@ Parses library parameters from URL if present (expects the `#addLibrary` hash ke
**How to use**
```js
import { parseLibraryTokensFromUrl } from "@excalidraw/excalidraw";
import { parseLibraryTokensFromUrl } from "@excalidraw/excalidraw/src";
```
**Signature**
@ -227,7 +227,7 @@ A hook that automatically imports library from url if `#addLibrary` hash key exi
**How to use**
```js
import { useHandleLibrary } from "@excalidraw/excalidraw";
import { useHandleLibrary } from "@excalidraw/excalidraw/src";
export const App = () => {
// ...
@ -259,7 +259,7 @@ getSceneVersion(elements: <a href="https://github.com/excalidraw/excalidraw/blo
**How to use**
```js
import { getSceneVersion } from "@excalidraw/excalidraw";
import { getSceneVersion } from "@excalidraw/excalidraw/src";
```
### sceneCoordsToViewportCoords
@ -267,7 +267,7 @@ import { getSceneVersion } from "@excalidraw/excalidraw";
This function returns equivalent `viewport` coords for the provided `scene` coords in params.
```js
import { sceneCoordsToViewportCoords } from "@excalidraw/excalidraw";
import { sceneCoordsToViewportCoords } from "@excalidraw/excalidraw/src";
```
**_Signature_**
@ -282,7 +282,7 @@ sceneCoordsToViewportCoords(&#123; sceneX: number, sceneY: number },<br/>&nbsp;
This function returns equivalent `scene` coords for the provided `viewport` coords in params.
```js
import { viewportCoordsToSceneCoords } from "@excalidraw/excalidraw";
import { viewportCoordsToSceneCoords } from "@excalidraw/excalidraw/src";
```
**_Signature_**
@ -354,7 +354,7 @@ To help with localization, we export the following.
| `useI18n` | [`() => { langCode, t }`](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/i18n.ts#L15) |
```js
import { defaultLang, languages, useI18n } from "@excalidraw/excalidraw";
import { defaultLang, languages, useI18n } from "@excalidraw/excalidraw/src";
```
#### defaultLang
@ -407,7 +407,7 @@ getCommonBounds(
**_How to use_**
```js
import { getCommonBounds } from "@excalidraw/excalidraw";
import { getCommonBounds } from "@excalidraw/excalidraw/src";
```
### elementsOverlappingBBox
@ -436,7 +436,7 @@ elementsOverlappingBBox(<br/>&nbsp;
**_How to use_**
```js
import { elementsOverlappingBBox } from "@excalidraw/excalidraw";
import { elementsOverlappingBBox } from "@excalidraw/excalidraw/src";
```
### isElementInsideBBox
@ -456,7 +456,7 @@ isElementInsideBBox(<br/>&nbsp;
**_How to use_**
```js
import { isElementInsideBBox } from "@excalidraw/excalidraw";
import { isElementInsideBBox } from "@excalidraw/excalidraw/src";
```
### elementPartiallyOverlapsWithOrContainsBBox
@ -475,5 +475,5 @@ elementPartiallyOverlapsWithOrContainsBBox(<br/>&nbsp;
**_How to use_**
```js
import { elementPartiallyOverlapsWithOrContainsBBox } from "@excalidraw/excalidraw";
import { elementPartiallyOverlapsWithOrContainsBBox } from "@excalidraw/excalidraw/src";
```

View file

@ -5,7 +5,7 @@
If you are using a module bundler (for instance, Webpack), you can import it as an ES6 module as shown below
```js
import { Excalidraw } from "@excalidraw/excalidraw";
import { Excalidraw } from "@excalidraw/excalidraw/src";
```
:::info
@ -39,7 +39,7 @@ If you want to only import `Excalidraw` component you can do :point_down:
```jsx showLineNumbers
import dynamic from "next/dynamic";
const Excalidraw = dynamic(
async () => (await import("@excalidraw/excalidraw")).Excalidraw,
async () => (await import("@excalidraw/excalidraw/src")).Excalidraw,
{
ssr: false,
},
@ -58,7 +58,7 @@ If you are using `pages router` then importing the wrapper dynamically would wor
```jsx showLineNumbers
"use client";
import { Excalidraw, convertToExcalidrawElements } from "@excalidraw/excalidraw";
import { Excalidraw, convertToExcalidrawElements } from "@excalidraw/excalidraw/src";
import "@excalidraw/excalidraw/index.css";
@ -131,7 +131,7 @@ If you are using `pages router` then importing the wrapper dynamically would wor
{/* Link should be updated to point to the latest! */}
Here is a [source code](https://github.com/excalidraw/excalidraw/tree/master/examples/with-nextjs) for the example with app and pages router. You you can try it out [here](https://excalidraw-package-example-with-nextjs.vercel.app/).
The `types` are available at `@excalidraw/excalidraw/types`, check [CodeSandbox](https://codesandbox.io/p/sandbox/github/excalidraw/excalidraw/tree/master/examples/with-script-in-browser) example for details.
The `types` are available at `@excalidraw/excalidraw/src/types`, check [CodeSandbox](https://codesandbox.io/p/sandbox/github/excalidraw/excalidraw/tree/master/examples/with-script-in-browser) example for details.
### Preact

View file

@ -12,7 +12,7 @@ This API receives the mermaid syntax as the input, and resolves to skeleton Exca
```ts
import { parseMermaidToExcalidraw } from "@excalidraw/mermaid-to-excalidraw";
import { convertToExcalidrawElements} from "@excalidraw/excalidraw"
import { convertToExcalidrawElements} from "@excalidraw/excalidraw/src"
try {
const { elements, files } = await parseMermaidToExcalidraw(mermaidSyntax: string, {
fontSize: number,

View file

@ -20,7 +20,7 @@ Once the library is installed, its ready to use.
```js
import { parseMermaidToExcalidraw } from "@excalidraw/mermaid-to-excalidraw";
import { convertToExcalidrawElements} from "@excalidraw/excalidraw"
import { convertToExcalidrawElements} from "@excalidraw/excalidraw/src"
try {
const { elements, files } = await parseMermaid(diagramDefinition, {

View file

@ -30,7 +30,7 @@ const sidebars = {
},
{
type: "category",
label: "@excalidraw/excalidraw",
label: "@excalidraw/excalidraw/src",
collapsed: false,
items: [
"@excalidraw/excalidraw/installation",

View file

@ -7,7 +7,7 @@ import "@excalidraw/excalidraw/index.css";
let ExcalidrawComp = {};
if (ExecutionEnvironment.canUseDOM) {
ExcalidrawComp = require("@excalidraw/excalidraw");
ExcalidrawComp = require("@excalidraw/excalidraw/src");
}
const Excalidraw = React.forwardRef((props, ref) => {
if (!window.EXCALIDRAW_ASSET_PATH) {