mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix
This commit is contained in:
parent
15b5295baf
commit
7087db42c0
5 changed files with 18 additions and 16 deletions
|
@ -1,4 +1,3 @@
|
|||
//@ts-nocheck
|
||||
import {
|
||||
ExcalidrawElement,
|
||||
ExcalidrawSelectionElement,
|
||||
|
@ -393,7 +392,9 @@ export const restoreElements = (
|
|||
migratedElement = { ...migratedElement, id: randomId() };
|
||||
}
|
||||
existingIds.add(migratedElement.id);
|
||||
//@ts-ignore
|
||||
if (element.children?.length) {
|
||||
//@ts-ignore
|
||||
const newElements = updateElementChildren(element);
|
||||
if (newElements) {
|
||||
elements.push(...newElements);
|
||||
|
@ -552,7 +553,6 @@ export const restore = (
|
|||
localElements: readonly ExcalidrawElement[] | null | undefined,
|
||||
elementsConfig?: { refreshDimensions?: boolean; repairBindings?: boolean },
|
||||
): RestoredDataState => {
|
||||
console.log(restoreElements(data?.elements, localElements, elementsConfig));
|
||||
return {
|
||||
elements: restoreElements(data?.elements, localElements, elementsConfig),
|
||||
appState: restoreAppState(data?.appState, localAppState || null),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ExcalidrawElement, ExcalidrawTextContainer } from "../element/types";
|
||||
import { ExcalidrawElement } from "../element/types";
|
||||
import {
|
||||
AppState,
|
||||
BinaryFiles,
|
||||
|
@ -8,8 +8,6 @@ import {
|
|||
import type { cleanAppStateForExport } from "../appState";
|
||||
import { VERSIONS } from "../constants";
|
||||
|
||||
import { ElementConstructorOpts } from "../element/newElement";
|
||||
|
||||
export interface ExportedDataState {
|
||||
type: string;
|
||||
version: number;
|
||||
|
|
|
@ -12,6 +12,7 @@ import {
|
|||
ExcalidrawFreeDrawElement,
|
||||
FontFamilyValues,
|
||||
ExcalidrawTextContainer,
|
||||
NonDeletedExcalidrawElement,
|
||||
} from "../element/types";
|
||||
import {
|
||||
arrayToMap,
|
||||
|
@ -48,6 +49,7 @@ import {
|
|||
} from "../constants";
|
||||
import { isArrowElement, isTextElement } from "./typeChecks";
|
||||
import { MarkOptional, Merge, Mutable } from "../utility-types";
|
||||
import { Children } from "react";
|
||||
|
||||
export type ElementConstructorOpts = MarkOptional<
|
||||
Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">,
|
||||
|
@ -647,14 +649,19 @@ export const duplicateElements = (
|
|||
return clonedElements;
|
||||
};
|
||||
|
||||
export const updateElementChildren = (
|
||||
element: {
|
||||
type: ExcalidrawElement["type"];
|
||||
} & MarkOptional<ElementConstructorOpts, "x" | "y">,
|
||||
) => {
|
||||
const textElement = element.children!.find((child) => child.text !== null);
|
||||
export const updateElementChildren = (element: {
|
||||
type: ExcalidrawGenericElement["type"];
|
||||
children?: [
|
||||
{ text: string } & MarkOptional<ElementConstructorOpts, "x" | "y">,
|
||||
] &
|
||||
MarkOptional<ElementConstructorOpts, "x" | "y">;
|
||||
}) => {
|
||||
const textElement = element.children?.find(
|
||||
(
|
||||
child: { text: string } & MarkOptional<ElementConstructorOpts, "x" | "y">,
|
||||
) => child.text !== null,
|
||||
);
|
||||
if (isValidTextContainer(element) && textElement) {
|
||||
//@ts-ignore
|
||||
const elements = bindTextToContainer(element, textElement);
|
||||
return elements;
|
||||
}
|
||||
|
|
|
@ -66,9 +66,6 @@ type _ExcalidrawElementBase = Readonly<{
|
|||
link: string | null;
|
||||
locked: boolean;
|
||||
customData?: Record<string, any>;
|
||||
children?: [
|
||||
{ text: string } & MarkOptional<ElementConstructorOpts, "x" | "y">,
|
||||
];
|
||||
}>;
|
||||
|
||||
export type ExcalidrawSelectionElement = _ExcalidrawElementBase & {
|
||||
|
|
|
@ -349,9 +349,9 @@ const ExcalidrawWrapper = () => {
|
|||
version: 2,
|
||||
source: "http://localhost:3000",
|
||||
elements: [
|
||||
//@ts-ignore
|
||||
{
|
||||
type: "rectangle",
|
||||
//@ts-ignore
|
||||
children: [{ text: "HELLO DAMMMMY" }],
|
||||
},
|
||||
],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue