docstring_tokens
stringlengths 18
16.9k
| code_tokens
stringlengths 75
1.81M
| html_url
stringlengths 74
116
| file_name
stringlengths 3
311
|
---|---|---|---|
keep keep keep keep replace keep keep keep keep
|
<mask> "updated": 1,
<mask> "version": 1,
<mask> "versionNonce": 0,
<mask> "verticalAlign": "top",
<mask> "width": 1,
<mask> "x": 0,
<mask> "y": 0,
<mask> }
<mask> `;
</s> fix: refresh text dimensions only after font load done (#5878)
* fix: refresh text dimensions only after font load done
* fix snaps </s> remove "width": 1,
</s> add "width": 100, </s> remove "height": 0,
</s> add "height": 100, </s> remove "height": 0,
</s> add "height": 100, </s> remove import { deepCopyElement, newFreeDrawElement } from "../element/newElement";
</s> add import {
deepCopyElement,
newFreeDrawElement,
refreshTextDimensions,
} from "../element/newElement"; </s> remove this.scene.getElementsIncludingDeleted().forEach((element) => {
if (isTextElement(element)) {
invalidateShapeForElement(element);
}
});
</s> add this.scene.replaceAllElements([
...this.scene.getElementsIncludingDeleted().map((element) => {
if (isTextElement(element)) {
invalidateShapeForElement(element);
return newElementWith(element, {
...refreshTextDimensions(element),
});
}
return element;
}),
]); </s> remove elements: restoreElements(data?.elements, localElements, true),
</s> add elements: restoreElements(data?.elements, localElements),
|
https://github.com/excalidraw/excalidraw/commit/d273acb7e49a1681e24b9c5b0b373dfcccee8ff6
|
src/tests/data/__snapshots__/restore.test.ts.snap
|
keep keep keep add keep keep keep keep keep
|
<mask> "requires": {
<mask> "tslib": "^1.9.0"
<mask> }
<mask> },
<mask> "ci-info": {
<mask> "version": "2.0.0",
<mask> "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz",
<mask> "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ=="
<mask> },
</s> Add version to build and the archived asar app (#854) </s> add "cuint": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/cuint/-/cuint-0.2.2.tgz",
"integrity": "sha1-QICG1AlVDCYxFVYZ6fp7ytw7mRs=",
"dev": true
}, </s> add "asar": "2.1.0", </s> remove "description": "",
</s> add </s> remove "build": "react-scripts build",
"build-node": "./scripts/build-node.js",
</s> add "build:app": "react-scripts build",
"build:zip": "node ./scripts/build-version.js",
"build": "npm run build:app && npm run build:zip",
"build-node": "node ./scripts/build-node.js",
|
https://github.com/excalidraw/excalidraw/commit/d2827aa40b692960adc82842951283ca1dd07de6
|
package-lock.json
|
keep keep add keep keep keep keep keep
|
<mask> "integrity": "sha512-xz39Sb4+OaTsULgUERcCk+TJj8ylkL4aSVDQiX/ksxbELSqwkgt4d4RD7fovIdgJGSuNYqwZEiVjYY5l0ask+Q==",
<mask> "dev": true
<mask> },
<mask> "currently-unhandled": {
<mask> "version": "0.4.1",
<mask> "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz",
<mask> "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=",
<mask> "dev": true,
</s> Add version to build and the archived asar app (#854) </s> add "chromium-pickle-js": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz",
"integrity": "sha1-BKEGZywYsIWrd02YPfo+oTjyIgU=",
"dev": true
}, </s> add "asar": "2.1.0", </s> remove "description": "",
</s> add </s> remove "build": "react-scripts build",
"build-node": "./scripts/build-node.js",
</s> add "build:app": "react-scripts build",
"build:zip": "node ./scripts/build-version.js",
"build": "npm run build:app && npm run build:zip",
"build-node": "node ./scripts/build-node.js",
|
https://github.com/excalidraw/excalidraw/commit/d2827aa40b692960adc82842951283ca1dd07de6
|
package-lock.json
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> "react-scripts": "3.4.0",
<mask> "roughjs": "4.0.4",
<mask> "stacktrace-js": "2.0.2"
<mask> },
<mask> "description": "",
<mask> "devDependencies": {
<mask> "@testing-library/jest-dom": "5.1.1",
<mask> "@testing-library/react": "9.4.1",
<mask> "@types/jest": "25.1.3",
<mask> "@types/nanoid": "2.1.0",
</s> Add version to build and the archived asar app (#854) </s> add "asar": "2.1.0", </s> add "chromium-pickle-js": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz",
"integrity": "sha1-BKEGZywYsIWrd02YPfo+oTjyIgU=",
"dev": true
}, </s> add "cuint": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/cuint/-/cuint-0.2.2.tgz",
"integrity": "sha1-QICG1AlVDCYxFVYZ6fp7ytw7mRs=",
"dev": true
}, </s> remove "build": "react-scripts build",
"build-node": "./scripts/build-node.js",
</s> add "build:app": "react-scripts build",
"build:zip": "node ./scripts/build-version.js",
"build": "npm run build:app && npm run build:zip",
"build-node": "node ./scripts/build-node.js",
|
https://github.com/excalidraw/excalidraw/commit/d2827aa40b692960adc82842951283ca1dd07de6
|
package.json
|
keep keep keep add keep keep keep keep keep
|
<mask> "roughjs": "4.0.4",
<mask> "stacktrace-js": "2.0.2"
<mask> },
<mask> "devDependencies": {
<mask> "@testing-library/jest-dom": "5.1.1",
<mask> "@testing-library/react": "9.4.1",
<mask> "@types/jest": "25.1.3",
<mask> "@types/nanoid": "2.1.0",
<mask> "@types/react": "16.9.22",
</s> Add version to build and the archived asar app (#854) </s> remove "description": "",
</s> add </s> add "chromium-pickle-js": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz",
"integrity": "sha1-BKEGZywYsIWrd02YPfo+oTjyIgU=",
"dev": true
}, </s> add "cuint": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/cuint/-/cuint-0.2.2.tgz",
"integrity": "sha1-QICG1AlVDCYxFVYZ6fp7ytw7mRs=",
"dev": true
}, </s> remove "build": "react-scripts build",
"build-node": "./scripts/build-node.js",
</s> add "build:app": "react-scripts build",
"build:zip": "node ./scripts/build-version.js",
"build": "npm run build:app && npm run build:zip",
"build-node": "node ./scripts/build-node.js",
|
https://github.com/excalidraw/excalidraw/commit/d2827aa40b692960adc82842951283ca1dd07de6
|
package.json
|
keep keep keep keep replace replace keep keep keep keep keep
|
<mask> },
<mask> "main": "src/index.js",
<mask> "name": "excalidraw",
<mask> "scripts": {
<mask> "build": "react-scripts build",
<mask> "build-node": "./scripts/build-node.js",
<mask> "eject": "react-scripts eject",
<mask> "fix": "npm run fix:other && npm run fix:code",
<mask> "fix:code": "npm run test:code -- --fix",
<mask> "fix:other": "npm run prettier -- --write",
<mask> "prettier": "prettier \"**/*.{css,scss,json,md,html,yml}\" --ignore-path=.eslintignore",
</s> Add version to build and the archived asar app (#854) </s> add "chromium-pickle-js": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz",
"integrity": "sha1-BKEGZywYsIWrd02YPfo+oTjyIgU=",
"dev": true
}, </s> add "cuint": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/cuint/-/cuint-0.2.2.tgz",
"integrity": "sha1-QICG1AlVDCYxFVYZ6fp7ytw7mRs=",
"dev": true
}, </s> add "asar": "2.1.0", </s> remove "description": "",
</s> add
|
https://github.com/excalidraw/excalidraw/commit/d2827aa40b692960adc82842951283ca1dd07de6
|
package.json
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> DistributeHorizontallyIcon,
<mask> DistributeVerticallyIcon,
<mask> } from "../components/icons";
<mask> import { ToolButton } from "../components/ToolButton";
<mask> import { distributeElements, Distribution } from "../disitrubte";
<mask> import { getNonDeletedElements } from "../element";
<mask> import { ExcalidrawElement } from "../element/types";
<mask> import { t } from "../i18n";
<mask> import { CODES, KEYS } from "../keys";
<mask> import { getSelectedElements, isSomeElementSelected } from "../scene";
</s> feat: support adding multiple library items on canvas (#5116) </s> add import { ExcalidrawElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds"; </s> remove import { saveLibraryAsJSON } from "../data/json";
</s> add import { saveLibraryAsJSON, serializeLibraryAsJSON } from "../data/json"; </s> add import { serializeLibraryAsJSON } from "../data/json";
import { distributeLibraryItemsOnSquareGrid } from "../data/library";
import { ExcalidrawGenericElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds"; </s> remove import { VERSIONS } from "../constants";
</s> add import { MIME_TYPES, VERSIONS } from "../constants"; </s> remove import Library from "../data/library";
</s> add import Library, { distributeLibraryItemsOnSquareGrid } from "../data/library"; </s> remove import { MIME_TYPES } from "../constants";
</s> add
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/actions/actionDistribute.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> VERTICAL_ALIGN,
<mask> ZOOM_STEP,
<mask> } from "../constants";
<mask> import { loadFromBlob } from "../data";
<mask> import Library from "../data/library";
<mask> import { restore, restoreElements } from "../data/restore";
<mask> import {
<mask> dragNewElement,
<mask> dragSelectedElements,
<mask> duplicateElement,
</s> feat: support adding multiple library items on canvas (#5116) </s> remove import Library from "../data/library";
</s> add import Library, { distributeLibraryItemsOnSquareGrid } from "../data/library"; </s> remove import { saveLibraryAsJSON } from "../data/json";
</s> add import { saveLibraryAsJSON, serializeLibraryAsJSON } from "../data/json"; </s> add import { serializeLibraryAsJSON } from "../data/json";
import { distributeLibraryItemsOnSquareGrid } from "../data/library";
import { ExcalidrawGenericElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds"; </s> remove import { VERSIONS } from "../constants";
</s> add import { MIME_TYPES, VERSIONS } from "../constants"; </s> add import { ExcalidrawElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds"; </s> remove import { MIME_TYPES } from "../constants";
</s> add
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/components/App.tsx
|
keep keep add keep keep keep keep
|
<mask> isSupportedImageFile,
<mask> loadSceneOrLibraryFromBlob,
<mask> normalizeFile,
<mask> resizeImageFile,
<mask> SVGStringToFile,
<mask> } from "../data/blob";
<mask> import {
</s> feat: support adding multiple library items on canvas (#5116) </s> remove import Library from "../data/library";
</s> add import Library, { distributeLibraryItemsOnSquareGrid } from "../data/library"; </s> remove import { distributeElements, Distribution } from "../disitrubte";
</s> add import { distributeElements, Distribution } from "../distribute"; </s> add import { ExcalidrawElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds"; </s> add import { serializeLibraryAsJSON } from "../data/json";
import { distributeLibraryItemsOnSquareGrid } from "../data/library";
import { ExcalidrawGenericElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds"; </s> remove import { saveLibraryAsJSON } from "../data/json";
</s> add import { saveLibraryAsJSON, serializeLibraryAsJSON } from "../data/json"; </s> remove import { MIME_TYPES } from "../constants";
</s> add
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/components/App.tsx
|
keep keep keep keep replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> errorMessage: error.message,
<mask> });
<mask> }
<mask>
<mask> const libraryShapes = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
<mask> if (libraryShapes !== "") {
<mask> this.addElementsFromPasteOrLibrary({
<mask> elements: JSON.parse(libraryShapes),
<mask> position: event,
<mask> files: null,
<mask> });
<mask> return;
<mask> }
<mask>
<mask> if (file) {
<mask> // atetmpt to parse an excalidraw/excalidrawlib file
</s> feat: support adding multiple library items on canvas (#5116) </s> remove onClick: () => onInsertShape(item.elements),
</s> add onClick: () => onInsertLibraryItems(getInsertedElements(item.id)), </s> add if (!id) {
event.preventDefault();
return;
} </s> add const getInsertedElements = (id: string) => {
let targetElements;
if (selectedItems.includes(id)) {
targetElements = libraryItems.filter((item) =>
selectedItems.includes(item.id),
);
} else {
targetElements = libraryItems.filter((item) => item.id === id);
}
return targetElements;
};
</s> remove export const loadLibraryFromBlob = async (
blob: Blob,
</s> add export const parseLibraryJSON = (
json: string, </s> remove const contents = await parseFileContents(blob);
const data: ImportedLibraryData | undefined = JSON.parse(contents);
</s> add const data: ImportedLibraryData | undefined = JSON.parse(json); </s> add import { serializeLibraryAsJSON } from "../data/json";
import { distributeLibraryItemsOnSquareGrid } from "../data/library";
import { ExcalidrawGenericElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds";
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/components/App.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> import { HelpDialog } from "./HelpDialog";
<mask> import Stack from "./Stack";
<mask> import { Tooltip } from "./Tooltip";
<mask> import { UserList } from "./UserList";
<mask> import Library from "../data/library";
<mask> import { JSONExportDialog } from "./JSONExportDialog";
<mask> import { LibraryButton } from "./LibraryButton";
<mask> import { isImageFileHandle } from "../data/blob";
<mask> import { LibraryMenu } from "./LibraryMenu";
<mask>
</s> feat: support adding multiple library items on canvas (#5116) </s> remove import { VERSIONS } from "../constants";
</s> add import { MIME_TYPES, VERSIONS } from "../constants"; </s> remove import { saveLibraryAsJSON } from "../data/json";
</s> add import { saveLibraryAsJSON, serializeLibraryAsJSON } from "../data/json"; </s> remove import Library from "../data/library";
</s> add import Library, { distributeLibraryItemsOnSquareGrid } from "../data/library"; </s> add import { serializeLibraryAsJSON } from "../data/json";
import { distributeLibraryItemsOnSquareGrid } from "../data/library";
import { ExcalidrawGenericElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds"; </s> add import { ExcalidrawElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds"; </s> remove import { distributeElements, Distribution } from "../disitrubte";
</s> add import { distributeElements, Distribution } from "../distribute";
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/components/LayerUI.tsx
|
keep keep replace keep keep keep keep keep
|
<mask> import { chunk } from "lodash";
<mask> import React, { useCallback, useState } from "react";
<mask> import { saveLibraryAsJSON } from "../data/json";
<mask> import Library from "../data/library";
<mask> import { ExcalidrawElement, NonDeleted } from "../element/types";
<mask> import { t } from "../i18n";
<mask> import {
<mask> AppState,
</s> feat: support adding multiple library items on canvas (#5116) </s> add import { ExcalidrawElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds"; </s> add import { serializeLibraryAsJSON } from "../data/json";
import { distributeLibraryItemsOnSquareGrid } from "../data/library";
import { ExcalidrawGenericElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds"; </s> remove import { distributeElements, Distribution } from "../disitrubte";
</s> add import { distributeElements, Distribution } from "../distribute"; </s> remove import Library from "../data/library";
</s> add import Library, { distributeLibraryItemsOnSquareGrid } from "../data/library"; </s> remove import { MIME_TYPES } from "../constants";
</s> add </s> remove import Library from "../data/library";
</s> add import Library, { distributeLibraryItemsOnSquareGrid } from "../data/library";
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/components/LibraryMenuItems.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> import { ToolButton } from "./ToolButton";
<mask> import { Tooltip } from "./Tooltip";
<mask>
<mask> import "./LibraryMenuItems.scss";
<mask> import { VERSIONS } from "../constants";
<mask> import Spinner from "./Spinner";
<mask> import { fileOpen } from "../data/filesystem";
<mask>
<mask> const LibraryMenuItems = ({
<mask> isLoading,
</s> feat: support adding multiple library items on canvas (#5116) </s> remove import Library from "../data/library";
</s> add import Library, { distributeLibraryItemsOnSquareGrid } from "../data/library"; </s> remove import { distributeElements, Distribution } from "../disitrubte";
</s> add import { distributeElements, Distribution } from "../distribute"; </s> add import { serializeLibraryAsJSON } from "../data/json";
import { distributeLibraryItemsOnSquareGrid } from "../data/library";
import { ExcalidrawGenericElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds"; </s> remove import { LibraryItem } from "../types";
</s> add import { LibraryItem, LibraryItems } from "../types"; </s> add import { ExcalidrawElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds"; </s> remove import { MIME_TYPES } from "../constants";
</s> add
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/components/LibraryMenuItems.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> isLoading,
<mask> libraryItems,
<mask> onRemoveFromLibrary,
<mask> onAddToLibrary,
<mask> onInsertShape,
<mask> pendingElements,
<mask> theme,
<mask> setAppState,
<mask> libraryReturnUrl,
<mask> library,
</s> feat: support adding multiple library items on canvas (#5116) </s> remove import { VERSIONS } from "../constants";
</s> add import { MIME_TYPES, VERSIONS } from "../constants"; </s> remove new Blob([JSON.stringify(libraryItems)], {
</s> add new Blob([serializeLibraryAsJSON([libraryItems])], { </s> remove new Blob([JSON.stringify(libraryItems)], {
</s> add new Blob([serializeLibraryAsJSON([libraryItems])], { </s> remove import Library from "../data/library";
</s> add import Library, { distributeLibraryItemsOnSquareGrid } from "../data/library"; </s> add parseLibraryJSON, </s> remove const libraryShapes = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
if (libraryShapes !== "") {
this.addElementsFromPasteOrLibrary({
elements: JSON.parse(libraryShapes),
position: event,
files: null,
});
</s> add const libraryJSON = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
if (libraryJSON && typeof libraryJSON === "string") {
try {
const libraryItems = parseLibraryJSON(libraryJSON);
this.addElementsFromPasteOrLibrary({
elements: distributeLibraryItemsOnSquareGrid(libraryItems),
position: event,
files: null,
});
} catch (error: any) {
this.setState({ errorMessage: error.message });
}
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/components/LibraryMenuItems.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> isLoading: boolean;
<mask> libraryItems: LibraryItems;
<mask> pendingElements: LibraryItem["elements"];
<mask> onRemoveFromLibrary: () => void;
<mask> onInsertShape: (elements: LibraryItem["elements"]) => void;
<mask> onAddToLibrary: (elements: LibraryItem["elements"]) => void;
<mask> theme: AppState["theme"];
<mask> files: BinaryFiles;
<mask> setAppState: React.Component<any, AppState>["setState"];
<mask> libraryReturnUrl: ExcalidrawProps["libraryReturnUrl"];
</s> feat: support adding multiple library items on canvas (#5116) </s> add onDrag: (id: string, event: React.DragEvent) => void; </s> add onDrag, </s> remove onClick: () => onInsertShape(item.elements),
</s> add onClick: () => onInsertLibraryItems(getInsertedElements(item.id)), </s> remove const libraryShapes = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
if (libraryShapes !== "") {
this.addElementsFromPasteOrLibrary({
elements: JSON.parse(libraryShapes),
position: event,
files: null,
});
</s> add const libraryJSON = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
if (libraryJSON && typeof libraryJSON === "string") {
try {
const libraryItems = parseLibraryJSON(libraryJSON);
this.addElementsFromPasteOrLibrary({
elements: distributeLibraryItemsOnSquareGrid(libraryItems),
position: event,
files: null,
});
} catch (error: any) {
this.setState({ errorMessage: error.message });
} </s> remove new Blob([JSON.stringify(libraryItems)], {
</s> add new Blob([serializeLibraryAsJSON([libraryItems])], { </s> remove new Blob([JSON.stringify(libraryItems)], {
</s> add new Blob([serializeLibraryAsJSON([libraryItems])], {
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/components/LibraryMenuItems.tsx
|
keep keep add keep keep keep keep keep
|
<mask> }
<mask> };
<mask>
<mask> const createLibraryItemCompo = (params: {
<mask> item:
<mask> | LibraryItem
<mask> | /* pending library item */ {
<mask> id: null;
</s> feat: support adding multiple library items on canvas (#5116) </s> add onDrag, </s> remove export const loadLibraryFromBlob = async (
blob: Blob,
</s> add export const parseLibraryJSON = (
json: string, </s> remove const contents = await parseFileContents(blob);
const data: ImportedLibraryData | undefined = JSON.parse(contents);
</s> add const data: ImportedLibraryData | undefined = JSON.parse(json); </s> remove new Blob([JSON.stringify(libraryItems)], {
</s> add new Blob([serializeLibraryAsJSON([libraryItems])], { </s> remove new Blob([JSON.stringify(libraryItems)], {
</s> add new Blob([serializeLibraryAsJSON([libraryItems])], { </s> add onDrag: (id: string, event: React.DragEvent) => void;
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/components/LibraryMenuItems.tsx
|
keep keep keep add keep keep keep keep
|
<mask> onClick={params.onClick || (() => {})}
<mask> id={params.item?.id || null}
<mask> selected={!!params.item?.id && selectedItems.includes(params.item.id)}
<mask> onToggle={onItemSelectToggle}
<mask> />
<mask> </Stack.Col>
<mask> );
<mask> };
</s> feat: support adding multiple library items on canvas (#5116) </s> remove event.dataTransfer.setData(
MIME_TYPES.excalidrawlib,
JSON.stringify(elements),
);
</s> add onDrag(id, event); </s> add if (!id) {
event.preventDefault();
return;
} </s> add export const loadLibraryFromBlob = async (
blob: Blob,
defaultStatus: LibraryItem["status"] = "unpublished",
) => {
return parseLibraryJSON(await parseFileContents(blob), defaultStatus);
};
</s> add const getInsertedElements = (id: string) => {
let targetElements;
if (selectedItems.includes(id)) {
targetElements = libraryItems.filter((item) =>
selectedItems.includes(item.id),
);
} else {
targetElements = libraryItems.filter((item) => item.id === id);
}
return targetElements;
};
</s> remove const contents = await parseFileContents(blob);
const data: ImportedLibraryData | undefined = JSON.parse(contents);
</s> add const data: ImportedLibraryData | undefined = JSON.parse(json); </s> remove T extends Exclude<ExcalidrawElement["type"], "selection">,
</s> add T extends Exclude<ExcalidrawElement["type"], "selection"> = "rectangle",
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/components/LibraryMenuItems.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> const _items = items.map((item) => {
<mask> if (item.id) {
<mask> return createLibraryItemCompo({
<mask> item,
<mask> onClick: () => onInsertShape(item.elements),
<mask> key: item.id,
<mask> });
<mask> }
<mask> return createLibraryItemCompo({
<mask> key: "__pending__item__",
</s> feat: support adding multiple library items on canvas (#5116) </s> remove const libraryShapes = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
if (libraryShapes !== "") {
this.addElementsFromPasteOrLibrary({
elements: JSON.parse(libraryShapes),
position: event,
files: null,
});
</s> add const libraryJSON = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
if (libraryJSON && typeof libraryJSON === "string") {
try {
const libraryItems = parseLibraryJSON(libraryJSON);
this.addElementsFromPasteOrLibrary({
elements: distributeLibraryItemsOnSquareGrid(libraryItems),
position: event,
files: null,
});
} catch (error: any) {
this.setState({ errorMessage: error.message });
} </s> add onDrag: (id: string, event: React.DragEvent) => void; </s> add export const loadLibraryFromBlob = async (
blob: Blob,
defaultStatus: LibraryItem["status"] = "unpublished",
) => {
return parseLibraryJSON(await parseFileContents(blob), defaultStatus);
};
</s> add const getInsertedElements = (id: string) => {
let targetElements;
if (selectedItems.includes(id)) {
targetElements = libraryItems.filter((item) =>
selectedItems.includes(item.id),
);
} else {
targetElements = libraryItems.filter((item) => item.id === id);
}
return targetElements;
};
</s> remove export const loadLibraryFromBlob = async (
blob: Blob,
</s> add export const parseLibraryJSON = (
json: string, </s> remove const contents = await parseFileContents(blob);
const data: ImportedLibraryData | undefined = JSON.parse(contents);
</s> add const data: ImportedLibraryData | undefined = JSON.parse(json);
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/components/LibraryMenuItems.tsx
|
keep keep keep replace keep keep keep keep keep
|
<mask> import clsx from "clsx";
<mask> import oc from "open-color";
<mask> import { useEffect, useRef, useState } from "react";
<mask> import { MIME_TYPES } from "../constants";
<mask> import { useDeviceType } from "../components/App";
<mask> import { exportToSvg } from "../scene/export";
<mask> import { BinaryFiles, LibraryItem } from "../types";
<mask> import "./LibraryUnit.scss";
<mask> import { CheckboxItem } from "./CheckboxItem";
</s> feat: support adding multiple library items on canvas (#5116) </s> add import { ExcalidrawElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds"; </s> remove import { LibraryItem } from "../types";
</s> add import { LibraryItem, LibraryItems } from "../types"; </s> add import { serializeLibraryAsJSON } from "../data/json";
import { distributeLibraryItemsOnSquareGrid } from "../data/library";
import { ExcalidrawGenericElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds"; </s> remove import { saveLibraryAsJSON } from "../data/json";
</s> add import { saveLibraryAsJSON, serializeLibraryAsJSON } from "../data/json"; </s> remove import { VERSIONS } from "../constants";
</s> add import { MIME_TYPES, VERSIONS } from "../constants"; </s> remove import Library from "../data/library";
</s> add import Library, { distributeLibraryItemsOnSquareGrid } from "../data/library";
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/components/LibraryUnit.tsx
|
keep keep add keep keep keep keep
|
<mask> onClick,
<mask> selected,
<mask> onToggle,
<mask> }: {
<mask> id: LibraryItem["id"] | /** for pending item */ null;
<mask> elements?: LibraryItem["elements"];
<mask> files: BinaryFiles;
</s> feat: support adding multiple library items on canvas (#5116) </s> add const getInsertedElements = (id: string) => {
let targetElements;
if (selectedItems.includes(id)) {
targetElements = libraryItems.filter((item) =>
selectedItems.includes(item.id),
);
} else {
targetElements = libraryItems.filter((item) => item.id === id);
}
return targetElements;
};
</s> remove onInsertShape: (elements: LibraryItem["elements"]) => void;
</s> add onInsertLibraryItems: (libraryItems: LibraryItems) => void; </s> remove type: T;
</s> add type?: T; </s> remove const libraryShapes = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
if (libraryShapes !== "") {
this.addElementsFromPasteOrLibrary({
elements: JSON.parse(libraryShapes),
position: event,
files: null,
});
</s> add const libraryJSON = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
if (libraryJSON && typeof libraryJSON === "string") {
try {
const libraryItems = parseLibraryJSON(libraryJSON);
this.addElementsFromPasteOrLibrary({
elements: distributeLibraryItemsOnSquareGrid(libraryItems),
position: event,
files: null,
});
} catch (error: any) {
this.setState({ errorMessage: error.message });
} </s> remove new Blob([JSON.stringify(libraryItems)], {
</s> add new Blob([serializeLibraryAsJSON([libraryItems])], { </s> remove new Blob([JSON.stringify(libraryItems)], {
</s> add new Blob([serializeLibraryAsJSON([libraryItems])], {
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/components/LibraryUnit.tsx
|
keep keep add keep keep keep keep keep
|
<mask> onClick: () => void;
<mask> selected: boolean;
<mask> onToggle: (id: string, event: React.MouseEvent) => void;
<mask> }) => {
<mask> const ref = useRef<HTMLDivElement | null>(null);
<mask> useEffect(() => {
<mask> const node = ref.current;
<mask> if (!node) {
</s> feat: support adding multiple library items on canvas (#5116) </s> remove onInsertShape: (elements: LibraryItem["elements"]) => void;
</s> add onInsertLibraryItems: (libraryItems: LibraryItems) => void; </s> remove onClick: () => onInsertShape(item.elements),
</s> add onClick: () => onInsertLibraryItems(getInsertedElements(item.id)), </s> add const getInsertedElements = (id: string) => {
let targetElements;
if (selectedItems.includes(id)) {
targetElements = libraryItems.filter((item) =>
selectedItems.includes(item.id),
);
} else {
targetElements = libraryItems.filter((item) => item.id === id);
}
return targetElements;
};
</s> remove export const loadLibraryFromBlob = async (
blob: Blob,
</s> add export const parseLibraryJSON = (
json: string, </s> remove const contents = await parseFileContents(blob);
const data: ImportedLibraryData | undefined = JSON.parse(contents);
</s> add const data: ImportedLibraryData | undefined = JSON.parse(json); </s> remove const libraryShapes = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
if (libraryShapes !== "") {
this.addElementsFromPasteOrLibrary({
elements: JSON.parse(libraryShapes),
position: event,
files: null,
});
</s> add const libraryJSON = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
if (libraryJSON && typeof libraryJSON === "string") {
try {
const libraryItems = parseLibraryJSON(libraryJSON);
this.addElementsFromPasteOrLibrary({
elements: distributeLibraryItemsOnSquareGrid(libraryItems),
position: event,
files: null,
});
} catch (error: any) {
this.setState({ errorMessage: error.message });
}
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/components/LibraryUnit.tsx
|
keep add keep keep keep keep keep keep
|
<mask> }
<mask> onDragStart={(event) => {
<mask> setIsHovered(false);
<mask> onDrag(id, event);
<mask> }}
<mask> />
<mask> {adder}
<mask> {id && elements && (isHovered || isMobile || selected) && (
</s> feat: support adding multiple library items on canvas (#5116) </s> remove event.dataTransfer.setData(
MIME_TYPES.excalidrawlib,
JSON.stringify(elements),
);
</s> add onDrag(id, event); </s> add onDrag={(id, event) => {
event.dataTransfer.setData(
MIME_TYPES.excalidrawlib,
serializeLibraryAsJSON(getInsertedElements(id)),
);
}} </s> remove const libraryShapes = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
if (libraryShapes !== "") {
this.addElementsFromPasteOrLibrary({
elements: JSON.parse(libraryShapes),
position: event,
files: null,
});
</s> add const libraryJSON = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
if (libraryJSON && typeof libraryJSON === "string") {
try {
const libraryItems = parseLibraryJSON(libraryJSON);
this.addElementsFromPasteOrLibrary({
elements: distributeLibraryItemsOnSquareGrid(libraryItems),
position: event,
files: null,
});
} catch (error: any) {
this.setState({ errorMessage: error.message });
} </s> add export const loadLibraryFromBlob = async (
blob: Blob,
defaultStatus: LibraryItem["status"] = "unpublished",
) => {
return parseLibraryJSON(await parseFileContents(blob), defaultStatus);
};
</s> remove const contents = await parseFileContents(blob);
const data: ImportedLibraryData | undefined = JSON.parse(contents);
</s> add const data: ImportedLibraryData | undefined = JSON.parse(json); </s> remove export const loadLibraryFromBlob = async (
blob: Blob,
</s> add export const parseLibraryJSON = (
json: string,
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/components/LibraryUnit.tsx
|
keep keep keep keep replace replace replace replace keep keep keep keep keep
|
<mask> : undefined
<mask> }
<mask> onDragStart={(event) => {
<mask> setIsHovered(false);
<mask> event.dataTransfer.setData(
<mask> MIME_TYPES.excalidrawlib,
<mask> JSON.stringify(elements),
<mask> );
<mask> }}
<mask> />
<mask> {adder}
<mask> {id && elements && (isHovered || isMobile || selected) && (
<mask> <CheckboxItem
</s> feat: support adding multiple library items on canvas (#5116) </s> add if (!id) {
event.preventDefault();
return;
} </s> add onDrag={(id, event) => {
event.dataTransfer.setData(
MIME_TYPES.excalidrawlib,
serializeLibraryAsJSON(getInsertedElements(id)),
);
}} </s> remove const contents = await parseFileContents(blob);
const data: ImportedLibraryData | undefined = JSON.parse(contents);
</s> add const data: ImportedLibraryData | undefined = JSON.parse(json); </s> remove const libraryShapes = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
if (libraryShapes !== "") {
this.addElementsFromPasteOrLibrary({
elements: JSON.parse(libraryShapes),
position: event,
files: null,
});
</s> add const libraryJSON = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
if (libraryJSON && typeof libraryJSON === "string") {
try {
const libraryItems = parseLibraryJSON(libraryJSON);
this.addElementsFromPasteOrLibrary({
elements: distributeLibraryItemsOnSquareGrid(libraryItems),
position: event,
files: null,
});
} catch (error: any) {
this.setState({ errorMessage: error.message });
} </s> add export const loadLibraryFromBlob = async (
blob: Blob,
defaultStatus: LibraryItem["status"] = "unpublished",
) => {
return parseLibraryJSON(await parseFileContents(blob), defaultStatus);
};
</s> remove export const loadLibraryFromBlob = async (
blob: Blob,
</s> add export const parseLibraryJSON = (
json: string,
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/components/LibraryUnit.tsx
|
keep keep replace replace keep keep replace replace keep keep keep keep
|
<mask> };
<mask>
<mask> export const loadLibraryFromBlob = async (
<mask> blob: Blob,
<mask> defaultStatus: LibraryItem["status"] = "unpublished",
<mask> ) => {
<mask> const contents = await parseFileContents(blob);
<mask> const data: ImportedLibraryData | undefined = JSON.parse(contents);
<mask> if (!isValidLibrary(data)) {
<mask> throw new Error("Invalid library");
<mask> }
<mask> const libraryItems = data.libraryItems || data.library;
</s> feat: support adding multiple library items on canvas (#5116) </s> add export const loadLibraryFromBlob = async (
blob: Blob,
defaultStatus: LibraryItem["status"] = "unpublished",
) => {
return parseLibraryJSON(await parseFileContents(blob), defaultStatus);
};
</s> add const getInsertedElements = (id: string) => {
let targetElements;
if (selectedItems.includes(id)) {
targetElements = libraryItems.filter((item) =>
selectedItems.includes(item.id),
);
} else {
targetElements = libraryItems.filter((item) => item.id === id);
}
return targetElements;
};
</s> remove new Blob([JSON.stringify(libraryItems)], {
</s> add new Blob([serializeLibraryAsJSON([libraryItems])], { </s> remove new Blob([JSON.stringify(libraryItems)], {
</s> add new Blob([serializeLibraryAsJSON([libraryItems])], { </s> remove const libraryShapes = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
if (libraryShapes !== "") {
this.addElementsFromPasteOrLibrary({
elements: JSON.parse(libraryShapes),
position: event,
files: null,
});
</s> add const libraryJSON = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
if (libraryJSON && typeof libraryJSON === "string") {
try {
const libraryItems = parseLibraryJSON(libraryJSON);
this.addElementsFromPasteOrLibrary({
elements: distributeLibraryItemsOnSquareGrid(libraryItems),
position: event,
files: null,
});
} catch (error: any) {
this.setState({ errorMessage: error.message });
}
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/data/blob.ts
|
keep keep keep add keep keep keep keep keep keep
|
<mask> const libraryItems = data.libraryItems || data.library;
<mask> return restoreLibraryItems(libraryItems, defaultStatus);
<mask> };
<mask>
<mask> export const canvasToBlob = async (
<mask> canvas: HTMLCanvasElement,
<mask> ): Promise<Blob> => {
<mask> return new Promise((resolve, reject) => {
<mask> try {
<mask> canvas.toBlob((blob) => {
</s> feat: support adding multiple library items on canvas (#5116) </s> remove const contents = await parseFileContents(blob);
const data: ImportedLibraryData | undefined = JSON.parse(contents);
</s> add const data: ImportedLibraryData | undefined = JSON.parse(json); </s> remove export const loadLibraryFromBlob = async (
blob: Blob,
</s> add export const parseLibraryJSON = (
json: string, </s> add const getInsertedElements = (id: string) => {
let targetElements;
if (selectedItems.includes(id)) {
targetElements = libraryItems.filter((item) =>
selectedItems.includes(item.id),
);
} else {
targetElements = libraryItems.filter((item) => item.id === id);
}
return targetElements;
};
</s> remove onClick: () => onInsertShape(item.elements),
</s> add onClick: () => onInsertLibraryItems(getInsertedElements(item.id)), </s> remove const libraryShapes = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
if (libraryShapes !== "") {
this.addElementsFromPasteOrLibrary({
elements: JSON.parse(libraryShapes),
position: event,
files: null,
});
</s> add const libraryJSON = event.dataTransfer.getData(MIME_TYPES.excalidrawlib);
if (libraryJSON && typeof libraryJSON === "string") {
try {
const libraryItems = parseLibraryJSON(libraryJSON);
this.addElementsFromPasteOrLibrary({
elements: distributeLibraryItemsOnSquareGrid(libraryItems),
position: event,
files: null,
});
} catch (error: any) {
this.setState({ errorMessage: error.message });
} </s> remove new Blob([JSON.stringify(libraryItems)], {
</s> add new Blob([serializeLibraryAsJSON([libraryItems])], {
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/data/blob.ts
|
keep keep add keep keep keep keep
|
<mask> import type App from "../components/App";
<mask> import { atom } from "jotai";
<mask> import { jotaiStore } from "../jotai";
<mask> import { AbortError } from "../errors";
<mask> import { t } from "../i18n";
<mask> import { useEffect, useRef } from "react";
<mask> import { URL_HASH_KEYS, URL_QUERY_KEYS, APP_NAME, EVENT } from "../constants";
</s> feat: support adding multiple library items on canvas (#5116) </s> remove import { MIME_TYPES } from "../constants";
</s> add </s> remove import { saveLibraryAsJSON } from "../data/json";
</s> add import { saveLibraryAsJSON, serializeLibraryAsJSON } from "../data/json"; </s> remove import { distributeElements, Distribution } from "../disitrubte";
</s> add import { distributeElements, Distribution } from "../distribute"; </s> add import { serializeLibraryAsJSON } from "../data/json";
import { distributeLibraryItemsOnSquareGrid } from "../data/library";
import { ExcalidrawGenericElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds"; </s> remove import { VERSIONS } from "../constants";
</s> add import { MIME_TYPES, VERSIONS } from "../constants"; </s> remove import { LibraryItem } from "../types";
</s> add import { LibraryItem, LibraryItems } from "../types";
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/data/library.ts
|
keep keep replace keep replace keep keep
|
<mask>
<mask> static createElement = <
<mask> T extends Exclude<ExcalidrawElement["type"], "selection">,
<mask> >({
<mask> type,
<mask> id,
<mask> x = 0,
</s> feat: support adding multiple library items on canvas (#5116) </s> remove const contents = await parseFileContents(blob);
const data: ImportedLibraryData | undefined = JSON.parse(contents);
</s> add const data: ImportedLibraryData | undefined = JSON.parse(json); </s> remove export const loadLibraryFromBlob = async (
blob: Blob,
</s> add export const parseLibraryJSON = (
json: string, </s> add const getInsertedElements = (id: string) => {
let targetElements;
if (selectedItems.includes(id)) {
targetElements = libraryItems.filter((item) =>
selectedItems.includes(item.id),
);
} else {
targetElements = libraryItems.filter((item) => item.id === id);
}
return targetElements;
};
</s> add export const loadLibraryFromBlob = async (
blob: Blob,
defaultStatus: LibraryItem["status"] = "unpublished",
) => {
return parseLibraryJSON(await parseFileContents(blob), defaultStatus);
};
</s> remove type: T;
</s> add type?: T;
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/tests/helpers/api.ts
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> isDeleted = false,
<mask> groupIds = [],
<mask> ...rest
<mask> }: {
<mask> type: T;
<mask> x?: number;
<mask> y?: number;
<mask> height?: number;
<mask> width?: number;
<mask> id?: string;
</s> feat: support adding multiple library items on canvas (#5116) </s> remove new Blob([JSON.stringify(libraryItems)], {
</s> add new Blob([serializeLibraryAsJSON([libraryItems])], { </s> remove new Blob([JSON.stringify(libraryItems)], {
</s> add new Blob([serializeLibraryAsJSON([libraryItems])], { </s> add onDrag, </s> add const getInsertedElements = (id: string) => {
let targetElements;
if (selectedItems.includes(id)) {
targetElements = libraryItems.filter((item) =>
selectedItems.includes(item.id),
);
} else {
targetElements = libraryItems.filter((item) => item.id === id);
}
return targetElements;
};
</s> remove export const loadLibraryFromBlob = async (
blob: Blob,
</s> add export const parseLibraryJSON = (
json: string, </s> add export const loadLibraryFromBlob = async (
blob: Blob,
defaultStatus: LibraryItem["status"] = "unpublished",
) => {
return parseLibraryJSON(await parseFileContents(blob), defaultStatus);
};
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/tests/helpers/api.ts
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> import { render, waitFor } from "./test-utils";
<mask> import ExcalidrawApp from "../excalidraw-app";
<mask> import { API } from "./helpers/api";
<mask> import { MIME_TYPES } from "../constants";
<mask> import { LibraryItem } from "../types";
<mask> import { UI } from "./helpers/ui";
<mask>
<mask> const { h } = window;
<mask>
<mask> describe("library", () => {
</s> feat: support adding multiple library items on canvas (#5116) </s> add import { serializeLibraryAsJSON } from "../data/json";
import { distributeLibraryItemsOnSquareGrid } from "../data/library";
import { ExcalidrawGenericElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds"; </s> remove import { MIME_TYPES } from "../constants";
</s> add </s> remove import { VERSIONS } from "../constants";
</s> add import { MIME_TYPES, VERSIONS } from "../constants"; </s> add import { ExcalidrawElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds"; </s> remove import Library from "../data/library";
</s> add import Library, { distributeLibraryItemsOnSquareGrid } from "../data/library"; </s> remove import { distributeElements, Distribution } from "../disitrubte";
</s> add import { distributeElements, Distribution } from "../distribute";
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/tests/library.test.tsx
|
keep keep add keep keep keep keep
|
<mask> import { MIME_TYPES } from "../constants";
<mask> import { LibraryItem, LibraryItems } from "../types";
<mask> import { UI } from "./helpers/ui";
<mask>
<mask> const { h } = window;
<mask>
<mask> describe("library", () => {
</s> feat: support adding multiple library items on canvas (#5116) </s> remove import { LibraryItem } from "../types";
</s> add import { LibraryItem, LibraryItems } from "../types"; </s> remove import { MIME_TYPES } from "../constants";
</s> add </s> remove import { VERSIONS } from "../constants";
</s> add import { MIME_TYPES, VERSIONS } from "../constants"; </s> add import { ExcalidrawElement } from "../element/types";
import { getCommonBoundingBox } from "../element/bounds"; </s> remove import Library from "../data/library";
</s> add import Library, { distributeLibraryItemsOnSquareGrid } from "../data/library"; </s> remove import Library from "../data/library";
</s> add import Library, { distributeLibraryItemsOnSquareGrid } from "../data/library";
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/tests/library.test.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> const libraryItems: LibraryItem = JSON.parse(
<mask> await API.readFile("./fixtures/fixture_library.excalidrawlib", "utf8"),
<mask> ).library[0];
<mask> await API.drop(
<mask> new Blob([JSON.stringify(libraryItems)], {
<mask> type: MIME_TYPES.excalidrawlib,
<mask> }),
<mask> );
<mask> await waitFor(() => {
<mask> expect(h.elements).toEqual([expect.objectContaining({ id: "A_copy" })]);
</s> feat: support adding multiple library items on canvas (#5116) </s> remove new Blob([JSON.stringify(libraryItems)], {
</s> add new Blob([serializeLibraryAsJSON([libraryItems])], { </s> remove const contents = await parseFileContents(blob);
const data: ImportedLibraryData | undefined = JSON.parse(contents);
</s> add const data: ImportedLibraryData | undefined = JSON.parse(json); </s> remove export const loadLibraryFromBlob = async (
blob: Blob,
</s> add export const parseLibraryJSON = (
json: string, </s> add const getInsertedElements = (id: string) => {
let targetElements;
if (selectedItems.includes(id)) {
targetElements = libraryItems.filter((item) =>
selectedItems.includes(item.id),
);
} else {
targetElements = libraryItems.filter((item) => item.id === id);
}
return targetElements;
};
</s> add onDrag={(id, event) => {
event.dataTransfer.setData(
MIME_TYPES.excalidrawlib,
serializeLibraryAsJSON(getInsertedElements(id)),
);
}} </s> add export const loadLibraryFromBlob = async (
blob: Blob,
defaultStatus: LibraryItem["status"] = "unpublished",
) => {
return parseLibraryJSON(await parseFileContents(blob), defaultStatus);
};
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/tests/library.test.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> const libraryItems: LibraryItem = JSON.parse(
<mask> await API.readFile("./fixtures/fixture_library.excalidrawlib", "utf8"),
<mask> ).library[0];
<mask> await API.drop(
<mask> new Blob([JSON.stringify(libraryItems)], {
<mask> type: MIME_TYPES.excalidrawlib,
<mask> }),
<mask> );
<mask> await waitFor(() => {
<mask> expect(h.elements).toEqual([expect.objectContaining({ id: "A_copy" })]);
</s> feat: support adding multiple library items on canvas (#5116)
|
https://github.com/excalidraw/excalidraw/commit/d2cc76e52eae9377f924172efebb81fae8baba5a
|
src/tests/library.test.tsx
|
keep add keep keep keep keep keep
|
<mask> generateIdFromFile,
<mask> getDataURL,
<mask> isSupportedImageFile,
<mask> loadSceneOrLibraryFromBlob,
<mask> normalizeFile,
<mask> loadLibraryFromBlob,
<mask> resizeImageFile,
</s> feat: make file handling more robust (#5057) </s> add loadSceneOrLibraryFromBlob,
normalizeFile, </s> add loadSceneOrLibraryFromBlob, </s> remove export { loadFromBlob, loadLibraryFromBlob } from "../data/blob";
</s> add export {
loadFromBlob,
loadSceneOrLibraryFromBlob,
loadLibraryFromBlob,
} from "../data/blob"; </s> add const loadSceneOrLibrary = async () => {
const file = await fileOpen({ description: "Excalidraw or library file" });
const contents = await loadSceneOrLibraryFromBlob(file, null, null);
excalidrawRef.current.updateScene(contents.data);
};
</s> add import { fileOpen } from "../../../data/filesystem";
import { loadSceneOrLibraryFromBlob } from "../../utils"; </s> add <button onClick={loadSceneOrLibrary}>Load Scene or Library</button>
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/components/App.tsx
|
keep add keep keep keep keep
|
<mask> getFileFromEvent,
<mask> isSupportedImageFile,
<mask> loadLibraryFromBlob,
<mask> resizeImageFile,
<mask> SVGStringToFile,
<mask> } from "../data/blob";
</s> feat: make file handling more robust (#5057) </s> add getFileFromEvent, </s> remove export { loadFromBlob, loadLibraryFromBlob } from "../data/blob";
</s> add export {
loadFromBlob,
loadSceneOrLibraryFromBlob,
loadLibraryFromBlob,
} from "../data/blob"; </s> add loadSceneOrLibraryFromBlob, </s> remove import { FileSystemHandle } from "./filesystem";
</s> add import { FileSystemHandle, nativeFileSystemSupported } from "./filesystem"; </s> remove import { isImageFileHandle, loadFromBlob } from "./blob";
</s> add import { isImageFileHandle, loadFromBlob, normalizeFile } from "./blob"; </s> remove import { fileOpen, nativeFileSystemSupported } from "../data/filesystem";
</s> add import { fileOpen, FileSystemHandle } from "../data/filesystem";
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/components/App.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> normalizeSVG,
<mask> updateImageCache as _updateImageCache,
<mask> } from "../element/image";
<mask> import throttle from "lodash.throttle";
<mask> import { fileOpen, nativeFileSystemSupported } from "../data/filesystem";
<mask> import {
<mask> bindTextToShapeAfterDuplication,
<mask> getApproxMinLineHeight,
<mask> getApproxMinLineWidth,
<mask> getBoundTextElement,
</s> feat: make file handling more robust (#5057) </s> remove import { FileSystemHandle } from "./filesystem";
</s> add import { FileSystemHandle, nativeFileSystemSupported } from "./filesystem"; </s> remove import { isImageFileHandle, loadFromBlob } from "./blob";
</s> add import { isImageFileHandle, loadFromBlob, normalizeFile } from "./blob"; </s> add import { blobToArrayBuffer } from "./blob"; </s> add import { fileOpen } from "../../../data/filesystem";
import { loadSceneOrLibraryFromBlob } from "../../utils"; </s> add import { blobToArrayBuffer } from "./blob"; </s> remove export { loadFromBlob, loadLibraryFromBlob } from "../data/blob";
</s> add export {
loadFromBlob,
loadSceneOrLibraryFromBlob,
loadLibraryFromBlob,
} from "../data/blob";
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/components/App.tsx
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> return;
<mask> }
<mask> const fileHandle = launchParams.files[0];
<mask> const blob: Blob = await fileHandle.getFile();
<mask> blob.handle = fileHandle;
<mask> loadFromBlob(
<mask> blob,
<mask> this.state,
<mask> this.scene.getElementsIncludingDeleted(),
<mask> )
<mask> .then((scene) => {
<mask> this.syncActionResult({
<mask> ...scene,
<mask> appState: {
<mask> ...(scene.appState || this.state),
<mask> isLoading: false,
<mask> },
<mask> commitToHistory: true,
<mask> });
<mask> })
<mask> .catch((error) => {
<mask> this.setState({ isLoading: false, errorMessage: error.message });
<mask> });
<mask> },
<mask> );
<mask> }
<mask>
<mask> if (!this.state.isLoading) {
</s> feat: make file handling more robust (#5057) </s> remove })
.catch((error) => {
this.setState({ isLoading: false, errorMessage: error.message });
});
</s> add } else if (ret.type === MIME_TYPES.excalidrawlib) {
this.library
.importLibrary(file)
.then(() => {
this.setState({
isLoading: false,
});
})
.catch((error) => {
console.error(error);
this.setState({
isLoading: false,
errorMessage: t("errors.importLibraryError"),
});
});
}
} catch (error: any) {
this.setState({ isLoading: false, errorMessage: error.message });
} </s> remove ...(scene.appState || this.state),
</s> add ...(ret.data.appState || this.state), </s> remove loadFileToCanvas = (file: Blob) => {
loadFromBlob(file, this.state, this.scene.getElementsIncludingDeleted())
.then((scene) => {
</s> add loadFileToCanvas = async (
file: File,
fileHandle: FileSystemHandle | null,
) => {
file = await normalizeFile(file);
try {
const ret = await loadSceneOrLibraryFromBlob(
file,
this.state,
this.scene.getElementsIncludingDeleted(),
fileHandle,
);
if (ret.type === MIME_TYPES.excalidraw) {
this.setState({ isLoading: true }); </s> remove ...scene,
</s> add ...ret.data, </s> remove const file = event.dataTransfer?.files.item(0);
if (
file?.type === MIME_TYPES.excalidrawlib ||
file?.name?.endsWith(".excalidrawlib")
) {
this.setState({ isLibraryOpen: true });
this.library.importLibrary(file).catch((error) => {
console.error(error);
this.setState({
isLoading: false,
errorMessage: t("errors.importLibraryError"),
});
});
// default: assume an Excalidraw file regardless of extension/MimeType
} else if (file) {
this.setState({ isLoading: true });
if (nativeFileSystemSupported) {
try {
// This will only work as of Chrome 86,
// but can be safely ignored on older releases.
const item = event.dataTransfer.items[0];
(file as any).handle = await (item as any).getAsFileSystemHandle();
} catch (error: any) {
console.warn(error.name, error.message);
}
}
await this.loadFileToCanvas(file);
</s> add if (file) {
// atetmpt to parse an excalidraw/excalidrawlib file
await this.loadFileToCanvas(file, fileHandle); </s> remove const file = await webShareTargetCache.match("shared-file");
if (file) {
const blob = await file.blob();
this.loadFileToCanvas(blob);
</s> add const response = await webShareTargetCache.match("shared-file");
if (response) {
const blob = await response.blob();
const file = new File([blob], blob.name || "", { type: blob.type });
this.loadFileToCanvas(file, null);
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/components/App.tsx
|
keep keep keep keep replace replace replace replace keep keep keep keep keep
|
<mask> restoreFileFromShare = async () => {
<mask> try {
<mask> const webShareTargetCache = await caches.open("web-share-target");
<mask>
<mask> const file = await webShareTargetCache.match("shared-file");
<mask> if (file) {
<mask> const blob = await file.blob();
<mask> this.loadFileToCanvas(blob);
<mask> await webShareTargetCache.delete("shared-file");
<mask> window.history.replaceState(null, APP_NAME, window.location.pathname);
<mask> }
<mask> } catch (error: any) {
<mask> this.setState({ errorMessage: error.message });
</s> feat: make file handling more robust (#5057) </s> remove const file = event.dataTransfer?.files.item(0);
if (
file?.type === MIME_TYPES.excalidrawlib ||
file?.name?.endsWith(".excalidrawlib")
) {
this.setState({ isLibraryOpen: true });
this.library.importLibrary(file).catch((error) => {
console.error(error);
this.setState({
isLoading: false,
errorMessage: t("errors.importLibraryError"),
});
});
// default: assume an Excalidraw file regardless of extension/MimeType
} else if (file) {
this.setState({ isLoading: true });
if (nativeFileSystemSupported) {
try {
// This will only work as of Chrome 86,
// but can be safely ignored on older releases.
const item = event.dataTransfer.items[0];
(file as any).handle = await (item as any).getAsFileSystemHandle();
} catch (error: any) {
console.warn(error.name, error.message);
}
}
await this.loadFileToCanvas(file);
</s> add if (file) {
// atetmpt to parse an excalidraw/excalidrawlib file
await this.loadFileToCanvas(file, fileHandle); </s> remove })
.catch((error) => {
this.setState({ isLoading: false, errorMessage: error.message });
});
</s> add } else if (ret.type === MIME_TYPES.excalidrawlib) {
this.library
.importLibrary(file)
.then(() => {
this.setState({
isLoading: false,
});
})
.catch((error) => {
console.error(error);
this.setState({
isLoading: false,
errorMessage: t("errors.importLibraryError"),
});
});
}
} catch (error: any) {
this.setState({ isLoading: false, errorMessage: error.message });
} </s> add const loadSceneOrLibrary = async () => {
const file = await fileOpen({ description: "Excalidraw or library file" });
const contents = await loadSceneOrLibraryFromBlob(file, null, null);
excalidrawRef.current.updateScene(contents.data);
};
</s> remove blob.handle = fileHandle;
loadFromBlob(
blob,
this.state,
this.scene.getElementsIncludingDeleted(),
)
.then((scene) => {
this.syncActionResult({
...scene,
appState: {
...(scene.appState || this.state),
isLoading: false,
},
commitToHistory: true,
});
})
.catch((error) => {
this.setState({ isLoading: false, errorMessage: error.message });
});
</s> add this.loadFileToCanvas(
new File([blob], blob.name || "", { type: blob.type }),
fileHandle,
); </s> remove await file.arrayBuffer(),
</s> add await blobToArrayBuffer(file), </s> remove loadFileToCanvas = (file: Blob) => {
loadFromBlob(file, this.state, this.scene.getElementsIncludingDeleted())
.then((scene) => {
</s> add loadFileToCanvas = async (
file: File,
fileHandle: FileSystemHandle | null,
) => {
file = await normalizeFile(file);
try {
const ret = await loadSceneOrLibraryFromBlob(
file,
this.state,
this.scene.getElementsIncludingDeleted(),
fileHandle,
);
if (ret.type === MIME_TYPES.excalidraw) {
this.setState({ isLoading: true });
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/components/App.tsx
|
keep keep keep keep replace replace keep keep keep keep keep
|
<mask> }
<mask> };
<mask>
<mask> private handleAppOnDrop = async (event: React.DragEvent<HTMLDivElement>) => {
<mask> try {
<mask> const file = event.dataTransfer.files.item(0);
<mask>
<mask> if (isSupportedImageFile(file)) {
<mask> // first attempt to decode scene from the image if it's embedded
<mask> // ---------------------------------------------------------------------
<mask>
</s> feat: make file handling more robust (#5057) </s> add try { </s> remove if (nativeFileSystemSupported) {
try {
// This will only work as of Chrome 86,
// but can be safely ignored on older releases.
const item = event.dataTransfer.items[0];
(file as any).handle = await (
item as any
).getAsFileSystemHandle();
} catch (error: any) {
console.warn(error.name, error.message);
}
}
</s> add </s> remove const file = event.dataTransfer?.files.item(0);
if (
file?.type === MIME_TYPES.excalidrawlib ||
file?.name?.endsWith(".excalidrawlib")
) {
this.setState({ isLibraryOpen: true });
this.library.importLibrary(file).catch((error) => {
console.error(error);
this.setState({
isLoading: false,
errorMessage: t("errors.importLibraryError"),
});
});
// default: assume an Excalidraw file regardless of extension/MimeType
} else if (file) {
this.setState({ isLoading: true });
if (nativeFileSystemSupported) {
try {
// This will only work as of Chrome 86,
// but can be safely ignored on older releases.
const item = event.dataTransfer.items[0];
(file as any).handle = await (item as any).getAsFileSystemHandle();
} catch (error: any) {
console.warn(error.name, error.message);
}
}
await this.loadFileToCanvas(file);
</s> add if (file) {
// atetmpt to parse an excalidraw/excalidrawlib file
await this.loadFileToCanvas(file, fileHandle); </s> remove const blobToArrayBuffer = (blob: Blob): Promise<ArrayBuffer> => {
if ("arrayBuffer" in blob) {
return blob.arrayBuffer();
}
// Safari
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = (event) => {
if (!event.target?.result) {
return reject(new Error("couldn't convert blob to ArrayBuffer"));
}
resolve(event.target.result as ArrayBuffer);
};
reader.readAsArrayBuffer(blob);
});
};
</s> add </s> remove const file = await webShareTargetCache.match("shared-file");
if (file) {
const blob = await file.blob();
this.loadFileToCanvas(blob);
</s> add const response = await webShareTargetCache.match("shared-file");
if (response) {
const blob = await response.blob();
const file = new File([blob], blob.name || "", { type: blob.type });
this.loadFileToCanvas(file, null); </s> remove await file.arrayBuffer(),
</s> add await blobToArrayBuffer(file),
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/components/App.tsx
|
keep keep keep add keep keep keep keep keep keep
|
<mask> private handleAppOnDrop = async (event: React.DragEvent<HTMLDivElement>) => {
<mask> // must be retrieved first, in the same frame
<mask> const { file, fileHandle } = await getFileFromEvent(event);
<mask>
<mask> if (isSupportedImageFile(file)) {
<mask> // first attempt to decode scene from the image if it's embedded
<mask> // ---------------------------------------------------------------------
<mask>
<mask> if (file?.type === MIME_TYPES.png || file?.type === MIME_TYPES.svg) {
<mask> try {
</s> feat: make file handling more robust (#5057) </s> remove try {
const file = event.dataTransfer.files.item(0);
</s> add // must be retrieved first, in the same frame
const { file, fileHandle } = await getFileFromEvent(event); </s> remove if (nativeFileSystemSupported) {
try {
// This will only work as of Chrome 86,
// but can be safely ignored on older releases.
const item = event.dataTransfer.items[0];
(file as any).handle = await (
item as any
).getAsFileSystemHandle();
} catch (error: any) {
console.warn(error.name, error.message);
}
}
</s> add </s> remove const file = event.dataTransfer?.files.item(0);
if (
file?.type === MIME_TYPES.excalidrawlib ||
file?.name?.endsWith(".excalidrawlib")
) {
this.setState({ isLibraryOpen: true });
this.library.importLibrary(file).catch((error) => {
console.error(error);
this.setState({
isLoading: false,
errorMessage: t("errors.importLibraryError"),
});
});
// default: assume an Excalidraw file regardless of extension/MimeType
} else if (file) {
this.setState({ isLoading: true });
if (nativeFileSystemSupported) {
try {
// This will only work as of Chrome 86,
// but can be safely ignored on older releases.
const item = event.dataTransfer.items[0];
(file as any).handle = await (item as any).getAsFileSystemHandle();
} catch (error: any) {
console.warn(error.name, error.message);
}
}
await this.loadFileToCanvas(file);
</s> add if (file) {
// atetmpt to parse an excalidraw/excalidrawlib file
await this.loadFileToCanvas(file, fileHandle); </s> remove const blobToArrayBuffer = (blob: Blob): Promise<ArrayBuffer> => {
if ("arrayBuffer" in blob) {
return blob.arrayBuffer();
}
// Safari
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = (event) => {
if (!event.target?.result) {
return reject(new Error("couldn't convert blob to ArrayBuffer"));
}
resolve(event.target.result as ArrayBuffer);
};
reader.readAsArrayBuffer(blob);
});
};
</s> add </s> remove loadFileToCanvas = (file: Blob) => {
loadFromBlob(file, this.state, this.scene.getElementsIncludingDeleted())
.then((scene) => {
</s> add loadFileToCanvas = async (
file: File,
fileHandle: FileSystemHandle | null,
) => {
file = await normalizeFile(file);
try {
const ret = await loadSceneOrLibraryFromBlob(
file,
this.state,
this.scene.getElementsIncludingDeleted(),
fileHandle,
);
if (ret.type === MIME_TYPES.excalidraw) {
this.setState({ isLoading: true }); </s> remove await file.arrayBuffer(),
</s> add await blobToArrayBuffer(file),
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/components/App.tsx
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> // ---------------------------------------------------------------------
<mask>
<mask> if (file?.type === MIME_TYPES.png || file?.type === MIME_TYPES.svg) {
<mask> try {
<mask> if (nativeFileSystemSupported) {
<mask> try {
<mask> // This will only work as of Chrome 86,
<mask> // but can be safely ignored on older releases.
<mask> const item = event.dataTransfer.items[0];
<mask> (file as any).handle = await (
<mask> item as any
<mask> ).getAsFileSystemHandle();
<mask> } catch (error: any) {
<mask> console.warn(error.name, error.message);
<mask> }
<mask> }
<mask>
<mask> const scene = await loadFromBlob(
<mask> file,
<mask> this.state,
<mask> this.scene.getElementsIncludingDeleted(),
<mask> );
</s> feat: make file handling more robust (#5057) </s> remove const file = event.dataTransfer?.files.item(0);
if (
file?.type === MIME_TYPES.excalidrawlib ||
file?.name?.endsWith(".excalidrawlib")
) {
this.setState({ isLibraryOpen: true });
this.library.importLibrary(file).catch((error) => {
console.error(error);
this.setState({
isLoading: false,
errorMessage: t("errors.importLibraryError"),
});
});
// default: assume an Excalidraw file regardless of extension/MimeType
} else if (file) {
this.setState({ isLoading: true });
if (nativeFileSystemSupported) {
try {
// This will only work as of Chrome 86,
// but can be safely ignored on older releases.
const item = event.dataTransfer.items[0];
(file as any).handle = await (item as any).getAsFileSystemHandle();
} catch (error: any) {
console.warn(error.name, error.message);
}
}
await this.loadFileToCanvas(file);
</s> add if (file) {
// atetmpt to parse an excalidraw/excalidrawlib file
await this.loadFileToCanvas(file, fileHandle); </s> add try { </s> remove try {
const file = event.dataTransfer.files.item(0);
</s> add // must be retrieved first, in the same frame
const { file, fileHandle } = await getFileFromEvent(event); </s> remove await file.arrayBuffer(),
</s> add await blobToArrayBuffer(file), </s> remove loadFileToCanvas = (file: Blob) => {
loadFromBlob(file, this.state, this.scene.getElementsIncludingDeleted())
.then((scene) => {
</s> add loadFileToCanvas = async (
file: File,
fileHandle: FileSystemHandle | null,
) => {
file = await normalizeFile(file);
try {
const ret = await loadSceneOrLibraryFromBlob(
file,
this.state,
this.scene.getElementsIncludingDeleted(),
fileHandle,
);
if (ret.type === MIME_TYPES.excalidraw) {
this.setState({ isLoading: true }); </s> remove const blobToArrayBuffer = (blob: Blob): Promise<ArrayBuffer> => {
if ("arrayBuffer" in blob) {
return blob.arrayBuffer();
}
// Safari
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = (event) => {
if (!event.target?.result) {
return reject(new Error("couldn't convert blob to ArrayBuffer"));
}
resolve(event.target.result as ArrayBuffer);
};
reader.readAsArrayBuffer(blob);
});
};
</s> add
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/components/App.tsx
|
keep keep add keep keep keep keep
|
<mask> file,
<mask> this.state,
<mask> this.scene.getElementsIncludingDeleted(),
<mask> );
<mask> this.syncActionResult({
<mask> ...scene,
<mask> appState: {
</s> feat: make file handling more robust (#5057) </s> remove loadFileToCanvas = (file: Blob) => {
loadFromBlob(file, this.state, this.scene.getElementsIncludingDeleted())
.then((scene) => {
</s> add loadFileToCanvas = async (
file: File,
fileHandle: FileSystemHandle | null,
) => {
file = await normalizeFile(file);
try {
const ret = await loadSceneOrLibraryFromBlob(
file,
this.state,
this.scene.getElementsIncludingDeleted(),
fileHandle,
);
if (ret.type === MIME_TYPES.excalidraw) {
this.setState({ isLoading: true }); </s> remove blob.handle = fileHandle;
loadFromBlob(
blob,
this.state,
this.scene.getElementsIncludingDeleted(),
)
.then((scene) => {
this.syncActionResult({
...scene,
appState: {
...(scene.appState || this.state),
isLoading: false,
},
commitToHistory: true,
});
})
.catch((error) => {
this.setState({ isLoading: false, errorMessage: error.message });
});
</s> add this.loadFileToCanvas(
new File([blob], blob.name || "", { type: blob.type }),
fileHandle,
); </s> remove ...scene,
</s> add ...ret.data, </s> remove ...(scene.appState || this.state),
</s> add ...(ret.data.appState || this.state), </s> remove if (nativeFileSystemSupported) {
try {
// This will only work as of Chrome 86,
// but can be safely ignored on older releases.
const item = event.dataTransfer.items[0];
(file as any).handle = await (
item as any
).getAsFileSystemHandle();
} catch (error: any) {
console.warn(error.name, error.message);
}
}
</s> add </s> remove const result = restore(
{
elements: clearElementsForExport(data.elements || []),
appState: {
theme: localAppState?.theme,
fileHandle: blob.handle || null,
...cleanAppStateForExport(data.appState || {}),
...(localAppState
? calculateScrollCenter(data.elements || [], localAppState, null)
: {}),
},
files: data.files,
},
localAppState,
localElements,
);
return result;
</s> add throw new Error(t("alerts.couldNotLoadInvalidFile"));
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/components/App.tsx
|
keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep replace replace replace keep keep keep keep
|
<mask> return;
<mask> }
<mask>
<mask> const file = event.dataTransfer?.files.item(0);
<mask> if (
<mask> file?.type === MIME_TYPES.excalidrawlib ||
<mask> file?.name?.endsWith(".excalidrawlib")
<mask> ) {
<mask> this.setState({ isLibraryOpen: true });
<mask> this.library.importLibrary(file).catch((error) => {
<mask> console.error(error);
<mask> this.setState({
<mask> isLoading: false,
<mask> errorMessage: t("errors.importLibraryError"),
<mask> });
<mask> });
<mask> // default: assume an Excalidraw file regardless of extension/MimeType
<mask> } else if (file) {
<mask> this.setState({ isLoading: true });
<mask> if (nativeFileSystemSupported) {
<mask> try {
<mask> // This will only work as of Chrome 86,
<mask> // but can be safely ignored on older releases.
<mask> const item = event.dataTransfer.items[0];
<mask> (file as any).handle = await (item as any).getAsFileSystemHandle();
<mask> } catch (error: any) {
<mask> console.warn(error.name, error.message);
<mask> }
<mask> }
<mask> await this.loadFileToCanvas(file);
<mask> }
<mask> };
<mask>
<mask> loadFileToCanvas = (file: Blob) => {
<mask> loadFromBlob(file, this.state, this.scene.getElementsIncludingDeleted())
<mask> .then((scene) => {
<mask> this.syncActionResult({
<mask> ...scene,
<mask> appState: {
<mask> ...(scene.appState || this.state),
</s> feat: make file handling more robust (#5057) </s> remove if (nativeFileSystemSupported) {
try {
// This will only work as of Chrome 86,
// but can be safely ignored on older releases.
const item = event.dataTransfer.items[0];
(file as any).handle = await (
item as any
).getAsFileSystemHandle();
} catch (error: any) {
console.warn(error.name, error.message);
}
}
</s> add </s> remove })
.catch((error) => {
this.setState({ isLoading: false, errorMessage: error.message });
});
</s> add } else if (ret.type === MIME_TYPES.excalidrawlib) {
this.library
.importLibrary(file)
.then(() => {
this.setState({
isLoading: false,
});
})
.catch((error) => {
console.error(error);
this.setState({
isLoading: false,
errorMessage: t("errors.importLibraryError"),
});
});
}
} catch (error: any) {
this.setState({ isLoading: false, errorMessage: error.message });
} </s> remove blob.handle = fileHandle;
loadFromBlob(
blob,
this.state,
this.scene.getElementsIncludingDeleted(),
)
.then((scene) => {
this.syncActionResult({
...scene,
appState: {
...(scene.appState || this.state),
isLoading: false,
},
commitToHistory: true,
});
})
.catch((error) => {
this.setState({ isLoading: false, errorMessage: error.message });
});
</s> add this.loadFileToCanvas(
new File([blob], blob.name || "", { type: blob.type }),
fileHandle,
); </s> remove ...scene,
</s> add ...ret.data, </s> remove const file = await webShareTargetCache.match("shared-file");
if (file) {
const blob = await file.blob();
this.loadFileToCanvas(blob);
</s> add const response = await webShareTargetCache.match("shared-file");
if (response) {
const blob = await response.blob();
const file = new File([blob], blob.name || "", { type: blob.type });
this.loadFileToCanvas(file, null);
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/components/App.tsx
|
keep keep keep keep replace keep replace keep keep keep keep
|
<mask> loadFileToCanvas = (file: Blob) => {
<mask> loadFromBlob(file, this.state, this.scene.getElementsIncludingDeleted())
<mask> .then((scene) => {
<mask> this.syncActionResult({
<mask> ...scene,
<mask> appState: {
<mask> ...(scene.appState || this.state),
<mask> isLoading: false,
<mask> },
<mask> replaceFiles: true,
<mask> commitToHistory: true,
</s> feat: make file handling more robust (#5057) </s> remove loadFileToCanvas = (file: Blob) => {
loadFromBlob(file, this.state, this.scene.getElementsIncludingDeleted())
.then((scene) => {
</s> add loadFileToCanvas = async (
file: File,
fileHandle: FileSystemHandle | null,
) => {
file = await normalizeFile(file);
try {
const ret = await loadSceneOrLibraryFromBlob(
file,
this.state,
this.scene.getElementsIncludingDeleted(),
fileHandle,
);
if (ret.type === MIME_TYPES.excalidraw) {
this.setState({ isLoading: true }); </s> remove blob.handle = fileHandle;
loadFromBlob(
blob,
this.state,
this.scene.getElementsIncludingDeleted(),
)
.then((scene) => {
this.syncActionResult({
...scene,
appState: {
...(scene.appState || this.state),
isLoading: false,
},
commitToHistory: true,
});
})
.catch((error) => {
this.setState({ isLoading: false, errorMessage: error.message });
});
</s> add this.loadFileToCanvas(
new File([blob], blob.name || "", { type: blob.type }),
fileHandle,
); </s> remove })
.catch((error) => {
this.setState({ isLoading: false, errorMessage: error.message });
});
</s> add } else if (ret.type === MIME_TYPES.excalidrawlib) {
this.library
.importLibrary(file)
.then(() => {
this.setState({
isLoading: false,
});
})
.catch((error) => {
console.error(error);
this.setState({
isLoading: false,
errorMessage: t("errors.importLibraryError"),
});
});
}
} catch (error: any) {
this.setState({ isLoading: false, errorMessage: error.message });
} </s> remove const file = event.dataTransfer?.files.item(0);
if (
file?.type === MIME_TYPES.excalidrawlib ||
file?.name?.endsWith(".excalidrawlib")
) {
this.setState({ isLibraryOpen: true });
this.library.importLibrary(file).catch((error) => {
console.error(error);
this.setState({
isLoading: false,
errorMessage: t("errors.importLibraryError"),
});
});
// default: assume an Excalidraw file regardless of extension/MimeType
} else if (file) {
this.setState({ isLoading: true });
if (nativeFileSystemSupported) {
try {
// This will only work as of Chrome 86,
// but can be safely ignored on older releases.
const item = event.dataTransfer.items[0];
(file as any).handle = await (item as any).getAsFileSystemHandle();
} catch (error: any) {
console.warn(error.name, error.message);
}
}
await this.loadFileToCanvas(file);
</s> add if (file) {
// atetmpt to parse an excalidraw/excalidrawlib file
await this.loadFileToCanvas(file, fileHandle); </s> add fileHandle,
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/components/App.tsx
|
keep keep keep keep replace replace replace replace keep keep keep keep keep
|
<mask> },
<mask> replaceFiles: true,
<mask> commitToHistory: true,
<mask> });
<mask> })
<mask> .catch((error) => {
<mask> this.setState({ isLoading: false, errorMessage: error.message });
<mask> });
<mask> };
<mask>
<mask> private handleCanvasContextMenu = (
<mask> event: React.PointerEvent<HTMLCanvasElement>,
<mask> ) => {
</s> feat: make file handling more robust (#5057) </s> remove blob.handle = fileHandle;
loadFromBlob(
blob,
this.state,
this.scene.getElementsIncludingDeleted(),
)
.then((scene) => {
this.syncActionResult({
...scene,
appState: {
...(scene.appState || this.state),
isLoading: false,
},
commitToHistory: true,
});
})
.catch((error) => {
this.setState({ isLoading: false, errorMessage: error.message });
});
</s> add this.loadFileToCanvas(
new File([blob], blob.name || "", { type: blob.type }),
fileHandle,
); </s> remove ...(scene.appState || this.state),
</s> add ...(ret.data.appState || this.state), </s> remove ...scene,
</s> add ...ret.data, </s> remove const file = event.dataTransfer?.files.item(0);
if (
file?.type === MIME_TYPES.excalidrawlib ||
file?.name?.endsWith(".excalidrawlib")
) {
this.setState({ isLibraryOpen: true });
this.library.importLibrary(file).catch((error) => {
console.error(error);
this.setState({
isLoading: false,
errorMessage: t("errors.importLibraryError"),
});
});
// default: assume an Excalidraw file regardless of extension/MimeType
} else if (file) {
this.setState({ isLoading: true });
if (nativeFileSystemSupported) {
try {
// This will only work as of Chrome 86,
// but can be safely ignored on older releases.
const item = event.dataTransfer.items[0];
(file as any).handle = await (item as any).getAsFileSystemHandle();
} catch (error: any) {
console.warn(error.name, error.message);
}
}
await this.loadFileToCanvas(file);
</s> add if (file) {
// atetmpt to parse an excalidraw/excalidrawlib file
await this.loadFileToCanvas(file, fileHandle); </s> remove loadFileToCanvas = (file: Blob) => {
loadFromBlob(file, this.state, this.scene.getElementsIncludingDeleted())
.then((scene) => {
</s> add loadFileToCanvas = async (
file: File,
fileHandle: FileSystemHandle | null,
) => {
file = await normalizeFile(file);
try {
const ret = await loadSceneOrLibraryFromBlob(
file,
this.state,
this.scene.getElementsIncludingDeleted(),
fileHandle,
);
if (ret.type === MIME_TYPES.excalidraw) {
this.setState({ isLoading: true }); </s> remove const file = await webShareTargetCache.match("shared-file");
if (file) {
const blob = await file.blob();
this.loadFileToCanvas(blob);
</s> add const response = await webShareTargetCache.match("shared-file");
if (response) {
const blob = await response.blob();
const file = new File([blob], blob.name || "", { type: blob.type });
this.loadFileToCanvas(file, null);
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/components/App.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> import { t } from "../i18n";
<mask> import { calculateScrollCenter } from "../scene";
<mask> import { AppState, DataURL, LibraryItem } from "../types";
<mask> import { bytesToHexString } from "../utils";
<mask> import { FileSystemHandle } from "./filesystem";
<mask> import { isValidExcalidrawData, isValidLibrary } from "./json";
<mask> import { restore, restoreLibraryItems } from "./restore";
<mask> import { ImportedLibraryData } from "./types";
<mask>
<mask> const parseFileContents = async (blob: Blob | File) => {
</s> feat: make file handling more robust (#5057) </s> remove import { isImageFileHandle, loadFromBlob } from "./blob";
</s> add import { isImageFileHandle, loadFromBlob, normalizeFile } from "./blob"; </s> remove import { fileOpen, nativeFileSystemSupported } from "../data/filesystem";
</s> add import { fileOpen, FileSystemHandle } from "../data/filesystem"; </s> add import { blobToArrayBuffer } from "./blob"; </s> add import { blobToArrayBuffer } from "./blob"; </s> add import { fileOpen } from "../../../data/filesystem";
import { loadSceneOrLibraryFromBlob } from "../../utils"; </s> remove export { loadFromBlob, loadLibraryFromBlob } from "../data/blob";
</s> add export {
loadFromBlob,
loadSceneOrLibraryFromBlob,
loadLibraryFromBlob,
} from "../data/blob";
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/data/blob.ts
|
keep keep keep keep replace replace keep keep keep keep keep
|
<mask> !!type && (ALLOWED_IMAGE_MIME_TYPES as readonly string[]).includes(type)
<mask> );
<mask> };
<mask>
<mask> export const loadFromBlob = async (
<mask> blob: Blob,
<mask> /** @see restore.localAppState */
<mask> localAppState: AppState | null,
<mask> localElements: readonly ExcalidrawElement[] | null,
<mask> ) => {
<mask> const contents = await parseFileContents(blob);
</s> feat: make file handling more robust (#5057) </s> add /** FileSystemHandle. Defaults to `blob.handle` if defined, otherwise null. */
fileHandle?: FileSystemHandle | null, </s> remove const blob = await fileOpen({
</s> add const file = await fileOpen({ </s> remove const blobToArrayBuffer = (blob: Blob): Promise<ArrayBuffer> => {
if ("arrayBuffer" in blob) {
return blob.arrayBuffer();
}
// Safari
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = (event) => {
if (!event.target?.result) {
return reject(new Error("couldn't convert blob to ArrayBuffer"));
}
resolve(event.target.result as ArrayBuffer);
};
reader.readAsArrayBuffer(blob);
});
};
</s> add </s> remove loadFileToCanvas = (file: Blob) => {
loadFromBlob(file, this.state, this.scene.getElementsIncludingDeleted())
.then((scene) => {
</s> add loadFileToCanvas = async (
file: File,
fileHandle: FileSystemHandle | null,
) => {
file = await normalizeFile(file);
try {
const ret = await loadSceneOrLibraryFromBlob(
file,
this.state,
this.scene.getElementsIncludingDeleted(),
fileHandle,
);
if (ret.type === MIME_TYPES.excalidraw) {
this.setState({ isLoading: true }); </s> add export { MIME_TYPES };
</s> add const loadSceneOrLibrary = async () => {
const file = await fileOpen({ description: "Excalidraw or library file" });
const contents = await loadSceneOrLibraryFromBlob(file, null, null);
excalidrawRef.current.updateScene(contents.data);
};
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/data/blob.ts
|
keep add keep keep keep keep keep
|
<mask> localAppState: AppState | null,
<mask> localElements: readonly ExcalidrawElement[] | null,
<mask> ) => {
<mask> const contents = await parseFileContents(blob);
<mask> try {
<mask> const data = JSON.parse(contents);
<mask> if (isValidExcalidrawData(data)) {
</s> feat: make file handling more robust (#5057) </s> remove export const loadFromBlob = async (
blob: Blob,
</s> add export const loadSceneOrLibraryFromBlob = async (
blob: Blob | File, </s> remove if (!isValidExcalidrawData(data)) {
throw new Error(t("alerts.couldNotLoadInvalidFile"));
</s> add if (isValidExcalidrawData(data)) {
return {
type: MIME_TYPES.excalidraw,
data: restore(
{
elements: clearElementsForExport(data.elements || []),
appState: {
theme: localAppState?.theme,
fileHandle: fileHandle || blob.handle || null,
...cleanAppStateForExport(data.appState || {}),
...(localAppState
? calculateScrollCenter(
data.elements || [],
localAppState,
null,
)
: {}),
},
files: data.files,
},
localAppState,
localElements,
),
};
} else if (isValidLibrary(data)) {
return {
type: MIME_TYPES.excalidrawlib,
data,
}; </s> remove const blob = await fileOpen({
</s> add const file = await fileOpen({ </s> remove loadFileToCanvas = (file: Blob) => {
loadFromBlob(file, this.state, this.scene.getElementsIncludingDeleted())
.then((scene) => {
</s> add loadFileToCanvas = async (
file: File,
fileHandle: FileSystemHandle | null,
) => {
file = await normalizeFile(file);
try {
const ret = await loadSceneOrLibraryFromBlob(
file,
this.state,
this.scene.getElementsIncludingDeleted(),
fileHandle,
);
if (ret.type === MIME_TYPES.excalidraw) {
this.setState({ isLoading: true }); </s> add const loadSceneOrLibrary = async () => {
const file = await fileOpen({ description: "Excalidraw or library file" });
const contents = await loadSceneOrLibraryFromBlob(file, null, null);
excalidrawRef.current.updateScene(contents.data);
};
</s> remove const result = restore(
{
elements: clearElementsForExport(data.elements || []),
appState: {
theme: localAppState?.theme,
fileHandle: blob.handle || null,
...cleanAppStateForExport(data.appState || {}),
...(localAppState
? calculateScrollCenter(data.elements || [], localAppState, null)
: {}),
},
files: data.files,
},
localAppState,
localElements,
);
return result;
</s> add throw new Error(t("alerts.couldNotLoadInvalidFile"));
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/data/blob.ts
|
keep keep replace replace keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep
|
<mask> try {
<mask> const data = JSON.parse(contents);
<mask> if (!isValidExcalidrawData(data)) {
<mask> throw new Error(t("alerts.couldNotLoadInvalidFile"));
<mask> }
<mask> const result = restore(
<mask> {
<mask> elements: clearElementsForExport(data.elements || []),
<mask> appState: {
<mask> theme: localAppState?.theme,
<mask> fileHandle: blob.handle || null,
<mask> ...cleanAppStateForExport(data.appState || {}),
<mask> ...(localAppState
<mask> ? calculateScrollCenter(data.elements || [], localAppState, null)
<mask> : {}),
<mask> },
<mask> files: data.files,
<mask> },
<mask> localAppState,
<mask> localElements,
<mask> );
<mask>
<mask> return result;
<mask> } catch (error: any) {
</s> feat: make file handling more robust (#5057) </s> remove blob.handle = fileHandle;
loadFromBlob(
blob,
this.state,
this.scene.getElementsIncludingDeleted(),
)
.then((scene) => {
this.syncActionResult({
...scene,
appState: {
...(scene.appState || this.state),
isLoading: false,
},
commitToHistory: true,
});
})
.catch((error) => {
this.setState({ isLoading: false, errorMessage: error.message });
});
</s> add this.loadFileToCanvas(
new File([blob], blob.name || "", { type: blob.type }),
fileHandle,
); </s> remove const file = await webShareTargetCache.match("shared-file");
if (file) {
const blob = await file.blob();
this.loadFileToCanvas(blob);
</s> add const response = await webShareTargetCache.match("shared-file");
if (response) {
const blob = await response.blob();
const file = new File([blob], blob.name || "", { type: blob.type });
this.loadFileToCanvas(file, null); </s> remove if (nativeFileSystemSupported) {
try {
// This will only work as of Chrome 86,
// but can be safely ignored on older releases.
const item = event.dataTransfer.items[0];
(file as any).handle = await (
item as any
).getAsFileSystemHandle();
} catch (error: any) {
console.warn(error.name, error.message);
}
}
</s> add </s> remove loadFileToCanvas = (file: Blob) => {
loadFromBlob(file, this.state, this.scene.getElementsIncludingDeleted())
.then((scene) => {
</s> add loadFileToCanvas = async (
file: File,
fileHandle: FileSystemHandle | null,
) => {
file = await normalizeFile(file);
try {
const ret = await loadSceneOrLibraryFromBlob(
file,
this.state,
this.scene.getElementsIncludingDeleted(),
fileHandle,
);
if (ret.type === MIME_TYPES.excalidraw) {
this.setState({ isLoading: true }); </s> remove await file.arrayBuffer(),
</s> add await blobToArrayBuffer(file),
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/data/blob.ts
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> export const generateIdFromFile = async (file: File): Promise<FileId> => {
<mask> try {
<mask> const hashBuffer = await window.crypto.subtle.digest(
<mask> "SHA-1",
<mask> await file.arrayBuffer(),
<mask> );
<mask> return bytesToHexString(new Uint8Array(hashBuffer)) as FileId;
<mask> } catch (error: any) {
<mask> console.error(error);
<mask> // length 40 to align with the HEX length of SHA-1 (which is 160 bit)
</s> feat: make file handling more robust (#5057) </s> remove const file = event.dataTransfer?.files.item(0);
if (
file?.type === MIME_TYPES.excalidrawlib ||
file?.name?.endsWith(".excalidrawlib")
) {
this.setState({ isLibraryOpen: true });
this.library.importLibrary(file).catch((error) => {
console.error(error);
this.setState({
isLoading: false,
errorMessage: t("errors.importLibraryError"),
});
});
// default: assume an Excalidraw file regardless of extension/MimeType
} else if (file) {
this.setState({ isLoading: true });
if (nativeFileSystemSupported) {
try {
// This will only work as of Chrome 86,
// but can be safely ignored on older releases.
const item = event.dataTransfer.items[0];
(file as any).handle = await (item as any).getAsFileSystemHandle();
} catch (error: any) {
console.warn(error.name, error.message);
}
}
await this.loadFileToCanvas(file);
</s> add if (file) {
// atetmpt to parse an excalidraw/excalidrawlib file
await this.loadFileToCanvas(file, fileHandle); </s> remove if (nativeFileSystemSupported) {
try {
// This will only work as of Chrome 86,
// but can be safely ignored on older releases.
const item = event.dataTransfer.items[0];
(file as any).handle = await (
item as any
).getAsFileSystemHandle();
} catch (error: any) {
console.warn(error.name, error.message);
}
}
</s> add </s> remove const file = await webShareTargetCache.match("shared-file");
if (file) {
const blob = await file.blob();
this.loadFileToCanvas(blob);
</s> add const response = await webShareTargetCache.match("shared-file");
if (response) {
const blob = await response.blob();
const file = new File([blob], blob.name || "", { type: blob.type });
this.loadFileToCanvas(file, null); </s> remove const blobToArrayBuffer = (blob: Blob): Promise<ArrayBuffer> => {
if ("arrayBuffer" in blob) {
return blob.arrayBuffer();
}
// Safari
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = (event) => {
if (!event.target?.result) {
return reject(new Error("couldn't convert blob to ArrayBuffer"));
}
resolve(event.target.result as ArrayBuffer);
};
reader.readAsArrayBuffer(blob);
});
};
</s> add </s> remove try {
const file = event.dataTransfer.files.item(0);
</s> add // must be retrieved first, in the same frame
const { file, fileHandle } = await getFileFromEvent(event); </s> add try {
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/data/blob.ts
|
add keep keep keep keep
|
<mask> import { ENCRYPTION_KEY_BITS } from "../constants";
<mask>
<mask> export const IV_LENGTH_BYTES = 12;
<mask>
<mask> export const createIV = () => {
</s> feat: make file handling more robust (#5057) </s> add const loadSceneOrLibrary = async () => {
const file = await fileOpen({ description: "Excalidraw or library file" });
const contents = await loadSceneOrLibraryFromBlob(file, null, null);
excalidrawRef.current.updateScene(contents.data);
};
</s> remove import { FileSystemHandle } from "./filesystem";
</s> add import { FileSystemHandle, nativeFileSystemSupported } from "./filesystem"; </s> remove const file = await webShareTargetCache.match("shared-file");
if (file) {
const blob = await file.blob();
this.loadFileToCanvas(blob);
</s> add const response = await webShareTargetCache.match("shared-file");
if (response) {
const blob = await response.blob();
const file = new File([blob], blob.name || "", { type: blob.type });
this.loadFileToCanvas(file, null); </s> remove import { isImageFileHandle, loadFromBlob } from "./blob";
</s> add import { isImageFileHandle, loadFromBlob, normalizeFile } from "./blob"; </s> remove const blobToArrayBuffer = (blob: Blob): Promise<ArrayBuffer> => {
if ("arrayBuffer" in blob) {
return blob.arrayBuffer();
}
// Safari
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = (event) => {
if (!event.target?.result) {
return reject(new Error("couldn't convert blob to ArrayBuffer"));
}
resolve(event.target.result as ArrayBuffer);
};
reader.readAsArrayBuffer(blob);
});
};
</s> add </s> add import { blobToArrayBuffer } from "./blob";
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/data/encryption.ts
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> ? new TextEncoder().encode(data)
<mask> : data instanceof Uint8Array
<mask> ? data
<mask> : data instanceof Blob
<mask> ? await data.arrayBuffer()
<mask> : data;
<mask>
<mask> // We use symmetric encryption. AES-GCM is the recommended algorithm and
<mask> // includes checks that the ciphertext has not been modified by an attacker.
<mask> const encryptedBuffer = await window.crypto.subtle.encrypt(
</s> feat: make file handling more robust (#5057) </s> remove const result = restore(
{
elements: clearElementsForExport(data.elements || []),
appState: {
theme: localAppState?.theme,
fileHandle: blob.handle || null,
...cleanAppStateForExport(data.appState || {}),
...(localAppState
? calculateScrollCenter(data.elements || [], localAppState, null)
: {}),
},
files: data.files,
},
localAppState,
localElements,
);
return result;
</s> add throw new Error(t("alerts.couldNotLoadInvalidFile")); </s> remove if (!isValidExcalidrawData(data)) {
throw new Error(t("alerts.couldNotLoadInvalidFile"));
</s> add if (isValidExcalidrawData(data)) {
return {
type: MIME_TYPES.excalidraw,
data: restore(
{
elements: clearElementsForExport(data.elements || []),
appState: {
theme: localAppState?.theme,
fileHandle: fileHandle || blob.handle || null,
...cleanAppStateForExport(data.appState || {}),
...(localAppState
? calculateScrollCenter(
data.elements || [],
localAppState,
null,
)
: {}),
},
files: data.files,
},
localAppState,
localElements,
),
};
} else if (isValidLibrary(data)) {
return {
type: MIME_TYPES.excalidrawlib,
data,
}; </s> add import { fileOpen } from "../../../data/filesystem";
import { loadSceneOrLibraryFromBlob } from "../../utils"; </s> add type ValueOf<T> = T[keyof T];
</s> remove await file.arrayBuffer(),
</s> add await blobToArrayBuffer(file), </s> remove try {
const file = event.dataTransfer.files.item(0);
</s> add // must be retrieved first, in the same frame
const { file, fileHandle } = await getFileFromEvent(event);
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/data/encryption.ts
|
keep keep keep add keep keep keep keep keep
|
<mask> import tEXt from "png-chunk-text";
<mask> import encodePng from "png-chunks-encode";
<mask> import { stringToBase64, encode, decode, base64ToString } from "./encode";
<mask> import { EXPORT_DATA_TYPES, MIME_TYPES } from "../constants";
<mask>
<mask> // -----------------------------------------------------------------------------
<mask> // PNG
<mask> // -----------------------------------------------------------------------------
<mask>
</s> feat: make file handling more robust (#5057) </s> remove import { isImageFileHandle, loadFromBlob } from "./blob";
</s> add import { isImageFileHandle, loadFromBlob, normalizeFile } from "./blob"; </s> add import { fileOpen } from "../../../data/filesystem";
import { loadSceneOrLibraryFromBlob } from "../../utils"; </s> remove import { FileSystemHandle } from "./filesystem";
</s> add import { FileSystemHandle, nativeFileSystemSupported } from "./filesystem"; </s> add import { blobToArrayBuffer } from "./blob"; </s> remove import { fileOpen, nativeFileSystemSupported } from "../data/filesystem";
</s> add import { fileOpen, FileSystemHandle } from "../data/filesystem"; </s> remove const blobToArrayBuffer = (blob: Blob): Promise<ArrayBuffer> => {
if ("arrayBuffer" in blob) {
return blob.arrayBuffer();
}
// Safari
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = (event) => {
if (!event.target?.result) {
return reject(new Error("couldn't convert blob to ArrayBuffer"));
}
resolve(event.target.result as ArrayBuffer);
};
reader.readAsArrayBuffer(blob);
});
};
</s> add
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/data/image.ts
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> // -----------------------------------------------------------------------------
<mask> // PNG
<mask> // -----------------------------------------------------------------------------
<mask>
<mask> const blobToArrayBuffer = (blob: Blob): Promise<ArrayBuffer> => {
<mask> if ("arrayBuffer" in blob) {
<mask> return blob.arrayBuffer();
<mask> }
<mask> // Safari
<mask> return new Promise((resolve, reject) => {
<mask> const reader = new FileReader();
<mask> reader.onload = (event) => {
<mask> if (!event.target?.result) {
<mask> return reject(new Error("couldn't convert blob to ArrayBuffer"));
<mask> }
<mask> resolve(event.target.result as ArrayBuffer);
<mask> };
<mask> reader.readAsArrayBuffer(blob);
<mask> });
<mask> };
<mask>
<mask> export const getTEXtChunk = async (
<mask> blob: Blob,
<mask> ): Promise<{ keyword: string; text: string } | null> => {
<mask> const chunks = decodePng(new Uint8Array(await blobToArrayBuffer(blob)));
<mask> const metadataChunk = chunks.find((chunk) => chunk.name === "tEXt");
</s> feat: make file handling more robust (#5057) </s> remove try {
const file = event.dataTransfer.files.item(0);
</s> add // must be retrieved first, in the same frame
const { file, fileHandle } = await getFileFromEvent(event); </s> remove const file = await webShareTargetCache.match("shared-file");
if (file) {
const blob = await file.blob();
this.loadFileToCanvas(blob);
</s> add const response = await webShareTargetCache.match("shared-file");
if (response) {
const blob = await response.blob();
const file = new File([blob], blob.name || "", { type: blob.type });
this.loadFileToCanvas(file, null); </s> remove await file.arrayBuffer(),
</s> add await blobToArrayBuffer(file), </s> remove export const loadFromBlob = async (
blob: Blob,
</s> add export const loadSceneOrLibraryFromBlob = async (
blob: Blob | File, </s> remove const file = event.dataTransfer?.files.item(0);
if (
file?.type === MIME_TYPES.excalidrawlib ||
file?.name?.endsWith(".excalidrawlib")
) {
this.setState({ isLibraryOpen: true });
this.library.importLibrary(file).catch((error) => {
console.error(error);
this.setState({
isLoading: false,
errorMessage: t("errors.importLibraryError"),
});
});
// default: assume an Excalidraw file regardless of extension/MimeType
} else if (file) {
this.setState({ isLoading: true });
if (nativeFileSystemSupported) {
try {
// This will only work as of Chrome 86,
// but can be safely ignored on older releases.
const item = event.dataTransfer.items[0];
(file as any).handle = await (item as any).getAsFileSystemHandle();
} catch (error: any) {
console.warn(error.name, error.message);
}
}
await this.loadFileToCanvas(file);
</s> add if (file) {
// atetmpt to parse an excalidraw/excalidrawlib file
await this.loadFileToCanvas(file, fileHandle); </s> add try {
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/data/image.ts
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> } from "../constants";
<mask> import { clearElementsForDatabase, clearElementsForExport } from "../element";
<mask> import { ExcalidrawElement } from "../element/types";
<mask> import { AppState, BinaryFiles, LibraryItems } from "../types";
<mask> import { isImageFileHandle, loadFromBlob } from "./blob";
<mask>
<mask> import {
<mask> ExportedDataState,
<mask> ImportedDataState,
<mask> ExportedLibraryData,
</s> feat: make file handling more robust (#5057) </s> remove import { FileSystemHandle } from "./filesystem";
</s> add import { FileSystemHandle, nativeFileSystemSupported } from "./filesystem"; </s> add import { blobToArrayBuffer } from "./blob"; </s> add import { blobToArrayBuffer } from "./blob"; </s> remove import { fileOpen, nativeFileSystemSupported } from "../data/filesystem";
</s> add import { fileOpen, FileSystemHandle } from "../data/filesystem"; </s> add import { fileOpen } from "../../../data/filesystem";
import { loadSceneOrLibraryFromBlob } from "../../utils"; </s> remove export { loadFromBlob, loadLibraryFromBlob } from "../data/blob";
</s> add export {
loadFromBlob,
loadSceneOrLibraryFromBlob,
loadLibraryFromBlob,
} from "../data/blob";
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/data/json.ts
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> export const loadFromJSON = async (
<mask> localAppState: AppState,
<mask> localElements: readonly ExcalidrawElement[] | null,
<mask> ) => {
<mask> const blob = await fileOpen({
<mask> description: "Excalidraw files",
<mask> // ToDo: Be over-permissive until https://bugs.webkit.org/show_bug.cgi?id=34442
<mask> // gets resolved. Else, iOS users cannot open `.excalidraw` files.
<mask> // extensions: ["json", "excalidraw", "png", "svg"],
<mask> });
</s> feat: make file handling more robust (#5057) </s> remove return loadFromBlob(blob, localAppState, localElements);
</s> add return loadFromBlob(await normalizeFile(file), localAppState, localElements); </s> remove export const loadFromBlob = async (
blob: Blob,
</s> add export const loadSceneOrLibraryFromBlob = async (
blob: Blob | File, </s> add /** FileSystemHandle. Defaults to `blob.handle` if defined, otherwise null. */
fileHandle?: FileSystemHandle | null, </s> add const loadSceneOrLibrary = async () => {
const file = await fileOpen({ description: "Excalidraw or library file" });
const contents = await loadSceneOrLibraryFromBlob(file, null, null);
excalidrawRef.current.updateScene(contents.data);
};
</s> remove const blobToArrayBuffer = (blob: Blob): Promise<ArrayBuffer> => {
if ("arrayBuffer" in blob) {
return blob.arrayBuffer();
}
// Safari
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = (event) => {
if (!event.target?.result) {
return reject(new Error("couldn't convert blob to ArrayBuffer"));
}
resolve(event.target.result as ArrayBuffer);
};
reader.readAsArrayBuffer(blob);
});
};
</s> add </s> remove const file = await webShareTargetCache.match("shared-file");
if (file) {
const blob = await file.blob();
this.loadFileToCanvas(blob);
</s> add const response = await webShareTargetCache.match("shared-file");
if (response) {
const blob = await response.blob();
const file = new File([blob], blob.name || "", { type: blob.type });
this.loadFileToCanvas(file, null);
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/data/json.ts
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> // ToDo: Be over-permissive until https://bugs.webkit.org/show_bug.cgi?id=34442
<mask> // gets resolved. Else, iOS users cannot open `.excalidraw` files.
<mask> // extensions: ["json", "excalidraw", "png", "svg"],
<mask> });
<mask> return loadFromBlob(blob, localAppState, localElements);
<mask> };
<mask>
<mask> export const isValidExcalidrawData = (data?: {
<mask> type?: any;
<mask> elements?: any;
</s> feat: make file handling more robust (#5057) </s> remove const blob = await fileOpen({
</s> add const file = await fileOpen({ </s> remove const blobToArrayBuffer = (blob: Blob): Promise<ArrayBuffer> => {
if ("arrayBuffer" in blob) {
return blob.arrayBuffer();
}
// Safari
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = (event) => {
if (!event.target?.result) {
return reject(new Error("couldn't convert blob to ArrayBuffer"));
}
resolve(event.target.result as ArrayBuffer);
};
reader.readAsArrayBuffer(blob);
});
};
</s> add </s> remove if (!isValidExcalidrawData(data)) {
throw new Error(t("alerts.couldNotLoadInvalidFile"));
</s> add if (isValidExcalidrawData(data)) {
return {
type: MIME_TYPES.excalidraw,
data: restore(
{
elements: clearElementsForExport(data.elements || []),
appState: {
theme: localAppState?.theme,
fileHandle: fileHandle || blob.handle || null,
...cleanAppStateForExport(data.appState || {}),
...(localAppState
? calculateScrollCenter(
data.elements || [],
localAppState,
null,
)
: {}),
},
files: data.files,
},
localAppState,
localElements,
),
};
} else if (isValidLibrary(data)) {
return {
type: MIME_TYPES.excalidrawlib,
data,
}; </s> remove await file.arrayBuffer(),
</s> add await blobToArrayBuffer(file), </s> remove const result = restore(
{
elements: clearElementsForExport(data.elements || []),
appState: {
theme: localAppState?.theme,
fileHandle: blob.handle || null,
...cleanAppStateForExport(data.appState || {}),
...(localAppState
? calculateScrollCenter(data.elements || [], localAppState, null)
: {}),
},
files: data.files,
},
localAppState,
localElements,
);
return result;
</s> add throw new Error(t("alerts.couldNotLoadInvalidFile")); </s> remove const file = event.dataTransfer?.files.item(0);
if (
file?.type === MIME_TYPES.excalidrawlib ||
file?.name?.endsWith(".excalidrawlib")
) {
this.setState({ isLibraryOpen: true });
this.library.importLibrary(file).catch((error) => {
console.error(error);
this.setState({
isLoading: false,
errorMessage: t("errors.importLibraryError"),
});
});
// default: assume an Excalidraw file regardless of extension/MimeType
} else if (file) {
this.setState({ isLoading: true });
if (nativeFileSystemSupported) {
try {
// This will only work as of Chrome 86,
// but can be safely ignored on older releases.
const item = event.dataTransfer.items[0];
(file as any).handle = await (item as any).getAsFileSystemHandle();
} catch (error: any) {
console.warn(error.name, error.message);
}
}
await this.loadFileToCanvas(file);
</s> add if (file) {
// atetmpt to parse an excalidraw/excalidrawlib file
await this.loadFileToCanvas(file, fileHandle);
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/data/json.ts
|
keep add keep keep keep keep keep
|
<mask> };
<mask>
<mask> type Merge<M, N> = Omit<M, keyof N> & N;
<mask>
<mask> /** utility type to assert that the second type is a subtype of the first type.
<mask> * Returns the subtype. */
<mask> type SubtypeOf<Supertype, Subtype extends Supertype> = Subtype;
</s> feat: make file handling more robust (#5057) </s> add export { MIME_TYPES };
</s> add import { fileOpen } from "../../../data/filesystem";
import { loadSceneOrLibraryFromBlob } from "../../utils"; </s> remove try {
const file = event.dataTransfer.files.item(0);
</s> add // must be retrieved first, in the same frame
const { file, fileHandle } = await getFileFromEvent(event); </s> remove ? await data.arrayBuffer()
</s> add ? await blobToArrayBuffer(data) </s> add try { </s> remove await file.arrayBuffer(),
</s> add await blobToArrayBuffer(file),
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/global.d.ts
|
keep keep add keep keep keep keep keep keep
|
<mask>
<mask> import "./App.scss";
<mask> import initialData from "./initialData";
<mask>
<mask> // This is so that we use the bundled excalidraw.development.js file instead
<mask> // of the actual source code
<mask>
<mask> const {
<mask> exportToCanvas,
</s> feat: make file handling more robust (#5057) </s> remove ? await data.arrayBuffer()
</s> add ? await blobToArrayBuffer(data) </s> add type ValueOf<T> = T[keyof T];
</s> add import { blobToArrayBuffer } from "./blob"; </s> remove try {
const file = event.dataTransfer.files.item(0);
</s> add // must be retrieved first, in the same frame
const { file, fileHandle } = await getFileFromEvent(event); </s> remove await file.arrayBuffer(),
</s> add await blobToArrayBuffer(file), </s> remove import { FileSystemHandle } from "./filesystem";
</s> add import { FileSystemHandle, nativeFileSystemSupported } from "./filesystem";
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/packages/excalidraw/example/App.js
|
keep keep add keep keep keep keep keep
|
<mask> };
<mask> }, []);
<mask>
<mask> const updateScene = () => {
<mask> const sceneData = {
<mask> elements: [
<mask> {
<mask> type: "rectangle",
</s> feat: make file handling more robust (#5057) </s> remove if (!isValidExcalidrawData(data)) {
throw new Error(t("alerts.couldNotLoadInvalidFile"));
</s> add if (isValidExcalidrawData(data)) {
return {
type: MIME_TYPES.excalidraw,
data: restore(
{
elements: clearElementsForExport(data.elements || []),
appState: {
theme: localAppState?.theme,
fileHandle: fileHandle || blob.handle || null,
...cleanAppStateForExport(data.appState || {}),
...(localAppState
? calculateScrollCenter(
data.elements || [],
localAppState,
null,
)
: {}),
},
files: data.files,
},
localAppState,
localElements,
),
};
} else if (isValidLibrary(data)) {
return {
type: MIME_TYPES.excalidrawlib,
data,
}; </s> remove const file = await webShareTargetCache.match("shared-file");
if (file) {
const blob = await file.blob();
this.loadFileToCanvas(blob);
</s> add const response = await webShareTargetCache.match("shared-file");
if (response) {
const blob = await response.blob();
const file = new File([blob], blob.name || "", { type: blob.type });
this.loadFileToCanvas(file, null); </s> add import { blobToArrayBuffer } from "./blob"; </s> remove blob.handle = fileHandle;
loadFromBlob(
blob,
this.state,
this.scene.getElementsIncludingDeleted(),
)
.then((scene) => {
this.syncActionResult({
...scene,
appState: {
...(scene.appState || this.state),
isLoading: false,
},
commitToHistory: true,
});
})
.catch((error) => {
this.setState({ isLoading: false, errorMessage: error.message });
});
</s> add this.loadFileToCanvas(
new File([blob], blob.name || "", { type: blob.type }),
fileHandle,
); </s> remove const result = restore(
{
elements: clearElementsForExport(data.elements || []),
appState: {
theme: localAppState?.theme,
fileHandle: blob.handle || null,
...cleanAppStateForExport(data.appState || {}),
...(localAppState
? calculateScrollCenter(data.elements || [], localAppState, null)
: {}),
},
files: data.files,
},
localAppState,
localElements,
);
return result;
</s> add throw new Error(t("alerts.couldNotLoadInvalidFile")); </s> remove const blobToArrayBuffer = (blob: Blob): Promise<ArrayBuffer> => {
if ("arrayBuffer" in blob) {
return blob.arrayBuffer();
}
// Safari
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = (event) => {
if (!event.target?.result) {
return reject(new Error("couldn't convert blob to ArrayBuffer"));
}
resolve(event.target.result as ArrayBuffer);
};
reader.readAsArrayBuffer(blob);
});
};
</s> add
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/packages/excalidraw/example/App.js
|
keep keep add keep keep keep keep keep
|
<mask> <h1> Excalidraw Example</h1>
<mask> <Sidebar>
<mask> <div className="button-wrapper">
<mask> <button className="update-scene" onClick={updateScene}>
<mask> Update Scene
<mask> </button>
<mask> <button
<mask> className="reset-scene"
</s> feat: make file handling more robust (#5057) </s> remove const file = event.dataTransfer?.files.item(0);
if (
file?.type === MIME_TYPES.excalidrawlib ||
file?.name?.endsWith(".excalidrawlib")
) {
this.setState({ isLibraryOpen: true });
this.library.importLibrary(file).catch((error) => {
console.error(error);
this.setState({
isLoading: false,
errorMessage: t("errors.importLibraryError"),
});
});
// default: assume an Excalidraw file regardless of extension/MimeType
} else if (file) {
this.setState({ isLoading: true });
if (nativeFileSystemSupported) {
try {
// This will only work as of Chrome 86,
// but can be safely ignored on older releases.
const item = event.dataTransfer.items[0];
(file as any).handle = await (item as any).getAsFileSystemHandle();
} catch (error: any) {
console.warn(error.name, error.message);
}
}
await this.loadFileToCanvas(file);
</s> add if (file) {
// atetmpt to parse an excalidraw/excalidrawlib file
await this.loadFileToCanvas(file, fileHandle); </s> remove export { loadFromBlob, loadLibraryFromBlob } from "../data/blob";
</s> add export {
loadFromBlob,
loadSceneOrLibraryFromBlob,
loadLibraryFromBlob,
} from "../data/blob"; </s> remove if (nativeFileSystemSupported) {
try {
// This will only work as of Chrome 86,
// but can be safely ignored on older releases.
const item = event.dataTransfer.items[0];
(file as any).handle = await (
item as any
).getAsFileSystemHandle();
} catch (error: any) {
console.warn(error.name, error.message);
}
}
</s> add </s> remove })
.catch((error) => {
this.setState({ isLoading: false, errorMessage: error.message });
});
</s> add } else if (ret.type === MIME_TYPES.excalidrawlib) {
this.library
.importLibrary(file)
.then(() => {
this.setState({
isLoading: false,
});
})
.catch((error) => {
console.error(error);
this.setState({
isLoading: false,
errorMessage: t("errors.importLibraryError"),
});
});
}
} catch (error: any) {
this.setState({ isLoading: false, errorMessage: error.message });
} </s> remove ...(scene.appState || this.state),
</s> add ...(ret.data.appState || this.state), </s> remove ...scene,
</s> add ...ret.data,
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/packages/excalidraw/example/App.js
|
keep add keep keep keep keep keep keep
|
<mask> loadLibraryFromBlob,
<mask> loadFromBlob,
<mask> getFreeDrawSvgPath,
<mask> exportToClipboard,
<mask> mergeLibraryItems,
<mask> } from "../../packages/utils";
<mask> export { isLinearElement } from "../../element/typeChecks";
<mask>
</s> feat: make file handling more robust (#5057) </s> remove export { loadFromBlob, loadLibraryFromBlob } from "../data/blob";
</s> add export {
loadFromBlob,
loadSceneOrLibraryFromBlob,
loadLibraryFromBlob,
} from "../data/blob"; </s> remove import { isImageFileHandle, loadFromBlob } from "./blob";
</s> add import { isImageFileHandle, loadFromBlob, normalizeFile } from "./blob"; </s> add import { blobToArrayBuffer } from "./blob"; </s> add loadSceneOrLibraryFromBlob,
normalizeFile, </s> remove import { FileSystemHandle } from "./filesystem";
</s> add import { FileSystemHandle, nativeFileSystemSupported } from "./filesystem"; </s> remove import { fileOpen, nativeFileSystemSupported } from "../data/filesystem";
</s> add import { fileOpen, FileSystemHandle } from "../data/filesystem";
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/packages/excalidraw/index.tsx
|
keep keep keep add keep keep keep keep keep keep
|
<mask> copyTextToSystemClipboard,
<mask> copyToClipboard,
<mask> } from "../clipboard";
<mask>
<mask> type ExportOpts = {
<mask> elements: readonly NonDeleted<ExcalidrawElement>[];
<mask> appState?: Partial<Omit<AppState, "offsetTop" | "offsetLeft">>;
<mask> files: BinaryFiles | null;
<mask> maxWidthOrHeight?: number;
<mask> getDimensions?: (
</s> feat: make file handling more robust (#5057) </s> remove export const loadFromBlob = async (
blob: Blob,
</s> add export const loadSceneOrLibraryFromBlob = async (
blob: Blob | File, </s> add /** FileSystemHandle. Defaults to `blob.handle` if defined, otherwise null. */
fileHandle?: FileSystemHandle | null, </s> remove const blob = await fileOpen({
</s> add const file = await fileOpen({ </s> remove if (!isValidExcalidrawData(data)) {
throw new Error(t("alerts.couldNotLoadInvalidFile"));
</s> add if (isValidExcalidrawData(data)) {
return {
type: MIME_TYPES.excalidraw,
data: restore(
{
elements: clearElementsForExport(data.elements || []),
appState: {
theme: localAppState?.theme,
fileHandle: fileHandle || blob.handle || null,
...cleanAppStateForExport(data.appState || {}),
...(localAppState
? calculateScrollCenter(
data.elements || [],
localAppState,
null,
)
: {}),
},
files: data.files,
},
localAppState,
localElements,
),
};
} else if (isValidLibrary(data)) {
return {
type: MIME_TYPES.excalidrawlib,
data,
}; </s> remove import { FileSystemHandle } from "./filesystem";
</s> add import { FileSystemHandle, nativeFileSystemSupported } from "./filesystem"; </s> remove const result = restore(
{
elements: clearElementsForExport(data.elements || []),
appState: {
theme: localAppState?.theme,
fileHandle: blob.handle || null,
...cleanAppStateForExport(data.appState || {}),
...(localAppState
? calculateScrollCenter(data.elements || [], localAppState, null)
: {}),
},
files: data.files,
},
localAppState,
localElements,
);
return result;
</s> add throw new Error(t("alerts.couldNotLoadInvalidFile"));
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/packages/utils.ts
|
keep keep keep keep replace keep keep
|
<mask> }
<mask> };
<mask>
<mask> export { serializeAsJSON, serializeLibraryAsJSON } from "../data/json";
<mask> export { loadFromBlob, loadLibraryFromBlob } from "../data/blob";
<mask> export { getFreeDrawSvgPath } from "../renderer/renderElement";
<mask> export { mergeLibraryItems } from "../data/library";
</s> feat: make file handling more robust (#5057) </s> add loadSceneOrLibraryFromBlob, </s> add import { blobToArrayBuffer } from "./blob"; </s> remove import { isImageFileHandle, loadFromBlob } from "./blob";
</s> add import { isImageFileHandle, loadFromBlob, normalizeFile } from "./blob"; </s> remove import { FileSystemHandle } from "./filesystem";
</s> add import { FileSystemHandle, nativeFileSystemSupported } from "./filesystem"; </s> add export { MIME_TYPES };
</s> remove import { fileOpen, nativeFileSystemSupported } from "../data/filesystem";
</s> add import { fileOpen, FileSystemHandle } from "../data/filesystem";
|
https://github.com/excalidraw/excalidraw/commit/d2e687ed0a0d3f9eb0efdd8a3ea1d093f2f641a6
|
src/packages/utils.ts
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> import React from "react";
<mask> import { undo, redo } from "../components/icons";
<mask> import { ToolButton } from "../components/ToolButton";
<mask> import { t } from "../i18n";
<mask> import { SceneHistory, HistoryEntry } from "../history";
<mask> import { ExcalidrawElement } from "../element/types";
<mask> import { AppState } from "../types";
<mask> import { isWindows, KEYS } from "../keys";
<mask> import { getElementMap } from "../element";
<mask> import { newElementWith } from "../element/mutateElement";
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove import { createHistory, SceneHistory } from "../history";
</s> add import History from "../history"; </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording();
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/actions/actionHistory.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> }
<mask> return { commitToHistory };
<mask> };
<mask>
<mask> type ActionCreator = (history: SceneHistory) => Action;
<mask>
<mask> export const createUndoAction: ActionCreator = (history) => ({
<mask> name: "undo",
<mask> perform: (elements, appState) =>
<mask> writeData(elements, appState, () => history.undoOnce()),
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove history.clear();
</s> add this.history.clear(); </s> remove const { history } = createHistory();
</s> add </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove
</s> add this.history = new History(); </s> remove history,
</s> add this.history, </s> remove h.history.clear();
</s> add
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/actions/actionHistory.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> isElementInGroup,
<mask> isSelectedViaGroup,
<mask> selectGroupsForSelectedElements,
<mask> } from "../groups";
<mask> import { createHistory, SceneHistory } from "../history";
<mask> import { defaultLang, getLanguage, languages, setLanguage, t } from "../i18n";
<mask> import {
<mask> CODES,
<mask> getResizeCenterPointKey,
<mask> getResizeWithSidesSameLengthKey,
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove import { SceneHistory, HistoryEntry } from "../history";
</s> add import History, { HistoryEntry } from "../history"; </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording();
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep keep keep replace replace keep keep keep keep keep
|
<mask> );
<mask> export const useExcalidrawContainer = () =>
<mask> useContext(ExcalidrawContainerContext);
<mask>
<mask> const { history } = createHistory();
<mask>
<mask> let didTapTwice: boolean = false;
<mask> let tappedTwiceTimer = 0;
<mask> let cursorX = 0;
<mask> let cursorY = 0;
<mask> let isHoldingSpace: boolean = false;
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove type ActionCreator = (history: SceneHistory) => Action;
</s> add type ActionCreator = (history: History) => Action; </s> remove history,
</s> add this.history, </s> remove this.actionManager.registerAction(createUndoAction(history));
this.actionManager.registerAction(createRedoAction(history));
</s> add this.actionManager.registerAction(createUndoAction(this.history));
this.actionManager.registerAction(createRedoAction(this.history)); </s> remove
</s> add this.history = new History(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording();
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep add keep keep keep keep
|
<mask> public libraryItemsFromStorage: LibraryItems | undefined;
<mask> private id: string;
<mask>
<mask> constructor(props: AppProps) {
<mask> super(props);
<mask> const defaultAppState = getDefaultAppState();
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove this.actionManager.registerAction(createUndoAction(history));
this.actionManager.registerAction(createRedoAction(history));
</s> add this.actionManager.registerAction(createUndoAction(this.history));
this.actionManager.registerAction(createRedoAction(this.history)); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove const { history } = createHistory();
</s> add </s> remove history.clear();
</s> add this.history.clear(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history,
</s> add this.history,
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> readyPromise.resolve(api);
<mask> }
<mask> this.scene = new Scene();
<mask> this.library = new Library(this);
<mask>
<mask> this.actionManager = new ActionManager(
<mask> this.syncActionResult,
<mask> () => this.state,
<mask> () => this.scene.getElementsIncludingDeleted(),
<mask> this,
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove history.setCurrentState(
</s> add this.history.setCurrentState( </s> remove type ActionCreator = (history: SceneHistory) => Action;
</s> add type ActionCreator = (history: History) => Action; </s> remove const { history } = createHistory();
</s> add </s> remove history,
</s> add this.history, </s> remove history.clear();
</s> add this.history.clear(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording();
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep keep keep replace replace keep keep keep keep keep
|
<mask> this,
<mask> );
<mask> this.actionManager.registerAll(actions);
<mask>
<mask> this.actionManager.registerAction(createUndoAction(history));
<mask> this.actionManager.registerAction(createRedoAction(history));
<mask> }
<mask>
<mask> private renderCanvas() {
<mask> const canvasScale = window.devicePixelRatio;
<mask> const {
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> add private history: History; </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove const { history } = createHistory();
</s> add </s> remove history,
</s> add this.history, </s> remove type ActionCreator = (history: SceneHistory) => Action;
</s> add type ActionCreator = (history: History) => Action; </s> remove history.clear();
</s> add this.history.clear();
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> }
<mask> });
<mask> this.scene.replaceAllElements(actionResult.elements);
<mask> if (actionResult.commitToHistory) {
<mask> history.resumeRecording();
<mask> }
<mask> }
<mask>
<mask> if (actionResult.appState || editingElement) {
<mask> if (actionResult.commitToHistory) {
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.setCurrentState(
</s> add this.history.setCurrentState( </s> remove history.resumeRecording();
</s> add this.history.resumeRecording();
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> }
<mask>
<mask> if (actionResult.appState || editingElement) {
<mask> if (actionResult.commitToHistory) {
<mask> history.resumeRecording();
<mask> }
<mask>
<mask> let viewModeEnabled = actionResult?.appState?.viewModeEnabled || false;
<mask> let zenModeEnabled = actionResult?.appState?.zenModeEnabled || false;
<mask> let gridSize = actionResult?.appState?.gridSize || null;
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove const { history } = createHistory();
</s> add </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording();
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> });
<mask> },
<mask> () => {
<mask> if (actionResult.syncHistory) {
<mask> history.setCurrentState(
<mask> this.state,
<mask> this.scene.getElementsIncludingDeleted(),
<mask> );
<mask> }
<mask> },
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove
</s> add this.history = new History(); </s> remove history,
</s> add this.history, </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove h.history.clear();
</s> add </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording();
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> }
<mask> };
<mask>
<mask> private resetHistory = () => {
<mask> history.clear();
<mask> };
<mask>
<mask> /**
<mask> * Resets scene & history.
<mask> * ! Do not use to clear scene user action !
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove type ActionCreator = (history: SceneHistory) => Action;
</s> add type ActionCreator = (history: History) => Action; </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove
</s> add this.history = new History(); </s> remove this.actionManager.registerAction(createUndoAction(history));
this.actionManager.registerAction(createRedoAction(history));
</s> add this.actionManager.registerAction(createUndoAction(this.history));
this.actionManager.registerAction(createRedoAction(this.history)); </s> add private history: History; </s> remove const { history } = createHistory();
</s> add
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep add keep keep keep keep keep
|
<mask> configurable: true,
<mask> value: this,
<mask> },
<mask> });
<mask> }
<mask>
<mask> this.scene.addCallback(this.onSceneUpdated);
<mask> this.addEventListeners();
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove history.setCurrentState(
</s> add this.history.setCurrentState( </s> remove this.actionManager.registerAction(createUndoAction(history));
this.actionManager.registerAction(createRedoAction(history));
</s> add this.actionManager.registerAction(createUndoAction(this.history));
this.actionManager.registerAction(createRedoAction(this.history)); </s> remove
</s> add this.history = new History(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove h.history.clear();
</s> add
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> if (this.state.scrolledOutside !== scrolledOutside) {
<mask> this.setState({ scrolledOutside });
<mask> }
<mask>
<mask> history.record(this.state, this.scene.getElementsIncludingDeleted());
<mask>
<mask> // Do not notify consumers if we're still loading the scene. Among other
<mask> // potential issues, this fixes a case where the tab isn't focused during
<mask> // init, which would trigger onChange with empty elements, which would then
<mask> // override whatever is in localStorage currently.
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.clear();
</s> add this.history.clear(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording();
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> oldIdToDuplicatedId,
<mask> );
<mask>
<mask> this.scene.replaceAllElements(nextElements);
<mask> history.resumeRecording();
<mask> this.setState(
<mask> selectGroupsForSelectedElements(
<mask> {
<mask> ...this.state,
<mask> isLibraryOpen: false,
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.setCurrentState(
</s> add this.history.setCurrentState( </s> remove this.actionManager.registerAction(createUndoAction(history));
this.actionManager.registerAction(createRedoAction(history));
</s> add this.actionManager.registerAction(createUndoAction(this.history));
this.actionManager.registerAction(createRedoAction(this.history)); </s> remove history,
</s> add this.history, </s> remove history.resumeRecording();
</s> add this.history.resumeRecording();
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> ...this.scene.getElementsIncludingDeleted(),
<mask> element,
<mask> ]);
<mask> this.setState({ selectedElementIds: { [element.id]: true } });
<mask> history.resumeRecording();
<mask> }
<mask>
<mask> // Collaboration
<mask>
<mask> setAppState = (obj: any) => {
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.record(this.state, this.scene.getElementsIncludingDeleted());
</s> add this.history.record(this.state, this.scene.getElementsIncludingDeleted()); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.setCurrentState(
</s> add this.history.setCurrentState( </s> remove history.resumeRecording();
</s> add this.history.resumeRecording();
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> };
<mask>
<mask> public updateScene = withBatchedUpdates((sceneData: SceneData) => {
<mask> if (sceneData.commitToHistory) {
<mask> history.resumeRecording();
<mask> }
<mask>
<mask> // currently we only support syncing background color
<mask> if (sceneData.appState?.viewBackgroundColor) {
<mask> this.setState({
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.record(this.state, this.scene.getElementsIncludingDeleted());
</s> add this.history.record(this.state, this.scene.getElementsIncludingDeleted()); </s> remove type ActionCreator = (history: SceneHistory) => Action;
</s> add type ActionCreator = (history: History) => Action; </s> remove history.resumeRecording();
</s> add this.history.resumeRecording();
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> if (
<mask> !this.state.editingLinearElement ||
<mask> this.state.editingLinearElement.elementId !== selectedElements[0].id
<mask> ) {
<mask> history.resumeRecording();
<mask> this.setState({
<mask> editingLinearElement: new LinearElementEditor(
<mask> selectedElements[0],
<mask> this.scene,
<mask> ),
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.record(this.state, this.scene.getElementsIncludingDeleted());
</s> add this.history.record(this.state, this.scene.getElementsIncludingDeleted());
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> } else {
<mask> fixBindingsAfterDeletion(this.scene.getElements(), [element]);
<mask> }
<mask> if (!isDeleted || isExistingElement) {
<mask> history.resumeRecording();
<mask> }
<mask>
<mask> this.setState({
<mask> draggingElement: null,
<mask> editingElement: null,
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording();
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> if (
<mask> !this.state.editingLinearElement ||
<mask> this.state.editingLinearElement.elementId !== selectedElements[0].id
<mask> ) {
<mask> history.resumeRecording();
<mask> this.setState({
<mask> editingLinearElement: new LinearElementEditor(
<mask> selectedElements[0],
<mask> this.scene,
<mask> ),
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> const ret = LinearElementEditor.handlePointerDown(
<mask> event,
<mask> this.state,
<mask> (appState) => this.setState(appState),
<mask> history,
<mask> pointerDownState.origin,
<mask> );
<mask> if (ret.hitElement) {
<mask> pointerDownState.hit.element = ret.hitElement;
<mask> }
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove const { history } = createHistory();
</s> add </s> remove history.setCurrentState(
</s> add this.history.setCurrentState( </s> remove this.actionManager.registerAction(createUndoAction(history));
this.actionManager.registerAction(createRedoAction(history));
</s> add this.actionManager.registerAction(createUndoAction(this.history));
this.actionManager.registerAction(createRedoAction(this.history)); </s> remove
</s> add this.history = new History(); </s> remove type ActionCreator = (history: SceneHistory) => Action;
</s> add type ActionCreator = (history: History) => Action;
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> }
<mask>
<mask> if (isLinearElement(draggingElement)) {
<mask> if (draggingElement!.points.length > 1) {
<mask> history.resumeRecording();
<mask> }
<mask> const pointerCoords = viewportCoordsToSceneCoords(
<mask> childEvent,
<mask> this.state,
<mask> );
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove history,
</s> add this.history, </s> remove history.setCurrentState(
</s> add this.history.setCurrentState( </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove this.actionManager.registerAction(createUndoAction(history));
this.actionManager.registerAction(createRedoAction(history));
</s> add this.actionManager.registerAction(createUndoAction(this.history));
this.actionManager.registerAction(createRedoAction(this.history)); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording();
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> );
<mask> }
<mask>
<mask> if (resizingElement) {
<mask> history.resumeRecording();
<mask> }
<mask>
<mask> if (resizingElement && isInvisiblySmallElement(resizingElement)) {
<mask> this.scene.replaceAllElements(
<mask> this.scene
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.setCurrentState(
</s> add this.history.setCurrentState( </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording(); </s> remove history.resumeRecording();
</s> add this.history.resumeRecording();
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/components/App.tsx
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
<mask> "selectedElementIds": Object {},
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [
<mask> Object {
<mask> "angle": 0,
<mask> "backgroundColor": "transparent",
<mask> "boundElementIds": null,
<mask> "fillStyle": "hachure",
<mask> "groupIds": Array [],
<mask> "height": 0,
<mask> "id": "id0",
<mask> "isDeleted": false,
<mask> "opacity": 100,
<mask> "roughness": 1,
<mask> "seed": 449462985,
<mask> "strokeColor": "#000000",
<mask> "strokeSharpness": "sharp",
<mask> "strokeStyle": "solid",
<mask> "strokeWidth": 1,
<mask> "type": "rectangle",
<mask> "version": 1,
<mask> "versionNonce": 0,
<mask> "width": 0,
<mask> "x": -10,
<mask> "y": 0,
<mask> },
<mask> ],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 449462985,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 449462985,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/tests/__snapshots__/contextmenu.test.tsx.snap
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
<mask> "selectedElementIds": Object {},
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [
<mask> Object {
<mask> "angle": 0,
<mask> "backgroundColor": "transparent",
<mask> "boundElementIds": null,
<mask> "fillStyle": "hachure",
<mask> "groupIds": Array [],
<mask> "height": 0,
<mask> "id": "id0",
<mask> "isDeleted": false,
<mask> "opacity": 100,
<mask> "roughness": 1,
<mask> "seed": 1278240551,
<mask> "strokeColor": "#000000",
<mask> "strokeSharpness": "sharp",
<mask> "strokeStyle": "solid",
<mask> "strokeWidth": 1,
<mask> "type": "rectangle",
<mask> "version": 1,
<mask> "versionNonce": 0,
<mask> "width": 0,
<mask> "x": -10,
<mask> "y": 0,
<mask> },
<mask> ],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": 100,
"y": 100,
},
],
},
</s> add
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/tests/__snapshots__/contextmenu.test.tsx.snap
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
<mask> "selectedElementIds": Object {},
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [
<mask> Object {
<mask> "angle": 0,
<mask> "backgroundColor": "transparent",
<mask> "boundElementIds": null,
<mask> "fillStyle": "hachure",
<mask> "groupIds": Array [],
<mask> "height": 0,
<mask> "id": "id0",
<mask> "isDeleted": false,
<mask> "opacity": 100,
<mask> "roughness": 1,
<mask> "seed": 1278240551,
<mask> "strokeColor": "#000000",
<mask> "strokeSharpness": "sharp",
<mask> "strokeStyle": "solid",
<mask> "strokeWidth": 1,
<mask> "type": "rectangle",
<mask> "version": 1,
<mask> "versionNonce": 0,
<mask> "width": 0,
<mask> "x": -10,
<mask> "y": 0,
<mask> },
<mask> ],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/tests/__snapshots__/contextmenu.test.tsx.snap
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
<mask> "selectedElementIds": Object {},
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [
<mask> Object {
<mask> "angle": 0,
<mask> "backgroundColor": "transparent",
<mask> "boundElementIds": null,
<mask> "fillStyle": "hachure",
<mask> "groupIds": Array [],
<mask> "height": 0,
<mask> "id": "id0",
<mask> "isDeleted": false,
<mask> "opacity": 100,
<mask> "roughness": 1,
<mask> "seed": 1278240551,
<mask> "strokeColor": "#000000",
<mask> "strokeSharpness": "sharp",
<mask> "strokeStyle": "solid",
<mask> "strokeWidth": 1,
<mask> "type": "rectangle",
<mask> "version": 1,
<mask> "versionNonce": 0,
<mask> "width": 0,
<mask> "x": -10,
<mask> "y": 0,
<mask> },
<mask> ],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/tests/__snapshots__/contextmenu.test.tsx.snap
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
<mask> "selectedElementIds": Object {},
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [
<mask> Object {
<mask> "angle": 0,
<mask> "backgroundColor": "transparent",
<mask> "boundElementIds": null,
<mask> "fillStyle": "hachure",
<mask> "groupIds": Array [],
<mask> "height": 0,
<mask> "id": "id0",
<mask> "isDeleted": false,
<mask> "opacity": 100,
<mask> "roughness": 1,
<mask> "seed": 1278240551,
<mask> "strokeColor": "#000000",
<mask> "strokeSharpness": "sharp",
<mask> "strokeStyle": "solid",
<mask> "strokeWidth": 1,
<mask> "type": "rectangle",
<mask> "version": 1,
<mask> "versionNonce": 0,
<mask> "width": 0,
<mask> "x": -10,
<mask> "y": 0,
<mask> },
<mask> ],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/tests/__snapshots__/contextmenu.test.tsx.snap
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
<mask> "selectedElementIds": Object {},
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [
<mask> Object {
<mask> "angle": 0,
<mask> "backgroundColor": "transparent",
<mask> "boundElementIds": null,
<mask> "fillStyle": "hachure",
<mask> "groupIds": Array [],
<mask> "height": 0,
<mask> "id": "id0",
<mask> "isDeleted": false,
<mask> "opacity": 100,
<mask> "roughness": 1,
<mask> "seed": 1278240551,
<mask> "strokeColor": "#000000",
<mask> "strokeSharpness": "sharp",
<mask> "strokeStyle": "solid",
<mask> "strokeWidth": 1,
<mask> "type": "rectangle",
<mask> "version": 1,
<mask> "versionNonce": 0,
<mask> "width": 0,
<mask> "x": -10,
<mask> "y": 0,
<mask> },
<mask> ],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/tests/__snapshots__/contextmenu.test.tsx.snap
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
<mask> "selectedElementIds": Object {},
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [
<mask> Object {
<mask> "angle": 0,
<mask> "backgroundColor": "transparent",
<mask> "boundElementIds": null,
<mask> "fillStyle": "hachure",
<mask> "groupIds": Array [],
<mask> "height": 0,
<mask> "id": "id0",
<mask> "isDeleted": false,
<mask> "opacity": 100,
<mask> "roughness": 1,
<mask> "seed": 449462985,
<mask> "strokeColor": "#000000",
<mask> "strokeSharpness": "sharp",
<mask> "strokeStyle": "solid",
<mask> "strokeWidth": 1,
<mask> "type": "rectangle",
<mask> "version": 1,
<mask> "versionNonce": 0,
<mask> "width": 0,
<mask> "x": -10,
<mask> "y": 0,
<mask> },
<mask> ],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/tests/__snapshots__/contextmenu.test.tsx.snap
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
<mask> "selectedElementIds": Object {},
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [
<mask> Object {
<mask> "angle": 0,
<mask> "backgroundColor": "transparent",
<mask> "boundElementIds": null,
<mask> "fillStyle": "hachure",
<mask> "groupIds": Array [],
<mask> "height": 0,
<mask> "id": "id0",
<mask> "isDeleted": false,
<mask> "opacity": 100,
<mask> "roughness": 1,
<mask> "seed": 1278240551,
<mask> "strokeColor": "#000000",
<mask> "strokeSharpness": "sharp",
<mask> "strokeStyle": "solid",
<mask> "strokeWidth": 1,
<mask> "type": "rectangle",
<mask> "version": 1,
<mask> "versionNonce": 0,
<mask> "width": 0,
<mask> "x": -10,
<mask> "y": 0,
<mask> },
<mask> ],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/tests/__snapshots__/contextmenu.test.tsx.snap
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
<mask> "selectedElementIds": Object {},
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [
<mask> Object {
<mask> "angle": 0,
<mask> "backgroundColor": "transparent",
<mask> "boundElementIds": null,
<mask> "fillStyle": "hachure",
<mask> "groupIds": Array [],
<mask> "height": 0,
<mask> "id": "id0",
<mask> "isDeleted": false,
<mask> "opacity": 100,
<mask> "roughness": 1,
<mask> "seed": 449462985,
<mask> "strokeColor": "#000000",
<mask> "strokeSharpness": "sharp",
<mask> "strokeStyle": "solid",
<mask> "strokeWidth": 1,
<mask> "type": "rectangle",
<mask> "version": 1,
<mask> "versionNonce": 0,
<mask> "width": 0,
<mask> "x": -10,
<mask> "y": 0,
<mask> },
<mask> ],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/tests/__snapshots__/contextmenu.test.tsx.snap
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
<mask> "selectedElementIds": Object {},
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [
<mask> Object {
<mask> "angle": 0,
<mask> "backgroundColor": "transparent",
<mask> "boundElementIds": null,
<mask> "fillStyle": "hachure",
<mask> "groupIds": Array [],
<mask> "height": 0,
<mask> "id": "id0",
<mask> "isDeleted": false,
<mask> "opacity": 100,
<mask> "roughness": 1,
<mask> "seed": 1278240551,
<mask> "strokeColor": "#000000",
<mask> "strokeSharpness": "sharp",
<mask> "strokeStyle": "solid",
<mask> "strokeWidth": 1,
<mask> "type": "rectangle",
<mask> "version": 1,
<mask> "versionNonce": 0,
<mask> "width": 0,
<mask> "x": 100,
<mask> "y": 100,
<mask> },
<mask> ],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/tests/__snapshots__/regressionTests.test.tsx.snap
|
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
|
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
<mask> "selectedElementIds": Object {},
<mask> "viewBackgroundColor": "#ffffff",
<mask> },
<mask> "elements": Array [
<mask> Object {
<mask> "angle": 0,
<mask> "backgroundColor": "transparent",
<mask> "boundElementIds": null,
<mask> "fillStyle": "hachure",
<mask> "groupIds": Array [],
<mask> "height": 0,
<mask> "id": "id0",
<mask> "isDeleted": false,
<mask> "opacity": 100,
<mask> "roughness": 1,
<mask> "seed": 337897,
<mask> "strokeColor": "#000000",
<mask> "strokeSharpness": "sharp",
<mask> "strokeStyle": "solid",
<mask> "strokeWidth": 1,
<mask> "type": "rectangle",
<mask> "version": 1,
<mask> "versionNonce": 0,
<mask> "width": 0,
<mask> "x": 0,
<mask> "y": 0,
<mask> },
<mask> ],
<mask> },
<mask> Object {
<mask> "appState": Object {
<mask> "editingGroupId": null,
<mask> "editingLinearElement": null,
<mask> "name": "Untitled-201933152653",
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 449462985,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 449462985,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add </s> remove Object {
"appState": Object {
"editingGroupId": null,
"editingLinearElement": null,
"name": "Untitled-201933152653",
"selectedElementIds": Object {},
"viewBackgroundColor": "#ffffff",
},
"elements": Array [
Object {
"angle": 0,
"backgroundColor": "transparent",
"boundElementIds": null,
"fillStyle": "hachure",
"groupIds": Array [],
"height": 0,
"id": "id0",
"isDeleted": false,
"opacity": 100,
"roughness": 1,
"seed": 1278240551,
"strokeColor": "#000000",
"strokeSharpness": "sharp",
"strokeStyle": "solid",
"strokeWidth": 1,
"type": "rectangle",
"version": 1,
"versionNonce": 0,
"width": 0,
"x": -10,
"y": 0,
},
],
},
</s> add
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/tests/__snapshots__/regressionTests.test.tsx.snap
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> describe("contextMenu element", () => {
<mask> beforeEach(async () => {
<mask> localStorage.clear();
<mask> renderScene.mockClear();
<mask> h.history.clear();
<mask> reseed(7);
<mask> setDateTimeForTests("201933152653");
<mask>
<mask> await render(<ExcalidrawApp />);
<mask> });
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove h.history.clear();
</s> add </s> remove history.setCurrentState(
</s> add this.history.setCurrentState( </s> remove type ActionCreator = (history: SceneHistory) => Action;
</s> add type ActionCreator = (history: History) => Action; </s> remove
</s> add this.history = new History(); </s> remove history.clear();
</s> add this.history.clear(); </s> remove const { history } = createHistory();
</s> add
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/tests/contextmenu.test.tsx
|
keep keep keep keep replace keep keep keep keep keep
|
<mask> ReactDOM.unmountComponentAtNode(document.getElementById("root")!);
<mask>
<mask> localStorage.clear();
<mask> renderScene.mockClear();
<mask> h.history.clear();
<mask> reseed(7);
<mask> setDateTimeForTests("201933152653");
<mask>
<mask> mouse.reset();
<mask> finger1.reset();
</s> fix: make history local to a given excalidraw instance (#3481)
* fix: make history local to a given excalidraw instance
* changelog
* Update src/packages/excalidraw/CHANGELOG.md </s> remove h.history.clear();
</s> add </s> remove type ActionCreator = (history: SceneHistory) => Action;
</s> add type ActionCreator = (history: History) => Action; </s> remove import { createHistory, SceneHistory } from "../history";
</s> add import History from "../history"; </s> remove const { history } = createHistory();
</s> add </s> add private history: History; </s> remove
</s> add this.history = new History();
|
https://github.com/excalidraw/excalidraw/commit/d3106495b2d85af8244709f93ca8296b10df20a7
|
src/tests/regressionTests.test.tsx
|
keep replace keep replace keep keep
|
<mask> import { ColorPicker } from "../components/ColorPicker";
<mask> import { eraser, ZoomInIcon, ZoomOutIcon } from "../components/icons";
<mask> import { ToolButton } from "../components/ToolButton";
<mask> import { MIN_ZOOM, THEME, ZOOM_STEP } from "../constants";
<mask> import { getCommonBounds, getNonDeletedElements } from "../element";
<mask> import { ExcalidrawElement } from "../element/types";
</s> feat: add hand/panning tool (#6141)
* feat: add hand/panning tool
* move hand tool right of tool lock separator
* tweak i18n
* rename `panning` -> `hand`
* toggle between last tool and hand on `H` shortcut
* hide properties sidebar when `hand` active
* revert to rendering HandButton manually due to mobile toolbar </s> remove import { getShortcutKey, updateActiveTool } from "../utils";
</s> add import { getShortcutKey, setCursor, updateActiveTool } from "../utils"; </s> remove import { getDefaultAppState, isEraserActive } from "../appState";
</s> add import {
getDefaultAppState,
isEraserActive,
isHandToolActive,
} from "../appState"; </s> remove import { AppState, DataURL, LastActiveToolBeforeEraser, Zoom } from "./types";
</s> add import { AppState, DataURL, LastActiveTool, Zoom } from "./types"; </s> add import { HandButton } from "./HandButton";
import { isHandToolActive } from "../appState"; </s> remove import { getDefaultAppState, isEraserActive } from "../appState";
import clsx from "clsx";
</s> add import {
getDefaultAppState,
isEraserActive,
isHandToolActive,
} from "../appState";
|
https://github.com/excalidraw/excalidraw/commit/d4afd6626850befdb000d86c203e7a604f8a871c
|
src/actions/actionCanvas.tsx
|
keep keep keep keep replace keep keep keep replace replace
|
<mask> import { getNormalizedZoom, getSelectedElements } from "../scene";
<mask> import { centerScrollOn } from "../scene/scroll";
<mask> import { getStateForZoom } from "../scene/zoom";
<mask> import { AppState, NormalizedZoomValue } from "../types";
<mask> import { getShortcutKey, updateActiveTool } from "../utils";
<mask> import { register } from "./register";
<mask> import { Tooltip } from "../components/Tooltip";
<mask> import { newElementWith } from "../element/mutateElement";
<mask> import { getDefaultAppState, isEraserActive } from "../appState";
<mask> import clsx from "clsx";
</s> feat: add hand/panning tool (#6141)
* feat: add hand/panning tool
* move hand tool right of tool lock separator
* tweak i18n
* rename `panning` -> `hand`
* toggle between last tool and hand on `H` shortcut
* hide properties sidebar when `hand` active
* revert to rendering HandButton manually due to mobile toolbar </s> remove import { getDefaultAppState, isEraserActive } from "../appState";
</s> add import {
getDefaultAppState,
isEraserActive,
isHandToolActive,
} from "../appState"; </s> remove import { MIN_ZOOM, THEME, ZOOM_STEP } from "../constants";
</s> add import { CURSOR_TYPE, MIN_ZOOM, THEME, ZOOM_STEP } from "../constants"; </s> remove import { eraser, ZoomInIcon, ZoomOutIcon } from "../components/icons";
</s> add import { ZoomInIcon, ZoomOutIcon } from "../components/icons"; </s> add import { HandButton } from "./HandButton";
import { isHandToolActive } from "../appState"; </s> remove import { AppState, DataURL, LastActiveToolBeforeEraser, Zoom } from "./types";
</s> add import { AppState, DataURL, LastActiveTool, Zoom } from "./types";
|
https://github.com/excalidraw/excalidraw/commit/d4afd6626850befdb000d86c203e7a604f8a871c
|
src/actions/actionCanvas.tsx
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.