mirror of
				https://github.com/excalidraw/excalidraw.git
				synced 2025-11-03 20:34:40 +01:00 
			
		
		
		
	Bump prettier from 2.0.3 to 2.0.4 (#1412)
* Bump prettier from 2.0.3 to 2.0.4 Bumps [prettier](https://github.com/prettier/prettier) from 2.0.3 to 2.0.4. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/2.0.3...2.0.4) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * format Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Panayiotis Lipiridis <lipiridis@gmail.com>
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							e77e2255bd
						
					
				
				
					commit
					7df16c1b1d
				
			
							
								
								
									
										6
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@@ -15548,9 +15548,9 @@
 | 
			
		||||
      "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw="
 | 
			
		||||
    },
 | 
			
		||||
    "prettier": {
 | 
			
		||||
      "version": "2.0.3",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.3.tgz",
 | 
			
		||||
      "integrity": "sha512-5qpBDBHO9fpE0zruKiTZm8Gxmz7kknO+WlQR/ivV+RMwgDw/WjOgmxLDn66MPrxq/WZPx/EgEZzh87xJO5E6Fw==",
 | 
			
		||||
      "version": "2.0.4",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.4.tgz",
 | 
			
		||||
      "integrity": "sha512-SVJIQ51spzFDvh4fIbCLvciiDMCrRhlN3mbZvv/+ycjvmF5E73bKdGfU8QDLNmjYJf+lsGnDBC4UUnvTe5OO0w==",
 | 
			
		||||
      "dev": true
 | 
			
		||||
    },
 | 
			
		||||
    "prettier-linter-helpers": {
 | 
			
		||||
 
 | 
			
		||||
@@ -48,7 +48,7 @@
 | 
			
		||||
    "lint-staged": "10.1.3",
 | 
			
		||||
    "node-sass": "4.13.1",
 | 
			
		||||
    "pepjs": "0.5.2",
 | 
			
		||||
    "prettier": "2.0.3",
 | 
			
		||||
    "prettier": "2.0.4",
 | 
			
		||||
    "rewire": "5.0.0",
 | 
			
		||||
    "typescript": "3.8.3"
 | 
			
		||||
  },
 | 
			
		||||
 
 | 
			
		||||
@@ -134,11 +134,9 @@ import {
 | 
			
		||||
function withBatchedUpdates<
 | 
			
		||||
  TFunction extends ((event: any) => void) | (() => void)
 | 
			
		||||
>(func: Parameters<TFunction>["length"] extends 0 | 1 ? TFunction : never) {
 | 
			
		||||
  return (
 | 
			
		||||
    ((event) => {
 | 
			
		||||
      unstable_batchedUpdates(func as TFunction, event);
 | 
			
		||||
    }) as TFunction
 | 
			
		||||
  );
 | 
			
		||||
  return ((event) => {
 | 
			
		||||
    unstable_batchedUpdates(func as TFunction, event);
 | 
			
		||||
  }) as TFunction;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const { history } = createHistory();
 | 
			
		||||
 
 | 
			
		||||
@@ -193,48 +193,38 @@ export function handlerRectangles(
 | 
			
		||||
      const [, p1] = element.points;
 | 
			
		||||
 | 
			
		||||
      if (p1[0] === 0 || p1[1] === 0) {
 | 
			
		||||
        return (
 | 
			
		||||
          {
 | 
			
		||||
            nw: handlers.nw,
 | 
			
		||||
            se: handlers.se,
 | 
			
		||||
          } as typeof handlers
 | 
			
		||||
        );
 | 
			
		||||
        return {
 | 
			
		||||
          nw: handlers.nw,
 | 
			
		||||
          se: handlers.se,
 | 
			
		||||
        } as typeof handlers;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (p1[0] > 0 && p1[1] < 0) {
 | 
			
		||||
        return (
 | 
			
		||||
          {
 | 
			
		||||
            ne: handlers.ne,
 | 
			
		||||
            sw: handlers.sw,
 | 
			
		||||
          } as typeof handlers
 | 
			
		||||
        );
 | 
			
		||||
        return {
 | 
			
		||||
          ne: handlers.ne,
 | 
			
		||||
          sw: handlers.sw,
 | 
			
		||||
        } as typeof handlers;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (p1[0] > 0 && p1[1] > 0) {
 | 
			
		||||
        return (
 | 
			
		||||
          {
 | 
			
		||||
            nw: handlers.nw,
 | 
			
		||||
            se: handlers.se,
 | 
			
		||||
          } as typeof handlers
 | 
			
		||||
        );
 | 
			
		||||
        return {
 | 
			
		||||
          nw: handlers.nw,
 | 
			
		||||
          se: handlers.se,
 | 
			
		||||
        } as typeof handlers;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (p1[0] < 0 && p1[1] > 0) {
 | 
			
		||||
        return (
 | 
			
		||||
          {
 | 
			
		||||
            ne: handlers.ne,
 | 
			
		||||
            sw: handlers.sw,
 | 
			
		||||
          } as typeof handlers
 | 
			
		||||
        );
 | 
			
		||||
        return {
 | 
			
		||||
          ne: handlers.ne,
 | 
			
		||||
          sw: handlers.sw,
 | 
			
		||||
        } as typeof handlers;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (p1[0] < 0 && p1[1] < 0) {
 | 
			
		||||
        return (
 | 
			
		||||
          {
 | 
			
		||||
            nw: handlers.nw,
 | 
			
		||||
            se: handlers.se,
 | 
			
		||||
          } as typeof handlers
 | 
			
		||||
        );
 | 
			
		||||
        return {
 | 
			
		||||
          nw: handlers.nw,
 | 
			
		||||
          se: handlers.se,
 | 
			
		||||
        } as typeof handlers;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -67,10 +67,9 @@ export function getDrawingVersion(elements: readonly ExcalidrawElement[]) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function getNonDeletedElements(elements: readonly ExcalidrawElement[]) {
 | 
			
		||||
  return (
 | 
			
		||||
    elements.filter((element) => !element.isDeleted) as
 | 
			
		||||
    readonly NonDeletedExcalidrawElement[]
 | 
			
		||||
  );
 | 
			
		||||
  return elements.filter(
 | 
			
		||||
    (element) => !element.isDeleted,
 | 
			
		||||
  ) as readonly NonDeletedExcalidrawElement[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function isNonDeletedElement<T extends ExcalidrawElement>(
 | 
			
		||||
 
 | 
			
		||||
@@ -13,9 +13,7 @@ export function IsMobileProvider({ children }: { children: React.ReactNode }) {
 | 
			
		||||
          matches: false,
 | 
			
		||||
          addListener: () => {},
 | 
			
		||||
          removeListener: () => {},
 | 
			
		||||
        } as
 | 
			
		||||
          any) as
 | 
			
		||||
        MediaQueryList);
 | 
			
		||||
        } as any) as MediaQueryList);
 | 
			
		||||
  }
 | 
			
		||||
  const [isMobile, setMobile] = useState(query.current.matches);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										31
									
								
								src/keys.ts
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								src/keys.ts
									
									
									
									
									
								
							@@ -1,21 +1,20 @@
 | 
			
		||||
export const isDarwin = /Mac|iPod|iPhone|iPad/.test(window.navigator.platform);
 | 
			
		||||
 | 
			
		||||
export const KEYS =
 | 
			
		||||
  {
 | 
			
		||||
    ARROW_LEFT: "ArrowLeft",
 | 
			
		||||
    ARROW_RIGHT: "ArrowRight",
 | 
			
		||||
    ARROW_DOWN: "ArrowDown",
 | 
			
		||||
    ARROW_UP: "ArrowUp",
 | 
			
		||||
    ENTER: "Enter",
 | 
			
		||||
    ESCAPE: "Escape",
 | 
			
		||||
    DELETE: "Delete",
 | 
			
		||||
    BACKSPACE: "Backspace",
 | 
			
		||||
    CTRL_OR_CMD: isDarwin ? "metaKey" : "ctrlKey",
 | 
			
		||||
    TAB: "Tab",
 | 
			
		||||
    SPACE: " ",
 | 
			
		||||
    QUESTION_MARK: "?",
 | 
			
		||||
    F_KEY_CODE: 70,
 | 
			
		||||
  } as const;
 | 
			
		||||
export const KEYS = {
 | 
			
		||||
  ARROW_LEFT: "ArrowLeft",
 | 
			
		||||
  ARROW_RIGHT: "ArrowRight",
 | 
			
		||||
  ARROW_DOWN: "ArrowDown",
 | 
			
		||||
  ARROW_UP: "ArrowUp",
 | 
			
		||||
  ENTER: "Enter",
 | 
			
		||||
  ESCAPE: "Escape",
 | 
			
		||||
  DELETE: "Delete",
 | 
			
		||||
  BACKSPACE: "Backspace",
 | 
			
		||||
  CTRL_OR_CMD: isDarwin ? "metaKey" : "ctrlKey",
 | 
			
		||||
  TAB: "Tab",
 | 
			
		||||
  SPACE: " ",
 | 
			
		||||
  QUESTION_MARK: "?",
 | 
			
		||||
  F_KEY_CODE: 70,
 | 
			
		||||
} as const;
 | 
			
		||||
 | 
			
		||||
export type Key = keyof typeof KEYS;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										145
									
								
								src/shapes.tsx
									
									
									
									
									
								
							
							
						
						
									
										145
									
								
								src/shapes.tsx
									
									
									
									
									
								
							@@ -2,79 +2,78 @@ import React from "react";
 | 
			
		||||
import oc from "open-color";
 | 
			
		||||
 | 
			
		||||
// We inline font-awesome icons in order to save on js size rather than including the font awesome react library
 | 
			
		||||
export const SHAPES =
 | 
			
		||||
  [
 | 
			
		||||
    {
 | 
			
		||||
      icon: (
 | 
			
		||||
        // fa-mouse-pointer
 | 
			
		||||
        <svg viewBox="0 0 320 512" className="">
 | 
			
		||||
          <path d="M302.189 329.126H196.105l55.831 135.993c3.889 9.428-.555 19.999-9.444 23.999l-49.165 21.427c-9.165 4-19.443-.571-23.332-9.714l-53.053-129.136-86.664 89.138C18.729 472.71 0 463.554 0 447.977V18.299C0 1.899 19.921-6.096 30.277 5.443l284.412 292.542c11.472 11.179 3.007 31.141-12.5 31.141z" />
 | 
			
		||||
        </svg>
 | 
			
		||||
      ),
 | 
			
		||||
      value: "selection",
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      icon: (
 | 
			
		||||
        // fa-square
 | 
			
		||||
        <svg viewBox="0 0 448 512">
 | 
			
		||||
          <path d="M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48z" />
 | 
			
		||||
        </svg>
 | 
			
		||||
      ),
 | 
			
		||||
      value: "rectangle",
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      icon: (
 | 
			
		||||
        // custom
 | 
			
		||||
        <svg viewBox="0 0 223.646 223.646">
 | 
			
		||||
          <path d="M111.823 0L16.622 111.823 111.823 223.646 207.025 111.823z" />
 | 
			
		||||
        </svg>
 | 
			
		||||
      ),
 | 
			
		||||
      value: "diamond",
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      icon: (
 | 
			
		||||
        // fa-circle
 | 
			
		||||
        <svg viewBox="0 0 512 512">
 | 
			
		||||
          <path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z" />
 | 
			
		||||
        </svg>
 | 
			
		||||
      ),
 | 
			
		||||
      value: "ellipse",
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      icon: (
 | 
			
		||||
        // fa-long-arrow-alt-right
 | 
			
		||||
        <svg viewBox="0 0 448 512" className="rtl-mirror">
 | 
			
		||||
          <path d="M313.941 216H12c-6.627 0-12 5.373-12 12v56c0 6.627 5.373 12 12 12h301.941v46.059c0 21.382 25.851 32.09 40.971 16.971l86.059-86.059c9.373-9.373 9.373-24.569 0-33.941l-86.059-86.059c-15.119-15.119-40.971-4.411-40.971 16.971V216z" />
 | 
			
		||||
        </svg>
 | 
			
		||||
      ),
 | 
			
		||||
      value: "arrow",
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      icon: (
 | 
			
		||||
        // custom
 | 
			
		||||
        <svg viewBox="0 0 6 6">
 | 
			
		||||
          <line
 | 
			
		||||
            x1="0"
 | 
			
		||||
            y1="3"
 | 
			
		||||
            x2="6"
 | 
			
		||||
            y2="3"
 | 
			
		||||
            stroke={oc.black}
 | 
			
		||||
            strokeLinecap="round"
 | 
			
		||||
          />
 | 
			
		||||
        </svg>
 | 
			
		||||
      ),
 | 
			
		||||
      value: "line",
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      icon: (
 | 
			
		||||
        // fa-font
 | 
			
		||||
        <svg viewBox="0 0 448 512">
 | 
			
		||||
          <path d="M432 416h-23.41L277.88 53.69A32 32 0 0 0 247.58 32h-47.16a32 32 0 0 0-30.3 21.69L39.41 416H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h128a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16h-19.58l23.3-64h152.56l23.3 64H304a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h128a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zM176.85 272L224 142.51 271.15 272z" />
 | 
			
		||||
        </svg>
 | 
			
		||||
      ),
 | 
			
		||||
      value: "text",
 | 
			
		||||
    },
 | 
			
		||||
  ] as const;
 | 
			
		||||
export const SHAPES = [
 | 
			
		||||
  {
 | 
			
		||||
    icon: (
 | 
			
		||||
      // fa-mouse-pointer
 | 
			
		||||
      <svg viewBox="0 0 320 512" className="">
 | 
			
		||||
        <path d="M302.189 329.126H196.105l55.831 135.993c3.889 9.428-.555 19.999-9.444 23.999l-49.165 21.427c-9.165 4-19.443-.571-23.332-9.714l-53.053-129.136-86.664 89.138C18.729 472.71 0 463.554 0 447.977V18.299C0 1.899 19.921-6.096 30.277 5.443l284.412 292.542c11.472 11.179 3.007 31.141-12.5 31.141z" />
 | 
			
		||||
      </svg>
 | 
			
		||||
    ),
 | 
			
		||||
    value: "selection",
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    icon: (
 | 
			
		||||
      // fa-square
 | 
			
		||||
      <svg viewBox="0 0 448 512">
 | 
			
		||||
        <path d="M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48z" />
 | 
			
		||||
      </svg>
 | 
			
		||||
    ),
 | 
			
		||||
    value: "rectangle",
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    icon: (
 | 
			
		||||
      // custom
 | 
			
		||||
      <svg viewBox="0 0 223.646 223.646">
 | 
			
		||||
        <path d="M111.823 0L16.622 111.823 111.823 223.646 207.025 111.823z" />
 | 
			
		||||
      </svg>
 | 
			
		||||
    ),
 | 
			
		||||
    value: "diamond",
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    icon: (
 | 
			
		||||
      // fa-circle
 | 
			
		||||
      <svg viewBox="0 0 512 512">
 | 
			
		||||
        <path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z" />
 | 
			
		||||
      </svg>
 | 
			
		||||
    ),
 | 
			
		||||
    value: "ellipse",
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    icon: (
 | 
			
		||||
      // fa-long-arrow-alt-right
 | 
			
		||||
      <svg viewBox="0 0 448 512" className="rtl-mirror">
 | 
			
		||||
        <path d="M313.941 216H12c-6.627 0-12 5.373-12 12v56c0 6.627 5.373 12 12 12h301.941v46.059c0 21.382 25.851 32.09 40.971 16.971l86.059-86.059c9.373-9.373 9.373-24.569 0-33.941l-86.059-86.059c-15.119-15.119-40.971-4.411-40.971 16.971V216z" />
 | 
			
		||||
      </svg>
 | 
			
		||||
    ),
 | 
			
		||||
    value: "arrow",
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    icon: (
 | 
			
		||||
      // custom
 | 
			
		||||
      <svg viewBox="0 0 6 6">
 | 
			
		||||
        <line
 | 
			
		||||
          x1="0"
 | 
			
		||||
          y1="3"
 | 
			
		||||
          x2="6"
 | 
			
		||||
          y2="3"
 | 
			
		||||
          stroke={oc.black}
 | 
			
		||||
          strokeLinecap="round"
 | 
			
		||||
        />
 | 
			
		||||
      </svg>
 | 
			
		||||
    ),
 | 
			
		||||
    value: "line",
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    icon: (
 | 
			
		||||
      // fa-font
 | 
			
		||||
      <svg viewBox="0 0 448 512">
 | 
			
		||||
        <path d="M432 416h-23.41L277.88 53.69A32 32 0 0 0 247.58 32h-47.16a32 32 0 0 0-30.3 21.69L39.41 416H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h128a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16h-19.58l23.3-64h152.56l23.3 64H304a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h128a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zM176.85 272L224 142.51 271.15 272z" />
 | 
			
		||||
      </svg>
 | 
			
		||||
    ),
 | 
			
		||||
    value: "text",
 | 
			
		||||
  },
 | 
			
		||||
] as const;
 | 
			
		||||
 | 
			
		||||
export const shapesShortcutKeys = SHAPES.map((shape, index) => [
 | 
			
		||||
  shape.value[0],
 | 
			
		||||
 
 | 
			
		||||
@@ -164,11 +164,13 @@ function getSelectedElement(): ExcalidrawElement {
 | 
			
		||||
 | 
			
		||||
type HandlerRectanglesRet = keyof ReturnType<typeof handlerRectangles>;
 | 
			
		||||
function getResizeHandles() {
 | 
			
		||||
  const rects =
 | 
			
		||||
    handlerRectangles(getSelectedElement(), h.state.zoom, pointerType) as
 | 
			
		||||
    {
 | 
			
		||||
      [T in HandlerRectanglesRet]: [number, number, number, number];
 | 
			
		||||
    };
 | 
			
		||||
  const rects = handlerRectangles(
 | 
			
		||||
    getSelectedElement(),
 | 
			
		||||
    h.state.zoom,
 | 
			
		||||
    pointerType,
 | 
			
		||||
  ) as {
 | 
			
		||||
    [T in HandlerRectanglesRet]: [number, number, number, number];
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  const rv: { [K in keyof typeof rects]: [number, number] } = {} as any;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user