docstring_tokens
stringlengths
18
16.9k
code_tokens
stringlengths
75
1.81M
html_url
stringlengths
74
116
file_name
stringlengths
3
311
keep keep add keep keep keep keep keep
<mask> return loadFromBlob(blob, localAppState); <mask> }; <mask> <mask> export const isValidLibrary = (json: any) => { <mask> return ( <mask> typeof json === "object" && <mask> json && <mask> json.type === "excalidrawlib" && </s> feat: support importing scene from url (#2726) </s> add import { ImportedDataState } from "./types"; </s> remove import { ImportedDataState, LibraryData } from "./types"; </s> add import { LibraryData } from "./types"; </s> remove const isExternalScene = !!(id || jsonMatch || roomLinkData); </s> add const isExternalScene = !!(id || jsonBackendMatch || roomLinkData); </s> remove const data: ImportedDataState = JSON.parse(contents); if (data.type !== "excalidraw") { </s> add const data = JSON.parse(contents); if (!isValidExcalidrawData(data)) { </s> remove const jsonMatch = window.location.hash.match( </s> add const jsonBackendMatch = window.location.hash.match( </s> add const externalUrlMatch = window.location.hash.match(/^#url=(.*)$/);
https://github.com/excalidraw/excalidraw/commit/beffc290fd1438b61f96d1e000c0b1567d5a62b8
src/data/json.ts
keep add keep keep keep keep keep keep
<mask> import { TopErrorBoundary } from "../components/TopErrorBoundary"; <mask> import { APP_NAME, EVENT, TITLE_TIMEOUT, VERSION_TIMEOUT } from "../constants"; <mask> import { DataState, ImportedDataState } from "../data/types"; <mask> import { <mask> ExcalidrawElement, <mask> NonDeletedExcalidrawElement, <mask> } from "../element/types"; <mask> import { useCallbackRefState } from "../hooks/useCallbackRefState"; </s> feat: support importing scene from url (#2726) </s> add import { ImportedDataState } from "./types"; </s> add import { isValidExcalidrawData } from "./json"; </s> remove import { ImportedDataState, LibraryData } from "./types"; </s> add import { LibraryData } from "./types"; </s> remove } else if (jsonMatch) { scene = await loadScene(jsonMatch[1], jsonMatch[2], initialData); </s> add } else if (jsonBackendMatch) { scene = await loadScene( jsonBackendMatch[1], jsonBackendMatch[2], initialData, ); </s> remove const data: ImportedDataState = JSON.parse(contents); if (data.type !== "excalidraw") { </s> add const data = JSON.parse(contents); if (!isValidExcalidrawData(data)) { </s> add const externalUrlMatch = window.location.hash.match(/^#url=(.*)$/);
https://github.com/excalidraw/excalidraw/commit/beffc290fd1438b61f96d1e000c0b1567d5a62b8
src/excalidraw-app/index.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> collabAPI: CollabAPI; <mask> }): Promise<ImportedDataState | null> => { <mask> const searchParams = new URLSearchParams(window.location.search); <mask> const id = searchParams.get("id"); <mask> const jsonMatch = window.location.hash.match( <mask> /^#json=([0-9]+),([a-zA-Z0-9_-]+)$/, <mask> ); <mask> <mask> const initialData = importFromLocalStorage(); <mask> </s> feat: support importing scene from url (#2726) </s> add const externalUrlMatch = window.location.hash.match(/^#url=(.*)$/); </s> remove const data: ImportedDataState = JSON.parse(contents); if (data.type !== "excalidraw") { </s> add const data = JSON.parse(contents); if (!isValidExcalidrawData(data)) { </s> remove const isExternalScene = !!(id || jsonMatch || roomLinkData); </s> add const isExternalScene = !!(id || jsonBackendMatch || roomLinkData); </s> add export const isValidExcalidrawData = (data?: { type?: any; elements?: any; appState?: any; }): data is ImportedDataState => { return ( data?.type === "excalidraw" && (!data.elements || (Array.isArray(data.elements) && (!data.appState || typeof data.appState === "object"))) ); }; </s> add import { isValidExcalidrawData } from "./json"; </s> add import { ImportedDataState } from "./types";
https://github.com/excalidraw/excalidraw/commit/beffc290fd1438b61f96d1e000c0b1567d5a62b8
src/excalidraw-app/index.tsx
keep keep add keep keep keep keep
<mask> const jsonBackendMatch = window.location.hash.match( <mask> /^#json=([0-9]+),([a-zA-Z0-9_-]+)$/, <mask> ); <mask> <mask> const initialData = importFromLocalStorage(); <mask> <mask> let scene: DataState & { scrollToCenter?: boolean } = await loadScene( </s> feat: support importing scene from url (#2726) </s> remove const jsonMatch = window.location.hash.match( </s> add const jsonBackendMatch = window.location.hash.match( </s> remove } else if (jsonMatch) { scene = await loadScene(jsonMatch[1], jsonMatch[2], initialData); </s> add } else if (jsonBackendMatch) { scene = await loadScene( jsonBackendMatch[1], jsonBackendMatch[2], initialData, ); </s> remove const data: ImportedDataState = JSON.parse(contents); if (data.type !== "excalidraw") { </s> add const data = JSON.parse(contents); if (!isValidExcalidrawData(data)) { </s> remove const isExternalScene = !!(id || jsonMatch || roomLinkData); </s> add const isExternalScene = !!(id || jsonBackendMatch || roomLinkData); </s> add import { isValidExcalidrawData } from "./json"; </s> remove import { ImportedDataState, LibraryData } from "./types"; </s> add import { LibraryData } from "./types";
https://github.com/excalidraw/excalidraw/commit/beffc290fd1438b61f96d1e000c0b1567d5a62b8
src/excalidraw-app/index.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> initialData, <mask> ); <mask> <mask> let roomLinkData = getCollaborationLinkData(window.location.href); <mask> const isExternalScene = !!(id || jsonMatch || roomLinkData); <mask> if (isExternalScene) { <mask> if ( <mask> // don't prompt if scene is empty <mask> !scene.elements.length || <mask> // don't prompt for collab scenes because we don't override local storage </s> feat: support importing scene from url (#2726) </s> remove } else if (jsonMatch) { scene = await loadScene(jsonMatch[1], jsonMatch[2], initialData); </s> add } else if (jsonBackendMatch) { scene = await loadScene( jsonBackendMatch[1], jsonBackendMatch[2], initialData, ); </s> add export const isValidExcalidrawData = (data?: { type?: any; elements?: any; appState?: any; }): data is ImportedDataState => { return ( data?.type === "excalidraw" && (!data.elements || (Array.isArray(data.elements) && (!data.appState || typeof data.appState === "object"))) ); }; </s> remove const data: ImportedDataState = JSON.parse(contents); if (data.type !== "excalidraw") { </s> add const data = JSON.parse(contents); if (!isValidExcalidrawData(data)) { </s> remove const jsonMatch = window.location.hash.match( </s> add const jsonBackendMatch = window.location.hash.match( </s> remove import { ImportedDataState, LibraryData } from "./types"; </s> add import { LibraryData } from "./types"; </s> add const externalUrlMatch = window.location.hash.match(/^#url=(.*)$/);
https://github.com/excalidraw/excalidraw/commit/beffc290fd1438b61f96d1e000c0b1567d5a62b8
src/excalidraw-app/index.tsx
keep keep keep keep replace replace keep keep keep keep keep
<mask> ) { <mask> // Backwards compatibility with legacy url format <mask> if (id) { <mask> scene = await loadScene(id, null, initialData); <mask> } else if (jsonMatch) { <mask> scene = await loadScene(jsonMatch[1], jsonMatch[2], initialData); <mask> } <mask> scene.scrollToCenter = true; <mask> if (!roomLinkData) { <mask> window.history.replaceState({}, APP_NAME, window.location.origin); <mask> } </s> feat: support importing scene from url (#2726) </s> remove const data: ImportedDataState = JSON.parse(contents); if (data.type !== "excalidraw") { </s> add const data = JSON.parse(contents); if (!isValidExcalidrawData(data)) { </s> remove const isExternalScene = !!(id || jsonMatch || roomLinkData); </s> add const isExternalScene = !!(id || jsonBackendMatch || roomLinkData); </s> remove import { ImportedDataState, LibraryData } from "./types"; </s> add import { LibraryData } from "./types"; </s> add const externalUrlMatch = window.location.hash.match(/^#url=(.*)$/); </s> add import { loadFromBlob } from "../data/blob"; </s> add import { isValidExcalidrawData } from "./json";
https://github.com/excalidraw/excalidraw/commit/beffc290fd1438b61f96d1e000c0b1567d5a62b8
src/excalidraw-app/index.tsx
keep add keep keep keep keep keep
<mask> "imageDoesNotContainScene": "Importing images isn't supported at the moment.\n\nDid you want to import a scene? This image does not seem to contain any scene data. Have you enabled this during export?", <mask> "cannotRestoreFromImage": "Scene couldn't be restored from this image file", <mask> "resetLibrary": "This will clear your library. Are you sure?" <mask> }, <mask> "toolBar": { <mask> "selection": "Selection", <mask> "draw": "Free draw", </s> feat: support importing scene from url (#2726) </s> remove } else if (jsonMatch) { scene = await loadScene(jsonMatch[1], jsonMatch[2], initialData); </s> add } else if (jsonBackendMatch) { scene = await loadScene( jsonBackendMatch[1], jsonBackendMatch[2], initialData, ); </s> add import { loadFromBlob } from "../data/blob"; </s> add import { isValidExcalidrawData } from "./json"; </s> remove import { ImportedDataState, LibraryData } from "./types"; </s> add import { LibraryData } from "./types"; </s> add import { ImportedDataState } from "./types"; </s> remove const isExternalScene = !!(id || jsonMatch || roomLinkData); </s> add const isExternalScene = !!(id || jsonBackendMatch || roomLinkData);
https://github.com/excalidraw/excalidraw/commit/beffc290fd1438b61f96d1e000c0b1567d5a62b8
src/locales/en.json
keep add keep keep keep keep
<mask> import { newElementWith } from "./element/mutateElement"; <mask> import { Box, getCommonBoundingBox } from "./element/bounds"; <mask> <mask> export interface Alignment { <mask> position: "start" | "center" | "end"; <mask> axis: "x" | "y"; </s> fix: align and distribute binded text in container and cleanup (#4468) </s> remove import { getCommonBounds } from "./element"; interface Box { minX: number; minY: number; maxX: number; maxY: number; midX: number; midY: number; width: number; height: number; } </s> add import { getMaximumGroups } from "./groups"; import { getCommonBoundingBox } from "./element/bounds"; </s> remove export const getMaximumGroups = ( elements: ExcalidrawElement[], ): ExcalidrawElement[][] => { const groups: Map<String, ExcalidrawElement[]> = new Map< String, ExcalidrawElement[] >(); elements.forEach((element: ExcalidrawElement) => { const groupId = element.groupIds.length === 0 ? element.id : element.groupIds[element.groupIds.length - 1]; const currentGroupMembers = groups.get(groupId) || []; groups.set(groupId, [...currentGroupMembers, element]); }); return Array.from(groups.values()); }; </s> add </s> remove import { GroupId, ExcalidrawElement, NonDeleted } from "./element/types"; </s> add import { GroupId, ExcalidrawElement, NonDeleted, ExcalidrawTextElementWithContainer, } from "./element/types"; </s> add import { getBoundTextElementId } from "./element/textElement"; import Scene from "./scene/Scene"; </s> add midX: number; midY: number; width: number; height: number; </s> remove return { minX, minY, maxX, maxY }; </s> add return { minX, minY, maxX, maxY, width: maxX - minX, height: maxY - minY, midX: (minX + maxX) / 2, midY: (minY + maxY) / 2, };
https://github.com/excalidraw/excalidraw/commit/bf2bca221ed9ba14aa5b0dfc00e540128e7bfe3f
src/align.ts
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 keep keep keep keep keep
<mask> ); <mask> }); <mask> }; <mask> <mask> export const getMaximumGroups = ( <mask> elements: ExcalidrawElement[], <mask> ): ExcalidrawElement[][] => { <mask> const groups: Map<String, ExcalidrawElement[]> = new Map< <mask> String, <mask> ExcalidrawElement[] <mask> >(); <mask> <mask> elements.forEach((element: ExcalidrawElement) => { <mask> const groupId = <mask> element.groupIds.length === 0 <mask> ? element.id <mask> : element.groupIds[element.groupIds.length - 1]; <mask> <mask> const currentGroupMembers = groups.get(groupId) || []; <mask> <mask> groups.set(groupId, [...currentGroupMembers, element]); <mask> }); <mask> <mask> return Array.from(groups.values()); <mask> }; <mask> <mask> const calculateTranslation = ( <mask> group: ExcalidrawElement[], <mask> selectionBoundingBox: Box, <mask> { axis, position }: Alignment, <mask> ): { x: number; y: number } => { </s> fix: align and distribute binded text in container and cleanup (#4468) </s> remove export const getMaximumGroups = ( elements: ExcalidrawElement[], ): ExcalidrawElement[][] => { const groups: Map<String, ExcalidrawElement[]> = new Map< String, ExcalidrawElement[] >(); elements.forEach((element: ExcalidrawElement) => { const groupId = element.groupIds.length === 0 ? element.id : element.groupIds[element.groupIds.length - 1]; const currentGroupMembers = groups.get(groupId) || []; groups.set(groupId, [...currentGroupMembers, element]); }); return Array.from(groups.values()); }; const getCommonBoundingBox = (elements: ExcalidrawElement[]): Box => { const [minX, minY, maxX, maxY] = getCommonBounds(elements); return { minX, minY, maxX, maxY, width: maxX - minX, height: maxY - minY, midX: (minX + maxX) / 2, midY: (minY + maxY) / 2, }; }; </s> add </s> remove return { minX, minY, maxX, maxY }; </s> add return { minX, minY, maxX, maxY, width: maxX - minX, height: maxY - minY, midX: (minX + maxX) / 2, midY: (minY + maxY) / 2, }; </s> add midX: number; midY: number; width: number; height: number; </s> add import { getBoundTextElementId } from "./element/textElement"; import Scene from "./scene/Scene"; </s> remove import { GroupId, ExcalidrawElement, NonDeleted } from "./element/types"; </s> add import { GroupId, ExcalidrawElement, NonDeleted, ExcalidrawTextElementWithContainer, } from "./element/types"; </s> add import { getMaximumGroups } from "./groups";
https://github.com/excalidraw/excalidraw/commit/bf2bca221ed9ba14aa5b0dfc00e540128e7bfe3f
src/align.ts
keep keep replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> import { ExcalidrawElement } from "./element/types"; <mask> import { newElementWith } from "./element/mutateElement"; <mask> import { getCommonBounds } from "./element"; <mask> <mask> interface Box { <mask> minX: number; <mask> minY: number; <mask> maxX: number; <mask> maxY: number; <mask> midX: number; <mask> midY: number; <mask> width: number; <mask> height: number; <mask> } <mask> <mask> export interface Distribution { <mask> space: "between"; <mask> axis: "x" | "y"; <mask> } </s> fix: align and distribute binded text in container and cleanup (#4468) </s> add midX: number; midY: number; width: number; height: number; </s> add import { getMaximumGroups } from "./groups"; </s> remove export const getMaximumGroups = ( elements: ExcalidrawElement[], ): ExcalidrawElement[][] => { const groups: Map<String, ExcalidrawElement[]> = new Map< String, ExcalidrawElement[] >(); elements.forEach((element: ExcalidrawElement) => { const groupId = element.groupIds.length === 0 ? element.id : element.groupIds[element.groupIds.length - 1]; const currentGroupMembers = groups.get(groupId) || []; groups.set(groupId, [...currentGroupMembers, element]); }); return Array.from(groups.values()); }; </s> add </s> remove import { GroupId, ExcalidrawElement, NonDeleted } from "./element/types"; </s> add import { GroupId, ExcalidrawElement, NonDeleted, ExcalidrawTextElementWithContainer, } from "./element/types"; </s> add import { getBoundTextElementId } from "./element/textElement"; import Scene from "./scene/Scene"; </s> remove return { minX, minY, maxX, maxY }; </s> add return { minX, minY, maxX, maxY, width: maxX - minX, height: maxY - minY, midX: (minX + maxX) / 2, midY: (minY + maxY) / 2, };
https://github.com/excalidraw/excalidraw/commit/bf2bca221ed9ba14aa5b0dfc00e540128e7bfe3f
src/disitrubte.ts
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
<mask> }), <mask> ); <mask> }); <mask> }; <mask> <mask> export const getMaximumGroups = ( <mask> elements: ExcalidrawElement[], <mask> ): ExcalidrawElement[][] => { <mask> const groups: Map<String, ExcalidrawElement[]> = new Map< <mask> String, <mask> ExcalidrawElement[] <mask> >(); <mask> <mask> elements.forEach((element: ExcalidrawElement) => { <mask> const groupId = <mask> element.groupIds.length === 0 <mask> ? element.id <mask> : element.groupIds[element.groupIds.length - 1]; <mask> <mask> const currentGroupMembers = groups.get(groupId) || []; <mask> <mask> groups.set(groupId, [...currentGroupMembers, element]); <mask> }); <mask> <mask> return Array.from(groups.values()); <mask> }; <mask> <mask> const getCommonBoundingBox = (elements: ExcalidrawElement[]): Box => { <mask> const [minX, minY, maxX, maxY] = getCommonBounds(elements); <mask> return { <mask> minX, <mask> minY, <mask> maxX, <mask> maxY, <mask> width: maxX - minX, <mask> height: maxY - minY, <mask> midX: (minX + maxX) / 2, <mask> midY: (minY + maxY) / 2, <mask> }; <mask> }; </s> fix: align and distribute binded text in container and cleanup (#4468) </s> remove export const getMaximumGroups = ( elements: ExcalidrawElement[], ): ExcalidrawElement[][] => { const groups: Map<String, ExcalidrawElement[]> = new Map< String, ExcalidrawElement[] >(); elements.forEach((element: ExcalidrawElement) => { const groupId = element.groupIds.length === 0 ? element.id : element.groupIds[element.groupIds.length - 1]; const currentGroupMembers = groups.get(groupId) || []; groups.set(groupId, [...currentGroupMembers, element]); }); return Array.from(groups.values()); }; </s> add </s> remove return { minX, minY, maxX, maxY }; </s> add return { minX, minY, maxX, maxY, width: maxX - minX, height: maxY - minY, midX: (minX + maxX) / 2, midY: (minY + maxY) / 2, }; </s> add midX: number; midY: number; width: number; height: number; </s> add import { getBoundTextElementId } from "./element/textElement"; import Scene from "./scene/Scene"; </s> remove import { GroupId, ExcalidrawElement, NonDeleted } from "./element/types"; </s> add import { GroupId, ExcalidrawElement, NonDeleted, ExcalidrawTextElementWithContainer, } from "./element/types"; </s> add import { getMaximumGroups } from "./groups";
https://github.com/excalidraw/excalidraw/commit/bf2bca221ed9ba14aa5b0dfc00e540128e7bfe3f
src/disitrubte.ts
keep keep keep add keep keep keep keep keep keep
<mask> minX: number; <mask> minY: number; <mask> maxX: number; <mask> maxY: number; <mask> } <mask> <mask> export const getCommonBoundingBox = ( <mask> elements: ExcalidrawElement[] | readonly NonDeleted<ExcalidrawElement>[], <mask> ): Box => { <mask> const [minX, minY, maxX, maxY] = getCommonBounds(elements); </s> fix: align and distribute binded text in container and cleanup (#4468) </s> remove import { getCommonBounds } from "./element"; interface Box { minX: number; minY: number; maxX: number; maxY: number; midX: number; midY: number; width: number; height: number; } </s> add import { getMaximumGroups } from "./groups"; import { getCommonBoundingBox } from "./element/bounds"; </s> remove return { minX, minY, maxX, maxY }; </s> add return { minX, minY, maxX, maxY, width: maxX - minX, height: maxY - minY, midX: (minX + maxX) / 2, midY: (minY + maxY) / 2, }; </s> remove export const getMaximumGroups = ( elements: ExcalidrawElement[], ): ExcalidrawElement[][] => { const groups: Map<String, ExcalidrawElement[]> = new Map< String, ExcalidrawElement[] >(); elements.forEach((element: ExcalidrawElement) => { const groupId = element.groupIds.length === 0 ? element.id : element.groupIds[element.groupIds.length - 1]; const currentGroupMembers = groups.get(groupId) || []; groups.set(groupId, [...currentGroupMembers, element]); }); return Array.from(groups.values()); }; const getCommonBoundingBox = (elements: ExcalidrawElement[]): Box => { const [minX, minY, maxX, maxY] = getCommonBounds(elements); return { minX, minY, maxX, maxY, width: maxX - minX, height: maxY - minY, midX: (minX + maxX) / 2, midY: (minY + maxY) / 2, }; }; </s> add </s> remove export const getMaximumGroups = ( elements: ExcalidrawElement[], ): ExcalidrawElement[][] => { const groups: Map<String, ExcalidrawElement[]> = new Map< String, ExcalidrawElement[] >(); elements.forEach((element: ExcalidrawElement) => { const groupId = element.groupIds.length === 0 ? element.id : element.groupIds[element.groupIds.length - 1]; const currentGroupMembers = groups.get(groupId) || []; groups.set(groupId, [...currentGroupMembers, element]); }); return Array.from(groups.values()); }; </s> add </s> add import { getBoundTextElementId } from "./element/textElement"; import Scene from "./scene/Scene"; </s> remove import { GroupId, ExcalidrawElement, NonDeleted } from "./element/types"; </s> add import { GroupId, ExcalidrawElement, NonDeleted, ExcalidrawTextElementWithContainer, } from "./element/types";
https://github.com/excalidraw/excalidraw/commit/bf2bca221ed9ba14aa5b0dfc00e540128e7bfe3f
src/element/bounds.ts
keep keep keep keep replace keep
<mask> export const getCommonBoundingBox = ( <mask> elements: ExcalidrawElement[] | readonly NonDeleted<ExcalidrawElement>[], <mask> ): Box => { <mask> const [minX, minY, maxX, maxY] = getCommonBounds(elements); <mask> return { minX, minY, maxX, maxY }; <mask> }; </s> fix: align and distribute binded text in container and cleanup (#4468) </s> remove export const getMaximumGroups = ( elements: ExcalidrawElement[], ): ExcalidrawElement[][] => { const groups: Map<String, ExcalidrawElement[]> = new Map< String, ExcalidrawElement[] >(); elements.forEach((element: ExcalidrawElement) => { const groupId = element.groupIds.length === 0 ? element.id : element.groupIds[element.groupIds.length - 1]; const currentGroupMembers = groups.get(groupId) || []; groups.set(groupId, [...currentGroupMembers, element]); }); return Array.from(groups.values()); }; const getCommonBoundingBox = (elements: ExcalidrawElement[]): Box => { const [minX, minY, maxX, maxY] = getCommonBounds(elements); return { minX, minY, maxX, maxY, width: maxX - minX, height: maxY - minY, midX: (minX + maxX) / 2, midY: (minY + maxY) / 2, }; }; </s> add </s> add midX: number; midY: number; width: number; height: number; </s> remove export const getMaximumGroups = ( elements: ExcalidrawElement[], ): ExcalidrawElement[][] => { const groups: Map<String, ExcalidrawElement[]> = new Map< String, ExcalidrawElement[] >(); elements.forEach((element: ExcalidrawElement) => { const groupId = element.groupIds.length === 0 ? element.id : element.groupIds[element.groupIds.length - 1]; const currentGroupMembers = groups.get(groupId) || []; groups.set(groupId, [...currentGroupMembers, element]); }); return Array.from(groups.values()); }; </s> add </s> add import { getBoundTextElementId } from "./element/textElement"; import Scene from "./scene/Scene"; </s> remove import { GroupId, ExcalidrawElement, NonDeleted } from "./element/types"; </s> add import { GroupId, ExcalidrawElement, NonDeleted, ExcalidrawTextElementWithContainer, } from "./element/types"; </s> add import { getMaximumGroups } from "./groups";
https://github.com/excalidraw/excalidraw/commit/bf2bca221ed9ba14aa5b0dfc00e540128e7bfe3f
src/element/bounds.ts
replace keep keep keep keep keep
<mask> import { GroupId, ExcalidrawElement, NonDeleted } from "./element/types"; <mask> import { AppState } from "./types"; <mask> import { getSelectedElements } from "./scene"; <mask> <mask> export const selectGroup = ( <mask> groupId: GroupId, </s> fix: align and distribute binded text in container and cleanup (#4468) </s> add import { getBoundTextElementId } from "./element/textElement"; import Scene from "./scene/Scene"; </s> remove import { getCommonBounds } from "./element"; interface Box { minX: number; minY: number; maxX: number; maxY: number; midX: number; midY: number; width: number; height: number; } </s> add import { getMaximumGroups } from "./groups"; import { getCommonBoundingBox } from "./element/bounds"; </s> remove export const getMaximumGroups = ( elements: ExcalidrawElement[], ): ExcalidrawElement[][] => { const groups: Map<String, ExcalidrawElement[]> = new Map< String, ExcalidrawElement[] >(); elements.forEach((element: ExcalidrawElement) => { const groupId = element.groupIds.length === 0 ? element.id : element.groupIds[element.groupIds.length - 1]; const currentGroupMembers = groups.get(groupId) || []; groups.set(groupId, [...currentGroupMembers, element]); }); return Array.from(groups.values()); }; </s> add </s> add import { getMaximumGroups } from "./groups"; </s> add midX: number; midY: number; width: number; height: number; </s> remove return { minX, minY, maxX, maxY }; </s> add return { minX, minY, maxX, maxY, width: maxX - minX, height: maxY - minY, midX: (minX + maxX) / 2, midY: (minY + maxY) / 2, };
https://github.com/excalidraw/excalidraw/commit/bf2bca221ed9ba14aa5b0dfc00e540128e7bfe3f
src/groups.ts
keep add keep keep keep keep keep
<mask> import { AppState } from "./types"; <mask> import { getSelectedElements } from "./scene"; <mask> <mask> export const selectGroup = ( <mask> groupId: GroupId, <mask> appState: AppState, <mask> elements: readonly NonDeleted<ExcalidrawElement>[], </s> fix: align and distribute binded text in container and cleanup (#4468) </s> remove import { GroupId, ExcalidrawElement, NonDeleted } from "./element/types"; </s> add import { GroupId, ExcalidrawElement, NonDeleted, ExcalidrawTextElementWithContainer, } from "./element/types"; </s> add midX: number; midY: number; width: number; height: number; </s> remove return { minX, minY, maxX, maxY }; </s> add return { minX, minY, maxX, maxY, width: maxX - minX, height: maxY - minY, midX: (minX + maxX) / 2, midY: (minY + maxY) / 2, }; </s> remove export const getMaximumGroups = ( elements: ExcalidrawElement[], ): ExcalidrawElement[][] => { const groups: Map<String, ExcalidrawElement[]> = new Map< String, ExcalidrawElement[] >(); elements.forEach((element: ExcalidrawElement) => { const groupId = element.groupIds.length === 0 ? element.id : element.groupIds[element.groupIds.length - 1]; const currentGroupMembers = groups.get(groupId) || []; groups.set(groupId, [...currentGroupMembers, element]); }); return Array.from(groups.values()); }; </s> add </s> remove import { getCommonBounds } from "./element"; interface Box { minX: number; minY: number; maxX: number; maxY: number; midX: number; midY: number; width: number; height: number; } </s> add import { getMaximumGroups } from "./groups"; import { getCommonBoundingBox } from "./element/bounds"; </s> remove export const getMaximumGroups = ( elements: ExcalidrawElement[], ): ExcalidrawElement[][] => { const groups: Map<String, ExcalidrawElement[]> = new Map< String, ExcalidrawElement[] >(); elements.forEach((element: ExcalidrawElement) => { const groupId = element.groupIds.length === 0 ? element.id : element.groupIds[element.groupIds.length - 1]; const currentGroupMembers = groups.get(groupId) || []; groups.set(groupId, [...currentGroupMembers, element]); }); return Array.from(groups.values()); }; const getCommonBoundingBox = (elements: ExcalidrawElement[]): Box => { const [minX, minY, maxX, maxY] = getCommonBounds(elements); return { minX, minY, maxX, maxY, width: maxX - minX, height: maxY - minY, midX: (minX + maxX) / 2, midY: (minY + maxY) / 2, }; }; </s> add
https://github.com/excalidraw/excalidraw/commit/bf2bca221ed9ba14aa5b0dfc00e540128e7bfe3f
src/groups.ts
keep add keep keep keep keep keep keep
<mask> this.savePointer(event.clientX, event.clientY, "down"); <mask> <mask> if (this.handleCanvasPanUsingWheelOrSpaceDrag(event)) { <mask> return; <mask> } <mask> <mask> // only handle left mouse button or touch <mask> if ( </s> fix: Pinch zoom in view mode (#5001) </s> remove this.updateGestureOnPointerDown(event); </s> add </s> remove gesture.pointers.size === 0 && </s> add gesture.pointers.size <= 1 &&
https://github.com/excalidraw/excalidraw/commit/bf6d0eeef7ea73525484fe680fd72f46ab490d51
src/components/App.tsx
keep keep keep keep replace replace keep keep keep keep keep
<mask> ) { <mask> return; <mask> } <mask> <mask> this.updateGestureOnPointerDown(event); <mask> <mask> // don't select while panning <mask> if (gesture.pointers.size > 1) { <mask> return; <mask> } <mask> </s> fix: Pinch zoom in view mode (#5001) </s> add this.updateGestureOnPointerDown(event); </s> remove gesture.pointers.size === 0 && </s> add gesture.pointers.size <= 1 &&
https://github.com/excalidraw/excalidraw/commit/bf6d0eeef7ea73525484fe680fd72f46ab490d51
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> event: React.PointerEvent<HTMLCanvasElement>, <mask> ): boolean => { <mask> if ( <mask> !( <mask> gesture.pointers.size === 0 && <mask> (event.button === POINTER_BUTTON.WHEEL || <mask> (event.button === POINTER_BUTTON.MAIN && isHoldingSpace) || <mask> this.state.viewModeEnabled) <mask> ) || <mask> isTextElement(this.state.editingElement) </s> fix: Pinch zoom in view mode (#5001) </s> remove this.updateGestureOnPointerDown(event); </s> add </s> add this.updateGestureOnPointerDown(event);
https://github.com/excalidraw/excalidraw/commit/bf6d0eeef7ea73525484fe680fd72f46ab490d51
src/components/App.tsx
keep add keep keep keep keep keep keep
<mask> left={left} <mask> fitInViewport={true} <mask> > <mask> <ul <mask> className="context-menu" <mask> onContextMenu={(event) => event.preventDefault()} <mask> > <mask> {options.map((option, idx) => { </s> fix: Right-click object menu displays partially off-screen (#4572) (#4631) </s> remove }, [fitInViewport]); </s> add }, [fitInViewport, viewportWidth, viewportHeight, offsetLeft, offsetTop]); </s> remove const viewportWidth = window.innerWidth; if (x + width > viewportWidth) { </s> add if (x + width - offsetLeft > viewportWidth) { </s> remove const viewportHeight = window.innerHeight; if (y + height > viewportHeight) { </s> add if (y + height - offsetTop > viewportHeight) { </s> add offsetLeft = 0, offsetTop = 0, viewportWidth = window.innerWidth, viewportHeight = window.innerHeight, </s> add offsetLeft?: number; offsetTop?: number; viewportWidth?: number; viewportHeight?: number;
https://github.com/excalidraw/excalidraw/commit/c009e03c8e654f89739f840c5b374bbb9d1d2982
src/components/ContextMenu.tsx
keep keep add keep keep keep keep keep keep
<mask> children?: React.ReactNode; <mask> onCloseRequest?(event: PointerEvent): void; <mask> fitInViewport?: boolean; <mask> }; <mask> <mask> export const Popover = ({ <mask> children, <mask> left, <mask> top, </s> fix: Right-click object menu displays partially off-screen (#4572) (#4631) </s> add offsetLeft = 0, offsetTop = 0, viewportWidth = window.innerWidth, viewportHeight = window.innerHeight, </s> remove const viewportWidth = window.innerWidth; if (x + width > viewportWidth) { </s> add if (x + width - offsetLeft > viewportWidth) { </s> remove const viewportHeight = window.innerHeight; if (y + height > viewportHeight) { </s> add if (y + height - offsetTop > viewportHeight) { </s> remove }, [fitInViewport]); </s> add }, [fitInViewport, viewportWidth, viewportHeight, offsetLeft, offsetTop]); </s> add offsetLeft={appState.offsetLeft} offsetTop={appState.offsetTop} viewportWidth={appState.width} viewportHeight={appState.height}
https://github.com/excalidraw/excalidraw/commit/c009e03c8e654f89739f840c5b374bbb9d1d2982
src/components/Popover.tsx
keep keep add keep keep keep keep keep keep
<mask> top, <mask> onCloseRequest, <mask> fitInViewport = false, <mask> }: Props) => { <mask> const popoverRef = useRef<HTMLDivElement>(null); <mask> <mask> // ensure the popover doesn't overflow the viewport <mask> useLayoutEffect(() => { <mask> if (fitInViewport && popoverRef.current) { </s> fix: Right-click object menu displays partially off-screen (#4572) (#4631) </s> remove const viewportWidth = window.innerWidth; if (x + width > viewportWidth) { </s> add if (x + width - offsetLeft > viewportWidth) { </s> remove }, [fitInViewport]); </s> add }, [fitInViewport, viewportWidth, viewportHeight, offsetLeft, offsetTop]); </s> remove const viewportHeight = window.innerHeight; if (y + height > viewportHeight) { </s> add if (y + height - offsetTop > viewportHeight) { </s> add offsetLeft={appState.offsetLeft} offsetTop={appState.offsetTop} viewportWidth={appState.width} viewportHeight={appState.height} </s> add offsetLeft?: number; offsetTop?: number; viewportWidth?: number; viewportHeight?: number;
https://github.com/excalidraw/excalidraw/commit/c009e03c8e654f89739f840c5b374bbb9d1d2982
src/components/Popover.tsx
keep keep keep replace replace replace keep keep replace replace keep keep keep keep
<mask> if (fitInViewport && popoverRef.current) { <mask> const element = popoverRef.current; <mask> const { x, y, width, height } = element.getBoundingClientRect(); <mask> <mask> const viewportWidth = window.innerWidth; <mask> if (x + width > viewportWidth) { <mask> element.style.left = `${viewportWidth - width}px`; <mask> } <mask> const viewportHeight = window.innerHeight; <mask> if (y + height > viewportHeight) { <mask> element.style.top = `${viewportHeight - height}px`; <mask> } <mask> } <mask> }, [fitInViewport]); </s> fix: Right-click object menu displays partially off-screen (#4572) (#4631) </s> remove }, [fitInViewport]); </s> add }, [fitInViewport, viewportWidth, viewportHeight, offsetLeft, offsetTop]); </s> add offsetLeft = 0, offsetTop = 0, viewportWidth = window.innerWidth, viewportHeight = window.innerHeight, </s> add offsetLeft?: number; offsetTop?: number; viewportWidth?: number; viewportHeight?: number; </s> add offsetLeft={appState.offsetLeft} offsetTop={appState.offsetTop} viewportWidth={appState.width} viewportHeight={appState.height}
https://github.com/excalidraw/excalidraw/commit/c009e03c8e654f89739f840c5b374bbb9d1d2982
src/components/Popover.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> if (y + height > viewportHeight) { <mask> element.style.top = `${viewportHeight - height}px`; <mask> } <mask> } <mask> }, [fitInViewport]); <mask> <mask> useEffect(() => { <mask> if (onCloseRequest) { <mask> const handler = (event: PointerEvent) => { <mask> if (!popoverRef.current?.contains(event.target as Node)) { </s> fix: Right-click object menu displays partially off-screen (#4572) (#4631) </s> remove const viewportHeight = window.innerHeight; if (y + height > viewportHeight) { </s> add if (y + height - offsetTop > viewportHeight) { </s> remove const viewportWidth = window.innerWidth; if (x + width > viewportWidth) { </s> add if (x + width - offsetLeft > viewportWidth) { </s> add offsetLeft = 0, offsetTop = 0, viewportWidth = window.innerWidth, viewportHeight = window.innerHeight, </s> add offsetLeft={appState.offsetLeft} offsetTop={appState.offsetTop} viewportWidth={appState.width} viewportHeight={appState.height} </s> add offsetLeft?: number; offsetTop?: number; viewportWidth?: number; viewportHeight?: number;
https://github.com/excalidraw/excalidraw/commit/c009e03c8e654f89739f840c5b374bbb9d1d2982
src/components/Popover.tsx
keep keep keep add keep keep keep keep
<mask> // https://stackoverflow.com/questions/521295/seeding-the-random-number-generator-in-javascript/47593316#47593316 <mask> const LCG = (seed: number) => () => <mask> ((2 ** 31 - 1) & (seed = Math.imul(48271, seed))) / 2 ** 31; <mask> <mask> // Unfortunately, roughjs doesn't support a seed attribute (https://github.com/pshihn/rough/issues/27). <mask> // We can achieve the same result by overriding the Math.random function with a <mask> // pseudo random generator that supports a random seed and swapping it back after. <mask> function withCustomMathRandom<T>(seed: number, cb: () => T): T { </s> Generate new seed on paste </s> add parsedElement.seed = randomSeed(); </s> remove seed: Math.floor(Math.random() * 2 ** 31), </s> add seed: randomSeed(),
https://github.com/excalidraw/excalidraw/commit/c077403eeca24283bfb33f3b924858d24ceb0f01
src/index.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> height: height, <mask> isSelected: false, <mask> strokeColor: strokeColor, <mask> backgroundColor: backgroundColor, <mask> seed: Math.floor(Math.random() * 2 ** 31), <mask> draw( <mask> rc: RoughCanvas, <mask> context: CanvasRenderingContext2D, <mask> sceneState: SceneState <mask> ) {} </s> Generate new seed on paste </s> add function randomSeed() { return Math.floor(Math.random() * 2 ** 31); } </s> add parsedElement.seed = randomSeed();
https://github.com/excalidraw/excalidraw/commit/c077403eeca24283bfb33f3b924858d24ceb0f01
src/index.tsx
keep keep keep add keep keep keep keep keep
<mask> clearSelection(); <mask> parsedElements.forEach(parsedElement => { <mask> parsedElement.x += 10; <mask> parsedElement.y += 10; <mask> generateDraw(parsedElement); <mask> elements.push(parsedElement); <mask> }); <mask> this.forceUpdate(); <mask> } </s> Generate new seed on paste </s> add function randomSeed() { return Math.floor(Math.random() * 2 ** 31); } </s> remove seed: Math.floor(Math.random() * 2 ** 31), </s> add seed: randomSeed(),
https://github.com/excalidraw/excalidraw/commit/c077403eeca24283bfb33f3b924858d24ceb0f01
src/index.tsx
keep replace replace replace keep replace replace keep keep keep keep
<mask> "@sentry/integrations": { <mask> "version": "5.19.2", <mask> "resolved": "https://registry.npmjs.org/@sentry/integrations/-/integrations-5.19.2.tgz", <mask> "integrity": "sha512-kHXJlJBRMKFDT6IebLNgTciJtSygxm4nLETmwVOmE555lTOUmbbmpNEpJokk1D8f/dCy9ai1N+h6CFyLsjCXNw==", <mask> "requires": { <mask> "@sentry/types": "5.19.2", <mask> "@sentry/utils": "5.19.2", <mask> "tslib": "^1.9.3" <mask> } <mask> }, <mask> "@sentry/minimal": { </s> Bump @sentry/integrations from 5.19.2 to 5.20.1 (#1968) Bumps [@sentry/integrations](https://github.com/getsentry/sentry-javascript) from 5.19.2 to 5.20.1. - [Release notes](https://github.com/getsentry/sentry-javascript/releases) - [Changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-javascript/compare/5.19.2...5.20.1) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> </s> remove "version": "5.19.2", "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-5.19.2.tgz", "integrity": "sha512-gEPkC0CJwvIWqcTcPSdIzqJkJa9N5vZzUZyBvdu1oiyJu7MfazpJEvj3whfJMysSfXJQxoJ+a1IPrA73VY23VA==", </s> add "version": "5.20.1", "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-5.20.1.tgz", "integrity": "sha512-dhK6IdO6g7Q2CoxCbB+q8gwUapDUH5VjraFg0UBzgkrtNhtHLylqmwx0sWQvXCcp14Q/3MuzEbb4euvoh8o8oA==", </s> remove "@sentry/types": "5.19.2", </s> add "@sentry/types": "5.20.1", </s> remove "@sentry/integrations": "5.19.2", </s> add "@sentry/integrations": "5.20.1", </s> remove "version": "5.19.2", "resolved": "https://registry.npmjs.org/@sentry/types/-/types-5.19.2.tgz", "integrity": "sha512-O6zkW8oM1qK5Uma9+B/UMlmlm9/gkw9MooqycWuEhIaKfDBj/yVbwb/UTiJmNkGc5VJQo0v1uXUZZQt6/Xq1GA==" </s> add "version": "5.20.1", "resolved": "https://registry.npmjs.org/@sentry/types/-/types-5.20.1.tgz", "integrity": "sha512-OU+i/lcjGpDJv0XkNpsKrI2r1VPp8qX0H6Knq8NuZrlZe3AbvO3jRJJK0pH14xFv8Xok5jbZZpKKoQLxYfxqsw=="
https://github.com/excalidraw/excalidraw/commit/c0ca6bae37723a6925a26f38ebd5c8470b87ff40
package-lock.json
keep keep keep keep replace replace replace keep keep replace replace replace keep keep
<mask> } <mask> } <mask> }, <mask> "@sentry/types": { <mask> "version": "5.19.2", <mask> "resolved": "https://registry.npmjs.org/@sentry/types/-/types-5.19.2.tgz", <mask> "integrity": "sha512-O6zkW8oM1qK5Uma9+B/UMlmlm9/gkw9MooqycWuEhIaKfDBj/yVbwb/UTiJmNkGc5VJQo0v1uXUZZQt6/Xq1GA==" <mask> }, <mask> "@sentry/utils": { <mask> "version": "5.19.2", <mask> "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-5.19.2.tgz", <mask> "integrity": "sha512-gEPkC0CJwvIWqcTcPSdIzqJkJa9N5vZzUZyBvdu1oiyJu7MfazpJEvj3whfJMysSfXJQxoJ+a1IPrA73VY23VA==", <mask> "requires": { <mask> "@sentry/types": "5.19.2", </s> Bump @sentry/integrations from 5.19.2 to 5.20.1 (#1968) Bumps [@sentry/integrations](https://github.com/getsentry/sentry-javascript) from 5.19.2 to 5.20.1. - [Release notes](https://github.com/getsentry/sentry-javascript/releases) - [Changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-javascript/compare/5.19.2...5.20.1) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> </s> remove "version": "5.19.2", "resolved": "https://registry.npmjs.org/@sentry/integrations/-/integrations-5.19.2.tgz", "integrity": "sha512-kHXJlJBRMKFDT6IebLNgTciJtSygxm4nLETmwVOmE555lTOUmbbmpNEpJokk1D8f/dCy9ai1N+h6CFyLsjCXNw==", </s> add "version": "5.20.1", "resolved": "https://registry.npmjs.org/@sentry/integrations/-/integrations-5.20.1.tgz", "integrity": "sha512-VpeZHYT8Fvw1J5478MqXXORf3Ftpt34YM4e+sTPuGrmf4Gro7lXdyownqiSaa7kwwNVQEV3zMlRDczVZzXQThw==", </s> remove "@sentry/types": "5.19.2", "@sentry/utils": "5.19.2", </s> add "@sentry/types": "5.20.1", "@sentry/utils": "5.20.1", </s> remove "@sentry/types": "5.19.2", </s> add "@sentry/types": "5.20.1", </s> remove "@sentry/integrations": "5.19.2", </s> add "@sentry/integrations": "5.20.1",
https://github.com/excalidraw/excalidraw/commit/c0ca6bae37723a6925a26f38ebd5c8470b87ff40
package-lock.json
keep keep keep keep replace keep keep keep keep keep
<mask> "version": "5.19.2", <mask> "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-5.19.2.tgz", <mask> "integrity": "sha512-gEPkC0CJwvIWqcTcPSdIzqJkJa9N5vZzUZyBvdu1oiyJu7MfazpJEvj3whfJMysSfXJQxoJ+a1IPrA73VY23VA==", <mask> "requires": { <mask> "@sentry/types": "5.19.2", <mask> "tslib": "^1.9.3" <mask> } <mask> }, <mask> "@svgr/babel-plugin-add-jsx-attribute": { <mask> "version": "4.2.0", </s> Bump @sentry/integrations from 5.19.2 to 5.20.1 (#1968) Bumps [@sentry/integrations](https://github.com/getsentry/sentry-javascript) from 5.19.2 to 5.20.1. - [Release notes](https://github.com/getsentry/sentry-javascript/releases) - [Changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-javascript/compare/5.19.2...5.20.1) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> </s> remove "version": "5.19.2", "resolved": "https://registry.npmjs.org/@sentry/integrations/-/integrations-5.19.2.tgz", "integrity": "sha512-kHXJlJBRMKFDT6IebLNgTciJtSygxm4nLETmwVOmE555lTOUmbbmpNEpJokk1D8f/dCy9ai1N+h6CFyLsjCXNw==", </s> add "version": "5.20.1", "resolved": "https://registry.npmjs.org/@sentry/integrations/-/integrations-5.20.1.tgz", "integrity": "sha512-VpeZHYT8Fvw1J5478MqXXORf3Ftpt34YM4e+sTPuGrmf4Gro7lXdyownqiSaa7kwwNVQEV3zMlRDczVZzXQThw==", </s> remove "version": "5.19.2", "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-5.19.2.tgz", "integrity": "sha512-gEPkC0CJwvIWqcTcPSdIzqJkJa9N5vZzUZyBvdu1oiyJu7MfazpJEvj3whfJMysSfXJQxoJ+a1IPrA73VY23VA==", </s> add "version": "5.20.1", "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-5.20.1.tgz", "integrity": "sha512-dhK6IdO6g7Q2CoxCbB+q8gwUapDUH5VjraFg0UBzgkrtNhtHLylqmwx0sWQvXCcp14Q/3MuzEbb4euvoh8o8oA==", </s> remove "@sentry/types": "5.19.2", "@sentry/utils": "5.19.2", </s> add "@sentry/types": "5.20.1", "@sentry/utils": "5.20.1", </s> remove "version": "5.19.2", "resolved": "https://registry.npmjs.org/@sentry/types/-/types-5.19.2.tgz", "integrity": "sha512-O6zkW8oM1qK5Uma9+B/UMlmlm9/gkw9MooqycWuEhIaKfDBj/yVbwb/UTiJmNkGc5VJQo0v1uXUZZQt6/Xq1GA==" </s> add "version": "5.20.1", "resolved": "https://registry.npmjs.org/@sentry/types/-/types-5.20.1.tgz", "integrity": "sha512-OU+i/lcjGpDJv0XkNpsKrI2r1VPp8qX0H6Knq8NuZrlZe3AbvO3jRJJK0pH14xFv8Xok5jbZZpKKoQLxYfxqsw==" </s> remove "@sentry/integrations": "5.19.2", </s> add "@sentry/integrations": "5.20.1",
https://github.com/excalidraw/excalidraw/commit/c0ca6bae37723a6925a26f38ebd5c8470b87ff40
package-lock.json
keep keep keep keep replace keep keep keep keep keep
<mask> ] <mask> }, <mask> "dependencies": { <mask> "@sentry/browser": "5.20.1", <mask> "@sentry/integrations": "5.19.2", <mask> "@testing-library/jest-dom": "5.11.1", <mask> "@testing-library/react": "10.4.7", <mask> "@types/jest": "26.0.7", <mask> "@types/nanoid": "2.1.0", <mask> "@types/react": "16.9.43", </s> Bump @sentry/integrations from 5.19.2 to 5.20.1 (#1968) Bumps [@sentry/integrations](https://github.com/getsentry/sentry-javascript) from 5.19.2 to 5.20.1. - [Release notes](https://github.com/getsentry/sentry-javascript/releases) - [Changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-javascript/compare/5.19.2...5.20.1) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> </s> remove "version": "5.19.2", "resolved": "https://registry.npmjs.org/@sentry/integrations/-/integrations-5.19.2.tgz", "integrity": "sha512-kHXJlJBRMKFDT6IebLNgTciJtSygxm4nLETmwVOmE555lTOUmbbmpNEpJokk1D8f/dCy9ai1N+h6CFyLsjCXNw==", </s> add "version": "5.20.1", "resolved": "https://registry.npmjs.org/@sentry/integrations/-/integrations-5.20.1.tgz", "integrity": "sha512-VpeZHYT8Fvw1J5478MqXXORf3Ftpt34YM4e+sTPuGrmf4Gro7lXdyownqiSaa7kwwNVQEV3zMlRDczVZzXQThw==", </s> remove "@sentry/types": "5.19.2", "@sentry/utils": "5.19.2", </s> add "@sentry/types": "5.20.1", "@sentry/utils": "5.20.1", </s> remove "@sentry/types": "5.19.2", </s> add "@sentry/types": "5.20.1", </s> remove "version": "5.19.2", "resolved": "https://registry.npmjs.org/@sentry/types/-/types-5.19.2.tgz", "integrity": "sha512-O6zkW8oM1qK5Uma9+B/UMlmlm9/gkw9MooqycWuEhIaKfDBj/yVbwb/UTiJmNkGc5VJQo0v1uXUZZQt6/Xq1GA==" </s> add "version": "5.20.1", "resolved": "https://registry.npmjs.org/@sentry/types/-/types-5.20.1.tgz", "integrity": "sha512-OU+i/lcjGpDJv0XkNpsKrI2r1VPp8qX0H6Knq8NuZrlZe3AbvO3jRJJK0pH14xFv8Xok5jbZZpKKoQLxYfxqsw==" </s> remove "version": "5.19.2", "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-5.19.2.tgz", "integrity": "sha512-gEPkC0CJwvIWqcTcPSdIzqJkJa9N5vZzUZyBvdu1oiyJu7MfazpJEvj3whfJMysSfXJQxoJ+a1IPrA73VY23VA==", </s> add "version": "5.20.1", "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-5.20.1.tgz", "integrity": "sha512-dhK6IdO6g7Q2CoxCbB+q8gwUapDUH5VjraFg0UBzgkrtNhtHLylqmwx0sWQvXCcp14Q/3MuzEbb4euvoh8o8oA==",
https://github.com/excalidraw/excalidraw/commit/c0ca6bae37723a6925a26f38ebd5c8470b87ff40
package.json
keep keep keep keep replace keep keep keep keep keep
<mask> ); <mask> <mask> if ( <mask> this.state.editingLinearElement && <mask> this.state.editingLinearElement.draggingElementPointIndex === null <mask> ) { <mask> const editingLinearElement = LinearElementEditor.handlePointerMove( <mask> event, <mask> scenePointerX, <mask> scenePointerY, </s> simplify by replacing draggingElementPointIndex with isDragging (#1982) * simplify by replacing draggingElementPointIndex with isDragging * add tsdoc </s> remove const clickedPointIndex = draggingElementPointIndex ?? LinearElementEditor.getPointIndexUnderCursor( element, appState.zoom, scenePointerX, scenePointerY, ); draggingElementPointIndex = draggingElementPointIndex ?? clickedPointIndex; if (draggingElementPointIndex > -1) { if ( editingLinearElement.draggingElementPointIndex !== draggingElementPointIndex || editingLinearElement.activePointIndex !== clickedPointIndex ) { </s> add if (activePointIndex != null && activePointIndex > -1) { if (isDragging === false) { </s> remove draggingElementPointIndex !== null && (draggingElementPointIndex === 0 || draggingElementPointIndex === element.points.length - 1) && </s> add isDragging && (activePointIndex === 0 || activePointIndex === element.points.length - 1) && </s> remove let { draggingElementPointIndex, elementId } = editingLinearElement; </s> add const { activePointIndex, elementId, isDragging } = editingLinearElement; </s> remove draggingElementPointIndex, draggingElementPointIndex === 0 </s> add activePointIndex, activePointIndex === 0 </s> remove const { elementId, draggingElementPointIndex } = editingLinearElement; </s> add const { elementId, activePointIndex, isDragging } = editingLinearElement; </s> remove if (draggingElementPointIndex !== null) { </s> add if (isDragging) {
https://github.com/excalidraw/excalidraw/commit/c171fb4c7f1e4c4e39b549af07de9d3c87beafc5
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> public elementId: ExcalidrawElement["id"] & { <mask> _brand: "excalidrawLinearElementId"; <mask> }; <mask> public activePointIndex: number | null; <mask> public draggingElementPointIndex: number | null; <mask> public lastUncommittedPoint: Point | null; <mask> <mask> constructor(element: NonDeleted<ExcalidrawLinearElement>, scene: Scene) { <mask> this.elementId = element.id as string & { <mask> _brand: "excalidrawLinearElementId"; </s> simplify by replacing draggingElementPointIndex with isDragging (#1982) * simplify by replacing draggingElementPointIndex with isDragging * add tsdoc </s> remove this.draggingElementPointIndex = null; </s> add this.isDragging = false; </s> remove draggingElementPointIndex: null, </s> add isDragging: false, </s> remove if (draggingElementPointIndex !== null) { </s> add if (isDragging) { </s> remove draggingElementPointIndex, activePointIndex: clickedPointIndex, </s> add isDragging: true, </s> remove const clickedPointIndex = draggingElementPointIndex ?? LinearElementEditor.getPointIndexUnderCursor( element, appState.zoom, scenePointerX, scenePointerY, ); draggingElementPointIndex = draggingElementPointIndex ?? clickedPointIndex; if (draggingElementPointIndex > -1) { if ( editingLinearElement.draggingElementPointIndex !== draggingElementPointIndex || editingLinearElement.activePointIndex !== clickedPointIndex ) { </s> add if (activePointIndex != null && activePointIndex > -1) { if (isDragging === false) { </s> remove let { draggingElementPointIndex, elementId } = editingLinearElement; </s> add const { activePointIndex, elementId, isDragging } = editingLinearElement;
https://github.com/excalidraw/excalidraw/commit/c171fb4c7f1e4c4e39b549af07de9d3c87beafc5
src/element/linearElementEditor.ts
keep keep keep keep replace keep keep keep keep keep
<mask> LinearElementEditor.normalizePoints(element); <mask> <mask> this.activePointIndex = null; <mask> this.lastUncommittedPoint = null; <mask> this.draggingElementPointIndex = null; <mask> } <mask> <mask> // --------------------------------------------------------------------------- <mask> // static methods <mask> // --------------------------------------------------------------------------- </s> simplify by replacing draggingElementPointIndex with isDragging (#1982) * simplify by replacing draggingElementPointIndex with isDragging * add tsdoc </s> remove public draggingElementPointIndex: number | null; </s> add /** whether you're dragging a point */ public isDragging: boolean; </s> remove const { elementId, draggingElementPointIndex } = editingLinearElement; </s> add const { elementId, activePointIndex, isDragging } = editingLinearElement; </s> remove let { draggingElementPointIndex, elementId } = editingLinearElement; </s> add const { activePointIndex, elementId, isDragging } = editingLinearElement; </s> remove const targetPoint = element.points[clickedPointIndex]; LinearElementEditor.movePoint(element, clickedPointIndex, [ </s> add const targetPoint = element.points[activePointIndex]; LinearElementEditor.movePoint(element, activePointIndex, [ </s> remove draggingElementPointIndex, activePointIndex: clickedPointIndex, </s> add isDragging: true, </s> remove const clickedPointIndex = draggingElementPointIndex ?? LinearElementEditor.getPointIndexUnderCursor( element, appState.zoom, scenePointerX, scenePointerY, ); draggingElementPointIndex = draggingElementPointIndex ?? clickedPointIndex; if (draggingElementPointIndex > -1) { if ( editingLinearElement.draggingElementPointIndex !== draggingElementPointIndex || editingLinearElement.activePointIndex !== clickedPointIndex ) { </s> add if (activePointIndex != null && activePointIndex > -1) { if (isDragging === false) {
https://github.com/excalidraw/excalidraw/commit/c171fb4c7f1e4c4e39b549af07de9d3c87beafc5
src/element/linearElementEditor.ts
keep keep keep keep replace keep keep keep keep keep
<mask> if (!appState.editingLinearElement) { <mask> return false; <mask> } <mask> const { editingLinearElement } = appState; <mask> let { draggingElementPointIndex, elementId } = editingLinearElement; <mask> <mask> const element = LinearElementEditor.getElement(elementId); <mask> if (!element) { <mask> return false; <mask> } </s> simplify by replacing draggingElementPointIndex with isDragging (#1982) * simplify by replacing draggingElementPointIndex with isDragging * add tsdoc </s> remove const { elementId, draggingElementPointIndex } = editingLinearElement; </s> add const { elementId, activePointIndex, isDragging } = editingLinearElement; </s> remove const clickedPointIndex = draggingElementPointIndex ?? LinearElementEditor.getPointIndexUnderCursor( element, appState.zoom, scenePointerX, scenePointerY, ); draggingElementPointIndex = draggingElementPointIndex ?? clickedPointIndex; if (draggingElementPointIndex > -1) { if ( editingLinearElement.draggingElementPointIndex !== draggingElementPointIndex || editingLinearElement.activePointIndex !== clickedPointIndex ) { </s> add if (activePointIndex != null && activePointIndex > -1) { if (isDragging === false) { </s> remove draggingElementPointIndex: null, </s> add isDragging: false, </s> remove if (draggingElementPointIndex !== null) { </s> add if (isDragging) { </s> remove this.draggingElementPointIndex = null; </s> add this.isDragging = false; </s> remove draggingElementPointIndex, activePointIndex: clickedPointIndex, </s> add isDragging: true,
https://github.com/excalidraw/excalidraw/commit/c171fb4c7f1e4c4e39b549af07de9d3c87beafc5
src/element/linearElementEditor.ts
keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep replace replace
<mask> return false; <mask> } <mask> <mask> const clickedPointIndex = <mask> draggingElementPointIndex ?? <mask> LinearElementEditor.getPointIndexUnderCursor( <mask> element, <mask> appState.zoom, <mask> scenePointerX, <mask> scenePointerY, <mask> ); <mask> <mask> draggingElementPointIndex = draggingElementPointIndex ?? clickedPointIndex; <mask> if (draggingElementPointIndex > -1) { <mask> if ( <mask> editingLinearElement.draggingElementPointIndex !== <mask> draggingElementPointIndex || <mask> editingLinearElement.activePointIndex !== clickedPointIndex <mask> ) { <mask> setState({ <mask> editingLinearElement: { <mask> ...editingLinearElement, <mask> draggingElementPointIndex, <mask> activePointIndex: clickedPointIndex, </s> simplify by replacing draggingElementPointIndex with isDragging (#1982) * simplify by replacing draggingElementPointIndex with isDragging * add tsdoc </s> remove draggingElementPointIndex !== null && (draggingElementPointIndex === 0 || draggingElementPointIndex === element.points.length - 1) && </s> add isDragging && (activePointIndex === 0 || activePointIndex === element.points.length - 1) && </s> remove this.state.editingLinearElement.draggingElementPointIndex === null </s> add !this.state.editingLinearElement.isDragging </s> remove draggingElementPointIndex, draggingElementPointIndex === 0 </s> add activePointIndex, activePointIndex === 0 </s> remove const { elementId, draggingElementPointIndex } = editingLinearElement; </s> add const { elementId, activePointIndex, isDragging } = editingLinearElement; </s> remove let { draggingElementPointIndex, elementId } = editingLinearElement; </s> add const { activePointIndex, elementId, isDragging } = editingLinearElement;
https://github.com/excalidraw/excalidraw/commit/c171fb4c7f1e4c4e39b549af07de9d3c87beafc5
src/element/linearElementEditor.ts
keep keep keep keep replace replace keep keep keep keep keep
<mask> 0, <mask> 0, <mask> -element.angle, <mask> ); <mask> const targetPoint = element.points[clickedPointIndex]; <mask> LinearElementEditor.movePoint(element, clickedPointIndex, [ <mask> targetPoint[0] + deltaX, <mask> targetPoint[1] + deltaY, <mask> ]); <mask> return true; <mask> } </s> simplify by replacing draggingElementPointIndex with isDragging (#1982) * simplify by replacing draggingElementPointIndex with isDragging * add tsdoc </s> remove draggingElementPointIndex, activePointIndex: clickedPointIndex, </s> add isDragging: true, </s> remove let { draggingElementPointIndex, elementId } = editingLinearElement; </s> add const { activePointIndex, elementId, isDragging } = editingLinearElement; </s> remove const clickedPointIndex = draggingElementPointIndex ?? LinearElementEditor.getPointIndexUnderCursor( element, appState.zoom, scenePointerX, scenePointerY, ); draggingElementPointIndex = draggingElementPointIndex ?? clickedPointIndex; if (draggingElementPointIndex > -1) { if ( editingLinearElement.draggingElementPointIndex !== draggingElementPointIndex || editingLinearElement.activePointIndex !== clickedPointIndex ) { </s> add if (activePointIndex != null && activePointIndex > -1) { if (isDragging === false) { </s> remove const { elementId, draggingElementPointIndex } = editingLinearElement; </s> add const { elementId, activePointIndex, isDragging } = editingLinearElement; </s> remove if (draggingElementPointIndex !== null) { </s> add if (isDragging) { </s> remove draggingElementPointIndex: null, </s> add isDragging: false,
https://github.com/excalidraw/excalidraw/commit/c171fb4c7f1e4c4e39b549af07de9d3c87beafc5
src/element/linearElementEditor.ts
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> static handlePointerUp( <mask> editingLinearElement: LinearElementEditor, <mask> ): LinearElementEditor { <mask> const { elementId, draggingElementPointIndex } = editingLinearElement; <mask> const element = LinearElementEditor.getElement(elementId); <mask> if (!element) { <mask> return editingLinearElement; <mask> } <mask> </s> simplify by replacing draggingElementPointIndex with isDragging (#1982) * simplify by replacing draggingElementPointIndex with isDragging * add tsdoc </s> remove let { draggingElementPointIndex, elementId } = editingLinearElement; </s> add const { activePointIndex, elementId, isDragging } = editingLinearElement; </s> remove const clickedPointIndex = draggingElementPointIndex ?? LinearElementEditor.getPointIndexUnderCursor( element, appState.zoom, scenePointerX, scenePointerY, ); draggingElementPointIndex = draggingElementPointIndex ?? clickedPointIndex; if (draggingElementPointIndex > -1) { if ( editingLinearElement.draggingElementPointIndex !== draggingElementPointIndex || editingLinearElement.activePointIndex !== clickedPointIndex ) { </s> add if (activePointIndex != null && activePointIndex > -1) { if (isDragging === false) { </s> remove draggingElementPointIndex: null, </s> add isDragging: false, </s> remove draggingElementPointIndex, activePointIndex: clickedPointIndex, </s> add isDragging: true, </s> remove draggingElementPointIndex !== null && (draggingElementPointIndex === 0 || draggingElementPointIndex === element.points.length - 1) && </s> add isDragging && (activePointIndex === 0 || activePointIndex === element.points.length - 1) && </s> remove if (draggingElementPointIndex !== null) { </s> add if (isDragging) {
https://github.com/excalidraw/excalidraw/commit/c171fb4c7f1e4c4e39b549af07de9d3c87beafc5
src/element/linearElementEditor.ts
keep keep keep keep replace replace replace keep keep keep keep replace replace keep keep keep
<mask> return editingLinearElement; <mask> } <mask> <mask> if ( <mask> draggingElementPointIndex !== null && <mask> (draggingElementPointIndex === 0 || <mask> draggingElementPointIndex === element.points.length - 1) && <mask> isPathALoop(element.points) <mask> ) { <mask> LinearElementEditor.movePoint( <mask> element, <mask> draggingElementPointIndex, <mask> draggingElementPointIndex === 0 <mask> ? element.points[element.points.length - 1] <mask> : element.points[0], <mask> ); </s> simplify by replacing draggingElementPointIndex with isDragging (#1982) * simplify by replacing draggingElementPointIndex with isDragging * add tsdoc </s> remove if (draggingElementPointIndex !== null) { </s> add if (isDragging) { </s> remove const clickedPointIndex = draggingElementPointIndex ?? LinearElementEditor.getPointIndexUnderCursor( element, appState.zoom, scenePointerX, scenePointerY, ); draggingElementPointIndex = draggingElementPointIndex ?? clickedPointIndex; if (draggingElementPointIndex > -1) { if ( editingLinearElement.draggingElementPointIndex !== draggingElementPointIndex || editingLinearElement.activePointIndex !== clickedPointIndex ) { </s> add if (activePointIndex != null && activePointIndex > -1) { if (isDragging === false) { </s> remove this.state.editingLinearElement.draggingElementPointIndex === null </s> add !this.state.editingLinearElement.isDragging </s> remove const { elementId, draggingElementPointIndex } = editingLinearElement; </s> add const { elementId, activePointIndex, isDragging } = editingLinearElement; </s> remove draggingElementPointIndex: null, </s> add isDragging: false,
https://github.com/excalidraw/excalidraw/commit/c171fb4c7f1e4c4e39b549af07de9d3c87beafc5
src/element/linearElementEditor.ts
keep keep replace keep keep keep keep keep keep keep keep replace keep keep keep keep
<mask> ); <mask> } <mask> if (draggingElementPointIndex !== null) { <mask> return { <mask> ...editingLinearElement, <mask> draggingElementPointIndex: null, <mask> }; <mask> } <mask> if (draggingElementPointIndex !== null) { <mask> return { <mask> ...editingLinearElement, <mask> draggingElementPointIndex: null, <mask> }; <mask> } <mask> return editingLinearElement; <mask> } </s> simplify by replacing draggingElementPointIndex with isDragging (#1982) * simplify by replacing draggingElementPointIndex with isDragging * add tsdoc </s> remove let { draggingElementPointIndex, elementId } = editingLinearElement; </s> add const { activePointIndex, elementId, isDragging } = editingLinearElement; </s> remove draggingElementPointIndex, draggingElementPointIndex === 0 </s> add activePointIndex, activePointIndex === 0 </s> remove const { elementId, draggingElementPointIndex } = editingLinearElement; </s> add const { elementId, activePointIndex, isDragging } = editingLinearElement; </s> remove const clickedPointIndex = draggingElementPointIndex ?? LinearElementEditor.getPointIndexUnderCursor( element, appState.zoom, scenePointerX, scenePointerY, ); draggingElementPointIndex = draggingElementPointIndex ?? clickedPointIndex; if (draggingElementPointIndex > -1) { if ( editingLinearElement.draggingElementPointIndex !== draggingElementPointIndex || editingLinearElement.activePointIndex !== clickedPointIndex ) { </s> add if (activePointIndex != null && activePointIndex > -1) { if (isDragging === false) { </s> remove draggingElementPointIndex !== null && (draggingElementPointIndex === 0 || draggingElementPointIndex === element.points.length - 1) && </s> add isDragging && (activePointIndex === 0 || activePointIndex === element.points.length - 1) &&
https://github.com/excalidraw/excalidraw/commit/c171fb4c7f1e4c4e39b549af07de9d3c87beafc5
src/element/linearElementEditor.ts
keep keep keep add keep keep keep keep keep keep
<mask> import { AppProps, AppState, Gesture, GestureEvent, SceneData } from "../types"; <mask> import { <mask> debounce, <mask> distance, <mask> isInputLike, <mask> isToolIcon, <mask> isWritableElement, <mask> resetCursor, <mask> ResolvablePromise, <mask> resolvablePromise, </s> feat: Add scroll listener to the nearest scrollable container and allow consumer to disable it (#3408) * fix: Add scroll listener to the nearest scrollable container * fix * use loop instead of recursion * fix * return document * calculate nearest scrollable container in settimeout to unblock main thread * Add prop detectNearestScroll and clear timeout on unmount * disable scroll listener on excal app * update prop name to detectScroll * update docs * remove settimeout * tweak docs Co-authored-by: David Luzar <[email protected]> * tweak changelog Co-authored-by: David Luzar <[email protected]> * lint Co-authored-by: David Luzar <[email protected]> </s> add detectScroll?: boolean; </s> add private nearestScrollableContainer: HTMLElement | Document | undefined; </s> remove document.addEventListener(EVENT.SCROLL, this.onScroll); </s> add if (this.props.detectScroll) { this.nearestScrollableContainer = getNearestScrollableContainer( this.excalidrawContainerRef.current!, ); this.nearestScrollableContainer.addEventListener( EVENT.SCROLL, this.onScroll, ); } </s> add this.nearestScrollableContainer?.removeEventListener( EVENT.SCROLL, this.onScroll, ); </s> remove Excalidraw.defaultProps = { lanCode: defaultLang.code, UIOptions: DEFAULT_UI_OPTIONS, }; </s> add </s> add detectScroll = true,
https://github.com/excalidraw/excalidraw/commit/c19c8ecd27589b50ab1de3f09d6c466787a07411
src/components/App.tsx
keep keep add keep keep keep keep
<mask> <mask> private scene: Scene; <mask> private resizeObserver: ResizeObserver | undefined; <mask> constructor(props: AppProps) { <mask> super(props); <mask> const defaultAppState = getDefaultAppState(); <mask> const { </s> feat: Add scroll listener to the nearest scrollable container and allow consumer to disable it (#3408) * fix: Add scroll listener to the nearest scrollable container * fix * use loop instead of recursion * fix * return document * calculate nearest scrollable container in settimeout to unblock main thread * Add prop detectNearestScroll and clear timeout on unmount * disable scroll listener on excal app * update prop name to detectScroll * update docs * remove settimeout * tweak docs Co-authored-by: David Luzar <[email protected]> * tweak changelog Co-authored-by: David Luzar <[email protected]> * lint Co-authored-by: David Luzar <[email protected]> </s> add this.nearestScrollableContainer?.removeEventListener( EVENT.SCROLL, this.onScroll, ); </s> add detectScroll = true, </s> remove Excalidraw.defaultProps = { lanCode: defaultLang.code, UIOptions: DEFAULT_UI_OPTIONS, }; </s> add </s> add detectScroll?: boolean; </s> add getNearestScrollableContainer, </s> remove document.addEventListener(EVENT.SCROLL, this.onScroll); </s> add if (this.props.detectScroll) { this.nearestScrollableContainer = getNearestScrollableContainer( this.excalidrawContainerRef.current!, ); this.nearestScrollableContainer.addEventListener( EVENT.SCROLL, this.onScroll, ); }
https://github.com/excalidraw/excalidraw/commit/c19c8ecd27589b50ab1de3f09d6c466787a07411
src/components/App.tsx
keep keep keep add keep keep keep keep keep
<mask> private removeEventListeners() { <mask> document.removeEventListener(EVENT.COPY, this.onCopy); <mask> document.removeEventListener(EVENT.PASTE, this.pasteFromClipboard); <mask> document.removeEventListener(EVENT.CUT, this.onCut); <mask> <mask> document.removeEventListener(EVENT.KEYDOWN, this.onKeyDown, false); <mask> document.removeEventListener( <mask> EVENT.MOUSE_MOVE, <mask> this.updateCurrentCursorPosition, </s> feat: Add scroll listener to the nearest scrollable container and allow consumer to disable it (#3408) * fix: Add scroll listener to the nearest scrollable container * fix * use loop instead of recursion * fix * return document * calculate nearest scrollable container in settimeout to unblock main thread * Add prop detectNearestScroll and clear timeout on unmount * disable scroll listener on excal app * update prop name to detectScroll * update docs * remove settimeout * tweak docs Co-authored-by: David Luzar <[email protected]> * tweak changelog Co-authored-by: David Luzar <[email protected]> * lint Co-authored-by: David Luzar <[email protected]> </s> remove document.addEventListener(EVENT.SCROLL, this.onScroll); </s> add if (this.props.detectScroll) { this.nearestScrollableContainer = getNearestScrollableContainer( this.excalidrawContainerRef.current!, ); this.nearestScrollableContainer.addEventListener( EVENT.SCROLL, this.onScroll, ); } </s> add private nearestScrollableContainer: HTMLElement | Document | undefined; </s> add getNearestScrollableContainer, </s> add detectScroll?: boolean; </s> remove Excalidraw.defaultProps = { lanCode: defaultLang.code, UIOptions: DEFAULT_UI_OPTIONS, }; </s> add </s> add detectScroll={detectScroll}
https://github.com/excalidraw/excalidraw/commit/c19c8ecd27589b50ab1de3f09d6c466787a07411
src/components/App.tsx
keep keep keep keep replace replace keep keep keep keep keep
<mask> } <mask> <mask> document.addEventListener(EVENT.PASTE, this.pasteFromClipboard); <mask> document.addEventListener(EVENT.CUT, this.onCut); <mask> document.addEventListener(EVENT.SCROLL, this.onScroll); <mask> <mask> window.addEventListener(EVENT.RESIZE, this.onResize, false); <mask> window.addEventListener(EVENT.UNLOAD, this.onUnload, false); <mask> window.addEventListener(EVENT.BLUR, this.onBlur, false); <mask> window.addEventListener(EVENT.DRAG_OVER, this.disableEvent, false); <mask> window.addEventListener(EVENT.DROP, this.disableEvent, false); </s> feat: Add scroll listener to the nearest scrollable container and allow consumer to disable it (#3408) * fix: Add scroll listener to the nearest scrollable container * fix * use loop instead of recursion * fix * return document * calculate nearest scrollable container in settimeout to unblock main thread * Add prop detectNearestScroll and clear timeout on unmount * disable scroll listener on excal app * update prop name to detectScroll * update docs * remove settimeout * tweak docs Co-authored-by: David Luzar <[email protected]> * tweak changelog Co-authored-by: David Luzar <[email protected]> * lint Co-authored-by: David Luzar <[email protected]> </s> add this.nearestScrollableContainer?.removeEventListener( EVENT.SCROLL, this.onScroll, ); </s> add detectScroll = true, </s> add detectScroll?: boolean; </s> add getNearestScrollableContainer, </s> remove Excalidraw.defaultProps = { lanCode: defaultLang.code, UIOptions: DEFAULT_UI_OPTIONS, }; </s> add </s> add detectScroll={detectScroll}
https://github.com/excalidraw/excalidraw/commit/c19c8ecd27589b50ab1de3f09d6c466787a07411
src/components/App.tsx
keep keep keep add keep keep keep keep
<mask> onExportToBackend={onExportToBackend} <mask> renderFooter={renderFooter} <mask> langCode={langCode} <mask> renderCustomStats={renderCustomStats} <mask> /> <mask> {excalidrawAPI && <CollabWrapper excalidrawAPI={excalidrawAPI} />} <mask> {errorMessage && ( <mask> <ErrorDialog </s> feat: Add scroll listener to the nearest scrollable container and allow consumer to disable it (#3408) * fix: Add scroll listener to the nearest scrollable container * fix * use loop instead of recursion * fix * return document * calculate nearest scrollable container in settimeout to unblock main thread * Add prop detectNearestScroll and clear timeout on unmount * disable scroll listener on excal app * update prop name to detectScroll * update docs * remove settimeout * tweak docs Co-authored-by: David Luzar <[email protected]> * tweak changelog Co-authored-by: David Luzar <[email protected]> * lint Co-authored-by: David Luzar <[email protected]> </s> add detectScroll={detectScroll} </s> add detectScroll?: boolean; </s> remove Excalidraw.defaultProps = { lanCode: defaultLang.code, UIOptions: DEFAULT_UI_OPTIONS, }; </s> add </s> add detectScroll = true, </s> remove document.addEventListener(EVENT.SCROLL, this.onScroll); </s> add if (this.props.detectScroll) { this.nearestScrollableContainer = getNearestScrollableContainer( this.excalidrawContainerRef.current!, ); this.nearestScrollableContainer.addEventListener( EVENT.SCROLL, this.onScroll, ); } </s> add this.nearestScrollableContainer?.removeEventListener( EVENT.SCROLL, this.onScroll, );
https://github.com/excalidraw/excalidraw/commit/c19c8ecd27589b50ab1de3f09d6c466787a07411
src/excalidraw-app/index.tsx
keep add keep keep keep keep
<mask> renderCustomStats, <mask> onPaste, <mask> } = props; <mask> <mask> const canvasActions = props.UIOptions?.canvasActions; <mask> </s> feat: Add scroll listener to the nearest scrollable container and allow consumer to disable it (#3408) * fix: Add scroll listener to the nearest scrollable container * fix * use loop instead of recursion * fix * return document * calculate nearest scrollable container in settimeout to unblock main thread * Add prop detectNearestScroll and clear timeout on unmount * disable scroll listener on excal app * update prop name to detectScroll * update docs * remove settimeout * tweak docs Co-authored-by: David Luzar <[email protected]> * tweak changelog Co-authored-by: David Luzar <[email protected]> * lint Co-authored-by: David Luzar <[email protected]> </s> add private nearestScrollableContainer: HTMLElement | Document | undefined; </s> remove Excalidraw.defaultProps = { lanCode: defaultLang.code, UIOptions: DEFAULT_UI_OPTIONS, }; </s> add </s> add detectScroll?: boolean; </s> add detectScroll={detectScroll} </s> remove document.addEventListener(EVENT.SCROLL, this.onScroll); </s> add if (this.props.detectScroll) { this.nearestScrollableContainer = getNearestScrollableContainer( this.excalidrawContainerRef.current!, ); this.nearestScrollableContainer.addEventListener( EVENT.SCROLL, this.onScroll, ); } </s> add getNearestScrollableContainer,
https://github.com/excalidraw/excalidraw/commit/c19c8ecd27589b50ab1de3f09d6c466787a07411
src/packages/excalidraw/index.tsx
keep keep keep add keep keep keep keep keep keep
<mask> name={name} <mask> renderCustomStats={renderCustomStats} <mask> UIOptions={UIOptions} <mask> onPaste={onPaste} <mask> /> <mask> </InitializeApp> <mask> ); <mask> }; <mask> <mask> type PublicExcalidrawProps = Omit<ExcalidrawProps, "forwardedRef">; </s> feat: Add scroll listener to the nearest scrollable container and allow consumer to disable it (#3408) * fix: Add scroll listener to the nearest scrollable container * fix * use loop instead of recursion * fix * return document * calculate nearest scrollable container in settimeout to unblock main thread * Add prop detectNearestScroll and clear timeout on unmount * disable scroll listener on excal app * update prop name to detectScroll * update docs * remove settimeout * tweak docs Co-authored-by: David Luzar <[email protected]> * tweak changelog Co-authored-by: David Luzar <[email protected]> * lint Co-authored-by: David Luzar <[email protected]> </s> remove Excalidraw.defaultProps = { lanCode: defaultLang.code, UIOptions: DEFAULT_UI_OPTIONS, }; </s> add </s> add detectScroll={false} </s> add detectScroll?: boolean; </s> add detectScroll = true, </s> remove document.addEventListener(EVENT.SCROLL, this.onScroll); </s> add if (this.props.detectScroll) { this.nearestScrollableContainer = getNearestScrollableContainer( this.excalidrawContainerRef.current!, ); this.nearestScrollableContainer.addEventListener( EVENT.SCROLL, this.onScroll, ); } </s> add private nearestScrollableContainer: HTMLElement | Document | undefined;
https://github.com/excalidraw/excalidraw/commit/c19c8ecd27589b50ab1de3f09d6c466787a07411
src/packages/excalidraw/index.tsx
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
<mask> prevKeys.every((key) => prev[key] === next[key]) <mask> ); <mask> }; <mask> <mask> Excalidraw.defaultProps = { <mask> lanCode: defaultLang.code, <mask> UIOptions: DEFAULT_UI_OPTIONS, <mask> }; <mask> <mask> const forwardedRefComp = forwardRef< <mask> ExcalidrawAPIRefValue, <mask> PublicExcalidrawProps <mask> >((props, ref) => <Excalidraw {...props} excalidrawRef={ref} />); <mask> export default React.memo(forwardedRefComp, areEqual); </s> feat: Add scroll listener to the nearest scrollable container and allow consumer to disable it (#3408) * fix: Add scroll listener to the nearest scrollable container * fix * use loop instead of recursion * fix * return document * calculate nearest scrollable container in settimeout to unblock main thread * Add prop detectNearestScroll and clear timeout on unmount * disable scroll listener on excal app * update prop name to detectScroll * update docs * remove settimeout * tweak docs Co-authored-by: David Luzar <[email protected]> * tweak changelog Co-authored-by: David Luzar <[email protected]> * lint Co-authored-by: David Luzar <[email protected]> </s> add detectScroll={detectScroll} </s> add detectScroll?: boolean; </s> add detectScroll = true, </s> add private nearestScrollableContainer: HTMLElement | Document | undefined; </s> remove document.addEventListener(EVENT.SCROLL, this.onScroll); </s> add if (this.props.detectScroll) { this.nearestScrollableContainer = getNearestScrollableContainer( this.excalidrawContainerRef.current!, ); this.nearestScrollableContainer.addEventListener( EVENT.SCROLL, this.onScroll, ); } </s> add this.nearestScrollableContainer?.removeEventListener( EVENT.SCROLL, this.onScroll, );
https://github.com/excalidraw/excalidraw/commit/c19c8ecd27589b50ab1de3f09d6c466787a07411
src/packages/excalidraw/index.tsx
keep add keep keep keep keep keep
<mask> ) => JSX.Element; <mask> UIOptions?: UIOptions; <mask> } <mask> <mask> export type SceneData = { <mask> elements?: ImportedDataState["elements"]; <mask> appState?: ImportedDataState["appState"]; </s> feat: Add scroll listener to the nearest scrollable container and allow consumer to disable it (#3408) * fix: Add scroll listener to the nearest scrollable container * fix * use loop instead of recursion * fix * return document * calculate nearest scrollable container in settimeout to unblock main thread * Add prop detectNearestScroll and clear timeout on unmount * disable scroll listener on excal app * update prop name to detectScroll * update docs * remove settimeout * tweak docs Co-authored-by: David Luzar <[email protected]> * tweak changelog Co-authored-by: David Luzar <[email protected]> * lint Co-authored-by: David Luzar <[email protected]> </s> remove Excalidraw.defaultProps = { lanCode: defaultLang.code, UIOptions: DEFAULT_UI_OPTIONS, }; </s> add </s> add getNearestScrollableContainer, </s> add detectScroll={detectScroll} </s> add detectScroll = true, </s> add private nearestScrollableContainer: HTMLElement | Document | undefined; </s> remove document.addEventListener(EVENT.SCROLL, this.onScroll); </s> add if (this.props.detectScroll) { this.nearestScrollableContainer = getNearestScrollableContainer( this.excalidrawContainerRef.current!, ); this.nearestScrollableContainer.addEventListener( EVENT.SCROLL, this.onScroll, ); }
https://github.com/excalidraw/excalidraw/commit/c19c8ecd27589b50ab1de3f09d6c466787a07411
src/types.ts
keep keep keep add keep keep keep keep keep keep
<mask> }, <mask> "alerts": { <mask> "clearReset": "", <mask> "couldNotCreateShareableLink": "", <mask> "importBackendFailed": "", <mask> "cannotExportEmptyCanvas": "", <mask> "couldNotCopyToClipboard": "", <mask> "decryptFailed": "", <mask> "uploadedSecurly": "" <mask> }, </s> New Crowdin translations (mostly Arabic updates) (#1181) </s> add }, "errorDialog": { "title": "" </s> add }, "errorDialog": { "title": "" </s> add "couldNotLoadInvalidFile": "", </s> add }, "errorDialog": { "title": ""
https://github.com/excalidraw/excalidraw/commit/c240fff0c5fd11e788658cdc4a947f49d10867db
src/locales/hi-IN.json
keep keep add keep keep
<mask> "desc_persistenceWarning": "", <mask> "desc_shareLink": "", <mask> "desc_exitSession": "" <mask> } <mask> } </s> New Crowdin translations (mostly Arabic updates) (#1181) </s> add }, "errorDialog": { "title": "" </s> add }, "errorDialog": { "title": "" </s> add "couldNotLoadInvalidFile": "", </s> add "couldNotLoadInvalidFile": "",
https://github.com/excalidraw/excalidraw/commit/c240fff0c5fd11e788658cdc4a947f49d10867db
src/locales/hi-IN.json
keep add keep keep keep keep keep
<mask> "clearReset": "Ini akan menghapus semua yang ada dikanvas. Apakah kamu yakin ?", <mask> "couldNotCreateShareableLink": "Tidak bisa membuat tautan yang bisa dibagikan", <mask> "importBackendFailed": "Gagal mengimpor dari backend", <mask> "cannotExportEmptyCanvas": "Tidak bisa mengekspor kanvas kosong", <mask> "couldNotCopyToClipboard": "Tidak bisa menyalin ke papan klip. Coba gunakan Browser Chrome", <mask> "decryptFailed": "", <mask> "uploadedSecurly": "Pengunggahan ini telah diamankan menggunakan enkripsi end-to-end, artinya server Excalidraw dan pihak ketiga tidak data membaca nya" </s> New Crowdin translations (mostly Arabic updates) (#1181) </s> add "couldNotLoadInvalidFile": "", </s> add }, "errorDialog": { "title": "" </s> add }, "errorDialog": { "title": "" </s> add }, "errorDialog": { "title": ""
https://github.com/excalidraw/excalidraw/commit/c240fff0c5fd11e788658cdc4a947f49d10867db
src/locales/id-ID.json
keep add keep keep
<mask> "desc_shareLink": "", <mask> "desc_exitSession": "" <mask> } <mask> } </s> New Crowdin translations (mostly Arabic updates) (#1181) </s> add }, "errorDialog": { "title": "" </s> add }, "errorDialog": { "title": "" </s> add "couldNotLoadInvalidFile": "", </s> add "couldNotLoadInvalidFile": "",
https://github.com/excalidraw/excalidraw/commit/c240fff0c5fd11e788658cdc4a947f49d10867db
src/locales/id-ID.json
keep keep add keep keep
<mask> "desc_persistenceWarning": "", <mask> "desc_shareLink": "Del denne linken med de du vil samarbeide med:", <mask> "desc_exitSession": "" <mask> } <mask> } </s> New Crowdin translations (mostly Arabic updates) (#1181) </s> add }, "errorDialog": { "title": "" </s> add }, "errorDialog": { "title": "" </s> add "couldNotLoadInvalidFile": "", </s> add "couldNotLoadInvalidFile": "",
https://github.com/excalidraw/excalidraw/commit/c240fff0c5fd11e788658cdc4a947f49d10867db
src/locales/no-NO.json
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> var generator = rough.generator(); <mask> <mask> function generateShape(element) { <mask> if (element.type === "selection") { <mask> element.draw = (rc, context) => { <mask> const fillStyle = context.fillStyle; <mask> context.fillStyle = "rgba(0, 0, 255, 0.10)"; <mask> context.fillRect(element.x, element.y, element.width, element.height); </s> Don't write null when cancelling text </s> remove generateShape(element); </s> add generateDraw(element); </s> remove element.text = prompt("What text do you want?"); </s> add const text = prompt("What text do you want?"); if (text === null) { return; } element.text = text; </s> remove generateShape(draggingElement); </s> add generateDraw(draggingElement);
https://github.com/excalidraw/excalidraw/commit/c26d04e162f9a70dae56ec15dfe4f0f6f544c3de
src/index.js
keep keep keep keep replace keep keep keep keep keep
<mask> const y = e.clientY - e.target.offsetTop; <mask> const element = newElement(elementType, x, y); <mask> <mask> if (elementType === "text") { <mask> element.text = prompt("What text do you want?"); <mask> element.font = "20px Virgil"; <mask> const font = context.font; <mask> context.font = element.font; <mask> element.measure = context.measureText(element.text); <mask> context.font = font; </s> Don't write null when cancelling text </s> remove generateShape(element); </s> add generateDraw(element); </s> remove function generateShape(element) { </s> add function generateDraw(element) { </s> remove generateShape(draggingElement); </s> add generateDraw(draggingElement);
https://github.com/excalidraw/excalidraw/commit/c26d04e162f9a70dae56ec15dfe4f0f6f544c3de
src/index.js
keep keep keep keep replace keep keep keep keep keep
<mask> element.width = element.measure.width; <mask> element.height = height; <mask> } <mask> <mask> generateShape(element); <mask> elements.push(element); <mask> if (elementType === "text") { <mask> setDraggingElement(null); <mask> } else { <mask> setDraggingElement(element); </s> Don't write null when cancelling text </s> remove function generateShape(element) { </s> add function generateDraw(element) { </s> remove element.text = prompt("What text do you want?"); </s> add const text = prompt("What text do you want?"); if (text === null) { return; } element.text = text; </s> remove generateShape(draggingElement); </s> add generateDraw(draggingElement);
https://github.com/excalidraw/excalidraw/commit/c26d04e162f9a70dae56ec15dfe4f0f6f544c3de
src/index.js
keep keep keep keep replace keep keep keep keep keep
<mask> draggingElement.width = width; <mask> // Make a perfect square or circle when shift is enabled <mask> draggingElement.height = e.shiftKey ? width : height; <mask> <mask> generateShape(draggingElement); <mask> <mask> if (elementType === "selection") { <mask> setSelection(draggingElement); <mask> } <mask> drawScene(); </s> Don't write null when cancelling text </s> remove generateShape(element); </s> add generateDraw(element); </s> remove element.text = prompt("What text do you want?"); </s> add const text = prompt("What text do you want?"); if (text === null) { return; } element.text = text; </s> remove function generateShape(element) { </s> add function generateDraw(element) {
https://github.com/excalidraw/excalidraw/commit/c26d04e162f9a70dae56ec15dfe4f0f6f544c3de
src/index.js
replace keep keep keep keep keep
<mask> *.log <mask> .DS_Store <mask> .envrc <mask> .now <mask> .vscode <mask> build </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove .now </s> add .eslintcache .idea .vercel </s> add .env.development.local .env.local .env.production.local .env.test.local </s> remove firebase/ </s> add dist firebase </s> add *.log *.tgz </s> add "endArrowhead": null, </s> add "endArrowhead": null,
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
.gitignore
add keep keep keep keep keep keep
<mask> .DS_Store <mask> .envrc <mask> .eslintcache <mask> .idea <mask> .vercel <mask> .vscode <mask> *.log </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove .now </s> add .eslintcache .idea .vercel </s> add *.log *.tgz </s> remove *.log </s> add </s> remove .idea dist/ .eslintcache *.tgz .env.local .env.development.local .env.test.local .env.production.local </s> add </s> remove firebase/ </s> add dist firebase </s> add "startArrowhead": null,
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
.gitignore
keep keep keep replace keep keep keep keep keep
<mask> *.log <mask> .DS_Store <mask> .envrc <mask> .now <mask> .vscode <mask> build <mask> firebase/ <mask> logs <mask> node_modules </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove firebase/ </s> add dist firebase </s> remove *.log </s> add </s> add *.log *.tgz </s> add .env.development.local .env.local .env.production.local .env.test.local </s> add "endArrowhead": null, </s> add "endArrowhead": null,
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
.gitignore
keep keep keep add keep keep keep keep
<mask> .eslintcache <mask> .idea <mask> .vercel <mask> .vscode <mask> build <mask> dist <mask> firebase <mask> logs </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove .now </s> add .eslintcache .idea .vercel </s> remove firebase/ </s> add dist firebase </s> add .env.development.local .env.local .env.production.local .env.test.local </s> remove *.log </s> add </s> remove .idea dist/ .eslintcache *.tgz .env.local .env.development.local .env.test.local .env.production.local </s> add </s> add "startArrowhead": null,
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
.gitignore
keep keep keep keep replace keep keep keep keep keep
<mask> .envrc <mask> .now <mask> .vscode <mask> build <mask> firebase/ <mask> logs <mask> node_modules <mask> npm-debug.log* <mask> static <mask> yarn-debug.log* </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove .now </s> add .eslintcache .idea .vercel </s> remove *.log </s> add </s> add *.log *.tgz </s> remove .idea dist/ .eslintcache *.tgz .env.local .env.development.local .env.test.local .env.production.local </s> add </s> add .env.development.local .env.local .env.production.local .env.test.local </s> add "startArrowhead": null,
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
.gitignore
keep keep keep keep replace replace replace replace replace replace replace replace replace
<mask> static <mask> yarn-debug.log* <mask> yarn-error.log* <mask> yarn.lock <mask> .idea <mask> dist/ <mask> .eslintcache <mask> *.tgz <mask> <mask> .env.local <mask> .env.development.local <mask> .env.test.local <mask> .env.production.local </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> add .env.development.local .env.local .env.production.local .env.test.local </s> add *.log *.tgz </s> remove firebase/ </s> add dist firebase </s> remove .now </s> add .eslintcache .idea .vercel </s> add currentItemArrowheads: { start: Arrowhead | null; end: Arrowhead | null; }; </s> add "startArrowhead": null,
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
.gitignore
keep add keep keep keep keep keep keep
<mask> TextAlign, <mask> FontFamily, <mask> } from "../element/types"; <mask> import { <mask> getCommonAttributeOfSelectedElements, <mask> isSomeElementSelected, <mask> getTargetElements, <mask> canChangeSharpness, </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> add canHaveArrowheads, </s> add canHaveArrowheads, </s> add Arrowhead, </s> remove getArrowPoints, </s> add </s> add ExcalidrawLinearElement, </s> add Arrowhead,
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/actions/actionProperties.tsx
keep add keep keep keep keep keep
<mask> getTargetElements, <mask> canChangeSharpness, <mask> } from "../scene"; <mask> import { ButtonSelect } from "../components/ButtonSelect"; <mask> import { ButtonIconSelect } from "../components/ButtonIconSelect"; <mask> import { ButtonIconCycle } from "../components/ButtonIconCycle"; <mask> import { </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> add import { ButtonIconCycle } from "../components/ButtonIconCycle"; </s> add canHaveArrowheads, </s> remove import { ExcalidrawElement, ExcalidrawLinearElement } from "./types"; </s> add import { ExcalidrawElement, ExcalidrawLinearElement, Arrowhead } from "./types"; </s> remove getArrowPoints, </s> add </s> add getArrowheadPoints, </s> add Arrowhead,
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/actions/actionProperties.tsx
keep keep add keep keep keep keep keep keep
<mask> } from "../scene"; <mask> import { ButtonSelect } from "../components/ButtonSelect"; <mask> import { ButtonIconSelect } from "../components/ButtonIconSelect"; <mask> import { <mask> isTextElement, <mask> redrawTextBoundingBox, <mask> getNonDeletedElements, <mask> } from "../element"; <mask> import { isLinearElement, isLinearElementType } from "../element/typeChecks"; </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> add canHaveArrowheads, </s> remove getArrowPoints, </s> add </s> add ExcalidrawLinearElement, </s> add canHaveArrowheads, </s> add Arrowhead, </s> add getArrowheadPoints,
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/actions/actionProperties.tsx
keep keep add keep keep keep keep
<mask> SloppinessArchitectIcon, <mask> SloppinessArtistIcon, <mask> SloppinessCartoonistIcon, <mask> } from "../components/icons"; <mask> import { EVENT_CHANGE, trackEvent } from "../analytics"; <mask> import colors from "../colors"; <mask> </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> add import { ButtonIconCycle } from "../components/ButtonIconCycle"; </s> add getArrowheadPoints, </s> remove getArrowPoints, </s> add </s> remove import { ExcalidrawElement, ExcalidrawLinearElement } from "./types"; </s> add import { ExcalidrawElement, ExcalidrawLinearElement, Arrowhead } from "./types"; </s> add Arrowhead, </s> add canHaveArrowheads,
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/actions/actionProperties.tsx
keep keep add keep keep keep keep keep keep
<mask> | "changeStrokeWidth" <mask> | "changeSloppiness" <mask> | "changeStrokeStyle" <mask> | "changeOpacity" <mask> | "changeFontSize" <mask> | "toggleCanvasMenu" <mask> | "toggleEditMenu" <mask> | "undo" <mask> | "redo" </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> add startArrowhead: Arrowhead | null; endArrowhead: Arrowhead | null; </s> remove type: "arrow" | "line" | "draw"; </s> add type: "line" | "draw" | "arrow"; </s> add export type Arrowhead = "arrow"; </s> add startArrowhead: null, endArrowhead: null, </s> add startArrowhead: Arrowhead | null; endArrowhead: Arrowhead | null; </s> add currentItemArrowheads: { start: Arrowhead | null; end: Arrowhead | null; };
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/actions/types.ts
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> ) => boolean; <mask> } <mask> <mask> export interface ActionsManagerInterface { <mask> actions: { <mask> [actionName in ActionName]: Action; <mask> }; <mask> registerAction: (action: Action) => void; <mask> handleKeyDown: (event: KeyboardEvent) => boolean; <mask> getContextMenuItems: ( <mask> actionFilter: ActionFilterFn, <mask> ) => { label: string; action: () => void }[]; </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove export const getArrowPoints = ( </s> add export const getArrowheadPoints = ( </s> add export const canHaveArrowheads = (type: string) => type === "arrow"; </s> add position: "start" | "end", arrowhead: Arrowhead, </s> add {(canHaveArrowheads(elementType) || targetElements.some((element) => canHaveArrowheads(element.type))) && ( <>{renderAction("changeArrowhead")}</> )} </s> add startArrowhead: Arrowhead | null; endArrowhead: Arrowhead | null; </s> remove { width: 40, height: 20 }, </s> add { width: 40, height: 20, },
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/actions/types.ts
keep keep add keep keep keep keep keep keep
<mask> currentItemTextAlign: DEFAULT_TEXT_ALIGN, <mask> currentItemStrokeSharpness: "sharp", <mask> currentItemLinearStrokeSharpness: "round", <mask> viewBackgroundColor: oc.white, <mask> scrollX: 0 as FlooredNumber, <mask> scrollY: 0 as FlooredNumber, <mask> cursorX: 0, <mask> cursorY: 0, <mask> cursorButton: "up", </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> add currentItemArrowheads: { start: Arrowhead | null; end: Arrowhead | null; }; </s> add currentItemArrowheads: { browser: true, export: false }, </s> remove <g stroke={iconFillColor(appearance)} fill="none"> <path d="M0 0s0 0 0 0m0 0s0 0 0 0m.133 12.04L10.63-.033M.133 12.04L10.63-.034M2.234 21.818L21.26-.07M2.234 21.818L21.26-.07m-8.395 21.852L31.89-.103M12.865 21.783C17.87 16.025 22.875 10.266 31.89-.103m-8.395 21.852L41.208 1.37M23.495 21.75L41.208 1.37m-7.083 20.343l7.216-8.302m-7.216 8.302l7.216-8.302M-.09 19.92s0 0 0 0m0 0s0 0 0 0m12.04-.133L-.126 9.29m12.075 10.497L-.126 9.29m24.871 11.02C19.872 16.075 15 11.84.595-.684m24.15 20.994L.595-.684m36.19 20.861L12.636-.817m24.15 20.994L12.636-.817m30.909 16.269L24.676-.95m18.868 16.402L24.676-.95m18.833 5.771L37.472-.427m6.037 5.248L37.472-.427" /> <path d="M0 0h40M0 0h40m0 0v20m0-20v20m0 0H0m40 0H0m0 0V0m0 20V0" strokeWidth={2} /> </s> add <g fill={iconFillColor(appearance)} fillRule="evenodd" clipRule="evenodd"> <path d="M20.101 16H28.0934L36 8.95989V4H33.5779L20.101 16ZM30.5704 4L17.0935 16H9.10101L22.5779 4H30.5704ZM19.5704 4L6.09349 16H4V10.7475L11.5779 4H19.5704ZM8.57036 4H4V8.06952L8.57036 4ZM36 11.6378L31.101 16H36V11.6378ZM2 2V18H38V2H2Z" /> <path d="M14.0001 18L3.00006 4.00002L4.5727 2.76438L15.5727 16.7644L14.0001 18ZM25.0001 18L14.0001 4.00002L15.5727 2.76438L26.5727 16.7644L25.0001 18ZM36.0001 18L25.0001 4.00002L26.5727 2.76438L37.5727 16.7644L36.0001 18Z" /> </s> remove <g stroke={iconFillColor(appearance)} fill="none"> <path d="M0 0s0 0 0 0m0 0s0 0 0 0m.133 12.04L10.63-.033M.133 12.04L10.63-.034M2.234 21.818L21.26-.07M2.234 21.818L21.26-.07m-8.395 21.852L31.89-.103M12.865 21.783L31.89-.103m-8.395 21.852L41.208 1.37M23.495 21.75L41.208 1.37m-7.083 20.343l7.216-8.302m-7.216 8.302l7.216-8.302" /> <path d="M0 0h40M0 0h40m0 0v20m0-20v20m0 0H0m40 0H0m0 0V0m0 20V0" strokeWidth={2} /> </g>, </s> add <path fillRule="evenodd" clipRule="evenodd" d="M20.101 16H28.0934L36 8.95989V4H33.5779L20.101 16ZM30.5704 4L17.0935 16H9.10101L22.5779 4H30.5704ZM19.5704 4L6.09349 16H4V10.7475L11.5779 4H19.5704ZM8.57036 4H4V8.06952L8.57036 4ZM36 11.6378L31.101 16H36V11.6378ZM2 2V18H38V2H2Z" fill={iconFillColor(appearance)} />, </s> remove const data = ops[ops.length - 1].data; </s> add // The index of the bCurve operation to examine. const index = position === "start" ? 1 : ops.length - 1; const data = ops[index].data; </s> remove // we need to find p0 of the bezier curve // it is typically the last point of the previous // curve; it can also be the position of moveTo operation const prevOp = ops[ops.length - 2]; </s> add // We need to find p0 of the bezier curve. // It is typically the last point of the previous // curve; it can also be the position of moveTo operation. const prevOp = ops[index - 1];
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/appState.ts
keep add keep keep keep keep
<mask> currentItemStrokeSharpness: { browser: true, export: false }, <mask> currentItemLinearStrokeSharpness: { browser: true, export: false }, <mask> cursorButton: { browser: true, export: false }, <mask> cursorX: { browser: true, export: false }, <mask> cursorY: { browser: true, export: false }, <mask> draggingElement: { browser: false, export: false }, </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> add "endArrowhead": "arrow", </s> add currentItemArrowheads: { start: null, end: "arrow" }, </s> add currentItemArrowheads: { start: Arrowhead | null; end: Arrowhead | null; }; </s> remove { width: 40, height: 20 }, </s> add { width: 40, height: 20, }, </s> add startArrowhead, endArrowhead, </s> add "currentItemArrowheads": Object { "end": "arrow", "start": null, },
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/appState.ts
keep keep keep add keep keep keep keep keep
<mask> hasBackground, <mask> hasStroke, <mask> canChangeSharpness, <mask> hasText, <mask> getTargetElements, <mask> } from "../scene"; <mask> import { t } from "../i18n"; <mask> import { SHAPES } from "../shapes"; <mask> import { ToolButton } from "./ToolButton"; </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> add canHaveArrowheads, </s> add import { ButtonIconCycle } from "../components/ButtonIconCycle"; </s> add Arrowhead, </s> add getArrowheadPoints, </s> remove getArrowPoints, </s> add </s> remove import { ExcalidrawElement, ExcalidrawLinearElement } from "./types"; </s> add import { ExcalidrawElement, ExcalidrawLinearElement, Arrowhead } from "./types";
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/Actions.tsx
keep add keep keep keep keep
<mask> )} <mask> <mask> {renderAction("changeOpacity")} <mask> <mask> <fieldset> <mask> <legend>{t("labels.layers")}</legend> </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> add currentItemArrowheads: { start: Arrowhead | null; end: Arrowhead | null; }; </s> add "endArrowhead": null, </s> add "currentItemArrowheads": Object { "end": "arrow", "start": null, }, </s> add "currentItemArrowheads": Object { "end": "arrow", "start": null, }, </s> add "currentItemArrowheads": Object { "end": "arrow", "start": null, }, </s> add "currentItemArrowheads": Object { "end": "arrow", "start": null, },
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/Actions.tsx
keep keep keep add keep keep keep keep keep
<mask> pointerDownState.origin.x, <mask> pointerDownState.origin.y, <mask> elementType === "draw" ? null : this.state.gridSize, <mask> ); <mask> const element = newLinearElement({ <mask> type: elementType, <mask> x: gridX, <mask> y: gridY, <mask> strokeColor: this.state.currentItemStrokeColor, </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> add startArrowhead: null, endArrowhead: null, </s> add const { startArrowhead = null, endArrowhead = element.type === "arrow" ? "arrow" : null, } = element; </s> remove const data = ops[ops.length - 1].data; </s> add // The index of the bCurve operation to examine. const index = position === "start" ? 1 : ops.length - 1; const data = ops[index].data; </s> remove type: "arrow" | "line" | "draw"; </s> add type: "line" | "draw" | "arrow"; </s> add export type Arrowhead = "arrow"; </s> remove const arrowPoints = getArrowPoints(element, shape); if (arrowPoints) { const [x2, y2, x3, y3, x4, y4] = arrowPoints; // for dotted arrows caps, reduce gap to make it more legible </s> add const { startArrowhead = null, endArrowhead = "arrow" } = element; function getArrowheadShapes( element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead, ) { const arrowheadPoints = getArrowheadPoints( element, shape, position, arrowhead, ); if (arrowheadPoints === null) { return []; } // Other arrowheads here... // Arrow arrowheads const [x2, y2, x3, y3, x4, y4] = arrowheadPoints;
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/App.tsx
keep keep add keep keep keep keep keep keep
<mask> roughness: this.state.currentItemRoughness, <mask> opacity: this.state.currentItemOpacity, <mask> strokeSharpness: this.state.currentItemLinearStrokeSharpness, <mask> }); <mask> this.setState((prevState) => ({ <mask> selectedElementIds: { <mask> ...prevState.selectedElementIds, <mask> [element.id]: false, <mask> }, </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove input[type="radio"] { </s> add input[type="radio"], input[type="button"] { </s> remove { width: 40, height: 20 }, </s> add { width: 40, height: 20, }, </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove d="M3.286 9.998h32.759" </s> add d="M6 10H34" </s> remove d="M9.18 19.68V6.346m0 13.336V6.345m0 0h29.599m-29.6 0h29.6" </s> add d="M10 17L10 5L35 5" </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34"
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/App.tsx
keep keep keep keep replace replace replace replace replace replace replace keep keep keep keep keep
<mask> <mask> export const FillHachureIcon = React.memo( <mask> ({ appearance }: { appearance: "light" | "dark" }) => <mask> createIcon( <mask> <g stroke={iconFillColor(appearance)} fill="none"> <mask> <path d="M0 0s0 0 0 0m0 0s0 0 0 0m.133 12.04L10.63-.033M.133 12.04L10.63-.034M2.234 21.818L21.26-.07M2.234 21.818L21.26-.07m-8.395 21.852L31.89-.103M12.865 21.783L31.89-.103m-8.395 21.852L41.208 1.37M23.495 21.75L41.208 1.37m-7.083 20.343l7.216-8.302m-7.216 8.302l7.216-8.302" /> <mask> <path <mask> d="M0 0h40M0 0h40m0 0v20m0-20v20m0 0H0m40 0H0m0 0V0m0 20V0" <mask> strokeWidth={2} <mask> /> <mask> </g>, <mask> { width: 40, height: 20 }, <mask> ), <mask> ); <mask> <mask> export const FillCrossHatchIcon = React.memo( </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove <g stroke={iconFillColor(appearance)} fill="none"> <path d="M0 0s0 0 0 0m0 0s0 0 0 0m.133 12.04L10.63-.033M.133 12.04L10.63-.034M2.234 21.818L21.26-.07M2.234 21.818L21.26-.07m-8.395 21.852L31.89-.103M12.865 21.783C17.87 16.025 22.875 10.266 31.89-.103m-8.395 21.852L41.208 1.37M23.495 21.75L41.208 1.37m-7.083 20.343l7.216-8.302m-7.216 8.302l7.216-8.302M-.09 19.92s0 0 0 0m0 0s0 0 0 0m12.04-.133L-.126 9.29m12.075 10.497L-.126 9.29m24.871 11.02C19.872 16.075 15 11.84.595-.684m24.15 20.994L.595-.684m36.19 20.861L12.636-.817m24.15 20.994L12.636-.817m30.909 16.269L24.676-.95m18.868 16.402L24.676-.95m18.833 5.771L37.472-.427m6.037 5.248L37.472-.427" /> <path d="M0 0h40M0 0h40m0 0v20m0-20v20m0 0H0m40 0H0m0 0V0m0 20V0" strokeWidth={2} /> </s> add <g fill={iconFillColor(appearance)} fillRule="evenodd" clipRule="evenodd"> <path d="M20.101 16H28.0934L36 8.95989V4H33.5779L20.101 16ZM30.5704 4L17.0935 16H9.10101L22.5779 4H30.5704ZM19.5704 4L6.09349 16H4V10.7475L11.5779 4H19.5704ZM8.57036 4H4V8.06952L8.57036 4ZM36 11.6378L31.101 16H36V11.6378ZM2 2V18H38V2H2Z" /> <path d="M14.0001 18L3.00006 4.00002L4.5727 2.76438L15.5727 16.7644L14.0001 18ZM25.0001 18L14.0001 4.00002L15.5727 2.76438L26.5727 16.7644L25.0001 18ZM36.0001 18L25.0001 4.00002L26.5727 2.76438L37.5727 16.7644L36.0001 18Z" /> </s> remove createIcon( <> <path d="M0 0h120v60H0" strokeWidth={0} /> <path d="M0 0h40M0 0h40m0 0v20m0-20v20m0 0H0m40 0H0m0 0V0m0 20V0" stroke={iconFillColor(appearance)} strokeWidth={2} fill="none" /> </>, { width: 40, height: 20 }, ), </s> add createIcon(<path d="M2 2H38V18H2V2Z" fill={iconFillColor(appearance)} />, { width: 40, height: 20, }), </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove { width: 40, height: 20 }, </s> add { width: 40, height: 20, }, </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove d="M9.18 19.68V6.346m0 13.336V6.345m0 0h29.599m-29.6 0h29.6" </s> add d="M10 17L10 5L35 5"
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/icons.tsx
keep keep keep keep replace replace replace replace replace replace keep keep keep keep keep
<mask> <mask> export const FillCrossHatchIcon = React.memo( <mask> ({ appearance }: { appearance: "light" | "dark" }) => <mask> createIcon( <mask> <g stroke={iconFillColor(appearance)} fill="none"> <mask> <path d="M0 0s0 0 0 0m0 0s0 0 0 0m.133 12.04L10.63-.033M.133 12.04L10.63-.034M2.234 21.818L21.26-.07M2.234 21.818L21.26-.07m-8.395 21.852L31.89-.103M12.865 21.783C17.87 16.025 22.875 10.266 31.89-.103m-8.395 21.852L41.208 1.37M23.495 21.75L41.208 1.37m-7.083 20.343l7.216-8.302m-7.216 8.302l7.216-8.302M-.09 19.92s0 0 0 0m0 0s0 0 0 0m12.04-.133L-.126 9.29m12.075 10.497L-.126 9.29m24.871 11.02C19.872 16.075 15 11.84.595-.684m24.15 20.994L.595-.684m36.19 20.861L12.636-.817m24.15 20.994L12.636-.817m30.909 16.269L24.676-.95m18.868 16.402L24.676-.95m18.833 5.771L37.472-.427m6.037 5.248L37.472-.427" /> <mask> <path <mask> d="M0 0h40M0 0h40m0 0v20m0-20v20m0 0H0m40 0H0m0 0V0m0 20V0" <mask> strokeWidth={2} <mask> /> <mask> </g>, <mask> { width: 40, height: 20 }, <mask> ), <mask> ); <mask> </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove <g stroke={iconFillColor(appearance)} fill="none"> <path d="M0 0s0 0 0 0m0 0s0 0 0 0m.133 12.04L10.63-.033M.133 12.04L10.63-.034M2.234 21.818L21.26-.07M2.234 21.818L21.26-.07m-8.395 21.852L31.89-.103M12.865 21.783L31.89-.103m-8.395 21.852L41.208 1.37M23.495 21.75L41.208 1.37m-7.083 20.343l7.216-8.302m-7.216 8.302l7.216-8.302" /> <path d="M0 0h40M0 0h40m0 0v20m0-20v20m0 0H0m40 0H0m0 0V0m0 20V0" strokeWidth={2} /> </g>, </s> add <path fillRule="evenodd" clipRule="evenodd" d="M20.101 16H28.0934L36 8.95989V4H33.5779L20.101 16ZM30.5704 4L17.0935 16H9.10101L22.5779 4H30.5704ZM19.5704 4L6.09349 16H4V10.7475L11.5779 4H19.5704ZM8.57036 4H4V8.06952L8.57036 4ZM36 11.6378L31.101 16H36V11.6378ZM2 2V18H38V2H2Z" fill={iconFillColor(appearance)} />, </s> remove createIcon( <> <path d="M0 0h120v60H0" strokeWidth={0} /> <path d="M0 0h40M0 0h40m0 0v20m0-20v20m0 0H0m40 0H0m0 0V0m0 20V0" stroke={iconFillColor(appearance)} strokeWidth={2} fill="none" /> </>, { width: 40, height: 20 }, ), </s> add createIcon(<path d="M2 2H38V18H2V2Z" fill={iconFillColor(appearance)} />, { width: 40, height: 20, }), </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove { width: 40, height: 20 }, </s> add { width: 40, height: 20, }, </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove d="M9.18 19.68V6.346m0 13.336V6.345m0 0h29.599m-29.6 0h29.6" </s> add d="M10 17L10 5L35 5"
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/icons.tsx
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> ); <mask> <mask> export const FillSolidIcon = React.memo( <mask> ({ appearance }: { appearance: "light" | "dark" }) => <mask> createIcon( <mask> <> <mask> <path d="M0 0h120v60H0" strokeWidth={0} /> <mask> <path <mask> d="M0 0h40M0 0h40m0 0v20m0-20v20m0 0H0m40 0H0m0 0V0m0 20V0" <mask> stroke={iconFillColor(appearance)} <mask> strokeWidth={2} <mask> fill="none" <mask> /> <mask> </>, <mask> { width: 40, height: 20 }, <mask> ), <mask> ); <mask> <mask> export const StrokeWidthIcon = React.memo( <mask> ({ <mask> appearance, </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove <g stroke={iconFillColor(appearance)} fill="none"> <path d="M0 0s0 0 0 0m0 0s0 0 0 0m.133 12.04L10.63-.033M.133 12.04L10.63-.034M2.234 21.818L21.26-.07M2.234 21.818L21.26-.07m-8.395 21.852L31.89-.103M12.865 21.783L31.89-.103m-8.395 21.852L41.208 1.37M23.495 21.75L41.208 1.37m-7.083 20.343l7.216-8.302m-7.216 8.302l7.216-8.302" /> <path d="M0 0h40M0 0h40m0 0v20m0-20v20m0 0H0m40 0H0m0 0V0m0 20V0" strokeWidth={2} /> </g>, </s> add <path fillRule="evenodd" clipRule="evenodd" d="M20.101 16H28.0934L36 8.95989V4H33.5779L20.101 16ZM30.5704 4L17.0935 16H9.10101L22.5779 4H30.5704ZM19.5704 4L6.09349 16H4V10.7475L11.5779 4H19.5704ZM8.57036 4H4V8.06952L8.57036 4ZM36 11.6378L31.101 16H36V11.6378ZM2 2V18H38V2H2Z" fill={iconFillColor(appearance)} />, </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove { width: 40, height: 20 }, </s> add { width: 40, height: 20, }, </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove d="M9.18 19.68V6.346m0 13.336V6.345m0 0h29.599m-29.6 0h29.6" </s> add d="M10 17L10 5L35 5" </s> remove d="M3.286 9.998h32.759" </s> add d="M6 10H34"
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/icons.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> strokeWidth: number; <mask> }) => <mask> createIcon( <mask> <path <mask> d="M0 10h40M0 10h40" <mask> stroke={iconFillColor(appearance)} <mask> strokeWidth={strokeWidth} <mask> fill="none" <mask> />, <mask> { width: 40, height: 20 }, </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove strokeWidth={2} </s> add strokeWidth={2.5} strokeDasharray={"4, 4"} </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove strokeDasharray="3 6" </s> add </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove createIcon( <> <path d="M0 0h120v60H0" strokeWidth={0} /> <path d="M0 0h40M0 0h40m0 0v20m0-20v20m0 0H0m40 0H0m0 0V0m0 20V0" stroke={iconFillColor(appearance)} strokeWidth={2} fill="none" /> </>, { width: 40, height: 20 }, ), </s> add createIcon(<path d="M2 2H38V18H2V2Z" fill={iconFillColor(appearance)} />, { width: 40, height: 20, }), </s> remove { width: 40, height: 20 }, </s> add { width: 40, height: 20, },
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/icons.tsx
keep keep replace keep keep keep keep replace
<mask> createIcon( <mask> <path <mask> d="M0 10h40M0 10h40" <mask> stroke={iconFillColor(appearance)} <mask> strokeWidth={2} <mask> fill="none" <mask> />, <mask> { width: 40, height: 20 }, </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]>
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/icons.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> export const StrokeStyleDashedIcon = React.memo( <mask> ({ appearance }: { appearance: "light" | "dark" }) => <mask> createIcon( <mask> <path <mask> d="M3.286 9.998h32.759" <mask> stroke={iconFillColor(appearance)} <mask> strokeWidth={2.5} <mask> fill="none" <mask> strokeDasharray="12 8" <mask> />, </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove { width: 40, height: 20 }, </s> add { width: 40, height: 20, }, </s> remove d="M9.18 19.68V6.346m0 13.336V6.345m0 0h29.599m-29.6 0h29.6" </s> add d="M10 17L10 5L35 5" </s> remove strokeDasharray="12 8" </s> add </s> remove createIcon( <> <path d="M0 0h120v60H0" strokeWidth={0} /> <path d="M0 0h40M0 0h40m0 0v20m0-20v20m0 0H0m40 0H0m0 0V0m0 20V0" stroke={iconFillColor(appearance)} strokeWidth={2} fill="none" /> </>, { width: 40, height: 20 }, ), </s> add createIcon(<path d="M2 2H38V18H2V2Z" fill={iconFillColor(appearance)} />, { width: 40, height: 20, }),
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/icons.tsx
keep add keep keep keep keep
<mask> stroke={iconFillColor(appearance)} <mask> strokeWidth={2.5} <mask> fill="none" <mask> />, <mask> { width: 40, height: 20 }, <mask> ), </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove strokeDasharray="12 8" </s> add </s> remove strokeWidth={2} </s> add strokeWidth={2.5} strokeDasharray={"4, 4"} </s> remove strokeDasharray="3 6" </s> add </s> remove { width: 40, height: 20 }, </s> add { width: 40, height: 20, }, </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34"
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/icons.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> d="M3.286 9.998h32.759" <mask> stroke={iconFillColor(appearance)} <mask> strokeWidth={2.5} <mask> fill="none" <mask> strokeDasharray="12 8" <mask> />, <mask> { width: 40, height: 20 }, <mask> ), <mask> ); <mask> </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> add strokeDasharray={"10, 8"} </s> remove strokeDasharray="3 6" </s> add </s> remove d="M3.286 9.998h32.759" </s> add d="M6 10H34" </s> remove strokeWidth={2} </s> add strokeWidth={2.5} strokeDasharray={"4, 4"} </s> remove { width: 40, height: 20 }, </s> add { width: 40, height: 20, }, </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34"
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/icons.tsx
keep keep keep replace keep replace keep keep
<mask> ({ appearance }: { appearance: "light" | "dark" }) => <mask> createIcon( <mask> <path <mask> d="M0 10h40M0 10h40" <mask> stroke={iconFillColor(appearance)} <mask> strokeWidth={2} <mask> fill="none" <mask> strokeDasharray="3 6" </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove d="M3.286 9.998h32.759" </s> add d="M6 10H34" </s> remove d="M9.18 19.68V6.346m0 13.336V6.345m0 0h29.599m-29.6 0h29.6" </s> add d="M10 17L10 5L35 5" </s> remove strokeDasharray="3 6" </s> add </s> remove { width: 40, height: 20 }, </s> add { width: 40, height: 20, },
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/icons.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> d="M0 10h40M0 10h40" <mask> stroke={iconFillColor(appearance)} <mask> strokeWidth={2} <mask> fill="none" <mask> strokeDasharray="3 6" <mask> />, <mask> { width: 40, height: 20 }, <mask> ), <mask> ); <mask> </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove strokeWidth={2} </s> add strokeWidth={2.5} strokeDasharray={"4, 4"} </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove strokeDasharray="12 8" </s> add </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove { width: 40, height: 20 }, </s> add { width: 40, height: 20, }, </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34"
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/icons.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> export const SloppinessArchitectIcon = React.memo( <mask> ({ appearance }: { appearance: "light" | "dark" }) => <mask> createIcon( <mask> <path <mask> d="M.268 17.938C4.05 15.093 19.414.725 22.96.868c3.547.143-4.149 16.266-1.41 17.928 2.738 1.662 14.866-6.632 17.84-7.958m-39.123 7.1C4.05 15.093 19.414.725 22.96.868c3.547.143-4.149 16.266-1.41 17.928 2.738 1.662 14.866-6.632 17.84-7.958" <mask> stroke={iconFillColor(appearance)} <mask> strokeWidth={2} <mask> fill="none" <mask> />, <mask> { width: 40, height: 20, mirror: true }, </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove d="M9.18 19.68V6.346m0 13.336V6.345m0 0h29.599m-29.6 0h29.6" </s> add d="M10 17L10 5L35 5" </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove { width: 40, height: 20 }, </s> add { width: 40, height: 20, }, </s> remove d="M9.444 19.537c.484-2.119-2.1-10.449 2.904-12.71 5.004-2.263 22.601-.72 27.121-.863M9.444 19.537c.484-2.119-2.1-10.449 2.904-12.71 5.004-2.263 22.601-.72 27.121-.863" </s> add d="M10 17V15C10 8 13 5 21 5L33.5 5" </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove d="M3.286 9.998h32.759" </s> add d="M6 10H34"
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/icons.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> export const SloppinessArtistIcon = React.memo( <mask> ({ appearance }: { appearance: "light" | "dark" }) => <mask> createIcon( <mask> <path <mask> d="M2.663 18.134c3.963-2.578 18.855-12.098 22.675-12.68 3.82-.58-1.966 8.367.242 9.196 2.209.828 10.649-3.14 13.01-4.224M7.037 15.474c4.013-2.198 14.19-14.648 17.18-14.32 2.99.329-1.749 14.286.759 16.292 2.507 2.006 12.284-2.68 14.286-4.256" <mask> stroke={iconFillColor(appearance)} <mask> strokeWidth={2} <mask> fill="none" <mask> />, <mask> { width: 40, height: 20, mirror: true }, </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove d="M9.18 19.68V6.346m0 13.336V6.345m0 0h29.599m-29.6 0h29.6" </s> add d="M10 17L10 5L35 5" </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove { width: 40, height: 20 }, </s> add { width: 40, height: 20, }, </s> remove d="M9.444 19.537c.484-2.119-2.1-10.449 2.904-12.71 5.004-2.263 22.601-.72 27.121-.863M9.444 19.537c.484-2.119-2.1-10.449 2.904-12.71 5.004-2.263 22.601-.72 27.121-.863" </s> add d="M10 17V15C10 8 13 5 21 5L33.5 5" </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove d="M3.286 9.998h32.759" </s> add d="M6 10H34"
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/icons.tsx
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> <mask> export const SloppinessCartoonistIcon = React.memo( <mask> ({ appearance }: { appearance: "light" | "dark" }) => <mask> createIcon( <mask> <> <mask> <path <mask> d="M1.944 17.15C6.056 14.637 22.368 1.86 26.615 2.083c4.248.223-.992 14.695.815 16.406 1.807 1.71 8.355-5.117 10.026-6.14m-35.512 4.8C6.056 14.637 22.368 1.86 26.615 2.083c4.248.223-.992 14.695.815 16.406 1.807 1.71 8.355-5.117 10.026-6.14" <mask> stroke={iconFillColor(appearance)} <mask> strokeWidth={2} <mask> fill="none" <mask> /> <mask> <path <mask> d="M3.114 10.534c2.737-1.395 12.854-8.814 16.42-8.368 3.568.445 2.35 10.282 4.984 11.04 2.635.756 9.019-5.416 10.822-6.5M3.114 10.535c2.737-1.395 12.854-8.814 16.42-8.368 3.568.445 2.35 10.282 4.984 11.04 2.635.756 9.019-5.416 10.822-6.5" <mask> stroke={iconFillColor(appearance)} <mask> strokeWidth={2} <mask> fill="none" <mask> /> <mask> </>, <mask> { width: 40, height: 20, mirror: true }, <mask> ), <mask> ); <mask> <mask> export const EdgeSharpIcon = React.memo( </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove createIcon( <> <path d="M0 0h120v60H0" strokeWidth={0} /> <path d="M0 0h40M0 0h40m0 0v20m0-20v20m0 0H0m40 0H0m0 0V0m0 20V0" stroke={iconFillColor(appearance)} strokeWidth={2} fill="none" /> </>, { width: 40, height: 20 }, ), </s> add createIcon(<path d="M2 2H38V18H2V2Z" fill={iconFillColor(appearance)} />, { width: 40, height: 20, }), </s> remove d="M9.18 19.68V6.346m0 13.336V6.345m0 0h29.599m-29.6 0h29.6" </s> add d="M10 17L10 5L35 5" </s> remove { width: 40, height: 20 }, </s> add { width: 40, height: 20, }, </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove d="M9.444 19.537c.484-2.119-2.1-10.449 2.904-12.71 5.004-2.263 22.601-.72 27.121-.863M9.444 19.537c.484-2.119-2.1-10.449 2.904-12.71 5.004-2.263 22.601-.72 27.121-.863" </s> add d="M10 17V15C10 8 13 5 21 5L33.5 5"
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/icons.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> export const EdgeSharpIcon = React.memo( <mask> ({ appearance }: { appearance: "light" | "dark" }) => <mask> createIcon( <mask> <path <mask> d="M9.18 19.68V6.346m0 13.336V6.345m0 0h29.599m-29.6 0h29.6" <mask> stroke={iconFillColor(appearance)} <mask> strokeWidth={2} <mask> fill="none" <mask> />, <mask> { width: 40, height: 20, mirror: true }, </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove { width: 40, height: 20 }, </s> add { width: 40, height: 20, }, </s> remove d="M9.444 19.537c.484-2.119-2.1-10.449 2.904-12.71 5.004-2.263 22.601-.72 27.121-.863M9.444 19.537c.484-2.119-2.1-10.449 2.904-12.71 5.004-2.263 22.601-.72 27.121-.863" </s> add d="M10 17V15C10 8 13 5 21 5L33.5 5" </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove d="M3.286 9.998h32.759" </s> add d="M6 10H34" </s> remove createIcon( <> <path d="M0 0h120v60H0" strokeWidth={0} /> <path d="M0 0h40M0 0h40m0 0v20m0-20v20m0 0H0m40 0H0m0 0V0m0 20V0" stroke={iconFillColor(appearance)} strokeWidth={2} fill="none" /> </>, { width: 40, height: 20 }, ), </s> add createIcon(<path d="M2 2H38V18H2V2Z" fill={iconFillColor(appearance)} />, { width: 40, height: 20, }),
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/icons.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> export const EdgeRoundIcon = React.memo( <mask> ({ appearance }: { appearance: "light" | "dark" }) => <mask> createIcon( <mask> <path <mask> d="M9.444 19.537c.484-2.119-2.1-10.449 2.904-12.71 5.004-2.263 22.601-.72 27.121-.863M9.444 19.537c.484-2.119-2.1-10.449 2.904-12.71 5.004-2.263 22.601-.72 27.121-.863" <mask> stroke={iconFillColor(appearance)} <mask> strokeWidth={2} <mask> fill="none" <mask> />, <mask> { width: 40, height: 20, mirror: true }, </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove d="M9.18 19.68V6.346m0 13.336V6.345m0 0h29.599m-29.6 0h29.6" </s> add d="M10 17L10 5L35 5" </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove { width: 40, height: 20 }, </s> add { width: 40, height: 20, }, </s> remove d="M0 10h40M0 10h40" </s> add d="M6 10H34" </s> remove d="M3.286 9.998h32.759" </s> add d="M6 10H34" </s> remove createIcon( <> <path d="M0 0h120v60H0" strokeWidth={0} /> <path d="M0 0h40M0 0h40m0 0v20m0-20v20m0 0H0m40 0H0m0 0V0m0 20V0" stroke={iconFillColor(appearance)} strokeWidth={2} fill="none" /> </>, { width: 40, height: 20 }, ), </s> add createIcon(<path d="M2 2H38V18H2V2Z" fill={iconFillColor(appearance)} />, { width: 40, height: 20, }),
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/components/icons.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> font-size: 0.75rem; <mask> display: inline-block; <mask> } <mask> <mask> input[type="radio"] { <mask> opacity: 0; <mask> position: absolute; <mask> pointer-events: none; <mask> } <mask> </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> add import { ButtonIconCycle } from "../components/ButtonIconCycle"; </s> remove getArrowPoints, </s> add </s> add getArrowheadPoints, </s> add Arrowhead, </s> add canHaveArrowheads, </s> add Arrowhead,
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/css/styles.scss
keep keep keep add keep keep keep keep
<mask> }); <mask> case "draw": <mask> case "line": <mask> case "arrow": { <mask> return restoreElementWithProperties(element, { <mask> startBinding: element.startBinding, <mask> endBinding: element.endBinding, <mask> points: </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> add startArrowhead, endArrowhead, </s> add startArrowhead: Arrowhead | null; endArrowhead: Arrowhead | null; </s> remove type: "arrow" | "line" | "draw"; </s> add type: "line" | "draw" | "arrow"; </s> add startArrowhead: Arrowhead | null; endArrowhead: Arrowhead | null; </s> add export type Arrowhead = "arrow"; </s> add startArrowhead, endArrowhead,
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/data/restore.ts
keep add keep keep keep keep keep
<mask> : element.points, <mask> lastCommittedPoint: null, <mask> }); <mask> } <mask> // generic elements <mask> case "ellipse": <mask> return restoreElementWithProperties(element, {}); </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> add const { startArrowhead = null, endArrowhead = element.type === "arrow" ? "arrow" : null, } = element; </s> add startArrowhead: opts.startArrowhead, endArrowhead: opts.endArrowhead, </s> add startArrowhead: null, endArrowhead: null, </s> add // for solid/dashed, keep solid arrow cap </s> remove const data = ops[ops.length - 1].data; </s> add // The index of the bCurve operation to examine. const index = position === "start" ? 1 : ops.length - 1; const data = ops[index].data; </s> remove shape.push( ...[ generator.line(x3, y3, x2, y2, options), generator.line(x4, y4, x2, y2, options), ], </s> add return [ generator.line(x3, y3, x2, y2, options), generator.line(x4, y4, x2, y2, options), ]; } if (startArrowhead !== null) { const shapes = getArrowheadShapes( element, shape, "start", startArrowhead, ); shape.push(...shapes); } if (endArrowhead !== null) { if (endArrowhead === undefined) { // Hey, we have an old arrow here! } const shapes = getArrowheadShapes( element, shape, "end", endArrowhead,
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/data/restore.ts
replace keep keep keep keep keep
<mask> import { ExcalidrawElement, ExcalidrawLinearElement } from "./types"; <mask> import { distance2d, rotate } from "../math"; <mask> import rough from "roughjs/bin/rough"; <mask> import { Drawable, Op } from "roughjs/bin/core"; <mask> import { Point } from "../types"; <mask> import { </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> add getArrowheadPoints, </s> remove getArrowPoints, </s> add </s> add Arrowhead, </s> add import { ButtonIconCycle } from "../components/ButtonIconCycle"; </s> add Arrowhead, </s> add canHaveArrowheads,
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/element/bounds.ts
keep keep keep keep replace keep keep keep keep keep
<mask> maxY + element.y, <mask> ]; <mask> }; <mask> <mask> export const getArrowPoints = ( <mask> element: ExcalidrawLinearElement, <mask> shape: Drawable[], <mask> ) => { <mask> const ops = getCurvePathOps(shape[0]); <mask> if (ops.length < 1) { </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> add position: "start" | "end", arrowhead: Arrowhead, </s> remove const arrowPoints = getArrowPoints(element, shape); if (arrowPoints) { const [x2, y2, x3, y3, x4, y4] = arrowPoints; // for dotted arrows caps, reduce gap to make it more legible </s> add const { startArrowhead = null, endArrowhead = "arrow" } = element; function getArrowheadShapes( element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead, ) { const arrowheadPoints = getArrowheadPoints( element, shape, position, arrowhead, ); if (arrowheadPoints === null) { return []; } // Other arrowheads here... // Arrow arrowheads const [x2, y2, x3, y3, x4, y4] = arrowheadPoints; </s> add export const canHaveArrowheads = (type: string) => type === "arrow"; </s> remove const data = ops[ops.length - 1].data; </s> add // The index of the bCurve operation to examine. const index = position === "start" ? 1 : ops.length - 1; const data = ops[index].data; </s> remove actions: { [actionName in ActionName]: Action; }; </s> add actions: Record<ActionName, Action>; </s> remove const size = 30; // pixels const arrowLength = element.points.reduce((total, [cx, cy], idx, points) => { </s> add const size = 30; // pixels (will differ for each arrowhead) const length = element.points.reduce((total, [cx, cy], idx, points) => {
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/element/bounds.ts
keep add keep keep keep keep
<mask> element: ExcalidrawLinearElement, <mask> shape: Drawable[], <mask> ) => { <mask> const ops = getCurvePathOps(shape[0]); <mask> if (ops.length < 1) { <mask> return null; </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove export const getArrowPoints = ( </s> add export const getArrowheadPoints = ( </s> remove const arrowPoints = getArrowPoints(element, shape); if (arrowPoints) { const [x2, y2, x3, y3, x4, y4] = arrowPoints; // for dotted arrows caps, reduce gap to make it more legible </s> add const { startArrowhead = null, endArrowhead = "arrow" } = element; function getArrowheadShapes( element: ExcalidrawLinearElement, shape: Drawable[], position: "start" | "end", arrowhead: Arrowhead, ) { const arrowheadPoints = getArrowheadPoints( element, shape, position, arrowhead, ); if (arrowheadPoints === null) { return []; } // Other arrowheads here... // Arrow arrowheads const [x2, y2, x3, y3, x4, y4] = arrowheadPoints; </s> remove const data = ops[ops.length - 1].data; </s> add // The index of the bCurve operation to examine. const index = position === "start" ? 1 : ops.length - 1; const data = ops[index].data; </s> add startArrowhead: Arrowhead | null; endArrowhead: Arrowhead | null; </s> add export const canHaveArrowheads = (type: string) => type === "arrow"; </s> remove actions: { [actionName in ActionName]: Action; }; </s> add actions: Record<ActionName, Action>;
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/element/bounds.ts
keep keep keep replace keep keep keep keep replace replace replace replace keep keep keep keep
<mask> return null; <mask> } <mask> <mask> const data = ops[ops.length - 1].data; <mask> const p3 = [data[4], data[5]] as Point; <mask> const p2 = [data[2], data[3]] as Point; <mask> const p1 = [data[0], data[1]] as Point; <mask> <mask> // we need to find p0 of the bezier curve <mask> // it is typically the last point of the previous <mask> // curve; it can also be the position of moveTo operation <mask> const prevOp = ops[ops.length - 2]; <mask> let p0: Point = [0, 0]; <mask> if (prevOp.op === "move") { <mask> p0 = (prevOp.data as unknown) as Point; <mask> } else if (prevOp.op === "bcurveTo") { </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove // we know the last point of the arrow const [x2, y2] = p3; </s> add // Ee know the last point of the arrow (or the first, if start arrowhead). const [x2, y2] = position === "start" ? p0 : p3; </s> remove // Scale down the arrow until we hit a certain size so that it doesn't look weird // This value is selected by minizing a minmum size with the whole length of the arrow // intead of last segment of the arrow const minSize = Math.min(size, arrowLength / 2); </s> add // Scale down the arrowhead until we hit a certain size so that it doesn't look weird. // This value is selected by minimizing a minimum size with the whole length of the // arrowhead instead of last segment of the arrowhead. const minSize = Math.min(size, length / 2); </s> remove // by using cubic bezier equation (B(t)) and the given parameters, // we calculate a point that is closer to the last point </s> add // By using cubic bezier equation (B(t)) and the given parameters, // we calculate a point that is closer to the last point. </s> remove // the tested cases </s> add // the tested cases. </s> remove // find the normalized direction vector based on the // previously calculated points </s> add // Find the normalized direction vector based on the // previously calculated points.
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/element/bounds.ts
keep keep keep keep replace replace keep keep keep keep keep
<mask> 3 * t * Math.pow(1 - t, 2) * p2[idx] + <mask> 3 * Math.pow(t, 2) * (1 - t) * p1[idx] + <mask> p0[idx] * Math.pow(t, 3); <mask> <mask> // we know the last point of the arrow <mask> const [x2, y2] = p3; <mask> <mask> // by using cubic bezier equation (B(t)) and the given parameters, <mask> // we calculate a point that is closer to the last point <mask> // The value 0.3 is chosen arbitrarily and it works best for all <mask> // the tested cases </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove // by using cubic bezier equation (B(t)) and the given parameters, // we calculate a point that is closer to the last point </s> add // By using cubic bezier equation (B(t)) and the given parameters, // we calculate a point that is closer to the last point. </s> remove // the tested cases </s> add // the tested cases. </s> remove // Scale down the arrow until we hit a certain size so that it doesn't look weird // This value is selected by minizing a minmum size with the whole length of the arrow // intead of last segment of the arrow const minSize = Math.min(size, arrowLength / 2); </s> add // Scale down the arrowhead until we hit a certain size so that it doesn't look weird. // This value is selected by minimizing a minimum size with the whole length of the // arrowhead instead of last segment of the arrowhead. const minSize = Math.min(size, length / 2); </s> remove // find the normalized direction vector based on the // previously calculated points </s> add // Find the normalized direction vector based on the // previously calculated points. </s> remove // we need to find p0 of the bezier curve // it is typically the last point of the previous // curve; it can also be the position of moveTo operation const prevOp = ops[ops.length - 2]; </s> add // We need to find p0 of the bezier curve. // It is typically the last point of the previous // curve; it can also be the position of moveTo operation. const prevOp = ops[index - 1]; </s> add // Return points
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/element/bounds.ts
keep keep keep keep replace replace keep keep keep keep keep
<mask> <mask> // we know the last point of the arrow <mask> const [x2, y2] = p3; <mask> <mask> // by using cubic bezier equation (B(t)) and the given parameters, <mask> // we calculate a point that is closer to the last point <mask> // The value 0.3 is chosen arbitrarily and it works best for all <mask> // the tested cases <mask> const [x1, y1] = [equation(0.3, 0), equation(0.3, 1)]; <mask> <mask> // find the normalized direction vector based on the </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove // the tested cases </s> add // the tested cases. </s> remove // we know the last point of the arrow const [x2, y2] = p3; </s> add // Ee know the last point of the arrow (or the first, if start arrowhead). const [x2, y2] = position === "start" ? p0 : p3; </s> remove // find the normalized direction vector based on the // previously calculated points </s> add // Find the normalized direction vector based on the // previously calculated points. </s> remove // we need to find p0 of the bezier curve // it is typically the last point of the previous // curve; it can also be the position of moveTo operation const prevOp = ops[ops.length - 2]; </s> add // We need to find p0 of the bezier curve. // It is typically the last point of the previous // curve; it can also be the position of moveTo operation. const prevOp = ops[index - 1]; </s> remove // Scale down the arrow until we hit a certain size so that it doesn't look weird // This value is selected by minizing a minmum size with the whole length of the arrow // intead of last segment of the arrow const minSize = Math.min(size, arrowLength / 2); </s> add // Scale down the arrowhead until we hit a certain size so that it doesn't look weird. // This value is selected by minimizing a minimum size with the whole length of the // arrowhead instead of last segment of the arrowhead. const minSize = Math.min(size, length / 2); </s> add // If arrow is pre-arrowheads, it will have undefined for both start and end arrowheads. // If so, we want it to be null/"arrow". If the linear item is not an arrow, we want it // to be null/null. Otherwise, we want it to use the currentItemArrowheads values. const { start, end } = this.state.currentItemArrowheads; const [startArrowhead, endArrowhead] = elementType === "arrow" ? [start, end] : [null, null];
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/element/bounds.ts
keep replace keep keep replace replace keep keep keep
<mask> // The value 0.3 is chosen arbitrarily and it works best for all <mask> // the tested cases <mask> const [x1, y1] = [equation(0.3, 0), equation(0.3, 1)]; <mask> <mask> // find the normalized direction vector based on the <mask> // previously calculated points <mask> const distance = Math.hypot(x2 - x1, y2 - y1); <mask> const nx = (x2 - x1) / distance; <mask> const ny = (y2 - y1) / distance; </s> Add Arrowheads to Arrows (#2452) Co-authored-by: dwelle <[email protected]> Co-authored-by: Lipis <[email protected]> </s> remove // by using cubic bezier equation (B(t)) and the given parameters, // we calculate a point that is closer to the last point </s> add // By using cubic bezier equation (B(t)) and the given parameters, // we calculate a point that is closer to the last point. </s> remove const size = 30; // pixels const arrowLength = element.points.reduce((total, [cx, cy], idx, points) => { </s> add const size = 30; // pixels (will differ for each arrowhead) const length = element.points.reduce((total, [cx, cy], idx, points) => { </s> remove // we know the last point of the arrow const [x2, y2] = p3; </s> add // Ee know the last point of the arrow (or the first, if start arrowhead). const [x2, y2] = position === "start" ? p0 : p3; </s> remove // Scale down the arrow until we hit a certain size so that it doesn't look weird // This value is selected by minizing a minmum size with the whole length of the arrow // intead of last segment of the arrow const minSize = Math.min(size, arrowLength / 2); </s> add // Scale down the arrowhead until we hit a certain size so that it doesn't look weird. // This value is selected by minimizing a minimum size with the whole length of the // arrowhead instead of last segment of the arrowhead. const minSize = Math.min(size, length / 2); </s> remove // we need to find p0 of the bezier curve // it is typically the last point of the previous // curve; it can also be the position of moveTo operation const prevOp = ops[ops.length - 2]; </s> add // We need to find p0 of the bezier curve. // It is typically the last point of the previous // curve; it can also be the position of moveTo operation. const prevOp = ops[index - 1];
https://github.com/excalidraw/excalidraw/commit/c291edfc443231053ad02f755de5d8493ab9c945
src/element/bounds.ts