From ee801f06a26eacfdc1c73444baad62b09c53014f Mon Sep 17 00:00:00 2001 From: Carlos Cano Date: Thu, 1 Feb 2024 16:43:11 +0100 Subject: [PATCH 1/6] Paste elements always as elements even if we are writting in a textarea --- src/clipboard.test.ts | 36 ++++++++++++++++++------------------ src/clipboard.ts | 10 +++++----- src/components/App.tsx | 19 +++++++++---------- src/element/textWysiwyg.tsx | 4 ++-- 4 files changed, 34 insertions(+), 35 deletions(-) diff --git a/src/clipboard.test.ts b/src/clipboard.test.ts index 770bcc90e794..2220b187d3f5 100644 --- a/src/clipboard.test.ts +++ b/src/clipboard.test.ts @@ -6,13 +6,13 @@ import { import { API } from "./tests/helpers/api"; describe("parseClipboard()", () => { - it("should parse JSON as plaintext if not excalidraw-api/clipboard data", async () => { + it("should parse JSON as plaintext if not excalidraw-api/clipboard data", () => { let text; let clipboardData; // ------------------------------------------------------------------------- text = "123"; - clipboardData = await parseClipboard( + clipboardData = parseClipboard( createPasteEvent({ types: { "text/plain": text } }), ); expect(clipboardData.text).toBe(text); @@ -20,7 +20,7 @@ describe("parseClipboard()", () => { // ------------------------------------------------------------------------- text = "[123]"; - clipboardData = await parseClipboard( + clipboardData = parseClipboard( createPasteEvent({ types: { "text/plain": text } }), ); expect(clipboardData.text).toBe(text); @@ -28,17 +28,17 @@ describe("parseClipboard()", () => { // ------------------------------------------------------------------------- text = JSON.stringify({ val: 42 }); - clipboardData = await parseClipboard( + clipboardData = parseClipboard( createPasteEvent({ types: { "text/plain": text } }), ); expect(clipboardData.text).toBe(text); }); - it("should parse valid excalidraw JSON if inside text/plain", async () => { + it("should parse valid excalidraw JSON if inside text/plain", () => { const rect = API.createElement({ type: "rectangle" }); const json = serializeAsClipboardJSON({ elements: [rect], files: null }); - const clipboardData = await parseClipboard( + const clipboardData = parseClipboard( createPasteEvent({ types: { "text/plain": json, @@ -48,14 +48,14 @@ describe("parseClipboard()", () => { expect(clipboardData.elements).toEqual([rect]); }); - it("should parse valid excalidraw JSON if inside text/html", async () => { + it("should parse valid excalidraw JSON if inside text/html", () => { const rect = API.createElement({ type: "rectangle" }); let json; let clipboardData; // ------------------------------------------------------------------------- json = serializeAsClipboardJSON({ elements: [rect], files: null }); - clipboardData = await parseClipboard( + clipboardData = parseClipboard( createPasteEvent({ types: { "text/html": json, @@ -65,7 +65,7 @@ describe("parseClipboard()", () => { expect(clipboardData.elements).toEqual([rect]); // ------------------------------------------------------------------------- json = serializeAsClipboardJSON({ elements: [rect], files: null }); - clipboardData = await parseClipboard( + clipboardData = parseClipboard( createPasteEvent({ types: { "text/html": `
${json}
`, @@ -76,10 +76,10 @@ describe("parseClipboard()", () => { // ------------------------------------------------------------------------- }); - it("should parse `src` urls out of text/html", async () => { + it("should parse `src` urls out of text/html", () => { let clipboardData; // ------------------------------------------------------------------------- - clipboardData = await parseClipboard( + clipboardData = parseClipboard( createPasteEvent({ types: { "text/html": ``, @@ -93,7 +93,7 @@ describe("parseClipboard()", () => { }, ]); // ------------------------------------------------------------------------- - clipboardData = await parseClipboard( + clipboardData = parseClipboard( createPasteEvent({ types: { "text/html": `
`, @@ -112,8 +112,8 @@ describe("parseClipboard()", () => { ]); }); - it("should parse text content alongside `src` urls out of text/html", async () => { - const clipboardData = await parseClipboard( + it("should parse text content alongside `src` urls out of text/html", () => { + const clipboardData = parseClipboard( createPasteEvent({ types: { "text/html": `hello
my friend!`, @@ -137,10 +137,10 @@ describe("parseClipboard()", () => { ]); }); - it("should parse spreadsheet from either text/plain and text/html", async () => { + it("should parse spreadsheet from either text/plain and text/html", () => { let clipboardData; // ------------------------------------------------------------------------- - clipboardData = await parseClipboard( + clipboardData = parseClipboard( createPasteEvent({ types: { "text/plain": `a b @@ -156,7 +156,7 @@ describe("parseClipboard()", () => { values: [2, 5, 10], }); // ------------------------------------------------------------------------- - clipboardData = await parseClipboard( + clipboardData = parseClipboard( createPasteEvent({ types: { "text/html": `a b @@ -172,7 +172,7 @@ describe("parseClipboard()", () => { values: [2, 5, 10], }); // ------------------------------------------------------------------------- - clipboardData = await parseClipboard( + clipboardData = parseClipboard( createPasteEvent({ types: { "text/html": ` diff --git a/src/clipboard.ts b/src/clipboard.ts index 32b0edf1a1fc..935daa383d07 100644 --- a/src/clipboard.ts +++ b/src/clipboard.ts @@ -292,10 +292,10 @@ export const readSystemClipboard = async () => { /** * Parses "paste" ClipboardEvent. */ -const parseClipboardEvent = async ( +const parseClipboardEvent = ( event: ClipboardEvent, isPlainPaste = false, -): Promise => { +): ParsedClipboardEvent => { try { const mixedContent = !isPlainPaste && event && maybeParseHTMLPaste(event); @@ -326,11 +326,11 @@ const parseClipboardEvent = async ( /** * Attempts to parse clipboard. Prefers system clipboard. */ -export const parseClipboard = async ( +export const parseClipboard = ( event: ClipboardEvent, isPlainPaste = false, -): Promise => { - const parsedEventData = await parseClipboardEvent(event, isPlainPaste); +): ClipboardData => { + const parsedEventData = parseClipboardEvent(event, isPlainPaste); if (parsedEventData.type === "mixedContent") { return { diff --git a/src/components/App.tsx b/src/components/App.tsx index 928a5194cacf..e37b9e9b1c63 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -2225,7 +2225,7 @@ class App extends React.Component { } }; - public pasteFromClipboard = withBatchedUpdates( + public pasteFromClipboard = withBatchedUpdates( async (event: ClipboardEvent) => { const isPlainPaste = !!IS_PLAIN_PASTE; @@ -2237,6 +2237,10 @@ class App extends React.Component { return; } + // These two lines are moved up by Alkemio to avoid pasting images json as text inside text elements + let file = event?.clipboardData?.files[0]; + const data = parseClipboard(event, isPlainPaste); + const elementUnderCursor = document.elementFromPoint( this.lastViewportPosition.x, this.lastViewportPosition.y, @@ -2244,7 +2248,8 @@ class App extends React.Component { if ( event && (!(elementUnderCursor instanceof HTMLCanvasElement) || - isWritableElement(target)) + isWritableElement(target)) && + !data.elements // If there are any elements, they will not be inserted as text ) { return; } @@ -2257,12 +2262,6 @@ class App extends React.Component { this.state, ); - // must be called in the same frame (thus before any awaits) as the paste - // event else some browsers (FF...) will clear the clipboardData - // (something something security) - let file = event?.clipboardData?.files[0]; - - const data = await parseClipboard(event, isPlainPaste); if (!file && !isPlainPaste) { if (data.mixedContent) { return this.addElementsFromMixedContentPaste(data.mixedContent, { @@ -2325,8 +2324,8 @@ class App extends React.Component { const elements = ( data.programmaticAPI ? convertToExcalidrawElements( - data.elements as ExcalidrawElementSkeleton[], - ) + data.elements as ExcalidrawElementSkeleton[], + ) : data.elements ) as readonly ExcalidrawElement[]; // TODO remove formatting from elements if isPlainPaste diff --git a/src/element/textWysiwyg.tsx b/src/element/textWysiwyg.tsx index 52f89e0b9151..6261f9391254 100644 --- a/src/element/textWysiwyg.tsx +++ b/src/element/textWysiwyg.tsx @@ -339,8 +339,8 @@ export const textWysiwyg = ({ updateWysiwygStyle(); if (onChange) { - editable.onpaste = async (event) => { - const clipboardData = await parseClipboard(event, true); + editable.onpaste = (event) => { + const clipboardData = parseClipboard(event, true); if (!clipboardData.text) { return; } From 5398bdc135543a82713e2522573c19dbac633b27 Mon Sep 17 00:00:00 2001 From: Carlos Cano Date: Thu, 1 Feb 2024 16:53:34 +0100 Subject: [PATCH 2/6] fix linting warnings --- src/components/App.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index e37b9e9b1c63..c0501ae9fe94 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -2225,7 +2225,7 @@ class App extends React.Component { } }; - public pasteFromClipboard = withBatchedUpdates( + public pasteFromClipboard = withBatchedUpdates( async (event: ClipboardEvent) => { const isPlainPaste = !!IS_PLAIN_PASTE; @@ -2324,8 +2324,8 @@ class App extends React.Component { const elements = ( data.programmaticAPI ? convertToExcalidrawElements( - data.elements as ExcalidrawElementSkeleton[], - ) + data.elements as ExcalidrawElementSkeleton[], + ) : data.elements ) as readonly ExcalidrawElement[]; // TODO remove formatting from elements if isPlainPaste From 747d5c8c760f9b4d9b4d11b3feee1f5ca9e09880 Mon Sep 17 00:00:00 2001 From: Carlos Cano Date: Thu, 1 Feb 2024 16:57:10 +0100 Subject: [PATCH 3/6] Update readme and package.json --- README.md | 7 ++++--- package.json | 2 +- src/packages/excalidraw/package.json | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ce9212961954..210ce6726958 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -

- Alkemio Logo +s

Alkemio Logo +

Enabling society to collaborate. Building a better future, together.

# Alkemio fork of Excalidraw v0.17.0 @@ -11,7 +11,8 @@ git merge v0.17.0 git push --set-upstream origin 0.17.0-alkemio-1 ``` -- Applied the new styles of the buttons to Alkemio's ZoomToFit added button +- Applied the new styles of the buttons to Alkemio's ZoomToFit added button. +- Modified the paste functionality to avoid pasting elements (such as images) as JSON when editing text. ### For testing you can link the new package from the local client diff --git a/package.json b/package.json index 2e4e6cb9f540..e5356248cd19 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ }, "homepage": "https://github.com/alkem-io/excalidraw", "name": "@alkemio/excalidraw", - "version": "0.17.0-alkemio-2", + "version": "0.17.0-alkemio-3-beta", "prettier": "@excalidraw/prettier-config", "private": false, "scripts": { diff --git a/src/packages/excalidraw/package.json b/src/packages/excalidraw/package.json index cb3ede03b96d..2c2422dad09c 100644 --- a/src/packages/excalidraw/package.json +++ b/src/packages/excalidraw/package.json @@ -1,6 +1,6 @@ { "name": "@alkemio/excalidraw", - "version": "0.17.0-alkemio-2", + "version": "0.17.0-alkemio-3-beta", "main": "main.js", "types": "types/packages/excalidraw/index.d.ts", "files": [ From 3ffbb671d80a017f9fa8cd336ec92805b72bf03b Mon Sep 17 00:00:00 2001 From: Carlos Cano Date: Fri, 19 Apr 2024 19:51:08 +0200 Subject: [PATCH 4/6] Add hideLibraryButton to AppState and change lock button functionality --- README.md | 12 +++++++ package.json | 2 +- src/appState.ts | 2 ++ src/components/LayerUI.tsx | 31 +++++++++++++++- src/components/LockElementButton.tsx | 53 ++++++++++++++++++++++++++++ src/components/ToolIcon.scss | 4 +++ src/data/types.ts | 1 + src/locales/en.json | 1 + src/packages/excalidraw/package.json | 2 +- src/types.ts | 1 + 10 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 src/components/LockElementButton.tsx diff --git a/README.md b/README.md index 210ce6726958..9ef56da80388 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,18 @@ yarn build:umd yarn pack yarn publish ``` +# Alkemio fork of Excalidraw v0.17.0-alkemio-4 +- Added `hideLibraryButton` to the appState to be able to hide the button from outside. +- Changed the toolbar Lock button behavior. Now it locks/unlocks elements instead of the tool in use + +# Alkemio fork of Excalidraw v0.17.0-alkemio-3-beta +- Changed behavior. Pasting elements is better handled and now it doesn't end up as a big text node with JSON inside. + + +# Alkemio fork of Excalidraw v0.17.0 + +- Upgraded from Excalidraw v0.16.1 to v0.17.0 + # Alkemio fork of Excalidraw v0.16.1 diff --git a/package.json b/package.json index e5356248cd19..a621f3f4efcf 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ }, "homepage": "https://github.com/alkem-io/excalidraw", "name": "@alkemio/excalidraw", - "version": "0.17.0-alkemio-3-beta", + "version": "0.17.0-alkemio-4", "prettier": "@excalidraw/prettier-config", "private": false, "scripts": { diff --git a/src/appState.ts b/src/appState.ts index 0089f57e982f..8bb84a9c8408 100644 --- a/src/appState.ts +++ b/src/appState.ts @@ -96,6 +96,7 @@ export const getDefaultAppState = (): Omit< value: 1 as NormalizedZoomValue, }, viewModeEnabled: false, + hideLibraryButton: false, pendingImageElementId: null, showHyperlinkPopup: false, selectedLinearElement: null, @@ -209,6 +210,7 @@ const APP_STATE_STORAGE_CONF = (< zenModeEnabled: { browser: true, export: false, server: false }, zoom: { browser: true, export: false, server: false }, viewModeEnabled: { browser: false, export: false, server: false }, + hideLibraryButton: { browser: true, export: false, server: false }, pendingImageElementId: { browser: false, export: false, server: false }, showHyperlinkPopup: { browser: false, export: false, server: false }, selectedLinearElement: { browser: true, export: false, server: false }, diff --git a/src/components/LayerUI.tsx b/src/components/LayerUI.tsx index b32adcf30a28..2ff42bf1d261 100644 --- a/src/components/LayerUI.tsx +++ b/src/components/LayerUI.tsx @@ -22,7 +22,7 @@ import { FixedSideContainer } from "./FixedSideContainer"; import { HintViewer } from "./HintViewer"; import { Island } from "./Island"; import { LoadingMessage } from "./LoadingMessage"; -import { LockButton } from "./LockButton"; +import { LockElementButton } from "./LockElementButton"; import { MobileMenu } from "./MobileMenu"; import { PasteChartDialog } from "./PasteChartDialog"; import { Section } from "./Section"; @@ -56,6 +56,7 @@ import { mutateElement } from "../element/mutateElement"; import { ShapeCache } from "../scene/ShapeCache"; import Scene from "../scene/Scene"; import { LaserPointerButton } from "./LaserTool/LaserPointerButton"; +import { actionToggleElementLock } from "../actions"; interface LayerUIProps { actionManager: ActionManager; @@ -214,6 +215,15 @@ const LayerUI = ({ ); + const allElementsLocked = (elementsIds: string[]) => { + if (elementsIds.length === 0) { + return false; + } + return elements + .filter((element) => elementsIds.includes(element.id)) + .every((element) => element.locked); + }; + const renderFixedSideContainer = () => { const shouldRenderSelectedShapeActions = showSelectedShapeActions( appState, @@ -262,11 +272,29 @@ const LayerUI = ({ title={t("toolBar.penMode")} penDetected={appState.penDetected} /> + {/* + Removed: + */} + + actionManager.executeAction( + actionToggleElementLock, + ) + } + title={t("toolBar.lockElements")} + />
@@ -320,6 +348,7 @@ const LayerUI = ({ {renderTopRightUI?.(device.editor.isMobile, appState)} {!appState.viewModeEnabled && + !appState.hideLibraryButton && // hide button when sidebar docked (!isSidebarDocked || appState.openSidebar?.name !== DEFAULT_SIDEBAR.name) && ( diff --git a/src/components/LockElementButton.tsx b/src/components/LockElementButton.tsx new file mode 100644 index 000000000000..a4e3dc0de580 --- /dev/null +++ b/src/components/LockElementButton.tsx @@ -0,0 +1,53 @@ +import "./ToolIcon.scss"; + +import clsx from "clsx"; +import { ToolButtonSize } from "./ToolButton"; +import { LockedIcon, UnlockedIcon } from "./icons"; + +type LockElementIconProps = { + title?: string; + name?: string; + checked: boolean; + disabled?: boolean; + onChange?(): void; + isMobile?: boolean; +}; + +const DEFAULT_SIZE: ToolButtonSize = "medium"; + +const ICONS = { + CHECKED: LockedIcon, + UNCHECKED: UnlockedIcon, +}; + +export const LockElementButton = (props: LockElementIconProps) => { + return ( + + ); +}; diff --git a/src/components/ToolIcon.scss b/src/components/ToolIcon.scss index 01d0bef3ddac..c2c7051dcc13 100644 --- a/src/components/ToolIcon.scss +++ b/src/components/ToolIcon.scss @@ -17,6 +17,10 @@ @include toolbarButtonColorStates; } + .ToolIcon.disabled { + cursor: default; + opacity: 0.5; + } .ToolIcon--plain { background-color: transparent; diff --git a/src/data/types.ts b/src/data/types.ts index 180bfa60a6a9..d4bb98ff02b0 100644 --- a/src/data/types.ts +++ b/src/data/types.ts @@ -43,6 +43,7 @@ export interface ImportedDataState { > | null; scrollToContent?: boolean; zoomToFit?: boolean; + hideLibraryButton?: boolean; libraryItems?: LibraryItems_anyVersion; files?: BinaryFiles; } diff --git a/src/locales/en.json b/src/locales/en.json index 098c2c4b55eb..83fddaae6587 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -236,6 +236,7 @@ "text": "Text", "library": "Library", "lock": "Keep selected tool active after drawing", + "lockElements": "Toggle Lock for selected elements", "penMode": "Pen mode - prevent touch", "link": "Add/ Update link for a selected shape", "eraser": "Eraser", diff --git a/src/packages/excalidraw/package.json b/src/packages/excalidraw/package.json index 2c2422dad09c..7f3b4e9eb0e6 100644 --- a/src/packages/excalidraw/package.json +++ b/src/packages/excalidraw/package.json @@ -1,6 +1,6 @@ { "name": "@alkemio/excalidraw", - "version": "0.17.0-alkemio-3-beta", + "version": "0.17.0-alkemio-4", "main": "main.js", "types": "types/packages/excalidraw/index.d.ts", "files": [ diff --git a/src/types.ts b/src/types.ts index 4e75702ff187..8c9ef9d1174b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -261,6 +261,7 @@ export type AppState = { theme: Theme; gridSize: number | null; viewModeEnabled: boolean; + hideLibraryButton: boolean; /** top-most selected groups (i.e. does not include nested groups) */ selectedGroupIds: { [groupId: string]: boolean }; From 4f5256a166a9f8fc469a68d7b9cda4e07b043e6a Mon Sep 17 00:00:00 2001 From: Carlos Cano Date: Fri, 19 Apr 2024 20:00:43 +0200 Subject: [PATCH 5/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9ef56da80388..9d7e674e8928 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -s

Alkemio Logo +

Alkemio Logo

Enabling society to collaborate. Building a better future, together.

From 002111e2e1e4984458fa3b0186506070b412f468 Mon Sep 17 00:00:00 2001 From: Carlos Cano Date: Tue, 23 Apr 2024 10:06:24 +0200 Subject: [PATCH 6/6] fixed tests --- src/appState.ts | 2 +- .../__snapshots__/contextmenu.test.tsx.snap | 17 ++++++ .../regressionTests.test.tsx.snap | 52 +++++++++++++++++++ .../packages/__snapshots__/utils.test.ts.snap | 1 + src/tests/selection.test.tsx | 31 +++++------ 5 files changed, 87 insertions(+), 16 deletions(-) diff --git a/src/appState.ts b/src/appState.ts index 8bb84a9c8408..30762695c29a 100644 --- a/src/appState.ts +++ b/src/appState.ts @@ -210,7 +210,7 @@ const APP_STATE_STORAGE_CONF = (< zenModeEnabled: { browser: true, export: false, server: false }, zoom: { browser: true, export: false, server: false }, viewModeEnabled: { browser: false, export: false, server: false }, - hideLibraryButton: { browser: true, export: false, server: false }, + hideLibraryButton: { browser: false, export: false, server: false }, pendingImageElementId: { browser: false, export: false, server: false }, showHyperlinkPopup: { browser: false, export: false, server: false }, selectedLinearElement: { browser: true, export: false, server: false }, diff --git a/src/tests/__snapshots__/contextmenu.test.tsx.snap b/src/tests/__snapshots__/contextmenu.test.tsx.snap index d8ef5572ae1a..5060a4311299 100644 --- a/src/tests/__snapshots__/contextmenu.test.tsx.snap +++ b/src/tests/__snapshots__/contextmenu.test.tsx.snap @@ -321,6 +321,7 @@ exports[`contextMenu element > right-clicking on a group should select whole gro "frameToHighlight": null, "gridSize": null, "height": 100, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -520,6 +521,7 @@ exports[`contextMenu element > selecting 'Add to library' in context menu adds e "frameToHighlight": null, "gridSize": null, "height": 100, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -722,6 +724,7 @@ exports[`contextMenu element > selecting 'Bring forward' in context menu brings "frameToHighlight": null, "gridSize": null, "height": 100, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -1098,6 +1101,7 @@ exports[`contextMenu element > selecting 'Bring to front' in context menu brings "frameToHighlight": null, "gridSize": null, "height": 100, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -1474,6 +1478,7 @@ exports[`contextMenu element > selecting 'Copy styles' in context menu copies st "frameToHighlight": null, "gridSize": null, "height": 100, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -1676,6 +1681,7 @@ exports[`contextMenu element > selecting 'Delete' in context menu deletes elemen "frameToHighlight": null, "gridSize": null, "height": 100, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -1915,6 +1921,7 @@ exports[`contextMenu element > selecting 'Duplicate' in context menu duplicates "frameToHighlight": null, "gridSize": null, "height": 100, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -2219,6 +2226,7 @@ exports[`contextMenu element > selecting 'Group selection' in context menu group "frameToHighlight": null, "gridSize": null, "height": 100, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -2611,6 +2619,7 @@ exports[`contextMenu element > selecting 'Paste styles' in context menu pastes s "frameToHighlight": null, "gridSize": null, "height": 100, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -3421,6 +3430,7 @@ exports[`contextMenu element > selecting 'Send backward' in context menu sends e "frameToHighlight": null, "gridSize": null, "height": 100, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -3797,6 +3807,7 @@ exports[`contextMenu element > selecting 'Send to back' in context menu sends el "frameToHighlight": null, "gridSize": null, "height": 100, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -4173,6 +4184,7 @@ exports[`contextMenu element > selecting 'Ungroup selection' in context menu ung "frameToHighlight": null, "gridSize": null, "height": 100, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -4905,6 +4917,7 @@ exports[`contextMenu element > shows 'Group selection' in context menu for multi "frameToHighlight": null, "gridSize": null, "height": 100, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -5485,6 +5498,7 @@ exports[`contextMenu element > shows 'Ungroup selection' in context menu for gro "frameToHighlight": null, "gridSize": null, "height": 100, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -6004,6 +6018,7 @@ exports[`contextMenu element > shows context menu for canvas > [end of test] app "frameToHighlight": null, "gridSize": null, "height": 100, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -6403,6 +6418,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap "frameToHighlight": null, "gridSize": null, "height": 100, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -6777,6 +6793,7 @@ exports[`contextMenu element > shows context menu for element > [end of test] ap "frameToHighlight": null, "gridSize": null, "height": 100, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, diff --git a/src/tests/__snapshots__/regressionTests.test.tsx.snap b/src/tests/__snapshots__/regressionTests.test.tsx.snap index 9cf919a9ce19..69860e7a1787 100644 --- a/src/tests/__snapshots__/regressionTests.test.tsx.snap +++ b/src/tests/__snapshots__/regressionTests.test.tsx.snap @@ -48,6 +48,7 @@ exports[`given element A and group of elements B and given both are selected whe "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -504,6 +505,7 @@ exports[`given element A and group of elements B and given both are selected whe "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -962,6 +964,7 @@ exports[`regression tests > Cmd/Ctrl-click exclusively select element under poin "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": false, "isLoading": false, "isResizing": false, @@ -1793,6 +1796,7 @@ exports[`regression tests > Drags selected element when hitting only bounding bo "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -2006,6 +2010,7 @@ exports[`regression tests > adjusts z order when grouping > [end of test] appSta "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -2460,6 +2465,7 @@ exports[`regression tests > alt-drag duplicates an element > [end of test] appSt "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -2702,6 +2708,7 @@ exports[`regression tests > arrow keys > [end of test] appState 1`] = ` "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -2870,6 +2877,7 @@ exports[`regression tests > can drag element that covers another element, while "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -3314,6 +3322,7 @@ exports[`regression tests > change the properties of a shape > [end of test] app "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -3611,6 +3620,7 @@ exports[`regression tests > click on an element and drag it > [dragged] appState "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -3856,6 +3866,7 @@ exports[`regression tests > click on an element and drag it > [end of test] appS "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -4112,6 +4123,7 @@ exports[`regression tests > click to select a shape > [end of test] appState 1`] "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -4354,6 +4366,7 @@ exports[`regression tests > click-drag to select a group > [end of test] appStat "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -4698,6 +4711,7 @@ exports[`regression tests > deleting last but one element in editing group shoul "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -5201,6 +5215,7 @@ exports[`regression tests > deselects group of selected elements on pointer down "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -5498,6 +5513,7 @@ exports[`regression tests > deselects group of selected elements on pointer up w "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -5767,6 +5783,7 @@ exports[`regression tests > deselects selected element on pointer down when poin "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -5963,6 +5980,7 @@ exports[`regression tests > deselects selected element, on pointer up, when clic "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -6131,6 +6149,7 @@ exports[`regression tests > double click to edit a group > [end of test] appStat "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -6583,6 +6602,7 @@ exports[`regression tests > drags selected elements from point inside common bou "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -6900,6 +6920,7 @@ exports[`regression tests > draw every type of shape > [end of test] appState 1` "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -8967,6 +8988,7 @@ exports[`regression tests > given a group of selected elements with an element t "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -9311,6 +9333,7 @@ exports[`regression tests > given a selected element A and a not selected elemen "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -9554,6 +9577,7 @@ exports[`regression tests > given selected element A with lower z-index than uns "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -9753,6 +9777,7 @@ exports[`regression tests > given selected element A with lower z-index than uns "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -10024,6 +10049,7 @@ exports[`regression tests > key 2 selects rectangle tool > [end of test] appStat "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -10192,6 +10218,7 @@ exports[`regression tests > key 3 selects diamond tool > [end of test] appState "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -10360,6 +10387,7 @@ exports[`regression tests > key 4 selects ellipse tool > [end of test] appState "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -10528,6 +10556,7 @@ exports[`regression tests > key 5 selects arrow tool > [end of test] appState 1` "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -10734,6 +10763,7 @@ exports[`regression tests > key 6 selects line tool > [end of test] appState 1`] "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -10940,6 +10970,7 @@ exports[`regression tests > key 7 selects freedraw tool > [end of test] appState "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -11126,6 +11157,7 @@ exports[`regression tests > key a selects arrow tool > [end of test] appState 1` "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -11332,6 +11364,7 @@ exports[`regression tests > key d selects diamond tool > [end of test] appState "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -11500,6 +11533,7 @@ exports[`regression tests > key l selects line tool > [end of test] appState 1`] "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -11706,6 +11740,7 @@ exports[`regression tests > key o selects ellipse tool > [end of test] appState "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -11874,6 +11909,7 @@ exports[`regression tests > key p selects freedraw tool > [end of test] appState "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -12060,6 +12096,7 @@ exports[`regression tests > key r selects rectangle tool > [end of test] appStat "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -12228,6 +12265,7 @@ exports[`regression tests > make a group and duplicate it > [end of test] appSta "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -12892,6 +12930,7 @@ exports[`regression tests > noop interaction after undo shouldn't create history "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -13134,6 +13173,7 @@ exports[`regression tests > pinch-to-zoom works > [end of test] appState 1`] = ` "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -13257,6 +13297,7 @@ exports[`regression tests > shift click on selected element should deselect it o "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -13425,6 +13466,7 @@ exports[`regression tests > shift-click to multiselect, then drag > [end of test "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -13742,6 +13784,7 @@ exports[`regression tests > should group elements and ungroup them > [end of tes "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -14303,6 +14346,7 @@ exports[`regression tests > single-clicking on a subgroup of a selected group sh "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -15159,6 +15203,7 @@ exports[`regression tests > spacebar + drag scrolls the canvas > [end of test] a "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -15285,6 +15330,7 @@ exports[`regression tests > supports nested groups > [end of test] appState 1`] "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -16100,6 +16146,7 @@ exports[`regression tests > switches from group of selected elements to another "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -16500,6 +16547,7 @@ exports[`regression tests > switches selected element on pointer down > [end of "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -16770,6 +16818,7 @@ exports[`regression tests > two-finger scroll works > [end of test] appState 1`] "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -16893,6 +16942,7 @@ exports[`regression tests > undo/redo drawing an element > [end of test] appStat "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -17376,6 +17426,7 @@ exports[`regression tests > updates fontSize & fontFamily appState > [end of tes "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, @@ -17499,6 +17550,7 @@ exports[`regression tests > zoom hotkeys > [end of test] appState 1`] = ` "frameToHighlight": null, "gridSize": null, "height": 768, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, diff --git a/src/tests/packages/__snapshots__/utils.test.ts.snap b/src/tests/packages/__snapshots__/utils.test.ts.snap index 254d4163b6e9..faa429ee0359 100644 --- a/src/tests/packages/__snapshots__/utils.test.ts.snap +++ b/src/tests/packages/__snapshots__/utils.test.ts.snap @@ -48,6 +48,7 @@ exports[`exportToSvg > with default arguments 1`] = ` }, "frameToHighlight": null, "gridSize": null, + "hideLibraryButton": false, "isBindingEnabled": true, "isLoading": false, "isResizing": false, diff --git a/src/tests/selection.test.tsx b/src/tests/selection.test.tsx index f251126f81ea..5d6512658083 100644 --- a/src/tests/selection.test.tsx +++ b/src/tests/selection.test.tsx @@ -472,21 +472,22 @@ describe("select single element on the scene", () => { }); }); -describe("tool locking & selection", () => { - it("should not select newly created element while tool is locked", async () => { - await render(); - - UI.clickTool("lock"); - expect(h.state.activeTool.locked).toBe(true); - - for (const { value } of Object.values(SHAPES)) { - if (value !== "image" && value !== "selection" && value !== "eraser") { - const element = UI.createElement(value); - expect(h.state.selectedElementIds[element.id]).not.toBe(true); - } - } - }); -}); +// This test makes no sense, we have removed the "Lock tool" functionality and now it's locking the selected elements +// describe("tool locking & selection", () => { +// it("should not select newly created element while tool is locked", async () => { +// await render(); + +// UI.clickTool("lock"); +// expect(h.state.activeTool.locked).toBe(true); + +// for (const { value } of Object.values(SHAPES)) { +// if (value !== "image" && value !== "selection" && value !== "eraser") { +// const element = UI.createElement(value); +// expect(h.state.selectedElementIds[element.id]).not.toBe(true); +// } +// } +// }); +// }); describe("selectedElementIds stability", () => { beforeEach(async () => {