Always bring modified item to front in canvas
This commit is contained in:
@@ -531,10 +531,6 @@ export const MediaEditor = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editMode !== EditMode.Text) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const obj = fabricCanvas.getActiveObject();
|
const obj = fabricCanvas.getActiveObject();
|
||||||
|
|
||||||
if (!obj || !(obj instanceof MediaEditorFabricIText)) {
|
if (!obj || !(obj instanceof MediaEditorFabricIText)) {
|
||||||
@@ -544,7 +540,7 @@ export const MediaEditor = ({
|
|||||||
obj.exitEditing();
|
obj.exitEditing();
|
||||||
obj.set(getTextStyleAttributes(textStyle, sliderValue));
|
obj.set(getTextStyleAttributes(textStyle, sliderValue));
|
||||||
fabricCanvas.requestRenderAll();
|
fabricCanvas.requestRenderAll();
|
||||||
}, [editMode, fabricCanvas, sliderValue, textStyle]);
|
}, [fabricCanvas, sliderValue, textStyle]);
|
||||||
|
|
||||||
// Create the CroppingRect
|
// Create the CroppingRect
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -601,6 +597,7 @@ export const MediaEditor = ({
|
|||||||
setCanCrop(false);
|
setCanCrop(false);
|
||||||
}, [editMode, fabricCanvas, imageState.height, imageState.width, zoom]);
|
}, [editMode, fabricCanvas, imageState.height, imageState.width, zoom]);
|
||||||
|
|
||||||
|
// Create an IText node when edit mode changes to Text
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!fabricCanvas) {
|
if (!fabricCanvas) {
|
||||||
return;
|
return;
|
||||||
|
@@ -15,6 +15,8 @@ export class MediaEditorFabricIText extends fabric.IText {
|
|||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
...options,
|
...options,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.on('modified', () => this.canvas?.bringToFront(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
static override fromObject(
|
static override fromObject(
|
||||||
|
@@ -19,6 +19,8 @@ export class MediaEditorFabricSticker extends fabric.Image {
|
|||||||
}
|
}
|
||||||
|
|
||||||
super(normalizedElement, options);
|
super(normalizedElement, options);
|
||||||
|
|
||||||
|
this.on('modified', () => this.canvas?.bringToFront(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
static fromObject(
|
static fromObject(
|
||||||
|
Reference in New Issue
Block a user