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 keep
<mask> { value: 2, text: t("labels.bold") }, <mask> { value: 4, text: t("labels.extraBold") }, <mask> ]} <mask> value={getFormValue( <mask> appState.editingElement, <mask> elements, <mask> element => element.strokeWidth, <mask> appState.currentItemStrokeWidth, <mask> )} <mask> onChange={value => updateData(value)} </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add appState, </s> remove appState.editingElement, </s> add </s> add appState, </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep add keep keep keep keep keep keep
<mask> { value: 4, text: t("labels.extraBold") }, <mask> ]} <mask> value={getFormValue( <mask> elements, <mask> element => element.strokeWidth, <mask> appState.currentItemStrokeWidth, <mask> )} <mask> onChange={value => updateData(value)} <mask> /> <mask> </fieldset> </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove appState.editingElement, </s> add </s> add appState, </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> add appState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep keep replace keep replace keep
<mask> export const actionChangeSloppiness = register({ <mask> name: "changeSloppiness", <mask> perform: (elements, appState, value) => { <mask> return { <mask> elements: changeProperty(elements, el => ({ <mask> ...el, <mask> shape: null, <mask> roughness: value, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> { value: 1, text: t("labels.artist") }, <mask> { value: 2, text: t("labels.cartoonist") }, <mask> ]} <mask> value={getFormValue( <mask> appState.editingElement, <mask> elements, <mask> element => element.roughness, <mask> appState.currentItemRoughness, <mask> )} <mask> onChange={value => updateData(value)} </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add appState, </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> add appState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep add keep keep keep keep keep keep
<mask> { value: 2, text: t("labels.cartoonist") }, <mask> ]} <mask> value={getFormValue( <mask> elements, <mask> element => element.roughness, <mask> appState.currentItemRoughness, <mask> )} <mask> onChange={value => updateData(value)} <mask> /> <mask> </fieldset> </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove appState.editingElement, </s> add </s> add appState, </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> add appState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep replace keep replace keep
<mask> return { <mask> elements: changeProperty(elements, el => ({ <mask> ...el, <mask> shape: null, <mask> opacity: value, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> }} <mask> value={ <mask> getFormValue( <mask> appState.editingElement, <mask> elements, <mask> element => element.opacity, <mask> appState.currentItemOpacity, <mask> ) ?? undefined <mask> } </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add appState, </s> add appState, </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep add keep keep keep keep keep
<mask> getFormValue( <mask> elements, <mask> element => element.opacity, <mask> appState.currentItemOpacity, <mask> ) ?? undefined <mask> } <mask> /> </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove appState.editingElement, </s> add </s> add appState, </s> add appState, </s> add appState, </s> add appState, </s> add appState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep replace keep keep keep replace
<mask> perform: (elements, appState, value) => { <mask> return { <mask> elements: changeProperty(elements, el => { <mask> if (isTextElement(el)) { <mask> const element: ExcalidrawTextElement = { <mask> ...el, <mask> shape: null, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements: changeProperty(elements, el => { </s> add elements: changeProperty(elements, appState, el => { </s> remove shape: null, </s> add </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> { value: 28, text: t("labels.large") }, <mask> { value: 36, text: t("labels.veryLarge") }, <mask> ]} <mask> value={getFormValue( <mask> appState.editingElement, <mask> elements, <mask> element => isTextElement(element) && +element.font.split("px ")[0], <mask> +(appState.currentItemFont || DEFAULT_FONT).split("px ")[0], <mask> )} <mask> onChange={value => updateData(value)} </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add appState, </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> add appState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep add keep keep keep keep keep keep
<mask> ]} <mask> value={getFormValue( <mask> elements, <mask> element => isTextElement(element) && +element.font.split("px ")[0], <mask> +(appState.currentItemFont || DEFAULT_FONT).split("px ")[0], <mask> )} <mask> onChange={value => updateData(value)} <mask> /> <mask> </fieldset> </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove appState.editingElement, </s> add </s> add appState, </s> remove appState.editingElement, </s> add </s> add appState, </s> add appState, </s> remove appState.editingElement, </s> add
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep replace keep keep keep replace keep keep
<mask> perform: (elements, appState, value) => { <mask> return { <mask> elements: changeProperty(elements, el => { <mask> if (isTextElement(el)) { <mask> const element: ExcalidrawTextElement = { <mask> ...el, <mask> shape: null, <mask> font: `${el.font.split("px ")[0]}px ${value}`, <mask> }; </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements: changeProperty(elements, el => { </s> add elements: changeProperty(elements, appState, el => { </s> remove shape: null, </s> add </s> remove shape: null, </s> add </s> remove shape: null, </s> add </s> remove shape: null, </s> add
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> { value: "Helvetica", text: t("labels.normal") }, <mask> { value: "Cascadia", text: t("labels.code") }, <mask> ]} <mask> value={getFormValue( <mask> appState.editingElement, <mask> elements, <mask> element => isTextElement(element) && element.font.split("px ")[1], <mask> (appState.currentItemFont || DEFAULT_FONT).split("px ")[1], <mask> )} <mask> onChange={value => updateData(value)} </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add appState, </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> add appState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep add keep keep keep keep keep
<mask> value={getFormValue( <mask> elements, <mask> element => isTextElement(element) && element.font.split("px ")[1], <mask> (appState.currentItemFont || DEFAULT_FONT).split("px ")[1], <mask> )} <mask> onChange={value => updateData(value)} <mask> /> </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove appState.editingElement, </s> add </s> add appState, </s> remove appState.editingElement, </s> add </s> add appState, </s> add appState, </s> remove appState.editingElement, </s> add
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep replace keep replace keep
<mask> <mask> export const actionSelectAll = register({ <mask> name: "selectAll", <mask> perform: elements => { <mask> return { <mask> elements: elements.map(elem => ({ ...elem, isSelected: true })), <mask> }; </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove perform: elements => { </s> add perform: (elements, appState) => { </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionSelectAll.ts
keep keep keep keep replace replace keep keep keep keep keep
<mask> let copiedStyles: string = "{}"; <mask> <mask> export const actionCopyStyles = register({ <mask> name: "copyStyles", <mask> perform: elements => { <mask> const element = elements.find(el => el.isSelected); <mask> if (element) { <mask> copiedStyles = JSON.stringify(element); <mask> } <mask> return {}; <mask> }, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove perform: elements => { </s> add perform: (elements, appState) => { </s> remove let newElements = clearSelection(elements); </s> add let newElements = elements; </s> remove perform: elements => { </s> add perform: (elements, appState) => { </s> add import { invalidateShapeForElement } from "../renderer/renderElement"; </s> remove elements: changeProperty(elements, el => { </s> add elements: changeProperty(elements, appState, el => { </s> remove elements: changeProperty(elements, el => { </s> add elements: changeProperty(elements, appState, el => {
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionStyles.ts
keep keep keep keep replace keep keep keep keep keep
<mask> }); <mask> <mask> export const actionPasteStyles = register({ <mask> name: "pasteStyles", <mask> perform: elements => { <mask> const pastedElement = JSON.parse(copiedStyles); <mask> if (!isExcalidrawElement(pastedElement)) { <mask> return { elements }; <mask> } <mask> return { </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove perform: elements => { </s> add perform: (elements, appState) => { </s> remove perform: elements => { const element = elements.find(el => el.isSelected); </s> add perform: (elements, appState) => { const element = elements.find(el => appState.selectedElementIds[el.id]); </s> remove elements: elements.map(elem => ({ ...elem, isSelected: true })), </s> add appState: { ...appState, selectedElementIds: Object.fromEntries( elements.map(element => [element.id, true]), ), }, </s> remove if (element.isSelected) { </s> add if (appState.selectedElementIds[element.id]) { </s> remove elements: changeProperty(elements, el => { </s> add elements: changeProperty(elements, appState, el => { </s> remove elements: changeProperty(elements, el => { </s> add elements: changeProperty(elements, appState, el => {
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionStyles.ts
keep keep keep keep replace keep keep replace keep keep keep keep
<mask> return { elements }; <mask> } <mask> return { <mask> elements: elements.map(element => { <mask> if (element.isSelected) { <mask> const newElement = { <mask> ...element, <mask> shape: null, <mask> backgroundColor: pastedElement?.backgroundColor, <mask> strokeWidth: pastedElement?.strokeWidth, <mask> strokeColor: pastedElement?.strokeColor, <mask> fillStyle: pastedElement?.fillStyle, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove if (element.isSelected) { </s> add if (appState.selectedElementIds[element.id]) { </s> remove shape: null, </s> add </s> remove shape: null, </s> add </s> remove shape: null, </s> add </s> remove shape: null, </s> add
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionStyles.ts
keep keep keep keep replace keep keep keep keep keep
<mask> export const actionSendBackward = register({ <mask> name: "sendBackward", <mask> perform: (elements, appState) => { <mask> return { <mask> elements: moveOneLeft([...elements], getSelectedIndices(elements)), <mask> appState, <mask> }; <mask> }, <mask> contextItemLabel: "labels.sendBackward", <mask> keyPriority: 40, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements: moveOneRight([...elements], getSelectedIndices(elements)), </s> add elements: moveOneRight( [...elements], getSelectedIndices(elements, appState), ), </s> remove elements: moveAllRight([...elements], getSelectedIndices(elements)), </s> add elements: moveAllRight( [...elements], getSelectedIndices(elements, appState), ), </s> remove elements: moveAllLeft([...elements], getSelectedIndices(elements)), </s> add elements: moveAllLeft( [...elements], getSelectedIndices(elements, appState), ), </s> remove elements: deleteSelectedElements(elements), </s> add elements: deleteSelectedElements(elements, appState), </s> remove perform: elements => { </s> add perform: (elements, appState) => { </s> remove perform: elements => { </s> add perform: (elements, appState) => {
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionZindex.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> export const actionBringForward = register({ <mask> name: "bringForward", <mask> perform: (elements, appState) => { <mask> return { <mask> elements: moveOneRight([...elements], getSelectedIndices(elements)), <mask> appState, <mask> }; <mask> }, <mask> contextItemLabel: "labels.bringForward", <mask> keyPriority: 40, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements: moveOneLeft([...elements], getSelectedIndices(elements)), </s> add elements: moveOneLeft( [...elements], getSelectedIndices(elements, appState), ), </s> remove elements: moveAllRight([...elements], getSelectedIndices(elements)), </s> add elements: moveAllRight( [...elements], getSelectedIndices(elements, appState), ), </s> remove elements: moveAllLeft([...elements], getSelectedIndices(elements)), </s> add elements: moveAllLeft( [...elements], getSelectedIndices(elements, appState), ), </s> remove elements: deleteSelectedElements(elements), </s> add elements: deleteSelectedElements(elements, appState), </s> remove perform: elements => { </s> add perform: (elements, appState) => { </s> remove perform: elements => { </s> add perform: (elements, appState) => {
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionZindex.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> export const actionSendToBack = register({ <mask> name: "sendToBack", <mask> perform: (elements, appState) => { <mask> return { <mask> elements: moveAllLeft([...elements], getSelectedIndices(elements)), <mask> appState, <mask> }; <mask> }, <mask> contextItemLabel: "labels.sendToBack", <mask> commitToHistory: () => true, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements: moveAllRight([...elements], getSelectedIndices(elements)), </s> add elements: moveAllRight( [...elements], getSelectedIndices(elements, appState), ), </s> remove elements: moveOneRight([...elements], getSelectedIndices(elements)), </s> add elements: moveOneRight( [...elements], getSelectedIndices(elements, appState), ), </s> remove elements: moveOneLeft([...elements], getSelectedIndices(elements)), </s> add elements: moveOneLeft( [...elements], getSelectedIndices(elements, appState), ), </s> remove elements: deleteSelectedElements(elements), </s> add elements: deleteSelectedElements(elements, appState), </s> remove perform: elements => { </s> add perform: (elements, appState) => { </s> remove perform: elements => { </s> add perform: (elements, appState) => {
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionZindex.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> export const actionBringToFront = register({ <mask> name: "bringToFront", <mask> perform: (elements, appState) => { <mask> return { <mask> elements: moveAllRight([...elements], getSelectedIndices(elements)), <mask> appState, <mask> }; <mask> }, <mask> commitToHistory: () => true, <mask> contextItemLabel: "labels.bringToFront", </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements: moveAllLeft([...elements], getSelectedIndices(elements)), </s> add elements: moveAllLeft( [...elements], getSelectedIndices(elements, appState), ), </s> remove elements: moveOneRight([...elements], getSelectedIndices(elements)), </s> add elements: moveOneRight( [...elements], getSelectedIndices(elements, appState), ), </s> remove elements: moveOneLeft([...elements], getSelectedIndices(elements)), </s> add elements: moveOneLeft( [...elements], getSelectedIndices(elements, appState), ), </s> remove elements: deleteSelectedElements(elements), </s> add elements: deleteSelectedElements(elements, appState), </s> remove perform: elements => { </s> add perform: (elements, appState) => { </s> remove perform: elements => { </s> add perform: (elements, appState) => {
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionZindex.tsx
keep keep add keep keep keep keep keep keep
<mask> zoom: 1, <mask> openMenu: null, <mask> lastPointerDownWith: "mouse", <mask> }; <mask> } <mask> <mask> export function clearAppStateForLocalStorage(appState: AppState) { <mask> const { <mask> draggingElement, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add selectedElementIds: { [id: string]: boolean }; </s> remove function generateElementCanvas(element: ExcalidrawElement, zoom: number) { </s> add export interface ExcalidrawElementWithCanvas { element: ExcalidrawElement | ExcalidrawTextElement; canvas: HTMLCanvasElement; canvasZoom: number; canvasOffsetX: number; canvasOffsetY: number; } function generateElementCanvas( element: ExcalidrawElement, zoom: number, ): ExcalidrawElementWithCanvas { </s> add appState: AppState, </s> add appState: AppState, </s> remove export function getSelectedIndices(elements: readonly ExcalidrawElement[]) { </s> add export function getSelectedIndices( elements: readonly ExcalidrawElement[], appState: AppState, ) { </s> remove elementsWithinSelection.forEach(element => { element.isSelected = true; }); </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, ...Object.fromEntries( elementsWithinSelection.map(element => [ element.id, true, ]), ), }, }));
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/appState.ts
keep add keep keep keep keep keep keep
<mask> import { ExcalidrawElement } from "./element/types"; <mask> import { getSelectedElements } from "./scene"; <mask> <mask> let CLIPBOARD = ""; <mask> let PREFER_APP_CLIPBOARD = false; <mask> <mask> export const probablySupportsClipboardReadText = <mask> "clipboard" in navigator && "readText" in navigator.clipboard; </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove import { FlooredNumber } from "../types"; </s> add import { FlooredNumber, AppState } from "../types"; </s> add import { AppState } from "../types"; </s> remove import { hasBackground, hasStroke, hasText, clearSelection } from "../scene"; </s> add import { hasBackground, hasStroke, hasText } from "../scene"; </s> add import { invalidateShapeForElement } from "../renderer/renderElement"; </s> add import { getDefaultAppState } from "./appState"; </s> add import { AppState } from "../types";
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/clipboard.ts
keep keep add keep keep keep keep keep keep
<mask> <mask> export async function copyToAppClipboard( <mask> elements: readonly ExcalidrawElement[], <mask> ) { <mask> CLIPBOARD = JSON.stringify(getSelectedElements(elements, appState)); <mask> try { <mask> // when copying to in-app clipboard, clear system clipboard so that if <mask> // system clip contains text on paste we know it was copied *after* user <mask> // copied elements, and thus we should prefer the text content. </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove CLIPBOARD = JSON.stringify( getSelectedElements(elements).map(({ shape, canvas, ...el }) => el), ); </s> add CLIPBOARD = JSON.stringify(getSelectedElements(elements, appState)); </s> remove if (hitElement?.isSelected) { </s> add if ( hitElement && this.state.selectedElementIds[hitElement.id] ) { </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> add appState: AppState, </s> remove if (!hitElement?.isSelected && !event.shiftKey) { elements = clearSelection(elements); </s> add if ( !( hitElement && this.state.selectedElementIds[hitElement.id] ) && !event.shiftKey ) { this.setState({ selectedElementIds: {} }); </s> remove isSelected: true, </s> add
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/clipboard.ts
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> <mask> export async function copyToAppClipboard( <mask> elements: readonly ExcalidrawElement[], <mask> ) { <mask> CLIPBOARD = JSON.stringify( <mask> getSelectedElements(elements).map(({ shape, canvas, ...el }) => el), <mask> ); <mask> try { <mask> // when copying to in-app clipboard, clear system clipboard so that if <mask> // system clip contains text on paste we know it was copied *after* user <mask> // copied elements, and thus we should prefer the text content. <mask> await copyTextToSystemClipboard(null); </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add appState: AppState, </s> remove if (hitElement?.isSelected) { </s> add if ( hitElement && this.state.selectedElementIds[hitElement.id] ) { </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> remove elements: elements.map(({ shape, canvas, isSelected, ...el }) => el), </s> add elements, </s> remove if (!hitElement?.isSelected && !event.shiftKey) { elements = clearSelection(elements); </s> add if ( !( hitElement && this.state.selectedElementIds[hitElement.id] ) && !event.shiftKey ) { this.setState({ selectedElementIds: {} }); </s> add appState: AppState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/clipboard.ts
keep keep keep replace keep keep keep keep keep
<mask> import React from "react"; <mask> import { ExcalidrawElement } from "../element/types"; <mask> import { ActionManager } from "../actions/manager"; <mask> import { hasBackground, hasStroke, hasText, clearSelection } from "../scene"; <mask> import { t } from "../i18n"; <mask> import { SHAPES } from "../shapes"; <mask> import { ToolButton } from "./ToolButton"; <mask> import { capitalizeString } from "../utils"; <mask> import { CURSOR_TYPE } from "../constants"; </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove import { clearSelection } from "../scene"; </s> add </s> remove import { Drawable } from "roughjs/bin/core"; </s> add </s> remove import { FlooredNumber } from "../types"; </s> add import { FlooredNumber, AppState } from "../types"; </s> add import { AppState } from "../types"; </s> add import { invalidateShapeForElement } from "../renderer/renderElement"; </s> add import { invalidateShapeForElement } from "../renderer/renderElement";
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/Actions.tsx
keep keep keep keep replace replace keep keep keep keep keep
<mask> keyBindingLabel={`${index + 1}`} <mask> aria-label={capitalizeString(label)} <mask> aria-keyshortcuts={`${label[0]} ${index + 1}`} <mask> onChange={() => { <mask> setAppState({ elementType: value, multiElement: null }); <mask> setElements(clearSelection(elements)); <mask> document.documentElement.style.cursor = <mask> value === "text" ? CURSOR_TYPE.TEXT : CURSOR_TYPE.CROSSHAIR; <mask> setAppState({}); <mask> }} <mask> ></ToolButton> </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove this.setState({}); </s> add this.setState({ selectedElementIds: {} }); </s> remove elements = clearSelection(elements); </s> add </s> remove shape: null, canvas: null, canvasOffsetX: element.canvasOffsetX || 0, canvasOffsetY: element.canvasOffsetY || 0, </s> add </s> remove element.canvasOffsetX = </s> add canvasOffsetX = </s> remove elements: deleteSelectedElements(elements), </s> add elements: deleteSelectedElements(elements, appState), </s> remove this.state.draggingElement!.isSelected = true; </s> add
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/Actions.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> getPerfectElementSize, <mask> normalizeDimensions, <mask> } from "../element"; <mask> import { <mask> clearSelection, <mask> deleteSelectedElements, <mask> getElementsWithinSelection, <mask> isOverScrollBars, <mask> getElementAtPosition, <mask> createScene, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove clearSelection, </s> add </s> remove import { clearSelection } from "../scene"; </s> add </s> remove import { FlooredNumber } from "../types"; </s> add import { FlooredNumber, AppState } from "../types"; </s> add import { AppState } from "../types"; </s> add import { AppState } from "../types"; </s> remove import { hasBackground, hasStroke, hasText, clearSelection } from "../scene"; </s> add import { hasBackground, hasStroke, hasText } from "../scene";
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep add keep keep keep keep
<mask> TEXT_TO_CENTER_SNAP_THRESHOLD, <mask> } from "../constants"; <mask> import { LayerUI } from "./LayerUI"; <mask> import { ScrollBars } from "../scene/types"; <mask> <mask> // ----------------------------------------------------------------------------- <mask> // TEST HOOKS <mask> // ----------------------------------------------------------------------------- </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove import { FlooredNumber } from "../types"; </s> add import { FlooredNumber, AppState } from "../types"; </s> remove import { hasBackground, hasStroke, hasText, clearSelection } from "../scene"; </s> add import { hasBackground, hasStroke, hasText } from "../scene"; </s> add import { getShapeForElement } from "../renderer/renderElement"; </s> remove import { clearSelection } from "../scene"; </s> add </s> remove import { Drawable } from "roughjs/bin/core"; </s> add </s> add import { AppState } from "../types"; import { getShapeForElement } from "../renderer/renderElement";
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace replace keep keep keep keep keep
<mask> private onCut = (event: ClipboardEvent) => { <mask> if (isWritableElement(event.target)) { <mask> return; <mask> } <mask> copyToAppClipboard(elements); <mask> elements = deleteSelectedElements(elements); <mask> history.resumeRecording(); <mask> this.setState({}); <mask> event.preventDefault(); <mask> }; <mask> private onCopy = (event: ClipboardEvent) => { </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove copyToAppClipboard(elements); </s> add copyToAppClipboard(elements, this.state); </s> remove copyToAppClipboard(elements); </s> add copyToAppClipboard(elements, this.state); </s> remove this.setState({ elementType }); </s> add </s> remove elements = elements.map(el => ({ ...el, shape: null })); </s> add elements.forEach(element => invalidateShapeForElement(element)); </s> remove elements = clearSelection(elements); </s> add this.setState({ elementType, selectedElementIds: {} }); } else { this.setState({ elementType }); </s> remove this.setState({}); </s> add this.setState({ selectedElementIds: Object.fromEntries( newElements.map(element => [element.id, true]), ), });
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> private onCopy = (event: ClipboardEvent) => { <mask> if (isWritableElement(event.target)) { <mask> return; <mask> } <mask> copyToAppClipboard(elements); <mask> event.preventDefault(); <mask> }; <mask> <mask> private onUnload = () => { <mask> isHoldingSpace = false; </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove copyToAppClipboard(elements); elements = deleteSelectedElements(elements); </s> add copyToAppClipboard(elements, this.state); elements = deleteSelectedElements(elements, this.state); </s> remove copyToAppClipboard(elements); </s> add copyToAppClipboard(elements, this.state); </s> remove this.setState({ elementType }); </s> add </s> remove elements = elements.map(el => ({ ...el, shape: null })); </s> add elements.forEach(element => invalidateShapeForElement(element)); </s> remove elements = clearSelection(elements); </s> add this.setState({ elementType, selectedElementIds: {} }); } else { this.setState({ elementType }); </s> remove this.setState({}); </s> add this.setState({ selectedElementIds: {} });
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> public state: AppState = getDefaultAppState(); <mask> <mask> private onResize = () => { <mask> elements = elements.map(el => ({ ...el, shape: null })); <mask> this.setState({}); <mask> }; <mask> <mask> private updateCurrentCursorPosition = (event: MouseEvent) => { <mask> cursorX = event.x; </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove copyToAppClipboard(elements); elements = deleteSelectedElements(elements); </s> add copyToAppClipboard(elements, this.state); elements = deleteSelectedElements(elements, this.state); </s> remove copyToAppClipboard(elements); </s> add copyToAppClipboard(elements, this.state); </s> remove copyToAppClipboard(elements); </s> add copyToAppClipboard(elements, this.state); </s> remove this.setState({ elementType }); </s> add </s> remove elementsWithinSelection.forEach(element => { element.isSelected = true; }); </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, ...Object.fromEntries( elementsWithinSelection.map(element => [ element.id, true, ]), ), }, })); </s> remove elements = clearSelection(elements); </s> add this.setState({ elementType, selectedElementIds: {} }); } else { this.setState({ elementType });
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> const step = event.shiftKey <mask> ? ELEMENT_SHIFT_TRANSLATE_AMOUNT <mask> : ELEMENT_TRANSLATE_AMOUNT; <mask> elements = elements.map(el => { <mask> if (el.isSelected) { <mask> const element = { ...el }; <mask> if (event.key === KEYS.ARROW_LEFT) { <mask> element.x -= step; <mask> } else if (event.key === KEYS.ARROW_RIGHT) { <mask> element.x += step; </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements = clearSelection(elements); </s> add </s> remove elements = clearSelection(elements); hitElement.isSelected = true; </s> add this.setState(prevState => ({ selectedElementIds: { [hitElement!.id]: true }, })); </s> remove draggingElement.shape = null; </s> add invalidateShapeForElement(draggingElement); </s> remove const getHints = ({ elementType, multiMode, isResizing, elements }: Hint) => { </s> add const getHints = ({ appState, elements }: Hint) => { const { elementType, isResizing } = appState; const multiMode = appState.multiElement !== null; </s> remove if (!element.shape) { </s> add if (!getShapeForElement(element)) { </s> remove elements = clearSelection(elements); this.setState({}); </s> add this.setState({ selectedElementIds: {} });
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep replace keep keep keep keep replace keep
<mask> } else { <mask> elements = clearSelection(elements); <mask> document.documentElement.style.cursor = <mask> this.state.elementType === "text" <mask> ? CURSOR_TYPE.TEXT <mask> : CURSOR_TYPE.CROSSHAIR; <mask> this.setState({}); <mask> } </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove setAppState({ elementType: value, multiElement: null }); setElements(clearSelection(elements)); </s> add setAppState({ elementType: value, multiElement: null, selectedElementIds: {}, }); </s> remove elements = clearSelection(elements); this.setState({}); </s> add this.setState({ selectedElementIds: {} }); </s> remove if (el.isSelected) { </s> add if (this.state.selectedElementIds[el.id]) { </s> remove if (!element.isSelected) { elements = clearSelection(elements); element.isSelected = true; this.setState({}); </s> add if (!this.state.selectedElementIds[element.id]) { this.setState({ selectedElementIds: { [element.id]: true } }); </s> remove draggingElement.shape = null; </s> add invalidateShapeForElement(draggingElement);
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> }; <mask> <mask> private copyToAppClipboard = () => { <mask> copyToAppClipboard(elements); <mask> }; <mask> <mask> private pasteFromClipboard = async (event: ClipboardEvent | null) => { <mask> // #686 <mask> const target = document.activeElement; </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove copyToAppClipboard(elements); </s> add copyToAppClipboard(elements, this.state); </s> remove copyToAppClipboard(elements); elements = deleteSelectedElements(elements); </s> add copyToAppClipboard(elements, this.state); elements = deleteSelectedElements(elements, this.state); </s> remove elements = elements.map(el => ({ ...el, shape: null })); </s> add elements.forEach(element => invalidateShapeForElement(element)); </s> remove this.setState({ elementType }); </s> add </s> remove elements = clearSelection(elements); </s> add this.setState({ elementType, selectedElementIds: {} }); } else { this.setState({ elementType }); </s> remove this.setState({}); </s> add this.setState({ selectedElementIds: Object.fromEntries( newElements.map(element => [element.id, true]), ), });
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> data.text, <mask> this.state.currentItemFont, <mask> ); <mask> <mask> element.isSelected = true; <mask> <mask> elements = [...clearSelection(elements), element]; <mask> history.resumeRecording(); <mask> } <mask> this.selectShapeTool("selection"); <mask> event?.preventDefault(); <mask> } </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove element.shape = null; </s> add invalidateShapeForElement(element); </s> remove multiElement.shape = null; </s> add invalidateShapeForElement(multiElement); </s> remove element.isSelected = false; </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [element.id]: false, }, })); </s> remove if (!element.isSelected) { elements = clearSelection(elements); element.isSelected = true; this.setState({}); </s> add if (!this.state.selectedElementIds[element.id]) { this.setState({ selectedElementIds: { [element.id]: true } }); </s> remove appState.multiElement.isSelected = true; </s> add appState.selectedElementIds[appState.multiElement.id] = true; </s> remove elementsWithinSelection.forEach(element => { element.isSelected = true; }); </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, ...Object.fromEntries( elementsWithinSelection.map(element => [ element.id, true, ]), ), }, }));
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> if (isToolIcon(document.activeElement)) { <mask> document.activeElement.blur(); <mask> } <mask> if (elementType !== "selection") { <mask> elements = clearSelection(elements); <mask> } <mask> this.setState({ elementType }); <mask> } <mask> <mask> private onGestureStart = (event: GestureEvent) => { </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove this.setState({ elementType }); </s> add </s> remove if (!element.isSelected) { elements = clearSelection(elements); element.isSelected = true; this.setState({}); </s> add if (!this.state.selectedElementIds[element.id]) { this.setState({ selectedElementIds: { [element.id]: true } }); </s> remove copyToAppClipboard(elements); elements = deleteSelectedElements(elements); </s> add copyToAppClipboard(elements, this.state); elements = deleteSelectedElements(elements, this.state); </s> remove if (!event.shiftKey && isSomeElementSelected(elements)) { elements = clearSelection(elements); </s> add if ( !event.shiftKey && isSomeElementSelected(elements, this.state) ) { this.setState({ selectedElementIds: {} }); </s> remove draggingElement.shape = null; </s> add invalidateShapeForElement(draggingElement); </s> remove const getHints = ({ elementType, multiMode, isResizing, elements }: Hint) => { </s> add const getHints = ({ appState, elements }: Hint) => { const { elementType, isResizing } = appState; const multiMode = appState.multiElement !== null;
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> if (elementType !== "selection") { <mask> elements = clearSelection(elements); <mask> } <mask> this.setState({ elementType }); <mask> } <mask> <mask> private onGestureStart = (event: GestureEvent) => { <mask> event.preventDefault(); <mask> gesture.initialScale = this.state.zoom; </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements = clearSelection(elements); </s> add this.setState({ elementType, selectedElementIds: {} }); } else { this.setState({ elementType }); </s> remove copyToAppClipboard(elements); elements = deleteSelectedElements(elements); </s> add copyToAppClipboard(elements, this.state); elements = deleteSelectedElements(elements, this.state); </s> remove copyToAppClipboard(elements); </s> add copyToAppClipboard(elements, this.state); </s> remove draggingElement.shape = null; </s> add invalidateShapeForElement(draggingElement); </s> remove if (!element.isSelected) { elements = clearSelection(elements); element.isSelected = true; this.setState({}); </s> add if (!this.state.selectedElementIds[element.id]) { this.setState({ selectedElementIds: { [element.id]: true } }); </s> remove if (!event.shiftKey && isSomeElementSelected(elements)) { elements = clearSelection(elements); </s> add if ( !event.shiftKey && isSomeElementSelected(elements, this.state) ) { this.setState({ selectedElementIds: {} });
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep add keep keep keep keep
<mask> ); <mask> <mask> const element = getElementAtPosition( <mask> elements, <mask> x, <mask> y, <mask> this.state.zoom, <mask> ); </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add this.state, </s> add this.state, </s> add this.state, </s> add this.state, </s> add this.state, </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, );
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace replace replace replace keep keep keep keep keep
<mask> }); <mask> return; <mask> } <mask> <mask> if (!element.isSelected) { <mask> elements = clearSelection(elements); <mask> element.isSelected = true; <mask> this.setState({}); <mask> } <mask> <mask> ContextMenu.push({ <mask> options: [ <mask> navigator.clipboard && { </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements = clearSelection(elements); this.setState({}); </s> add this.setState({ selectedElementIds: {} }); </s> remove elementsWithinSelection.forEach(element => { element.isSelected = true; }); </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, ...Object.fromEntries( elementsWithinSelection.map(element => [ element.id, true, ]), ), }, })); </s> remove hitElement.isSelected = false; </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [hitElement!.id]: false, }, })); </s> remove element.isSelected = true; elements = [...clearSelection(elements), element]; </s> add elements = [...elements, element]; this.setState({ selectedElementIds: { [element.id]: true } }); </s> remove draggingElement.shape = null; </s> add invalidateShapeForElement(draggingElement); </s> remove copyToAppClipboard(elements); elements = deleteSelectedElements(elements); </s> add copyToAppClipboard(elements, this.state); elements = deleteSelectedElements(elements, this.state);
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep add keep keep keep keep keep
<mask> let elementIsAddedToSelection = false; <mask> if (this.state.elementType === "selection") { <mask> const resizeElement = getElementWithResizeHandler( <mask> elements, <mask> { x, y }, <mask> this.state.zoom, <mask> event.pointerType, <mask> ); <mask> </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add this.state, </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> remove if (!event.shiftKey && isSomeElementSelected(elements)) { elements = clearSelection(elements); </s> add if ( !event.shiftKey && isSomeElementSelected(elements, this.state) ) { this.setState({ selectedElementIds: {} }); </s> remove elements = clearSelection(elements); </s> add </s> remove draggingElement.shape = null; </s> add invalidateShapeForElement(draggingElement);
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> this.state.zoom, <mask> event.pointerType, <mask> ); <mask> <mask> const selectedElements = getSelectedElements(elements); <mask> if (selectedElements.length === 1 && resizeElement) { <mask> this.setState({ <mask> resizingElement: resizeElement <mask> ? resizeElement.element <mask> : null, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> add this.state, </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> add this.state, </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements(elements, appState); </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, );
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep add keep keep keep keep
<mask> hitElement = getElementAtPosition( <mask> elements, <mask> x, <mask> y, <mask> this.state.zoom, <mask> ); </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add this.state, </s> add this.state, </s> add this.state, </s> remove if (hitTest(elements[i], x, y, zoom)) { </s> add if (hitTest(elements[i], appState, x, y, zoom)) { </s> add this.state, </s> add this.state,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace replace keep keep keep keep keep
<mask> y, <mask> this.state.zoom, <mask> ); <mask> // clear selection if shift is not clicked <mask> if (!hitElement?.isSelected && !event.shiftKey) { <mask> elements = clearSelection(elements); <mask> } <mask> <mask> // If we click on something <mask> if (hitElement) { <mask> // deselect if item is selected </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove if (!hitElement.isSelected) { hitElement.isSelected = true; </s> add if (!this.state.selectedElementIds[hitElement.id]) { this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [hitElement!.id]: true, }, })); </s> remove elements = clearSelection(elements); this.setState({}); </s> add this.setState({ selectedElementIds: {} }); </s> remove elements = clearSelection(elements); hitElement.isSelected = true; </s> add this.setState(prevState => ({ selectedElementIds: { [hitElement!.id]: true }, })); </s> remove elements = [ ...elements.map(element => ({ ...element, isSelected: false, })), ...getSelectedElements(elements).map(element => { const newElement = duplicateElement(element); newElement.isSelected = true; return newElement; }), ]; </s> add // Move the currently selected elements to the top of the z index stack, and // put the duplicates where the selected elements used to be. const nextElements = []; const elementsToAppend = []; for (const element of elements) { if (this.state.selectedElementIds[element.id]) { nextElements.push(duplicateElement(element)); elementsToAppend.push(element); } else { nextElements.push(element); } } elements = [...nextElements, ...elementsToAppend]; </s> remove if (hitElement?.isSelected) { </s> add if ( hitElement && this.state.selectedElementIds[hitElement.id] ) { </s> remove elements = clearSelection(elements); </s> add this.setState({ selectedElementIds: {} });
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace replace keep keep keep keep keep
<mask> // deselect if item is selected <mask> // if shift is not clicked, this will always return true <mask> // otherwise, it will trigger selection based on current <mask> // state of the box <mask> if (!hitElement.isSelected) { <mask> hitElement.isSelected = true; <mask> elements = elements.slice(); <mask> elementIsAddedToSelection = true; <mask> } <mask> <mask> // We duplicate the selected element if alt is pressed on pointer down </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements = [ ...elements.map(element => ({ ...element, isSelected: false, })), ...getSelectedElements(elements).map(element => { const newElement = duplicateElement(element); newElement.isSelected = true; return newElement; }), ]; </s> add // Move the currently selected elements to the top of the z index stack, and // put the duplicates where the selected elements used to be. const nextElements = []; const elementsToAppend = []; for (const element of elements) { if (this.state.selectedElementIds[element.id]) { nextElements.push(duplicateElement(element)); elementsToAppend.push(element); } else { nextElements.push(element); } } elements = [...nextElements, ...elementsToAppend]; </s> remove if (!hitElement?.isSelected && !event.shiftKey) { elements = clearSelection(elements); </s> add if ( !( hitElement && this.state.selectedElementIds[hitElement.id] ) && !event.shiftKey ) { this.setState({ selectedElementIds: {} }); </s> remove elements = clearSelection(elements); hitElement.isSelected = true; </s> add this.setState(prevState => ({ selectedElementIds: { [hitElement!.id]: true }, })); </s> remove elements = clearSelection(elements); this.setState({}); </s> add this.setState({ selectedElementIds: {} }); </s> remove element.shape = [generator.curve(points, options)]; </s> add shape = [generator.curve(points, options)]; </s> add appState: AppState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep replace keep keep keep keep
<mask> <mask> // We duplicate the selected element if alt is pressed on pointer down <mask> if (event.altKey) { <mask> elements = [ <mask> ...elements.map(element => ({ <mask> ...element, <mask> isSelected: false, <mask> })), <mask> ...getSelectedElements(elements).map(element => { <mask> const newElement = duplicateElement(element); <mask> newElement.isSelected = true; <mask> return newElement; <mask> }), <mask> ]; <mask> } <mask> } <mask> } <mask> } else { <mask> elements = clearSelection(elements); <mask> } <mask> <mask> if (isTextElement(element)) { <mask> // if we're currently still editing text, clicking outside </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove if (!hitElement.isSelected) { hitElement.isSelected = true; </s> add if (!this.state.selectedElementIds[hitElement.id]) { this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [hitElement!.id]: true, }, })); </s> remove elements = clearSelection(elements); hitElement.isSelected = true; </s> add this.setState(prevState => ({ selectedElementIds: { [hitElement!.id]: true }, })); </s> remove elements = clearSelection(elements); this.setState({}); </s> add this.setState({ selectedElementIds: {} }); </s> remove hitElement.isSelected = false; </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [hitElement!.id]: false, }, })); </s> remove if (!element.isSelected) { elements = clearSelection(elements); element.isSelected = true; this.setState({}); </s> add if (!this.state.selectedElementIds[element.id]) { this.setState({ selectedElementIds: { [element.id]: true } });
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> element, <mask> text, <mask> this.state.currentItemFont, <mask> ), <mask> isSelected: true, <mask> }, <mask> ]; <mask> } <mask> if (this.state.elementLocked) { <mask> setCursorForShape(this.state.elementType); </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [element.id]: true, }, })); </s> remove isSelected: true, </s> add </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [element.id]: true, }, })); </s> remove localStorage.setItem( LOCAL_STORAGE_KEY, JSON.stringify( elements.map( ({ shape, canvas, ...element }: ExcalidrawElement) => element, ), ), ); </s> add localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(elements)); </s> remove }); </s> add selectedElementIds: { ...prevState.selectedElementIds, [this.state.draggingElement!.id]: true, }, })); </s> remove elementsWithinSelection.forEach(element => { element.isSelected = true; }); </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, ...Object.fromEntries( elementsWithinSelection.map(element => [ element.id, true, ]), ), }, }));
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep add keep keep keep keep
<mask> ]; <mask> } <mask> if (this.state.elementLocked) { <mask> setCursorForShape(this.state.elementType); <mask> } <mask> history.resumeRecording(); </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove isSelected: true, </s> add </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [element.id]: true, }, })); </s> remove isSelected: true, </s> add </s> remove isSomeElementSelected(elements) </s> add isSomeElementSelected(elements, this.state) </s> remove element.isSelected = true; elements = [...clearSelection(elements), element]; </s> add elements = [...elements, element]; this.setState({ selectedElementIds: { [element.id]: true } }); </s> remove this.setState({}); </s> add this.setState({ selectedElementIds: Object.fromEntries( newElements.map(element => [element.id, true]), ), });
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep replace keep replace keep
<mask> const { multiElement } = this.state; <mask> const { x: rx, y: ry } = multiElement; <mask> multiElement.isSelected = true; <mask> multiElement.points.push([x - rx, y - ry]); <mask> multiElement.shape = null; <mask> } else { </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove element.isSelected = false; </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [element.id]: false, }, })); </s> remove draggingElement.shape = null; </s> add invalidateShapeForElement(draggingElement); </s> remove multiElement.shape = null; </s> add invalidateShapeForElement(multiElement); </s> remove element.shape = null; </s> add invalidateShapeForElement(element); </s> remove elements = [ ...elements, ...clipboardElements.map(clipboardElements => { const duplicate = duplicateElement(clipboardElements); duplicate.x += dx - minX; duplicate.y += dy - minY; return duplicate; }), ]; </s> add const newElements = clipboardElements.map(clipboardElements => { const duplicate = duplicateElement(clipboardElements); duplicate.x += dx - minX; duplicate.y += dy - minY; return duplicate; }); elements = [...elements, ...newElements];
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep replace keep replace keep keep keep keep
<mask> multiElement.shape = null; <mask> } else { <mask> element.isSelected = false; <mask> element.points.push([0, 0]); <mask> element.shape = null; <mask> elements = [...elements, element]; <mask> this.setState({ <mask> draggingElement: element, <mask> }); </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove multiElement.shape = null; </s> add invalidateShapeForElement(multiElement); </s> remove element.isSelected = true; elements = [...clearSelection(elements), element]; </s> add elements = [...elements, element]; this.setState({ selectedElementIds: { [element.id]: true } }); </s> remove multiElement.isSelected = true; </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [multiElement.id]: true, }, })); </s> remove this.state.draggingElement!.isSelected = true; </s> add </s> remove this.setState({ </s> add this.setState(prevState => ({
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> if (isResizingElements && this.state.resizingElement) { <mask> this.setState({ isResizing: true }); <mask> const el = this.state.resizingElement; <mask> const selectedElements = getSelectedElements(elements); <mask> if (selectedElements.length === 1) { <mask> const { x, y } = viewportCoordsToSceneCoords( <mask> event, <mask> this.state, <mask> this.canvas, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> add this.state, </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements(elements, appState); </s> add this.state,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> { element, resizeHandle }, <mask> ); <mask> el.x = element.x; <mask> el.y = element.y; <mask> el.shape = null; <mask> <mask> lastX = x; <mask> lastY = y; <mask> this.setState({}); <mask> return; </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove const resizeHandle = resizeTest(element, x, y, zoom, pointerType); </s> add const resizeHandle = resizeTest(element, appState, x, y, zoom, pointerType); </s> remove multiElement.shape = null; </s> add invalidateShapeForElement(multiElement); </s> remove element.shape = null; </s> add invalidateShapeForElement(element); </s> remove element.isSelected = false; </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [element.id]: false, }, })); </s> remove copyToAppClipboard(elements); elements = deleteSelectedElements(elements); </s> add copyToAppClipboard(elements, this.state); elements = deleteSelectedElements(elements, this.state); </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, );
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep replace keep keep keep replace keep keep keep keep
<mask> } <mask> } <mask> <mask> if (hitElement?.isSelected) { <mask> // Marking that click was used for dragging to check <mask> // if elements should be deselected on pointerup <mask> draggingOccurred = true; <mask> const selectedElements = getSelectedElements(elements); <mask> if (selectedElements.length > 0) { <mask> const { x, y } = viewportCoordsToSceneCoords( <mask> event, <mask> this.state, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> remove elements = [ ...elements.map(element => ({ ...element, isSelected: false, })), ...getSelectedElements(elements).map(element => { const newElement = duplicateElement(element); newElement.isSelected = true; return newElement; }), ]; </s> add // Move the currently selected elements to the top of the z index stack, and // put the duplicates where the selected elements used to be. const nextElements = []; const elementsToAppend = []; for (const element of elements) { if (this.state.selectedElementIds[element.id]) { nextElements.push(duplicateElement(element)); elementsToAppend.push(element); } else { nextElements.push(element); } } elements = [...nextElements, ...elementsToAppend]; </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements(elements, appState); </s> remove if (hitTest(elements[i], x, y, zoom)) { </s> add if (hitTest(elements[i], appState, x, y, zoom)) {
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> draggingElement.width = width; <mask> draggingElement.height = height; <mask> } <mask> <mask> draggingElement.shape = null; <mask> <mask> if (this.state.elementType === "selection") { <mask> if (!event.shiftKey && isSomeElementSelected(elements)) { <mask> elements = clearSelection(elements); <mask> } </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove if (!event.shiftKey && isSomeElementSelected(elements)) { elements = clearSelection(elements); </s> add if ( !event.shiftKey && isSomeElementSelected(elements, this.state) ) { this.setState({ selectedElementIds: {} }); </s> remove elements = clearSelection(elements); </s> add </s> remove this.setState({ elementType }); </s> add </s> remove elements = clearSelection(elements); </s> add this.setState({ elementType, selectedElementIds: {} }); } else { this.setState({ elementType }); </s> remove this.state.draggingElement!.isSelected = true; </s> add </s> remove hitElement.isSelected = false; </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [hitElement!.id]: false, }, }));
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace replace keep keep keep keep keep
<mask> <mask> draggingElement.shape = null; <mask> <mask> if (this.state.elementType === "selection") { <mask> if (!event.shiftKey && isSomeElementSelected(elements)) { <mask> elements = clearSelection(elements); <mask> } <mask> const elementsWithinSelection = getElementsWithinSelection( <mask> elements, <mask> draggingElement, <mask> ); </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove draggingElement.shape = null; </s> add invalidateShapeForElement(draggingElement); </s> remove elements = clearSelection(elements); </s> add </s> add this.state, </s> remove elementsWithinSelection.forEach(element => { element.isSelected = true; }); </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, ...Object.fromEntries( elementsWithinSelection.map(element => [ element.id, true, ]), ), }, })); </s> remove this.setState({ elementType }); </s> add </s> remove this.state.draggingElement!.isSelected = true; </s> add
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> const elementsWithinSelection = getElementsWithinSelection( <mask> elements, <mask> draggingElement, <mask> ); <mask> elementsWithinSelection.forEach(element => { <mask> element.isSelected = true; <mask> }); <mask> } <mask> this.setState({}); <mask> }; <mask> <mask> const onPointerUp = (event: PointerEvent) => { </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove if (!event.shiftKey && isSomeElementSelected(elements)) { elements = clearSelection(elements); </s> add if ( !event.shiftKey && isSomeElementSelected(elements, this.state) ) { this.setState({ selectedElementIds: {} }); </s> remove if (!element.isSelected) { elements = clearSelection(elements); element.isSelected = true; this.setState({}); </s> add if (!this.state.selectedElementIds[element.id]) { this.setState({ selectedElementIds: { [element.id]: true } }); </s> remove copyToAppClipboard(elements); elements = deleteSelectedElements(elements); </s> add copyToAppClipboard(elements, this.state); elements = deleteSelectedElements(elements, this.state); </s> remove element.isSelected = true; elements = [...clearSelection(elements), element]; </s> add elements = [...elements, element]; this.setState({ selectedElementIds: { [element.id]: true } }); </s> remove multiElement.shape = null; </s> add invalidateShapeForElement(multiElement); </s> remove elements = elements.map(el => ({ ...el, shape: null })); </s> add elements.forEach(element => invalidateShapeForElement(element));
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep replace keep keep replace keep keep keep
<mask> x - draggingElement.x, <mask> y - draggingElement.y, <mask> ]); <mask> draggingElement.shape = null; <mask> this.setState({ multiElement: this.state.draggingElement }); <mask> } else if (draggingOccurred && !multiElement) { <mask> this.state.draggingElement!.isSelected = true; <mask> if (!elementLocked) { <mask> resetCursor(); <mask> this.setState({ </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove this.setState({ </s> add this.setState(prevState => ({ </s> remove element.isSelected = false; </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [element.id]: false, }, })); </s> remove if (isElementDraggableFromInside(element)) { </s> add if (isElementDraggableFromInside(element, appState)) { </s> remove multiElement.shape = null; </s> add invalidateShapeForElement(multiElement); </s> remove multiElement.isSelected = true; </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [multiElement.id]: true, }, }));
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep replace
<mask> } else if (draggingOccurred && !multiElement) { <mask> this.state.draggingElement!.isSelected = true; <mask> if (!elementLocked) { <mask> resetCursor(); <mask> this.setState({ <mask> draggingElement: null, <mask> elementType: "selection", <mask> }); </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove this.state.draggingElement!.isSelected = true; </s> add </s> remove draggingElement.shape = null; </s> add invalidateShapeForElement(draggingElement); </s> remove this.setState({ </s> add this.setState(prevState => ({ </s> remove }); </s> add selectedElementIds: { ...prevState.selectedElementIds, [this.state.draggingElement!.id]: true, }, })); </s> remove if (!element.isSelected) { elements = clearSelection(elements); element.isSelected = true; this.setState({}); </s> add if (!this.state.selectedElementIds[element.id]) { this.setState({ selectedElementIds: { [element.id]: true } });
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> draggingElement: null, <mask> elementType: "selection", <mask> }); <mask> } else { <mask> this.setState({ <mask> draggingElement: null, <mask> }); <mask> } <mask> } <mask> return; </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove }); </s> add selectedElementIds: { ...prevState.selectedElementIds, [this.state.draggingElement!.id]: true, }, })); </s> remove this.setState({ </s> add this.setState(prevState => ({ </s> remove }); </s> add selectedElementIds: { ...prevState.selectedElementIds, [this.state.draggingElement!.id]: true, }, })); </s> remove this.state.draggingElement!.isSelected = true; </s> add </s> remove element.shape = null; </s> add invalidateShapeForElement(element); </s> remove elements = clearSelection(elements); </s> add this.setState({ elementType, selectedElementIds: {} }); } else { this.setState({ elementType });
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> }); <mask> } else { <mask> this.setState({ <mask> draggingElement: null, <mask> }); <mask> } <mask> } <mask> return; <mask> } <mask> </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove this.setState({ </s> add this.setState(prevState => ({ </s> remove }); </s> add selectedElementIds: { ...prevState.selectedElementIds, [this.state.draggingElement!.id]: true, }, })); </s> remove this.setState({ </s> add this.setState(prevState => ({ </s> remove this.state.draggingElement!.isSelected = true; </s> add </s> remove elements = clearSelection(elements); </s> add this.setState({ elementType, selectedElementIds: {} }); } else { this.setState({ elementType }); </s> remove element.shape = null; </s> add invalidateShapeForElement(element);
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep replace keep replace replace keep keep keep keep
<mask> !elementIsAddedToSelection <mask> ) { <mask> if (event.shiftKey) { <mask> hitElement.isSelected = false; <mask> } else { <mask> elements = clearSelection(elements); <mask> hitElement.isSelected = true; <mask> } <mask> } <mask> <mask> if (draggingElement === null) { </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements = clearSelection(elements); this.setState({}); </s> add this.setState({ selectedElementIds: {} }); </s> remove elements = clearSelection(elements); </s> add </s> remove if (!element.isSelected) { elements = clearSelection(elements); element.isSelected = true; this.setState({}); </s> add if (!this.state.selectedElementIds[element.id]) { this.setState({ selectedElementIds: { [element.id]: true } }); </s> remove multiElement.isSelected = true; </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [multiElement.id]: true, }, })); </s> remove draggingElement.shape = null; </s> add invalidateShapeForElement(draggingElement);
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace replace keep keep keep keep replace
<mask> } <mask> <mask> if (draggingElement === null) { <mask> // if no element is clicked, clear the selection and redraw <mask> elements = clearSelection(elements); <mask> this.setState({}); <mask> return; <mask> } <mask> <mask> if (!elementLocked) { <mask> draggingElement.isSelected = true; </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements = clearSelection(elements); hitElement.isSelected = true; </s> add this.setState(prevState => ({ selectedElementIds: { [hitElement!.id]: true }, })); </s> remove if (!hitElement.isSelected) { hitElement.isSelected = true; </s> add if (!this.state.selectedElementIds[hitElement.id]) { this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [hitElement!.id]: true, }, })); </s> remove elements = [ ...elements.map(element => ({ ...element, isSelected: false, })), ...getSelectedElements(elements).map(element => { const newElement = duplicateElement(element); newElement.isSelected = true; return newElement; }), ]; </s> add // Move the currently selected elements to the top of the z index stack, and // put the duplicates where the selected elements used to be. const nextElements = []; const elementsToAppend = []; for (const element of elements) { if (this.state.selectedElementIds[element.id]) { nextElements.push(duplicateElement(element)); elementsToAppend.push(element); } else { nextElements.push(element); } } elements = [...nextElements, ...elementsToAppend]; </s> remove if (!element.isSelected) { elements = clearSelection(elements); element.isSelected = true; this.setState({}); </s> add if (!this.state.selectedElementIds[element.id]) { this.setState({ selectedElementIds: { [element.id]: true } }); </s> remove if (!hitElement?.isSelected && !event.shiftKey) { elements = clearSelection(elements); </s> add if ( !( hitElement && this.state.selectedElementIds[hitElement.id] ) && !event.shiftKey ) { this.setState({ selectedElementIds: {} });
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> if ( <mask> elementType !== "selection" || <mask> isSomeElementSelected(elements) <mask> ) { <mask> history.resumeRecording(); <mask> } <mask> <mask> if (!elementLocked) { </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove draggingElement.isSelected = true; </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [draggingElement.id]: true, }, })); </s> remove elements = clearSelection(elements); </s> add this.setState({ elementType, selectedElementIds: {} }); } else { this.setState({ elementType }); </s> remove this.setState({ elementType }); </s> add </s> remove if (!element.canvas || element.canvasZoom !== zoom) { generateElementCanvas(element, zoom); </s> add const prevElementWithCanvas = elementWithCanvasCache.get(element); if (!prevElementWithCanvas || prevElementWithCanvas.canvasZoom !== zoom) { return generateElementCanvas(element, zoom); </s> remove function isElementDraggableFromInside(element: ExcalidrawElement): boolean { return element.backgroundColor !== "transparent" || element.isSelected; </s> add function isElementDraggableFromInside( element: ExcalidrawElement, appState: AppState, ): boolean { return ( element.backgroundColor !== "transparent" || appState.selectedElementIds[element.id] ); </s> remove const getHints = ({ elementType, multiMode, isResizing, elements }: Hint) => { </s> add const getHints = ({ appState, elements }: Hint) => { const { elementType, isResizing } = appState; const multiMode = appState.multiElement !== null;
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep add keep keep keep keep keep
<mask> <mask> const elementAtPosition = getElementAtPosition( <mask> elements, <mask> x, <mask> y, <mask> this.state.zoom, <mask> ); <mask> </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add this.state, </s> add this.state, </s> add this.state, </s> add this.state, </s> add this.state, </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, );
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> { <mask> // we need to recreate the element to update dimensions & <mask> // position <mask> ...newTextElement(element, text, element.font), <mask> isSelected: true, <mask> }, <mask> ]; <mask> } <mask> history.resumeRecording(); <mask> resetSelection(); </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [element.id]: true, }, })); </s> add import { getShapeForElement } from "../renderer/renderElement"; </s> remove isSelected: true, </s> add </s> remove elements = [ ...elements.map(element => ({ ...element, isSelected: false, })), ...getSelectedElements(elements).map(element => { const newElement = duplicateElement(element); newElement.isSelected = true; return newElement; }), ]; </s> add // Move the currently selected elements to the top of the z index stack, and // put the duplicates where the selected elements used to be. const nextElements = []; const elementsToAppend = []; for (const element of elements) { if (this.state.selectedElementIds[element.id]) { nextElements.push(duplicateElement(element)); elementsToAppend.push(element); } else { nextElements.push(element); } } elements = [...nextElements, ...elementsToAppend]; </s> remove if (hitTest(elements[i], x, y, zoom)) { </s> add if (hitTest(elements[i], appState, x, y, zoom)) { </s> add appState: AppState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep add keep keep keep keep keep keep
<mask> }, <mask> ]; <mask> } <mask> history.resumeRecording(); <mask> resetSelection(); <mask> }, <mask> onCancel: () => { <mask> resetSelection(); <mask> }, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove isSelected: true, </s> add </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [element.id]: true, }, })); </s> remove isSelected: true, </s> add </s> add appState, </s> add }, "engines": { "node": ">=12.0.0" </s> remove this.setState({}); </s> add this.setState({ selectedElementIds: Object.fromEntries( newElements.map(element => [element.id, true]), ), });
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> const points = multiElement.points; <mask> const pnt = points[points.length - 1]; <mask> pnt[0] = x - originX; <mask> pnt[1] = y - originY; <mask> multiElement.shape = null; <mask> this.setState({}); <mask> return; <mask> } <mask> <mask> const hasDeselectedButton = Boolean(event.buttons); </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove multiElement.shape = null; </s> add invalidateShapeForElement(multiElement); </s> remove elements = [ ...elements, ...clipboardElements.map(clipboardElements => { const duplicate = duplicateElement(clipboardElements); duplicate.x += dx - minX; duplicate.y += dy - minY; return duplicate; }), ]; </s> add const newElements = clipboardElements.map(clipboardElements => { const duplicate = duplicateElement(clipboardElements); duplicate.x += dx - minX; duplicate.y += dy - minY; return duplicate; }); elements = [...elements, ...newElements]; </s> remove element.isSelected = false; </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [element.id]: false, }, })); </s> remove draggingElement.shape = null; </s> add invalidateShapeForElement(draggingElement); </s> remove multiElement.isSelected = true; </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [multiElement.id]: true, }, })); </s> remove if (isElementDraggableFromInside(element)) { </s> add if (isElementDraggableFromInside(element, appState)) {
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> ) { <mask> return; <mask> } <mask> <mask> const selectedElements = getSelectedElements(elements); <mask> if (selectedElements.length === 1 && !isOverScrollBar) { <mask> const resizeElement = getElementWithResizeHandler( <mask> elements, <mask> { x, y }, <mask> this.state.zoom, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add this.state, </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> add this.state, </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements(elements, appState); </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, );
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep add keep keep keep keep keep keep
<mask> ); <mask> if (selectedElements.length === 1 && !isOverScrollBar) { <mask> const resizeElement = getElementWithResizeHandler( <mask> elements, <mask> { x, y }, <mask> this.state.zoom, <mask> event.pointerType, <mask> ); <mask> if (resizeElement && resizeElement.resizeHandle) { <mask> document.documentElement.style.cursor = getCursorForResizingElement( </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> add this.state, </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> remove if (!event.shiftKey && isSomeElementSelected(elements)) { elements = clearSelection(elements); </s> add if ( !event.shiftKey && isSomeElementSelected(elements, this.state) ) { this.setState({ selectedElementIds: {} }); </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, );
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep add keep keep keep keep
<mask> } <mask> } <mask> const hitElement = getElementAtPosition( <mask> elements, <mask> x, <mask> y, <mask> this.state.zoom, <mask> ); </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add this.state, </s> add this.state, </s> add this.state, </s> remove if (hitTest(elements[i], x, y, zoom)) { </s> add if (hitTest(elements[i], appState, x, y, zoom)) { </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> add this.state,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace replace keep keep keep keep keep
<mask> <mask> private addElementsFromPaste = ( <mask> clipboardElements: readonly ExcalidrawElement[], <mask> ) => { <mask> elements = clearSelection(elements); <mask> <mask> const [minX, minY, maxX, maxY] = getCommonBounds(clipboardElements); <mask> <mask> const elementsCenterX = distance(minX, maxX) / 2; <mask> const elementsCenterY = distance(minY, maxY) / 2; <mask> </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements(elements, appState); </s> add let canvasOffsetX = 0; let canvasOffsetY = 0; </s> remove element.shape = generator.ellipse( </s> add shape = generator.ellipse( </s> remove this.setState({ elementType }); </s> add </s> remove if (!event.shiftKey && isSomeElementSelected(elements)) { elements = clearSelection(elements); </s> add if ( !event.shiftKey && isSomeElementSelected(elements, this.state) ) { this.setState({ selectedElementIds: {} }); </s> remove element.canvasOffsetX = </s> add canvasOffsetX =
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace replace replace replace replace replace replace replace replace keep replace keep keep keep
<mask> <mask> const dx = x - elementsCenterX; <mask> const dy = y - elementsCenterY; <mask> <mask> elements = [ <mask> ...elements, <mask> ...clipboardElements.map(clipboardElements => { <mask> const duplicate = duplicateElement(clipboardElements); <mask> duplicate.x += dx - minX; <mask> duplicate.y += dy - minY; <mask> return duplicate; <mask> }), <mask> ]; <mask> history.resumeRecording(); <mask> this.setState({}); <mask> }; <mask> <mask> private getTextWysiwygSnappedToCenterPosition(x: number, y: number) { </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove multiElement.shape = null; </s> add invalidateShapeForElement(multiElement); </s> remove multiElement.shape = null; </s> add invalidateShapeForElement(multiElement); </s> remove draggingElement.shape = null; </s> add invalidateShapeForElement(draggingElement); </s> remove if (isElementDraggableFromInside(element)) { </s> add if (isElementDraggableFromInside(element, appState)) { </s> remove multiElement.isSelected = true; </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [multiElement.id]: true, }, }));
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep add keep keep keep keep keep
<mask> <mask> componentDidUpdate() { <mask> const { atLeastOneVisibleElement, scrollBars } = renderScene( <mask> elements, <mask> this.state.selectionElement, <mask> this.rc!, <mask> this.canvas!, <mask> { <mask> scrollX: this.state.scrollX, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add appState, </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> remove elementType, multiMode, isResizing, </s> add appState, </s> add import { getDefaultAppState } from "./appState"; </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> remove multiElement.isSelected = true; </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [multiElement.id]: true, }, }));
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> onExportToClipboard: ExportCB; <mask> onExportToBackend: ExportCB; <mask> onCloseRequest: () => void; <mask> }) { <mask> const someElementIsSelected = isSomeElementSelected(elements); <mask> const [scale, setScale] = useState(defaultScale); <mask> const [exportSelected, setExportSelected] = useState(someElementIsSelected); <mask> const previewRef = useRef<HTMLDivElement>(null); <mask> const { exportBackground, viewBackgroundColor } = appState; <mask> const pngButton = useRef<HTMLButtonElement>(null); </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove const tempCanvas = exportToCanvas(elements, { </s> add const tempCanvas = exportToCanvas(elements, appState, { </s> remove const canvas = exportToCanvas(exportedElements, { </s> add const canvas = exportToCanvas(exportedElements, appState, { </s> remove ? getSelectedElements(elements) </s> add ? getSelectedElements(elements, appState) </s> remove const getHints = ({ elementType, multiMode, isResizing, elements }: Hint) => { </s> add const getHints = ({ appState, elements }: Hint) => { const { elementType, isResizing } = appState; const multiMode = appState.multiElement !== null; </s> remove expect(h.elements[0].isSelected).toBeTruthy(); </s> add expect(h.appState.selectedElementIds[h.elements[0].id]).toBeTruthy(); </s> remove expect(h.elements[0].isSelected).toBeTruthy(); </s> add expect(h.appState.selectedElementIds[h.elements[0].id]).toBeTruthy();
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/ExportDialog.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> const closeButton = useRef<HTMLButtonElement>(null); <mask> const onlySelectedInput = useRef<HTMLInputElement>(null); <mask> <mask> const exportedElements = exportSelected <mask> ? getSelectedElements(elements) <mask> : elements; <mask> <mask> useEffect(() => { <mask> setExportSelected(someElementIsSelected); <mask> }, [someElementIsSelected]); </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove const canvas = exportToCanvas(exportedElements, { </s> add const canvas = exportToCanvas(exportedElements, appState, { </s> remove const someElementIsSelected = isSomeElementSelected(elements); </s> add const someElementIsSelected = isSomeElementSelected(elements, appState); </s> add shapeCache.set(element, shape); </s> remove export function clearSelection(elements: readonly ExcalidrawElement[]) { let someWasSelected = false; elements.forEach(element => { if (element.isSelected) { someWasSelected = true; element.isSelected = false; } }); return someWasSelected ? elements.slice() : elements; } export function deleteSelectedElements(elements: readonly ExcalidrawElement[]) { return elements.filter(el => !el.isSelected); </s> add export function deleteSelectedElements( elements: readonly ExcalidrawElement[], appState: AppState, ) { return elements.filter(el => !appState.selectedElementIds[el.id]); </s> remove if (el.isSelected) { </s> add if (this.state.selectedElementIds[el.id]) { </s> remove let newElements = clearSelection(elements); </s> add let newElements = elements;
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/ExportDialog.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> }, [someElementIsSelected]); <mask> <mask> useEffect(() => { <mask> const previewNode = previewRef.current; <mask> const canvas = exportToCanvas(exportedElements, { <mask> exportBackground, <mask> viewBackgroundColor, <mask> exportPadding, <mask> scale, <mask> }); </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove const tempCanvas = exportToCanvas(elements, { </s> add const tempCanvas = exportToCanvas(elements, appState, { </s> add appState, </s> remove ? getSelectedElements(elements) </s> add ? getSelectedElements(elements, appState) </s> add appState: AppState, </s> add appState: AppState, </s> add getDefaultAppState(),
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/ExportDialog.tsx
keep keep keep add keep keep keep keep
<mask> return () => { <mask> previewNode?.removeChild(canvas); <mask> }; <mask> }, [ <mask> exportedElements, <mask> exportBackground, <mask> exportPadding, <mask> viewBackgroundColor, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove const canvas = exportToCanvas(exportedElements, { </s> add const canvas = exportToCanvas(exportedElements, appState, { </s> remove const tempCanvas = exportToCanvas(elements, { </s> add const tempCanvas = exportToCanvas(elements, appState, { </s> add appState: AppState, </s> add appState: AppState, </s> remove exportCanvas(type, exportedElements, canvas, { </s> add exportCanvas(type, exportedElements, appState, canvas, { </s> remove elements: moveAllLeft([...elements], getSelectedIndices(elements)), </s> add elements: moveAllLeft( [...elements], getSelectedIndices(elements, appState), ),
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/ExportDialog.tsx
keep add keep keep keep keep
<mask> <mask> import "./HintViewer.css"; <mask> <mask> interface Hint { <mask> appState: AppState; <mask> elements: readonly ExcalidrawElement[]; </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elementType: string; multiMode: boolean; isResizing: boolean; </s> add appState: AppState; </s> add import { AppState } from "../types"; </s> add appState: AppState, </s> add import { AppState } from "../types"; </s> add appState: AppState, </s> add import { AppState } from "../types"; import { getShapeForElement } from "../renderer/renderElement";
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/HintViewer.tsx
keep keep keep replace replace replace keep keep keep replace keep
<mask> import "./HintViewer.css"; <mask> <mask> interface Hint { <mask> elementType: string; <mask> multiMode: boolean; <mask> isResizing: boolean; <mask> elements: readonly ExcalidrawElement[]; <mask> } <mask> <mask> const getHints = ({ elementType, multiMode, isResizing, elements }: Hint) => { <mask> if (elementType === "arrow" || elementType === "line") { </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add import { AppState } from "../types"; </s> remove export const HintViewer = ({ elementType, multiMode, isResizing, elements, }: Hint) => { </s> add export const HintViewer = ({ appState, elements }: Hint) => { </s> remove elementType, multiMode, isResizing, </s> add appState, </s> add import { invalidateShapeForElement } from "../renderer/renderElement"; </s> remove elements = clearSelection(elements); </s> add this.setState({ elementType, selectedElementIds: {} }); } else { this.setState({ elementType });
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/HintViewer.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> return t("hints.linearElementMulti"); <mask> } <mask> <mask> if (isResizing) { <mask> const selectedElements = getSelectedElements(elements); <mask> if ( <mask> selectedElements.length === 1 && <mask> (selectedElements[0].type === "arrow" || <mask> selectedElements[0].type === "line") && <mask> selectedElements[0].points.length > 2 </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, ); </s> remove const shape = element.shape as Drawable[]; </s> add const shape = getShapeForElement(element) as Drawable[]; </s> remove const getHints = ({ elementType, multiMode, isResizing, elements }: Hint) => { </s> add const getHints = ({ appState, elements }: Hint) => { const { elementType, isResizing } = appState; const multiMode = appState.multiElement !== null; </s> add import { invalidateShapeForElement } from "../renderer/renderElement"; </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, );
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/HintViewer.tsx
keep keep keep keep replace replace replace replace replace replace keep replace replace replace keep
<mask> <mask> return null; <mask> }; <mask> <mask> export const HintViewer = ({ <mask> elementType, <mask> multiMode, <mask> isResizing, <mask> elements, <mask> }: Hint) => { <mask> const hint = getHints({ <mask> elementType, <mask> multiMode, <mask> isResizing, <mask> elements, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove const getHints = ({ elementType, multiMode, isResizing, elements }: Hint) => { </s> add const getHints = ({ appState, elements }: Hint) => { const { elementType, isResizing } = appState; const multiMode = appState.multiElement !== null; </s> remove elementType: string; multiMode: boolean; isResizing: boolean; </s> add appState: AppState; </s> remove elements = clearSelection(elements); </s> add this.setState({ elementType, selectedElementIds: {} }); } else { this.setState({ elementType }); </s> remove elementsWithinSelection.forEach(element => { element.isSelected = true; }); </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, ...Object.fromEntries( elementsWithinSelection.map(element => [ element.id, true, ]), ), }, })); </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements( elements, this.state, );
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/HintViewer.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> exportedElements, <mask> scale, <mask> ) => { <mask> if (canvas) { <mask> exportCanvas(type, exportedElements, canvas, { <mask> exportBackground: appState.exportBackground, <mask> name: appState.name, <mask> viewBackgroundColor: appState.viewBackgroundColor, <mask> scale, <mask> }); </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove exportedElements.map(element => ({ ...element, isSelected: false, })), </s> add exportedElements, { ...appState, selectedElementIds: {}, }, </s> remove const tempCanvas = exportToCanvas(elements, { </s> add const tempCanvas = exportToCanvas(elements, appState, { </s> add getDefaultAppState(), </s> remove const canvas = exportToCanvas(exportedElements, { </s> add const canvas = exportToCanvas(exportedElements, appState, { </s> add appState, </s> remove perform: elements => { </s> add perform: (elements, appState) => {
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/LayerUI.tsx
keep keep keep keep replace replace replace replace keep keep keep keep keep
<mask> onExportToBackend={exportedElements => { <mask> if (canvas) { <mask> exportCanvas( <mask> "backend", <mask> exportedElements.map(element => ({ <mask> ...element, <mask> isSelected: false, <mask> })), <mask> canvas, <mask> appState, <mask> ); <mask> } <mask> }} </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove exportCanvas(type, exportedElements, canvas, { </s> add exportCanvas(type, exportedElements, appState, canvas, { </s> remove elements = [ ...elements.map(element => ({ ...element, isSelected: false, })), ...getSelectedElements(elements).map(element => { const newElement = duplicateElement(element); newElement.isSelected = true; return newElement; }), ]; </s> add // Move the currently selected elements to the top of the z index stack, and // put the duplicates where the selected elements used to be. const nextElements = []; const elementsToAppend = []; for (const element of elements) { if (this.state.selectedElementIds[element.id]) { nextElements.push(duplicateElement(element)); elementsToAppend.push(element); } else { nextElements.push(element); } } elements = [...nextElements, ...elementsToAppend]; </s> remove perform: elements => { </s> add perform: (elements, appState) => { </s> remove hitElement.isSelected = false; </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [hitElement!.id]: false, }, })); </s> remove elements: elements.map(({ shape, canvas, ...element }) => ({ </s> add elements: elements.map(element => ({ </s> remove shape: null, canvas: null, </s> add
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/LayerUI.tsx
keep keep keep keep replace replace replace replace replace replace keep keep keep keep keep
<mask> /> <mask> ) : ( <mask> <> <mask> <FixedSideContainer side="top"> <mask> <HintViewer <mask> elementType={appState.elementType} <mask> multiMode={appState.multiElement !== null} <mask> isResizing={appState.isResizing} <mask> elements={elements} <mask> /> <mask> <div className="App-menu App-menu_top"> <mask> <Stack.Col gap={4} align="end"> <mask> <Section className="App-right-menu" heading="canvasActions"> <mask> <Island padding={4}> <mask> <Stack.Col gap={4}> </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove <HintViewer elementType={appState.elementType} multiMode={appState.multiElement !== null} isResizing={appState.isResizing} elements={elements} /> </s> add <HintViewer appState={appState} elements={elements} /> </s> remove targetElements={getTargetElement( appState.editingElement, elements, )} </s> add targetElements={getTargetElement(elements, appState)} </s> remove targetElements={getTargetElement( appState.editingElement, elements, )} </s> add targetElements={getTargetElement(elements, appState)} </s> add appState, </s> remove isSomeElementSelected(elements) </s> add isSomeElementSelected(elements, this.state) </s> add appState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/LayerUI.tsx
keep keep keep keep replace replace replace replace keep keep keep keep keep
<mask> heading="selectedShapeActions" <mask> > <mask> <Island padding={4}> <mask> <SelectedShapeActions <mask> targetElements={getTargetElement( <mask> appState.editingElement, <mask> elements, <mask> )} <mask> renderAction={actionManager.renderAction} <mask> elementType={appState.elementType} <mask> /> <mask> </Island> <mask> </Section> </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove targetElements={getTargetElement( appState.editingElement, elements, )} </s> add targetElements={getTargetElement(elements, appState)} </s> remove <HintViewer elementType={appState.elementType} multiMode={appState.multiElement !== null} isResizing={appState.isResizing} elements={elements} /> </s> add <HintViewer appState={appState} elements={elements} /> </s> remove <HintViewer elementType={appState.elementType} multiMode={appState.multiElement !== null} isResizing={appState.isResizing} elements={elements} /> </s> add <HintViewer appState={appState} elements={elements} /> </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> add appState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/LayerUI.tsx
keep keep keep keep replace replace replace replace keep keep keep keep keep
<mask> showSelectedShapeActions(appState, elements) ? ( <mask> <Section className="App-mobile-menu" heading="selectedShapeActions"> <mask> <div className="App-mobile-menu-scroller"> <mask> <SelectedShapeActions <mask> targetElements={getTargetElement( <mask> appState.editingElement, <mask> elements, <mask> )} <mask> renderAction={actionManager.renderAction} <mask> elementType={appState.elementType} <mask> /> <mask> </div> <mask> </Section> </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove targetElements={getTargetElement( appState.editingElement, elements, )} </s> add targetElements={getTargetElement(elements, appState)} </s> remove <HintViewer elementType={appState.elementType} multiMode={appState.multiElement !== null} isResizing={appState.isResizing} elements={elements} /> </s> add <HintViewer appState={appState} elements={elements} /> </s> remove <HintViewer elementType={appState.elementType} multiMode={appState.multiElement !== null} isResizing={appState.isResizing} elements={elements} /> </s> add <HintViewer appState={appState} elements={elements} /> </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> add appState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/MobileMenu.tsx
keep keep keep keep replace replace replace replace replace replace keep keep keep keep keep
<mask> </Stack.Row> <mask> </Stack.Col> <mask> )} <mask> </Section> <mask> <HintViewer <mask> elementType={appState.elementType} <mask> multiMode={appState.multiElement !== null} <mask> isResizing={appState.isResizing} <mask> elements={elements} <mask> /> <mask> </FixedSideContainer> <mask> <footer className="App-toolbar"> <mask> <div className="App-toolbar-content"> <mask> {actionManager.renderAction("toggleCanvasMenu")} <mask> {actionManager.renderAction("toggleEditMenu")} </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove <HintViewer elementType={appState.elementType} multiMode={appState.multiElement !== null} isResizing={appState.isResizing} elements={elements} /> </s> add <HintViewer appState={appState} elements={elements} /> </s> remove targetElements={getTargetElement( appState.editingElement, elements, )} </s> add targetElements={getTargetElement(elements, appState)} </s> remove targetElements={getTargetElement( appState.editingElement, elements, )} </s> add targetElements={getTargetElement(elements, appState)} </s> add appState, </s> add appState, </s> add appState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/components/MobileMenu.tsx
keep keep keep add keep keep keep keep keep keep
<mask> <mask> export async function exportCanvas( <mask> type: ExportType, <mask> elements: readonly ExcalidrawElement[], <mask> canvas: HTMLCanvasElement, <mask> { <mask> exportBackground, <mask> exportPadding = 10, <mask> viewBackgroundColor, <mask> name, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add appState: AppState, </s> add appState: AppState, </s> remove return elements.filter(element => element.isSelected); </s> add return elements.filter(element => appState.selectedElementIds[element.id]); </s> remove export function getSelectedIndices(elements: readonly ExcalidrawElement[]) { </s> add export function getSelectedIndices( elements: readonly ExcalidrawElement[], appState: AppState, ) { </s> add appState: AppState, </s> remove const tempCanvas = exportToCanvas(elements, { </s> add const tempCanvas = exportToCanvas(elements, appState, {
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/data/index.ts
keep keep keep keep replace keep keep keep keep keep
<mask> }); <mask> return; <mask> } <mask> <mask> const tempCanvas = exportToCanvas(elements, { <mask> exportBackground, <mask> viewBackgroundColor, <mask> exportPadding, <mask> scale, <mask> }); </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove const canvas = exportToCanvas(exportedElements, { </s> add const canvas = exportToCanvas(exportedElements, appState, { </s> add appState, </s> add appState: AppState, </s> remove if (!element.isSelected) { elements = clearSelection(elements); element.isSelected = true; this.setState({}); </s> add if (!this.state.selectedElementIds[element.id]) { this.setState({ selectedElementIds: { [element.id]: true } }); </s> remove }); </s> add selectedElementIds: { ...prevState.selectedElementIds, [this.state.draggingElement!.id]: true, }, })); </s> remove this.setState({ </s> add this.setState(prevState => ({
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/data/index.ts
keep keep keep keep replace keep keep keep keep keep
<mask> { <mask> type: "excalidraw", <mask> version: 1, <mask> source: window.location.origin, <mask> elements: elements.map(({ shape, canvas, isSelected, ...el }) => el), <mask> appState: cleanAppStateForExport(appState), <mask> }, <mask> null, <mask> 2, <mask> ); </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements: elements.map(({ shape, canvas, ...element }) => ({ </s> add elements: elements.map(element => ({ </s> remove shape: null, canvas: null, </s> add </s> remove CLIPBOARD = JSON.stringify( getSelectedElements(elements).map(({ shape, canvas, ...el }) => el), ); </s> add CLIPBOARD = JSON.stringify(getSelectedElements(elements, appState)); </s> remove localStorage.setItem( LOCAL_STORAGE_KEY, JSON.stringify( elements.map( ({ shape, canvas, ...element }: ExcalidrawElement) => element, ), ), ); </s> add localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(elements)); </s> remove isSelected: false, </s> add </s> remove isSelected: false, </s> add
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/data/json.ts
keep keep keep keep replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> export function saveToLocalStorage( <mask> elements: readonly ExcalidrawElement[], <mask> appState: AppState, <mask> ) { <mask> localStorage.setItem( <mask> LOCAL_STORAGE_KEY, <mask> JSON.stringify( <mask> elements.map( <mask> ({ shape, canvas, ...element }: ExcalidrawElement) => element, <mask> ), <mask> ), <mask> ); <mask> localStorage.setItem( <mask> LOCAL_STORAGE_KEY_STATE, <mask> JSON.stringify(clearAppStateForLocalStorage(appState)), <mask> ); <mask> } </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements = JSON.parse(savedElements).map( ({ shape, ...element }: ExcalidrawElement) => element, ); </s> add elements = JSON.parse(savedElements); </s> remove elements: elements.map(({ shape, canvas, ...element }) => ({ </s> add elements: elements.map(element => ({ </s> add appState: AppState, </s> add appState: AppState, </s> add appState: AppState, </s> add appState: AppState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/data/localStorage.ts
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> <mask> let elements = []; <mask> if (savedElements) { <mask> try { <mask> elements = JSON.parse(savedElements).map( <mask> ({ shape, ...element }: ExcalidrawElement) => element, <mask> ); <mask> } catch { <mask> // Do nothing because elements array is already empty <mask> } <mask> } <mask> </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements = [ ...elements.map(element => ({ ...element, isSelected: false, })), ...getSelectedElements(elements).map(element => { const newElement = duplicateElement(element); newElement.isSelected = true; return newElement; }), ]; </s> add // Move the currently selected elements to the top of the z index stack, and // put the duplicates where the selected elements used to be. const nextElements = []; const elementsToAppend = []; for (const element of elements) { if (this.state.selectedElementIds[element.id]) { nextElements.push(duplicateElement(element)); elementsToAppend.push(element); } else { nextElements.push(element); } } elements = [...nextElements, ...elementsToAppend]; </s> remove localStorage.setItem( LOCAL_STORAGE_KEY, JSON.stringify( elements.map( ({ shape, canvas, ...element }: ExcalidrawElement) => element, ), ), ); </s> add localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(elements)); </s> remove const getHints = ({ elementType, multiMode, isResizing, elements }: Hint) => { </s> add const getHints = ({ appState, elements }: Hint) => { const { elementType, isResizing } = appState; const multiMode = appState.multiElement !== null; </s> remove elements = clearSelection(elements); hitElement.isSelected = true; </s> add this.setState(prevState => ({ selectedElementIds: { [hitElement!.id]: true }, })); </s> remove elements = clearSelection(elements); this.setState({}); </s> add this.setState({ selectedElementIds: {} }); </s> remove element.isSelected = true; elements = [...clearSelection(elements), element]; </s> add elements = [...elements, element]; this.setState({ selectedElementIds: { [element.id]: true } });
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/data/localStorage.ts
keep keep keep keep replace replace replace replace keep keep keep keep keep
<mask> element.opacity === null || element.opacity === undefined <mask> ? 100 <mask> : element.opacity, <mask> points, <mask> shape: null, <mask> canvas: null, <mask> canvasOffsetX: element.canvasOffsetX || 0, <mask> canvasOffsetY: element.canvasOffsetY || 0, <mask> }; <mask> }); <mask> <mask> if (opts?.scrollToContent && savedState) { <mask> savedState = { ...savedState, ...calculateScrollCenter(elements) }; </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove canvas: null as HTMLCanvasElement | null, canvasZoom: 1, // The zoom level used to render the cached canvas canvasOffsetX: 0, canvasOffsetY: 0, </s> add </s> remove shape: null as Drawable | Drawable[] | null, </s> add </s> remove element.shape = generator.rectangle( 0, 0, element.width, element.height, { stroke: element.strokeColor, fill: element.backgroundColor === "transparent" ? undefined : element.backgroundColor, fillStyle: element.fillStyle, strokeWidth: element.strokeWidth, roughness: element.roughness, seed: element.seed, }, ); </s> add shape = generator.rectangle(0, 0, element.width, element.height, { stroke: element.strokeColor, fill: element.backgroundColor === "transparent" ? undefined : element.backgroundColor, fillStyle: element.fillStyle, strokeWidth: element.strokeWidth, roughness: element.roughness, seed: element.seed, }); </s> remove if (!element.shape) { element.canvas = null; </s> add let shape = shapeCache.get(element) || null; if (!shape) { </s> add selectedElementIds: {}, </s> remove shape: null, canvas: null, </s> add
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/data/restore.ts
keep keep keep add keep keep keep keep
<mask> import { ExcalidrawElement } from "./types"; <mask> import { rotate } from "../math"; <mask> import { Drawable } from "roughjs/bin/core"; <mask> import { Point } from "roughjs/bin/geometry"; <mask> <mask> // If the element is created from right to left, the width is going to be negative <mask> // This set of functions retrieves the absolute position of the 4 points. <mask> export function getElementAbsoluteCoords(element: ExcalidrawElement) { </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove import { Drawable } from "roughjs/bin/core"; </s> add </s> add import { AppState } from "../types"; import { getShapeForElement } from "../renderer/renderElement"; </s> remove import { FlooredNumber } from "../types"; </s> add import { FlooredNumber, AppState } from "../types"; </s> remove import { hasBackground, hasStroke, hasText, clearSelection } from "../scene"; </s> add import { hasBackground, hasStroke, hasText } from "../scene"; </s> add import { invalidateShapeForElement } from "../renderer/renderElement"; </s> remove import { clearSelection } from "../scene"; </s> add
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/element/bounds.ts
keep keep keep keep replace keep keep keep keep keep
<mask> return [topX, topY, rightX, rightY, bottomX, bottomY, leftX, leftY]; <mask> } <mask> <mask> export function getLinearElementAbsoluteBounds(element: ExcalidrawElement) { <mask> if (element.points.length < 2 || !element.shape) { <mask> const { minX, minY, maxX, maxY } = element.points.reduce( <mask> (limits, [x, y]) => { <mask> limits.minY = Math.min(limits.minY, y); <mask> limits.minX = Math.min(limits.minX, x); <mask> </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove if (!element.shape) { </s> add if (!getShapeForElement(element)) { </s> remove export function getArrowPoints(element: ExcalidrawElement) { const shape = element.shape as Drawable[]; </s> add export function getArrowPoints(element: ExcalidrawElement, shape: Drawable[]) { </s> remove const shape = element.shape as Drawable[]; </s> add const shape = getShapeForElement(element) as Drawable[]; </s> remove if (isElementDraggableFromInside(element)) { </s> add if (isElementDraggableFromInside(element, appState)) { </s> remove export function clearSelection(elements: readonly ExcalidrawElement[]) { let someWasSelected = false; elements.forEach(element => { if (element.isSelected) { someWasSelected = true; element.isSelected = false; } }); return someWasSelected ? elements.slice() : elements; } export function deleteSelectedElements(elements: readonly ExcalidrawElement[]) { return elements.filter(el => !el.isSelected); </s> add export function deleteSelectedElements( elements: readonly ExcalidrawElement[], appState: AppState, ) { return elements.filter(el => !appState.selectedElementIds[el.id]); </s> add import { invalidateShapeForElement } from "../renderer/renderElement";
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/element/bounds.ts
keep keep keep keep replace keep keep keep keep keep
<mask> maxY + element.y, <mask> ]; <mask> } <mask> <mask> const shape = element.shape as Drawable[]; <mask> <mask> // first element is always the curve <mask> const ops = shape[0].sets[0].ops; <mask> <mask> let currentP: Point = [0, 0]; </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove export function getArrowPoints(element: ExcalidrawElement) { const shape = element.shape as Drawable[]; </s> add export function getArrowPoints(element: ExcalidrawElement, shape: Drawable[]) { </s> remove element.shape = [generator.curve(points, options)]; </s> add shape = [generator.curve(points, options)]; </s> remove const shape = element.shape as Drawable[]; </s> add const shape = getShapeForElement(element) as Drawable[]; </s> remove if (!hitElement.isSelected) { hitElement.isSelected = true; </s> add if (!this.state.selectedElementIds[hitElement.id]) { this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [hitElement!.id]: true, }, })); </s> remove elements = [ ...elements.map(element => ({ ...element, isSelected: false, })), ...getSelectedElements(elements).map(element => { const newElement = duplicateElement(element); newElement.isSelected = true; return newElement; }), ]; </s> add // Move the currently selected elements to the top of the z index stack, and // put the duplicates where the selected elements used to be. const nextElements = []; const elementsToAppend = []; for (const element of elements) { if (this.state.selectedElementIds[element.id]) { nextElements.push(duplicateElement(element)); elementsToAppend.push(element); } else { nextElements.push(element); } } elements = [...nextElements, ...elementsToAppend]; </s> remove if (!element.shape) { </s> add if (!getShapeForElement(element)) {
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/element/bounds.ts
keep keep keep keep replace replace keep keep keep keep keep
<mask> maxY + element.y, <mask> ]; <mask> } <mask> <mask> export function getArrowPoints(element: ExcalidrawElement) { <mask> const shape = element.shape as Drawable[]; <mask> const ops = shape[0].sets[0].ops; <mask> <mask> const data = ops[ops.length - 1].data; <mask> const p3 = [data[4], data[5]] as Point; <mask> const p2 = [data[2], data[3]] as Point; </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove const shape = element.shape as Drawable[]; </s> add const shape = getShapeForElement(element) as Drawable[]; </s> remove const shape = element.shape as Drawable[]; </s> add const shape = getShapeForElement(element) as Drawable[]; </s> remove if (!element.shape) { </s> add if (!getShapeForElement(element)) { </s> remove const node = rsvg.draw(element.shape as Drawable); </s> add const node = rsvg.draw(getShapeForElement(element) as Drawable); </s> remove (element.shape as Drawable[]).forEach(shape => { </s> add (getShapeForElement(element) as Drawable[]).forEach(shape => { </s> remove (element.shape as Drawable[]).forEach(shape => rc.draw(shape)); </s> add (getShapeForElement(element) as Drawable[]).forEach(shape => rc.draw(shape), );
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/element/bounds.ts
keep keep add keep keep keep keep keep
<mask> } from "./bounds"; <mask> import { Point } from "roughjs/bin/geometry"; <mask> import { Drawable, OpSet } from "roughjs/bin/core"; <mask> <mask> function isElementDraggableFromInside( <mask> element: ExcalidrawElement, <mask> appState: AppState, <mask> ): boolean { </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove function isElementDraggableFromInside(element: ExcalidrawElement): boolean { return element.backgroundColor !== "transparent" || element.isSelected; </s> add function isElementDraggableFromInside( element: ExcalidrawElement, appState: AppState, ): boolean { return ( element.backgroundColor !== "transparent" || appState.selectedElementIds[element.id] ); </s> remove import { Drawable } from "roughjs/bin/core"; </s> add </s> add import { AppState } from "../types"; </s> add import { getShapeForElement } from "../renderer/renderElement"; </s> add import { AppState } from "../types"; </s> add import { AppState } from "../types";
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/element/collision.ts
keep keep keep keep replace replace keep keep keep keep keep
<mask> } from "./bounds"; <mask> import { Point } from "roughjs/bin/geometry"; <mask> import { Drawable, OpSet } from "roughjs/bin/core"; <mask> <mask> function isElementDraggableFromInside(element: ExcalidrawElement): boolean { <mask> return element.backgroundColor !== "transparent" || element.isSelected; <mask> } <mask> <mask> export function hitTest( <mask> element: ExcalidrawElement, <mask> x: number, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add import { AppState } from "../types"; import { getShapeForElement } from "../renderer/renderElement"; </s> remove import { Drawable } from "roughjs/bin/core"; </s> add </s> add import { invalidateShapeForElement } from "../renderer/renderElement"; </s> add import { getShapeForElement } from "../renderer/renderElement"; </s> add import { AppState } from "../types"; </s> add import { AppState } from "../types";
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/element/collision.ts