mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
improve & granularize ExcalidrawElement types (#991)
* improve & granularize ExcalidrawElement types * fix incorrectly passing type * fix tests * fix more tests * fix unnecessary spreads & refactor * add comments
This commit is contained in:
parent
1c545c1d47
commit
373d16abe6
22 changed files with 430 additions and 272 deletions
|
@ -2,6 +2,7 @@ import { AppState } from "./types";
|
|||
import { ExcalidrawElement } from "./element/types";
|
||||
import { clearAppStatePropertiesForHistory } from "./appState";
|
||||
import { newElementWith } from "./element/mutateElement";
|
||||
import { isLinearElement } from "./element/typeChecks";
|
||||
|
||||
type Result = {
|
||||
appState: AppState;
|
||||
|
@ -24,14 +25,17 @@ export class SceneHistory {
|
|||
) {
|
||||
return JSON.stringify({
|
||||
appState: clearAppStatePropertiesForHistory(appState),
|
||||
elements: elements.map(element =>
|
||||
newElementWith(element, {
|
||||
points:
|
||||
appState.multiElement && appState.multiElement.id === element.id
|
||||
? element.points.slice(0, -1)
|
||||
: element.points,
|
||||
}),
|
||||
),
|
||||
elements: elements.map(element => {
|
||||
if (isLinearElement(element)) {
|
||||
return newElementWith(element, {
|
||||
points:
|
||||
appState.multiElement && appState.multiElement.id === element.id
|
||||
? element.points.slice(0, -1)
|
||||
: element.points,
|
||||
});
|
||||
}
|
||||
return newElementWith(element, {});
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue