Compare commits
4 Commits
155297b17a
...
7cc8d43fae
Author | SHA1 | Date |
---|---|---|
dependabot[bot] | 7cc8d43fae | |
Marcel Mraz | 6e5aeb112d | |
Marcel Mraz | 4d83d1c91e | |
dependabot[bot] | 947e6b8dcc |
|
@ -5320,10 +5320,10 @@ multicast-dns@^7.2.5:
|
||||||
dns-packet "^5.2.2"
|
dns-packet "^5.2.2"
|
||||||
thunky "^1.0.2"
|
thunky "^1.0.2"
|
||||||
|
|
||||||
nanoid@^3.3.4:
|
nanoid@^3.3.6:
|
||||||
version "3.3.4"
|
version "3.3.6"
|
||||||
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab"
|
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c"
|
||||||
integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==
|
integrity sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==
|
||||||
|
|
||||||
negotiator@0.6.3:
|
negotiator@0.6.3:
|
||||||
version "0.6.3"
|
version "0.6.3"
|
||||||
|
@ -5984,11 +5984,11 @@ postcss-zindex@^5.1.0:
|
||||||
integrity sha512-fgFMf0OtVSBR1va1JNHYgMxYk73yhn/qb4uQDq1DLGYolz8gHCyr/sesEuGUaYs58E3ZJRcpoGuPVoB7Meiq9A==
|
integrity sha512-fgFMf0OtVSBR1va1JNHYgMxYk73yhn/qb4uQDq1DLGYolz8gHCyr/sesEuGUaYs58E3ZJRcpoGuPVoB7Meiq9A==
|
||||||
|
|
||||||
postcss@^8.3.11, postcss@^8.4.13, postcss@^8.4.14, postcss@^8.4.7:
|
postcss@^8.3.11, postcss@^8.4.13, postcss@^8.4.14, postcss@^8.4.7:
|
||||||
version "8.4.14"
|
version "8.4.31"
|
||||||
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.14.tgz#ee9274d5622b4858c1007a74d76e42e56fd21caf"
|
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.31.tgz#92b451050a9f914da6755af352bdc0192508656d"
|
||||||
integrity sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==
|
integrity sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
nanoid "^3.3.4"
|
nanoid "^3.3.6"
|
||||||
picocolors "^1.0.0"
|
picocolors "^1.0.0"
|
||||||
source-map-js "^1.0.2"
|
source-map-js "^1.0.2"
|
||||||
|
|
||||||
|
|
|
@ -4166,6 +4166,11 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
originSnapOffset: null,
|
originSnapOffset: null,
|
||||||
activeEmbeddable: null,
|
activeEmbeddable: null,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
if (nextActiveTool.type === "freedraw") {
|
||||||
|
this.store.shouldCaptureIncrement();
|
||||||
|
}
|
||||||
|
|
||||||
if (nextActiveTool.type !== "selection") {
|
if (nextActiveTool.type !== "selection") {
|
||||||
return {
|
return {
|
||||||
...prevState,
|
...prevState,
|
||||||
|
|
|
@ -22,7 +22,7 @@ export const getObservedAppState = (appState: AppState): ObservedAppState => {
|
||||||
selectedLinearElementId: appState.selectedLinearElement?.elementId || null,
|
selectedLinearElementId: appState.selectedLinearElement?.elementId || null,
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.defineProperty(observedAppState, hiddenObservedAppStateProp, {
|
Reflect.defineProperty(observedAppState, hiddenObservedAppStateProp, {
|
||||||
value: true,
|
value: true,
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
});
|
});
|
||||||
|
@ -33,7 +33,7 @@ export const getObservedAppState = (appState: AppState): ObservedAppState => {
|
||||||
const isObservedAppState = (
|
const isObservedAppState = (
|
||||||
appState: AppState | ObservedAppState,
|
appState: AppState | ObservedAppState,
|
||||||
): appState is ObservedAppState =>
|
): appState is ObservedAppState =>
|
||||||
Object.hasOwn(appState, hiddenObservedAppStateProp);
|
!!Reflect.get(appState, hiddenObservedAppStateProp);
|
||||||
|
|
||||||
export type StoreActionType = "capture" | "update" | "none";
|
export type StoreActionType = "capture" | "update" | "none";
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -6570,12 +6570,27 @@ History {
|
||||||
"delta": Delta {
|
"delta": Delta {
|
||||||
"deleted": {
|
"deleted": {
|
||||||
"selectedElementIds": {},
|
"selectedElementIds": {},
|
||||||
"selectedLinearElementId": null,
|
|
||||||
},
|
},
|
||||||
"inserted": {
|
"inserted": {
|
||||||
"selectedElementIds": {
|
"selectedElementIds": {
|
||||||
"id6": true,
|
"id6": true,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"elementsChange": ElementsChange {
|
||||||
|
"added": Map {},
|
||||||
|
"removed": Map {},
|
||||||
|
"updated": Map {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
HistoryEntry {
|
||||||
|
"appStateChange": AppStateChange {
|
||||||
|
"delta": Delta {
|
||||||
|
"deleted": {
|
||||||
|
"selectedLinearElementId": null,
|
||||||
|
},
|
||||||
|
"inserted": {
|
||||||
"selectedLinearElementId": "id6",
|
"selectedLinearElementId": "id6",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,7 +15,11 @@ import { createUndoAction, createRedoAction } from "../actions/actionHistory";
|
||||||
import { EXPORT_DATA_TYPES, MIME_TYPES } from "../constants";
|
import { EXPORT_DATA_TYPES, MIME_TYPES } from "../constants";
|
||||||
import { AppState, ExcalidrawImperativeAPI } from "../types";
|
import { AppState, ExcalidrawImperativeAPI } from "../types";
|
||||||
import { arrayToMap, resolvablePromise } from "../utils";
|
import { arrayToMap, resolvablePromise } from "../utils";
|
||||||
import { COLOR_PALETTE } from "../colors";
|
import {
|
||||||
|
COLOR_PALETTE,
|
||||||
|
DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX,
|
||||||
|
DEFAULT_ELEMENT_STROKE_COLOR_INDEX,
|
||||||
|
} from "../colors";
|
||||||
import { KEYS } from "../keys";
|
import { KEYS } from "../keys";
|
||||||
import { newElementWith } from "../element/mutateElement";
|
import { newElementWith } from "../element/mutateElement";
|
||||||
import {
|
import {
|
||||||
|
@ -67,10 +71,11 @@ const checkpoint = (name: string) => {
|
||||||
const renderStaticScene = vi.spyOn(StaticScene, "renderStaticScene");
|
const renderStaticScene = vi.spyOn(StaticScene, "renderStaticScene");
|
||||||
|
|
||||||
const transparent = COLOR_PALETTE.transparent;
|
const transparent = COLOR_PALETTE.transparent;
|
||||||
const red = COLOR_PALETTE.red[1];
|
const black = COLOR_PALETTE.black;
|
||||||
const blue = COLOR_PALETTE.blue[1];
|
const red = COLOR_PALETTE.red[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX];
|
||||||
const yellow = COLOR_PALETTE.yellow[1];
|
const blue = COLOR_PALETTE.blue[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX];
|
||||||
const violet = COLOR_PALETTE.violet[1];
|
const yellow = COLOR_PALETTE.yellow[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX];
|
||||||
|
const violet = COLOR_PALETTE.violet[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX];
|
||||||
|
|
||||||
describe("history", () => {
|
describe("history", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -973,6 +978,69 @@ describe("history", () => {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should create entry when selecting freedraw", async () => {
|
||||||
|
await render(<Excalidraw handleKeyboardGlobally={true} />);
|
||||||
|
|
||||||
|
UI.clickTool("rectangle");
|
||||||
|
mouse.down(-10, -10);
|
||||||
|
mouse.up(10, 10);
|
||||||
|
|
||||||
|
UI.clickTool("freedraw");
|
||||||
|
mouse.down(40, -20);
|
||||||
|
mouse.up(50, 10);
|
||||||
|
|
||||||
|
const rectangle = h.elements[0];
|
||||||
|
const freedraw1 = h.elements[1];
|
||||||
|
|
||||||
|
expect(API.getUndoStack().length).toBe(3);
|
||||||
|
expect(API.getRedoStack().length).toBe(0);
|
||||||
|
expect(API.getSelectedElements().length).toBe(0);
|
||||||
|
expect(h.elements).toEqual([
|
||||||
|
expect.objectContaining({ id: rectangle.id }),
|
||||||
|
expect.objectContaining({ id: freedraw1.id, strokeColor: black }),
|
||||||
|
]);
|
||||||
|
|
||||||
|
Keyboard.undo();
|
||||||
|
expect(API.getUndoStack().length).toBe(2);
|
||||||
|
expect(API.getRedoStack().length).toBe(1);
|
||||||
|
expect(API.getSelectedElements().length).toBe(0);
|
||||||
|
expect(h.elements).toEqual([
|
||||||
|
expect.objectContaining({ id: rectangle.id }),
|
||||||
|
expect.objectContaining({
|
||||||
|
id: freedraw1.id,
|
||||||
|
strokeColor: black,
|
||||||
|
isDeleted: true,
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
togglePopover("Stroke");
|
||||||
|
UI.clickOnTestId("color-red");
|
||||||
|
mouse.down(40, -20);
|
||||||
|
mouse.up(50, 10);
|
||||||
|
|
||||||
|
const freedraw2 = h.elements[2];
|
||||||
|
|
||||||
|
expect(API.getUndoStack().length).toBe(3);
|
||||||
|
expect(API.getRedoStack().length).toBe(0);
|
||||||
|
expect(h.elements).toEqual([
|
||||||
|
expect.objectContaining({ id: rectangle.id }),
|
||||||
|
expect.objectContaining({
|
||||||
|
id: freedraw1.id,
|
||||||
|
strokeColor: black,
|
||||||
|
isDeleted: true,
|
||||||
|
}),
|
||||||
|
expect.objectContaining({
|
||||||
|
id: freedraw2.id,
|
||||||
|
strokeColor: COLOR_PALETTE.red[DEFAULT_ELEMENT_STROKE_COLOR_INDEX],
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// ensure we don't end up with duplicated entries
|
||||||
|
UI.clickTool("freedraw");
|
||||||
|
expect(API.getUndoStack().length).toBe(3);
|
||||||
|
expect(API.getRedoStack().length).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
it("should support duplication of groups, appstate group selection and editing group", async () => {
|
it("should support duplication of groups, appstate group selection and editing group", async () => {
|
||||||
await render(<Excalidraw handleKeyboardGlobally={true} />);
|
await render(<Excalidraw handleKeyboardGlobally={true} />);
|
||||||
const rect1 = API.createElement({
|
const rect1 = API.createElement({
|
||||||
|
|
Loading…
Reference in New Issue