Set Trailing Cmma to (#525)

This commit is contained in:
Lipis 2020-01-24 12:04:54 +02:00 committed by GitHub
parent 25202aec11
commit ee68af0fd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 352 additions and 350 deletions

View file

@ -13,7 +13,7 @@ const _ce = ({ x, y, w, h }: { x: number; y: number; w: number; h: number }) =>
x,
y,
width: w,
height: h
height: h,
} as ExcalidrawElement);
describe("getElementAbsoluteCoords", () => {
@ -29,14 +29,14 @@ describe("getElementAbsoluteCoords", () => {
it("test x2 coordinate if width is positive or zero", () => {
const [, , x2] = getElementAbsoluteCoords(
_ce({ x: 10, y: 0, w: 10, h: 0 })
_ce({ x: 10, y: 0, w: 10, h: 0 }),
);
expect(x2).toEqual(20);
});
it("test x2 coordinate if width is negative", () => {
const [, , x2] = getElementAbsoluteCoords(
_ce({ x: 10, y: 0, w: -10, h: 0 })
_ce({ x: 10, y: 0, w: -10, h: 0 }),
);
expect(x2).toEqual(10);
});
@ -53,14 +53,14 @@ describe("getElementAbsoluteCoords", () => {
it("test y2 coordinate if height is positive or zero", () => {
const [, , , y2] = getElementAbsoluteCoords(
_ce({ x: 0, y: 10, w: 0, h: 10 })
_ce({ x: 0, y: 10, w: 0, h: 10 }),
);
expect(y2).toEqual(20);
});
it("test y2 coordinate if height is negative", () => {
const [, , , y2] = getElementAbsoluteCoords(
_ce({ x: 0, y: 10, w: 0, h: -10 })
_ce({ x: 0, y: 10, w: 0, h: -10 }),
);
expect(y2).toEqual(10);
});

View file

@ -10,7 +10,7 @@ export function getElementAbsoluteCoords(element: ExcalidrawElement) {
element.width >= 0 ? element.x : element.x + element.width, // x1
element.height >= 0 ? element.y : element.y + element.height, // y1
element.width >= 0 ? element.x + element.width : element.x, // x2
element.height >= 0 ? element.y + element.height : element.y // y2
element.height >= 0 ? element.y + element.height : element.y, // y2
];
}

View file

@ -5,7 +5,7 @@ import {
getArrowPoints,
getDiamondPoints,
getElementAbsoluteCoords,
getLinePoints
getLinePoints,
} from "./bounds";
function isElementDraggableFromInside(element: ExcalidrawElement): boolean {
@ -15,7 +15,7 @@ function isElementDraggableFromInside(element: ExcalidrawElement): boolean {
export function hitTest(
element: ExcalidrawElement,
x: number,
y: number
y: number,
): boolean {
// For shapes that are composed of lines, we only enable point-selection when the distance
// of the click is less than x pixels of any of the lines that the shape is composed of
@ -95,7 +95,7 @@ export function hitTest(
bottomX,
bottomY,
leftX,
leftY
leftY,
] = getDiamondPoints(element);
if (isElementDraggableFromInside(element)) {

View file

@ -5,7 +5,7 @@ type Sides = "n" | "s" | "w" | "e" | "nw" | "ne" | "sw" | "se";
export function handlerRectangles(
element: ExcalidrawElement,
{ scrollX, scrollY }: SceneScroll
{ scrollX, scrollY }: SceneScroll,
) {
const elementX1 = element.x;
const elementX2 = element.x + element.width;
@ -24,14 +24,14 @@ export function handlerRectangles(
elementX1 + (elementX2 - elementX1) / 2 + scrollX - 4,
elementY1 - margin + scrollY + marginY,
8,
8
8,
];
handlers["s"] = [
elementX1 + (elementX2 - elementX1) / 2 + scrollX - 4,
elementY2 - margin + scrollY - marginY,
8,
8
8,
];
}
@ -40,14 +40,14 @@ export function handlerRectangles(
elementX1 - margin + scrollX + marginX,
elementY1 + (elementY2 - elementY1) / 2 + scrollY - 4,
8,
8
8,
];
handlers["e"] = [
elementX2 - margin + scrollX - marginX,
elementY1 + (elementY2 - elementY1) / 2 + scrollY - 4,
8,
8
8,
];
}
@ -55,31 +55,31 @@ export function handlerRectangles(
elementX1 - margin + scrollX + marginX,
elementY1 - margin + scrollY + marginY,
8,
8
8,
]; // nw
handlers["ne"] = [
elementX2 - margin + scrollX - marginX,
elementY1 - margin + scrollY + marginY,
8,
8
8,
]; // ne
handlers["sw"] = [
elementX1 - margin + scrollX + marginX,
elementY2 - margin + scrollY - marginY,
8,
8
8,
]; // sw
handlers["se"] = [
elementX2 - margin + scrollX - marginX,
elementY2 - margin + scrollY - marginY,
8,
8
8,
]; // se
if (element.type === "arrow" || element.type === "line") {
return {
nw: handlers.nw,
se: handlers.se
se: handlers.se,
} as typeof handlers;
}

View file

@ -3,7 +3,7 @@ export {
getElementAbsoluteCoords,
getDiamondPoints,
getArrowPoints,
getLinePoints
getLinePoints,
} from "./bounds";
export { handlerRectangles } from "./handlerRectangles";
@ -15,5 +15,5 @@ export { redrawTextBoundingBox } from "./textElement";
export {
getPerfectElementSize,
isInvisiblySmallElement,
resizePerfectLineForNWHandler
resizePerfectLineForNWHandler,
} from "./sizeHelpers";

View file

@ -16,7 +16,7 @@ export function newElement(
roughness: number,
opacity: number,
width = 0,
height = 0
height = 0,
) {
const element = {
id: nanoid(),
@ -33,7 +33,7 @@ export function newElement(
opacity,
isSelected: false,
seed: randomSeed(),
shape: null as Drawable | Drawable[] | null
shape: null as Drawable | Drawable[] | null,
};
return element;
}
@ -41,7 +41,7 @@ export function newElement(
export function newTextElement(
element: ExcalidrawElement,
text: string,
font: string
font: string,
) {
const metrics = measureText(text, font);
const textElement: ExcalidrawTextElement = {
@ -54,7 +54,7 @@ export function newTextElement(
y: element.y - metrics.height / 2,
width: metrics.width,
height: metrics.height,
baseline: metrics.baseline
baseline: metrics.baseline,
};
return textElement;

View file

@ -9,7 +9,7 @@ export function resizeTest(
element: ExcalidrawElement,
x: number,
y: number,
{ scrollX, scrollY }: SceneScroll
{ scrollX, scrollY }: SceneScroll,
): HandlerRectanglesRet | false {
if (!element.isSelected || element.type === "text") return false;
@ -36,7 +36,7 @@ export function resizeTest(
export function getElementWithResizeHandler(
elements: readonly ExcalidrawElement[],
{ x, y }: { x: number; y: number },
{ scrollX, scrollY }: SceneScroll
{ scrollX, scrollY }: SceneScroll,
) {
return elements.reduce((result, element) => {
if (result) {
@ -44,7 +44,7 @@ export function getElementWithResizeHandler(
}
const resizeHandle = resizeTest(element, x, y, {
scrollX,
scrollY
scrollY,
});
return resizeHandle ? { element, resizeHandle } : null;
}, null as { element: ExcalidrawElement; resizeHandle: ReturnType<typeof resizeTest> } | null);

View file

@ -10,7 +10,7 @@ export function isInvisiblySmallElement(element: ExcalidrawElement): boolean {
export function getPerfectElementSize(
elementType: string,
width: number,
height: number
height: number,
): { width: number; height: number } {
const absWidth = Math.abs(width);
const absHeight = Math.abs(height);
@ -33,7 +33,7 @@ export function getPerfectElementSize(
export function resizePerfectLineForNWHandler(
element: ExcalidrawElement,
x: number,
y: number
y: number,
) {
const anchorX = element.x + element.width;
const anchorY = element.y + element.height;

View file

@ -22,7 +22,7 @@ export function textWysiwyg({
y,
strokeColor,
font,
onSubmit
onSubmit,
}: TextWysiwygParams) {
// Using contenteditable here as it has dynamic width.
// But this solution has an issue — it allows to paste
@ -45,7 +45,7 @@ export function textWysiwyg({
padding: "4px",
outline: "transparent",
whiteSpace: "nowrap",
minHeight: "1em"
minHeight: "1em",
});
editable.onkeydown = ev => {

View file

@ -1,7 +1,7 @@
import { ExcalidrawElement, ExcalidrawTextElement } from "./types";
export function isTextElement(
element: ExcalidrawElement
element: ExcalidrawElement,
): element is ExcalidrawTextElement {
return element.type === "text";
}