mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
let host call convertToExcalidrawElements when using programmatic API
This commit is contained in:
parent
c1a61b06df
commit
25e2f80709
5 changed files with 58 additions and 48 deletions
|
@ -24,15 +24,43 @@ import {
|
|||
import {
|
||||
ExcalidrawBindableElement,
|
||||
ExcalidrawElement,
|
||||
ExcalidrawFreeDrawElement,
|
||||
ExcalidrawGenericElement,
|
||||
ExcalidrawImageElement,
|
||||
ExcalidrawLinearElement,
|
||||
ExcalidrawSelectionElement,
|
||||
ExcalidrawTextElement,
|
||||
} from "../element/types";
|
||||
import { MarkOptional } from "../utility-types";
|
||||
import { getFontString } from "../utils";
|
||||
import { ImportedDataState, ValidContainer, ValidLinearElement } from "./types";
|
||||
import { ValidContainer, ValidLinearElement } from "./types";
|
||||
|
||||
export interface ExcalidrawProgrammaticAPI {
|
||||
elements?:
|
||||
| readonly (
|
||||
| Extract<
|
||||
ExcalidrawElement,
|
||||
| ExcalidrawSelectionElement
|
||||
| ExcalidrawImageElement
|
||||
| ExcalidrawFreeDrawElement
|
||||
>
|
||||
| ({
|
||||
type: Extract<ExcalidrawLinearElement["type"], "line">;
|
||||
x: number;
|
||||
y: number;
|
||||
} & Partial<ExcalidrawLinearElement>)
|
||||
| ValidContainer
|
||||
| ValidLinearElement
|
||||
| ({
|
||||
type: "text";
|
||||
text: string;
|
||||
x: number;
|
||||
y: number;
|
||||
id?: ExcalidrawTextElement["id"];
|
||||
} & Partial<ExcalidrawTextElement>)
|
||||
)[]
|
||||
| null;
|
||||
}
|
||||
export const ELEMENTS_SUPPORTING_PROGRAMMATIC_API = [
|
||||
"rectangle",
|
||||
"ellipse",
|
||||
|
@ -307,7 +335,7 @@ const excalidrawElements = (() => {
|
|||
})();
|
||||
|
||||
export const convertToExcalidrawElements = (
|
||||
elements: ImportedDataState["elements"],
|
||||
elements: ExcalidrawProgrammaticAPI["elements"],
|
||||
): ExcalidrawElement[] => {
|
||||
excalidrawElements.clear();
|
||||
if (!elements) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue