Skip to content

Commit

Permalink
Fix: persisted object lock
Browse files Browse the repository at this point in the history
  • Loading branch information
Akalanka47000 committed Dec 7, 2024
1 parent 08d7381 commit 47f42b4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
Changelog

# v3.1.1 [2024-12-07]

## Patch Release

### Fixes
- Fixed an issue where the image object lock attribute was not included in the data exported from the toolkit

---

# v3.1.0 [2024-12-05]

## Minor Release

### Features
- Adds a new event handler named `onImageHover` which is applicable in User mode

---

# v3.0.1 [2024-12-05]
Expand Down
5 changes: 3 additions & 2 deletions src/components/workspace/elements/image.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { forwardRef } from "react";
import { twMerge } from "tailwind-merge";
import { dataAttributes } from "@/constants";
import { IImage, ISTKProps } from "@/types";

export interface IImageProps extends IImage {
Expand All @@ -10,8 +11,7 @@ export interface IImageProps extends IImage {
}

const Image: React.FC<IImageProps> = forwardRef(

({ x, y, id, href, width, height, rotation, consumer, isSelected, element, ...props }, ref: any) => {
({ x, y, id, href, width, height, rotation, locked, consumer, isSelected, element, ...props }, ref: any) => {
const onMouseOver = (e: React.MouseEvent<SVGElement>) => {
if (consumer.mode === "user") {
consumer.events?.onImageHover?.(element, {
Expand All @@ -30,6 +30,7 @@ const Image: React.FC<IImageProps> = forwardRef(
width={width}
height={height}
{...props}
{...{ [dataAttributes.objectLock]: locked }}
className={twMerge(
"resizable fill-transparent object-cover",
isSelected && "outline outline-2 outline-blue-500 -outline-offset-2",
Expand Down
1 change: 1 addition & 0 deletions src/types/elements/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export interface IImage {
width?: number;
height?: number;
rotation?: number;
locked?: boolean;
}
3 changes: 2 additions & 1 deletion src/utils/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export const domImagesToJSON = () => {
width: +image.attr("width"),
height: +image.attr("height"),
href: image.attr("href"),
rotation: image.rotation()
rotation: image.rotation(),
locked: image.attr(dataAttributes.objectLock) === "true"
};
});
};
Expand Down

0 comments on commit 47f42b4

Please sign in to comment.