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 replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep replace replace replace replace keep keep keep keep
<mask> this.state.zoom, <mask> ); <mask> <mask> const element = <mask> elementAtPosition && isTextElement(elementAtPosition) <mask> ? elementAtPosition <mask> : newTextElement({ <mask> x: x, <mask> y: y, <mask> strokeColor: this.state.currentItemStrokeColor, <mask> backgroundColor: this.state.currentItemBackgroundColor, <mask> fillStyle: this.state.currentItemFillStyle, <mask> strokeWidth: this.state.currentItemStrokeWidth, <mask> strokeStyle: this.state.currentItemStrokeStyle, <mask> roughness: this.state.currentItemRoughness, <mask> opacity: this.state.currentItemOpacity, <mask> text: "", <mask> fontSize: this.state.currentItemFontSize, <mask> fontFamily: this.state.currentItemFontFamily, <mask> textAlign: this.state.currentItemTextAlign, <mask> }); <mask> <mask> this.setState({ editingElement: element }); <mask> <mask> let textX = clientX || x; <mask> let textY = clientY || y; <mask> <mask> let isExistingTextElement = false; <mask> <mask> if (elementAtPosition && isTextElement(elementAtPosition)) { <mask> isExistingTextElement = true; <mask> const centerElementX = elementAtPosition.x + elementAtPosition.width / 2; <mask> const centerElementY = elementAtPosition.y + elementAtPosition.height / 2; <mask> <mask> const { <mask> x: centerElementXInViewport, <mask> y: centerElementYInViewport, </s> do not center text when not applicable (#1783) </s> remove textX = centerElementXInViewport; textY = centerElementYInViewport; </s> add const element = existingTextElement ? existingTextElement : newTextElement({ x: parentCenterPosition ? parentCenterPosition.elementCenterX : sceneX, y: parentCenterPosition ? parentCenterPosition.elementCenterY : sceneY, strokeColor: this.state.currentItemStrokeColor, backgroundColor: this.state.currentItemBackgroundColor, fillStyle: this.state.currentItemFillStyle, strokeWidth: this.state.currentItemStrokeWidth, strokeStyle: this.state.currentItemStrokeStyle, roughness: this.state.currentItemRoughness, opacity: this.state.currentItemOpacity, text: "", fontSize: this.state.currentItemFontSize, fontFamily: this.state.currentItemFontFamily, textAlign: parentCenterPosition ? "center" : this.state.currentItemTextAlign, verticalAlign: parentCenterPosition ? "middle" : DEFAULT_VERTICAL_ALIGN, }); </s> remove const { x: centerElementXInViewport, y: centerElementYInViewport, } = sceneCoordsToViewportCoords( { sceneX: centerElementX, sceneY: centerElementY }, </s> add const parentCenterPosition = insertAtParentCenter && this.getTextWysiwygSnappedToCenterPosition( sceneX, sceneY, </s> remove const x = selectedElement.x + selectedElement.width / 2; const y = selectedElement.y + selectedElement.height / 2; </s> add </s> remove x: x, y: y, </s> add sceneX: selectedElement.x + selectedElement.width / 2, sceneY: selectedElement.y + selectedElement.height / 2, </s> remove private startTextEditing = ({ x, y, clientX, clientY, centerIfPossible = true, }: { x: number; y: number; clientX?: number; clientY?: number; centerIfPossible?: boolean; }) => { const elementAtPosition = getElementAtPosition( </s> add private getTextElementAtPosition( x: number, y: number, ): NonDeleted<ExcalidrawTextElement> | null { const element = getElementAtPosition(
https://github.com/excalidraw/excalidraw/commit/cd87bd6901b47430a692a06a8928b0f732d77097
src/components/App.tsx
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
<mask> isExistingTextElement = true; <mask> const centerElementX = elementAtPosition.x + elementAtPosition.width / 2; <mask> const centerElementY = elementAtPosition.y + elementAtPosition.height / 2; <mask> <mask> const { <mask> x: centerElementXInViewport, <mask> y: centerElementYInViewport, <mask> } = sceneCoordsToViewportCoords( <mask> { sceneX: centerElementX, sceneY: centerElementY }, <mask> this.state, <mask> this.canvas, <mask> window.devicePixelRatio, <mask> ); <mask> </s> do not center text when not applicable (#1783) </s> remove if (elementAtPosition && isTextElement(elementAtPosition)) { isExistingTextElement = true; const centerElementX = elementAtPosition.x + elementAtPosition.width / 2; const centerElementY = elementAtPosition.y + elementAtPosition.height / 2; </s> add private startTextEditing = ({ sceneX, sceneY, insertAtParentCenter = true, }: { /** X position to insert text at */ sceneX: number; /** Y position to insert text at */ sceneY: number; /** whether to attempt to insert at element center if applicable */ insertAtParentCenter?: boolean; }) => { const existingTextElement = this.getTextElementAtPosition(sceneX, sceneY); </s> remove const element = elementAtPosition && isTextElement(elementAtPosition) ? elementAtPosition : newTextElement({ x: x, y: y, strokeColor: this.state.currentItemStrokeColor, backgroundColor: this.state.currentItemBackgroundColor, fillStyle: this.state.currentItemFillStyle, strokeWidth: this.state.currentItemStrokeWidth, strokeStyle: this.state.currentItemStrokeStyle, roughness: this.state.currentItemRoughness, opacity: this.state.currentItemOpacity, text: "", fontSize: this.state.currentItemFontSize, fontFamily: this.state.currentItemFontFamily, textAlign: this.state.currentItemTextAlign, }); this.setState({ editingElement: element }); let textX = clientX || x; let textY = clientY || y; let isExistingTextElement = false; </s> add if (element && isTextElement(element) && !element.isDeleted) { return element; } return null; } </s> remove x: x, y: y, </s> add sceneX: selectedElement.x + selectedElement.width / 2, sceneY: selectedElement.y + selectedElement.height / 2, </s> remove const x = selectedElement.x + selectedElement.width / 2; const y = selectedElement.y + selectedElement.height / 2; </s> add </s> add getViewportCoords: (x, y) => { const { x: viewportX, y: viewportY } = sceneCoordsToViewportCoords( { sceneX: x, sceneY: y }, this.state, this.canvas, window.devicePixelRatio, ); return [viewportX, viewportY]; }, </s> remove const { x, y } = viewportCoordsToSceneCoords( </s> add const { x: sceneX, y: sceneY } = viewportCoordsToSceneCoords(
https://github.com/excalidraw/excalidraw/commit/cd87bd6901b47430a692a06a8928b0f732d77097
src/components/App.tsx
keep keep keep keep replace replace keep keep keep keep keep
<mask> this.canvas, <mask> window.devicePixelRatio, <mask> ); <mask> <mask> textX = centerElementXInViewport; <mask> textY = centerElementYInViewport; <mask> <mask> // x and y will change after calling newTextElement function <mask> mutateElement(element, { <mask> x: centerElementX, <mask> y: centerElementY, </s> do not center text when not applicable (#1783) </s> remove // x and y will change after calling newTextElement function mutateElement(element, { x: centerElementX, y: centerElementY, }); </s> add this.setState({ editingElement: element }); if (existingTextElement) { // if text element is no longer centered to a container, reset // verticalAlign to default because it's currently internal-only if (!parentCenterPosition || element.textAlign !== "center") { mutateElement(element, { verticalAlign: DEFAULT_VERTICAL_ALIGN }); } </s> remove const { x, y } = viewportCoordsToSceneCoords( </s> add const { x: sceneX, y: sceneY } = viewportCoordsToSceneCoords( </s> remove const { x: centerElementXInViewport, y: centerElementYInViewport, } = sceneCoordsToViewportCoords( { sceneX: centerElementX, sceneY: centerElementY }, </s> add const parentCenterPosition = insertAtParentCenter && this.getTextWysiwygSnappedToCenterPosition( sceneX, sceneY, </s> add getViewportCoords: (x, y) => { const { x: viewportX, y: viewportY } = sceneCoordsToViewportCoords( { sceneX: x, sceneY: y }, this.state, this.canvas, window.devicePixelRatio, ); return [viewportX, viewportY]; }, </s> remove const x = selectedElement.x + selectedElement.width / 2; const y = selectedElement.y + selectedElement.height / 2; </s> add </s> remove const element = elementAtPosition && isTextElement(elementAtPosition) ? elementAtPosition : newTextElement({ x: x, y: y, strokeColor: this.state.currentItemStrokeColor, backgroundColor: this.state.currentItemBackgroundColor, fillStyle: this.state.currentItemFillStyle, strokeWidth: this.state.currentItemStrokeWidth, strokeStyle: this.state.currentItemStrokeStyle, roughness: this.state.currentItemRoughness, opacity: this.state.currentItemOpacity, text: "", fontSize: this.state.currentItemFontSize, fontFamily: this.state.currentItemFontFamily, textAlign: this.state.currentItemTextAlign, }); this.setState({ editingElement: element }); let textX = clientX || x; let textY = clientY || y; let isExistingTextElement = false; </s> add if (element && isTextElement(element) && !element.isDeleted) { return element; } return null; }
https://github.com/excalidraw/excalidraw/commit/cd87bd6901b47430a692a06a8928b0f732d77097
src/components/App.tsx
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
<mask> <mask> textX = centerElementXInViewport; <mask> textY = centerElementYInViewport; <mask> <mask> // x and y will change after calling newTextElement function <mask> mutateElement(element, { <mask> x: centerElementX, <mask> y: centerElementY, <mask> }); <mask> } else { <mask> globalSceneState.replaceAllElements([ <mask> ...globalSceneState.getElementsIncludingDeleted(), <mask> element, <mask> ]); </s> do not center text when not applicable (#1783) </s> remove textX = centerElementXInViewport; textY = centerElementYInViewport; </s> add const element = existingTextElement ? existingTextElement : newTextElement({ x: parentCenterPosition ? parentCenterPosition.elementCenterX : sceneX, y: parentCenterPosition ? parentCenterPosition.elementCenterY : sceneY, strokeColor: this.state.currentItemStrokeColor, backgroundColor: this.state.currentItemBackgroundColor, fillStyle: this.state.currentItemFillStyle, strokeWidth: this.state.currentItemStrokeWidth, strokeStyle: this.state.currentItemStrokeStyle, roughness: this.state.currentItemRoughness, opacity: this.state.currentItemOpacity, text: "", fontSize: this.state.currentItemFontSize, fontFamily: this.state.currentItemFontFamily, textAlign: parentCenterPosition ? "center" : this.state.currentItemTextAlign, verticalAlign: parentCenterPosition ? "middle" : DEFAULT_VERTICAL_ALIGN, }); </s> add verticalAlign: DEFAULT_VERTICAL_ALIGN, </s> remove if (side === "w" || side === "nw" || side === "sw") { if (isResizeFromCenter) { x += deltaX1 + deltaX2; } else { x += deltaX1 * (1 - cos); y += deltaX1 * -sin; x += deltaX2 * (1 + cos); y += deltaX2 * sin; } } if (side === "n" || side === "nw" || side === "ne") { if (isResizeFromCenter) { y += deltaY1 + deltaY2; } else { x += deltaY1 * sin; y += deltaY1 * (1 - cos); x += deltaY2 * -sin; y += deltaY2 * (1 + cos); } </s> add if (sides.n && sides.s) { y += deltaY1 + deltaY2; } else if (sides.n) { x += deltaY1 * sin; y += deltaY1 * (1 - cos); x += deltaY2 * -sin; y += deltaY2 * (1 + cos); } else if (sides.s) { x += deltaY1 * -sin; y += deltaY1 * (1 + cos); x += deltaY2 * sin; y += deltaY2 * (1 - cos); </s> remove const deleteElement = () => { globalSceneState.replaceAllElements([ ...globalSceneState.getElementsIncludingDeleted().map((_element) => { if (_element.id === element.id) { return newElementWith(_element, { isDeleted: true }); } return _element; }), ]); }; </s> add </s> remove x: x, y: y, </s> add sceneX: selectedElement.x + selectedElement.width / 2, sceneY: selectedElement.y + selectedElement.height / 2, </s> remove const x = selectedElement.x + selectedElement.width / 2; const y = selectedElement.y + selectedElement.height / 2; </s> add
https://github.com/excalidraw/excalidraw/commit/cd87bd6901b47430a692a06a8928b0f732d77097
src/components/App.tsx
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> editingElement: element, <mask> }); <mask> <mask> this.handleTextWysiwyg(element, { <mask> x: textX, <mask> y: textY, <mask> isExistingElement: isExistingTextElement, <mask> }); <mask> }; <mask> <mask> private handleCanvasDoubleClick = ( <mask> event: React.MouseEvent<HTMLCanvasElement>, </s> do not center text when not applicable (#1783) </s> remove x: x, y: y, clientX: event.clientX, clientY: event.clientY, centerIfPossible: !event.altKey, </s> add sceneX, sceneY, insertAtParentCenter: !event.altKey, </s> remove const deleteElement = () => { globalSceneState.replaceAllElements([ ...globalSceneState.getElementsIncludingDeleted().map((_element) => { if (_element.id === element.id) { return newElementWith(_element, { isDeleted: true }); } return _element; }), ]); }; </s> add </s> remove // x and y will change after calling newTextElement function mutateElement(element, { x: centerElementX, y: centerElementY, }); </s> add this.setState({ editingElement: element }); if (existingTextElement) { // if text element is no longer centered to a container, reset // verticalAlign to default because it's currently internal-only if (!parentCenterPosition || element.textAlign !== "center") { mutateElement(element, { verticalAlign: DEFAULT_VERTICAL_ALIGN }); } </s> remove x, y, </s> add </s> remove private startTextEditing = ({ x, y, clientX, clientY, centerIfPossible = true, }: { x: number; y: number; clientX?: number; clientY?: number; centerIfPossible?: boolean; }) => { const elementAtPosition = getElementAtPosition( </s> add private getTextElementAtPosition( x: number, y: number, ): NonDeleted<ExcalidrawTextElement> | null { const element = getElementAtPosition( </s> remove }: { x: number; y: number; isExistingElement?: boolean }, </s> add }: { isExistingElement?: boolean; },
https://github.com/excalidraw/excalidraw/commit/cd87bd6901b47430a692a06a8928b0f732d77097
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> resetCursor(); <mask> <mask> const { x, y } = viewportCoordsToSceneCoords( <mask> event, <mask> this.state, <mask> this.canvas, <mask> window.devicePixelRatio, <mask> ); </s> do not center text when not applicable (#1783) </s> add getViewportCoords: (x, y) => { const { x: viewportX, y: viewportY } = sceneCoordsToViewportCoords( { sceneX: x, sceneY: y }, this.state, this.canvas, window.devicePixelRatio, ); return [viewportX, viewportY]; }, </s> remove const { x: centerElementXInViewport, y: centerElementYInViewport, } = sceneCoordsToViewportCoords( { sceneX: centerElementX, sceneY: centerElementY }, </s> add const parentCenterPosition = insertAtParentCenter && this.getTextWysiwygSnappedToCenterPosition( sceneX, sceneY, </s> remove x, y, </s> add sceneX, sceneY, </s> remove textX = centerElementXInViewport; textY = centerElementYInViewport; </s> add const element = existingTextElement ? existingTextElement : newTextElement({ x: parentCenterPosition ? parentCenterPosition.elementCenterX : sceneX, y: parentCenterPosition ? parentCenterPosition.elementCenterY : sceneY, strokeColor: this.state.currentItemStrokeColor, backgroundColor: this.state.currentItemBackgroundColor, fillStyle: this.state.currentItemFillStyle, strokeWidth: this.state.currentItemStrokeWidth, strokeStyle: this.state.currentItemStrokeStyle, roughness: this.state.currentItemRoughness, opacity: this.state.currentItemOpacity, text: "", fontSize: this.state.currentItemFontSize, fontFamily: this.state.currentItemFontFamily, textAlign: parentCenterPosition ? "center" : this.state.currentItemTextAlign, verticalAlign: parentCenterPosition ? "middle" : DEFAULT_VERTICAL_ALIGN, }); </s> remove private startTextEditing = ({ x, y, clientX, clientY, centerIfPossible = true, }: { x: number; y: number; clientX?: number; clientY?: number; centerIfPossible?: boolean; }) => { const elementAtPosition = getElementAtPosition( </s> add private getTextElementAtPosition( x: number, y: number, ): NonDeleted<ExcalidrawTextElement> | null { const element = getElementAtPosition( </s> remove x: x, y: y, </s> add sceneX: selectedElement.x + selectedElement.width / 2, sceneY: selectedElement.y + selectedElement.height / 2,
https://github.com/excalidraw/excalidraw/commit/cd87bd6901b47430a692a06a8928b0f732d77097
src/components/App.tsx
keep keep keep keep replace replace keep keep keep keep keep
<mask> const elements = globalSceneState.getElements(); <mask> const hitElement = getElementAtPosition( <mask> elements, <mask> this.state, <mask> x, <mask> y, <mask> this.state.zoom, <mask> ); <mask> <mask> const selectedGroupId = <mask> hitElement && </s> do not center text when not applicable (#1783) </s> remove private startTextEditing = ({ x, y, clientX, clientY, centerIfPossible = true, }: { x: number; y: number; clientX?: number; clientY?: number; centerIfPossible?: boolean; }) => { const elementAtPosition = getElementAtPosition( </s> add private getTextElementAtPosition( x: number, y: number, ): NonDeleted<ExcalidrawTextElement> | null { const element = getElementAtPosition( </s> remove const { x, y } = viewportCoordsToSceneCoords( </s> add const { x: sceneX, y: sceneY } = viewportCoordsToSceneCoords( </s> remove const { x: centerElementXInViewport, y: centerElementYInViewport, } = sceneCoordsToViewportCoords( { sceneX: centerElementX, sceneY: centerElementY }, </s> add const parentCenterPosition = insertAtParentCenter && this.getTextWysiwygSnappedToCenterPosition( sceneX, sceneY, </s> remove const element = elementAtPosition && isTextElement(elementAtPosition) ? elementAtPosition : newTextElement({ x: x, y: y, strokeColor: this.state.currentItemStrokeColor, backgroundColor: this.state.currentItemBackgroundColor, fillStyle: this.state.currentItemFillStyle, strokeWidth: this.state.currentItemStrokeWidth, strokeStyle: this.state.currentItemStrokeStyle, roughness: this.state.currentItemRoughness, opacity: this.state.currentItemOpacity, text: "", fontSize: this.state.currentItemFontSize, fontFamily: this.state.currentItemFontFamily, textAlign: this.state.currentItemTextAlign, }); this.setState({ editingElement: element }); let textX = clientX || x; let textY = clientY || y; let isExistingTextElement = false; </s> add if (element && isTextElement(element) && !element.isDeleted) { return element; } return null; } </s> remove const x = selectedElement.x + selectedElement.width / 2; const y = selectedElement.y + selectedElement.height / 2; </s> add </s> add getViewportCoords: (x, y) => { const { x: viewportX, y: viewportY } = sceneCoordsToViewportCoords( { sceneX: x, sceneY: y }, this.state, this.canvas, window.devicePixelRatio, ); return [viewportX, viewportY]; },
https://github.com/excalidraw/excalidraw/commit/cd87bd6901b47430a692a06a8928b0f732d77097
src/components/App.tsx
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
<mask> <mask> resetCursor(); <mask> <mask> this.startTextEditing({ <mask> x: x, <mask> y: y, <mask> clientX: event.clientX, <mask> clientY: event.clientY, <mask> centerIfPossible: !event.altKey, <mask> }); <mask> }; <mask> <mask> private handleCanvasPointerMove = ( <mask> event: React.PointerEvent<HTMLCanvasElement>, </s> do not center text when not applicable (#1783) </s> remove x: textX, y: textY, isExistingElement: isExistingTextElement, </s> add isExistingElement: !!existingTextElement, </s> remove x: x, y: y, </s> add sceneX: selectedElement.x + selectedElement.width / 2, sceneY: selectedElement.y + selectedElement.height / 2, </s> remove const x = selectedElement.x + selectedElement.width / 2; const y = selectedElement.y + selectedElement.height / 2; </s> add </s> remove private startTextEditing = ({ x, y, clientX, clientY, centerIfPossible = true, }: { x: number; y: number; clientX?: number; clientY?: number; centerIfPossible?: boolean; }) => { const elementAtPosition = getElementAtPosition( </s> add private getTextElementAtPosition( x: number, y: number, ): NonDeleted<ExcalidrawTextElement> | null { const element = getElementAtPosition( </s> remove x, y, </s> add </s> remove const { x, y } = viewportCoordsToSceneCoords( </s> add const { x: sceneX, y: sceneY } = viewportCoordsToSceneCoords(
https://github.com/excalidraw/excalidraw/commit/cd87bd6901b47430a692a06a8928b0f732d77097
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> isRotating: false, <mask> resizingElement: null, <mask> selectionElement: null, <mask> cursorButton: "up", <mask> editingElement: multiElement ? this.state.editingElement : null, <mask> }); <mask> <mask> this.savePointer(childEvent.clientX, childEvent.clientY, "up"); <mask> <mask> // if moving start/end point towards start/end point within threshold, </s> do not center text when not applicable (#1783) </s> remove }: { x: number; y: number; isExistingElement?: boolean }, </s> add }: { isExistingElement?: boolean; }, </s> remove const deleteElement = () => { globalSceneState.replaceAllElements([ ...globalSceneState.getElementsIncludingDeleted().map((_element) => { if (_element.id === element.id) { return newElementWith(_element, { isDeleted: true }); } return _element; }), ]); }; </s> add </s> remove textX = centerElementXInViewport; textY = centerElementYInViewport; </s> add const element = existingTextElement ? existingTextElement : newTextElement({ x: parentCenterPosition ? parentCenterPosition.elementCenterX : sceneX, y: parentCenterPosition ? parentCenterPosition.elementCenterY : sceneY, strokeColor: this.state.currentItemStrokeColor, backgroundColor: this.state.currentItemBackgroundColor, fillStyle: this.state.currentItemFillStyle, strokeWidth: this.state.currentItemStrokeWidth, strokeStyle: this.state.currentItemStrokeStyle, roughness: this.state.currentItemRoughness, opacity: this.state.currentItemOpacity, text: "", fontSize: this.state.currentItemFontSize, fontFamily: this.state.currentItemFontFamily, textAlign: parentCenterPosition ? "center" : this.state.currentItemTextAlign, verticalAlign: parentCenterPosition ? "middle" : DEFAULT_VERTICAL_ALIGN, }); </s> remove const scrolledOutside = !atLeastOneVisibleElement && elements.length > 0; </s> add const scrolledOutside = // hide when editing text this.state.editingElement?.type === "text" ? false : !atLeastOneVisibleElement && elements.length > 0; </s> remove import { FontFamily } from "./element/types"; export const DEFAULT_FONT_SIZE = 20; export const DEFAULT_FONT_FAMILY: FontFamily = 1; export const DEFAULT_TEXT_ALIGN = "left"; </s> add import { DEFAULT_FONT_SIZE, DEFAULT_FONT_FAMILY, DEFAULT_TEXT_ALIGN, } from "./constants"; </s> remove // x and y will change after calling newTextElement function mutateElement(element, { x: centerElementX, y: centerElementY, }); </s> add this.setState({ editingElement: element }); if (existingTextElement) { // if text element is no longer centered to a container, reset // verticalAlign to default because it's currently internal-only if (!parentCenterPosition || element.textAlign !== "center") { mutateElement(element, { verticalAlign: DEFAULT_VERTICAL_ALIGN }); }
https://github.com/excalidraw/excalidraw/commit/cd87bd6901b47430a692a06a8928b0f732d77097
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> isLinearElement(element), <mask> element.angle, <mask> ); <mask> const [nextElementX, nextElementY] = adjustXYWithRotation( <mask> resizeHandle, <mask> element.x - flipDiffX, <mask> element.y - flipDiffY, <mask> element.angle, <mask> deltaX1, <mask> deltaY1, </s> do not center text when not applicable (#1783) </s> add verticalAlign: DEFAULT_VERTICAL_ALIGN, </s> remove side: "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se", </s> add sides: { n?: boolean; e?: boolean; s?: boolean; w?: boolean; }, </s> remove type TextWysiwygParams = { id: string; initText: string; x: number; y: number; strokeColor: string; fontSize: number; fontFamily: FontFamily; opacity: number; zoom: number; angle: number; textAlign: string; onChange?: (text: string) => void; onSubmit: (text: string) => void; onCancel: () => void; </s> add const getTransform = ( width: number, height: number, angle: number, zoom: number, ) => { const degree = (180 * angle) / Math.PI; return `translate(${(width * (zoom - 1)) / 2}px, ${ (height * (zoom - 1)) / 2 }px) scale(${zoom}) rotate(${degree}deg)`; </s> remove if (text) { updateElement(text); } else { deleteElement(); } </s> add updateElement(text); </s> remove x, y, initText: element.text, strokeColor: element.strokeColor, opacity: element.opacity, fontSize: element.fontSize, fontFamily: element.fontFamily, angle: element.angle, textAlign: element.textAlign, </s> add </s> remove if (side === "w" || side === "nw" || side === "sw") { if (isResizeFromCenter) { x += deltaX1 + deltaX2; } else { x += deltaX1 * (1 - cos); y += deltaX1 * -sin; x += deltaX2 * (1 + cos); y += deltaX2 * sin; } } if (side === "n" || side === "nw" || side === "ne") { if (isResizeFromCenter) { y += deltaY1 + deltaY2; } else { x += deltaY1 * sin; y += deltaY1 * (1 - cos); x += deltaY2 * -sin; y += deltaY2 * (1 + cos); } </s> add if (sides.n && sides.s) { y += deltaY1 + deltaY2; } else if (sides.n) { x += deltaY1 * sin; y += deltaY1 * (1 - cos); x += deltaY2 * -sin; y += deltaY2 * (1 + cos); } else if (sides.s) { x += deltaY1 * -sin; y += deltaY1 * (1 + cos); x += deltaY2 * sin; y += deltaY2 * (1 - cos);
https://github.com/excalidraw/excalidraw/commit/cd87bd6901b47430a692a06a8928b0f732d77097
src/element/resizeElements.ts
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> // for multiline texts) <mask> return text.replace(/^\n+|\n+$/g, ""); <mask> }; <mask> <mask> type TextWysiwygParams = { <mask> id: string; <mask> initText: string; <mask> x: number; <mask> y: number; <mask> strokeColor: string; <mask> fontSize: number; <mask> fontFamily: FontFamily; <mask> opacity: number; <mask> zoom: number; <mask> angle: number; <mask> textAlign: string; <mask> onChange?: (text: string) => void; <mask> onSubmit: (text: string) => void; <mask> onCancel: () => void; <mask> }; <mask> <mask> export const textWysiwyg = ({ <mask> id, <mask> initText, </s> do not center text when not applicable (#1783) </s> remove private startTextEditing = ({ x, y, clientX, clientY, centerIfPossible = true, }: { x: number; y: number; clientX?: number; clientY?: number; centerIfPossible?: boolean; }) => { const elementAtPosition = getElementAtPosition( </s> add private getTextElementAtPosition( x: number, y: number, ): NonDeleted<ExcalidrawTextElement> | null { const element = getElementAtPosition( </s> remove x, y, </s> add </s> remove }: { x: number; y: number; isExistingElement?: boolean }, </s> add }: { isExistingElement?: boolean; }, </s> remove x, y, initText: element.text, strokeColor: element.strokeColor, opacity: element.opacity, fontSize: element.fontSize, fontFamily: element.fontFamily, angle: element.angle, textAlign: element.textAlign, </s> add </s> remove const deleteElement = () => { globalSceneState.replaceAllElements([ ...globalSceneState.getElementsIncludingDeleted().map((_element) => { if (_element.id === element.id) { return newElementWith(_element, { isDeleted: true }); } return _element; }), ]); }; </s> add </s> remove if (elementAtPosition && isTextElement(elementAtPosition)) { isExistingTextElement = true; const centerElementX = elementAtPosition.x + elementAtPosition.width / 2; const centerElementY = elementAtPosition.y + elementAtPosition.height / 2; </s> add private startTextEditing = ({ sceneX, sceneY, insertAtParentCenter = true, }: { /** X position to insert text at */ sceneX: number; /** Y position to insert text at */ sceneY: number; /** whether to attempt to insert at element center if applicable */ insertAtParentCenter?: boolean; }) => { const existingTextElement = this.getTextElementAtPosition(sceneX, sceneY);
https://github.com/excalidraw/excalidraw/commit/cd87bd6901b47430a692a06a8928b0f732d77097
src/element/textWysiwyg.tsx
keep keep keep replace keep replace keep keep
<mask> fontFamily, <mask> opacity, <mask> zoom, <mask> angle, <mask> onChange, <mask> textAlign, <mask> onSubmit, <mask> onCancel, </s> do not center text when not applicable (#1783) </s> remove opacity: opacity / 100, top: `${y}px`, left: `${x}px`, transform: `translate(-50%, -50%) scale(${zoom}) rotate(${degree}deg)`, textAlign: textAlign, </s> add </s> remove if (side === "w" || side === "nw" || side === "sw") { if (isResizeFromCenter) { x += deltaX1 + deltaX2; } else { x += deltaX1 * (1 - cos); y += deltaX1 * -sin; x += deltaX2 * (1 + cos); y += deltaX2 * sin; } } if (side === "n" || side === "nw" || side === "ne") { if (isResizeFromCenter) { y += deltaY1 + deltaY2; } else { x += deltaY1 * sin; y += deltaY1 * (1 - cos); x += deltaY2 * -sin; y += deltaY2 * (1 + cos); } </s> add if (sides.n && sides.s) { y += deltaY1 + deltaY2; } else if (sides.n) { x += deltaY1 * sin; y += deltaY1 * (1 - cos); x += deltaY2 * -sin; y += deltaY2 * (1 + cos); } else if (sides.s) { x += deltaY1 * -sin; y += deltaY1 * (1 + cos); x += deltaY2 * sin; y += deltaY2 * (1 - cos); </s> remove import { ExcalidrawElement, ExcalidrawTextElement } from "../element/types"; </s> add import { ExcalidrawElement, ExcalidrawTextElement, NonDeleted, } from "../element/types"; </s> remove const deleteElement = () => { globalSceneState.replaceAllElements([ ...globalSceneState.getElementsIncludingDeleted().map((_element) => { if (_element.id === element.id) { return newElementWith(_element, { isDeleted: true }); } return _element; }), ]); }; </s> add </s> remove }: { x: number; y: number; isExistingElement?: boolean }, </s> add }: { isExistingElement?: boolean; },
https://github.com/excalidraw/excalidraw/commit/cd87bd6901b47430a692a06a8928b0f732d77097
src/element/textWysiwyg.tsx
keep add keep keep keep keep keep keep
<mask> } <mask> } <mask> editable.dir = "auto"; <mask> editable.tabIndex = 0; <mask> editable.dataset.type = "wysiwyg"; <mask> // prevent line wrapping on Safari <mask> editable.wrap = "off"; <mask> </s> do not center text when not applicable (#1783) </s> remove editable.innerText = initText; </s> add </s> remove const scrolledOutside = !atLeastOneVisibleElement && elements.length > 0; </s> add const scrolledOutside = // hide when editing text this.state.editingElement?.type === "text" ? false : !atLeastOneVisibleElement && elements.length > 0; </s> remove const { x, y } = viewportCoordsToSceneCoords( </s> add const { x: sceneX, y: sceneY } = viewportCoordsToSceneCoords( </s> remove import { FontFamily } from "./element/types"; export const DEFAULT_FONT_SIZE = 20; export const DEFAULT_FONT_FAMILY: FontFamily = 1; export const DEFAULT_TEXT_ALIGN = "left"; </s> add import { DEFAULT_FONT_SIZE, DEFAULT_FONT_FAMILY, DEFAULT_TEXT_ALIGN, } from "./constants"; </s> remove // x and y will change after calling newTextElement function mutateElement(element, { x: centerElementX, y: centerElementY, }); </s> add this.setState({ editingElement: element }); if (existingTextElement) { // if text element is no longer centered to a container, reset // verticalAlign to default because it's currently internal-only if (!parentCenterPosition || element.textAlign !== "center") { mutateElement(element, { verticalAlign: DEFAULT_VERTICAL_ALIGN }); } </s> remove private startTextEditing = ({ x, y, clientX, clientY, centerIfPossible = true, }: { x: number; y: number; clientX?: number; clientY?: number; centerIfPossible?: boolean; }) => { const elementAtPosition = getElementAtPosition( </s> add private getTextElementAtPosition( x: number, y: number, ): NonDeleted<ExcalidrawTextElement> | null { const element = getElementAtPosition(
https://github.com/excalidraw/excalidraw/commit/cd87bd6901b47430a692a06a8928b0f732d77097
src/element/textWysiwyg.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> editable.contentEditable = "true"; <mask> } <mask> editable.dir = "auto"; <mask> editable.tabIndex = 0; <mask> editable.innerText = initText; <mask> editable.dataset.type = "wysiwyg"; <mask> <mask> const degree = (180 * angle) / Math.PI; <mask> <mask> Object.assign(editable.style, { </s> do not center text when not applicable (#1783) </s> add const editable = document.createElement("textarea"); </s> remove type TextWysiwygParams = { id: string; initText: string; x: number; y: number; strokeColor: string; fontSize: number; fontFamily: FontFamily; opacity: number; zoom: number; angle: number; textAlign: string; onChange?: (text: string) => void; onSubmit: (text: string) => void; onCancel: () => void; </s> add const getTransform = ( width: number, height: number, angle: number, zoom: number, ) => { const degree = (180 * angle) / Math.PI; return `translate(${(width * (zoom - 1)) / 2}px, ${ (height * (zoom - 1)) / 2 }px) scale(${zoom}) rotate(${degree}deg)`; </s> remove const scrolledOutside = !atLeastOneVisibleElement && elements.length > 0; </s> add const scrolledOutside = // hide when editing text this.state.editingElement?.type === "text" ? false : !atLeastOneVisibleElement && elements.length > 0; </s> remove const { x: centerElementXInViewport, y: centerElementYInViewport, } = sceneCoordsToViewportCoords( { sceneX: centerElementX, sceneY: centerElementY }, </s> add const parentCenterPosition = insertAtParentCenter && this.getTextWysiwygSnappedToCenterPosition( sceneX, sceneY, </s> remove if (elementAtPosition && isTextElement(elementAtPosition)) { isExistingTextElement = true; const centerElementX = elementAtPosition.x + elementAtPosition.width / 2; const centerElementY = elementAtPosition.y + elementAtPosition.height / 2; </s> add private startTextEditing = ({ sceneX, sceneY, insertAtParentCenter = true, }: { /** X position to insert text at */ sceneX: number; /** Y position to insert text at */ sceneY: number; /** whether to attempt to insert at element center if applicable */ insertAtParentCenter?: boolean; }) => { const existingTextElement = this.getTextElementAtPosition(sceneX, sceneY); </s> remove const x = selectedElement.x + selectedElement.width / 2; const y = selectedElement.y + selectedElement.height / 2; </s> add
https://github.com/excalidraw/excalidraw/commit/cd87bd6901b47430a692a06a8928b0f732d77097
src/element/textWysiwyg.tsx
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
<mask> <mask> Object.assign(editable.style, { <mask> color: strokeColor, <mask> position: "fixed", <mask> opacity: opacity / 100, <mask> top: `${y}px`, <mask> left: `${x}px`, <mask> transform: `translate(-50%, -50%) scale(${zoom}) rotate(${degree}deg)`, <mask> textAlign: textAlign, <mask> display: "inline-block", <mask> font: getFontString({ fontSize, fontFamily }), <mask> padding: "4px", <mask> // This needs to have "1px solid" otherwise the carret doesn't show up <mask> // the first time on Safari and Chrome! </s> do not center text when not applicable (#1783) </s> add const editable = document.createElement("textarea"); </s> remove // x and y will change after calling newTextElement function mutateElement(element, { x: centerElementX, y: centerElementY, }); </s> add this.setState({ editingElement: element }); if (existingTextElement) { // if text element is no longer centered to a container, reset // verticalAlign to default because it's currently internal-only if (!parentCenterPosition || element.textAlign !== "center") { mutateElement(element, { verticalAlign: DEFAULT_VERTICAL_ALIGN }); } </s> remove editingElement: multiElement ? this.state.editingElement : null, </s> add // text elements are reset on finalize, and resetting on pointerup // may cause issues with double taps editingElement: multiElement || isTextElement(this.state.editingElement) ? this.state.editingElement : null, </s> remove angle, </s> add </s> remove type TextWysiwygParams = { id: string; initText: string; x: number; y: number; strokeColor: string; fontSize: number; fontFamily: FontFamily; opacity: number; zoom: number; angle: number; textAlign: string; onChange?: (text: string) => void; onSubmit: (text: string) => void; onCancel: () => void; </s> add const getTransform = ( width: number, height: number, angle: number, zoom: number, ) => { const degree = (180 * angle) / Math.PI; return `translate(${(width * (zoom - 1)) / 2}px, ${ (height * (zoom - 1)) / 2 }px) scale(${zoom}) rotate(${degree}deg)`; </s> remove textX = centerElementXInViewport; textY = centerElementYInViewport; </s> add const element = existingTextElement ? existingTextElement : newTextElement({ x: parentCenterPosition ? parentCenterPosition.elementCenterX : sceneX, y: parentCenterPosition ? parentCenterPosition.elementCenterY : sceneY, strokeColor: this.state.currentItemStrokeColor, backgroundColor: this.state.currentItemBackgroundColor, fillStyle: this.state.currentItemFillStyle, strokeWidth: this.state.currentItemStrokeWidth, strokeStyle: this.state.currentItemStrokeStyle, roughness: this.state.currentItemRoughness, opacity: this.state.currentItemOpacity, text: "", fontSize: this.state.currentItemFontSize, fontFamily: this.state.currentItemFontFamily, textAlign: parentCenterPosition ? "center" : this.state.currentItemTextAlign, verticalAlign: parentCenterPosition ? "middle" : DEFAULT_VERTICAL_ALIGN, });
https://github.com/excalidraw/excalidraw/commit/cd87bd6901b47430a692a06a8928b0f732d77097
src/element/textWysiwyg.tsx
keep keep add keep keep keep keep keep
<mask> editable.oninput = null; <mask> editable.onkeydown = null; <mask> <mask> window.removeEventListener("wheel", stopEvent, true); <mask> window.removeEventListener("pointerdown", onPointerDown); <mask> window.removeEventListener("pointerup", rebindBlur); <mask> window.removeEventListener("blur", handleSubmit); <mask> </s> do not center text when not applicable (#1783) </s> add import { DEFAULT_VERTICAL_ALIGN } from "./constants"; </s> add verticalAlign: DEFAULT_VERTICAL_ALIGN, </s> remove const element = elementAtPosition && isTextElement(elementAtPosition) ? elementAtPosition : newTextElement({ x: x, y: y, strokeColor: this.state.currentItemStrokeColor, backgroundColor: this.state.currentItemBackgroundColor, fillStyle: this.state.currentItemFillStyle, strokeWidth: this.state.currentItemStrokeWidth, strokeStyle: this.state.currentItemStrokeStyle, roughness: this.state.currentItemRoughness, opacity: this.state.currentItemOpacity, text: "", fontSize: this.state.currentItemFontSize, fontFamily: this.state.currentItemFontFamily, textAlign: this.state.currentItemTextAlign, }); this.setState({ editingElement: element }); let textX = clientX || x; let textY = clientY || y; let isExistingTextElement = false; </s> add if (element && isTextElement(element) && !element.isDeleted) { return element; } return null; } </s> remove editable.innerText = initText; </s> add </s> add const editable = document.createElement("textarea"); </s> remove x, y, </s> add sceneX, sceneY,
https://github.com/excalidraw/excalidraw/commit/cd87bd6901b47430a692a06a8928b0f732d77097
src/element/textWysiwyg.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> (x1 - x2) * Math.sin(angle) + (y1 - y2) * Math.cos(angle) + y2, <mask> ]; <mask> <mask> export const adjustXYWithRotation = ( <mask> side: "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se", <mask> x: number, <mask> y: number, <mask> angle: number, <mask> deltaX1: number, <mask> deltaY1: number, </s> do not center text when not applicable (#1783) </s> remove type TextWysiwygParams = { id: string; initText: string; x: number; y: number; strokeColor: string; fontSize: number; fontFamily: FontFamily; opacity: number; zoom: number; angle: number; textAlign: string; onChange?: (text: string) => void; onSubmit: (text: string) => void; onCancel: () => void; </s> add const getTransform = ( width: number, height: number, angle: number, zoom: number, ) => { const degree = (180 * angle) / Math.PI; return `translate(${(width * (zoom - 1)) / 2}px, ${ (height * (zoom - 1)) / 2 }px) scale(${zoom}) rotate(${degree}deg)`; </s> remove private startTextEditing = ({ x, y, clientX, clientY, centerIfPossible = true, }: { x: number; y: number; clientX?: number; clientY?: number; centerIfPossible?: boolean; }) => { const elementAtPosition = getElementAtPosition( </s> add private getTextElementAtPosition( x: number, y: number, ): NonDeleted<ExcalidrawTextElement> | null { const element = getElementAtPosition( </s> add import { DEFAULT_VERTICAL_ALIGN } from "./constants"; </s> remove if (side === "w" || side === "nw" || side === "sw") { if (isResizeFromCenter) { x += deltaX1 + deltaX2; } else { x += deltaX1 * (1 - cos); y += deltaX1 * -sin; x += deltaX2 * (1 + cos); y += deltaX2 * sin; } } if (side === "n" || side === "nw" || side === "ne") { if (isResizeFromCenter) { y += deltaY1 + deltaY2; } else { x += deltaY1 * sin; y += deltaY1 * (1 - cos); x += deltaY2 * -sin; y += deltaY2 * (1 + cos); } </s> add if (sides.n && sides.s) { y += deltaY1 + deltaY2; } else if (sides.n) { x += deltaY1 * sin; y += deltaY1 * (1 - cos); x += deltaY2 * -sin; y += deltaY2 * (1 + cos); } else if (sides.s) { x += deltaY1 * -sin; y += deltaY1 * (1 + cos); x += deltaY2 * sin; y += deltaY2 * (1 - cos); </s> remove x: x, y: y, </s> add sceneX: selectedElement.x + selectedElement.width / 2, sceneY: selectedElement.y + selectedElement.height / 2, </s> remove resizeHandle, </s> add getSidesForResizeHandle(resizeHandle, isResizeFromCenter),
https://github.com/excalidraw/excalidraw/commit/cd87bd6901b47430a692a06a8928b0f732d77097
src/math.ts
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> x += deltaY2 * sin; <mask> y += deltaY2 * (1 - cos); <mask> } <mask> } <mask> if (side === "w" || side === "nw" || side === "sw") { <mask> if (isResizeFromCenter) { <mask> x += deltaX1 + deltaX2; <mask> } else { <mask> x += deltaX1 * (1 - cos); <mask> y += deltaX1 * -sin; <mask> x += deltaX2 * (1 + cos); <mask> y += deltaX2 * sin; <mask> } <mask> } <mask> if (side === "n" || side === "nw" || side === "ne") { <mask> if (isResizeFromCenter) { <mask> y += deltaY1 + deltaY2; <mask> } else { <mask> x += deltaY1 * sin; <mask> y += deltaY1 * (1 - cos); <mask> x += deltaY2 * -sin; <mask> y += deltaY2 * (1 + cos); <mask> } <mask> } <mask> return [x, y]; <mask> }; <mask> <mask> export const getFlipAdjustment = ( </s> do not center text when not applicable (#1783) </s> remove side: "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se", </s> add sides: { n?: boolean; e?: boolean; s?: boolean; w?: boolean; }, </s> remove x: x, y: y, </s> add sceneX: selectedElement.x + selectedElement.width / 2, sceneY: selectedElement.y + selectedElement.height / 2, </s> remove const x = selectedElement.x + selectedElement.width / 2; const y = selectedElement.y + selectedElement.height / 2; </s> add </s> remove // x and y will change after calling newTextElement function mutateElement(element, { x: centerElementX, y: centerElementY, }); </s> add this.setState({ editingElement: element }); if (existingTextElement) { // if text element is no longer centered to a container, reset // verticalAlign to default because it's currently internal-only if (!parentCenterPosition || element.textAlign !== "center") { mutateElement(element, { verticalAlign: DEFAULT_VERTICAL_ALIGN }); } </s> remove type TextWysiwygParams = { id: string; initText: string; x: number; y: number; strokeColor: string; fontSize: number; fontFamily: FontFamily; opacity: number; zoom: number; angle: number; textAlign: string; onChange?: (text: string) => void; onSubmit: (text: string) => void; onCancel: () => void; </s> add const getTransform = ( width: number, height: number, angle: number, zoom: number, ) => { const degree = (180 * angle) / Math.PI; return `translate(${(width * (zoom - 1)) / 2}px, ${ (height * (zoom - 1)) / 2 }px) scale(${zoom}) rotate(${degree}deg)`; </s> remove editable.innerText = initText; </s> add
https://github.com/excalidraw/excalidraw/commit/cd87bd6901b47430a692a06a8928b0f732d77097
src/math.ts
keep keep keep add keep keep keep keep
<mask> "firebase": "8.3.3", <mask> "i18next-browser-languagedetector": "6.1.2", <mask> "idb-keyval": "6.0.3", <mask> "image-blob-reduce": "3.0.1", <mask> "lodash.throttle": "4.1.1", <mask> "nanoid": "3.1.32", <mask> "open-color": "1.9.1", <mask> "pako": "1.0.11", </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove updateItemsInStorage={() => library.saveLibrary(libraryItems)} </s> add updateItemsInStorage={() => library.saveLibrary(libraryItemsData.libraryItems) } </s> remove blob: Blob, </s> add library: | Blob | Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>, </s> remove await this.app.props.onLibraryChange?.([]); this.libraryCache = []; </s> add this.saveLibrary([]); </s> remove private libraryCache: LibraryItems | null = null; </s> add /** cache for currently active promise when initializing/updating libaries asynchronously */ private libraryItemsPromise: Promise<LibraryItems> | null = null; /** last resolved libraryItems */ private lastLibraryItems: LibraryItems = []; </s> remove export const isValidLibrary = (json: any) => { </s> add export const isValidLibrary = (json: any): json is ImportedLibraryData => { </s> add ImportedLibraryData,
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
package.json
keep keep keep keep replace keep keep keep replace replace replace replace replace replace keep keep keep keep
<mask> if ( <mask> token === this.id || <mask> window.confirm( <mask> t("alerts.confirmAddLibrary", { <mask> numShapes: (json.libraryItems || json.library || []).length, <mask> }), <mask> ) <mask> ) { <mask> await this.library.importLibrary(blob, "published"); <mask> // hack to rerender the library items after import <mask> if (this.state.isLibraryOpen) { <mask> this.setState({ isLibraryOpen: false }); <mask> } <mask> this.setState({ isLibraryOpen: true }); <mask> } <mask> } catch (error: any) { <mask> window.alert(t("alerts.errorLoadingLibrary")); <mask> console.error(error); </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove window.alert(t("alerts.errorLoadingLibrary")); </s> add </s> add this.setState({ errorMessage: t("errors.importLibraryError") }); </s> remove const libraryItems = this.app.libraryItemsFromStorage; if (!libraryItems) { return resolve([]); } const items = restoreLibraryItems(libraryItems, "unpublished"); // clone to ensure we don't mutate the cached library elements in the app this.libraryCache = JSON.parse(JSON.stringify(items)); resolve(items); } catch (error: any) { console.error(error); resolve([]); </s> add resolve( cloneLibraryItems( await (this.libraryItemsPromise || this.lastLibraryItems), ), ); } catch (error) { return resolve(this.lastLibraryItems); </s> remove // detect z-index difference by checking the excalidraw elements // are in order return libraryItem.elements.every((libItemExcalidrawItem, idx) => { return ( libItemExcalidrawItem.id === targetLibraryItem.elements[idx].id && libItemExcalidrawItem.versionNonce === targetLibraryItem.elements[idx].versionNonce ); }); }); }; const existingLibraryItems = await this.loadLibrary(); const library = libraryFile.libraryItems || libraryFile.library || []; const restoredLibItems = restoreLibraryItems(library, defaultStatus); const filteredItems = []; for (const item of restoredLibItems) { if (isUniqueitem(existingLibraryItems, item)) { filteredItems.push(item); } } await this.saveLibrary([...filteredItems, ...existingLibraryItems]); </s> add }), ); </s> remove this.libraryItemsFromStorage = restoreLibraryItems( initialData.libraryItems, "unpublished", ) as LibraryItems; </s> add this.library.importLibrary(initialData.libraryItems, "unpublished");
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> this.setState({ isLibraryOpen: true }); <mask> } <mask> } catch (error: any) { <mask> window.alert(t("alerts.errorLoadingLibrary")); <mask> console.error(error); <mask> } finally { <mask> this.focusContainer(); <mask> } <mask> }; </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove await this.library.importLibrary(blob, "published"); // hack to rerender the library items after import if (this.state.isLibraryOpen) { this.setState({ isLibraryOpen: false }); } this.setState({ isLibraryOpen: true }); </s> add await this.library.importLibrary(libraryItems, defaultStatus); </s> add this.setState({ errorMessage: t("errors.importLibraryError") }); </s> remove const libraryItems = this.app.libraryItemsFromStorage; if (!libraryItems) { return resolve([]); } const items = restoreLibraryItems(libraryItems, "unpublished"); // clone to ensure we don't mutate the cached library elements in the app this.libraryCache = JSON.parse(JSON.stringify(items)); resolve(items); } catch (error: any) { console.error(error); resolve([]); </s> add resolve( cloneLibraryItems( await (this.libraryItemsPromise || this.lastLibraryItems), ), ); } catch (error) { return resolve(this.lastLibraryItems); </s> remove this.libraryCache = prevLibraryItems; </s> add this.lastLibraryItems = prevLibraryItems; this.libraryItemsPromise = null; jotaiStore.set(libraryItemsAtom, { status: "loaded", libraryItems: prevLibraryItems, }); </s> remove this.libraryItemsFromStorage = restoreLibraryItems( initialData.libraryItems, "unpublished", ) as LibraryItems; </s> add this.library.importLibrary(initialData.libraryItems, "unpublished"); </s> remove return libraryItems; } catch (e) { console.error(e); </s> add return libraryItems || []; } catch (error) { console.error(error);
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/components/App.tsx
keep add keep keep keep keep
<mask> } catch (error: any) { <mask> console.error(error); <mask> } finally { <mask> this.focusContainer(); <mask> } <mask> }; </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove window.alert(t("alerts.errorLoadingLibrary")); </s> add </s> remove await this.library.importLibrary(blob, "published"); // hack to rerender the library items after import if (this.state.isLibraryOpen) { this.setState({ isLibraryOpen: false }); } this.setState({ isLibraryOpen: true }); </s> add await this.library.importLibrary(libraryItems, defaultStatus); </s> remove this.libraryItemsFromStorage = restoreLibraryItems( initialData.libraryItems, "unpublished", ) as LibraryItems; </s> add this.library.importLibrary(initialData.libraryItems, "unpublished"); </s> remove const libraryItems = this.app.libraryItemsFromStorage; if (!libraryItems) { return resolve([]); } const items = restoreLibraryItems(libraryItems, "unpublished"); // clone to ensure we don't mutate the cached library elements in the app this.libraryCache = JSON.parse(JSON.stringify(items)); resolve(items); } catch (error: any) { console.error(error); resolve([]); </s> add resolve( cloneLibraryItems( await (this.libraryItemsPromise || this.lastLibraryItems), ), ); } catch (error) { return resolve(this.lastLibraryItems); </s> remove this.libraryCache = prevLibraryItems; </s> add this.lastLibraryItems = prevLibraryItems; this.libraryItemsPromise = null; jotaiStore.set(libraryItemsAtom, { status: "loaded", libraryItems: prevLibraryItems, }); </s> remove return libraryItems; } catch (e) { console.error(e); </s> add return libraryItems || []; } catch (error) { console.error(error);
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/components/App.tsx
keep keep keep keep replace replace replace replace keep keep keep keep keep
<mask> let initialData = null; <mask> try { <mask> initialData = (await this.props.initialData) || null; <mask> if (initialData?.libraryItems) { <mask> this.libraryItemsFromStorage = restoreLibraryItems( <mask> initialData.libraryItems, <mask> "unpublished", <mask> ) as LibraryItems; <mask> } <mask> } catch (error: any) { <mask> console.error(error); <mask> initialData = { <mask> appState: { </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove const serializedItems = JSON.stringify(items); // cache optimistically so that the app has access to the latest // immediately this.libraryCache = JSON.parse(serializedItems); await this.app.props.onLibraryChange?.(items); </s> add let nextLibraryItems; if (isPromiseLike(items)) { const promise = items.then((items) => cloneLibraryItems(items)); this.libraryItemsPromise = promise; jotaiStore.set(libraryItemsAtom, { status: "loading", promise, libraryItems: null, }); nextLibraryItems = await promise; } else { nextLibraryItems = cloneLibraryItems(items); } this.lastLibraryItems = nextLibraryItems; this.libraryItemsPromise = null; jotaiStore.set(libraryItemsAtom, { status: "loaded", libraryItems: nextLibraryItems, }); await this.app.props.onLibraryChange?.( cloneLibraryItems(nextLibraryItems), ); </s> remove this.libraryCache = prevLibraryItems; </s> add this.lastLibraryItems = prevLibraryItems; this.libraryItemsPromise = null; jotaiStore.set(libraryItemsAtom, { status: "loaded", libraryItems: prevLibraryItems, }); </s> remove const libraryFile = await loadLibraryFromBlob(blob); if (!libraryFile || !(libraryFile.libraryItems || libraryFile.library)) { return; } /** * checks if library item does not exist already in current library */ const isUniqueitem = ( existingLibraryItems: LibraryItems, targetLibraryItem: LibraryItem, ) => { return !existingLibraryItems.find((libraryItem) => { if (libraryItem.elements.length !== targetLibraryItem.elements.length) { return false; </s> add return this.saveLibrary( new Promise<LibraryItems>(async (resolve, reject) => { try { let libraryItems: LibraryItems; if (library instanceof Blob) { libraryItems = await loadLibraryFromBlob(library, defaultStatus); } else { libraryItems = restoreLibraryItems(await library, defaultStatus); } const existingLibraryItems = this.lastLibraryItems; const filteredItems = []; for (const item of libraryItems) { if (isUniqueItem(existingLibraryItems, item)) { filteredItems.push(item); } } resolve([...filteredItems, ...existingLibraryItems]); } catch (error) { reject(new Error(t("errors.importLibraryError"))); </s> remove const libraryItems = this.app.libraryItemsFromStorage; if (!libraryItems) { return resolve([]); } const items = restoreLibraryItems(libraryItems, "unpublished"); // clone to ensure we don't mutate the cached library elements in the app this.libraryCache = JSON.parse(JSON.stringify(items)); resolve(items); } catch (error: any) { console.error(error); resolve([]); </s> add resolve( cloneLibraryItems( await (this.libraryItemsPromise || this.lastLibraryItems), ), ); } catch (error) { return resolve(this.lastLibraryItems); </s> remove const libraryItems = JSON.parse( localStorage.getItem(STORAGE_KEYS.LOCAL_STORAGE_LIBRARY) as string, ) || []; </s> add const libraryItems: ImportedDataState["libraryItems"] = JSON.parse( localStorage.getItem(STORAGE_KEYS.LOCAL_STORAGE_LIBRARY) as string, ); </s> remove return libraryItems; } catch (e) { console.error(e); </s> add return libraryItems || []; } catch (error) { console.error(error);
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/components/App.tsx
keep keep add keep keep keep keep keep
<mask> import { KEYS } from "../keys"; <mask> import { arrayToMap } from "../utils"; <mask> import { trackEvent } from "../analytics"; <mask> <mask> const useOnClickOutside = ( <mask> ref: RefObject<HTMLElement>, <mask> cb: (event: MouseEvent) => void, <mask> ) => { </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> add import { Provider } from "jotai"; import { jotaiScope, jotaiStore } from "../../jotai"; </s> add import { ImportedDataState } from "../../data/types"; </s> remove import { ALLOWED_IMAGE_MIME_TYPES, EXPORT_DATA_TYPES, MIME_TYPES, } from "../constants"; </s> add import { ALLOWED_IMAGE_MIME_TYPES, MIME_TYPES } from "../constants"; </s> remove import { ImportedDataState } from "../data/types"; </s> add </s> add ExcalidrawInitialDataState, </s> remove private libraryCache: LibraryItems | null = null; </s> add /** cache for currently active promise when initializing/updating libaries asynchronously */ private libraryItemsPromise: Promise<LibraryItems> | null = null; /** last resolved libraryItems */ private lastLibraryItems: LibraryItems = [];
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/components/LibraryMenu.tsx
keep keep keep keep replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> <mask> const removeFromLibrary = useCallback(async () => { <mask> const items = await library.loadLibrary(); <mask> <mask> const nextItems = items.filter((item) => !selectedItems.includes(item.id)); <mask> library.saveLibrary(nextItems).catch((error) => { <mask> setLibraryItems(items); <mask> setAppState({ errorMessage: t("alerts.errorRemovingFromLibrary") }); <mask> }); <mask> setSelectedItems([]); <mask> setLibraryItems(nextItems); <mask> }, [library, setAppState, selectedItems, setSelectedItems]); <mask> <mask> const resetLibrary = useCallback(() => { <mask> library.resetLibrary(); <mask> setLibraryItems([]); <mask> focusContainer(); </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove setLibraryItems(nextItems); </s> add </s> remove await this.app.props.onLibraryChange?.([]); this.libraryCache = []; </s> add this.saveLibrary([]); </s> remove // detect z-index difference by checking the excalidraw elements // are in order return libraryItem.elements.every((libItemExcalidrawItem, idx) => { return ( libItemExcalidrawItem.id === targetLibraryItem.elements[idx].id && libItemExcalidrawItem.versionNonce === targetLibraryItem.elements[idx].versionNonce ); }); }); }; const existingLibraryItems = await this.loadLibrary(); const library = libraryFile.libraryItems || libraryFile.library || []; const restoredLibItems = restoreLibraryItems(library, defaultStatus); const filteredItems = []; for (const item of restoredLibItems) { if (isUniqueitem(existingLibraryItems, item)) { filteredItems.push(item); } } await this.saveLibrary([...filteredItems, ...existingLibraryItems]); </s> add }), ); </s> remove const serializedItems = JSON.stringify(items); // cache optimistically so that the app has access to the latest // immediately this.libraryCache = JSON.parse(serializedItems); await this.app.props.onLibraryChange?.(items); </s> add let nextLibraryItems; if (isPromiseLike(items)) { const promise = items.then((items) => cloneLibraryItems(items)); this.libraryItemsPromise = promise; jotaiStore.set(libraryItemsAtom, { status: "loading", promise, libraryItems: null, }); nextLibraryItems = await promise; } else { nextLibraryItems = cloneLibraryItems(items); } this.lastLibraryItems = nextLibraryItems; this.libraryItemsPromise = null; jotaiStore.set(libraryItemsAtom, { status: "loaded", libraryItems: nextLibraryItems, }); await this.app.props.onLibraryChange?.( cloneLibraryItems(nextLibraryItems), ); </s> remove saveLibrary = async (items: LibraryItems) => { const prevLibraryItems = this.libraryCache; </s> add saveLibrary = async (items: LibraryItems | Promise<LibraryItems>) => { const prevLibraryItems = this.lastLibraryItems; </s> remove const libraryItems = this.app.libraryItemsFromStorage; if (!libraryItems) { return resolve([]); } const items = restoreLibraryItems(libraryItems, "unpublished"); // clone to ensure we don't mutate the cached library elements in the app this.libraryCache = JSON.parse(JSON.stringify(items)); resolve(items); } catch (error: any) { console.error(error); resolve([]); </s> add resolve( cloneLibraryItems( await (this.libraryItemsPromise || this.lastLibraryItems), ), ); } catch (error) { return resolve(this.lastLibraryItems);
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/components/LibraryMenu.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> library.saveLibrary(nextItems).catch((error) => { <mask> setLibraryItems(items); <mask> setAppState({ errorMessage: t("alerts.errorAddingToLibrary") }); <mask> }); <mask> setLibraryItems(nextItems); <mask> }, <mask> [onAddToLibrary, library, setAppState], <mask> ); <mask> <mask> const renderPublishSuccess = useCallback(() => { </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove const nextItems = items.filter((item) => !selectedItems.includes(item.id)); library.saveLibrary(nextItems).catch((error) => { setLibraryItems(items); setAppState({ errorMessage: t("alerts.errorRemovingFromLibrary") }); }); setSelectedItems([]); setLibraryItems(nextItems); }, [library, setAppState, selectedItems, setSelectedItems]); </s> add const removeFromLibrary = useCallback( async (libraryItems: LibraryItems) => { const nextItems = libraryItems.filter( (item) => !selectedItems.includes(item.id), ); library.saveLibrary(nextItems).catch(() => { setAppState({ errorMessage: t("alerts.errorRemovingFromLibrary") }); }); setSelectedItems([]); }, [library, setAppState, selectedItems, setSelectedItems], ); </s> remove // detect z-index difference by checking the excalidraw elements // are in order return libraryItem.elements.every((libItemExcalidrawItem, idx) => { return ( libItemExcalidrawItem.id === targetLibraryItem.elements[idx].id && libItemExcalidrawItem.versionNonce === targetLibraryItem.elements[idx].versionNonce ); }); }); }; const existingLibraryItems = await this.loadLibrary(); const library = libraryFile.libraryItems || libraryFile.library || []; const restoredLibItems = restoreLibraryItems(library, defaultStatus); const filteredItems = []; for (const item of restoredLibItems) { if (isUniqueitem(existingLibraryItems, item)) { filteredItems.push(item); } } await this.saveLibrary([...filteredItems, ...existingLibraryItems]); </s> add }), ); </s> remove {loadingState === "loading" ? ( <div className="layer-ui__library-message"> {t("labels.libraryLoadingMessage")} </div> ) : ( <LibraryMenuItems libraryItems={libraryItems} onRemoveFromLibrary={removeFromLibrary} onAddToLibrary={addToLibrary} onInsertShape={onInsertShape} pendingElements={pendingElements} setAppState={setAppState} libraryReturnUrl={libraryReturnUrl} library={library} theme={theme} files={files} id={id} selectedItems={selectedItems} onToggle={(id, event) => { const shouldSelect = !selectedItems.includes(id); if (shouldSelect) { if (event.shiftKey && lastSelectedItem) { const rangeStart = libraryItems.findIndex( (item) => item.id === lastSelectedItem, ); const rangeEnd = libraryItems.findIndex( (item) => item.id === id, ); if (rangeStart === -1 || rangeEnd === -1) { setSelectedItems([...selectedItems, id]); return; } const selectedItemsMap = arrayToMap(selectedItems); const nextSelectedIds = libraryItems.reduce( (acc: LibraryItem["id"][], item, idx) => { if ( (idx >= rangeStart && idx <= rangeEnd) || selectedItemsMap.has(item.id) ) { acc.push(item.id); } return acc; }, [], ); </s> add if (shouldSelect) { if (event.shiftKey && lastSelectedItem) { const rangeStart = libraryItemsData.libraryItems.findIndex( (item) => item.id === lastSelectedItem, ); const rangeEnd = libraryItemsData.libraryItems.findIndex( (item) => item.id === id, ); </s> remove const serializedItems = JSON.stringify(items); // cache optimistically so that the app has access to the latest // immediately this.libraryCache = JSON.parse(serializedItems); await this.app.props.onLibraryChange?.(items); </s> add let nextLibraryItems; if (isPromiseLike(items)) { const promise = items.then((items) => cloneLibraryItems(items)); this.libraryItemsPromise = promise; jotaiStore.set(libraryItemsAtom, { status: "loading", promise, libraryItems: null, }); nextLibraryItems = await promise; } else { nextLibraryItems = cloneLibraryItems(items); } this.lastLibraryItems = nextLibraryItems; this.libraryItemsPromise = null; jotaiStore.set(libraryItemsAtom, { status: "loaded", libraryItems: nextLibraryItems, }); await this.app.props.onLibraryChange?.( cloneLibraryItems(nextLibraryItems), ); </s> add this.setState({ errorMessage: t("errors.importLibraryError") }); </s> remove saveLibrary = async (items: LibraryItems) => { const prevLibraryItems = this.libraryCache; </s> add saveLibrary = async (items: LibraryItems | Promise<LibraryItems>) => { const prevLibraryItems = this.lastLibraryItems;
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/components/LibraryMenu.tsx
keep keep keep keep replace replace keep keep keep keep keep
<mask> const [lastSelectedItem, setLastSelectedItem] = useState< <mask> LibraryItem["id"] | null <mask> >(null); <mask> <mask> return loadingState === "preloading" ? null : ( <mask> <Island padding={1} ref={ref} className="layer-ui__library"> <mask> {showPublishLibraryDialog && ( <mask> <PublishLibrary <mask> onClose={() => setShowPublishLibraryDialog(false)} <mask> libraryItems={getSelectedItems(libraryItems, selectedItems)} <mask> appState={appState} </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove {loadingState === "loading" ? ( <div className="layer-ui__library-message"> {t("labels.libraryLoadingMessage")} </div> ) : ( <LibraryMenuItems libraryItems={libraryItems} onRemoveFromLibrary={removeFromLibrary} onAddToLibrary={addToLibrary} onInsertShape={onInsertShape} pendingElements={pendingElements} setAppState={setAppState} libraryReturnUrl={libraryReturnUrl} library={library} theme={theme} files={files} id={id} selectedItems={selectedItems} onToggle={(id, event) => { const shouldSelect = !selectedItems.includes(id); if (shouldSelect) { if (event.shiftKey && lastSelectedItem) { const rangeStart = libraryItems.findIndex( (item) => item.id === lastSelectedItem, ); const rangeEnd = libraryItems.findIndex( (item) => item.id === id, ); if (rangeStart === -1 || rangeEnd === -1) { setSelectedItems([...selectedItems, id]); return; } const selectedItemsMap = arrayToMap(selectedItems); const nextSelectedIds = libraryItems.reduce( (acc: LibraryItem["id"][], item, idx) => { if ( (idx >= rangeStart && idx <= rangeEnd) || selectedItemsMap.has(item.id) ) { acc.push(item.id); } return acc; }, [], ); </s> add if (shouldSelect) { if (event.shiftKey && lastSelectedItem) { const rangeStart = libraryItemsData.libraryItems.findIndex( (item) => item.id === lastSelectedItem, ); const rangeEnd = libraryItemsData.libraryItems.findIndex( (item) => item.id === id, ); </s> remove { scene: ImportedDataState | null } & ( </s> add { scene: ExcalidrawInitialDataState | null } & ( </s> remove export const isValidLibrary = (json: any) => { </s> add export const isValidLibrary = (json: any): json is ImportedLibraryData => { </s> remove updateItemsInStorage={() => library.saveLibrary(libraryItems)} </s> add updateItemsInStorage={() => library.saveLibrary(libraryItemsData.libraryItems) } </s> remove libraryItems: NonOptional<ImportedDataState["libraryItems"]>, </s> add libraryItems: ImportedDataState["libraryItems"] = [], </s> remove initialData?: ImportedDataState | null | Promise<ImportedDataState | null>; </s> add initialData?: | ExcalidrawInitialDataState | null | Promise<ExcalidrawInitialDataState | null>;
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/components/LibraryMenu.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> libraryItems={getSelectedItems(libraryItems, selectedItems)} <mask> appState={appState} <mask> onSuccess={onPublishLibSuccess} <mask> onError={(error) => window.alert(error)} <mask> updateItemsInStorage={() => library.saveLibrary(libraryItems)} <mask> onRemove={(id: string) => <mask> setSelectedItems(selectedItems.filter((_id) => _id !== id)) <mask> } <mask> /> <mask> )} </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove setLastSelectedItem(null); setSelectedItems(selectedItems.filter((_id) => _id !== id)); </s> add setSelectedItems([...selectedItems, id]); </s> remove return loadingState === "preloading" ? null : ( <Island padding={1} ref={ref} className="layer-ui__library"> </s> add if (libraryItemsData.status === "loading") { return ( <LibraryMenuWrapper ref={ref}> <div className="layer-ui__library-message"> <Spinner size="2em" /> <span>{t("labels.libraryLoadingMessage")}</span> </div> </LibraryMenuWrapper> ); } return ( <LibraryMenuWrapper ref={ref}> </s> add import { ImportedDataState } from "../../data/types"; </s> remove {loadingState === "loading" ? ( <div className="layer-ui__library-message"> {t("labels.libraryLoadingMessage")} </div> ) : ( <LibraryMenuItems libraryItems={libraryItems} onRemoveFromLibrary={removeFromLibrary} onAddToLibrary={addToLibrary} onInsertShape={onInsertShape} pendingElements={pendingElements} setAppState={setAppState} libraryReturnUrl={libraryReturnUrl} library={library} theme={theme} files={files} id={id} selectedItems={selectedItems} onToggle={(id, event) => { const shouldSelect = !selectedItems.includes(id); if (shouldSelect) { if (event.shiftKey && lastSelectedItem) { const rangeStart = libraryItems.findIndex( (item) => item.id === lastSelectedItem, ); const rangeEnd = libraryItems.findIndex( (item) => item.id === id, ); if (rangeStart === -1 || rangeEnd === -1) { setSelectedItems([...selectedItems, id]); return; } const selectedItemsMap = arrayToMap(selectedItems); const nextSelectedIds = libraryItems.reduce( (acc: LibraryItem["id"][], item, idx) => { if ( (idx >= rangeStart && idx <= rangeEnd) || selectedItemsMap.has(item.id) ) { acc.push(item.id); } return acc; }, [], ); </s> add if (shouldSelect) { if (event.shiftKey && lastSelectedItem) { const rangeStart = libraryItemsData.libraryItems.findIndex( (item) => item.id === lastSelectedItem, ); const rangeEnd = libraryItemsData.libraryItems.findIndex( (item) => item.id === id, ); </s> remove // detect z-index difference by checking the excalidraw elements // are in order return libraryItem.elements.every((libItemExcalidrawItem, idx) => { return ( libItemExcalidrawItem.id === targetLibraryItem.elements[idx].id && libItemExcalidrawItem.versionNonce === targetLibraryItem.elements[idx].versionNonce ); }); }); }; const existingLibraryItems = await this.loadLibrary(); const library = libraryFile.libraryItems || libraryFile.library || []; const restoredLibItems = restoreLibraryItems(library, defaultStatus); const filteredItems = []; for (const item of restoredLibItems) { if (isUniqueitem(existingLibraryItems, item)) { filteredItems.push(item); } } await this.saveLibrary([...filteredItems, ...existingLibraryItems]); </s> add }), ); </s> remove const libraryFile = await loadLibraryFromBlob(blob); if (!libraryFile || !(libraryFile.libraryItems || libraryFile.library)) { return; } /** * checks if library item does not exist already in current library */ const isUniqueitem = ( existingLibraryItems: LibraryItems, targetLibraryItem: LibraryItem, ) => { return !existingLibraryItems.find((libraryItem) => { if (libraryItem.elements.length !== targetLibraryItem.elements.length) { return false; </s> add return this.saveLibrary( new Promise<LibraryItems>(async (resolve, reject) => { try { let libraryItems: LibraryItems; if (library instanceof Blob) { libraryItems = await loadLibraryFromBlob(library, defaultStatus); } else { libraryItems = restoreLibraryItems(await library, defaultStatus); } const existingLibraryItems = this.lastLibraryItems; const filteredItems = []; for (const item of libraryItems) { if (isUniqueItem(existingLibraryItems, item)) { filteredItems.push(item); } } resolve([...filteredItems, ...existingLibraryItems]); } catch (error) { reject(new Error(t("errors.importLibraryError")));
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/components/LibraryMenu.tsx
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> /> <mask> )} <mask> {publishLibSuccess && renderPublishSuccess()} <mask> <mask> {loadingState === "loading" ? ( <mask> <div className="layer-ui__library-message"> <mask> {t("labels.libraryLoadingMessage")} <mask> </div> <mask> ) : ( <mask> <LibraryMenuItems <mask> libraryItems={libraryItems} <mask> onRemoveFromLibrary={removeFromLibrary} <mask> onAddToLibrary={addToLibrary} <mask> onInsertShape={onInsertShape} <mask> pendingElements={pendingElements} <mask> setAppState={setAppState} <mask> libraryReturnUrl={libraryReturnUrl} <mask> library={library} <mask> theme={theme} <mask> files={files} <mask> id={id} <mask> selectedItems={selectedItems} <mask> onToggle={(id, event) => { <mask> const shouldSelect = !selectedItems.includes(id); <mask> <mask> if (shouldSelect) { <mask> if (event.shiftKey && lastSelectedItem) { <mask> const rangeStart = libraryItems.findIndex( <mask> (item) => item.id === lastSelectedItem, <mask> ); <mask> const rangeEnd = libraryItems.findIndex( <mask> (item) => item.id === id, <mask> ); <mask> <mask> if (rangeStart === -1 || rangeEnd === -1) { <mask> setSelectedItems([...selectedItems, id]); <mask> return; <mask> } <mask> <mask> const selectedItemsMap = arrayToMap(selectedItems); <mask> const nextSelectedIds = libraryItems.reduce( <mask> (acc: LibraryItem["id"][], item, idx) => { <mask> if ( <mask> (idx >= rangeStart && idx <= rangeEnd) || <mask> selectedItemsMap.has(item.id) <mask> ) { <mask> acc.push(item.id); <mask> } <mask> return acc; <mask> }, <mask> [], <mask> ); <mask> <mask> setSelectedItems(nextSelectedIds); <mask> } else { <mask> setSelectedItems([...selectedItems, id]); <mask> } </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove return loadingState === "preloading" ? null : ( <Island padding={1} ref={ref} className="layer-ui__library"> </s> add if (libraryItemsData.status === "loading") { return ( <LibraryMenuWrapper ref={ref}> <div className="layer-ui__library-message"> <Spinner size="2em" /> <span>{t("labels.libraryLoadingMessage")}</span> </div> </LibraryMenuWrapper> ); } return ( <LibraryMenuWrapper ref={ref}> </s> remove export const isValidLibrary = (json: any) => { </s> add export const isValidLibrary = (json: any): json is ImportedLibraryData => { </s> remove // detect z-index difference by checking the excalidraw elements // are in order return libraryItem.elements.every((libItemExcalidrawItem, idx) => { return ( libItemExcalidrawItem.id === targetLibraryItem.elements[idx].id && libItemExcalidrawItem.versionNonce === targetLibraryItem.elements[idx].versionNonce ); }); }); }; const existingLibraryItems = await this.loadLibrary(); const library = libraryFile.libraryItems || libraryFile.library || []; const restoredLibItems = restoreLibraryItems(library, defaultStatus); const filteredItems = []; for (const item of restoredLibItems) { if (isUniqueitem(existingLibraryItems, item)) { filteredItems.push(item); } } await this.saveLibrary([...filteredItems, ...existingLibraryItems]); </s> add }), ); </s> remove setLastSelectedItem(null); setSelectedItems(selectedItems.filter((_id) => _id !== id)); </s> add setSelectedItems([...selectedItems, id]); </s> remove const libraryFile = await loadLibraryFromBlob(blob); if (!libraryFile || !(libraryFile.libraryItems || libraryFile.library)) { return; } /** * checks if library item does not exist already in current library */ const isUniqueitem = ( existingLibraryItems: LibraryItems, targetLibraryItem: LibraryItem, ) => { return !existingLibraryItems.find((libraryItem) => { if (libraryItem.elements.length !== targetLibraryItem.elements.length) { return false; </s> add return this.saveLibrary( new Promise<LibraryItems>(async (resolve, reject) => { try { let libraryItems: LibraryItems; if (library instanceof Blob) { libraryItems = await loadLibraryFromBlob(library, defaultStatus); } else { libraryItems = restoreLibraryItems(await library, defaultStatus); } const existingLibraryItems = this.lastLibraryItems; const filteredItems = []; for (const item of libraryItems) { if (isUniqueItem(existingLibraryItems, item)) { filteredItems.push(item); } } resolve([...filteredItems, ...existingLibraryItems]); } catch (error) { reject(new Error(t("errors.importLibraryError"))); </s> remove libraryItems: NonOptional<ImportedDataState["libraryItems"]>, </s> add libraryItems: ImportedDataState["libraryItems"] = [],
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/components/LibraryMenu.tsx
keep keep keep keep replace replace keep keep keep keep keep
<mask> setSelectedItems([...selectedItems, id]); <mask> } <mask> setLastSelectedItem(id); <mask> } else { <mask> setLastSelectedItem(null); <mask> setSelectedItems(selectedItems.filter((_id) => _id !== id)); <mask> } <mask> }} <mask> onPublish={() => setShowPublishLibraryDialog(true)} <mask> resetLibrary={resetLibrary} <mask> /> </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove updateItemsInStorage={() => library.saveLibrary(libraryItems)} </s> add updateItemsInStorage={() => library.saveLibrary(libraryItemsData.libraryItems) } </s> remove {loadingState === "loading" ? ( <div className="layer-ui__library-message"> {t("labels.libraryLoadingMessage")} </div> ) : ( <LibraryMenuItems libraryItems={libraryItems} onRemoveFromLibrary={removeFromLibrary} onAddToLibrary={addToLibrary} onInsertShape={onInsertShape} pendingElements={pendingElements} setAppState={setAppState} libraryReturnUrl={libraryReturnUrl} library={library} theme={theme} files={files} id={id} selectedItems={selectedItems} onToggle={(id, event) => { const shouldSelect = !selectedItems.includes(id); if (shouldSelect) { if (event.shiftKey && lastSelectedItem) { const rangeStart = libraryItems.findIndex( (item) => item.id === lastSelectedItem, ); const rangeEnd = libraryItems.findIndex( (item) => item.id === id, ); if (rangeStart === -1 || rangeEnd === -1) { setSelectedItems([...selectedItems, id]); return; } const selectedItemsMap = arrayToMap(selectedItems); const nextSelectedIds = libraryItems.reduce( (acc: LibraryItem["id"][], item, idx) => { if ( (idx >= rangeStart && idx <= rangeEnd) || selectedItemsMap.has(item.id) ) { acc.push(item.id); } return acc; }, [], ); </s> add if (shouldSelect) { if (event.shiftKey && lastSelectedItem) { const rangeStart = libraryItemsData.libraryItems.findIndex( (item) => item.id === lastSelectedItem, ); const rangeEnd = libraryItemsData.libraryItems.findIndex( (item) => item.id === id, ); </s> remove const libraryFile = await loadLibraryFromBlob(blob); if (!libraryFile || !(libraryFile.libraryItems || libraryFile.library)) { return; } /** * checks if library item does not exist already in current library */ const isUniqueitem = ( existingLibraryItems: LibraryItems, targetLibraryItem: LibraryItem, ) => { return !existingLibraryItems.find((libraryItem) => { if (libraryItem.elements.length !== targetLibraryItem.elements.length) { return false; </s> add return this.saveLibrary( new Promise<LibraryItems>(async (resolve, reject) => { try { let libraryItems: LibraryItems; if (library instanceof Blob) { libraryItems = await loadLibraryFromBlob(library, defaultStatus); } else { libraryItems = restoreLibraryItems(await library, defaultStatus); } const existingLibraryItems = this.lastLibraryItems; const filteredItems = []; for (const item of libraryItems) { if (isUniqueItem(existingLibraryItems, item)) { filteredItems.push(item); } } resolve([...filteredItems, ...existingLibraryItems]); } catch (error) { reject(new Error(t("errors.importLibraryError"))); </s> remove // detect z-index difference by checking the excalidraw elements // are in order return libraryItem.elements.every((libItemExcalidrawItem, idx) => { return ( libItemExcalidrawItem.id === targetLibraryItem.elements[idx].id && libItemExcalidrawItem.versionNonce === targetLibraryItem.elements[idx].versionNonce ); }); }); }; const existingLibraryItems = await this.loadLibrary(); const library = libraryFile.libraryItems || libraryFile.library || []; const restoredLibItems = restoreLibraryItems(library, defaultStatus); const filteredItems = []; for (const item of restoredLibItems) { if (isUniqueitem(existingLibraryItems, item)) { filteredItems.push(item); } } await this.saveLibrary([...filteredItems, ...existingLibraryItems]); </s> add }), ); </s> remove if (this.libraryCache) { return resolve(JSON.parse(JSON.stringify(this.libraryCache))); } </s> add </s> add import { useAtom } from "jotai"; import { jotaiScope } from "../jotai"; import Spinner from "./Spinner";
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/components/LibraryMenu.tsx
keep keep replace replace replace replace replace keep keep keep keep keep
<mask> import { nanoid } from "nanoid"; <mask> import { cleanAppStateForExport } from "../appState"; <mask> import { <mask> ALLOWED_IMAGE_MIME_TYPES, <mask> EXPORT_DATA_TYPES, <mask> MIME_TYPES, <mask> } from "../constants"; <mask> import { clearElementsForExport } from "../element"; <mask> import { ExcalidrawElement, FileId } from "../element/types"; <mask> import { CanvasError } from "../errors"; <mask> import { t } from "../i18n"; <mask> import { calculateScrollCenter } from "../scene"; </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove import { ImportedDataState } from "../data/types"; </s> add </s> add import { useAtom } from "jotai"; import { jotaiScope } from "../jotai"; import Spinner from "./Spinner"; </s> add import { Provider } from "jotai"; import { jotaiScope, jotaiStore } from "../../jotai"; </s> add import { ImportedDataState } from "../../data/types"; </s> add ExcalidrawInitialDataState, </s> remove private libraryCache: LibraryItems | null = null; </s> add /** cache for currently active promise when initializing/updating libaries asynchronously */ private libraryItemsPromise: Promise<LibraryItems> | null = null; /** last resolved libraryItems */ private lastLibraryItems: LibraryItems = [];
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/data/blob.ts
keep keep add keep keep keep keep keep keep
<mask> ExportedDataState, <mask> ImportedDataState, <mask> ExportedLibraryData, <mask> } from "./types"; <mask> import Library from "./library"; <mask> <mask> /** <mask> * Strips out files which are only referenced by deleted elements <mask> */ </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove private libraryCache: LibraryItems | null = null; </s> add /** cache for currently active promise when initializing/updating libaries asynchronously */ private libraryItemsPromise: Promise<LibraryItems> | null = null; /** last resolved libraryItems */ private lastLibraryItems: LibraryItems = []; </s> remove import { ALLOWED_IMAGE_MIME_TYPES, EXPORT_DATA_TYPES, MIME_TYPES, } from "../constants"; </s> add import { ALLOWED_IMAGE_MIME_TYPES, MIME_TYPES } from "../constants"; </s> add import { useAtom } from "jotai"; import { jotaiScope } from "../jotai"; import Spinner from "./Spinner"; </s> remove import { ImportedDataState } from "../data/types"; </s> add </s> add import { Provider } from "jotai"; import { jotaiScope, jotaiStore } from "../../jotai"; </s> add import { ImportedDataState } from "../../data/types";
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/data/json.ts
keep keep keep keep replace keep keep keep keep keep
<mask> (!data.appState || typeof data.appState === "object"))) <mask> ); <mask> }; <mask> <mask> export const isValidLibrary = (json: any) => { <mask> return ( <mask> typeof json === "object" && <mask> json && <mask> json.type === EXPORT_DATA_TYPES.excalidrawLibrary && <mask> (json.version === 1 || json.version === 2) </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove {loadingState === "loading" ? ( <div className="layer-ui__library-message"> {t("labels.libraryLoadingMessage")} </div> ) : ( <LibraryMenuItems libraryItems={libraryItems} onRemoveFromLibrary={removeFromLibrary} onAddToLibrary={addToLibrary} onInsertShape={onInsertShape} pendingElements={pendingElements} setAppState={setAppState} libraryReturnUrl={libraryReturnUrl} library={library} theme={theme} files={files} id={id} selectedItems={selectedItems} onToggle={(id, event) => { const shouldSelect = !selectedItems.includes(id); if (shouldSelect) { if (event.shiftKey && lastSelectedItem) { const rangeStart = libraryItems.findIndex( (item) => item.id === lastSelectedItem, ); const rangeEnd = libraryItems.findIndex( (item) => item.id === id, ); if (rangeStart === -1 || rangeEnd === -1) { setSelectedItems([...selectedItems, id]); return; } const selectedItemsMap = arrayToMap(selectedItems); const nextSelectedIds = libraryItems.reduce( (acc: LibraryItem["id"][], item, idx) => { if ( (idx >= rangeStart && idx <= rangeEnd) || selectedItemsMap.has(item.id) ) { acc.push(item.id); } return acc; }, [], ); </s> add if (shouldSelect) { if (event.shiftKey && lastSelectedItem) { const rangeStart = libraryItemsData.libraryItems.findIndex( (item) => item.id === lastSelectedItem, ); const rangeEnd = libraryItemsData.libraryItems.findIndex( (item) => item.id === id, ); </s> remove return loadingState === "preloading" ? null : ( <Island padding={1} ref={ref} className="layer-ui__library"> </s> add if (libraryItemsData.status === "loading") { return ( <LibraryMenuWrapper ref={ref}> <div className="layer-ui__library-message"> <Spinner size="2em" /> <span>{t("labels.libraryLoadingMessage")}</span> </div> </LibraryMenuWrapper> ); } return ( <LibraryMenuWrapper ref={ref}> </s> remove // detect z-index difference by checking the excalidraw elements // are in order return libraryItem.elements.every((libItemExcalidrawItem, idx) => { return ( libItemExcalidrawItem.id === targetLibraryItem.elements[idx].id && libItemExcalidrawItem.versionNonce === targetLibraryItem.elements[idx].versionNonce ); }); }); }; const existingLibraryItems = await this.loadLibrary(); const library = libraryFile.libraryItems || libraryFile.library || []; const restoredLibItems = restoreLibraryItems(library, defaultStatus); const filteredItems = []; for (const item of restoredLibItems) { if (isUniqueitem(existingLibraryItems, item)) { filteredItems.push(item); } } await this.saveLibrary([...filteredItems, ...existingLibraryItems]); </s> add }), ); </s> remove numShapes: (json.libraryItems || json.library || []).length, </s> add numShapes: libraryItems.length, </s> remove const libraryItems = JSON.parse( localStorage.getItem(STORAGE_KEYS.LOCAL_STORAGE_LIBRARY) as string, ) || []; </s> add const libraryItems: ImportedDataState["libraryItems"] = JSON.parse( localStorage.getItem(STORAGE_KEYS.LOCAL_STORAGE_LIBRARY) as string, ); </s> remove const libraryItems = this.app.libraryItemsFromStorage; if (!libraryItems) { return resolve([]); } const items = restoreLibraryItems(libraryItems, "unpublished"); // clone to ensure we don't mutate the cached library elements in the app this.libraryCache = JSON.parse(JSON.stringify(items)); resolve(items); } catch (error: any) { console.error(error); resolve([]); </s> add resolve( cloneLibraryItems( await (this.libraryItemsPromise || this.lastLibraryItems), ), ); } catch (error) { return resolve(this.lastLibraryItems);
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/data/json.ts
keep keep keep keep replace keep keep keep keep keep
<mask> import { restoreLibraryItems } from "./restore"; <mask> import type App from "../components/App"; <mask> <mask> class Library { <mask> private libraryCache: LibraryItems | null = null; <mask> private app: App; <mask> <mask> constructor(app: App) { <mask> this.app = app; <mask> } </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> add import { useAtom } from "jotai"; import { jotaiScope } from "../jotai"; import Spinner from "./Spinner"; </s> add import { Provider } from "jotai"; import { jotaiScope, jotaiStore } from "../../jotai"; </s> add import { ImportedDataState } from "../../data/types"; </s> remove import { ALLOWED_IMAGE_MIME_TYPES, EXPORT_DATA_TYPES, MIME_TYPES, } from "../constants"; </s> add import { ALLOWED_IMAGE_MIME_TYPES, MIME_TYPES } from "../constants"; </s> remove { scene: ImportedDataState | null } & ( </s> add { scene: ExcalidrawInitialDataState | null } & ( </s> remove import { ImportedDataState } from "../data/types"; </s> add
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/data/library.ts
keep keep replace replace keep keep keep keep replace keep
<mask> <mask> resetLibrary = async () => { <mask> await this.app.props.onLibraryChange?.([]); <mask> this.libraryCache = []; <mask> }; <mask> <mask> /** imports library (currently merges, removing duplicates) */ <mask> async importLibrary( <mask> blob: Blob, <mask> defaultStatus: LibraryItem["status"] = "unpublished", </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove const libraryFile = await loadLibraryFromBlob(blob); if (!libraryFile || !(libraryFile.libraryItems || libraryFile.library)) { return; } /** * checks if library item does not exist already in current library */ const isUniqueitem = ( existingLibraryItems: LibraryItems, targetLibraryItem: LibraryItem, ) => { return !existingLibraryItems.find((libraryItem) => { if (libraryItem.elements.length !== targetLibraryItem.elements.length) { return false; </s> add return this.saveLibrary( new Promise<LibraryItems>(async (resolve, reject) => { try { let libraryItems: LibraryItems; if (library instanceof Blob) { libraryItems = await loadLibraryFromBlob(library, defaultStatus); } else { libraryItems = restoreLibraryItems(await library, defaultStatus); } const existingLibraryItems = this.lastLibraryItems; const filteredItems = []; for (const item of libraryItems) { if (isUniqueItem(existingLibraryItems, item)) { filteredItems.push(item); } } resolve([...filteredItems, ...existingLibraryItems]); } catch (error) { reject(new Error(t("errors.importLibraryError"))); </s> remove const nextItems = items.filter((item) => !selectedItems.includes(item.id)); library.saveLibrary(nextItems).catch((error) => { setLibraryItems(items); setAppState({ errorMessage: t("alerts.errorRemovingFromLibrary") }); }); setSelectedItems([]); setLibraryItems(nextItems); }, [library, setAppState, selectedItems, setSelectedItems]); </s> add const removeFromLibrary = useCallback( async (libraryItems: LibraryItems) => { const nextItems = libraryItems.filter( (item) => !selectedItems.includes(item.id), ); library.saveLibrary(nextItems).catch(() => { setAppState({ errorMessage: t("alerts.errorRemovingFromLibrary") }); }); setSelectedItems([]); }, [library, setAppState, selectedItems, setSelectedItems], ); </s> remove saveLibrary = async (items: LibraryItems) => { const prevLibraryItems = this.libraryCache; </s> add saveLibrary = async (items: LibraryItems | Promise<LibraryItems>) => { const prevLibraryItems = this.lastLibraryItems; </s> remove const serializedItems = JSON.stringify(items); // cache optimistically so that the app has access to the latest // immediately this.libraryCache = JSON.parse(serializedItems); await this.app.props.onLibraryChange?.(items); </s> add let nextLibraryItems; if (isPromiseLike(items)) { const promise = items.then((items) => cloneLibraryItems(items)); this.libraryItemsPromise = promise; jotaiStore.set(libraryItemsAtom, { status: "loading", promise, libraryItems: null, }); nextLibraryItems = await promise; } else { nextLibraryItems = cloneLibraryItems(items); } this.lastLibraryItems = nextLibraryItems; this.libraryItemsPromise = null; jotaiStore.set(libraryItemsAtom, { status: "loaded", libraryItems: nextLibraryItems, }); await this.app.props.onLibraryChange?.( cloneLibraryItems(nextLibraryItems), ); </s> remove const libraryItems = this.app.libraryItemsFromStorage; if (!libraryItems) { return resolve([]); } const items = restoreLibraryItems(libraryItems, "unpublished"); // clone to ensure we don't mutate the cached library elements in the app this.libraryCache = JSON.parse(JSON.stringify(items)); resolve(items); } catch (error: any) { console.error(error); resolve([]); </s> add resolve( cloneLibraryItems( await (this.libraryItemsPromise || this.lastLibraryItems), ), ); } catch (error) { return resolve(this.lastLibraryItems);
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/data/library.ts
keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep
<mask> ) { <mask> const libraryFile = await loadLibraryFromBlob(blob); <mask> if (!libraryFile || !(libraryFile.libraryItems || libraryFile.library)) { <mask> return; <mask> } <mask> <mask> /** <mask> * checks if library item does not exist already in current library <mask> */ <mask> const isUniqueitem = ( <mask> existingLibraryItems: LibraryItems, <mask> targetLibraryItem: LibraryItem, <mask> ) => { <mask> return !existingLibraryItems.find((libraryItem) => { <mask> if (libraryItem.elements.length !== targetLibraryItem.elements.length) { <mask> return false; <mask> } <mask> <mask> // detect z-index difference by checking the excalidraw elements <mask> // are in order <mask> return libraryItem.elements.every((libItemExcalidrawItem, idx) => { <mask> return ( <mask> libItemExcalidrawItem.id === targetLibraryItem.elements[idx].id && <mask> libItemExcalidrawItem.versionNonce === <mask> targetLibraryItem.elements[idx].versionNonce <mask> ); <mask> }); <mask> }); <mask> }; <mask> <mask> const existingLibraryItems = await this.loadLibrary(); <mask> <mask> const library = libraryFile.libraryItems || libraryFile.library || []; <mask> const restoredLibItems = restoreLibraryItems(library, defaultStatus); <mask> const filteredItems = []; <mask> for (const item of restoredLibItems) { <mask> if (isUniqueitem(existingLibraryItems, item)) { <mask> filteredItems.push(item); <mask> } <mask> } <mask> <mask> await this.saveLibrary([...filteredItems, ...existingLibraryItems]); <mask> } <mask> </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove blob: Blob, </s> add library: | Blob | Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>, </s> remove const libraryItems = this.app.libraryItemsFromStorage; if (!libraryItems) { return resolve([]); } const items = restoreLibraryItems(libraryItems, "unpublished"); // clone to ensure we don't mutate the cached library elements in the app this.libraryCache = JSON.parse(JSON.stringify(items)); resolve(items); } catch (error: any) { console.error(error); resolve([]); </s> add resolve( cloneLibraryItems( await (this.libraryItemsPromise || this.lastLibraryItems), ), ); } catch (error) { return resolve(this.lastLibraryItems); </s> remove {loadingState === "loading" ? ( <div className="layer-ui__library-message"> {t("labels.libraryLoadingMessage")} </div> ) : ( <LibraryMenuItems libraryItems={libraryItems} onRemoveFromLibrary={removeFromLibrary} onAddToLibrary={addToLibrary} onInsertShape={onInsertShape} pendingElements={pendingElements} setAppState={setAppState} libraryReturnUrl={libraryReturnUrl} library={library} theme={theme} files={files} id={id} selectedItems={selectedItems} onToggle={(id, event) => { const shouldSelect = !selectedItems.includes(id); if (shouldSelect) { if (event.shiftKey && lastSelectedItem) { const rangeStart = libraryItems.findIndex( (item) => item.id === lastSelectedItem, ); const rangeEnd = libraryItems.findIndex( (item) => item.id === id, ); if (rangeStart === -1 || rangeEnd === -1) { setSelectedItems([...selectedItems, id]); return; } const selectedItemsMap = arrayToMap(selectedItems); const nextSelectedIds = libraryItems.reduce( (acc: LibraryItem["id"][], item, idx) => { if ( (idx >= rangeStart && idx <= rangeEnd) || selectedItemsMap.has(item.id) ) { acc.push(item.id); } return acc; }, [], ); </s> add if (shouldSelect) { if (event.shiftKey && lastSelectedItem) { const rangeStart = libraryItemsData.libraryItems.findIndex( (item) => item.id === lastSelectedItem, ); const rangeEnd = libraryItemsData.libraryItems.findIndex( (item) => item.id === id, ); </s> remove libraryItems: NonOptional<ImportedDataState["libraryItems"]>, </s> add libraryItems: ImportedDataState["libraryItems"] = [], </s> remove await this.library.importLibrary(blob, "published"); // hack to rerender the library items after import if (this.state.isLibraryOpen) { this.setState({ isLibraryOpen: false }); } this.setState({ isLibraryOpen: true }); </s> add await this.library.importLibrary(libraryItems, defaultStatus);
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/data/library.ts
keep keep keep keep replace replace replace replace keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep
<mask> } <mask> <mask> loadLibrary = (): Promise<LibraryItems> => { <mask> return new Promise(async (resolve) => { <mask> if (this.libraryCache) { <mask> return resolve(JSON.parse(JSON.stringify(this.libraryCache))); <mask> } <mask> <mask> try { <mask> const libraryItems = this.app.libraryItemsFromStorage; <mask> if (!libraryItems) { <mask> return resolve([]); <mask> } <mask> <mask> const items = restoreLibraryItems(libraryItems, "unpublished"); <mask> <mask> // clone to ensure we don't mutate the cached library elements in the app <mask> this.libraryCache = JSON.parse(JSON.stringify(items)); <mask> <mask> resolve(items); <mask> } catch (error: any) { <mask> console.error(error); <mask> resolve([]); <mask> } </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove // detect z-index difference by checking the excalidraw elements // are in order return libraryItem.elements.every((libItemExcalidrawItem, idx) => { return ( libItemExcalidrawItem.id === targetLibraryItem.elements[idx].id && libItemExcalidrawItem.versionNonce === targetLibraryItem.elements[idx].versionNonce ); }); }); }; const existingLibraryItems = await this.loadLibrary(); const library = libraryFile.libraryItems || libraryFile.library || []; const restoredLibItems = restoreLibraryItems(library, defaultStatus); const filteredItems = []; for (const item of restoredLibItems) { if (isUniqueitem(existingLibraryItems, item)) { filteredItems.push(item); } } await this.saveLibrary([...filteredItems, ...existingLibraryItems]); </s> add }), ); </s> remove const libraryFile = await loadLibraryFromBlob(blob); if (!libraryFile || !(libraryFile.libraryItems || libraryFile.library)) { return; } /** * checks if library item does not exist already in current library */ const isUniqueitem = ( existingLibraryItems: LibraryItems, targetLibraryItem: LibraryItem, ) => { return !existingLibraryItems.find((libraryItem) => { if (libraryItem.elements.length !== targetLibraryItem.elements.length) { return false; </s> add return this.saveLibrary( new Promise<LibraryItems>(async (resolve, reject) => { try { let libraryItems: LibraryItems; if (library instanceof Blob) { libraryItems = await loadLibraryFromBlob(library, defaultStatus); } else { libraryItems = restoreLibraryItems(await library, defaultStatus); } const existingLibraryItems = this.lastLibraryItems; const filteredItems = []; for (const item of libraryItems) { if (isUniqueItem(existingLibraryItems, item)) { filteredItems.push(item); } } resolve([...filteredItems, ...existingLibraryItems]); } catch (error) { reject(new Error(t("errors.importLibraryError"))); </s> remove const serializedItems = JSON.stringify(items); // cache optimistically so that the app has access to the latest // immediately this.libraryCache = JSON.parse(serializedItems); await this.app.props.onLibraryChange?.(items); </s> add let nextLibraryItems; if (isPromiseLike(items)) { const promise = items.then((items) => cloneLibraryItems(items)); this.libraryItemsPromise = promise; jotaiStore.set(libraryItemsAtom, { status: "loading", promise, libraryItems: null, }); nextLibraryItems = await promise; } else { nextLibraryItems = cloneLibraryItems(items); } this.lastLibraryItems = nextLibraryItems; this.libraryItemsPromise = null; jotaiStore.set(libraryItemsAtom, { status: "loaded", libraryItems: nextLibraryItems, }); await this.app.props.onLibraryChange?.( cloneLibraryItems(nextLibraryItems), ); </s> remove this.libraryItemsFromStorage = restoreLibraryItems( initialData.libraryItems, "unpublished", ) as LibraryItems; </s> add this.library.importLibrary(initialData.libraryItems, "unpublished"); </s> remove saveLibrary = async (items: LibraryItems) => { const prevLibraryItems = this.libraryCache; </s> add saveLibrary = async (items: LibraryItems | Promise<LibraryItems>) => { const prevLibraryItems = this.lastLibraryItems;
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/data/library.ts
keep keep keep replace replace keep replace replace replace replace replace keep keep keep keep
<mask> }); <mask> }; <mask> <mask> saveLibrary = async (items: LibraryItems) => { <mask> const prevLibraryItems = this.libraryCache; <mask> try { <mask> const serializedItems = JSON.stringify(items); <mask> // cache optimistically so that the app has access to the latest <mask> // immediately <mask> this.libraryCache = JSON.parse(serializedItems); <mask> await this.app.props.onLibraryChange?.(items); <mask> } catch (error: any) { <mask> this.libraryCache = prevLibraryItems; <mask> throw error; <mask> } </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove this.libraryCache = prevLibraryItems; </s> add this.lastLibraryItems = prevLibraryItems; this.libraryItemsPromise = null; jotaiStore.set(libraryItemsAtom, { status: "loaded", libraryItems: prevLibraryItems, }); </s> remove const libraryItems = this.app.libraryItemsFromStorage; if (!libraryItems) { return resolve([]); } const items = restoreLibraryItems(libraryItems, "unpublished"); // clone to ensure we don't mutate the cached library elements in the app this.libraryCache = JSON.parse(JSON.stringify(items)); resolve(items); } catch (error: any) { console.error(error); resolve([]); </s> add resolve( cloneLibraryItems( await (this.libraryItemsPromise || this.lastLibraryItems), ), ); } catch (error) { return resolve(this.lastLibraryItems); </s> remove resolvablePromise<ImportedDataState | null>(); </s> add resolvablePromise<ExcalidrawInitialDataState | null>(); </s> remove await this.app.props.onLibraryChange?.([]); this.libraryCache = []; </s> add this.saveLibrary([]); </s> remove const libraryFile = await loadLibraryFromBlob(blob); if (!libraryFile || !(libraryFile.libraryItems || libraryFile.library)) { return; } /** * checks if library item does not exist already in current library */ const isUniqueitem = ( existingLibraryItems: LibraryItems, targetLibraryItem: LibraryItem, ) => { return !existingLibraryItems.find((libraryItem) => { if (libraryItem.elements.length !== targetLibraryItem.elements.length) { return false; </s> add return this.saveLibrary( new Promise<LibraryItems>(async (resolve, reject) => { try { let libraryItems: LibraryItems; if (library instanceof Blob) { libraryItems = await loadLibraryFromBlob(library, defaultStatus); } else { libraryItems = restoreLibraryItems(await library, defaultStatus); } const existingLibraryItems = this.lastLibraryItems; const filteredItems = []; for (const item of libraryItems) { if (isUniqueItem(existingLibraryItems, item)) { filteredItems.push(item); } } resolve([...filteredItems, ...existingLibraryItems]); } catch (error) { reject(new Error(t("errors.importLibraryError")));
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/data/library.ts
keep keep keep keep replace keep keep keep keep keep
<mask> // immediately <mask> this.libraryCache = JSON.parse(serializedItems); <mask> await this.app.props.onLibraryChange?.(items); <mask> } catch (error: any) { <mask> this.libraryCache = prevLibraryItems; <mask> throw error; <mask> } <mask> }; <mask> } <mask> </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove const serializedItems = JSON.stringify(items); // cache optimistically so that the app has access to the latest // immediately this.libraryCache = JSON.parse(serializedItems); await this.app.props.onLibraryChange?.(items); </s> add let nextLibraryItems; if (isPromiseLike(items)) { const promise = items.then((items) => cloneLibraryItems(items)); this.libraryItemsPromise = promise; jotaiStore.set(libraryItemsAtom, { status: "loading", promise, libraryItems: null, }); nextLibraryItems = await promise; } else { nextLibraryItems = cloneLibraryItems(items); } this.lastLibraryItems = nextLibraryItems; this.libraryItemsPromise = null; jotaiStore.set(libraryItemsAtom, { status: "loaded", libraryItems: nextLibraryItems, }); await this.app.props.onLibraryChange?.( cloneLibraryItems(nextLibraryItems), ); </s> remove const libraryItems = this.app.libraryItemsFromStorage; if (!libraryItems) { return resolve([]); } const items = restoreLibraryItems(libraryItems, "unpublished"); // clone to ensure we don't mutate the cached library elements in the app this.libraryCache = JSON.parse(JSON.stringify(items)); resolve(items); } catch (error: any) { console.error(error); resolve([]); </s> add resolve( cloneLibraryItems( await (this.libraryItemsPromise || this.lastLibraryItems), ), ); } catch (error) { return resolve(this.lastLibraryItems); </s> remove saveLibrary = async (items: LibraryItems) => { const prevLibraryItems = this.libraryCache; </s> add saveLibrary = async (items: LibraryItems | Promise<LibraryItems>) => { const prevLibraryItems = this.lastLibraryItems; </s> remove await this.app.props.onLibraryChange?.([]); this.libraryCache = []; </s> add this.saveLibrary([]); </s> remove this.libraryItemsFromStorage = restoreLibraryItems( initialData.libraryItems, "unpublished", ) as LibraryItems; </s> add this.library.importLibrary(initialData.libraryItems, "unpublished"); </s> remove await this.library.importLibrary(blob, "published"); // hack to rerender the library items after import if (this.state.isLibraryOpen) { this.setState({ isLibraryOpen: false }); } this.setState({ isLibraryOpen: true }); </s> add await this.library.importLibrary(libraryItems, defaultStatus);
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/data/library.ts
keep keep keep keep replace keep keep keep keep keep
<mask> }; <mask> }; <mask> <mask> export const restore = ( <mask> data: ImportedDataState | null, <mask> /** <mask> * Local AppState (`this.state` or initial state from localStorage) so that we <mask> * don't overwrite local state with default values (when values not <mask> * explicitly specified). <mask> * Supply `null` if you can't get access to it. </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove "errorLoadingLibrary": "There was an error loading the third party library.", </s> add </s> add ImportedLibraryData, </s> remove promise: ResolvablePromise<ImportedDataState | null>; </s> add promise: ResolvablePromise<ExcalidrawInitialDataState | null>; </s> add type Merge<M, N> = Omit<M, keyof N> & N; </s> remove saveLibrary = async (items: LibraryItems) => { const prevLibraryItems = this.libraryCache; </s> add saveLibrary = async (items: LibraryItems | Promise<LibraryItems>) => { const prevLibraryItems = this.lastLibraryItems; </s> remove const libraryFile = await loadLibraryFromBlob(blob); if (!libraryFile || !(libraryFile.libraryItems || libraryFile.library)) { return; } /** * checks if library item does not exist already in current library */ const isUniqueitem = ( existingLibraryItems: LibraryItems, targetLibraryItem: LibraryItem, ) => { return !existingLibraryItems.find((libraryItem) => { if (libraryItem.elements.length !== targetLibraryItem.elements.length) { return false; </s> add return this.saveLibrary( new Promise<LibraryItems>(async (resolve, reject) => { try { let libraryItems: LibraryItems; if (library instanceof Blob) { libraryItems = await loadLibraryFromBlob(library, defaultStatus); } else { libraryItems = restoreLibraryItems(await library, defaultStatus); } const existingLibraryItems = this.lastLibraryItems; const filteredItems = []; for (const item of libraryItems) { if (isUniqueItem(existingLibraryItems, item)) { filteredItems.push(item); } } resolve([...filteredItems, ...existingLibraryItems]); } catch (error) { reject(new Error(t("errors.importLibraryError")));
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/data/restore.ts
keep keep keep keep replace keep keep keep keep keep
<mask> return elements.length ? { ...libraryItem, elements } : null; <mask> }; <mask> <mask> export const restoreLibraryItems = ( <mask> libraryItems: NonOptional<ImportedDataState["libraryItems"]>, <mask> defaultStatus: LibraryItem["status"], <mask> ) => { <mask> const restoredItems: LibraryItem[] = []; <mask> for (const item of libraryItems) { <mask> // migrate older libraries </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove const libraryFile = await loadLibraryFromBlob(blob); if (!libraryFile || !(libraryFile.libraryItems || libraryFile.library)) { return; } /** * checks if library item does not exist already in current library */ const isUniqueitem = ( existingLibraryItems: LibraryItems, targetLibraryItem: LibraryItem, ) => { return !existingLibraryItems.find((libraryItem) => { if (libraryItem.elements.length !== targetLibraryItem.elements.length) { return false; </s> add return this.saveLibrary( new Promise<LibraryItems>(async (resolve, reject) => { try { let libraryItems: LibraryItems; if (library instanceof Blob) { libraryItems = await loadLibraryFromBlob(library, defaultStatus); } else { libraryItems = restoreLibraryItems(await library, defaultStatus); } const existingLibraryItems = this.lastLibraryItems; const filteredItems = []; for (const item of libraryItems) { if (isUniqueItem(existingLibraryItems, item)) { filteredItems.push(item); } } resolve([...filteredItems, ...existingLibraryItems]); } catch (error) { reject(new Error(t("errors.importLibraryError"))); </s> remove // detect z-index difference by checking the excalidraw elements // are in order return libraryItem.elements.every((libItemExcalidrawItem, idx) => { return ( libItemExcalidrawItem.id === targetLibraryItem.elements[idx].id && libItemExcalidrawItem.versionNonce === targetLibraryItem.elements[idx].versionNonce ); }); }); }; const existingLibraryItems = await this.loadLibrary(); const library = libraryFile.libraryItems || libraryFile.library || []; const restoredLibItems = restoreLibraryItems(library, defaultStatus); const filteredItems = []; for (const item of restoredLibItems) { if (isUniqueitem(existingLibraryItems, item)) { filteredItems.push(item); } } await this.saveLibrary([...filteredItems, ...existingLibraryItems]); </s> add }), ); </s> remove const libraryItems = JSON.parse( localStorage.getItem(STORAGE_KEYS.LOCAL_STORAGE_LIBRARY) as string, ) || []; </s> add const libraryItems: ImportedDataState["libraryItems"] = JSON.parse( localStorage.getItem(STORAGE_KEYS.LOCAL_STORAGE_LIBRARY) as string, ); </s> remove private libraryCache: LibraryItems | null = null; </s> add /** cache for currently active promise when initializing/updating libaries asynchronously */ private libraryItemsPromise: Promise<LibraryItems> | null = null; /** last resolved libraryItems */ private lastLibraryItems: LibraryItems = []; </s> remove const serializedItems = JSON.stringify(items); // cache optimistically so that the app has access to the latest // immediately this.libraryCache = JSON.parse(serializedItems); await this.app.props.onLibraryChange?.(items); </s> add let nextLibraryItems; if (isPromiseLike(items)) { const promise = items.then((items) => cloneLibraryItems(items)); this.libraryItemsPromise = promise; jotaiStore.set(libraryItemsAtom, { status: "loading", promise, libraryItems: null, }); nextLibraryItems = await promise; } else { nextLibraryItems = cloneLibraryItems(items); } this.lastLibraryItems = nextLibraryItems; this.libraryItemsPromise = null; jotaiStore.set(libraryItemsAtom, { status: "loaded", libraryItems: nextLibraryItems, }); await this.app.props.onLibraryChange?.( cloneLibraryItems(nextLibraryItems), ); </s> remove {loadingState === "loading" ? ( <div className="layer-ui__library-message"> {t("labels.libraryLoadingMessage")} </div> ) : ( <LibraryMenuItems libraryItems={libraryItems} onRemoveFromLibrary={removeFromLibrary} onAddToLibrary={addToLibrary} onInsertShape={onInsertShape} pendingElements={pendingElements} setAppState={setAppState} libraryReturnUrl={libraryReturnUrl} library={library} theme={theme} files={files} id={id} selectedItems={selectedItems} onToggle={(id, event) => { const shouldSelect = !selectedItems.includes(id); if (shouldSelect) { if (event.shiftKey && lastSelectedItem) { const rangeStart = libraryItems.findIndex( (item) => item.id === lastSelectedItem, ); const rangeEnd = libraryItems.findIndex( (item) => item.id === id, ); if (rangeStart === -1 || rangeEnd === -1) { setSelectedItems([...selectedItems, id]); return; } const selectedItemsMap = arrayToMap(selectedItems); const nextSelectedIds = libraryItems.reduce( (acc: LibraryItem["id"][], item, idx) => { if ( (idx >= rangeStart && idx <= rangeEnd) || selectedItemsMap.has(item.id) ) { acc.push(item.id); } return acc; }, [], ); </s> add if (shouldSelect) { if (event.shiftKey && lastSelectedItem) { const rangeStart = libraryItemsData.libraryItems.findIndex( (item) => item.id === lastSelectedItem, ); const rangeEnd = libraryItemsData.libraryItems.findIndex( (item) => item.id === id, );
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/data/restore.ts
keep keep keep add keep keep keep keep
<mask> getDefaultAppState, <mask> } from "../../appState"; <mask> import { clearElementsForLocalStorage } from "../../element"; <mask> import { STORAGE_KEYS } from "../app_constants"; <mask> <mask> export const saveUsernameToLocalStorage = (username: string) => { <mask> try { <mask> localStorage.setItem( </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> add import { useAtom } from "jotai"; import { jotaiScope } from "../jotai"; import Spinner from "./Spinner"; </s> add import { Provider } from "jotai"; import { jotaiScope, jotaiStore } from "../../jotai"; </s> remove import { ALLOWED_IMAGE_MIME_TYPES, EXPORT_DATA_TYPES, MIME_TYPES, } from "../constants"; </s> add import { ALLOWED_IMAGE_MIME_TYPES, MIME_TYPES } from "../constants"; </s> remove import { ImportedDataState } from "../data/types"; </s> add </s> remove private libraryCache: LibraryItems | null = null; </s> add /** cache for currently active promise when initializing/updating libaries asynchronously */ private libraryItemsPromise: Promise<LibraryItems> | null = null; /** last resolved libraryItems */ private lastLibraryItems: LibraryItems = []; </s> add ExcalidrawInitialDataState,
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/excalidraw-app/data/localStorage.ts
keep replace replace replace replace keep replace replace replace
<mask> try { <mask> const libraryItems = <mask> JSON.parse( <mask> localStorage.getItem(STORAGE_KEYS.LOCAL_STORAGE_LIBRARY) as string, <mask> ) || []; <mask> <mask> return libraryItems; <mask> } catch (e) { <mask> console.error(e); </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove this.libraryItemsFromStorage = restoreLibraryItems( initialData.libraryItems, "unpublished", ) as LibraryItems; </s> add this.library.importLibrary(initialData.libraryItems, "unpublished"); </s> remove const libraryFile = await loadLibraryFromBlob(blob); if (!libraryFile || !(libraryFile.libraryItems || libraryFile.library)) { return; } /** * checks if library item does not exist already in current library */ const isUniqueitem = ( existingLibraryItems: LibraryItems, targetLibraryItem: LibraryItem, ) => { return !existingLibraryItems.find((libraryItem) => { if (libraryItem.elements.length !== targetLibraryItem.elements.length) { return false; </s> add return this.saveLibrary( new Promise<LibraryItems>(async (resolve, reject) => { try { let libraryItems: LibraryItems; if (library instanceof Blob) { libraryItems = await loadLibraryFromBlob(library, defaultStatus); } else { libraryItems = restoreLibraryItems(await library, defaultStatus); } const existingLibraryItems = this.lastLibraryItems; const filteredItems = []; for (const item of libraryItems) { if (isUniqueItem(existingLibraryItems, item)) { filteredItems.push(item); } } resolve([...filteredItems, ...existingLibraryItems]); } catch (error) { reject(new Error(t("errors.importLibraryError"))); </s> remove const libraryItems = this.app.libraryItemsFromStorage; if (!libraryItems) { return resolve([]); } const items = restoreLibraryItems(libraryItems, "unpublished"); // clone to ensure we don't mutate the cached library elements in the app this.libraryCache = JSON.parse(JSON.stringify(items)); resolve(items); } catch (error: any) { console.error(error); resolve([]); </s> add resolve( cloneLibraryItems( await (this.libraryItemsPromise || this.lastLibraryItems), ), ); } catch (error) { return resolve(this.lastLibraryItems); </s> remove if (this.libraryCache) { return resolve(JSON.parse(JSON.stringify(this.libraryCache))); } </s> add </s> remove // detect z-index difference by checking the excalidraw elements // are in order return libraryItem.elements.every((libItemExcalidrawItem, idx) => { return ( libItemExcalidrawItem.id === targetLibraryItem.elements[idx].id && libItemExcalidrawItem.versionNonce === targetLibraryItem.elements[idx].versionNonce ); }); }); }; const existingLibraryItems = await this.loadLibrary(); const library = libraryFile.libraryItems || libraryFile.library || []; const restoredLibItems = restoreLibraryItems(library, defaultStatus); const filteredItems = []; for (const item of restoredLibItems) { if (isUniqueitem(existingLibraryItems, item)) { filteredItems.push(item); } } await this.saveLibrary([...filteredItems, ...existingLibraryItems]); </s> add }), );
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/excalidraw-app/data/localStorage.ts
keep keep keep keep replace keep keep keep keep keep
<mask> URL_HASH_KEYS, <mask> VERSION_TIMEOUT, <mask> } from "../constants"; <mask> import { loadFromBlob } from "../data/blob"; <mask> import { ImportedDataState } from "../data/types"; <mask> import { <mask> ExcalidrawElement, <mask> FileId, <mask> NonDeletedExcalidrawElement, <mask> } from "../element/types"; </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove import { ALLOWED_IMAGE_MIME_TYPES, EXPORT_DATA_TYPES, MIME_TYPES, } from "../constants"; </s> add import { ALLOWED_IMAGE_MIME_TYPES, MIME_TYPES } from "../constants"; </s> add import { ImportedDataState } from "../../data/types"; </s> add import { useAtom } from "jotai"; import { jotaiScope } from "../jotai"; import Spinner from "./Spinner"; </s> add import { Provider } from "jotai"; import { jotaiScope, jotaiStore } from "../../jotai"; </s> add ExcalidrawInitialDataState, </s> remove private libraryCache: LibraryItems | null = null; </s> add /** cache for currently active promise when initializing/updating libaries asynchronously */ private libraryItemsPromise: Promise<LibraryItems> | null = null; /** last resolved libraryItems */ private lastLibraryItems: LibraryItems = [];
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/excalidraw-app/index.tsx
keep add keep keep keep keep keep keep
<mask> ExcalidrawImperativeAPI, <mask> BinaryFiles, <mask> } from "../types"; <mask> import { <mask> debounce, <mask> getVersion, <mask> getFrame, <mask> isTestEnv, </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove import { ALLOWED_IMAGE_MIME_TYPES, EXPORT_DATA_TYPES, MIME_TYPES, } from "../constants"; </s> add import { ALLOWED_IMAGE_MIME_TYPES, MIME_TYPES } from "../constants"; </s> add import { useAtom } from "jotai"; import { jotaiScope } from "../jotai"; import Spinner from "./Spinner"; </s> remove import { ImportedDataState } from "../data/types"; </s> add </s> add import { Provider } from "jotai"; import { jotaiScope, jotaiStore } from "../../jotai"; </s> add import { ImportedDataState } from "../../data/types"; </s> remove private libraryCache: LibraryItems | null = null; </s> add /** cache for currently active promise when initializing/updating libaries asynchronously */ private libraryItemsPromise: Promise<LibraryItems> | null = null; /** last resolved libraryItems */ private lastLibraryItems: LibraryItems = [];
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/excalidraw-app/index.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> const initializeScene = async (opts: { <mask> collabAPI: CollabAPI; <mask> }): Promise< <mask> { scene: ImportedDataState | null } & ( <mask> | { isExternalScene: true; id: string; key: string } <mask> | { isExternalScene: false; id?: null; key?: null } <mask> ) <mask> > => { <mask> const searchParams = new URLSearchParams(window.location.search); </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove private libraryCache: LibraryItems | null = null; </s> add /** cache for currently active promise when initializing/updating libaries asynchronously */ private libraryItemsPromise: Promise<LibraryItems> | null = null; /** last resolved libraryItems */ private lastLibraryItems: LibraryItems = []; </s> remove initialData?: ImportedDataState | null | Promise<ImportedDataState | null>; </s> add initialData?: | ExcalidrawInitialDataState | null | Promise<ExcalidrawInitialDataState | null>; </s> add export type ExcalidrawInitialDataState = Merge< ImportedDataState, { libraryItems?: | Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>; } >; </s> remove const libraryFile = await loadLibraryFromBlob(blob); if (!libraryFile || !(libraryFile.libraryItems || libraryFile.library)) { return; } /** * checks if library item does not exist already in current library */ const isUniqueitem = ( existingLibraryItems: LibraryItems, targetLibraryItem: LibraryItem, ) => { return !existingLibraryItems.find((libraryItem) => { if (libraryItem.elements.length !== targetLibraryItem.elements.length) { return false; </s> add return this.saveLibrary( new Promise<LibraryItems>(async (resolve, reject) => { try { let libraryItems: LibraryItems; if (library instanceof Blob) { libraryItems = await loadLibraryFromBlob(library, defaultStatus); } else { libraryItems = restoreLibraryItems(await library, defaultStatus); } const existingLibraryItems = this.lastLibraryItems; const filteredItems = []; for (const item of libraryItems) { if (isUniqueItem(existingLibraryItems, item)) { filteredItems.push(item); } } resolve([...filteredItems, ...existingLibraryItems]); } catch (error) { reject(new Error(t("errors.importLibraryError"))); </s> remove return loadingState === "preloading" ? null : ( <Island padding={1} ref={ref} className="layer-ui__library"> </s> add if (libraryItemsData.status === "loading") { return ( <LibraryMenuWrapper ref={ref}> <div className="layer-ui__library-message"> <Spinner size="2em" /> <span>{t("labels.libraryLoadingMessage")}</span> </div> </LibraryMenuWrapper> ); } return ( <LibraryMenuWrapper ref={ref}> </s> remove if (this.libraryCache) { return resolve(JSON.parse(JSON.stringify(this.libraryCache))); } </s> add
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/excalidraw-app/index.tsx
keep replace keep keep keep replace keep keep keep keep
<mask> const initialStatePromiseRef = useRef<{ <mask> promise: ResolvablePromise<ImportedDataState | null>; <mask> }>({ promise: null! }); <mask> if (!initialStatePromiseRef.current.promise) { <mask> initialStatePromiseRef.current.promise = <mask> resolvablePromise<ImportedDataState | null>(); <mask> } <mask> <mask> useEffect(() => { <mask> trackEvent("load", "frame", getFrame()); </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove initialData?: ImportedDataState | null | Promise<ImportedDataState | null>; </s> add initialData?: | ExcalidrawInitialDataState | null | Promise<ExcalidrawInitialDataState | null>; </s> remove { scene: ImportedDataState | null } & ( </s> add { scene: ExcalidrawInitialDataState | null } & ( </s> remove saveLibrary = async (items: LibraryItems) => { const prevLibraryItems = this.libraryCache; </s> add saveLibrary = async (items: LibraryItems | Promise<LibraryItems>) => { const prevLibraryItems = this.lastLibraryItems; </s> remove // detect z-index difference by checking the excalidraw elements // are in order return libraryItem.elements.every((libItemExcalidrawItem, idx) => { return ( libItemExcalidrawItem.id === targetLibraryItem.elements[idx].id && libItemExcalidrawItem.versionNonce === targetLibraryItem.elements[idx].versionNonce ); }); }); }; const existingLibraryItems = await this.loadLibrary(); const library = libraryFile.libraryItems || libraryFile.library || []; const restoredLibItems = restoreLibraryItems(library, defaultStatus); const filteredItems = []; for (const item of restoredLibItems) { if (isUniqueitem(existingLibraryItems, item)) { filteredItems.push(item); } } await this.saveLibrary([...filteredItems, ...existingLibraryItems]); </s> add }), ); </s> remove blob: Blob, </s> add library: | Blob | Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>,
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/excalidraw-app/index.tsx
keep keep keep add keep keep keep keep keep keep
<mask> type Mutable<T> = { <mask> -readonly [P in keyof T]: T[P]; <mask> }; <mask> <mask> /** utility type to assert that the second type is a subtype of the first type. <mask> * Returns the subtype. */ <mask> type SubtypeOf<Supertype, Subtype extends Supertype> = Subtype; <mask> <mask> type ResolutionType<T extends (...args: any) => any> = T extends ( <mask> ...args: any </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove private libraryCache: LibraryItems | null = null; </s> add /** cache for currently active promise when initializing/updating libaries asynchronously */ private libraryItemsPromise: Promise<LibraryItems> | null = null; /** last resolved libraryItems */ private lastLibraryItems: LibraryItems = []; </s> add export type ExcalidrawInitialDataState = Merge< ImportedDataState, { libraryItems?: | Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>; } >; </s> remove resolvablePromise<ImportedDataState | null>(); </s> add resolvablePromise<ExcalidrawInitialDataState | null>(); </s> remove const libraryFile = await loadLibraryFromBlob(blob); if (!libraryFile || !(libraryFile.libraryItems || libraryFile.library)) { return; } /** * checks if library item does not exist already in current library */ const isUniqueitem = ( existingLibraryItems: LibraryItems, targetLibraryItem: LibraryItem, ) => { return !existingLibraryItems.find((libraryItem) => { if (libraryItem.elements.length !== targetLibraryItem.elements.length) { return false; </s> add return this.saveLibrary( new Promise<LibraryItems>(async (resolve, reject) => { try { let libraryItems: LibraryItems; if (library instanceof Blob) { libraryItems = await loadLibraryFromBlob(library, defaultStatus); } else { libraryItems = restoreLibraryItems(await library, defaultStatus); } const existingLibraryItems = this.lastLibraryItems; const filteredItems = []; for (const item of libraryItems) { if (isUniqueItem(existingLibraryItems, item)) { filteredItems.push(item); } } resolve([...filteredItems, ...existingLibraryItems]); } catch (error) { reject(new Error(t("errors.importLibraryError"))); </s> remove saveLibrary = async (items: LibraryItems) => { const prevLibraryItems = this.libraryCache; </s> add saveLibrary = async (items: LibraryItems | Promise<LibraryItems>) => { const prevLibraryItems = this.lastLibraryItems; </s> remove const libraryItems = this.app.libraryItemsFromStorage; if (!libraryItems) { return resolve([]); } const items = restoreLibraryItems(libraryItems, "unpublished"); // clone to ensure we don't mutate the cached library elements in the app this.libraryCache = JSON.parse(JSON.stringify(items)); resolve(items); } catch (error: any) { console.error(error); resolve([]); </s> add resolve( cloneLibraryItems( await (this.libraryItemsPromise || this.lastLibraryItems), ), ); } catch (error) { return resolve(this.lastLibraryItems);
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/global.d.ts
keep keep keep keep replace keep keep keep keep keep
<mask> "decryptFailed": "Couldn't decrypt data.", <mask> "uploadedSecurly": "The upload has been secured with end-to-end encryption, which means that Excalidraw server and third parties can't read the content.", <mask> "loadSceneOverridePrompt": "Loading external drawing will replace your existing content. Do you wish to continue?", <mask> "collabStopOverridePrompt": "Stopping the session will overwrite your previous, locally stored drawing. Are you sure?\n\n(If you want to keep your local drawing, simply close the browser tab instead.)", <mask> "errorLoadingLibrary": "There was an error loading the third party library.", <mask> "errorAddingToLibrary": "Couldn't add item to the library", <mask> "errorRemovingFromLibrary": "Couldn't remove item from the library", <mask> "confirmAddLibrary": "This will add {{numShapes}} shape(s) to your library. Are you sure?", <mask> "imageDoesNotContainScene": "This image does not seem to contain any scene data. Have you enabled scene embedding during export?", <mask> "cannotRestoreFromImage": "Scene couldn't be restored from this image file", </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove "cannotResolveCollabServer": "Couldn't connect to the collab server. Please reload the page and try again." </s> add "cannotResolveCollabServer": "Couldn't connect to the collab server. Please reload the page and try again.", "importLibraryError": "Couldn't load library" </s> remove data: ImportedDataState | null, </s> add data: Pick<ImportedDataState, "appState" | "elements" | "files"> | null, </s> remove resolvablePromise<ImportedDataState | null>(); </s> add resolvablePromise<ExcalidrawInitialDataState | null>(); </s> add type Merge<M, N> = Omit<M, keyof N> & N; </s> remove saveLibrary = async (items: LibraryItems) => { const prevLibraryItems = this.libraryCache; </s> add saveLibrary = async (items: LibraryItems | Promise<LibraryItems>) => { const prevLibraryItems = this.lastLibraryItems; </s> remove numShapes: (json.libraryItems || json.library || []).length, </s> add numShapes: libraryItems.length,
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/locales/en.json
keep keep keep keep replace keep keep keep keep keep
<mask> "imageInsertError": "Couldn't insert image. Try again later...", <mask> "fileTooBig": "File is too big. Maximum allowed size is {{maxSize}}.", <mask> "svgImageInsertError": "Couldn't insert SVG image. The SVG markup looks invalid.", <mask> "invalidSVGString": "Invalid SVG.", <mask> "cannotResolveCollabServer": "Couldn't connect to the collab server. Please reload the page and try again." <mask> }, <mask> "toolBar": { <mask> "selection": "Selection", <mask> "image": "Insert image", <mask> "rectangle": "Rectangle", </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove "errorLoadingLibrary": "There was an error loading the third party library.", </s> add </s> add type Merge<M, N> = Omit<M, keyof N> & N; </s> remove saveLibrary = async (items: LibraryItems) => { const prevLibraryItems = this.libraryCache; </s> add saveLibrary = async (items: LibraryItems | Promise<LibraryItems>) => { const prevLibraryItems = this.lastLibraryItems; </s> remove export const isValidLibrary = (json: any) => { </s> add export const isValidLibrary = (json: any): json is ImportedLibraryData => { </s> remove const libraryItems = this.app.libraryItemsFromStorage; if (!libraryItems) { return resolve([]); } const items = restoreLibraryItems(libraryItems, "unpublished"); // clone to ensure we don't mutate the cached library elements in the app this.libraryCache = JSON.parse(JSON.stringify(items)); resolve(items); } catch (error: any) { console.error(error); resolve([]); </s> add resolve( cloneLibraryItems( await (this.libraryItemsPromise || this.lastLibraryItems), ), ); } catch (error) { return resolve(this.lastLibraryItems); </s> remove resolvablePromise<ImportedDataState | null>(); </s> add resolvablePromise<ExcalidrawInitialDataState | null>();
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/locales/en.json
keep add keep keep keep keep keep keep
<mask> import { defaultLang } from "../../i18n"; <mask> import { DEFAULT_UI_OPTIONS } from "../../constants"; <mask> <mask> const Excalidraw = (props: ExcalidrawProps) => { <mask> const { <mask> onChange, <mask> initialData, <mask> excalidrawRef, </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> add import { useAtom } from "jotai"; import { jotaiScope } from "../jotai"; import Spinner from "./Spinner"; </s> add import { ImportedDataState } from "../../data/types"; </s> remove import { ALLOWED_IMAGE_MIME_TYPES, EXPORT_DATA_TYPES, MIME_TYPES, } from "../constants"; </s> add import { ALLOWED_IMAGE_MIME_TYPES, MIME_TYPES } from "../constants"; </s> remove import { ImportedDataState } from "../data/types"; </s> add </s> remove private libraryCache: LibraryItems | null = null; </s> add /** cache for currently active promise when initializing/updating libaries asynchronously */ private libraryItemsPromise: Promise<LibraryItems> | null = null; /** last resolved libraryItems */ private lastLibraryItems: LibraryItems = []; </s> add ExcalidrawInitialDataState,
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/packages/excalidraw/index.tsx
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> }, []); <mask> <mask> return ( <mask> <InitializeApp langCode={langCode}> <mask> <App <mask> onChange={onChange} <mask> initialData={initialData} <mask> excalidrawRef={excalidrawRef} <mask> onCollabButtonClick={onCollabButtonClick} <mask> isCollaborating={isCollaborating} <mask> onPointerUpdate={onPointerUpdate} <mask> renderTopRightUI={renderTopRightUI} <mask> renderFooter={renderFooter} <mask> langCode={langCode} <mask> viewModeEnabled={viewModeEnabled} <mask> zenModeEnabled={zenModeEnabled} <mask> gridModeEnabled={gridModeEnabled} <mask> libraryReturnUrl={libraryReturnUrl} <mask> theme={theme} <mask> name={name} <mask> renderCustomStats={renderCustomStats} <mask> UIOptions={UIOptions} <mask> onPaste={onPaste} <mask> detectScroll={detectScroll} <mask> handleKeyboardGlobally={handleKeyboardGlobally} <mask> onLibraryChange={onLibraryChange} <mask> autoFocus={autoFocus} <mask> generateIdForFile={generateIdForFile} <mask> onLinkOpen={onLinkOpen} <mask> /> <mask> </InitializeApp> <mask> ); <mask> }; <mask> <mask> type PublicExcalidrawProps = Omit<ExcalidrawProps, "forwardedRef">; </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove {loadingState === "loading" ? ( <div className="layer-ui__library-message"> {t("labels.libraryLoadingMessage")} </div> ) : ( <LibraryMenuItems libraryItems={libraryItems} onRemoveFromLibrary={removeFromLibrary} onAddToLibrary={addToLibrary} onInsertShape={onInsertShape} pendingElements={pendingElements} setAppState={setAppState} libraryReturnUrl={libraryReturnUrl} library={library} theme={theme} files={files} id={id} selectedItems={selectedItems} onToggle={(id, event) => { const shouldSelect = !selectedItems.includes(id); if (shouldSelect) { if (event.shiftKey && lastSelectedItem) { const rangeStart = libraryItems.findIndex( (item) => item.id === lastSelectedItem, ); const rangeEnd = libraryItems.findIndex( (item) => item.id === id, ); if (rangeStart === -1 || rangeEnd === -1) { setSelectedItems([...selectedItems, id]); return; } const selectedItemsMap = arrayToMap(selectedItems); const nextSelectedIds = libraryItems.reduce( (acc: LibraryItem["id"][], item, idx) => { if ( (idx >= rangeStart && idx <= rangeEnd) || selectedItemsMap.has(item.id) ) { acc.push(item.id); } return acc; }, [], ); </s> add if (shouldSelect) { if (event.shiftKey && lastSelectedItem) { const rangeStart = libraryItemsData.libraryItems.findIndex( (item) => item.id === lastSelectedItem, ); const rangeEnd = libraryItemsData.libraryItems.findIndex( (item) => item.id === id, ); </s> remove return loadingState === "preloading" ? null : ( <Island padding={1} ref={ref} className="layer-ui__library"> </s> add if (libraryItemsData.status === "loading") { return ( <LibraryMenuWrapper ref={ref}> <div className="layer-ui__library-message"> <Spinner size="2em" /> <span>{t("labels.libraryLoadingMessage")}</span> </div> </LibraryMenuWrapper> ); } return ( <LibraryMenuWrapper ref={ref}> </s> add type Merge<M, N> = Omit<M, keyof N> & N; </s> remove const nextItems = items.filter((item) => !selectedItems.includes(item.id)); library.saveLibrary(nextItems).catch((error) => { setLibraryItems(items); setAppState({ errorMessage: t("alerts.errorRemovingFromLibrary") }); }); setSelectedItems([]); setLibraryItems(nextItems); }, [library, setAppState, selectedItems, setSelectedItems]); </s> add const removeFromLibrary = useCallback( async (libraryItems: LibraryItems) => { const nextItems = libraryItems.filter( (item) => !selectedItems.includes(item.id), ); library.saveLibrary(nextItems).catch(() => { setAppState({ errorMessage: t("alerts.errorRemovingFromLibrary") }); }); setSelectedItems([]); }, [library, setAppState, selectedItems, setSelectedItems], ); </s> remove setLibraryItems(nextItems); </s> add </s> add export type ExcalidrawInitialDataState = Merge< ImportedDataState, { libraryItems?: | Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>; } >;
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/packages/excalidraw/index.tsx
keep keep add keep keep keep keep
<mask> ready?: false; <mask> }; <mask> <mask> export interface ExcalidrawProps { <mask> onChange?: ( <mask> elements: readonly ExcalidrawElement[], <mask> appState: AppState, </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> remove initialData?: ImportedDataState | null | Promise<ImportedDataState | null>; </s> add initialData?: | ExcalidrawInitialDataState | null | Promise<ExcalidrawInitialDataState | null>; </s> remove export const isValidLibrary = (json: any) => { </s> add export const isValidLibrary = (json: any): json is ImportedLibraryData => { </s> remove { scene: ImportedDataState | null } & ( </s> add { scene: ExcalidrawInitialDataState | null } & ( </s> remove libraryItems: NonOptional<ImportedDataState["libraryItems"]>, </s> add libraryItems: ImportedDataState["libraryItems"] = [], </s> remove this.libraryItemsFromStorage = restoreLibraryItems( initialData.libraryItems, "unpublished", ) as LibraryItems; </s> add this.library.importLibrary(initialData.libraryItems, "unpublished"); </s> remove // detect z-index difference by checking the excalidraw elements // are in order return libraryItem.elements.every((libItemExcalidrawItem, idx) => { return ( libItemExcalidrawItem.id === targetLibraryItem.elements[idx].id && libItemExcalidrawItem.versionNonce === targetLibraryItem.elements[idx].versionNonce ); }); }); }; const existingLibraryItems = await this.loadLibrary(); const library = libraryFile.libraryItems || libraryFile.library || []; const restoredLibItems = restoreLibraryItems(library, defaultStatus); const filteredItems = []; for (const item of restoredLibItems) { if (isUniqueitem(existingLibraryItems, item)) { filteredItems.push(item); } } await this.saveLibrary([...filteredItems, ...existingLibraryItems]); </s> add }), );
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/types.ts
keep keep keep keep replace keep keep keep keep keep
<mask> elements: readonly ExcalidrawElement[], <mask> appState: AppState, <mask> files: BinaryFiles, <mask> ) => void; <mask> initialData?: ImportedDataState | null | Promise<ImportedDataState | null>; <mask> excalidrawRef?: ForwardRef<ExcalidrawAPIRefValue>; <mask> onCollabButtonClick?: () => void; <mask> isCollaborating?: boolean; <mask> onPointerUpdate?: (payload: { <mask> pointer: { x: number; y: number }; </s> feat: rewrite library state management & related refactor (#5067) * support libraryItems promise for `updateScene()` and use `importLibrary` * fix typing for `getLibraryItemsFromStorage()` * remove `libraryItemsFromStorage` hack if there was a point to it then I'm missing it, but this part will be rewritten anyway * rewrite state handling (temporarily removed loading states) * add async support * refactor and deduplicate library importing logic * hide hints when library open * fix snaps * support promise in `initialData.libraryItems` * add default to params instead </s> add export type ExcalidrawInitialDataState = Merge< ImportedDataState, { libraryItems?: | Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>; } >; </s> remove { scene: ImportedDataState | null } & ( </s> add { scene: ExcalidrawInitialDataState | null } & ( </s> remove resolvablePromise<ImportedDataState | null>(); </s> add resolvablePromise<ExcalidrawInitialDataState | null>(); </s> remove promise: ResolvablePromise<ImportedDataState | null>; </s> add promise: ResolvablePromise<ExcalidrawInitialDataState | null>; </s> remove private libraryCache: LibraryItems | null = null; </s> add /** cache for currently active promise when initializing/updating libaries asynchronously */ private libraryItemsPromise: Promise<LibraryItems> | null = null; /** last resolved libraryItems */ private lastLibraryItems: LibraryItems = []; </s> remove blob: Blob, </s> add library: | Blob | Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>,
https://github.com/excalidraw/excalidraw/commit/cd942c3e3b9f4ca109b9d46f9074d74536f131ba
src/types.ts
keep keep keep keep replace keep keep keep keep keep
<mask> perform: (_elements, appState) => { <mask> return { <mask> appState: { <mask> ...appState, <mask> showShortcutsDialog: true, <mask> }, <mask> commitToHistory: false, <mask> }; <mask> }, <mask> PanelComponent: ({ updateData }) => ( </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove <HelpIcon title={t("shortcutsDialog.title")} onClick={updateData} /> </s> add <HelpIcon title={t("helpDialog.title")} onClick={updateData} /> </s> remove showShortcutsDialog: { browser: false, export: false }, </s> add showHelpDialog: { browser: false, export: false }, </s> remove {appState.showShortcutsDialog && ( <ShortcutsDialog onClose={() => setAppState({ showShortcutsDialog: false })} /> </s> add {appState.showHelpDialog && ( <HelpDialog onClose={() => setAppState({ showHelpDialog: false })} /> </s> remove showShortcutsDialog: true, </s> add showHelpDialog: true, </s> remove const shortcut = `${capitalizeString(letter)} ${t( "shortcutsDialog.or", )} ${index + 1}`; </s> add const shortcut = `${capitalizeString(letter)} ${t("helpDialog.or")} ${ index + 1 }`; </s> remove showShortcutsDialog: boolean; </s> add showHelpDialog: boolean;
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/actions/actionMenu.tsx
keep keep keep keep replace keep keep keep
<mask> commitToHistory: false, <mask> }; <mask> }, <mask> PanelComponent: ({ updateData }) => ( <mask> <HelpIcon title={t("shortcutsDialog.title")} onClick={updateData} /> <mask> ), <mask> keyTest: (event) => event.key === KEYS.QUESTION_MARK, <mask> }); </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove showShortcutsDialog: true, </s> add showHelpDialog: true, </s> remove {appState.showShortcutsDialog && ( <ShortcutsDialog onClose={() => setAppState({ showShortcutsDialog: false })} /> </s> add {appState.showHelpDialog && ( <HelpDialog onClose={() => setAppState({ showHelpDialog: false })} /> </s> remove const shortcut = `${capitalizeString(letter)} ${t( "shortcutsDialog.or", )} ${index + 1}`; </s> add const shortcut = `${capitalizeString(letter)} ${t("helpDialog.or")} ${ index + 1 }`; </s> remove showShortcutsDialog: true, </s> add showHelpDialog: true, </s> remove showShortcutsDialog: boolean; </s> add showHelpDialog: boolean; </s> remove showShortcutsDialog: { browser: false, export: false }, </s> add showHelpDialog: { browser: false, export: false },
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/actions/actionMenu.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> selectAll: [getShortcutKey("CtrlOrCmd+A")], <mask> delete: [getShortcutKey("Del")], <mask> duplicateSelection: [ <mask> getShortcutKey("CtrlOrCmd+D"), <mask> getShortcutKey(`Alt+${t("shortcutsDialog.drag")}`), <mask> ], <mask> sendBackward: [getShortcutKey("CtrlOrCmd+[")], <mask> bringForward: [getShortcutKey("CtrlOrCmd+]")], <mask> sendToBack: [ <mask> isDarwin </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove showShortcutsDialog: boolean; </s> add showHelpDialog: boolean; </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false,
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/actions/shortcuts.ts
keep keep keep keep replace keep keep keep keep keep
<mask> selectedGroupIds: {}, <mask> selectionElement: null, <mask> shouldAddWatermark: false, <mask> shouldCacheIgnoreZoom: false, <mask> showShortcutsDialog: false, <mask> showStats: false, <mask> startBoundElement: null, <mask> suggestedBindings: [], <mask> toastMessage: null, <mask> viewBackgroundColor: oc.white, </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove showShortcutsDialog: { browser: false, export: false }, </s> add showHelpDialog: { browser: false, export: false }, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false,
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/appState.ts
keep keep keep keep replace keep keep keep keep keep
<mask> selectedGroupIds: { browser: true, export: false }, <mask> selectionElement: { browser: false, export: false }, <mask> shouldAddWatermark: { browser: true, export: false }, <mask> shouldCacheIgnoreZoom: { browser: true, export: false }, <mask> showShortcutsDialog: { browser: false, export: false }, <mask> showStats: { browser: true, export: false }, <mask> startBoundElement: { browser: false, export: false }, <mask> suggestedBindings: { browser: false, export: false }, <mask> toastMessage: { browser: false, export: false }, <mask> viewBackgroundColor: { browser: true, export: true }, </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove showShortcutsDialog: true, </s> add showHelpDialog: true, </s> remove showShortcutsDialog: true, </s> add showHelpDialog: true, </s> remove showShortcutsDialog: false, </s> add showHelpDialog: false, </s> remove "shortcutsDialog": { "title": "Keyboard shortcuts", "shapes": "Shapes", "or": "or", </s> add "helpDialog": { "blog": "Read our blog", </s> remove {appState.showShortcutsDialog && ( <ShortcutsDialog onClose={() => setAppState({ showShortcutsDialog: false })} /> </s> add {appState.showHelpDialog && ( <HelpDialog onClose={() => setAppState({ showHelpDialog: false })} /> </s> remove "zoomToSelection": "Zoom to selection", "preventBinding": "Prevent arrow binding" </s> add "zoomToSelection": "Zoom to selection"
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/appState.ts
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> <> <mask> {SHAPES.map(({ value, icon, key }, index) => { <mask> const label = t(`toolBar.${value}`); <mask> const letter = typeof key === "string" ? key : key[0]; <mask> const shortcut = `${capitalizeString(letter)} ${t( <mask> "shortcutsDialog.or", <mask> )} ${index + 1}`; <mask> return ( <mask> <ToolButton <mask> className="Shape" <mask> key={value} <mask> type="radio" </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove showShortcutsDialog: true, </s> add showHelpDialog: true, </s> add import { questionCircle } from "../components/icons"; </s> remove {appState.showShortcutsDialog && ( <ShortcutsDialog onClose={() => setAppState({ showShortcutsDialog: false })} /> </s> add {appState.showHelpDialog && ( <HelpDialog onClose={() => setAppState({ showHelpDialog: false })} /> </s> remove <HelpIcon title={t("shortcutsDialog.title")} onClick={updateData} /> </s> add <HelpIcon title={t("helpDialog.title")} onClick={updateData} /> </s> remove </h3> </s> add </h2> </s> remove showShortcutsDialog: true, </s> add showHelpDialog: true,
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/components/Actions.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> if (event.key === KEYS.QUESTION_MARK) { <mask> this.setState({ <mask> showShortcutsDialog: true, <mask> }); <mask> } <mask> <mask> if (!event[KEYS.CTRL_OR_CMD] && event.altKey && event.code === CODES.Z) { <mask> this.toggleZenMode(); </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove import { ShortcutsDialog } from "./ShortcutsDialog"; </s> add import { HelpDialog } from "./HelpDialog"; </s> remove {appState.showShortcutsDialog && ( <ShortcutsDialog onClose={() => setAppState({ showShortcutsDialog: false })} /> </s> add {appState.showHelpDialog && ( <HelpDialog onClose={() => setAppState({ showHelpDialog: false })} /> </s> remove color: $oc-blue-7; /* OC Blue 7 */ </s> add color: var(--link-color); </s> remove showShortcutsDialog: true, </s> add showHelpDialog: true, </s> remove showShortcutsDialog: { browser: false, export: false }, </s> add showHelpDialog: { browser: false, export: false }, </s> add --link-color: #{$oc-blue-7};
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/components/App.tsx
keep keep add keep keep keep keep
<mask> padding: calc(var(--space-factor) * 2); <mask> text-align: center; <mask> font-variant: small-caps; <mask> } <mask> <mask> .Dialog__titleContent { <mask> flex: 1; </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove import { ShortcutsDialog } from "./ShortcutsDialog"; </s> add import { HelpDialog } from "./HelpDialog"; </s> remove color: $oc-blue-7; /* OC Blue 7 */ </s> add color: var(--link-color); </s> remove showShortcutsDialog: true, </s> add showHelpDialog: true, </s> add width: 1.5rem; </s> add --link-color: #{$oc-blue-7}; </s> add import { questionCircle } from "../components/icons";
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/components/Dialog.scss
keep keep keep keep replace keep keep keep keep keep
<mask> maxWidth={props.small ? 550 : 800} <mask> onCloseRequest={props.onCloseRequest} <mask> > <mask> <Island ref={setIslandNode}> <mask> <h3 id="dialog-title" className="Dialog__title"> <mask> <span className="Dialog__titleContent">{props.title}</span> <mask> <button <mask> className="Modal__close" <mask> onClick={props.onCloseRequest} <mask> aria-label={t("buttons.close")} </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove </h3> </s> add </h2> </s> remove const shortcut = `${capitalizeString(letter)} ${t( "shortcutsDialog.or", )} ${index + 1}`; </s> add const shortcut = `${capitalizeString(letter)} ${t("helpDialog.or")} ${ index + 1 }`; </s> remove showShortcutsDialog: boolean; </s> add showHelpDialog: boolean; </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false,
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/components/Dialog.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> aria-label={t("buttons.close")} <mask> > <mask> {useIsMobile() ? back : close} <mask> </button> <mask> </h3> <mask> <div className="Dialog__content">{props.children}</div> <mask> </Island> <mask> </Modal> <mask> ); <mask> }; </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove <h3 id="dialog-title" className="Dialog__title"> </s> add <h2 id="dialog-title" className="Dialog__title"> </s> remove const shortcut = `${capitalizeString(letter)} ${t( "shortcutsDialog.or", )} ${index + 1}`; </s> add const shortcut = `${capitalizeString(letter)} ${t("helpDialog.or")} ${ index + 1 }`; </s> remove showShortcutsDialog: boolean; </s> add showHelpDialog: boolean; </s> remove showShortcutsDialog: true, </s> add showHelpDialog: true, </s> remove <HelpIcon title={t("shortcutsDialog.title")} onClick={updateData} /> </s> add <HelpIcon title={t("helpDialog.title")} onClick={updateData} /> </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false,
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/components/Dialog.tsx
add keep keep keep keep
<mask> import React from "react"; <mask> <mask> type HelpIconProps = { <mask> title?: string; <mask> name?: string; </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove import { ShortcutsDialog } from "./ShortcutsDialog"; </s> add import { HelpDialog } from "./HelpDialog"; </s> remove const shortcut = `${capitalizeString(letter)} ${t( "shortcutsDialog.or", )} ${index + 1}`; </s> add const shortcut = `${capitalizeString(letter)} ${t("helpDialog.or")} ${ index + 1 }`; </s> remove showShortcutsDialog: { browser: false, export: false }, </s> add showHelpDialog: { browser: false, export: false }, </s> remove showShortcutsDialog: true, </s> add showHelpDialog: true, </s> add width: 1.5rem; </s> add --link-color: #{$oc-blue-7};
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/components/HelpIcon.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> import { LockIcon } from "./LockIcon"; <mask> import { MobileMenu } from "./MobileMenu"; <mask> import { PasteChartDialog } from "./PasteChartDialog"; <mask> import { Section } from "./Section"; <mask> import { ShortcutsDialog } from "./ShortcutsDialog"; <mask> import Stack from "./Stack"; <mask> import { ToolButton } from "./ToolButton"; <mask> import { Tooltip } from "./Tooltip"; <mask> import { UserList } from "./UserList"; <mask> </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> add import { questionCircle } from "../components/icons"; </s> remove color: $oc-blue-7; /* OC Blue 7 */ </s> add color: var(--link-color); </s> remove showShortcutsDialog: true, </s> add showHelpDialog: true, </s> add width: 1.5rem; </s> add --link-color: #{$oc-blue-7}; </s> add font-size: 1.2em;
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/components/LayerUI.tsx
keep keep keep keep replace replace replace replace keep keep keep keep keep
<mask> message={appState.errorMessage} <mask> onClose={() => setAppState({ errorMessage: null })} <mask> /> <mask> )} <mask> {appState.showShortcutsDialog && ( <mask> <ShortcutsDialog <mask> onClose={() => setAppState({ showShortcutsDialog: false })} <mask> /> <mask> )} <mask> {appState.pasteDialog.shown && ( <mask> <PasteChartDialog <mask> setAppState={setAppState} <mask> appState={appState} </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove <HelpIcon title={t("shortcutsDialog.title")} onClick={updateData} /> </s> add <HelpIcon title={t("helpDialog.title")} onClick={updateData} /> </s> remove showShortcutsDialog: true, </s> add showHelpDialog: true, </s> remove const shortcut = `${capitalizeString(letter)} ${t( "shortcutsDialog.or", )} ${index + 1}`; </s> add const shortcut = `${capitalizeString(letter)} ${t("helpDialog.or")} ${ index + 1 }`; </s> remove showShortcutsDialog: true, </s> add showHelpDialog: true, </s> remove showShortcutsDialog: { browser: false, export: false }, </s> add showHelpDialog: { browser: false, export: false }, </s> remove showShortcutsDialog: false, </s> add showHelpDialog: false,
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/components/LayerUI.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> a { <mask> font-weight: 500; <mask> text-decoration: none; <mask> color: $oc-blue-7; /* OC Blue 7 */ <mask> <mask> &:hover { <mask> text-decoration: underline; <mask> } <mask> } </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove import { ShortcutsDialog } from "./ShortcutsDialog"; </s> add import { HelpDialog } from "./HelpDialog"; </s> remove showShortcutsDialog: true, </s> add showHelpDialog: true, </s> add width: 1.5rem; </s> add --link-color: #{$oc-blue-7}; </s> add import { questionCircle } from "../components/icons"; </s> add font-size: 1.2em;
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/css/styles.scss
keep add keep keep keep keep keep keep
<mask> fill: $oc-gray-6; <mask> bottom: 14px; <mask> <mask> :root[dir="ltr"] & { <mask> right: 14px; <mask> } <mask> <mask> :root[dir="rtl"] & { </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove import { ShortcutsDialog } from "./ShortcutsDialog"; </s> add import { HelpDialog } from "./HelpDialog"; </s> remove color: $oc-blue-7; /* OC Blue 7 */ </s> add color: var(--link-color); </s> remove showShortcutsDialog: true, </s> add showHelpDialog: true, </s> add --link-color: #{$oc-blue-7}; </s> add import { questionCircle } from "../components/icons"; </s> add font-size: 1.2em;
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/css/styles.scss
keep keep keep add keep keep keep keep
<mask> --popup-secondary-background-color: #{$oc-gray-1}; <mask> --popup-text-color: #{$oc-black}; <mask> --popup-text-inverted-color: #{$oc-white}; <mask> --dialog-border: #{$oc-gray-6}; <mask> } <mask> <mask> .excalidraw { <mask> &.Appearance_dark { </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove import { ShortcutsDialog } from "./ShortcutsDialog"; </s> add import { HelpDialog } from "./HelpDialog"; </s> remove color: $oc-blue-7; /* OC Blue 7 */ </s> add color: var(--link-color); </s> remove showShortcutsDialog: true, </s> add showHelpDialog: true, </s> add width: 1.5rem; </s> add import { questionCircle } from "../components/icons"; </s> add font-size: 1.2em;
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/css/theme.scss
keep replace replace replace replace keep replace keep keep keep keep
<mask> }, <mask> "shortcutsDialog": { <mask> "title": "Keyboard shortcuts", <mask> "shapes": "Shapes", <mask> "or": "or", <mask> "click": "click", <mask> "drag": "drag", <mask> "curvedArrow": "Curved arrow", <mask> "curvedLine": "Curved line", <mask> "editor": "Editor", <mask> "view": "View", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> add "documentation": "Documentation", "drag": "drag", </s> remove "view": "View", "blog": "Read our blog", "howto": "Follow our guides", </s> add </s> add "textNewLine": "Add new line (text)", "title": "Help", "view": "View", </s> remove "textNewLine": "Add new line (text)", </s> add "howto": "Follow our guides", "or": "or", "preventBinding": "Prevent arrow binding", "shapes": "Shapes", "shortcuts": "Keyboard shortcuts", </s> remove showShortcutsDialog: { browser: false, export: false }, </s> add showHelpDialog: { browser: false, export: false },
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/locales/en.json
keep keep add keep keep keep keep keep
<mask> "click": "click", <mask> "curvedArrow": "Curved arrow", <mask> "curvedLine": "Curved line", <mask> "editor": "Editor", <mask> "github": "Found an issue? Submit", <mask> "howto": "Follow our guides", <mask> "or": "or", <mask> "preventBinding": "Prevent arrow binding", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove "view": "View", "blog": "Read our blog", "howto": "Follow our guides", </s> add </s> remove "drag": "drag", </s> add </s> remove "textNewLine": "Add new line (text)", </s> add "howto": "Follow our guides", "or": "or", "preventBinding": "Prevent arrow binding", "shapes": "Shapes", "shortcuts": "Keyboard shortcuts", </s> remove "shortcutsDialog": { "title": "Keyboard shortcuts", "shapes": "Shapes", "or": "or", </s> add "helpDialog": { "blog": "Read our blog", </s> remove "zoomToSelection": "Zoom to selection", "preventBinding": "Prevent arrow binding" </s> add "zoomToSelection": "Zoom to selection" </s> remove showShortcutsDialog: boolean; </s> add showHelpDialog: boolean;
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/locales/en.json
keep replace replace replace keep replace keep keep keep
<mask> "editor": "Editor", <mask> "view": "View", <mask> "blog": "Read our blog", <mask> "howto": "Follow our guides", <mask> "github": "Found an issue? Submit", <mask> "textNewLine": "Add new line (text)", <mask> "textFinish": "Finish editing (text)", <mask> "zoomToFit": "Zoom to fit all elements", <mask> "zoomToSelection": "Zoom to selection", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove "zoomToSelection": "Zoom to selection", "preventBinding": "Prevent arrow binding" </s> add "zoomToSelection": "Zoom to selection" </s> add "textNewLine": "Add new line (text)", "title": "Help", "view": "View", </s> add "documentation": "Documentation", "drag": "drag", </s> remove "drag": "drag", </s> add </s> remove "shortcutsDialog": { "title": "Keyboard shortcuts", "shapes": "Shapes", "or": "or", </s> add "helpDialog": { "blog": "Read our blog",
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/locales/en.json
keep keep add keep keep keep keep keep keep
<mask> "shapes": "Shapes", <mask> "shortcuts": "Keyboard shortcuts", <mask> "textFinish": "Finish editing (text)", <mask> "zoomToFit": "Zoom to fit all elements", <mask> "zoomToSelection": "Zoom to selection" <mask> }, <mask> "encrypted": { <mask> "tooltip": "Your drawings are end-to-end encrypted so Excalidraw's servers will never see them." <mask> }, </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove "zoomToSelection": "Zoom to selection", "preventBinding": "Prevent arrow binding" </s> add "zoomToSelection": "Zoom to selection" </s> remove "textNewLine": "Add new line (text)", </s> add "howto": "Follow our guides", "or": "or", "preventBinding": "Prevent arrow binding", "shapes": "Shapes", "shortcuts": "Keyboard shortcuts", </s> remove "view": "View", "blog": "Read our blog", "howto": "Follow our guides", </s> add </s> remove "shortcutsDialog": { "title": "Keyboard shortcuts", "shapes": "Shapes", "or": "or", </s> add "helpDialog": { "blog": "Read our blog", </s> remove "drag": "drag", </s> add </s> remove showShortcutsDialog: { browser: false, export: false }, </s> add showHelpDialog: { browser: false, export: false },
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/locales/en.json
keep keep keep keep replace replace keep keep keep keep keep
<mask> "github": "Found an issue? Submit", <mask> "textNewLine": "Add new line (text)", <mask> "textFinish": "Finish editing (text)", <mask> "zoomToFit": "Zoom to fit all elements", <mask> "zoomToSelection": "Zoom to selection", <mask> "preventBinding": "Prevent arrow binding" <mask> }, <mask> "encrypted": { <mask> "tooltip": "Your drawings are end-to-end encrypted so Excalidraw's servers will never see them." <mask> }, <mask> "stats": { </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> add "textNewLine": "Add new line (text)", "title": "Help", "view": "View", </s> remove "textNewLine": "Add new line (text)", </s> add "howto": "Follow our guides", "or": "or", "preventBinding": "Prevent arrow binding", "shapes": "Shapes", "shortcuts": "Keyboard shortcuts", </s> remove "view": "View", "blog": "Read our blog", "howto": "Follow our guides", </s> add </s> add "documentation": "Documentation", "drag": "drag", </s> remove showShortcutsDialog: { browser: false, export: false }, </s> add showHelpDialog: { browser: false, export: false }, </s> remove showShortcutsDialog: true, </s> add showHelpDialog: true,
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/locales/en.json
keep keep keep keep replace keep keep keep keep keep
<mask> }, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false,
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> }, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false,
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> }, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "y": 500, <mask> }, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false,
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "y": 110, <mask> }, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]> </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false, </s> remove "showShortcutsDialog": false, </s> add "showHelpDialog": false,
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap
keep keep keep keep replace keep keep keep keep keep
<mask> "selectedGroupIds": Object {}, <mask> "selectionElement": null, <mask> "shouldAddWatermark": false, <mask> "shouldCacheIgnoreZoom": false, <mask> "showShortcutsDialog": false, <mask> "showStats": false, <mask> "startBoundElement": null, <mask> "suggestedBindings": Array [], <mask> "toastMessage": null, <mask> "viewBackgroundColor": "#ffffff", </s> feat: Change shortcuts menu to help menu (#2812) Co-authored-by: Panayiotis Lipiridis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/ce2c341910ec14b20162c0e3fc11f982f56cd2e4
src/tests/__snapshots__/regressionTests.test.tsx.snap