You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Actual issue is while unmounting react component which means closing the editor it trigger the component remove and component remove before event.
import { Component, Editor, PluginOptions } from "grapesjs";
import { EditorBase } from "../base";
import { storeElementNames } from "../../../constant";
import { StateManager } from "../../../store";
import { EmailEditorState } from "../../../types";
export class ComponentRemoved extends EditorBase {
state;
constructor(
editor: Editor,
_: PluginOptions,
state: StateManager<EmailEditorState>
) {
super(editor);
this.state = state;
editor.on("component:remove", (component: Component) => {
if (!component) return;
this.enabledStoreElement(component);
// this.removeDefaultTraits([]);
});
}
/** if the exists store element removed from the canvas then enabled the blocks */
enabledStoreElement(comp: Component) {
const storeElementName = comp.getAttributes()["store-element"];
if (storeElementName && storeElementNames.includes(storeElementName)) {
this.editor.BlockManager.get(storeElementName).set({
disable: false,
});
}
}
}
On the First Time Editor Loads the Plugin it Triggers and also if i am removing the component that time it trigger and even i am closing the editor it also trigger this component removing method
and also i am triggering component:remove directly in my closeHandler you may check below code
const closeHandler = () => {
const isCouponConfigured = editor?.Editor.runCommand(
'check-coupon-configured',
);
const path =
props.editorType === 'campaign'
? `/service/campaigns/edit/${params.broadcast_uuid}`
: -1;
const previousPage = location.state?.to || path;
if (!isCouponConfigured.isConfigured && isCouponConfigured.couponBlock) {
AlertToast({
icon: 'warning',
title: 'Configure Your Coupon',
text: 'It appears you have not configured the coupon block properly. Click on the “configure” button to set up the coupon. If left unconfigured, the customer will not get the coupon code in the email.',
cancelButtonText: 'Continue to edit',
showCancelButton: true,
reverseButtons: true,
customClass: {
title: '',
confirmButton: 'bg-danger',
},
confirmButtonText: 'Save and Close Anyway',
}).then(async res => {
if (res.isConfirmed) {
if (previousPage) {
navigate(previousPage);
} else {
navigate(-1);
}
} else if (res.dismiss || res.isDenied || res.isDismissed) {
if (isCouponConfigured.comp) {
editor.Editor.select(isCouponConfigured.comp);
}
}
});
} else {
navigate(previousPage);
}
};
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The Actual issue is while unmounting react component which means closing the editor it trigger the component remove and component remove before event.
On the First Time Editor Loads the Plugin it Triggers and also if i am removing the component that time it trigger and even i am closing the editor it also trigger this component removing method
and also i am triggering component:remove directly in my closeHandler you may check below code
Beta Was this translation helpful? Give feedback.
All reactions