mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix singular elements
This commit is contained in:
parent
596edaea62
commit
6c41e507db
3 changed files with 9 additions and 18 deletions
|
@ -18,6 +18,7 @@ import {
|
||||||
TextAlign,
|
TextAlign,
|
||||||
VerticalAlign,
|
VerticalAlign,
|
||||||
} from "../element/types";
|
} from "../element/types";
|
||||||
|
import { randomId } from "../random";
|
||||||
import { MarkOptional } from "../utility-types";
|
import { MarkOptional } from "../utility-types";
|
||||||
import { ImportedDataState } from "./types";
|
import { ImportedDataState } from "./types";
|
||||||
|
|
||||||
|
@ -262,9 +263,10 @@ export const convertToExcalidrawElements = (
|
||||||
} else {
|
} else {
|
||||||
let excalidrawElement;
|
let excalidrawElement;
|
||||||
if (element.type === "text") {
|
if (element.type === "text") {
|
||||||
excalidrawElement = {
|
excalidrawElement = newTextElement({
|
||||||
...element,
|
...element,
|
||||||
} as ExcalidrawTextElement;
|
});
|
||||||
|
|
||||||
excalidrawElements.push(excalidrawElement);
|
excalidrawElements.push(excalidrawElement);
|
||||||
} else if (element.type === "arrow" || element.type === "line") {
|
} else if (element.type === "arrow" || element.type === "line") {
|
||||||
const { linearElement, startBoundElement, endBoundElement } =
|
const { linearElement, startBoundElement, endBoundElement } =
|
||||||
|
@ -286,6 +288,7 @@ export const convertToExcalidrawElements = (
|
||||||
} else {
|
} else {
|
||||||
excalidrawElement = {
|
excalidrawElement = {
|
||||||
...element,
|
...element,
|
||||||
|
id: element.id || randomId(),
|
||||||
width:
|
width:
|
||||||
element?.width ||
|
element?.width ||
|
||||||
(ELEMENTS_SUPPORTING_PROGRAMMATIC_API.includes(element.type)
|
(ELEMENTS_SUPPORTING_PROGRAMMATIC_API.includes(element.type)
|
||||||
|
|
|
@ -3,6 +3,7 @@ import {
|
||||||
ExcalidrawElement,
|
ExcalidrawElement,
|
||||||
ExcalidrawGenericElement,
|
ExcalidrawGenericElement,
|
||||||
ExcalidrawLinearElement,
|
ExcalidrawLinearElement,
|
||||||
|
ExcalidrawTextElement,
|
||||||
FontFamilyValues,
|
FontFamilyValues,
|
||||||
TextAlign,
|
TextAlign,
|
||||||
VerticalAlign,
|
VerticalAlign,
|
||||||
|
@ -46,21 +47,8 @@ export interface ImportedDataState {
|
||||||
source?: string;
|
source?: string;
|
||||||
elements?:
|
elements?:
|
||||||
| readonly (
|
| readonly (
|
||||||
| (ExcalidrawElement & {
|
|
||||||
id?: ExcalidrawElement["id"];
|
|
||||||
label?: {
|
|
||||||
text: string;
|
|
||||||
fontSize?: number;
|
|
||||||
fontFamily?: FontFamilyValues;
|
|
||||||
textAlign?: TextAlign;
|
|
||||||
verticalAlign?: VerticalAlign;
|
|
||||||
} & MarkOptional<ElementConstructorOpts, "x" | "y">;
|
|
||||||
} & ElementConstructorOpts)
|
|
||||||
| ({
|
| ({
|
||||||
type: Exclude<
|
type: Exclude<ExcalidrawElement["type"], "text">;
|
||||||
typeof ELEMENTS_SUPPORTING_PROGRAMMATIC_API[number],
|
|
||||||
"text"
|
|
||||||
>;
|
|
||||||
id?: ExcalidrawElement["id"];
|
id?: ExcalidrawElement["id"];
|
||||||
label?: {
|
label?: {
|
||||||
text: string;
|
text: string;
|
||||||
|
@ -73,7 +61,7 @@ export interface ImportedDataState {
|
||||||
| ({
|
| ({
|
||||||
type: "text";
|
type: "text";
|
||||||
text: string;
|
text: string;
|
||||||
id?: ExcalidrawBindableElement["id"];
|
id?: ExcalidrawTextElement["id"];
|
||||||
} & ElementConstructorOpts)
|
} & ElementConstructorOpts)
|
||||||
| ({
|
| ({
|
||||||
type: ExcalidrawLinearElement["type"];
|
type: ExcalidrawLinearElement["type"];
|
||||||
|
|
|
@ -158,7 +158,7 @@ export const newTextElement = (
|
||||||
fontFamily?: FontFamilyValues;
|
fontFamily?: FontFamilyValues;
|
||||||
textAlign?: TextAlign;
|
textAlign?: TextAlign;
|
||||||
verticalAlign?: VerticalAlign;
|
verticalAlign?: VerticalAlign;
|
||||||
containerId?: ExcalidrawTextContainer["id"];
|
containerId?: ExcalidrawTextContainer["id"] | null;
|
||||||
lineHeight?: ExcalidrawTextElement["lineHeight"];
|
lineHeight?: ExcalidrawTextElement["lineHeight"];
|
||||||
strokeWidth?: ExcalidrawTextElement["strokeWidth"];
|
strokeWidth?: ExcalidrawTextElement["strokeWidth"];
|
||||||
} & ElementConstructorOpts,
|
} & ElementConstructorOpts,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue