Skip to content

Commit

Permalink
Merge pull request #179 from dansreis/176-remove-rca_polygon-and-reta…
Browse files Browse the repository at this point in the history
…in-only-uuid

Removed 'RCA_POLYGON' from id
  • Loading branch information
dansreis authored Jun 28, 2024
2 parents af10750 + 43de5c4 commit 96173b4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/components/Board/Board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ const Board = React.forwardRef<BoardActions, BoardProps>(
onResetZoom?.();
},
retrieveObjectContent(id: string) {
const polygonId = fabricUtils.toPolygonId(id);
if (editor?.canvas) {
const obj = fabricUtils.findObjectByName(editor.canvas, polygonId);
const obj = fabricUtils.findObjectByName(editor.canvas, id);
return obj
? getObjectInfo(obj as fabricTypes.CustomObject).content ?? null
: null;
Expand All @@ -88,7 +87,7 @@ const Board = React.forwardRef<BoardActions, BoardProps>(
drawObject(type?: "rectangle" | "polygon") {
const isDrawing = !drawingObject?.isDrawing;
if (isDrawing) {
const polygonId = fabricUtils.toPolygonId(uuidv4());
const polygonId = uuidv4();
setDrawingObject({
id: polygonId,
type: type ?? "polygon",
Expand Down Expand Up @@ -571,7 +570,7 @@ const Board = React.forwardRef<BoardActions, BoardProps>(
fabric.Polygon,
scaledCoords,
{
name: fabricUtils.toPolygonId(item.id),
name: item.id,
stroke: item.color,
fill: `rgba(${parse(item.color).values.join(",")},${item.opacity ?? 0.4})`,
selectable: item.selectable ?? true,
Expand Down
4 changes: 0 additions & 4 deletions src/fabric/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,3 @@ export const getObjectHelperCoords = (obj: fabric.Object) => {
top: boundingRect.top + boundingRect.height,
};
};

export const toPolygonId = (id?: string) => {
return `RCA_POLYGON_${id}`;
};

0 comments on commit 96173b4

Please sign in to comment.