Skip to content

Commit

Permalink
fix /var/folders/t2/4cllrtnj2zj0nnf00mntbd800000gn/T/84f7e257721b90cf…
Browse files Browse the repository at this point in the history
…9382ad6991cd3917e33e9aca:66:6: ERROR - [JSC_BLOCK_SCOPED_DECL_MULTIPLY_DECLARED_ERROR] Block-scoped variable Rect declared more than once. First occurrence: externs.zip//w3c_css.js:858:9

  66| class Rect {
  • Loading branch information
potatowagon committed Jul 16, 2024
1 parent 0779336 commit 899fd35
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions packages/lexical-react/src/LexicalDraggableBlockPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
import {createPortal} from 'react-dom';

import {Point} from './shared/point';
import {Rect} from './shared/rect';
import {Rectangle} from './shared/rect';

const SPACE = 4;
const TARGET_LINE_HALF_HEIGHT = 2;
Expand Down Expand Up @@ -137,7 +137,7 @@ function getBlockElement(
}
const zoom = calculateZoomLevel(elem);
const point = new Point(event.x / zoom, event.y / zoom);
const domRect = Rect.fromDOM(elem);
const domRect = Rectangle.fromDOM(elem);
const {marginTop, marginBottom} = getCollapsedMargins(elem);
const rect = domRect.generateNewRect({
bottom: domRect.bottom + marginBottom,
Expand Down
30 changes: 15 additions & 15 deletions packages/lexical-react/src/shared/rect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type ContainsPointReturn = {
};
};

export class Rect {
export class Rectangle {
private readonly _left: number;
private readonly _top: number;
private readonly _right: number;
Expand Down Expand Up @@ -60,7 +60,7 @@ export class Rect {
return Math.abs(this._bottom - this._top);
}

public equals({top, left, bottom, right}: Rect): boolean {
public equals({top, left, bottom, right}: Rectangle): boolean {
return (
top === this._top &&
bottom === this._bottom &&
Expand All @@ -70,8 +70,8 @@ export class Rect {
}

public contains({x, y}: Point): ContainsPointReturn;
public contains({top, left, bottom, right}: Rect): boolean;
public contains(target: Point | Rect): boolean | ContainsPointReturn {
public contains({top, left, bottom, right}: Rectangle): boolean;
public contains(target: Point | Rectangle): boolean | ContainsPointReturn {
if (isPoint(target)) {
const {x, y} = target;

Expand Down Expand Up @@ -108,7 +108,7 @@ export class Rect {
}
}

public intersectsWith(rect: Rect): boolean {
public intersectsWith(rect: Rectangle): boolean {
const {left: x1, top: y1, width: w1, height: h1} = rect;
const {left: x2, top: y2, width: w2, height: h2} = this;
const maxX = x1 + w1 >= x2 + w2 ? x1 + w1 : x2 + w2;
Expand All @@ -123,36 +123,36 @@ export class Rect {
top = this.top,
right = this.right,
bottom = this.bottom,
}): Rect {
return new Rect(left, top, right, bottom);
}): Rectangle {
return new Rectangle(left, top, right, bottom);
}

static fromLTRB(
left: number,
top: number,
right: number,
bottom: number,
): Rect {
return new Rect(left, top, right, bottom);
): Rectangle {
return new Rectangle(left, top, right, bottom);
}

static fromLWTH(
left: number,
width: number,
top: number,
height: number,
): Rect {
return new Rect(left, top, left + width, top + height);
): Rectangle {
return new Rectangle(left, top, left + width, top + height);
}

static fromPoints(startPoint: Point, endPoint: Point): Rect {
static fromPoints(startPoint: Point, endPoint: Point): Rectangle {
const {y: top, x: left} = startPoint;
const {y: bottom, x: right} = endPoint;
return Rect.fromLTRB(left, top, right, bottom);
return Rectangle.fromLTRB(left, top, right, bottom);
}

static fromDOM(dom: HTMLElement): Rect {
static fromDOM(dom: HTMLElement): Rectangle {
const {top, width, left, height} = dom.getBoundingClientRect();
return Rect.fromLWTH(left, width, top, height);
return Rectangle.fromLWTH(left, width, top, height);
}
}

0 comments on commit 899fd35

Please sign in to comment.