mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
make image attributes optional and better ts check
This commit is contained in:
parent
bdb84b01ca
commit
bf3afc34ed
3 changed files with 45 additions and 40 deletions
|
@ -134,7 +134,6 @@ export interface ExcalidrawProgrammaticAPI {
|
||||||
| Extract<
|
| Extract<
|
||||||
ExcalidrawElement,
|
ExcalidrawElement,
|
||||||
| ExcalidrawSelectionElement
|
| ExcalidrawSelectionElement
|
||||||
| ExcalidrawImageElement
|
|
||||||
| ExcalidrawFreeDrawElement
|
| ExcalidrawFreeDrawElement
|
||||||
| ExcalidrawFrameElement
|
| ExcalidrawFrameElement
|
||||||
>
|
>
|
||||||
|
@ -152,6 +151,11 @@ export interface ExcalidrawProgrammaticAPI {
|
||||||
y: number;
|
y: number;
|
||||||
id?: ExcalidrawTextElement["id"];
|
id?: ExcalidrawTextElement["id"];
|
||||||
} & Partial<ExcalidrawTextElement>)
|
} & Partial<ExcalidrawTextElement>)
|
||||||
|
| ({
|
||||||
|
type: Extract<ExcalidrawImageElement["type"], "image">;
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
} & Partial<ExcalidrawImageElement>)
|
||||||
)[]
|
)[]
|
||||||
| null;
|
| null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,9 +146,7 @@ export default function App({ appTitle, useCustom, customArgs }: AppProps) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
initialStatePromiseRef.current.promise.resolve({
|
initialStatePromiseRef.current.promise.resolve({
|
||||||
...initialData,
|
...initialData,
|
||||||
elements: convertToExcalidrawElements(
|
elements: convertToExcalidrawElements(initialData.elements),
|
||||||
initialData.elements as ExcalidrawProgrammaticAPI["elements"],
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
excalidrawAPI.addFiles(imagesArray);
|
excalidrawAPI.addFiles(imagesArray);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
export default {
|
import { ExcalidrawProgrammaticAPI } from "../../../data/transform";
|
||||||
elements: [
|
import { FileId } from "../../../element/types";
|
||||||
|
|
||||||
|
const elements: ExcalidrawProgrammaticAPI["elements"] = [
|
||||||
{
|
{
|
||||||
type: "rectangle",
|
type: "rectangle",
|
||||||
x: 10,
|
x: 10,
|
||||||
y: 10,
|
y: 10,
|
||||||
strokeWidth: "2",
|
strokeWidth: 2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "diamond",
|
type: "diamond",
|
||||||
x: 120,
|
x: 120,
|
||||||
y: 20,
|
y: 20,
|
||||||
backgroundColor: "#fff3bf",
|
backgroundColor: "#fff3bf",
|
||||||
strokeWidth: "2",
|
strokeWidth: 2,
|
||||||
label: {
|
label: {
|
||||||
text: "HELLO EXCALIDRAW",
|
text: "HELLO EXCALIDRAW",
|
||||||
strokeColor: "#099268",
|
strokeColor: "#099268",
|
||||||
|
@ -26,16 +28,17 @@ export default {
|
||||||
start: { type: "rectangle" },
|
start: { type: "rectangle" },
|
||||||
end: { type: "ellipse" },
|
end: { type: "ellipse" },
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
fileId: "rocket",
|
fileId: "rocket" as FileId,
|
||||||
type: "image",
|
type: "image",
|
||||||
x: 606.1042326312408,
|
x: 606.1042326312408,
|
||||||
y: 153.57729779411773,
|
y: 153.57729779411773,
|
||||||
width: 231.30325348751828,
|
width: 231.30325348751828,
|
||||||
height: 231.64340533088227,
|
height: 231.64340533088227,
|
||||||
},
|
},
|
||||||
],
|
];
|
||||||
|
export default {
|
||||||
|
elements,
|
||||||
appState: { viewBackgroundColor: "#AFEEEE", currentItemFontFamily: 1 },
|
appState: { viewBackgroundColor: "#AFEEEE", currentItemFontFamily: 1 },
|
||||||
scrollToContent: true,
|
scrollToContent: true,
|
||||||
libraryItems: [
|
libraryItems: [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue