mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-22 17:00:40 +02:00
minor cleanup
This commit is contained in:
@@ -2057,7 +2057,6 @@ export class ElementsDelta implements DeltaContainer<SceneElementsMap> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static stripIrrelevantProps(partial: ElementPartial): ElementPartial {
|
private static stripIrrelevantProps(partial: ElementPartial): ElementPartial {
|
||||||
// ElementPartial already excludes id, updated, seed; defensively strip if present
|
|
||||||
const {
|
const {
|
||||||
id: _id,
|
id: _id,
|
||||||
updated: _updated,
|
updated: _updated,
|
||||||
|
@@ -455,10 +455,6 @@ export const computeStickyNoteFontSize = (
|
|||||||
text: string,
|
text: string,
|
||||||
element: ExcalidrawTextElement,
|
element: ExcalidrawTextElement,
|
||||||
container: ExcalidrawTextContainer,
|
container: ExcalidrawTextContainer,
|
||||||
/**
|
|
||||||
* Upper cap to which the font size is allowed to grow back during this
|
|
||||||
* editing session (snapped). If not provided defaults to global max.
|
|
||||||
*/
|
|
||||||
maxGrowFontSize?: number,
|
maxGrowFontSize?: number,
|
||||||
): StickyNoteFontComputationResult => {
|
): StickyNoteFontComputationResult => {
|
||||||
const step = STICKY_NOTE_FONT_STEP;
|
const step = STICKY_NOTE_FONT_STEP;
|
||||||
@@ -468,10 +464,7 @@ export const computeStickyNoteFontSize = (
|
|||||||
const snap = (size: number) =>
|
const snap = (size: number) =>
|
||||||
Math.max(
|
Math.max(
|
||||||
STICKY_NOTE_MIN_FONT_SIZE,
|
STICKY_NOTE_MIN_FONT_SIZE,
|
||||||
Math.min(
|
|
||||||
STICKY_NOTE_MAX_FONT_SIZE,
|
|
||||||
Math.max(step, Math.floor(size / step) * step),
|
Math.max(step, Math.floor(size / step) * step),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let size = snap(element.fontSize);
|
let size = snap(element.fontSize);
|
||||||
@@ -548,8 +541,6 @@ export const refreshTextDimensions = (
|
|||||||
: textElement.width,
|
: textElement.width,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// NOTE: sticky note font auto-sizing is handled during editing (WYSIWYG)
|
|
||||||
// so we keep refresh logic unchanged to avoid side-effects elsewhere.
|
|
||||||
const dimensions = getAdjustedDimensions(textElement, elementsMap, text);
|
const dimensions = getAdjustedDimensions(textElement, elementsMap, text);
|
||||||
return { text, ...dimensions };
|
return { text, ...dimensions };
|
||||||
};
|
};
|
||||||
|
@@ -185,7 +185,8 @@ const restoreElementWithProperties = <
|
|||||||
element: T,
|
element: T,
|
||||||
extra: Pick<
|
extra: Pick<
|
||||||
T,
|
T,
|
||||||
// @ts-ignore
|
// This extra Pick<T, keyof K> ensure no excess properties are passed.
|
||||||
|
// @ts-ignore TS complains here but type checks the call sites fine.
|
||||||
keyof K
|
keyof K
|
||||||
> &
|
> &
|
||||||
Partial<Pick<ExcalidrawElement, "type" | "x" | "y" | "customData">>,
|
Partial<Pick<ExcalidrawElement, "type" | "x" | "y" | "customData">>,
|
||||||
@@ -195,6 +196,8 @@ const restoreElementWithProperties = <
|
|||||||
const base: Pick<T, keyof ExcalidrawElement> = {
|
const base: Pick<T, keyof ExcalidrawElement> = {
|
||||||
type: nextType,
|
type: nextType,
|
||||||
version: element.version || 1,
|
version: element.version || 1,
|
||||||
|
// all elements must have version > 0 so getSceneVersion() will pick up
|
||||||
|
// newly added elements
|
||||||
versionNonce: element.versionNonce ?? 0,
|
versionNonce: element.versionNonce ?? 0,
|
||||||
index: element.index ?? null,
|
index: element.index ?? null,
|
||||||
isDeleted: element.isDeleted ?? false,
|
isDeleted: element.isDeleted ?? false,
|
||||||
@@ -248,12 +251,16 @@ const restoreElementWithProperties = <
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ret = {
|
const ret = {
|
||||||
|
// spread the original element properties to not lose unknown ones
|
||||||
|
// for forward-compatibility
|
||||||
...element,
|
...element,
|
||||||
|
// normalized properties
|
||||||
...base,
|
...base,
|
||||||
...getNormalizedDimensions(base),
|
...getNormalizedDimensions(base),
|
||||||
...extra,
|
...extra,
|
||||||
} as unknown as T;
|
} as unknown as T;
|
||||||
|
|
||||||
|
// strip legacy props (migrated in previous steps)
|
||||||
delete (ret as any).strokeSharpness;
|
delete (ret as any).strokeSharpness;
|
||||||
delete (ret as any).boundElementIds;
|
delete (ret as any).boundElementIds;
|
||||||
|
|
||||||
|
@@ -131,7 +131,6 @@ export const textWysiwyg = ({
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Sticky note: remember initial font size for this edit session
|
|
||||||
let stickyNoteInitialFontSize: number | null = null;
|
let stickyNoteInitialFontSize: number | null = null;
|
||||||
|
|
||||||
const updateWysiwygStyle = () => {
|
const updateWysiwygStyle = () => {
|
||||||
|
Reference in New Issue
Block a user